aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
AgeCommit message (Collapse)AuthorFilesLines
9 days[gdb/symtab] Handle DW_OP_entry_value at function entryTom de Vries1-2/+21
On riscv64-linux, with test-case gdb.base/vla-optimized-out.exp I ran into: ... (gdb) p sizeof (a)^M $2 = <optimized out>^M (gdb) FAIL: $exp: o1: printed size of optimized out vla ... The variable a has type 0xbf: ... <1><bf>: Abbrev Number: 12 (DW_TAG_array_type) <c0> DW_AT_type : <0xe3> <c4> DW_AT_sibling : <0xdc> <2><c8>: Abbrev Number: 13 (DW_TAG_subrange_type) <c9> DW_AT_type : <0xdc> <cd> DW_AT_upper_bound : 13 byte block: a3 1 5a 23 1 8 20 24 8 20 26 31 1c (DW_OP_entry_value: (DW_OP_reg10 (a0)); DW_OP_plus_uconst: 1; DW_OP_const1u: 32; DW_OP_shl; DW_OP_const1u: 32; DW_OP_shra; DW_OP_lit1; DW_OP_minus) ... which has an upper bound using a DW_OP_entry_value, and since the corresponding call site contains no information to resolve the value of a0 at function entry: ... <2><6b>: Abbrev Number: 6 (DW_TAG_call_site) <6c> DW_AT_call_return_pc: 0x638 <74> DW_AT_call_origin : <0x85> ... evaluting the dwarf expression fails, and we get <optimized out>. My first thought was to try breaking at *f1 instead of f1 to see if that would help, but actually the breakpoint resolved to the same address. In other words, the inferior is stopped at function entry. Fix this by resolving DW_OP_entry_value when stopped at function entry by simply evaluating the expression. This handles these two cases (x86_64, using reg rdi): - DW_OP_entry_value: (DW_OP_regx: 5 (rdi)) - DW_OP_entry_value: (DW_OP_bregx: 5 (rdi) 0; DW_OP_deref_size: 4) Tested on x86_64-linux. Tested gdb.base/vla-optimized-out.exp on riscv64-linux. Tested an earlier version of gdb.dwarf2/dw2-entry-value-2.exp on riscv64-linux, but atm I'm running into trouble on that machine (cfarm92) so I haven't tested the current version there.
10 daysgdb/testsuite/dwarf: fix abbrev section name when putting type unit in DWO fileSimon Marchi1-1/+1
Fix what looks like a copy paste error resulting in the wrong abbrev section name. The resulting section name in my test was ".debug_info.dwo.dwo", when it should have been ".debug_abbrev.dwo". Change-Id: I82166d8ac6eaf3c3abc15d2d2949d00c31fe79f4 Approved-By: Tom Tromey <tom@tromey.com>
10 daysgdb/testsuite/dwarf: add support to generate DWARF 5 split compile unitsSimon Marchi1-1/+44
Add support to the DWARF assembler to generate DWARF 5 split compile units. The assembler knows how to generate DWARF < 5 split compile units (fission), DWARF 5 compile units, but not DWARF 5 split compile units. What's missing is: - using the right unit type in the header: skeleton for the unit in the main file and split_compile for the unit in the DWO file - have a way for the caller to specify the DWO ID that will end up in the unit header Add a dwo_id parameter to the cu proc. In addition to specifying the DWO ID, the presence of this parameter tells the assembler to use the skeleton or split_compile unit type. This is used in a subsequent patch. Change-Id: I05d9b189a0843ea6c2771b1d5e5a91762426dea9 Approved-By: Tom Tromey <tom@tromey.com>
10 daysUpdate copyright dates to include 2025Tom Tromey60-60/+60
This updates the copyright headers to include 2025. I did this by running gdb/copyright.py and then manually modifying a few files as noted by the script. Approved-By: Eli Zaretskii <eliz@gnu.org>
2025-04-03[gdb/testsuite] Add gdb.testsuite/version-compare.expTom de Vries1-1/+4
Add a test-case gdb.testsuite/version-compare.exp that excercises proc version_compare, and a note to proc version_compare that it considers v1 < v1.0 instead of v1 == v1.0. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2025-04-01Check gnatmake version in gnat_version_compareTom Tromey1-3/+7
Tom de Vries pointed out that my earlier change to gnat_version_compare made it actually test gcc's version -- not gnat's. This patch changes gnat_version_compare to examine gnatmake's version, while preserving the nicer API. Approved-By: Tom de Vries <tdevries@suse.de>
2025-03-31testsuite: fix is_aarch32_targetThiago Jung Bauermann1-6/+9
Commit c221b2f77080 Testsuite: Add gdb_can_simple_compile changed the source file name extension of the test program from .s to .c resulting in compile fails. This, in turn, causes is_aarch32_target checks to fail. Change the test source from an assembly program to a C program using inline assembly. is_amd64_regs_target had a similar problem, which was fixed by commit 224d30d39365 testsuite: fix is_amd64_regs_target This fix — and commit message — are mostly copied from it. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-26gdb/testsuite: Force DWARF debuginfo where applicable in AIX systemsGuinevere Larsen1-0/+17
In the AIX systems available for testing in the gcc compile farm, the default debug information format is stabs. This is a problem for many reasons, mainly that stabs is not as complete as dwarf and stabs is being deprecated in the next release. In the current state, we have: PASS: 39798 FAIL: 7405 When running these tests, I unfortunately didn't have the foresight to save the number of unsupported and untested cases. To improve testing there, this patch changes the gdb_compile TCL proc, so that if we're running tests in AIX, we requested debug info, and we haven't explicitly asked for some debuginfo format, gdb_compile will add -gdwarf to the compilation line, forcing DWARF to be used. After this patch, we get: PASS: 74548 FAIL: 5963 So not only do we have fewer failures, there are tens of thousands of tests that are no longer skipped. Approved-By: Tom Tromey <tom@tromey.com>
2025-03-26gdb: add configure option to disable compileGuinevere Larsen2-0/+9
GDB's compile subsystem is deeply tied to GDB's ability to understand DWARF. A future patch will add the option to disable DWARF at configure time, but for that to work, the compile subsystem will need to be entirely disabled as well, so this patch adds that possibility. I also think there is motive for a security conscious user to disable compile for it's own sake. Considering that the code is quite unmaintained, and depends on an equally unmaintained gcc plugin, there is a case to be made that this is an unnecessary increase in the attack surface if a user knows they won't use the subsystem. Additionally, this can make compilation slightly faster and the final binary is around 3Mb smaller. But these are all secondary to the main goal of being able to disable dwarf at configure time. To be able to achieve optional compilation, some of the code that interfaces with compile had to be changed. All parts that directly called compile things have been wrapped by ifdefs checking for compile support. The file compile/compile.c has been setup in a similar way to how python's and guile's main file has been setup, still being compiled but only for with placeholder command. Finally, to avoid several new errors, a new TCL proc was introduced to gdb.exp, allow_compile_tests, which checks if the "compile" command is recognized before the inferior is started and otherwise skips the compile tests. All tests in the gdb.compile subfolder have been updated to use that, and the test gdb.base/filename-completion also uses this. The proc skip_compile_feature_tests to recognize when the subsystem has been disabled at compile time. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
2025-03-21gdb/testsuite/lib/rocm: Drop hip_devices_support_precise_memoryLancelot SIX1-19/+0
Remove hip_devices_support_precise_memory as this is not used anymore. Change-Id: If5e19cf81f8b8778ee11b27d99b8488562804967 Approved-by: Pedro Alves <pedro@palves.net>
2025-03-18[gdb/testsuite] Fix gdb.base/enum_cond.exp on arm-linuxTom de Vries1-0/+12
On arm-linux, I run into: ... gdb compile failed, ld: warning: enum_cond.o uses variable-size enums yet \ the output is to use 32-bit enums; use of enum values across objects may fail UNTESTED: gdb.base/enum_cond.exp: failed to compile ... Fix this by using -nostdlib. Tested on arm-linux and x86_64-linux. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-04Check whether gnatmake can link with -sharedTom Tromey1-0/+9
Currently, gnat-llvm does not ship a shared libgnat. This patch changes the relevant test to check whether linking with -shared actually works.
2025-03-04Check whether gnatmake supports -OgTom Tromey1-0/+5
gnat-llvm does not support the -Og flag. This arranges to check for this flag before using it.
2025-03-04Look for -fgnat-encodings optionTom Tromey1-1/+17
gnat-llvm does not support the -fgnat-encodings option, and does not emit GNAT encodings at all -- it only supports the equivalent of GCC's "minimal" encodings; which is to say, ordinary DWARF. This patch changes gdb to test whether gnatmake supports this flag and adapt accordingly. foreach_gnat_encoding is changed to pretend that the "minimal" mode is in effect, as some test examine the mode.
2025-03-04Check -fvar-tracking via ada_simple_compileTom Tromey1-0/+5
A couple of Ada tests check whether the C compiler supports -fvar-tracking. However, this doesn't really work when using gnat-llvm, because that will invoke clang under the hood. This patch arranges to check gnatmake instead, which is more robust even when toolchains are mix-and-matched.
2025-03-04Introduce ada_simple_compileTom Tromey2-11/+56
This introduces ada_simple_compile, an Ada-specific analog of gdb_simple_compile. gdb_compile_test is split into two procs to make this possible. ada_simple_compile isn't used in this patch but will be by later patches in this series.
2025-03-03Add language to type unit in debug-names-tu.exp.tclTom Tromey1-24/+32
I think debug-names-tu.exp.tcl only passes by accident -- the type unit does not have a language, which gdb essentially requires. This isn't noticeable right now because the type unit in question is expanded in one phase and then the symbol found in another. However, I'm working on a series that would regress this. This patch partially fixes the problem by correcting the test case, adding the language to the TU. Hoewver, it then goes a bit further and arranges for this information not to be written to .debug_names. Whether or not a type should be considered "static" seems like something that is purely internal to gdb, so this patch has the entry-creation function apply the appropriate transform. It also may make sense to change the "debug_names" proc in the test suite to process attributes more like the ordinary "cu" proc does.
2025-02-24gdb/tui: use correct setting to control asm window stylingAndrew Burgess1-4/+19
Currently the TUI's asm window uses `source_styling` to control styling. This setting is supposed to be for styling of source files though, and the asm window displays disassembler output. We have a different setting for this `disassemble_styling`, which is controlled with 'set style disassembler enabled on|off'. Switch to use the correct control variable. I've written a new test for this, but this required some additions to the tuiterm library in order to grab character attributes for a screen region. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-24gdb/testsuite/lib/rocm.exp: Fix a typo in a commentShahab Vahedi1-1/+1
"Check we have ..." --> "Check if we have ..." This is for consistency with the previous comment and the code downstream.
2025-02-21gdb/testsuite/rocm.exp: Use system GPU(s) to detect featuresShahab Vahedi1-36/+74
gdb/testsuite/rocm.exp: Use system GPU(s) to detect features Background ---------- This patch revisits the purpose of hcc_amdgpu_targets{} in order to address the separation of concerns between: - GPU targets passed to the compiler. This kind of target is passed as an argument to flags like "--offload-arch=...", "--targets=...", etc. - GPU targets as in available GPU devices on the system. This is crucial for finding which capabilities are available, and therefore which tests should be executed or skipped. Code change ----------- - A new "find_amdgpu_devices{}" procedure is added. It is responsible for listing the GPU devices that are available on the system. - "hcc_amdgpu_targets{}" is rewritten to use the newly added "find_amdgpu_devices{}" when there's no environment variable (HCC_AMDGPU_TARGET) set. - The output of "hcc_amdgpu_targets{}" is now only used in places that set the target for the building toolchains. - The output of "find_amdgpu_devices{}" is used anywhere that needs to evaluate the GPU features. Approved-By: Lancelot Six <lancelot.six@amd.com> (amdgpu) Change-Id: Ib11021dbe674aa40192737ede78284a1bc531513
2025-02-18testsuite, mi: prevent buffer overflow in get_mi_thread_listTankut Baris Aktemur1-25/+26
If there is a large number of threads in the input program, the expect buffer in `get_mi_thread_list` would become full. Prevent this by consuming the buffer in small pieces. Regression-tested using the gdb.mi tests. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-02-18[gdb] Fix some typosTom de Vries3-5/+5
Fix typos: ... overriden -> overridden reate -> create ... Tested on x86_64-linux. I
2025-02-17testsuite, mi: fix indentation in get_mi_thread_listTankut Baris Aktemur1-29/+29
The `get_mi_thread_list` procedure's body is incorrectly indented. Fix it. There is one line that was already long. Consider it an exception and don't bother breaking it.
2025-02-13gdb, testsuite: Rename set_sanitizer procedures to append_environment.Christina Schimpe1-9/+9
The procedures set_sanitizer_1, set_sanitizer and set_sanitizer_default are used for the configuration of ASAN specific environment variables. However, they are actually generic. Rename them to append_environment* so that their purpose is more clear. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-12Add copyright header to gnat_debug_info_test.adbTom Tromey1-0/+15
I noticed that gdb/testsuite/lib/gnat_debug_info_test.adb is missing a copyright header. This adds one, using the date range from the original commit.
2025-02-09gdb: include a still-mapped flag in solib unload notificationAndrew Burgess2-33/+33
Consider the gdb.base/dlmopen.exp test case. The executable in this test uses dlmopen to load libraries into multiple linker namespaces. When a library is loaded into a separate namespace, its dependencies are also loaded into that namespace. This means that an inferior can have multiple copies of some libraries, including the dynamic linker, loaded at once. However, glibc optimises at least the dynamic linker case. Though the library appears to be mapped multiple times (it is in the inferior's solib list multiple times), there is really only one copy mapped into the inferior's address space. Here is the 'info sharedlibrary' output on an x86-64/Linux machine once all the libraries are loaded: (gdb) info sharedlibrary From To Syms Read Shared Object Library 0x00007ffff7fca000 0x00007ffff7ff03f5 Yes /lib64/ld-linux-x86-64.so.2 0x00007ffff7eda3d0 0x00007ffff7f4e898 Yes /lib64/libm.so.6 0x00007ffff7d0e800 0x00007ffff7e6dccd Yes /lib64/libc.so.6 0x00007ffff7fbd040 0x00007ffff7fbd116 Yes /tmp/build/gdb/testsuite/outputs/gdb.base/dlmopen/dlmopen-lib.1.so 0x00007ffff7fb8040 0x00007ffff7fb80f9 Yes /tmp/build/gdb/testsuite/outputs/gdb.base/dlmopen/dlmopen-lib-dep.so 0x00007ffff7bfe3d0 0x00007ffff7c72898 Yes /lib64/libm.so.6 0x00007ffff7a32800 0x00007ffff7b91ccd Yes /lib64/libc.so.6 0x00007ffff7fca000 0x00007ffff7ff03f5 Yes /lib64/ld-linux-x86-64.so.2 0x00007ffff7fb3040 0x00007ffff7fb3116 Yes /tmp/build/gdb/testsuite/outputs/gdb.base/dlmopen/dlmopen-lib.1.so 0x00007ffff7fae040 0x00007ffff7fae0f9 Yes /tmp/build/gdb/testsuite/outputs/gdb.base/dlmopen/dlmopen-lib-dep.so 0x00007ffff7ce1040 0x00007ffff7ce1116 Yes /tmp/build/gdb/testsuite/outputs/gdb.base/dlmopen/dlmopen-lib.1.so 0x00007ffff7cdc040 0x00007ffff7cdc0f9 Yes /tmp/build/gdb/testsuite/outputs/gdb.base/dlmopen/dlmopen-lib-dep.so 0x00007ffff79253d0 0x00007ffff7999898 Yes /lib64/libm.so.6 0x00007ffff7759800 0x00007ffff78b8ccd Yes /lib64/libc.so.6 0x00007ffff7fca000 0x00007ffff7ff03f5 Yes /lib64/ld-linux-x86-64.so.2 0x00007ffff7cd7040 0x00007ffff7cd7116 Yes /tmp/build/gdb/testsuite/outputs/gdb.base/dlmopen/dlmopen-lib.2.so Notice that every copy of /lib64/ld-linux-x86-64.so.2 is mapped at the same address. As the inferior closes the libraries that it loaded, the various copies of the dynamic linker will also be unloaded. Currently, when this happens GDB calls notify_solib_unloaded, which triggers the gdb::observers::solib_unloaded observer. This observer will call disable_breakpoints_in_unloaded_shlib (in breakpoint.c), which disables any breakpoints in the unloaded solib. The problem with this, is that, when the dynamic linker (or any solib) is only really mapped once as is the case here, we only want to disable breakpoints in the library when the last instance of the library is unloaded. The first idea that comes to mind is that GDB should not emit the solib_unloaded notification if a shared library is still in use, however, this could break MI consumers. Currently, every time a copy of ld-linux-x86-64.so.2 is unloaded, GDB's MI interpreter will emit a =library-unloaded event. An MI consumer might use this to update the library list that it displays to the user, and fewer notify_solib_unloaded calls will mean fewer MI events, which will mean the MI consumer's library list could get out of sync with GDB. Instead I propose that we extend GDB's solib_unloaded event to add a new flag. The new flag indicates if the library mapping is still in use within the inferior. Now the MI will continue to emit the expected =library-unloaded events, but disable_breakpoints_in_unloaded_shlib can check the new flag, when it is true (indicating that the library is still mapped into the inferior), no breakpoints should be disabled. The other user of the solib_unloaded observer, in bsd-uthread.c, should, I think, do nothing if the mapping is still in use. This observer is also disabling breakpoints when a library is unloaded. Most of the changes in this commit relate to passing the new flag around for the event. The interesting changes are mostly in solib.c, where the flag value is determined, and in breakpoint.c and bsd-uthread.c, where the flag value is read. There's a new MI test, the source of which is mostly copied from the gdb.base/dlmopen.exp test. This new test is checking we see all the expected =library-unloaded events.
2025-02-06gdb/testsuite: gdb.base/gcorebg.exp against installed binariesLancelot SIX1-17/+17
It is possible to run GDB's testsuite against installed binaries rather than the one from the build tree. For example, one could do: $ make check-gdb RUNTESTFLAGS=GDB=/usr/bin/gdb Running the testsuite this way causes error for gdb.base/gcorebg.exp: Running [...]/gdb/testsuite/gdb.base/gcorebg.exp ... FAIL: gdb.base/gcorebg.exp: detached=detached: Spawned gcore finished FAIL: gdb.base/gcorebg.exp: detached=detached: Core file generated by gcore FAIL: gdb.base/gcorebg.exp: detached=standard: Spawned gcore finished FAIL: gdb.base/gcorebg.exp: detached=standard: Core file generated by gcore This is due to 2 problems. First, when running this way, the $GDB_DATA_DIRECTORY is not set (on purpose) as the installed GDB does not need to be specified where to find it. See this section in gdb/testsuite/lib/gdb.exp: if ![info exists GDB] { [....] } else { # If the user specifies GDB on the command line, and doesn't # specify GDB_DATA_DIRECTORY, then assume we're testing an # installed GDB, and let it use its own configured data directory. if ![info exists GDB_DATA_DIRECTORY] { set GDB_DATA_DIRECTORY "" } } The testbg.exp file always assumes a non-empty GDB_DATA_DIRECTORY. As a consequence, when calling the gcorebg binary with an empty argument (i.e. missing argument), the program fails: gcorebg: [...]/gdb/testsuite/gdb.base/gcorebg.c:42: main: Assertion `argc == 5' failed. FAIL: gdb.base/gcorebg.exp: detached=standard: Spawned gcore finished This patch does adjust the gcorebg.c and gcorebg.exp files to allow not specifying the data-directory. The other issue is that the testsuite assumes that the `gcore` to test is always the one from the build tree. However, if someone is testing an installed binary by setting GDB, I think that person would expect to test the `gcore` script next to the binary that was specified (unless GCORE is specified to explicitly specified). This patch does that adjustment as well. To that end, it needs to move the block setting GCORE after the block setting GDB. Change-Id: I070e039903c0b5afeac357d8fac7d710ff6697b9 Approved-By: Tom Tromey <tom@tromey.com>
2025-01-30gdb: add first gdbreplay test, connect.expAlexandra Hájková1-0/+143
When the changes on the remote protocol are made, we want to test all the corner cases to prevent regressions. Currently it can be tricky to simulate some corner case conditions that would expose possible regressions. When I want to add or change the remote protocol packet, I need to hack gdbserver to send a corrupted packet or an error to make sure GDB is able to handle such a case. This test makes it easy to send a corruped packet or an error message to GDB using the gdbreplay tool and check GDB deals with it as we expect it to. This test starts a communication with gdbsever setting the remotelog file. Then, it modifies the remotelog with update_log proc, injects an error message instead of the expected replay to the vMustReplyEmpty packet in order to test GDB reacts to the error response properly. After the remotelog modification, this test restarts GDB and starts communication with gdbreply instead of the gdbserver using the remotelog. Add a lib/gdbreplay-support.exp. update_log proc matches lines from GDB to gdbserver in a remotelogfile. Once a match is found then the custom line is used to build a replacement line to send from gdbserver to GDB. Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-01-29Use command style in "help" commandTom Tromey1-2/+2
This changes the help command to use the new command style when displaying text like: List of "catch" subcommands: As a side effect, this mildly -- but not hugely -- cleans up some i18n issues in help_list. The header comment for that function is also changed to the gdb style. Finally, this function used to print something like: Type "help catch" followed by catch subcommand name for full documentation. The second "catch" here seems redundant to me, so this patch removes it.
2025-01-29gdb/testsuite: add comments to line table from DWARF assemblerAndrew Burgess1-7/+7
Add comments to the assembler generated by the DWARF assembler that builds the line table. I found these comments useful when debugging issues with the line table parsing. This patch should make no difference to what is being tested. The test binaries should be unchanged after this commit. Approved-By: Kevin Buettner <kevinb@redhat.com>
2025-01-22Remove gnatmake_version_at_leastTom Tromey1-21/+0
This removes gnatmake_version_at_least in favor of using the more flexible gnat_version_compare. I think these two version numbers should be the same, as gnatmake is shipped with the compiler.
2025-01-16[gdb/testsuite] Fix timeouts in gdb.threads/step-over-thread-exit.expTom de Vries1-1/+8
Once in a while, I run into a timeout in test-case gdb.threads/step-over-thread-exit.exp: ... (gdb) continue^M Continuing.^M [New Thread 0xfffff7cff1a0 (LWP 2874854)]^M ^M Thread 97 "step-over-threa" hit Breakpoint 2, 0x0000000000410314 in \ my_exit_syscall () at gdb/testsuite/lib/my-syscalls.S:74^M 74 SYSCALL (my_exit, __NR_exit)^M (gdb) [Thread 0xfffff7cff1a0 (LWP 2874853) exited]^M FAIL: $exp: step_over_mode=displaced: non-stop=on: target-non-stop=on: \ schedlock=off: cmd=continue: ns_stop_all=0: iter 95: continue (timeout) ... I can reproduce it more frequently by running with taskset -c <slow core id>. Fix this by using -no-prompt-anchor. This requires us to add -no-prompt-anchor to proc gdb_test_multiple. Tested on aarch64-linux. PR testsuite/32489 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32489
2025-01-15gdb/testsuite: make gdb.reverse/i386-avx-reverse.exp require also avx2Jan Vrany1-0/+45
The test gdb.reverse/i386-avx-reverse.exp requires CPU to have AVX instructions but it actually also uses AVX2 instructions (like vpcmpeqd). This caused the test to fail on CPUs that have AVX but not AVX2. This commit adds check for AVX2. Tested on Intel Xeon CPU E3-1265L (no AVX2) and Intel Core i7-1355U (has AVX2).
2025-01-12Add an option with a color type.Andrei Pikas2-12/+17
Colors can be specified as "none" for terminal's default color, as a name of one of the eight standard colors of ISO/IEC 6429 "black", "red", "green", etc., as an RGB hexadecimal tripplet #RRGGBB for 24-bit TrueColor, or as an integer from 0 to 255. Integers 0 to 7 are the synonyms for the standard colors. Integers 8-15 are used for the so-called bright colors from the aixterm extended 16-color palette. Integers 16-255 are the indexes into xterm extended 256-color palette (usually 6x6x6 cube plus gray ramp). In general, 256-color palette is terminal dependent and sometimes can be changed with OSC 4 sequences, e.g. "\033]4;1;rgb:00/FF/00\033\\". It is the responsibility of the user to verify that the terminal supports the specified colors. PATCH v5 changes: documentation fixed. PATCH v6 changes: documentation fixed. PATCH v7 changes: rebase onto master and fixes after review. PATCH v8 changes: fixes after review.
2025-01-07testsuite: adapt to new --debug command line optionChristina Schimpe1-10/+19
Since commit "gdbserver: allow the --debug command line option to take a value", gdbserver no longer supports --debug --remote-debug --event-loop-debug. Instead, --debug now takes a comma separated list of components. The make check parameter GDBSERVER_DEBUG doesn't support these changes yet. This patch fixes this, by adding the --debug gdbserver arguments, as "debug-threads", "debug-remote", "debug-event-loop" or "debug-all" for GDBSERVER_DEBUG. Replay logging is still enabled by adding the "replay" GDBSERVER_DEBUG argument. We can also configure "all" to enable all of the available options. Now, for instance, we can use it as follows: make check GDBSERVER_DEBUG="debug-remote,debug-event-loop,replay" RUNTESTFLAGS="--target_board=native-gdbserver" TESTS="gdb.trace/ftrace.exp" or simply make check GDBSERVER_DEBUG="all" RUNTESTFLAGS="--target_board=native-gdbserver" TESTS="gdb.trace/ftrace.exp" to enable all debug options. Approved-By: Tom Tromey <tom@tromey.com>
2025-01-06Handle linesStartAt1 in DAPTom Tromey1-6/+9
The DAP initialize request has a "linesStartAt1" option, where the client can indicate that it prefers whether line numbers be 0-based or 1-based. This patch implements this. I audited all the line-related code in the DAP implementation. Note that while a similar option exists for column numbers, gdb doesn't handle these yet, so nothing is done here. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32468
2024-12-12Replace uses of "title" style with "command"Tom Tromey1-0/+1
Currently the "title" style is only used when printing command names. The "title" name itself is probably a misnomer, but meanwhile this patch changes the existing uses to instead use the new "command" style for consistency. The "title" style is not removed; see the next patch. Reviewed-By: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-09Fix error check in gdb_py_test_silent_cmdTom Tromey1-0/+1
I added a new test using gdb_py_test_silent_cmd, and then was surprised to find out that the new test passed -- it caused a Python exception and I had expected it to fail. This patch fixes this proc to detect this situation and fail.
2024-12-09Defer DAP launch command until after configurationDoneTom Tromey1-14/+19
PR dap/32090 points out that gdb's DAP "launch" sequencing is incorrect. The current approach (which is itself a 2nd implementation...) was based on a misreading of the spec. The spec has since been clarified here: https://github.com/microsoft/debug-adapter-protocol/issues/497 The clarification here is that a client is free to send the "launch" (or "attach") request at any point after the "initialized" event has been sent by gdb. However, the "launch" does not cause any action to be taken -- and does not send a response -- until after "configurationDone" has been seen. This patch implements this by arranging for the launch and attach commands to return a DeferredRequest object. All the tests needed updates. I've also added a new test that checks that the deferred "launch" request can be cancelled. (Note that the cancellation is lazy -- it also waits until configurationDone is seen. This could be fixed, but I was not sure whether it is important to do so.) Finally, the "launch" command has a somewhat funny sequencing now. Simply sending the command and waiting for a response yielded strange results if the inferior did not stop -- in this case, the repsonse was never sent. So now, the command is split into two parts, with some setup being done synchronously (for better error propagation) and the actual "run" being done async. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32090 Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-11-26nios2: Remove all GDB support for Nios II targets.Sandra Loosemore1-1/+1
Intel has EOL'ed the Nios II architecture, and it's time to remove support from all toolchain components before it gets any more bit-rotten from lack of maintenance or regular testing.
2024-11-25gdb: LoongArch: Add basic process record/replay supportHui Li1-0/+2
GDB provides a special process record and replay target that can record a log of the process execution, and replay it later with both forward and reverse execution commands. This patch adds the basic support of process record and replay on LoongArch, it allows users to debug basic LoongArch instructions and provides reverse debugging support. Here is a simple example on LoongArch: $ cat test.c int a = 0; int main() { a = 1; a = 2; return 0; } $ gdb test ... (gdb) start ... Temporary breakpoint 1, main () at test.c:4 4 a = 1; (gdb) record (gdb) p a $1 = 0 (gdb) n 5 a = 2; (gdb) n 6 return 0; (gdb) p a $2 = 2 (gdb) rn 5 a = 2; (gdb) rn Reached end of recorded history; stopping. Backward execution from here not possible. main () at test.c:4 4 a = 1; (gdb) p a $3 = 0 (gdb) record stop Process record is stopped and all execution logs are deleted. (gdb) c Continuing. [Inferior 1 (process 129178) exited normally] Signed-off-by: Hui Li <lihui@loongson.cn> Approved-By: Guinevere Larsen <guinevere@redhat.com> (record-full) Approved-By: Tom Tromey <tom@tromey.com> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-11-23[gdb/contrib] Add two rules in common-misspellings.txtTom de Vries1-2/+2
Eli mentioned [1] that given that we use US English spelling in our documentation, we should use "behavior" instead of "behaviour". In wikipedia-common-misspellings.txt there's a rule: ... behavour->behavior, behaviour ... which leaves this as a choice. Add an overriding rule to hardcode the choice to common-misspellings.txt: ... behavour->behavior ... and add a rule to rewrite behaviour into behavior: ... behaviour->behavior ... and re-run spellcheck.sh on gdb*. Tested on x86_64-linux. [1] https://sourceware.org/pipermail/gdb-patches/2024-November/213371.html
2024-11-21gdb/build-id: protect against weirdly short build-idsAndrew Burgess1-3/+10
While looking at build_id_to_bfd_suffix (in gdb/build-id.c) I realised that GDB would likely not do what we wanted if a build-id was ever a single byte. Right now, build-ids generated by the GNU linker are 32 bytes, but there's nothing that forces this to be the case, it's pretty easy to create a fake, single byte, build-id. Given that the build-id is an external input (read from the objfile), GDB should protect itself against these edge cases. The problem with build_id_to_bfd_suffix is that this function creates the path used to lookup either the debug information, or an executable, based on its build-id. So a 3-byte build-id 0xaabbcc will look in the path: `$DEBUG_FILE_DIRECTORY/.build-id/aa/bbcc.debug`. However, a single byte build-id 0xaa, will look in the file: `$DEBUG_FILE_DIRECTORY/.build-id/aa/.debug` which doesn't seem right. Worse, when looking for an objfile given a build-id GDB will look for a file called `$DEBUG_FILE_DIRECTORY/.build-id/aa/` with a trailing '/' character. I propose that, in build_id_to_bfd_suffix we just return early if the build-id is 1 byte (or less) with a return value that indicates no separate file was found. For testing I made use of the DWARF assembler. I needed to update the build-id creation proc, the existing code assumes that the build-id is a multiple of 4 bytes, so I added some additional padding to ensure that the generated note was a multiple of 4 bytes, even if the build-id was not. I added a test with a 1 byte build-id, and also for the case where the build-id has zero length. The zero length case already does what you'd expect (no debug is loaded) as the bfd library rejects the build-id when loading it from the objfile, but adding this additional test is pretty cheap. Approved-By: Kevin Buettner <kevinb@redhat.com>
2024-11-21testsuite: skip confirmation in 'gdb_reinitialize_dir'Rohr, Stephan1-2/+4
Some shells automatically confirm the 'dir' command: (gdb) dir Reinitialize source path to empty? (y or n) [answered Y; input not from terminal] Source directories searched: $cdir;$cwd (gdb) y dir <...>/gdb/testsuite/gdb.base Undefined command: "y". Try "help". For example, this reprdocues in a MinGW32 environment with 'TERM=dumb'. Skip sending 'y' if the command is already confirmed. Approved-By: Tom Tromey <tom@tromey.com>
2024-11-18LAM: Enable tagged pointer support for watchpoints.Christina Schimpe1-0/+64
The Intel (R) linear address masking (LAM) feature modifies the checking applied to 64-bit linear addresses. With this so-called "modified canonicality check" the processor masks the metadata bits in a pointer before using it as a linear address. LAM supports two different modes that differ regarding which pointer bits are masked and can be used for metadata: LAM 48 resulting in a LAM width of 15 and LAM 57 resulting in a LAM width of 6. This patch adjusts watchpoint addresses based on the currently enabled LAM mode using the untag mask provided in the /proc/<pid>/status file. As LAM can be enabled at runtime or as the configuration may change when entering an enclave, GDB checks enablement state each time a watchpoint is updated. In contrast to the patch implemented for ARM's Top Byte Ignore "Clear non-significant bits of address on memory access", it is not necessary to adjust addresses before they are passed to the target layer cache, as for LAM tagged pointers are supported by the system call to read memory. Additionally, LAM applies only to addresses used for data accesses. Thus, it is sufficient to mask addresses used for watchpoints. The following examples are based on a LAM57 enabled program. Before this patch tagged pointers were not supported for watchpoints: ~~~ (gdb) print pi_tagged $2 = (int *) 0x10007ffffffffe004 (gdb) watch *pi_tagged Hardware watchpoint 2: *pi_tagged (gdb) c Continuing. Couldn't write debug register: Invalid argument. ~~~~ Once LAM 48 or LAM 57 is enabled for the current program, GDB can now specify watchpoints for tagged addresses with LAM width 15 or 6, respectively. Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-11-13[gdb/contrib] Add "doens't->doesn't" to common-misspellings.txtTom de Vries1-1/+1
Add "doens't->doesn't" to gdb/contrib/common-misspellings.txt, and run gdb/contrib/spellcheck.sh to fix this in a few files. Tested on x86_64-linux. Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-11-12gdb/readline: don't get stuck thinking an EOF arrivedAndrew Burgess1-0/+28
It was brought to my attention[1] that if a user makes use of Ctrl+d to quit from a secondary prompt (e.g. the prompt used to enter lines for the 'commands' command) then GDB will start displaying some unexpected blank lines. Here's an example: Reading symbols from /tmp/hello.x... (gdb) break main Breakpoint 1 at 0x401198: file hello.c, line 18. (gdb) commands Type commands for breakpoint(s) 1, one per line. End with a line saying just "end". >quit # <----------- Use Ctrl+d to quit here. (gdb) show architecture # <----------- This blank line is unexpected. The target architecture is set to "auto" (currently "i386:x86-64"). (gdb) I've marked up where I press 'Ctrl+d', and also the unexpected blank line. This issue will only happen if bracketed-paste-mode is in use. If this has been disabled (e.g. in ~/.inputrc) then this issue will not occur. The blank line is not just emitted for the 'show architecture' command. The blank line is actually caused by an extra '\n' character emitted by readline after it has gathered a complete line of input, and so will occur for any command. The problem is caused by readline getting "stuck" in a state where it thinks that an EOF has just been delivered. This state is set when the 'Ctrl+d' does deliver an EOF, but then this state is never fully reset. As a result, every time readline completes a line, it thinks that the line was completed due to an EOF and so adds an extra '\n' character. Obviously the real fix for this issue is to patch readline, and I do have a patch for that[2], however, version 8.2 of readline has been released, and contains this issue. As such, if GDB is linked against the system readline, and that system readline is 8.2, then we can expect to see this issue. There's a pretty simple, and cheap workaround that we can add to GDB that will mitigate this issue. I propose that we add this workaround to GDB. If/when the readline patch is accepted then I'll back-port this to our local readline copy, but retaining the workaround will be harmless, and will make GDB play nicer with system readline libraries (version 8.2). [1] https://inbox.sourceware.org/gdb-patches/34ef5438-8644-44cd-8537-5068e0e5e434@redhat.com [2] https://lists.gnu.org/archive/html/bug-readline/2024-10/msg00014.html Reviewed-By: Keith Seitz <keiths@redhat.com>
2024-11-08Add dw2-aranges.expAlexandra Hájková1-2/+13
This test checks that GDB is able to load DWARF information when .debug_aranges has a section address size that is set to 0. This test was originally written by Jan Kratochvil to test commit 927aa2e778d from 2017, titled "DWARF-5: .debug_names index consumer". This test was originally written using a static .S file and has been present in the Fedora tree for a long time. If dwarf2/aranges.c is modified to turn off the address_size check, GDB will crash with SIGFPE when loading the executable with address size set to zero. I modified the DWARF assembler to make it possible to set the address size to zero in a .debug_aranges section and used the DWARF assembler to produce the assembly file. Co-Authored-By: Jan Kratochvil <jan.kratochvil@redhat.com> Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-10-25[gdb/testsuite] Fix gdb.cp/exceptprint.exp with check-read1Tom de Vries1-1/+2
Fix test-case gdb.cp/exceptprint.exp with make target check-read1 by limiting the output of skip_libstdcxx_probe_tests_prompt by making the used command more precise: using "info probes stap libstdcxx" instead of "info probes". Tested on x86_64-linux.
2024-10-23gdb/testsuite: introduce dwarf5 option to gdb_compileGuinevere Larsen1-0/+8
A few tests on the testsuite require dwarf5 to work. Up until now, the way to do this was to explicitly add the command line flag -gdwarf-5. This isn't very portable, in case a compiler requires a different flag to emit dwarf5. This commit adds a new option to gdb_compile that would be able to add the correct flag (if known) or error out in case we are unable to tell which flag to use. It also changes the existing tests to use this general option instead of hard coding -gdwarf-5. Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Tom Tromey <tom@tromey.com>