aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
13 hours[gdb/testsuite] Handle unsupported catch syscallTom de Vries3-28/+75
On riscv64-linux, I run into: ... Expecting: ^(catch syscall[^M ]+)?((&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done[^M ]+[(]gdb[)] ^M [ ]*) catch syscall^M &"catch syscall\n"^M &"The feature 'catch syscall' is not supported on this architecture yet.\n"^M ^error,msg="The feature 'catch syscall' is not supported on this architecture yet."^M (gdb) ^M FAIL: gdb.mi/mi-breakpoint-changed.exp: test_insert_delete_modify: catch syscall (unexpected output) ... Fix this by: - factoring out proc supports_catch_syscall out of gdb.base/catch-syscall.exp, and - using it in gdb.mi/mi-breakpoint-changed.exp. Tested on x86_64-linux and riscv64-linux. Approved-By: Andrew Burgess <aburgess@redhat.com>
28 hoursFix regexp quoting in gdb.ada test casesTom Tromey14-43/+43
I noticed that some gdb.ada tests used regular expressions like: "Continuing\..*$inferior_exited_re.*" \ Here, the "\." should either be "." or "\\." -- "\." is not really meaningful. This patch fixes all the cases of this I could find in gdb.ada. In one test (fun_renaming.exp), using "\\." would result in failures, and here I rewrote the tests to use -wrap. Approved-By: Andrew Burgess <aburgess@redhat.com>
2 daysgdb: reject inserting breakpoints between functionsAndrew Burgess15-48/+159
When debugging ROCm code, you might have something like this: __global__ void kernel () { ... // break here ... } int main () { // Code to call `kernel` } ... where kernel is a function compiled to execute on the GPU. It does not exist in the host x86-64 program that runs the main function, and GDB doesn't know about that function until it is called, at which point the runtime loads the corresponding code object and GDB learns about the code of the "kernel" function. Before the GPU code object is loaded, from the point of view of GDB, you might as well have blank lines instead of the "kernel" function. The DWARF in the host program doesn't describe anything at these lines. So, a common problem that users face is: - Start GDB with the host binary - Place a breakpoint by line number at the "break here" line - At this point, GDB only knows about the host code, the lines of the `kernel` function are a big void. - GDB finds no code mapped to the "break here" line and searches for the first following line that has code mapped to it. - GDB finds that the line with the opening bracket of the `main` function (or around there) has code mapped to it, places breakpoint there. - User runs the program. - The programs hits the breakpoint at the start of main. - User is confused, because they didn't ask for a breakpoint in main. If they continue, the code object eventually gets loaded, GDB reads the debug info from it, re-evaluates the breakpoint locations, and at this point the breakpoint is placed at the expected location. The goal of this patch is to get rid of this annoyance. A case similar to the one shown above can actually be simulated without GPU-specific code: using a single source file to generate a library and an executable loading that library (see the new test gdb.linespec/line-breakpoint-outside-function.c for an example). Before the library is loaded, trying to place a breakpoint in the library code results in the breakpoint "drifting" down to the main function. To address this problem, make it so that when a user requests a breakpoint outside a function, GDB makes a pending breakpoint, rather than placing a breakpoint at the next line with code, which happens to be in the next function. When the GPU kernel or shared library gets loaded, the breakpoint resolves to a location in the kernel or library. Note that we still want breakpoints placed inside a function to "drift" down to the next line with code. For example, here: 9 10 void foo() 11 { 12 int x; 13 14 x++; There is probably no code associated to lines 10, 12 and 13, but the user can still reasonably expect to be able to put a breakpoint there. In my experience, GCC maps the function prologue to the line with the opening curly bracket, so the user will be able to place a breakpoint there anyway (line 11 in the example). But I don't really see a use case to put a breakpoint above line 10 and expect to get a breakpoint in foo. So I think that is a reasonable behavior change for GDB. This is implemented using the following heuristic: - If a breakpoint is requested at line L but there is no code mapped to L, search for a following line with associated code (this already exists today). - However, if: 1. the found location falls in a function symbol's block 2. the found location's address is equal the entry PC of that function 3. the found location's line is greater that the requested line ... then we don't place a breakpoint at the found location, we will end up with a pending breakpoint. Change the message "No line X in file..." to "No compiled code for line X in file...". There is clearly a line 9 in the example above, so it would be weird to say "No line 9 in file...". What we mean is that there is no code associated to line 9. All the regressions that I found this patch to cause were: 1. tests specifically this behavior where placing a breakpoint before a function results in a breakpoint on that function, in which case I removed the tests or changed them to expect a pending breakpoint 2. linespec tests expecting things like "break -line N garbage" to error out because of the following garbage, but we now got a different error because line N now doesn't resolve to something anymore. For example, before: (gdb) break -line 3 if foofoofoo == 1 No symbol "foofoofoo" in current context. became (gdb) break -line 3 if foofoofoo == 1 No line 3 in the current file. These tests were modified to refer to a valid line with code, so that we can still test what we intended to test. Notes: - The CUDA compiler "solves" this problem by adding dummy function symbols between functions, that are never called. So when you try to insert a breakpoint in the not-yet-loaded kernel, the breakpoint still drifts, but is placed on some dummy symbol. For reasons that would be too long to explain here, the ROCm compiler does not do that, and it is not a desirable option. - You can have constructs like this: void host_function() { struct foo { static void __global__ kernel () { // Place breakpoint here } }; // Host code that calls `kernel` } The heuristic won't work then, as the breakpoint will drift somewhere inside the enclosing function, but won't be at the start of that function. So a bogus breakpoint location will be created on the host side. I don't think that people are going to use this kind of construct often though, so we can probably ignore it (or at least it shouldn't prevent making the more common case better). ROCm doesn't support passing a lambda kernel function to hipLaunchKernelGGL (the function used to launch kernels on the device), but if it eventually does, there will be the same problem. I think that to properly support this, we will need some DWARF improvements to be able to say "there is really nothing at these lines" in the line table. Co-Authored-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: I3cc12cfa823dc7d8e24dd4d35bced8e8baf7f9b6
2 days[gdb/testsuite] Fix another regexp in gdb.threads/stepi-over-clone.expTom de Vries1-1/+1
On openSUSE Tumbleweed, I run into: ... (gdb) PASS: gdb.threads/stepi-over-clone.exp: catch process syscalls continue^M Continuing.^M ^M Catchpoint 2 (call to syscall clone3), __clone3 () at clone3.S:62^M (gdb) FAIL: gdb.threads/stepi-over-clone.exp: continue ... Fix this by updating another (see commit 8fbf220321d) regexp to also recognize __clone3. Tested on x86_64-linux.
3 days[gdb/testsuite] Fix regexp in gdb.arch/i386-disp-step-self-call.expTom de Vries2-2/+2
Usually, with test-case gdb.arch/i386-disp-step-self-call.exp I get: ... (gdb) x/1wx 0xffffc4f8^M 0xffffc4f8: 0x08048472^M (gdb) PASS: $exp: check return address was updated correctly ... but sometimes I run into: ... (gdb) x/1wx 0xffffc5c8^M 0xffffc5c8: 0x0804917e^M (gdb) FAIL: $exp: check return address was updated correctly ... The problem is that here: ... set next_insn_addr 0x[format %08X $next_insn_addr] gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \ "check return address was updated correctly" ... we're trying to match string 0x0804917e against regexp 0x0804917E due to using "%08X" as format string. We only run into this problem if the address contains letters, which apparently usually isn't the case. Fix this by using "%08x" instead as format string. Likewise in test-case gdb.arch/amd64-disp-step-self-call.exp. Tested on x86_64-linux. PR testsuite/32121 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32121
3 daysgdb/testsuite: fix gdb.btrace/non-stop.exp end of history checkGuinevere Larsen1-7/+9
The recent commit 089197010993b3a5dc50bf882470bab2de696d92 changed the warnings when GDB reaches the end of the recorded history, and updated tests to expect the new messages. The pattern used for gdb.btrace/non-stop.exp, however, was too broad and could cause the following test result: ... (gdb) PASS: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: prompt ^M Reached end of recorded history; stopping.^M Following forward execution will be added to history.^M test (arg=0x0) at /data/vries/gdb/src/gdb/testsuite/gdb.btrace/non-stop.c:30^M 30 return arg; /* bp.2 */^M ^M Reached end of recorded history; stopping.^M Following forward execution will be added to history.^M test (arg=0x0) at /data/vries/gdb/src/gdb/testsuite/gdb.btrace/non-stop.c:30^M 30 return arg; /* bp.2 */^M PASS: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: thread 0 FAIL: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: thread 1 (timeout) ... This happens because the pattern looks like one of these 2: "Reached end of recorded.*Backwards execution.*" "Reached end of recorded.*Following forward.*" What seems to have happened is that all the output came at once, and most of it was consumed by the first '.*' pattern when checking for thread 0, so there was no output left for checking thread 1. This commit fixes that by making the expected outputs more exact. I also fixed the whitespace errors in gdb_cont_to_no_history_backwards that pre-dated the commit above, since I was already touching that proc. Approved-By: Tom de Vries <tdevries@suse.de>
3 daysgdb/testsuite: add no-delete-breakpoints option to 'runto' procAndrew Burgess3-29/+20
New 'no-delete-breakpoints' option for the 'runto' proc. This option disables the delete_breakpoints call early on in this proc. There are a couple of places in the testsuite where I have used: proc no_delete_breakpoints {} {} with_override delete_breakpoints no_delete_breakpoints { if {![runto_main]} { return } } In order to avoid the deleting all breakpoints when I call runto_main. I was about to add yet another instance of this pattern and I figured that it's time to do this properly. This commit adds the new option to 'runto' which causes the delete_breakpoints call to be skipped. And, we now forward any arguments from 'runto_main' through to 'runto', this means I can now just do: if {![runto_main no-delete-breakpoints]} { return } which I think is cleaner and easier to understand. I've updated the two tests I found that use the old with_override approach. There should be no change in what is tested after this commit. Approved-By: Tom Tromey <tom@tromey.com>
3 daysgdb: add 'maint info blocks' commandAndrew Burgess1-1/+64
While reviewing a patch I wanted to understand which blocks existed at a given address. The 'maint print symbols' command does provide some of this information, but that command displays all blocks within a given symtab. If I want to know which blocks are at a given address I have to figure that out for myself based on the output of 'maint print symbols' ... and I'm too lazy for that! So this command lists just those blocks at a given address, along with information about the blocks type. This new command doesn't list the symbols within each block, for that my expectation is that you'd cross reference the output with that of 'maint print symbols'. The new command format is: maintenance info blocks maintenance info blocks ADDRESS This lists the blocks at ADDRESS, or at the current $pc if ADDRESS is not given. Blocks are listed starting at the global block, then the static block, and then the progressively narrower scoped blocks. For each block we list the internal block pointer (which allows easy cross referencing with 'maint print symbols'), the inferior address range, along with other useful information. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Simon Marchi <simon.marchi@efficios.com>
3 daysgdb: Add 'maint info inline-frames' commandAndrew Burgess2-0/+208
While reviewing a patch I wanted to view GDB's inline frame state. I don't believe there's currently a maintenance command to view this information, so in this commit I've added one. The new command is: maintenance info inline-frames maintenance info inline-frames ADDRESS The command lists the inline frames that start at ADDRESS, or at the current $pc if no ADDRESS is given. The command also displays the "outer" function in which the inline functions are present. An example of the command output: (gdb) maintenance info inline-frames Cached inline state information for thread 1. program counter = 0x401137 skipped frames = 1 bar > foo main (gdb) This tells us that function 'main' called 'foo' which called 'bar'. The functions 'foo' and 'bar' are both inline and both start at the address 0x401137. Currently GDB considers the inferior to be stopped in frame 'foo' (note the '>' marker), this means that there is 1 skipped frame (function 'bar'). The function 'main' is the outer function. The outer function might not start at 0x401137, it is simply the function that contains the inline functions. If the user does a 'step' then GDB will not actually move the inferior forward, but will instead simply tell the user that the inferior entered 'bar'. The output of 'maint info inline-frames' will change like this: (gdb) step bar () at inline.c:6 6 ++global_counter; (gdb) maintenance info inline-frames Cached inline state information for thread 1. program counter = 0x401137 skipped frames = 0 > bar foo main (gdb) Now GDB is in function 'bar' and there are no skipped frames. I have renamed skipped_symbols to function symbols within the inline_state class. We are now going to carry the "outer" function (the function that contains all the inlined functions) within this list (as the last entry), so the old name didn't really make sense. As a consequence of this rename I've updated some comments. I've changed stopped_by_user_bp_inline_frame to take a symbol rather than a block. Previously we just used the block to access the associated function symbol. After this commit we can just pass in the function symbol directly, so lets do that. New function gather_inline_frames contains some of the logic pulled from skip_inline_frames. This new function builds the list of all symbols of inlined functions that start at a given $pc value and also the "outer" function that contains all of the inlined functions. In skip_inline_frames I've split the loop logic into two. The loop to build the function symbol list has moved to gather_inline_frames. The loop to figure out how many of the inlined functions we are skipping remains in skip_inline_frames and uses the result of calling gather_inline_frames. In inline_skipped_symbol there are some minor updates to the comment, and I've tweaked one of the asserts now that the function symbols list also contains the "outer" function (a <= becomes <). The maintenance_info_inline_frames function is now and implements the new maintenance command. And _initialize_inline_frame is updated to register the new command. I've added a basic test for the new command. Please excuse the file name for the new test, in the next commit I'll be adding additional tests and at that point the file name will make sense. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 days[gdb/testsuite] Fix regexp in gdb.dwarf2/dw2-inter-cu-error.expTom de Vries1-1/+1
In commit b5070480d74 ("[gdb/symtab] Change DWARF_ERROR from Dwarf Error to DWARF Error") I changed the dwarf error prefix, but failed to update test-case gdb.dwarf2/dw2-inter-cu-error.exp. Fix this by updating the corresponding regexp in the test-case. Tested on x86_64-linux.
4 days[gdb/symtab] Change DWARF_ERROR from Dwarf Error to DWARF ErrorTom de Vries5-6/+6
It was suggested here [1] that the canonical prefix for dwarf errors should not be "Dwarf Error: ", given that the canonical spelling is DWARF instead of Dwarf. Fix this by using "DWARF Error: " instead. Given the use of DWARF_ERROR_PREFIX, that needs to be changed only in a single location. Tested on x86_64-linux. Suggested-By: Tom Tromey <tom@tromey.com> Approved-By: Tom Tromey <tom@tromey.com> [1] https://sourceware.org/pipermail/gdb-patches/2024-August/211258.html
5 daysgdb: imply --once if connecting via stdioWilliam Ferreira1-1/+12
Currently, gdbserver hangs after stdin is closed while it tries to write: "Remote side has terminated connection. GDBserver will reopen the connection." This hang disappears if --once is also given. Since the stdin connection won't ever reopen if it's closed, it's safe to assume --once is desired. The gdb.server/server-pipe.exp test was also updated to reflect this change. There is now a second disconnect at the end of the proc, with a tighter-than-normal timeout to catch if the command hangs as it used to. Co-Authored-By: Guinevere Larsen <blarsen@redhat.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29796 Approved-By: Andrew Burgess <aburgess@redhat.com>
5 daysChange message when reaching end of reverse history.Guinevere Larsen10-32/+44
In a record session, when we move backward, GDB switches from normal execution to simulation. Moving forward again, the emulation continues until the end of the reverse history. When the end is reached, the execution stops, and a warning message is shown. This message has been modified to indicate that the forward emulation has reached the end, but the execution can continue as normal, and the recording will also continue. Before this patch, the warning message shown in that case was the same as in the reverse case. This meant that when the end of history was reached in either backward or forward emulation, the same message was displayed: "No more reverse-execution history." This message has changed for these two cases. Backward emulation: "Reached end of recorded history; stopping. Backward execution from here not possible." Forward emulation: "Reached end of recorded history; stopping. Following forward execution will be added to history." The reason for this change is that the initial message was deceiving, for the forward case, making the user believe that forward debugging could not continue. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31224 Reviewed-By: Markus T. Metzger <markus.t.metzger@intel.com> (btrace) Approved-By: Guinevere Larsen <blarsen@redhat.com>
8 daysgdb/dwarf2: Check for null abbrev_info ptrAaron Merey1-0/+51
A corrupt debuginfo file can result in a null abbrev_info pointer being passed to cooked_indexer::scan_attributes. This pointer is set to nullptr by peek_die_abbrev when an abbrev of 0 is found. There is no check for whether the abbrev pointer is null and SIGSEGV occurs when attempting to dereference the pointer. An abbrev of 0 normally indicates that the corresponding DIE is a null entry, but scan_attributes expects a non-null DIE. Fix this by throwing an error in cooked_indexer::scan_attributes when peek_die_abbrev returns a nullptr in order to avoid scan_attributes calling itself with a null abbrev. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31478 Co-authored-by: Tom de Vries <tdevries@suse.de> Approved-By: Tom Tromey <tom@tromey.com>
9 days[gdb/symtab] Return correct reader for top-level CU in ↵Tom de Vries1-0/+60
cooked_indexer::ensure_cu_exists With the test-case included in this patch, we run into: ... $ gdb -q -batch $exec Dwarf Error: Could not find abbrev number 3 in CU at offset 0xdb \ [in module $exec] ... The debug info consists of two CUs: ... Compilation Unit @ offset 0xb2: Length: 0x25 (32-bit) Version: 4 Abbrev Offset: 0x6c Pointer Size: 8 <0><bd>: Abbrev Number: 1 (DW_TAG_compile_unit) <be> DW_AT_language : 2 (non-ANSI C) <1><bf>: Abbrev Number: 2 (DW_TAG_subprogram) <c0> DW_AT_low_pc : 0x4004a7 <c8> DW_AT_high_pc : 0x4004b2 <d0> DW_AT_specification: <0xe8> <1><d4>: Abbrev Number: 3 (DW_TAG_subprogram) <d5> DW_AT_name : main <1><da>: Abbrev Number: 0 Compilation Unit @ offset 0xdb: Length: 0xf (32-bit) Version: 4 Abbrev Offset: 0x86 Pointer Size: 8 <0><e6>: Abbrev Number: 1 (DW_TAG_compile_unit) <e7> DW_AT_language : 2 (non-ANSI C) <1><e8>: Abbrev Number: 2 (DW_TAG_subprogram) <e9> DW_AT_specification: <0xd4> <1><ed>: Abbrev Number: 0 ... where: - DIE 0xbf in CU@0xb2 contains an inter-CU reference to - DIE 0xe8 in CU@0xdb, which contains an inter-CU reference to - DIE 0xd4 back in CU@0xb2. The dwarf error is caused by this bit of code in cooked_indexer::ensure_cu_exists: ... if (per_cu == m_per_cu) return reader; ... The dwarf error happens as follows: - a cutu_reader A is created for CU@0xb2 - using cutu_reader A, the cooked index reader starts indexing dies, with m_per_cu set to CU@0xb2 - while indexing it scans the attributes of DIE 0xbf and encounters the inter-CU reference to DIE 0xe8 - it calls cooked_indexer::ensure_cu_exists, which creates a cutu_reader B for CU@0xdb and returns it - using cutu_reader B, it continues scanning attributes of DIE 0xe8 and encounters the inter-CU reference to DIE 0xd4 - it calls cooked_indexer::ensure_cu_exists, the problematic bit is triggered and cutu_reader B is returned - using cutu_reader B, it continues scanning attributes of DIE 0xd4 - this goes wrong because: - the attributes of the DIE are encoded using the abbreviation table at offset 0x6c, while - the decoding is done using cutu_reader B which uses the abbreviation table at offset 0x86. Fix this by removing the problematic if clause. Since cutu_reader A is not preserved in m_index_storage, cooked_indexer::ensure_cu_exists cannot find it there and creates a duplicate cutu_reader C for CU@0xb2. Fix this in process_psymtab_comp_unit by preserving the cutu_reader A as well in m_index_storage. Tested on x86_64-linux and aarch64-linux. PR symtab/32081 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32081 Approved-By: Tom Tromey <tom@tromey.com> Reported-By: Andreas Schwab <schwab@linux-m68k.org>
11 daysgdb/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>
11 days[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
12 daysEnsure 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.
12 daysgdb: fix a target: prefix issue in find_separate_debug_fileAndrew Burgess1-17/+0
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
12 daysgdb: avoid '//' in filenames when searching for debuginfoAndrew Burgess1-2/+4
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>
13 days[gdb] Prune inferior after switching inferiorTom de Vries1-26/+5
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 Tromey2-0/+103
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-14Notify Python when breakpoint symbol changesTom Tromey1-10/+20
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 Tromey2-0/+16
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 Tromey1-0/+90
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-14btrace: Extend ptwrite event decoding.Felix Willgerodt5-0/+1407
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-14python: Add clear() to gdb.Record.Felix Willgerodt1-0/+4
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-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: remove QNX Neutrino supportSimon Marchi1-1/+0
Remove the support for the QNX Neutrino OS (tdep and native bits). This has been unmaintained for years, and we don't have a way to see if it works (or even builds, for the native parts). Without somebody actively maintaining it, this is just a burden for developers, especially that this port does a few weird unique things that require reasoning about when doing big change. Support for GDBserver was removed in 2020, commit 613f149a90d6 ("gdbserver: remove support for Neutrino"). Change-Id: I4e25ec26ab06636629adebd02ceb161ee31c232d Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-08-09Fix test failure when TUI is not enabledBernd Edlinger1-3/+5
This adds a missing allow_tui_tests guard. When tui is not enabled this test case does typically fail: FAIL: gdb.base/new-ui.exp: do_test_invalid_args: new-ui with tui Approved-By: Tom de Vries <tdevries@suse.de>
2024-08-09gdb: adjust the default place of 'list' to main's prologueStephan Rohr5-12/+42
The 'list' command prints around the 'main' function if the current source location is not set. The prologue of 'main' is skipped and the first real line of 'main' is offset by 'lines_to_print - 1'. This is incorrect, the location should be defaulted to main's prologue without applying offsets (similar to 'list main'). Printing around the selected line is then done in 'list_around_line'. The patch also fixes an issue if the list command is used before the program is started. For example, with the following code: 26 static void attribute ((used)) ambiguous_fun (void) {} 27 28 static int attribute ((used)) ambiguous_var; 29 30 31 32 33 34 35 36 37 38 int 39 main (void) 40 { 41 return 0; 42 } GDB offsets the relevant line by 'lines_to_print - 1' and then by another 'lines_to_print / 2' and prints: (gdb) list 27 28 static int attribute ((used)) ambiguous_var; 29 30 31 32 33 34 35 36 With this patch, GDB correctly prints: 37 38 int 39 main (void) 40 { 41 return 0; 42 } Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-06Mark unavailable bytes of limited-length arrays when allocating contentsHannes Domani2-0/+12
Using 'output' to print arrays larger than max-value-size, with only repeating elements, can cause gdb to crash: ``` $ cat a.c: char a[1000000]; int main() { return a[0]; } $ gdb -q a (gdb) print a $1 = {0 '\000' <repeats 65536 times>, <unavailable> <repeats 934464 times>} (gdb) output a This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. ``` Using 'print' works, because value::record_latest sets the unavailable bytes of the value when it's added to the value history. But 'outout' doesn't do that, so the printing tries to access more bytes than are available. The original problem in PR32015 was about using 'print' of a dynamic array in a D program. Here the crash happens because for 'print' the value was a struct with length/ptr fields, which is converted in d-valprint.c into an array. So value::record_latest didn't have a chance to mark the unavailable bytes in this case. To make sure the unavailable bytes always match the contents, this fixes it by marking the unavailable bytes immediately after the contents are allocated. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32015 Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-05[gdb] Notice when stepping into different fileTom de Vries3-0/+85
Consider the following test-case: ... $ cat -n test.c 1 int var; 2 3 int 4 foo (void) 5 { 6 var = 1; 7 #include "test.h" 8 } 9 10 int 11 main () 12 { 13 return foo (); 14 } $ cat -n test.h 1 return 1; $ gcc test.c -g ... When stepping through the test-case, gdb doesn't make it explicit that line 1 is not in test.c: ... Temporary breakpoint 1, main () at test.c:13 13 return foo (); (gdb) step foo () at test.c:6 6 var = 1; (gdb) n 1 return 1; (gdb) 8 } (gdb) ... which makes it easy to misinterpret the output. This is with the default "print frame-info" == auto, with documented behaviour [1]: ... stepi will switch between source-line and source-and-location depending on the program counter. ... What is actually implemented is that source-line is used unless stepping into or out of a function. The problem can be worked around by using "set print frame-info source-and-location", but that's a bit verbose. Instead, change the behaviour of "print frame-info" == auto to also use source-and-location when stepping into another file, which gets us: ... (gdb) n foo () at test.h:1 1 return 1; ... Tested on x86_64-linux. Reviewed-By: Kevin Buettner <kevinb@redhat.com> Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com> PR gdb/32011 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32011 [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Print-Settings.html#index-set-print-frame_002dinfo
2024-08-02gdb,testsuite: fix gdb.base/list-dot-nodebug and make it more robustGuinevere Larsen1-11/+26
Thiago Jung Bauermann noticed that gdb.base/list-dot-nodebug was not actually compiling the test with some debuginfo in the relevant part, and while fixing I noticed that the base assumption of the "some" case was wrong, GDB would select some symtab as a default location and the test would always fail. This fix makes printing the default location only be tested when there is no debuginfo. When testing with no debuginfo, if a system had static libc debuginfo, the test would also fail. To add an extra layer of robustness to the test, this rewrite also strips any stray debuginfo from the executable. The test would only fail now if it runs in a system that can't handle stripped debuginfo and has static debuginfo pre-installed. Reported-By: Tom de Vries <tdevries@suse.de> Reported-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31721 Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-02gdb/testsuite: fix gdb.python/py-framefilter-invalidarg.exp with clangGuinevere Larsen1-1/+1
The final test of gdb.python/py-framefilter-invalidarg.exp expected that the the backtrace only printed the source file name. However, when using clang, gdb will always print the full path to the file, which would cause the test to fail. This commit introduces a regexp that optionally matches paths, preprended to the file name, which fixes the clang failure without introducing gcc failures. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-02gdb/testsuite: extend XFAIL to gdb.fortran/entry-point.exp to clang tooGuinevere Larsen1-2/+2
The test gdb.fortran/entry-point.exp already has an XFAIL when trying to set a breakpoint in mod::mod_foo because gcc puts that subprogram in the wrong scope in the debug information. Clang's debug information looks the same as gcc's, so the test to setup the xfail has been extended to also include clang. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-02gdb/testsuite: add build-id compile flag to tests that expect itGuinevere Larsen4-4/+6
Clang doesn't add build-id information by default, unlike gcc. This means that tests that rely on build-id being available and don't explicitly add it to the compilation options will fail with clang. This commit fixes the fails in gdb.python/py-missing-debug.exp, gdb.server/remote-read-msgs.exp, gdb.base/coredump-filter-build-id.exp and gdb.server/solib-list.exp Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-01[gdb/testsuite] Fix gdb.python/py-format-string.exp with python 3.13Tom de Vries1-1/+7
On fedora rawhide, with python 3.13, I run into: ... (gdb) python print (gdb.parse_and_eval ('a_point_t').format_string (invalid=True))^M Python Exception <class 'TypeError'>: \ this function got an unexpected keyword argument 'invalid'^M Error occurred in Python: \ this function got an unexpected keyword argument 'invalid'^M (gdb) FAIL: $exp: format_string: lang_c: test_all_common: test_invalid_args: \ a_point_t with option invalid=True ... A passing version with an older python version looks like: ... (gdb) python print (gdb.parse_and_eval ('a_point_t').format_string (invalid=True))^M Python Exception <class 'TypeError'>: \ 'invalid' is an invalid keyword argument for this function^M Error occurred in Python: \ 'invalid' is an invalid keyword argument for this function^M (gdb) PASS: $exp: format_string: lang_c: test_all_common: test_invalid_args: \ a_point_t with option invalid=True ... Fix this by accepting the updated error message. Tested on aarch64-linux. PR testsuite/31912 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31912
2024-07-31[gdb/testsuite] Fix trailing-text-in-parentheses duplicatesTom de Vries77-627/+618
Fix all trailing-text-in-parentheses duplicates exposed by previous patch. Tested on x86_64-linux and aarch64-linux.
2024-07-31[gdb/testsuite] Detect trailing-text-in-parentheses duplicatesTom de Vries2-5/+39
When using a duplicate test name: ... fail foo fail foo ... we get: ... FAIL: $exp: foo FAIL: $exp: foo DUPLICATE: $exp: foo ... But when we do: ... fail foo fail "foo (timeout)" ... we get only: ... FAIL: $exp: foo FAIL: $exp: foo (timeout) ... Trailing text between parentheses prefixed with a space is interpreted as extra information, and not as part of the test name [1]. Consequently, "foo" and "foo (timeout)" do count as duplicate test names, which should have been detected. This is PR testsuite/29772. Fix this in CheckTestNames::_check_duplicates, such that we get: ... FAIL: $exp: foo FAIL: $exp: foo (timeout) DUPLICATE: $exp: foo (timeout) ... [ One note on the implementation: I used the regexp { \([^()]*\)$}. I don't know whether that covers all required cases, due to the fact that those are not unambiguousely specified. It might be possible to reverse-engineer that information by reading or running the "regression analysis tools" mentioned on the wiki page [1], but I haven't been able to. Regardless, the current regexp covers a large amount of cases, which IMO should be sufficient to be acceptable. ] Doing so shows many new duplicates in the testsuite. A significant number of those is due to using a message which is a copy of the command: ... gdb_test "print (1)" ... Fix this by handling those cases using test names "gdb-command<print (1)>" and "gdb-command<print (2)>. Fix the remaining duplicates manually (split off as follow-up patch for readability of this patch). Tested on x86_64-linux and aarch64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29772 [1] https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages
2024-07-31[gdb/testsuite] Add gdb.python/py-disasm-{exec,obj}.expTom de Vries4-16/+90
I tried to reproduce a problem in test-case gdb.python/py-disasm.exp on a s390x machine, but when running with target board unix/-m31 I saw that the required libraries were missing, so I couldn't generate an executable. However, I realized that I did have an object file, and the test-case should mostly also work with an object file. I've renamed gdb.python/py-disasm.exp to gdb.python/py-disasm.exp.tcl and included it from two new minimal test-case wrappers: - gdb.python/py-disasm-exec.exp, and - gdb.python/py-disasm-obj.exp where the former uses an executable as before, and the latter uses an object file. Using an object file required changing the info.read_memory calls in gdb.python/py-disasm.py: ... - info.read_memory(1, -info.address + 2) + info.read_memory(1, -info.address - 1) ... because reading from address 2 succeeds. Using address -1 instead does generate the expected gdb.MemoryError. Tested on x86_64-linux.
2024-07-31[gdb/exp] Fix gdb.fortran/intrinsics.exp fail on armTom de Vries3-7/+42
When running test-case gdb.fortran/intrinsics.exp on arm-linux, I get: ... (gdb) p cmplx (4,4,16)^M /home/linux/gdb/src/gdb/f-lang.c:1002: internal-error: eval_op_f_cmplx: \ Assertion `kind_arg->code () == TYPE_CODE_COMPLEX' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M ----- Backtrace -----^M FAIL: gdb.fortran/intrinsics.exp: p cmplx (4,4,16) (GDB internal error) ... The problem is that 16-byte floats are unsupported: ... $ gfortran test.f90 test.f90:2:17: 2 | REAL(kind=16) :: foo = 1 | 1 Error: Kind 16 not supported for type REAL at (1) ... and consequently we end up with a builtin_real_s16 and builtin_complex_s16 with code TYPE_CODE_ERROR. Fix this by bailing out asap when encountering such a type. Without this patch we're able to do the rather useless: ... (gdb) ptype real*16 type = real*16 (gdb) ptype real_16 type = real*16 ... but with this patch we get: ... (gdb) ptype real*16 unsupported kind 16 for type real*4 (gdb) ptype real_16 unsupported type real*16 ... Tested on arm-linux. PR fortran/30537 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30537
2024-07-30[gdb/testsuite] Fix regexp in gdb.ada/mi_var_access.exp some moreTom de Vries1-1/+2
When running test-case gdb.ada/mi_var_access.exp on arm-linux (debian trixie), I run into: ... Expecting: ^(-var-create A_String_Access \* A_String_Access[ ]+)?((\^done,name="A_String_Access",numchild="[0-9]+",.*|\^error,msg="Value out of range.".*)[ ]+[(]gdb[)] [ ]*) -var-create A_String_Access * A_String_Access ^error,msg="Cannot access memory at address 0x4" (gdb) FAIL: gdb.ada/mi_var_access.exp: Create varobj (unexpected output) ... This is similar to the problem fixed by commit c5a72a8d1c3 ("[gdb/testsuite] Fix regexp in gdb.ada/mi_var_access.exp"). The problem in both cases is that we're printing an uninitialized variable, and consequently we can run into various error messages during printing. Fix this as in the other commit, by accepting the error message. Tested on arm-linux.
2024-07-30[gdb/symtab] Emit malformed macro definition complaint onceTom de Vries1-0/+198
Add a test-case gdb.dwarf2/macro-complaints.exp, that checks complaints for the .debug_macro section. For one malformed macro definition, I get two identical complaints: ... During symbol reading: macro debug info contains a malformed macro definition:^M `M1_11_MALFORMED(ARG'^M During symbol reading: macro debug info contains a malformed macro definition:^M `M1_11_MALFORMED(ARG'^M ... Fix this by bailing out after the first one. Tested on aarch64-linux. Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2024-07-29Add a test for the gcore scriptAlexandra Hájková3-0/+175
It also tests the gcore script being run without its accessible terminal. This test was written by Jan Kratochvil a long time ago. I modernized the test making it use various procs from lib/gdb.exp, reorganizing it and added some comments. Modify the gcore script to make it possible to pass the --data-directory to it. This prevents a lot of these warnings: Python Exception <class 'AttributeError'>: module 'gdb' has no attribute '_handle_missing_debuginfo' Tested by using make check-all-boards. Co-Authored-By: Jan Kratochvil <jan.kratochvil@redhat.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-07-29[gdb/testsuite] Fix gdb.gdb/index-file.exp with -g0Tom de Vries1-2/+13
When building gdb with -g0 and running test-case gdb.gdb/index-file.exp, we run into: ... (gdb) save gdb-index index_1^M Error while writing index for `xgdb': No debugging symbols^M (gdb) FAIL: gdb.gdb/index-file.exp: create gdb-index file ... Fix this by instead emitting an unsupported, and bailing out. Tested on aarch64-linux.
2024-07-29[gdb/testsuite] Remove PR31554 kfail in gdb.threads/leader-exit-attach.expTom de Vries1-8/+0
When running test-case gdb.threads/leader-exit-attach.exp with target board native-extended-gdbserver I run into: ... (gdb) KFAIL: $exp: attach (PRMS: gdb/31555) print $_inferior_thread_count^M $1 = 0^M (gdb) KPASS: $exp: get valueof "$_inferior_thread_count" (PRMS server/31554) ... The PR mentioned in the KPASS, PR31554 was fixed by commit f1fc8dc2dcc ("Fix "attach" failure handling with GDBserver"), and consequently the PR is closed. Fix this by removing the corresponding kfail. Tested on x86_64-linux.