aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile/compile-loc2c.c
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2024-12-06 14:04:00 +0100
committerHannes Domani <ssbssa@yahoo.de>2024-12-06 14:04:04 +0100
commitb2682eade4db993bc8231007ba94aec4e4728c61 (patch)
treefab3f6098344cbdea331fabf92734d1ed66e9445 /gdb/compile/compile-loc2c.c
parenta3011beced048e66d200921b2a11c836fae31abf (diff)
downloadbinutils-b2682eade4db993bc8231007ba94aec4e4728c61.zip
binutils-b2682eade4db993bc8231007ba94aec4e4728c61.tar.gz
binutils-b2682eade4db993bc8231007ba94aec4e4728c61.tar.bz2
Reduce WOW64 code duplication
Currently we have duplicate code for each place where windows_thread_info::context is touched, since for WOW64 processes it has to do the equivalent with wow64_context instead. For example this code...: #ifdef __x86_64__ if (windows_process.wow64_process) { th->wow64_context.ContextFlags = WOW64_CONTEXT_ALL; CHECK (Wow64GetThreadContext (th->h, &th->wow64_context)); ... } else #endif { th->context.ContextFlags = CONTEXT_DEBUGGER_DR; CHECK (GetThreadContext (th->h, &th->context)); ... } ...changes to look like this instead: windows_process.with_context (th, [&] (auto *context) { context->ContextFlags = WindowsContext<decltype(context)>::all; CHECK (get_thread_context (th->h, context)); ... } The actual choice if context or wow64_context are used, is handled by this new function in windows_process_info: template<typename Function> auto with_context (windows_thread_info *th, Function function) { #ifdef __x86_64__ if (wow64_process) return function (th != nullptr ? th->wow64_context : nullptr); else #endif return function (th != nullptr ? th->context : nullptr); } The other parts to make this work are the templated WindowsContext class which give the appropriate ContextFlags for both types. And there are also overloaded helper functions, like in the case of get_thread_context here, call either GetThreadContext or Wow64GetThreadContext. According git log --stat, this results in 120 lines less code. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/compile/compile-loc2c.c')
0 files changed, 0 insertions, 0 deletions