aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2023-02-20gdb: revert one erroneous bool-ification changeSimon Marchi1-1/+1
Commit 42c13555ff88 ("Change value::m_stack to bool") erroneously changed a `0` to `false` in this call to read_value_memory. This parameter is `LONGEST bit_offset`, it should stay `0`. Change-Id: I128df6834cf8055ec6a7051e237e379978d3d651
2023-02-20gdb/doc: Consistency fixes for GDB/MI documentationAndrew Burgess1-27/+27
I noticed two inconsistencies in the GDB/MI documentation, which this commit addresses: 1. Each MI command is introduced like this: @subheading The @code{-command-name} Command Except for a few of the tracing command, which just use: @subheading -command-name In this commit I've updated all these trace commands to use the more common format. 2. Each MI command starts with a @subheading, and then the details of that command are split up using multiple @subsubheading entries. Except for a few commands which use @subheading for the top-level command, and then continue to use @subheading for each part of the command description. In this commit I've updated these to use @subsubheading where appropriate.
2023-02-20[gdb/symtab] Trust epilogue unwind info for unknown or non-gcc producerTom de Vries1-1/+7
Currently we only trust epilogue unwind info only for gcc >= 4.5.0. This has the effect that we don't trust epilogue unwind info for: - unknown producers (CU without DW_AT_producer attribute) - non-gcc producers (say, clang). Instead, only distrust epilogue unwind info only for gcc < 4.5.0.
2023-02-20[gdb/symtab] Trust epilogue unwind info for unknown producer (-g0 case)Tom de Vries3-2/+108
For a -g0 -fasynchronous-unwind-tables exec (without .debug_info but with .eh_frame section), start using the dwarf2 unwinder instead of the "amd64 epilogue override" unwinder, by returning true in compunit_epilogue_unwind_valid for cust == nullptr. This has effect both on the amd64 and i386 targets, but only add amd64 test-case gdb.base/unwind-on-each-insn-amd64-2.exp.
2023-02-20[gdb/tdep] Add amd64/i386 epilogue override unwindersTom de Vries2-14/+103
For amd64 the current frame-unwinders are: ... $ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwinders" The target architecture is set to "i386:x86-64". dummy DUMMY_FRAME dwarf2 tailcall TAILCALL_FRAME inline INLINE_FRAME python NORMAL_FRAME amd64 epilogue NORMAL_FRAME dwarf2 NORMAL_FRAME dwarf2 signal SIGTRAMP_FRAME amd64 sigtramp SIGTRAMP_FRAME amd64 prologue NORMAL_FRAME ... For a -g0 -fasynchronous-unwind-tables exec (without .debug_info but with .eh_frame section), we'd like to start using the dwarf2 unwinder instead of the "amd64 epilogue" unwinder, by returning true in compunit_epilogue_unwind_valid for cust == nullptr. But we'd run into the following problem for a -g0 -fno-asynchronous-unwind-tables (without .debug_info and .eh_frame section) exec: - the "amd64 epilogue" unwinder would not run (because compunit_epilogue_unwind_valid () == true) - the dwarf2 unwinder would also not run (because there's no .eh_frame info). Fix this by: - renaming the "amd64 epilogue" unwinder to "amd64 epilogue override", and - adding a fallback "amd64 epilogue" after the dwarf unwinders, while making sure that only one of the two is active. Likewise for i386. NFC. For amd64, this results in this change: ... $ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwinders" The target architecture is set to "i386:x86-64". dummy DUMMY_FRAME dwarf2 tailcall TAILCALL_FRAME inline INLINE_FRAME python NORMAL_FRAME -amd64 epilogue NORMAL_FRAME +amd64 epilogue override NORMAL_FRAME dwarf2 NORMAL_FRAME dwarf2 signal SIGTRAMP_FRAME +amd64 epilogue NORMAL_FRAME amd64 sigtramp SIGTRAMP_FRAME amd64 prologue NORMAL_FRAME ... And for i386: ... $ gdb -q -batch -ex "set arch i386" -ex "maint info frame-unwinders" The target architecture is set to "i386". dummy DUMMY_FRAME dwarf2 tailcall TAILCALL_FRAME iline INLINE_FRAME -i386 epilogue NORMAL_FRAME +i386 epilogue override NORMAL_FRAME dwarf2 NORMAL_FRAME dwarf2 signal SIGTRAMP_FRAME +i386 epilogue NORMAL_FRAME i386 stack tramp NORMAL_FRAME i386 sigtramp SIGTRAMP_FRAME i386 prologue NORMAL_FRAME ...
2023-02-20[gdb/tdep] Fix amd64/i386_stack_frame_destroyed_pTom de Vries2-15/+24
The use of compunit_epilogue_unwind_valid in both amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p is problematic, in the sense that the functions no longer match their documented behaviour. Fix this by moving the use of compunit_epilogue_unwind_valid to amd64_epilogue_frame_sniffer and i386_epilogue_frame_sniffer. No functional changes.
2023-02-20[gdb/symtab] Factor out compunit_epilogue_unwind_validTom de Vries3-6/+15
Factor out compunit_epilogue_unwind_valid from both amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p. No functional changes. Also add a comment in the new function about the assumption that in absence of producer information, epilogue unwind info is invalid. Approved-By: Tom Tromey <tom@tromey.com>
2023-02-20[gdb/testsuite] Add xfail case in gdb.python/py-record-btrace.expTom de Vries1-1/+6
I came across: ... gdb) PASS: gdb.python/py-record-btrace.exp: prepare record: stepi 100 python insn = r.instruction_history^M warning: Non-contiguous trace at instruction 1 (offset = 0x3e10).^M (gdb) FAIL: gdb.python/py-record-btrace.exp: prepare record: python insn = r.i\ nstruction_history ... I'm assuming it's the same root cause as for the already present XFAIL. Fix this by recognizing above warning in the xfail regexp. Tested on x86_64-linux, although sofar I was not able to trigger the warning again. Approved-By: Markus T. Metzger <markus.t.metzger@intel.com>
2023-02-20[gdb/testsuite] Fix gdb.threads/schedlock.exp for gcc 4.8.5Tom de Vries1-3/+2
Since commit 9af467b8240 ("[gdb/testsuite] Fix gdb.threads/schedlock.exp on fast cpu"), the test-case fails for gcc 4.8.5. The problem is that for gcc 4.8.5, the commit turned a two-line loop: ... (gdb) next 78 while (*myp > 0) (gdb) next 81 MAYBE_CALL_SOME_FUNCTION(); (*myp) ++; (gdb) next 78 while (*myp > 0) ... into a three-line loop: ... (gdb) next 83 MAYBE_CALL_SOME_FUNCTION(); (*myp) ++; (gdb) next 84 cnt++; (gdb) next 85 } (gdb) next 83 MAYBE_CALL_SOME_FUNCTION(); (*myp) ++; (gdb) ... and the test-case doesn't expect this. Fix this by reverting back to the original loop shape as much as possible by: - removing the cnt++ line - replacing "while (1)" with "while (one)", where one is a volatile variable set to 1. Tested on x86_64-linux, using compilers: - gcc 4.8.5, 7.5.0, 12.2.1 - clang 4.0.1, 13.0.1
2023-02-19Convert contained_in to methodTom Tromey8-22/+20
This converts contained_in to be a method of block.
2023-02-19Make block members 'private'Tom Tromey1-6/+6
This changes block to make the data members 'private'.
2023-02-19Remove allocate_block and allocate_global_blockTom Tromey5-35/+10
This removes allocate_block and allocate_global_block in favor of simply calling 'new'.
2023-02-19Have global_block inherit from blockTom Tromey2-8/+2
This changes global_block to inherit from block, which is what was always intended.
2023-02-19Use 'new' for block and global_blockTom Tromey2-14/+12
This changes block and global_block to add initializers, and then to use 'new' for allocation.
2023-02-19Fix memory leak in mdebugread.cTom Tromey1-10/+9
mdebugread.c allocates blocks on the heap. However, this is a memory leak if the corresponding objfile is ever destroyed. This patch changes this code to use allocate_block instead, fixing a FIXME from 2003. I don't know how to test this patch.
2023-02-19Remove ALL_BLOCK_SYMBOLSTom Tromey12-84/+35
This removes ALL_BLOCK_SYMBOLS in favor of foreach.
2023-02-19Remove ALL_BLOCK_SYMBOLS_WITH_NAMETom Tromey5-41/+13
This removes ALL_BLOCK_SYMBOLS_WITH_NAME in favor of foreach.
2023-02-19Convert explicit iterator uses to foreachTom Tromey3-17/+5
This converts most existing explicit uses of block_iterator to use foreach with the range iterator instead.
2023-02-19Introduce a block iterator wrapperTom Tromey1-0/+50
This introduces a C++-style iterator that wraps the existing block_iterator. It also adds a range adapter. These will be used in a later patch.
2023-02-19Combine both styles of block iteratorTom Tromey3-56/+32
This merges the two styles of block iterator, having the initialization API decide which to use based on an optional parameter.
2023-02-19Store 'name' in block_iteratorTom Tromey3-15/+19
This changes the block_iterator to store the 'name' that is used by block_iter_match_next. This avoids any problem where the name could be passed inconsistently, and also makes the subsequent patches easier to understand.
2023-02-19Convert block_static_link to methodTom Tromey3-16/+18
This converts block_static_link to be a method. This was mostly written by script.
2023-02-19Convert set_block_compunit_symtab to methodTom Tromey4-9/+10
This converts set_block_compunit_symtab to be a method. This was mostly written by script.
2023-02-19Convert block_static_block and block_global_block to methodsTom Tromey12-36/+43
This converts block_static_block and block_global_block to be methods. This was mostly written by script. It was simpler to convert them at the same time because they're often used near each other.
2023-02-19Convert block_containing_function to methodTom Tromey4-9/+13
This converts block_containing_function to be a method. This was mostly written by script.
2023-02-19Convert block_linkage_function to methodTom Tromey10-19/+22
This converts block_linkage_function to be a method. This was mostly written by script.
2023-02-19Convert more block functions to methodsTom Tromey13-76/+74
This converts block_scope, block_set_scope, block_using, and block_set_using to be methods. These are all done at once to make it easier to also convert block_initialize_namespace at the same time. This was mostly written by script.
2023-02-19Convert block_inlined_p to methodTom Tromey6-16/+18
This converts block_inlined_p to be a method. This was mostly written by script.
2023-02-19Convert block_gdbarch to methodTom Tromey6-12/+12
This converts block_gdbarch to be a method. This was mostly written by script.
2023-02-19Convert block_objfile to methodTom Tromey8-20/+20
This converts block_objfile to be a method. This was mostly written by script.
2023-02-19Don't allow NULL as an argument to block_global_blockTom Tromey3-14/+12
block_global_block has special behavior when the block is NULL. Remove this and patch up the callers instead.
2023-02-19Don't allow NULL as an argument to block_static_blockTom Tromey6-11/+30
block_static_block has special behavior when the block is NULL. Remove this and patch up the callers instead.
2023-02-19Don't allow NULL as an argument to block_usingTom Tromey1-1/+1
block_using has special behavior when the block is NULL. Remove this. No caller seems to be affected.
2023-02-19Don't allow NULL as an argument to block_scopeTom Tromey3-5/+6
block_scope has special behavior when the block is NULL. Remove this and patch up the callers instead.
2023-02-19Avoid extra allocations in blockTom Tromey1-0/+12
block_set_scope and block_set_using unconditionally allocate the block namespace object. However, this isn't truly needed, so arrange to only allocate when it is.
2023-02-19Rearrange block.c to avoid a forward declarationTom Tromey1-13/+10
Moving block_initialize_namespace before its callers lets us avoid a forward declaration.
2023-02-18Fix "start" for D, Rust, etcTom Tromey7-25/+159
The new DWARF indexer broke "start" for some languages. For D, it is broken because, while the code in cooked_index_shard::add specifically excludes Ada, it fails to exclude D. This means that the C "main" will be detected as "main" here -- whereas what is intended is for the code in find_main_name to use d_main_name to find the name. The Rust compiler, on the other hand, uses DW_AT_main_subprogram. However, the code in dwarf2_build_psymtabs_hard fails to create a fully-qualified name, so the name always ends up as plain "main". For D and Ada, a very simple approach suffices: remove the check against "main" from cooked_index_shard::add. This also has the benefit of slightly speeding up DWARF indexing. I assume this approach will work for Pascal and Modula-2 as well, but I don't have a way to test those at present. For Rust, though, this is not sufficient. And, computing the fully-qualified name in dwarf2_build_psymtabs_hard will crash, because cooked_index_entry::full_name uses the canonical name -- and that is not computed until after canonicalization. However, we don't want to wait for canonicalization to be done before computing the main name. That would remove any benefit from doing canonicalization is the background. This patch solves this dilemma by noticing that languages using DW_AT_main_subprogram are, currently, disjoint from languages requiring canonicalization. Because of this, we can add a parameter to full_name to let us avoid crashes, slowdowns, and races here. This is kind of tricky and ugly, so I've tried to comment it sufficiently. While doing this, I had to change gdb.dwarf2/main-subprogram.exp. A different possibility here would be to ignore the canonicalization needs of C in this situation, because those only affect certain types. However, I chose this approach because the test case is artificial anyhow. A long time ago, in an earlier threading attempt, I changed the global current_language to be a function (hidden behind a macro) to let us attempt lazily computing the current language. Perhaps this approach could still be made to work. However, that also seemed rather tricky, more so than this patch. Reviewed-By: Andrew Burgess <aburgess@redhat.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30116
2023-02-17Fix crash in go_symbol_package_nameTom Tromey3-2/+34
go_symbol_package_name package name asserts that it is only passed a Go symbol, but this is not enforced by one caller. It seems simplest to just check and return early in this case. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17876 Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-17Avoid manual memory management in go-lang.cTom Tromey4-30/+31
I noticed a couple of spots in go-lang.c that could be improved by using unique_ptr. Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-17gdb: fix regression in gdb.xml/maint_print_struct.expAndrew Burgess1-2/+7
A regression in gdb.xml/maint_print_struct.exp was introduced with commit: commit 81b86eced24f905545b58aa6c27478104c364976 Date: Fri Jan 6 09:30:40 2023 -0700 Do not record a rejected target description The test relied on an invalid target description being stored within the tdesc_info of the current inferior, the above commit stopped this behaviour. Update the test to check that the invalid architecture is NOT stored, and then check printing the target description directly from the file. Approved-By: Tom Tromey <tromey@adacore.com>
2023-02-17Fix multi-threaded debugging under AIXAditya Vidyadhar Kamath2-148/+239
Multi-threaded debugging using the libpthdebug debug interface is currently broken due to multiple issues. When debugging a single inferior, we were getting assertion failures in get_aix_thread_info as no tp->priv structure was allocated for the main thread. We fixed this by switching the main thread from a (pid, 0, 0) ptid_t to a (pid, 0, tid) ptid_t and allocaing the tp->priv structure in sync_threadlists. As a result, the switch_to_thread call in pdc_read_data could now fail since the main thread no longer uses (pid, 0, 0). So we replaced the call by only switching inferior_ptid, the current inferior, and the current address space (like proc-service.c). Add similar switching to pdc_write_data where it was missing completely. When debugging multiple inferiors, an additional set of problems prevented correct multi-threaded debugging: First of all, aix-thread.c used to have a number of global variables holding per-inferior information. We switched hese to a per-inferior data structure instead. Also, sync_threadlists was getting confused as we were comparing the list of threads returned by libpthdebug for *one* process with GDB's list of threads for *all* processes. Now we only use he GDB threads of the current inferior instead. We also skip calling pd_activate from pd_enable if that in_initial_library_scan flag is true for the current inferior. Finally, the presence of the thread library in any but the first inferior was not correctly detected due to a bug in solib-aix.c, where the BFD file name for shared library members was changed when the library was loaded for the first time, which caused the library to no longer be recognized by name when loaded a second time.
2023-02-17Remove two unnecessary returns in ada-lang.cTom Tromey1-10/+4
I found a couple of spots in ada-lang.c where a return follows a call to error. These are unnecessary because error never returns.
2023-02-17[gdb/testsuite] Simplify gdb.arch/amd64-disp-step-avx.expTom de Vries2-20/+6
On SLE-11, with glibc 2.11.3, I run into: ... (gdb) PASS: gdb.arch/amd64-disp-step-avx.exp: vex3: \ var128 has expected value after continue^M Continuing.^M ^M Program received signal SIGSEGV, Segmentation fault.^M 0x0000000000400283 in _exit (status=0) at \ ../sysdeps/unix/sysv/linux/_exit.c:33^M 33 ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.^M (gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: \ continue until exit at amd64-disp-step-avx ... This is not related to gdb, we get the same result by just running the exec. The problem is that the test-case: - calls glibc's _exit, and - uses -nostartfiles -static, putting the burden for any necessary initialization for calling glibc's _exit on the test-case itself. So, when we get to the second insn in _exit: ... 000000000040acb0 <_exit>: 40acb0: 48 63 d7 movslq %edi,%rdx 40acb3: 64 4c 8b 14 25 00 00 mov %fs:0x0,%r10 ... no glibc-related initialization is done, and we run into the segfault. Adding this (borrowed from __libc_start_main) in _start in the .S file is sufficient to fix it: ... .rept 200 nop + call __pthread_initialize_minimal .endr ... But that already doesn't compile with say glibc 2.31, and regardless I think this sort of fix is too fragile. We could of course fix this by simply not running to exit. But ideally we'd have an exec that doesn't segfault when you just run it. Alternatively, we could hand-code an _exit syscall and bypass glibc all together. But I'd rather fix this in a way that simplifies the test-case. Taking a step back, the -nostartfiles -static was added to address that the xmm registers were not zero at main (which AFAICT is a valid thing to happen). [ The change itself silently broke the test-case, needing further fixing by commit 40310f30a51 ("gdb: make gdb.arch/amd64-disp-step-avx.exp actually test displaced stepping"). ] Instead, simplify things by reverting to the original situation: - no -nostartfiles -static compilation flags, - no _start in the .S file, - use exit instead of _exit in the .S file, and fix the original problem by setting the xmm registers to zero rather than checking that they're zero. Now that we're no longer forcing -static, add nopie to the flags to prevent compilation failure with target board unix/-fPIE/-pie. Tested on x86_64-linux. PR testsuite/30132 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30132
2023-02-16Rename parameter of create_ada_exception_catchpointTom Tromey2-3/+3
create_ada_exception_catchpoint has a parameter named "disabled", but both its callers and callees use it to mean "enabled". This is confusing, so this patch renames the parameter.
2023-02-16Update the 'g' packet documentationTom Tromey1-10/+20
The 'g' packet documentation references a macro that no longer exists, and it also claims that the 'x' response for an unavailable register is limited to trace frames. This patch updates the documentation to reflect what I think is currently correct. Co-Authored-By: Pedro Alves <pedro@palves.net> Approved-By: Eli Zaretskii <eliz@gnu.org> Change-Id: I863baa3b9293059cfd4aa3d534602cbcb693ba87
2023-02-16Constify ada_main_nameTom Tromey2-3/+3
Unlike the other *_main_name functions, ada_main_name returns a non-const "char *". This is strange, though, because the caller should not in fact modify or free this pointer. This patch changes this function to constify its return type.
2023-02-16Remove unused declaration from ada-lang.hTom Tromey1-2/+0
I stumbled across this declaration in ada-lang.h. I don't know what function did, but it no longer exists, so remove the declaration. Tested by rebuilding.
2023-02-16gdb/doc: document MI -remove-inferior commandAndrew Burgess1-0/+34
Back in 2010 the -remove-inferior command was added in commit a79b8f6ea8c2, unfortunately this command was never added to the documentation. This commit addresses that oversight. Approved-By: Eli Zaretskii <eliz@gnu.org>
2023-02-15Return bool from more value methodsTom Tromey2-26/+26
There are several more value methods that currently return 'int' but that should return 'bool'. This patch updates these. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Have value::bits_synthetic_pointer return boolTom Tromey5-14/+14
This changes value::bits_synthetic_pointer to return bool and fixes up some fallout from this. Reviewed-By: Bruno Larsen <blarsen@redhat.com>