aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-04-21Handle erroneous DW_AT_call_return_pcTom Tromey6-0/+90
On PPC64, with the test case included in an earlier patch, we found that "finish" would still not correctly find the return value via entry values. The issue is simple. The compiler emits: 0x00000000100032b8 <+28>: bl 0x1000320c <pck__create_large> 0x00000000100032bc <+32>: nop 0x00000000100032c0 <+36>: li r9,42 ... but the DWARF says: <162a> DW_AT_call_return_pc: 0x100032c0 That is, the declared return PC is one instruction past the actual return PC. This patch adds a new arch hook to handle this scenario, and implements it for PPC64. Some care is taken so that GDB will continue to work if this compiler bug is fixed. A GCC patch is here: https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613336.html No check for 'nop' is done, as subsequent discussion revealed that the linker might replace this with another instruction.
2023-04-21Handle function descriptors in call_site_targetTom Tromey5-1/+124
call_site_target::iterate_over_addresses may look up a minimal symbol. On platforms like PPC64 that use function descriptors, this may find an unexpected address. The fix is to use gdbarch_convert_from_func_ptr_addr to convert from a function descriptor to the address recorded at the call site. I've added a new test case that is based on the internal AdaCore test that provoked this bug. However, I'm unable to test it as-is on PPC64.
2023-04-21x86: drop (explicit) BFD64 dependency from disassemblerJan Beulich1-13/+4
get64() is unreachable when !BFD64 (due to a check relatively early in print_insn()). Let's avoid the associated #ifdef-ary (or else we should extend it to remove more dead code).
2023-04-21x86: drop use of setjmp() from disassemblerJan Beulich1-5/+0
With the longjmp() uses all gone, the setjmp() isn't necessary anymore either.
2023-04-21x86: change fetch error handling for get<N>()Jan Beulich1-133/+114
Make them return boolean and convert FETCH_DATA() uses to fetch_code(). With this no further users of FETCH_DATA() remain, so the macro and its backing function are dropped as well. Leave value types as they were for the helper functions, even if I don't think that beyond get64() use of bfd_{,signed_}vma is really necessary. With type change of "disp" in OP_E_memory(), change the 2nd parameter of print_displacement() to a signed type as well, though (eliminating the need for a local variable of signed type). This also eliminates the need for custom printing of '-' in Intel syntax displacement expressions. While there drop forward declarations which aren't really needed.
2023-04-21x86: change fetch error handling when processing operandsJan Beulich1-233/+276
Make the handler functions all return boolean and convert FETCH_DATA() uses to fetch_code().
2023-04-21x86: change fetch error handling in get_valid_dis386()Jan Beulich1-30/+26
Introduce a special error indicator node, for the sole (real) caller to recognize and act upon.
2023-04-21x86: change fetch error handling in ckprefix()Jan Beulich1-12/+20
Use a tristate (enum) return value type to be able to express all three cases which are of interest to the (sole) caller. This also allows doing away with the abuse of "rex_used".
2023-04-21x86: change fetch error handling in top-level functionJan Beulich1-13/+59
... and its direct helper get_sib(). Using setjmp()/longjmp() for fetch error handling is problematic, as per https://sourceware.org/pipermail/binutils/2023-March/126687.html. Start using more conventional error handling instead. Also introduce a fetch_modrm() helper, for subsequent re-use.
2023-04-21x86: move fetch error handling into a helper functionJan Beulich1-28/+35
... such that it can be used from other than the setjmp() error handling path. Since I'd like the function's parameter to be pointer-to-const, two other functions need respective constification then, too (along with needing to be forward-declared).
2023-04-21bfd: fix STRICT_PE_FORMAT buildJan Beulich1-3/+3
A semicolon was missing and "name" needs to be pointer-to-const. While adding "const" there, also add it for "sec".
2023-04-21RISC-V: Optimize relaxation of gp with max_alignment.Lifang Xia4-29/+149
This should be the first related issue, which posted in riscv-gnu-toolchain, https://github.com/riscv-collab/riscv-gnu-toolchain/issues/497 If the output sections are not between gp and the symbol, then their alignments shouldn't affect the gp relaxation. However, this patch improves this idea even more, it limits the range to the gp+-2k, which means only the output section which are in the [gp-2K, gp+2K) range need to be considered. Even if the output section candidates may be different for each relax passes, the symbol that can be relaxed ar this round will not be truncated at next round. That is because this round you can do relaxation which means that the section where the symbol is located is within the [gp-2K, gp+2K) range, so all the output section alignments between them should be considered. In other words, if the alignments between them may cause truncated, then we should already preserve the size and won't do the gp relaxation this time. This patch can resolve the github issue which mentioned above, and also passed all gcc/binutils regressions of riscv-gnu-toolchain, so should be worth and safe enough to commit. Originally, this patch also do the same optimization for the call relaxations, https://sourceware.org/pipermail/binutils/2022-October/123918.html But just in case there is something that has not been considered, we only deal with the gp relaxation at this time. bfd/ * elfnn-riscv.c (riscv_elf_link_hash_table): Added new bfd_vma, max_alignment_for_gp. It is used to record the maximum alignment of the output sections, which are in the [gp-2K, gp+2k) range. (riscv_elf_link_hash_table_create): Init max_alignment_for_gp to -1. (_bfd_riscv_get_max_alignment): Added new parameter, gp. If gp is zero, then all the output section alignments are possible candidates; Otherwise, only the output sections which are in the [gp-2K, gp+2K) range need to be considered. (_bfd_riscv_relax_lui): Called _bfd_riscv_get_max_alignment with the non-zero gp if the max_alignment_for_gp is -1. (_bfd_riscv_relax_pc): Likewise. (_bfd_riscv_relax_section): Record the first input section, so that we can reset the max_alignment_for_gp for each repeated relax passes. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/relax-max-align-gp.*: New testcase. It fails without this patch.
2023-04-21ld: add missing period after @xrefJan Beulich1-1/+1
At least older versions of one of the doc generation tools complain (warn) about it missing.
2023-04-21Keeping track of rs6000-coff archive element pointersAlan Modra3-113/+183
rs6000-coff archives use a linked list of file offsets, where each element points to the next element. The idea is to allow updating of large archives quickly without rewriting the whole archive. (binutils ar does not do this.) Unfortunately this is an easy target for fuzzers to create an archive that will cause ar or any other tool processing archives to hang. I'd implemented guards against pointing back to the previous element, but of course that didn't last long. So this patch implements a scheme to keep track of file offset ranges used by elements as _bfd_read_ar_hdr is called for each element. See the add_range function comment. I needed a place to stash the list, so chose the obvious artdata.tdata backend extension to archive's tdata, already used by xcoff. That involved a little cleanup, because while it would be possible to continue using different artdata.tdata for the big and small archives, it's nicer to use a union. If anyone is concerned this list of element ranges might grow large and thus significantly slow down the tools, adjacent ranges are merged. In fact something like "ar t" will only ever have one range on xcoff archives generated by binutils/ar. I agree there might still be a problem with ld random element access via the armap. include/ * coff/xcoff.h (SIZEOF_AR_FILE_HDR): Use sizeof. (SIZEOF_AR_FILE_HDR_BIG, SIZEOF_AR_HDR, SIZEOF_AR_HDR_BIG): Likewise. (struct ar_ranges, struct xcoff_artdata): New. (x_artdata): Define. (xcoff_big_format_p): Rewrite. (xcoff_ardata, xcoff_ardata_big): Delete. bfd/ * coff-rs6000.c: Replace uses of xcoff_ardata and xcoff_ardata_big throughout file. (_bfd_xcoff_archive_p): Adjust artdata.tdata allocation. (add_range): New function. (_bfd_xcoff_read_ar_hdr): Use it here. Fix memory leak. (_bfd_xcoff_openr_next_archived_file): Remove old sanity checks. Set up range for header. (xcoff_write_archive_contents_old): Make the temporary artdata.tdata used here to pass info down to _bfd_compute_and_write_armap a struct xcoff_artdata. (xcoff_write_archive_contents_big): Likewise. * coff64-rs6000.c: Replace uses of xcoff_ardata and xcoff_ardata_big throughout file. (xcoff64_archive_p): Adjust artdata.tdata allocation.
2023-04-21Delete struct artdata archive_headAlan Modra5-34/+1
This element is unused. Ideally we'd be moving archive_head and other archive specific fields from struct bfd to here, but that's a much larger change than this little bit of cleanup. * libbfd-in.h (struct artdata): Delete archive_head. * libbfd.h: Regenerate. * archive.c, * coff-rs6000.c, * coff64-rs6000.c: Delete comments mentioning artdata archive_head.
2023-04-21Automatic date update in version.inGDB Administrator1-1/+1
2023-04-20Add a SECURITY.txt file describing the GNU Binutils' project's stance on ↵Nick Clifton5-1/+84
security related bugs.
2023-04-20x86: adjust an ILP32 testcase using .insnJan Beulich1-1/+1
In commit 6967633c8b49 ("x86: convert testcases to use .insn") an ILP32 clone of a testcase was missed in the set of tests needing --divide added. Reported-by: Clément Chigot <chigot@adacore.com>
2023-04-20Automatic date update in version.inGDB Administrator1-1/+1
2023-04-20sh4-linux segfaults running ld testsuiteAlan Modra1-0/+2
Segmentation fault FAIL: pr22269-1 (static pie undefined weak) and others running "visibility (hidden undef)" tests No code has any right to access bfd_link_hash_entry u.def without first checking the type, and SYMBOL_REFERENCES_LOCAL isn't sufficient. * elf32-sh.c (sh_elf_finish_dynamic_symbol): Don't use relative relocs in GOT unless symbol is defined.
2023-04-20PR30343 infrastructureAlan Modra2-9/+10
Make ldemul_before_plugin_all_symbols_read more useful. * ldlang.c (lang_process): Move call to ldemul_before_plugin_all_symbols_read outside BFD_SUPPORTS_PLUGINS. Allow backends to add to gc_sym_list before handling entry sym. * ldelf.c (ldelf_before_plugin_all_symbols_read): Test lto_plugin_active.
2023-04-20ubsan: signed integer overflow in display_debug_lines_rawAlan Modra2-16/+17
This one was caused by me unnecessarily promoting an "int adv" to "int64_t adv". The expression overflowing was 4259 + 9223372036854775807 with the left number being unsigned int. * dwarf.h (DWARF2_Internal_LineInfo): Replace unsigned short with uint16_t and unsigned char with uint8_t. Make li_line_base an int8_t. * dwarf.c (display_debug_lines_raw): Revert "adv" back to an int.
2023-04-20Yet another out-of-memory fuzzed objectAlan Modra2-4/+15
Do I care about out of memory conditions triggered by fuzzers? Not much. Your operating system ought to be able to handle it by killing the memory hog. Oh well, this one was an element of a coff-alpha archive that said it was a little less that 2**64 in size. The coff-alpha compression scheme expands at most 8 times, so we can do better in bfd_get_file_size. * bfdio.c (bfd_get_file_size): Assume elements in compressed archive can only expand a maximum of eight times. * coffgen.c (_bfd_coff_get_external_symbols): Sanity check size of symbol table agains file size.
2023-04-20buffer overflow in print_symnameAlan Modra1-0/+6
* ecoff.c (_bfd_ecoff_slurp_symbolic_info): Zero terminate string sections.
2023-04-19libsframe: minor formatting fixes in sframe_encoder_write_freIndu Bhagat1-11/+7
libsframe/ * sframe.c (sframe_encoder_write_fre): Formatting fixes for readability.
2023-04-19libsframe: use consistent function argument namesIndu Bhagat1-14/+14
libsframe/ * sframe.c (sframe_decoder_get_header): Use consistent function arg names. (sframe_decoder_free): Likewise. (sframe_encode): Use more appropriate var name.
2023-04-19sframe: correct some typosIndu Bhagat2-3/+3
include/ * sframe.h: Correct a typo. libsframe/ * sframe.c: Likewise.
2023-04-19libsframe: use return type of bool for predicate functionsIndu Bhagat1-9/+9
libsframe/ * sframe.c (sframe_header_sanity_check_p): Change return type to bool. (sframe_fre_sanity_check_p): Likewise.
2023-04-19gas: sframe: fix commentIndu Bhagat1-1/+1
2023-04-19gas: sframe: use ATTRIBUTE_UNUSED consistentlyIndu Bhagat1-3/+3
gas/ * gen-sframe.c (sframe_set_version): Use ATTRIBUTE_UNUSED consistently. (output_sframe): Likewise. (sframe_set_fre_info): Remove the usage of ATTRIBUTE_UNUSED.
2023-04-19Remove adjust_type_signednessTom Tromey1-10/+0
I happened across adjust_type_signedness, which may be used to modify a type when printing an Ada value. Modifying a type like this is a bad idea -- they should normally be considered immutable. Removing this function still passes both the dejagnu and internal AdaCore tests, though, so this patch drops it. As this was reviewed internally, and only affect Ada, I am checking it in.
2023-04-19Fix: readelf: loc_offset XX too bigNick Clifton2-2/+9
PR 30355 * dwarf.c (read_and_display_attr_value): Correctly handle DW_loclistx attributes that index a version 5 .debug_loclists section.
2023-04-19gas: document that get_symbol_name() can clobber the input bufferJan Beulich1-5/+10
Callers which want to make further parsing attempts at the buffer passed to the function need to be aware that due to the potential of string concatenation the input buffer may be altered in ways beyond what can be undone by putting back at *input_line_pointer the character that the function returns.
2023-04-19x86: parse_register() must not alter the parsed stringJan Beulich1-13/+9
This reverts the code change done by 100f993c53a5 ("x86: Check unbalanced braces in memory reference"), which wrongly identified e87fb6a6d0cd ("x86/gas: support quoted address scale factor in AT&T syntax") as the root cause of PR gas/30248. (The testcase is left in place, no matter that it's at best marginally useful in that shape.) The problem instead is that parse_register() alters the string handed to it, thus breaking valid assumptions in subsequent parsing code. Since the function's behavior is a result of get_symbol_name()'s, make a copy of the incoming string before invoking that function. Like for parse_real_register() follow the model of strtol() et al: input string is const-qualified to signal that the string isn't altered, but the returned "end" pointer is not const-qualified, requiring const to be cast away (which generally is a bad idea, but the alternative would again be more convoluted code).
2023-04-19x86: parse_real_register() does not alter the parsed stringJan Beulich1-4/+4
Follow the model of strtol() et al - input string is const-qualified to signal that the string isn't altered, but the returned "end" pointer is not const-qualified, requiring const to be cast away (which generally is a bad idea, but the alternative would be more convoluted code).
2023-04-19Updated Hungarian translation for the gprof directoryNick Clifton2-44/+48
2023-04-19Automatic date update in version.inGDB Administrator1-1/+1
2023-04-18gdb: re-format Python code with black 23Simon Marchi2-2/+6
Change-Id: I849d10d69c254342bf01e955ffe62a2b60f9de4b
2023-04-18PowerPC: fix _Float128 type output stringCarl Love7-4/+120
PowerPC supports two 128-bit floating point formats, the IBM long double and IEEE 128-bit float. The issue is the DWARF information does not distinguish between the two. There have been proposals of how to extend the DWARF information as discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104194 but has not been fully implemented. GCC introduced the _Float128 internal type as a work around for the issue. The workaround is not transparent to GDB. The internal _Float128 type name is printed rather then the user specified long double type. This patch adds a new gdbarch method to allow PowerPC to detect the GCC workaround. The workaround checks for "_Float128" name when reading the base typedef from the die_info. If the workaround is detected, the type and format fields from the _Float128 typedef are copied to the long double typedef. The same is done for the complex long double typedef. This patch fixes 74 regression test failures in gdb.base/whatis-ptype-typedefs.exp on PowerPC with IEEE float 128 as the default on GCC. It fixes one regression test failure in gdb.base/complex-parts.exp. The patch has been tested on Power 10 where GCC defaults to IEEE Float 128-bit and on Power 10 where GCC defaults to the IBM 128-bit float. The patch as also been tested on X86-64 with no new regression failures.
2023-04-18Symbols with GOT relocatios do not fix adjustbalemengqinggang6-96/+122
gas * config/tc-loongarch.c (loongarch_fix_adjustable): Symbols with GOT relocatios do not fix adjustbale. * testsuite/gas/loongarch/macro_op_large_abs.d: Regenerated. * testsuite/gas/loongarch/macro_op_large_pc.d: Regenerated. ld * testsuite/ld-loongarch-elf/macro_op.d: Regenerated. -
2023-04-18Assembler Internal Docs: Describe handling of opcodes for relaxation a bit ↵Thomas Koenig2-3/+10
better.
2023-04-18RISC-V: Cache the latest mapping symbol and its boundary.Kito Cheng1-0/+43
This issue was reported from https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1188 Current flow: 1) Scan any mapping symbol less than this instruciton. 2) If not found, did a backward search. The flow seems not big issue, let run an example here: $x: 0x0 a <--- Found at step 1 0x4 b <--- Not found in step 1, but found at step 2 0x8 c <--- Not found in step 1, but found at step 2 $d 0x12 .word 1234 <-- Found at step 1 The instruciton didn't have the same address with mapping symbol will still did backward search again and again. So the new flow is: 1) Use the last mapping symbol status if the address is still within the range of the current mapping symbol. 2) Scan any mapping symbol less than this instruciton. 3) If not found, did a backward search. 4) If a proper mapping symbol is found in either step 2 or 3, find its boundary, and cache that. Use the same example to run the new flow again: $x: 0x0 a <--- Found at step 2, the boundary is 0x12 0x4 b <--- Cache hit at step 1, within the boundary. 0x8 c <--- Cache hit at step 1, within the boundary. $d 0x12 .word 1234 <-- Found at step 2, the boundary is the end of section. The disassemble time of the test cases has been reduced from ~20 minutes to ~4 seconds. opcode/ChangeLog PR 30282 * riscv-dis.c (last_map_symbol_boundary): New. (last_map_state): New. (last_map_section): New. (riscv_search_mapping_symbol): Cache the result of latest mapping symbol.
2023-04-18objdump use of uninitialised value in pr_string_fieldAlan Modra1-1/+2
PR 30365 * rdcoff.c (parse_coff_struct_type): Leave bitsize zero when no auxents.
2023-04-18objdump buffer overflow in fetch_indexed_stringAlan Modra1-13/+7
PR 30361 * dwarf.c (fetch_indexed_string): Sanity check string index.
2023-04-18Automatic date update in version.inGDB Administrator1-1/+1
2023-04-17gprofng: 30360 Seg. Fault when application uses std::threadVladimir Mezentsev6-94/+136
We interpose a lot of libC functions (dlopen, fork, pthread_create, etc.). Some of these functions have versions. For example, % nm -D /lib64/gprofng/libgp-collector.so | grep thread_create@ | sort 000000000004b420 T pthread_create@GLIBC_2.34 000000000004b490 T pthread_create@GLIBC_2.17 000000000004b500 T pthread_create@GLIBC_2.2.5 000000000004b570 T pthread_create@GLIBC_2.1 000000000004b5e0 T pthread_create@GLIBC_2.0 Our library does not set the default version for symbols. This is correct because we don't know which libC will be used. gcc and g++ links differently the version symbols when the default version is not set. c-linker is using our pthread_create@GLIBC_2.34 and c++-linker is using our pthread_create@GLIBC_2.0 by default. The current implementation of the interposed functions is: If we are in our pthread_create@GLIBC_<NN>, we use dlvsym (dlflag, "pthread_create", "GLIBC_<NN>") to find and call the same function from libC. In the test from PR 30360, pthread_create@GLIBC_2.0 is not in the current libC. We need to call the default version symbol from libC. gprofng/ChangeLog 2023-04-16 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR gprofng/30360 * libcollector/iotrace.c: Find and call a default libC version symbol. * libcollector/dispatcher.c: Likewise. * libcollector/iotrace.c: Likewise. * libcollector/linetrace.c: Likewise. * libcollector/mmaptrace.c: Likewise. * libcollector/synctrace.c: Likewise. * libcollector/collector.h (REAL_DCL): Remove an unused argument.
2023-04-17gprofng: Update documentationVladimir Mezentsev15-3761/+6291
This patch addresses bugzilla 29521: Bug 29521 - [docs] man pages are not in the release tarball The dependence on help2man to create the man pages has been eliminated. All man pages are now written in Texinfo. Texi2pod and pod2man are used to generate the man pages from the source. The user guide has been significantly expanded. It also includes all the man pages. These are formatted appropriately in the INFO, PDF, and HTML formats. The index in the user guide has been enhanced to include an overview of all options and commands that have been documented so far. The work on the documentation has not been completed, but this is a significant step forward. gprofng/ChangeLog 2023-04-15 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR gprofng/29521 * doc/Makefile.am: Build documentation. * doc/gprofng.texi: Update documentation. * doc/version.texi: Likewise. * src/Makefile.am: Move the man pages generation to doc/Makefile.am. * gp-display-html/Makefile.am: Likewise. * doc/gp-archive.texi: New file. * doc/gp-collect-app.texi: New file. * doc/gp-display-html.texi: New file. * doc/gp-display-src.texi: New file. * doc/gp-display-text.texi: New file. * doc/gp-macros.texi: New file. * doc/gprofng_ug.texi: New file. * doc/Makefile.in: Rebuild. * gp-display-html/Makefile.in: Rebuild. * src/Makefile.in" Rebuild.
2023-04-17Remove some unnecessary casts from ada-lang.cTom Tromey1-7/+6
I noticed some unnecessary casts to LONGEST in ada-lang.c. This patch removes the ones I think are very clearly not needed. I'm checking this in as obvious.
2023-04-17gdb/amdgpu: add follow fork and exec supportSimon Marchi7-0/+380
Prior to this patch, it's not possible for GDB to debug GPU code in fork children or after an exec. The amd-dbgapi target attaches to processes when an inferior appears due to a "run" or "attach" command, but not after a fork or exec. This patch adds support for that, such that it's possible to for an inferior to fork and for GDB to debug the GPU code in the child. To achieve that, use the inferior_forked and inferior_execd observers. In the case of fork, we have nothing to do if `child_inf` is nullptr, meaning that GDB won't debug the child. We also don't attach if the inferior has vforked. We are already attached to the parent's address space, which is shared with the child, so trying to attach would cause problems. And anyway, the inferior can't do anything other than exec or exit, it certainly won't start GPU kernels before exec'ing. In the case of exec, we detach from the exec'ing inferior and attach to the following inferior. This works regardless of whether they are the same or not. If they are the same, meaning the execution continues in the existing inferior, we need to do a detach/attach anyway, as amd-dbgapi needs to be aware of the new address space created by the exec. Note that we use observers and not target_ops::follow_{fork,exec} here. When the amd-dbgapi target is compiled in, it will attach (in the amd_dbgapi_process_attach sense, not the ptrace sense) to native inferiors when they appear, but won't push itself on the inferior's target stack just yet. It only pushes itself if the inferior initializes the ROCm runtime. So, if a non-GPU-using inferior calls fork, an amd_dbgapi_target::follow_fork method would not get called. Same for exec. A previous version of the code had the amd-dbgapi target pushed all the time, in which case we could use the target methods. But we prefer having the target pushed only when necessary, it's less intrusive when doing native debugging that doesn't involve the GPU. Change-Id: I5819c151c371120da8bab2fa9cbfa8769ba1d6f9 Reviewed-By: Pedro Alves <pedro@palves.net>
2023-04-17gdb: switch to right inferior in fetch_inferior_eventSimon Marchi1-3/+7
The problem explained and fixed in the previous patch could have also been fixed by this patch. But I think it's good change anyhow, that could prevent future bugs, so here it is. fetch_inferior_event switches to an arbitrary (in practice, the first) inferior of the process target of the inferior used to fetch the event. The idea is that the event handling code will need to do some target calls, so we want to switch to an inferior that has target target. However, you can have two inferiors that share a process target, but with one inferior having an additional target on top: inf 1 inf 2 ----- ----- another target process target process target exec exec Let's say inferior 2 is selected by do_target_wait and returns an event that is really synthetized by "another target". This "another target" could be a thread or record stratum target (in the case explained by the previous patch, it was the arch stratum target, but it's because the amd-dbgapi abuses the arch layer). fetch_inferior_event will then switch to the first inferior with "process target", so inferior 1. handle_signal_stop then tries to fetch the thread's registers: ecs->event_thread->set_stop_pc (regcache_read_pc (get_thread_regcache (ecs->event_thread))); This will try to get the thread's register by calling into the current target stack, the stack of inferior 1. This is problematic because "another target" might have a special fetch_registers implementation. I think it would be a good idea to switch to the inferior for which the even was reported, not just some inferior of the same process target. This will ensure that any target call done before we eventually call context_switch will be done on the full target stack that reported the event. Not all events are associated to an inferior though. For instance, TARGET_WAITKIND_NO_RESUMED. In those cases, some targets return null_ptid, some return minus_one_ptid (ideally the expected return value should be clearly defined / documented). So, if the ptid returned is either of these, switch to an arbitrary inferior with that process target, as before. Change-Id: I1ffc8c1095125ab591d0dc79ea40025b1d7454af Reviewed-By: Pedro Alves <pedro@palves.net>