aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2024-08-22[gdb] Eliminate catch(...) in get_test_insnTom de Vries1-1/+1
In get_test_insn in gdb/disasm-selftests.c, we find this code: ... try { kind = gdbarch_breakpoint_kind_from_pc (gdbarch, &pc); insn = gdbarch_sw_breakpoint_from_kind (gdbarch, kind, &bplen); } catch (...) { continue; } ... The catch is there to catch memory errors, but it swallows all exceptions, including gdb_exception_quit and gdb_exception_forced_quit. Fix this by limiting the catch to gdb_exception_error. Tested on x86_64-linux, by rebuilding and running gdb.gdb/unittest.exp. Approved-By: Tom Tromey <tom@tromey.com>
2024-08-21gdb: some global_block improvementsSimon Marchi4-64/+68
Some refactors around struct global_block, all in one patch because they all tie in together and are relatively trivial. - Make block::global_block() and blockvector::global_block() return `global_block *`, instead of `block *`. There is no cost in doing so, and it's a bit more precise. Callers of these methods that need a `global_block *` won't need to cast themselves. - Add some block::as_global_block methods, as a way to get a `global_block *` from a `block *` when you know it's a global block. This is basically a static cast with an assert. - Move set_compunit_symtab to global_block, since it requires the block to be a global block anyway. Rename to just `set_compunit` (I think that compunit_symtab should just be renamed compunit...). - Move the get_block_compunit_symtab free function to be a method of global_block. - Make global_block::compunit_symtab private and rename. - Simplify initialize_block_iterator. Change-Id: I1667a86b5c1a02d0d460cfad55b5d3d48867583d Approved-By: Tom Tromey <tom@tromey.com>
2024-08-21Do not assume ELF in dwarf2/read.cTom Tromey1-5/+4
dwarf2/read.c has this code: else if (elf_section_data (sectp)->this_hdr.sh_size > bfd_get_file_size (abfd)) This assumes that the BFD is an ELF, which is an invalid assumption. A user noticed that this can sometimes cause a crash. This patch fixes the problem by changing this code to use bfd_section_size_insane. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32104 Reviewed-By: Tom de Vries <tdevries@suse.de> Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-20gdb/testsuite: track nested caching proc callsAndrew Burgess1-9/+75
It was pointed out in this email: https://inbox.sourceware.org/gdb-patches/97973506-79f4-4216-9c0b-57401b3933f5@arm.com that this commit: commit 0726729d344fecf98f8d138e688e77201cc3cece Date: Mon Jun 3 13:56:54 2024 +0100 gdb/testsuite: track if a caching proc calls gdb_exit or not had broken some AArch64 tests. What is going on is that there are two caching procs: allow_aarch64_sme_tests aarch64_initialize_sme_information the allow_aarch64_sme_tests proc makes a call to aarch64_initialize_sme_information, but aarch64_initialize_sme_information is also called from other non-caching procs, like aarch64_supports_sme_svl. Both of the caching procs mentioned above compile and run a helper program, and both of them call gdb_exit. After the above commit, the first call to any caching proc, the body of which calls gdb_exit, will result in a gdb_exit call even if the body is not executed and the result is fetched from the cache. What was observed is that in the first test script allow_aarch64_sme_tests is called, the body of this caching proc is run which calls gdb_exit. Then allow_aarch64_sme_tests calls aarch64_initialize_sme_information, the body of which is run and gdb_exit is called again. The results from both procs are added to the cache. In the next test script allow_aarch64_sme_tests is called. This results in a cache hit, but gdb_exit is also called as this is the first call in this second test script. Later in the test script aarch64_supports_sme_svl is called which calls aarch64_initialize_sme_information. As this is the first call to aarch64_initialize_sme_information in this second test script (remember the body of allow_aarch64_sme_tests was never run) then gdb_exit is called. This call to gdb_exit is new after the above commit and is unexpected. I think the idea behind the above commit is still sound. If the call to allow_aarch64_sme_tests was removed from the second test script then we would want the extra gdb_exit call as this would expose a real bug in the test. The problem is that after the above commit the nested nature of the caching proc calls becomes important: a call to allow_aarch64_sme_tests should mean that we've also called aarch64_initialize_sme_information, and that relationship isn't currently captured. So in this commit I'm adding another field to the global gdb_data_cache (in lib/cache.exp). This new field is 'also_called'. For every caching proc we populate this field with a list of names, these are the names of any nested caching procs that are called when the body of a caching proc is executed. Now when we get a cache hit in gdb_data_cache we mark every proc in the 'also_called' list as having been called. This means that further calls to these procs will no longer trigger a gdb_exit call. Approved-By: Luis Machado <luis.machado@arm.com> Tested-By: Luis Machado <luis.machado@arm.com>
2024-08-20Fix Windows regressionTom Tromey1-1/+1
commit cb9f919f ("gdb: add program_space parameter to lookup_minimal_symbol_text") caused a crash on Windows. In this function, section can be nullptr, but it is unconditionally dereferenced by the change introduced by the patch. I tested this using the AdaCore internal test suite. v2: always use current_program_space, reverting to be behavior before cb9f919f. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-20Use SEARCH_FUNCTION_DOMAIN when looking for Ada exception symbolsTom Tromey1-2/+4
While working on another bug, I noticed that the Ada code to find exception symbols uses SEARCH_VFT. This will find variables and types -- but only functions are needed here. This patch changes the code to use SEARCH_FUNCTION_DOMAIN. Tested on x86-64 Fedora 38, using a version of GNAT with the debuginfo installed, to ensure the exception-related tests work. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-20[gdb/testsuite] Fix gdb.python/py-mi-cmd.exp with python 3.13Tom de Vries1-7/+41
When running test-case gdb.python/py-mi-cmd.exp with python 3.13, I run into: ... Expecting: ^(-pycmd exp[^M ]+)?(.*&"Traceback \(most recent call last\):.."^M &"[^^M ]+py-mi-cmd.py[^^M ]+"^M &"[^^M ]+raise gdb.GdbError\(\).."^M &"gdb.GdbError.."^M \^error,msg="Error occurred in Python\."[^M ]+[(]gdb[)] ^M [ ]*) -pycmd exp^M &"Traceback (most recent call last):\n"^M &" File \"py-mi-cmd.py\", line 76, in invoke\n raise gdb.GdbError()\n"^M &"gdb.GdbError\n"^M ^error,msg="Error occurred in Python."^M (gdb) ^M FAIL: gdb.python/py-mi-cmd.exp: -pycmd exp (unexpected output) ... In contrast, with python 3.12 I have: ... Expecting: ^(-pycmd exp[^M ]+)?(.*&"Traceback \(most recent call last\):.."^M &"[^^M ]+py-mi-cmd.py[^^M ]+"^M &"[^^M ]+raise gdb.GdbError\(\).."^M &"gdb.GdbError.."^M \^error,msg="Error occurred in Python\."[^M ]+[(]gdb[)] ^M [ ]*) -pycmd exp^M &"Traceback (most recent call last):\n"^M &" File \"py-mi-cmd.py\", line 76, in invoke\n"^M &" raise gdb.GdbError()\n"^M &"gdb.GdbError\n"^M ^error,msg="Error occurred in Python."^M (gdb) ^M PASS: gdb.python/py-mi-cmd.exp: -pycmd exp ... To make it easier to understand what we're looking at, let's take this out of the mi interpreter context and use the cli interpreter: ... $ gdb -q -batch -ex "set trace-commands on" -x gdb.in +set python print-stack full +source py-mi-cmd.py +python pycmd1('-pycmd') +python pycmd1.invoke (pycmd1, ["exp"]) Traceback (most recent call last): File "<string>", line 1, in <module> File "py-mi-cmd.py", line 76, in invoke raise gdb.GdbError() gdb.GdbError gdb.in:4: Error in sourced command file: Error occurred in Python. ... Interestingly, this is what we're seeing with both python 3.12 and 3.13. The difference between the python versions is that: - with python 3.12 each line is printed by itself, and - with python 3.13 two particular lines are printed toghether. With the cli interpreter, that makes no difference, because the '\n' is interpreted. But with the mi interpreter, that causes a difference in output because the '\n' is not interpreted, but rather printed literally. Fix this by accepting the new output in addition to the old one. Tested on aarch64-linux. Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org> PR testsuite/31913 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31913
2024-08-19Fix m68k OS ABI snifferAndreas Schwab1-2/+10
Do not override the generic OS ABI sniffer. Fixes: 3eba3a011a8 ("Various m68k fixes for gdb")
2024-08-19Ensure gdb.ada/multiarray.exp runs in both modesTom Tromey1-1/+2
gdb.ada/multiarray.exp has a loop that looks like it should run the test in both 'all' and 'minimal' encodings mode. However, the body of the loop doesn't actually use the 'flags' variable. This was an oversight in the original commit.
2024-08-19gdb: fix a target: prefix issue in find_separate_debug_fileAndrew Burgess2-35/+7
Following on from the previous commit, this commit fixes the two KFAIL in gdb.base/sysroot-debug-lookup.exp when not using the native-extended-gdbserver board. The failures in this test, when using the 'unix' board, are logged as bug PR gdb/31804. The problem appears to be caused by the use of the child_path function in find_separate_debug_file. What happens on the 'unix' board is that the file is specified to GDB with a target: prefix, however GDB spots that the target filesystem is local to GDB and so opens the file without a target: prefix. When we call into find_separate_debug_file the DIR and CANON_DIR arguments, which are computed from the objfile_name() no longer have a target: prefix. However, in this test if the file was opened with a target: prefix, then the sysroot also has a target: prefix. When child_path is called it looks for a common prefix between CANON_DIR (from the objfile_name) and the sysroot. However, the sysroot still has the target: prefix, which means the child_path() call fails and returns nullptr. What I think we need to do is this: if the sysroot has a target: prefix, and the target filesystem is local to GDB, then we should strip the target: prefix from the sysroot, just as we do when opening a file (see gdb_bfd_open in gdb_bfd.c). Now, when we make the child_path() call neither the sysroot nor CANON_DIR will have a target: prefix, the child_path() call will succeed, and GDB will correctly find the debug information. There is just one remaining issue, the last path we look in when searching for debug information is built by starting with the sysroot, then adding the debug directory, see this line: debugfile = path_join (target_prefix_str, root.c_str (), debugdir.get (), base_path, debuglink); The target_prefix_str is set to target: if DIR has a target: prefix, and DIR should have a target: prefix if the file we're looking for was opened with a target: prefix. However, in our case the file was in a local filesystem so GDB stripped the prefix off. The sysroot however, does have the target: prefix, and the test is expecting to see GDB look within a file with the target: prefix. Given that the above line is about looking within a sub-directory of the sysroot, I think we should not be stripping the target: prefix off the sysroot path (as we do when building ROOT), instead, we should, in this case, not use TARGET_PREFIX_STR, and instead just use GDB's sysroot as it is (in this case with the target: prefix). With these fixes in place I now see no failures when using the 'unix', 'native-gdbserver', or 'native-extended-gdbserver' boards with this test, and the KFAILs can be removed. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31804
2024-08-19gdb: avoid '//' in filenames when searching for debuginfoAndrew Burgess2-30/+17
I spotted that the gdb.base/sysroot-debug-lookup.exp test that I added recently actually had a KPASS when run with the native-extended-gdbserver board. This was an oversight when adding the test. The failures in this test, when using the 'unix' board, are logged as bug PR gdb/31804. The problem appears to be caused by the use of the child_path function in find_separate_debug_file. What happens on the 'unix' board is that the file is specified to GDB with a target: prefix, however GDB spots that the target filesystem is local to GDB and so opens the file without a target: prefix. When we call into find_separate_debug_file the DIR and CANON_DIR arguments, which are computed from the objfile_name() no longer have a target: prefix. However, in this test if the file was opened with a target: prefix, then the sysroot also has a target: prefix. When child_path is called it looks for a common prefix between CANON_DIR (from the objfile_name) and the sysroot. However, the sysroot still has the target: prefix, which means the child_path() call fails and returns nullptr. What happens in the native-extended-gdbserver case is that GDB doesn't see the target filesystem as local. Now the filename retains the target: prefix, which means that in the child_path() call both the sysroot and the CANON_DIR have a target: prefix, and so the child_path() call succeeds. This allows GDB to progress, try some additional paths, and then find the debug information. So, this commit changes gdb.base/sysroot-debug-lookup.exp to expect the test to succeed when using the native-extended-gdbserver protocol. This leaves one KFAIL when using the native-extended-gdbserver board, we find the debug information but (apparently) find it in the wrong file. What's happening is that when GDB builds the filename for the debug information we end up with a '//' string as a directory separator, the test regexp only expects a single separator. Instead of just fixing the test regexp, I've updated the path_join function in gdbsupport/pathstuff.{cc,h} to allow for absolute paths to appear in the argument list after the first argument. This means it's now possible to do this: auto result = path_join ("/a/b/c", "/d/e/f"); gdb_assert (result == "/a/b/c/d/e/f"); Additionally I've changed path_join so that it avoids adding unnecessary directory separators. In the above case when the two paths were joined GDB only added a single separator between 'c' and 'd'. But additionally, if we did this: auto result = path_join ("/a/b/c/", "/d/e/f"); gdb_assert (result == "/a/b/c/d/e/f"); We'd still only get a single separator. With these changes to path_join I can now make use of this function in find_separate_debug_file. With this done I now have no KFAIL when using the native-extended-gdbserver board. After this commit we still have 2 KFAIL when not using the native-gdbserver and unix boards, these will be addressed in the next commit. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31804 Reviewed-By: Keith Seitz <keiths@redhat.com>
2024-08-19gdb: Fix printing frame when reversing out of a recursive call with clangGuinevere Larsen1-1/+2
Commit bf2813aff8f2988ad3d53e819a0415abf295c91f introduced some logic to not refresh the step frame id if it detects that the inferior is reverse stepping out of a recursive call, so that we would still print frame information once the inferior stops. However, that logic was overly specific, and wouldn't be hit for inferiors compiled with clang because clang adds line table entries that aren't statements, making process_event_stop_test go through a different branch on the relevant if statement. Fix this by not making the code that detects "reversing out of a recursion" an else clause to the previous if, but a standalone if block. Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-08-18[gdb] Prune inferior after switching inferiorTom de Vries2-26/+9
Usually with test-case gdb.python/py-progspace-events.exp I get: ... (gdb) inferior 1^M [Switching to inferior 1 [process 4116] (py-progspace-events)]^M [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 4116))]^M 28 { /* Nothing. */ }^M (gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1 step^M FreeProgspaceEvent: <gdb.Progspace object at 0xabf4f850>^M do_parent_stuff () at py-progspace-events.c:41^M 41 ++global_var;^M (gdb) PASS: gdb.python/py-progspace-events.exp: step ... But occasionally I run into the following FAIL: ... (gdb) inferior 1^M [Switching to inferior 1 [process 5199] (py-progspace-events)]^M [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M 28 { /* Nothing. */ }^M (gdb) FreeProgspaceEvent: <gdb.Progspace object at 0xabaf03a0>^M FAIL: gdb.python/py-progspace-events.exp: inferior 1 (timeout) ... This is caused by a race between the handling of an event, and the "inferior 1" command. In the passing case, the event is handled first. During which prune_inferiors is called, but it can't remove inferior 2, because it's still the current one. In the failing case, the "inferior 1" command is handled first. Then during handling of the event, prune_inferiors is called, and it can remove inferior 2 because it's no longer the current one. This looks like a test-case issue to me, but ISTM that we can do better: by calling prune_inferiors asap, at the end of the "inferior 1" command, we stabilize the moment when the inferior is removed: ... (gdb) inferior 1^M [Switching to inferior 1 [process 5199] (py-progspace-events)]^M [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M 28 { /* Nothing. */ }^M FreeProgspaceEvent: <gdb.Progspace object at 0xabaf03a0>^M (gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1 ... This also allows us to simplify the test-case by removing the step command, which is no longer required to trigger the pruning of the inferior. Tested on x86_64-linux. Approved-by: Kevin Buettner <kevinb@redhat.com> PR gdb/31440 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31440
2024-08-16Fix DAP failure when fetching global variablesTom Tromey3-1/+105
The relatively new "globals" scope code in DAP has a fairly obvious bug -- the fetch_one_child method should return a tuple with two elements, but instead just returns the variable's value. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32029 Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-08-16[gdb/testsuite] Fix gdb.dwarf2/dw2-fixed-point.exp on arm-linuxTom de Vries1-6/+0
With test-case gdb.dwarf2/dw2-fixed-point.exp on arm-linux I run into: ... (gdb) PASS: gdb.dwarf2/dw2-fixed-point.exp: set lang ada print pck.fp1_var^M $1 = 0.3125^M (gdb) FAIL: gdb.dwarf2/dw2-fixed-point.exp: print pck.fp1_var ... The problem is that the thumb prologue analyzer overshoot, setting the breakpoint for main after line 49: ... 46 int 47 main (void) 48 { 49 pck__fp1_var++; ... and consequently we see the value of pck.fp1_var after line 49 instead of before line 49. This is PR tdep/31981. Work around this by removing line 49 and all similar subsequent lines, which turn out to be dead code. Approved-By: Luis Machado <luis.machado@arm.com> Tested on arm-linux.
2024-08-16[gdb/testsuite] Fix gdb.arch/arm-single-step-kernel-helper.expTom de Vries2-2/+8
On arm-linux I run into: ... (gdb) p *kernel_user_helper_version^M Cannot access memory at address 0xffff0ffc^M (gdb) FAIL: gdb.arch/arm-single-step-kernel-helper.exp: check kernel helper version ... What the test-case is trying to do, is to access a special address in the arm linux kernel [1] using ptrace, which doesn't seem to work. This is with kernel version 6.1.55. Perhaps this used to work, but the kernel was modified to be more strict with respect to access to this special address. Fix this by making the inferior access that special address instead. Tested on arm-linux. Approved-By: Luis Machado <luis.machado@arm.com> PR testsuite/32070 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32070 [1] https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt
2024-08-16gdb: Fix gdb.python/py-record-btrace.exp testFelix Willgerodt1-4/+11
My previous patch commit 8958aefd34200c8d2cd6e81bba32198468789c62 (HEAD) Author: Felix Willgerodt <felix.willgerodt@intel.com> Date: Mon Feb 25 15:30:29 2019 +0100 python: Add clear() to gdb.Record. exposed a clear function for btrace data in python and added some tests for it. That caused a regression (PR 32086) when recording with bts. This is reproducible even without my patch, when adding "maintenance btrace clear" to the test. When comparing the instructions that get recorded in both cases, the traces are almost identical, just that the first 3 instructions are missing. Before clear: (gdb) record instruction-history 1,100 1 0x0000555555555163 <main+12>: movl $0x0,-0x4(%rbp) 2 0x000055555555516a <main+19>: movl $0x0,-0x8(%rbp) 3 0x0000555555555171 <main+26>: jmp 0x555555555184 <main+45> 4 0x0000555555555184 <main+45>: cmpl $0x63,-0x4(%rbp) 5 0x0000555555555188 <main+49>: jle 0x555555555173 <main+28> 6 0x0000555555555173 <main+28>: mov -0x8(%rbp),%eax 7 0x0000555555555176 <main+31>: mov %eax,%edi ... After clear: (gdb) record instruction-history 1,100 1 0x0000555555555184 <main+45>: cmpl $0x63,-0x4(%rbp) 2 0x0000555555555188 <main+49>: jle 0x555555555173 <main+28> 3 0x0000555555555173 <main+28>: mov -0x8(%rbp),%eax 4 0x0000555555555176 <main+31>: mov %eax,%edi ... The GDB manual describes this behaviour already: maint btrace clear Discard the branch trace data. The data will be fetched anew and the branch trace will be recomputed when needed. This implicitly truncates the branch trace to a single branch trace buffer. When updating branch trace incrementally, the branch trace available to GDB may be bigger than a single branch trace buffer. The test with BTS is updating the recorded trace incrementally. After the clear, the buffer of raw trace data available is not enough to recompute the whole trace as it was before the clear(), and the first 3 instructions are missing. As increasing the buffer size for BTS didn't help, I propose to fix the test by moving the testing of clear to the end of the test. Approved-By: Tom de Vries <tdevries@suse.de> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32086
2024-08-15Add another constructor to scoped_restore_current_languageTom Tromey6-14/+16
While working on something else, I noticed that this is relatively common: scoped_restore_current_language save; set_language (something); This patch adds a second constructor to scoped_restore_current_language to simplify this idiom. Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-08-14Log gdb version and configuration in DAPTom Tromey1-0/+3
I think it would be useful for gdb's DAP logs to come with the version and configuration information. This might make debugging some bug reports a little simpler.
2024-08-14Notify Python when breakpoint symbol changesTom Tromey2-10/+27
A DAP user noticed that breakpoints set by address were never updated to show their location after the DAP launch request. It turns out that gdb does not emit the breakpoint-modified event when this sort of breakpoint is updated. This patch changes gdb to notify the breakpoint-modified observer when a breakpoint location's symbol changes. This in turn causes the DAP event to be emitted. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14Fix failure with C++ exceptions in DAPTom Tromey3-1/+20
While working on earlier patches, I noticed that the DAP C++ exception test had some strange results in the log. Digging into this, I found that while the Ada catchpoints emit a "bkptno" field in the MI result, the C++ ones do not -- but the DAP code was relying on this. This patch fixes the problem by changing which field is examined, and then updates the tests to verify this. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14Make DAP instruction breakpoints unverifiedTom Tromey2-2/+97
Currently, when a DAP client uses setInstructionBreakpoints, the resulting breakpoints are created as "verified", even though there is no symbol file and thus the breakpoint can't possibly have a source location. This patch changes the DAP code to assume that all breakpoints are unverified before launch. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14Introduce exec_mi_and_log for DAPTom Tromey4-9/+20
This adds a new exec_mi_and_log function that wraps gdb.execute_mi and logs the command. This can be handy when debugging DAP. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14Remove unnecessary default argument from initialize_block_iteratorTom Tromey1-1/+1
I noticed that initialize_block_iterator has a default value for one of its arguments, but this is not needed as this function has a single caller that always passes all arguments. This patch removes the default. Tested by rebuilding.
2024-08-14btrace: Extend ptwrite event decoding.Felix Willgerodt8-0/+1638
Call the ptwrite filter function whenever a ptwrite event is decoded. The returned string is written to the aux_data string table and a corresponding auxiliary instruction is appended to the function segment. Approved-By: Markus Metzger <markus.t.metzger@intel.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14btrace, python: Enable ptwrite filter registration.Felix Willgerodt13-0/+237
By default GDB will be printing the hex payload of the ptwrite package as auxiliary information. To customize this, the user can register a ptwrite filter function in python, that takes the payload and the PC as arguments and returns a string which will be printed instead. Registering the filter function is done using a factory pattern to make per-thread filtering easier. Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14btrace, linux: Enable ptwrite packets.Felix Willgerodt3-0/+72
Enable ptwrite in the PT config, if it is supported by the kernel. Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14btrace, gdbserver: Add ptwrite to btrace_config_pt.Felix Willgerodt3-1/+63
This enables gdb and gdbserver to communicate about ptwrite support. If ptwrite support would be enabled unconditionally, GDBs with older libipt versions would break. Approved-By: Markus Metzger <markus.t.metzger@intel.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14python: Add clear() to gdb.Record.Felix Willgerodt6-0/+46
This function allows to clear the trace data from python, forcing to re-decode the trace for successive commands. This will be used in future ptwrite patches, to trigger re-decoding when the ptwrite filter changes. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14python: Introduce gdb.RecordAuxiliary class.Felix Willgerodt5-16/+153
Auxiliary instructions are no real instructions and get their own object class, similar to gaps. gdb.Record.instruction_history is now possibly a list of gdb.RecordInstruction, gdb.RecordGap or gdb.RecordAuxiliary objects. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. Approved-By: Markus Metzger <markus.t.metzger@intel.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14btrace: Handle stepping and goto for auxiliary instructions.Felix Willgerodt1-11/+54
Print the auxiliary data when stepping. Don't allow to goto an auxiliary instruction. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14btrace: Enable auxiliary instructions in record function-call-history.Felix Willgerodt6-6/+52
Print the auxiliary data when a btrace_insn of type BTRACE_INSN_AUX is encountered in the function-call-history. Printing is active by default, it can be silenced with the /a modifier. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. Approved-By: Markus Metzger <markus.t.metzger@intel.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14btrace: Enable auxiliary instructions in record instruction-history.Felix Willgerodt4-0/+25
Print the auxiliary data when a btrace_insn of type BTRACE_INSN_AUX is encountered in the instruction-history. Printing is active by default, it can be silenced with the /a modifier. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. Approved-By: Markus Metzger <markus.t.metzger@intel.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14btrace: Introduce auxiliary instructions.Felix Willgerodt3-3/+26
Auxiliary instructions are pseudo instructions pointing to auxiliary data. This auxiliary data can be printed in all commands displaying (record function-call-history, record instruction-history) or stepping through (stepi etc.) the execution history, which will be introduced in the next commits. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. Approved-By: Markus Metzger <markus.t.metzger@intel.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14gdb: remove unnecessary code relating to limited-length arraysAndrew Burgess1-15/+1
While reviewing this commit: commit 8fdd2b2bcd8117cafcc6ef976e45f0d9f95fb528 Date: Tue Aug 6 19:34:18 2024 +0200 Mark unavailable bytes of limited-length arrays when allocating contents I spotted that there was some code in value::record_latest relating to limited-length arrays which appeared redundant. The code was added with the first introduction on limited-length arrays in commit: commit a0c07915778486a950952139d27c01d4285b02b4 Date: Fri Feb 10 23:49:19 2023 +0000 GDB: Introduce limited array lengths while printing values The code in question is in value::record_latest. When the value being recorded is lazy we need to fetch its value before adding it to the history list. The code I spotted checks to see if the value is lazy, if we currently have array limiting in effect, and if we do sets m_limited_length to max_value_size before finally calling fetch_lazy. The first thing fetch_lazy does is call allocate_contents to setup the value's buffer, and in allocate_contents we perform the same set of checks: if the value is an array, and array length limiting is in effect then only allocate max_value_size buffer for the contents. In ::allocate_contents the `if` condition check is spread out between ::allocate_contents and ::set_limited_array_length, but I'm certain it's checking the same condition. As such the checks and m_limited_length adjustment in ::record_latest is redundant and can be removed. Out of curiosity I went back to the original a0c07915778486a commit and removed the same block of code from record_latest_value (as value::record_latest was called back then) and non of the tests added by commit a0c07915778486a failed. I think this block of code was never needed. Anyway, I removed the unnecessary code and retested and there are no regressions. There should be no user visible changes after this commit. Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-08-13gdb/gdbarch: fix a dot-space-space in generated filesGerlicher, Klaus2-190/+190
This is a very small patch to straighten out dot-space-space in these comments in the gdbarch generated files: - /* Skip verify of short_bit, invalid_p == 0 */ + /* Skip verify of short_bit, invalid_p == 0. */ There is no functional change after this commit. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12Simplify typename_concatTom Tromey1-33/+20
This patch simplifies typename_concat, changing the return type and removing the obstack allocation code. The latter is possible because the only caller using this mode uses the name when creating a new type, and 'new_type' copies the string to the appropriate obstack anyway. It also changes typename_concat to use 'concat'. This change lets us remove a mildly fragile macro as well. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-12[gdb/testsuite] Fix gdb.tui/wrap-line.exp with wrapping disabledBernd Edlinger1-6/+25
There are a couple of ways that readline wrapping can be disabled: - using "set horizontal-scroll-mode on" in INPUTRC, - using a TERM setting like TERM=dumb, and - building gdb with stub-termcap. Using a trigger patch in default_gdb_init that adds "set horizontal-scroll-mode on" to INPUTRC: ... - setenv INPUTRC [cached_file inputrc "set enable-bracketed-paste off"] + setenv INPUTRC [cached_file inputrc "set enable-bracketed-paste off\nset horizontal-scroll-mode on"] ... we can easily reproduce a failure in gdb.tui/wrap-line.exp mentioned in PR testsuite/31201 (which was reported for the stub-termcap case): ... WARNING: timeout in accept_gdb_output Screen Dump (size 50 columns x 24 rows, cursor at column 34, row 1): 0 Quit 1 <89012345678901234567890123456789W 2 ... 23 FAIL: gdb.tui/wrap-line.exp: width-hard-coded: cli: wrap ... Fix this by accepting the horizontal-scroll-mode style output. We do this only when in CLI mode though, when in TUI wrapping works as before because it doesn't rely on readline. Tested on x86_64-linux. Co-Authored-By: Tom de Vries <tdevries@suse.de> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31201
2024-08-12gdb/amd-dbgapi-target: adjust to amd-dbgapi 0.75.0Simon Marchi3-19/+80
amd-dbgapi 0.75 (from ROCm release 6.2.0) brings a few backwards incompatible changes. Adjust the amd-dbgapi target code accordingly. Given that the AMD GPU port in upstream GDB today is of limited use (it's still missing important pieces), we don't really care about supporting amd-dbgapi versions other than the latest stable one, so no effort is made to keep compatibility with versions 6.1.2 and older. The changes are: - AMD_DBGAPI_EXCEPTION_WAVE_APERTURE_VIOLATION was renamed to AMD_DBGAPI_EXCEPTION_WAVE_ADDRESS_ERROR (the old name still exists but is deprecated), use the latter. - In the callbacks structure, the get_os_pid callback was replaced with client_process_get_info, which is more general and extensible. Convert our get_os_pid to a new, equivalent, client_process_get_info callback. Handle the new AMD_DBGAPI_CLIENT_PROCESS_INFO_CORE_STATE query, but just return "not available". - The xfer_global_memory callback was added to the callbacks structure, add that new callback. - Update configure.ac to check for amd-dbgapi >= 0.75.0. Change-Id: If012398cf55ebf6146b007f6b4e8395dd48ef981 Approved-By: Lancelot Six <lancelot.six@amd.com> Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2024-08-12gdb: pass inferior to gdbarch_update_pSimon Marchi10-33/+34
Make the current inferior reference bubble up one level. I think this makes it clearer what gdbarch_update_p, which is update the passed inferior's architecture (although the function name could probably be better). When gdbarch_find_by_info, it is possible for the new architecture's init callback to be called. I have not audited all of them (there are just too many), it's possible that some of them do care about the current inferior, for some reason (for instance, if one of them makes a target call). If so, they should be changed too. Change-Id: I89f012188d7fdca395a830f4b013743565f26847
2024-08-12gdb: pass inferior to target_current_descriptionSimon Marchi3-12/+9
Make the current inferior reference bubble up one level. Change-Id: I441f954877749dc5a861ab03e881b529dafc2efd
2024-08-12gdb: change names of enumerations in enum flags selftestSimon Marchi1-151/+153
When reading this test (in the context of PR 31331), I had trouble understanding the tests, because of the abbreviated names. I would prefer if the names were a bit more explicit, like this. Change-Id: I85669b238a9d5dacf673a7bbfc1ca18f80d2b2cf
2024-08-12gdb, gdbsupport: use `using` in enum flags codeSimon Marchi1-2/+2
I think that `using` is easier to read than `typedef`, and it's the modern C++ thing anyway. Change-Id: Iccb62dc3869cddfb6a684ef3023dcd5b799f3ab2
2024-08-12gdb/NEWS: announce removal of QNX Neutrino supportSimon Marchi1-0/+3
QNX Neutrino support was removed here [1], but I forgot to mention in in NEWS. [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=36fb20fa93484b104d91e42e38930ee8629192ab Change-Id: I8db7957acdd0be3c1e0b751c7c245870c4cd7101 Approved-By: Eli Zaretskii <eliz@gnu.org>
2024-08-12gdb: add program_space parameter to lookup_minimal_symbol_textSimon Marchi5-10/+16
Make the current program space reference bubble up one level. Use a program space from the context whenever that makes sense. Change-Id: Id3b0bf4490178d71a9aecdbf404b9287c22b30f5 Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12gdb: add program_space parameter to lookup_minimal_symbol_linkageSimon Marchi4-10/+16
Make the current_program_space reference bubble up one level. Change-Id: Ic349dc96b7d375ad7c66022d84657136f0de8c87 Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12gdb: add program_space parameter to get_symbol_leading_charSimon Marchi1-10/+10
Make the current_program_space references bubble up one level. In this case, I think it makes sense to use m_objfile's program space. Change-Id: Ibecb89b5e8a0363328240f1675d0fb95ff99c99a Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12gdb: add program_space parameter to lookup_minimal_symbolSimon Marchi66-123/+218
>From what I can see, lookup_minimal_symbol doesn't have any dependencies on the global current state other than the single reference to current_program_space. Add a program_space parameter and make that current_program_space reference bubble up one level. Change-Id: I759415e2f9c74c9627a2fe05bd44eb4147eee6fe Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12gdb: remove lookup_bound_minimal_symbolSimon Marchi20-37/+22
Now that lookup_minimal_symbol has default values for sfile and objf, calling lookup_bound_minimal_symbol is identical to calling lookup_minimal_symbol without sfile and objf. Remove lookup_bound_minimal_symbol, replace call sites with lookup_minimal_symbol. Change-Id: I0a420fb56de1de8bee8a7303228c9e4546e3577b Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12gdb: make lookup_minimal_symbol objf and sfile parameters optionalSimon Marchi57-133/+104
Most calls to lookup_minimal_symbol don't pass a value for sfile and objf. Make these parameters optional (have a default value of nullptr). And since passing a value to `objf` is much more common than passing a value to `sfile`, swap the order so `objf` comes first, to avoid having to pass a nullptr value to `sfile` when wanting to pass a value to `objf`. Change-Id: I8e9cc6b942e593bec640f9dfd30f62786b0f5a27 Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>