aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
AgeCommit message (Collapse)AuthorFilesLines
8 hours[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
28 hoursgdb/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).
4 daysAdd 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.
9 daystestsuite: 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>
10 daysHandle 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>
2024-10-21[gdb/symtab] Fix incorrect filenames with inter-CU refsTom de Vries1-0/+4
With target board unix we get: ... $ gdb -q -batch outputs/gdb.cp/cplusfuncs/cplusfuncs \ -ex "info function operator\*" All functions matching regular expression "operator\*": File /home/vries/gdb/src/gdb/testsuite/gdb.cp/cplusfuncs.cc: 72: void foo::operator*(foo&); 85: void foo::operator*=(foo&); ... but with target board cc-with-dwz-m: ... All functions matching regular expression "operator\*": File /usr/lib/gcc/aarch64-redhat-linux/14/include/stddef.h: 72: void foo::operator*(foo&); 85: void foo::operator*=(foo&); ... The first operator: ... $ c++filt _ZN3foomlERS_ foo::operator*(foo&) ... matches address 0x410250 which is defined here in the CU in the exec: ... <1><10f1>: Abbrev Number: 13 (DW_TAG_subprogram) <10f2> DW_AT_specification: <alt 0x93> <10f6> DW_AT_decl_line : 72 <10f7> DW_AT_decl_column : 7 <10f7> DW_AT_object_pointer: <0x1106> <10f9> DW_AT_low_pc : 0x410250 <1101> DW_AT_high_pc : 32 <1102> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <1104> DW_AT_call_all_calls: 1 ... and declared here in the PU in the .dwz file: ... <2><93>: Abbrev Number: 20 (DW_TAG_subprogram) <94> DW_AT_external : 1 <94> DW_AT_name : operator* <98> DW_AT_decl_file : 2 <98> DW_AT_decl_line : 10 <99> DW_AT_decl_column : 9 <9a> DW_AT_linkage_name: _ZN3foomlERS_ <9e> DW_AT_accessibility: 1 (public) <9e> DW_AT_declaration : 1 <9e> DW_AT_object_pointer: <0xa2> ... When creating a new symbol for the operator, the DW_AT_decl_file attribute is looked up, and found to be 2. The 2 is supposed to be mapped using the PU, which has this file name table: ... The File Name Table (offset 0x78, lines 3, columns 2): Entry Dir Name 0 0 <dwz> 1 1 stddef.h 2 2 cplusfuncs.cc ... Instead, it's mapped using the CU, which has this file name table: ... The File Name Table (offset 0x34, lines 3, columns 2): Entry Dir Name 0 1 cplusfuncs.cc 1 1 cplusfuncs.cc 2 2 stddef.h ... This is PR symtab/30814. There's a similar PR for lto, PR symtab/25771, where the same problem happens for two CUs. Fix this by using the correct file name table. Add a dwarf assembly test-case for PR25771. Tested on aarch64-linux. Reviewed-By: Tom Tromey <tom@tromey.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25771 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30814
2024-10-15Introduce and use gnat_version_compareTom Tromey2-2/+31
While testing a modified GNAT, I found that this test in fun_renaming.exp was returning 0 for GCC 13: if {[test_compiler_info {gcc-6*}]} This patch introduces a new, more robust way to check the GNAT compiler version, and changes the gda.ada tests to use it. A small update to version_compare was also needed. Note that, in its current form, this new code won't really interact well with non-GCC compilers (specifically gnat-llvm). This doesn't seem like a major issue at this point, though, because gnat-llvm doesn't properly emit debuginfo yet, and when it does, more changes will be needed in these tests anyway. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-10-10[gdb/testsuite] Fix gdb.dwarf2/enum-type-c++.exp with clangTom de Vries1-16/+50
When running test-case gdb.dwarf2/enum-type-c++.exp with clang, we get: ... FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent FAIL: gdb.dwarf2/enum-type-c++.exp: print ns::A::val1 FAIL: gdb.dwarf2/enum-type-c++.exp: val2 has correct parent FAIL: gdb.dwarf2/enum-type-c++.exp: print ns::ec::val2 ... The problem is that the debug info produced by clang does not contain any references to enumerators val1 and val2, or the corresponding enumeration types. Instead, the variables u1 and u2 are considered to be simply of type int: ... <1><fb>: Abbrev Number: 2 (DW_TAG_variable) <fc> DW_AT_name : u1 <fd> DW_AT_type : <0x106> <101> DW_AT_external : 1 <103> DW_AT_location : (DW_OP_addrx <0>) <1><106>: Abbrev Number: 3 (DW_TAG_base_type) <107> DW_AT_name : int <108> DW_AT_encoding : 5 (signed) <109> DW_AT_byte_size : 4 <1><10a>: Abbrev Number: 2 (DW_TAG_variable) <10b> DW_AT_name : u2 <10c> DW_AT_type : <0x106> <110> DW_AT_external : 1 <112> DW_AT_location : (DW_OP_addrx <0x1>) ... Fix this by checking whether val1 and val2 are present in the cooked index before checking whether they have the correct parent. This cannot be expressed efficiently with gdb_test_lines, so factor out gdb_get_lines and use that instead. The test-case still calls "maint print objfiles" twice, but the first time is for have_index. We should probably use a gdb_caching_proc for this. Tested on aarch64-linux. Reported-By: Guinevere Larsen <guinevere@redhat.com> Reviewed-By: Keith Seitz <keiths@redhat.com> Tested-By: Guinevere Larsen <guinevere@redhat.com>
2024-10-06[gdb] Fix common misspellingsTom de Vries3-3/+3
Fix the following common misspellings: ... accidently -> accidentally additonal -> additional addresing -> addressing adress -> address agaisnt -> against albiet -> albeit arbitary -> arbitrary artifical -> artificial auxillary -> auxiliary auxilliary -> auxiliary bcak -> back begining -> beginning cannonical -> canonical compatiblity -> compatibility completetion -> completion diferent -> different emited -> emitted emiting -> emitting emmitted -> emitted everytime -> every time excercise -> exercise existance -> existence fucntion -> function funtion -> function guarentee -> guarantee htis -> this immediatly -> immediately layed -> laid noone -> no one occurances -> occurrences occured -> occurred originaly -> originally preceeded -> preceded preceeds -> precedes propogate -> propagate publically -> publicly refering -> referring substract -> subtract substracting -> subtracting substraction -> subtraction taht -> that targetting -> targeting teh -> the thier -> their thru -> through transfered -> transferred transfering -> transferring upto -> up to vincinity -> vicinity whcih -> which whereever -> wherever wierd -> weird withing -> within writen -> written wtih -> with doesnt -> doesn't ... Tested on x86_64-linux.
2024-09-30Add line-number stylingTom Tromey2-2/+3
This patch adds separate styling for line numbers. That is, whenever gdb prints a source line number, it uses this style. v2 includes a change to ensure that %ps works in query. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-09-25gdb, gdbserver, python, testsuite: Remove MPX.Schimpe, Christina1-89/+0
GDB deprecated the commands "show/set mpx bound" in GDB 15.1, as Intel listed Intel(R) Memory Protection Extensions (MPX) as removed in 2019. MPX is also deprecated in gcc (since v9.1), the linux kernel (since v5.6) and glibc (since v2.35). Let's now remove MPX support in GDB completely. This includes the removal of: - MPX functionality including register support - deprecated mpx commands - i386 and amd64 implementation of the hooks report_signal_info and get_siginfo_type - tests - and pretty printer. We keep MPX register numbers to not break compatibility with old gdbservers. Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-09-24btrace: Add support for interrupt events.Felix Willgerodt1-0/+56
Newer Intel CPUs support recording asynchronous events in the PT trace. Libipt also recently added support for decoding these. This patch adds support for interrupt events, based on the existing aux infrastructure. GDB can now display such events during the record instruction-history and function-call-history commands. Subsequent patches will add the rest of the events currently supported. Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-09-23[gdb/testsuite] Make parse_args error out on remaining argsTom de Vries2-7/+28
I noticed that introducing a typo here in gdb.mi/mi-breakpoint-changed.exp: ... set bp_re [mi_make_breakpoint \ - -number $bp_nr \ + -nunber $bp_nr \ -type dprintf \ -func marker \ -script [string_to_regexp {["printf \"arg\" \""]}]] ... didn't make the test fail. Proc mi_make_breakpoint uses parse_args, but does not check the remaining args as parse_args suggests: ... proc parse_args { argset } { parse_list 2 args $argset "-" false # The remaining args should be checked to see that they match the # number of items expected to be passed into the procedure } ... We could add the missing check in mi_make_breakpoint, but I think the problem is likely to occur again because the name parse_args does not suggest that further action is required. Fix this instead by: - copying proc parse_args to new proc parse_some_args, - adding new proc check_no_args_left, and - calling check_no_args_left in parse_args. Also be more strict in a few places where we do lassign for remaining args: ... lassign $args a b ... There may be more arguments left in $args, so check that that's not the case using check_no_args_left: ... set args [lassign $args a b] check_no_args_left ... Fix a few test-cases that trigger on the stricter checking. Tested on x86_64-linux. Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com> PR testsuite/32129 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32129
2024-09-13testsuite, trace: add guards if In-Process Agent library is not foundStephan Rohr1-0/+14
Several tests in gdb.trace trigger TCL errors if the In-Process Agent library is not found, e.g.: Running gdb/testsuite/gdb.trace/change-loc.exp ... ERROR: tcl error sourcing gdb/testsuite/gdb.trace/change-loc.exp. ERROR: error copying "gdb/gdb/testsuite/../../gdbserver/libinproctrace.so": no such file or directory while executing "file copy -force $fromfile $tofile" (procedure "gdb_remote_download" line 29) invoked from within "gdb_remote_download target $target_file" (procedure "gdb_download_shlib" line 6) invoked from within "gdb_download_shlib $file" (procedure "gdb_load_shlib" line 2) invoked from within "gdb_load_shlib $libipa" (file "gdb/testsuite/gdb.trace/change-loc.exp" line 354) invoked from within "source gdb/testsuite/gdb.trace/change-loc.exp" ("uplevel" body line 1) invoked from within "uplevel #0 source gdb/testsuite/gdb.trace/change-loc.exp" invoked from within "catch "uplevel #0 source $test_file_name"" Protect against this error by checking if the library is available.
2024-09-10gdb/testsuite: fix argument order in example code within a commentAndrew Burgess1-1/+1
Small typo in some example code inside a comment; the arguments were in the wrong order. There's no functional change after this commit.
2024-09-07gdb: split apart two different types of filename completionAndrew Burgess1-0/+10
Unfortunately we have two different types of filename completion in GDB. The majority of commands have what I call unquoted filename completion, this is for commands like 'set logging file ...', 'target core ...', and 'add-auto-load-safe-path ...'. For these commands everything after the command name (that is not a command option) is treated as a single filename. If the filename contains white space then this does not need to be escaped, nor does the filename need to be quoted. In fact, the filename argument is not de-quoted, and does not have any escaping removed, so if a user does try to add such things, they will be treated as part of the filename. As an example: (gdb) target core "/path/that contains/some white space" Will look for a directory calls '"' (double quotes) in the local directory. A small number of commands do de-quote and remove escapes from filename arguments. These command accept what I call quoted and escaped filenames. Right now these are the commands that specify the file for GDB to debug, so: file exec-file symbol-file add-symbol-file remove-symbol-file As an example of this in action: (gdb) file "/path/that contains/some white space" In this case GDB would load the file: /path/that contains/some white space Current filename completion always assumes that filenames can be quoted, though escaping doesn't work in completion right now. But the assumption that quoting is allowed is clearly wrong. This commit splits filename completion into two. The existing filename_completer is retained, and is used for unquoted filenames. A second filename_maybe_quoted_completer is added which can be used for completing quoted filenames. The filename completion test has been extended to cover more cases. As part of the extended testing I need to know the character that should be used to separate filenames within a path. For this TCL 8.6+ has $::tcl_platform(pathSeparator). To support older versions of TCL I've added some code to testsuite/lib/gdb.exp. You might notice that after this commit the completion for unquoted files is all done in the brkchars phase, that is the function filename_completer_handle_brkchars calculates the completions and marks the completion_tracker as using a custom word point. The reason for this is that we don't want to break on white space for this completion, but if we rely on readline to find the completion word, readline will consider the entire command line, and with no white space in the word break character set, readline will end up using the entire command line as the word to complete. For now at least, the completer for quoted filenames does generate its completions during the completion phase, though this is going to change in a later commit.
2024-09-07gdb: unify build-id to objfile lookup codeAndrew Burgess1-2/+5
There are 3 places where we currently call debuginfod_exec_query to lookup an objfile for a given build-id. In one of these places we first call build_id_to_exec_bfd which also looks up an objfile given a build-id, but this function looks on disk for a symlink in the .build-id/ sub-directory (within the debug-file-directory). I can't think of any reason why we shouldn't call build_id_to_exec_bfd before every call to debuginfod_exec_query. So, in this commit I have added a new function in build-id.c, find_objfile_by_build_id, this function calls build_id_to_exec_bfd, and if that fails, then calls debuginfod_exec_query. Everywhere we call debuginfod_exec_query is updated to call the new function, and in locate_exec_from_corefile_build_id, the existing call to build_id_to_exec_bfd is removed as calling find_objfile_by_build_id does this for us. One slight weird thing is in core_target::build_file_mappings, here we call find_objfile_by_build_id which returns a gdb_bfd_ref_ptr for the opened file, however we immediately reopen the file as "binary". The reason for this is that all the bfds opened in ::build_file_mappings need to be opened as "binary" (see the function comments for why). I did consider passing a target type into find_objfile_by_build_id, which could then be forwarded to build_id_to_exec_bfd and used to open the BFD as "binary", however, if you follow the call chain you'll end up in build_id_to_debug_bfd_1, where we actually open the bfd. Notice in here that we call build_id_verify to double check the build-id of the file we found, this requires that the bfd not be opened as "binary". What this means is that we always have to first open the bfd using the gnutarget target type (for the build-id check), and then we would have to reopen it as "binary". There seems little point pushing the reopen logic into find_objfile_by_build_id, so we just do this in the ::build_file_mappings function. I've extended the tests to cover the two cases which actually changed in this commit.
2024-09-06Introduce and use foreach_gnat_encodingTom Tromey1-0/+19
gnat-llvm does not support the -fgnat-encodings flag. This patch prepares gdb's Ada tests to handle this situation by introducing a new foreach_gnat_encoding. A subsequent patch may change this to support gnat-llvm; meanwhile this is a little cleaner anyway.
2024-09-06Fix the build-id option for GCC default configurationBernd Edlinger1-4/+5
It is possible that the compiler is configured to do so automatically, but at least for GCC the configure option --enable-linker-build-id is not enabled by default. So the option -Wl,--build-id should be used regardless of which compiler is used. Approved-By: Tom de Vries <tdevries@suse.de>
2024-08-31[gdb/testsuite] Handle unsupported catch syscallTom de Vries1-0/+49
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>
2024-08-28gdb/testsuite: add no-delete-breakpoints option to 'runto' procAndrew Burgess1-6/+11
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>
2024-08-20gdb/testsuite: track nested caching proc callsAndrew Burgess1-9/+75
It was pointed out in this email: https://inbox.sourceware.org/gdb-patches/97973506-79f4-4216-9c0b-57401b3933f5@arm.com that this commit: commit 0726729d344fecf98f8d138e688e77201cc3cece Date: Mon Jun 3 13:56:54 2024 +0100 gdb/testsuite: track if a caching proc calls gdb_exit or not had broken some AArch64 tests. What is going on is that there are two caching procs: allow_aarch64_sme_tests aarch64_initialize_sme_information the allow_aarch64_sme_tests proc makes a call to aarch64_initialize_sme_information, but aarch64_initialize_sme_information is also called from other non-caching procs, like aarch64_supports_sme_svl. Both of the caching procs mentioned above compile and run a helper program, and both of them call gdb_exit. After the above commit, the first call to any caching proc, the body of which calls gdb_exit, will result in a gdb_exit call even if the body is not executed and the result is fetched from the cache. What was observed is that in the first test script allow_aarch64_sme_tests is called, the body of this caching proc is run which calls gdb_exit. Then allow_aarch64_sme_tests calls aarch64_initialize_sme_information, the body of which is run and gdb_exit is called again. The results from both procs are added to the cache. In the next test script allow_aarch64_sme_tests is called. This results in a cache hit, but gdb_exit is also called as this is the first call in this second test script. Later in the test script aarch64_supports_sme_svl is called which calls aarch64_initialize_sme_information. As this is the first call to aarch64_initialize_sme_information in this second test script (remember the body of allow_aarch64_sme_tests was never run) then gdb_exit is called. This call to gdb_exit is new after the above commit and is unexpected. I think the idea behind the above commit is still sound. If the call to allow_aarch64_sme_tests was removed from the second test script then we would want the extra gdb_exit call as this would expose a real bug in the test. The problem is that after the above commit the nested nature of the caching proc calls becomes important: a call to allow_aarch64_sme_tests should mean that we've also called aarch64_initialize_sme_information, and that relationship isn't currently captured. So in this commit I'm adding another field to the global gdb_data_cache (in lib/cache.exp). This new field is 'also_called'. For every caching proc we populate this field with a list of names, these are the names of any nested caching procs that are called when the body of a caching proc is executed. Now when we get a cache hit in gdb_data_cache we mark every proc in the 'also_called' list as having been called. This means that further calls to these procs will no longer trigger a gdb_exit call. Approved-By: Luis Machado <luis.machado@arm.com> Tested-By: Luis Machado <luis.machado@arm.com>
2024-08-14btrace: Extend ptwrite event decoding.Felix Willgerodt1-0/+73
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-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-07-31[gdb/testsuite] Fix trailing-text-in-parentheses duplicatesTom de Vries1-15/+22
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-29Add a test for the gcore scriptAlexandra Hájková1-0/+17
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-28gdb/testsuite: track if a caching proc calls gdb_exit or notAndrew Burgess2-74/+135
After a recent patch review I asked myself why can_spawn_for_attach exists. This proc currently does some checks, and then calls can_spawn_for_attach_1 which is an actual caching proc. The answer is that can_spawn_for_attach exists in order to call gdb_exit the first time can_spawn_for_attach is called within any test script. The reason this is useful is that can_spawn_for_attach_1 calls gdb_exit. If the user calls can_spawn_for_attach_1 directly then a problem might exist. Imagine a test written like this: gdb_start if { [can_spawn_for_attach_1] } { ... do stuff that assumes GDB is running ... } If this test is NOT the first test run, and if an earlier test calls can_spawn_for_attach_1, then when the above test is run the can_spawn_for_attach_1 call will return the cached value and gdb_exit will not be called. But, if the above test IS the first test run then can_spawn_for_attach_1 will not return the cached value, but will instead compute the cached value, a process that ends up calling gdb_exit. When can_spawn_for_attach_1 returns GDB will have exited and the test might fail if it is written assuming that GDB is running. So can_spawn_for_attach was added which ensures that we _always_ call gdb_exit the first time can_spawn_for_attach is called within a single test script, this ensures that in the above case, even if the above is not the first test script run, gdb_exit will still be called. This ensures consistent behaviour and avoids some hidden bugs in the testsuite. The split between can_spawn_for_attach and can_spawn_for_attach_1 was introduced in this commit: commit 147fe7f9fb9a89b217d11d73053f53e8edacf90f Date: Mon May 6 14:27:09 2024 +0200 [gdb/testsuite] Handle ptrace operation not permitted in can_spawn_for_attach However, I observe that can_spawn_for_attach is not the only caching proc that calls gdb_exit. Why does can_spawn_for_attach get special treatment when surely the same issue exists for any other caching proc that calls gdb_exit? I think a better solution is to move the logic from can_spawn_for_attach into cache.exp and generalise it so that it applies to all caching procs. This commit does this by: 1. When the underlying caching proc is executed we track calls to gdb_exit. If a caching proc calls gdb_exit then this information is stored in gdb_data_cache (using a ',exit' suffix), and also written to the cache file if appropriate. 2. When a cached value is returned from gdb_do_cache, if the underlying proc would have called gdb_exit, and if this is the first use of the caching proc in this test script, then we call gdb_exit. When storing the ',exit' value into the on-disk cache file, the flag value is stored on a second line. Currently every cached value only occupies a single line, and a check is added to ensure this remains true in the future. To track calls to gdb_exit I eventually settled on using TCL's trace mechanism. We already make use of this in lib/gdb.exp so I figure this is OK to use. This should be fine, so long as non of the caching procs use 'with_override' to replace gdb_exit, or do any other proc replacement to change gdb_exit, however, I think that is pretty unlikely. One issue did come up in testing, a FAIL in gdb.base/break-interp.exp, prior to this commit can_spawn_for_attach would call gdb_exit before calling the underlying caching proc. After this call we call gdb_exit after calling the caching proc. The underlying caching proc relies on gdb_exit having been called. To resolve this issue I just added a call to gdb_exit into can_spawn_for_attach. With this done can_spawn_for_attach_1 can be renamed to can_spawn_for_attach, and the existing can_spawn_for_attach can be deleted.
2024-07-28gdb/testsuite: restructure gdb_data_cache (lib/cache.exp)Andrew Burgess1-9/+9
In the next commit I want to add more information to gdb_data_cache (see lib/cache.exp). Specifically I want to track if the underlying function of a caching proc calls gdb_exit or not. Currently gdb_data_cache is an associative array, the keys of which are the name of the caching proc. In this commit I add a ',value' suffix to the gdb_data_cache keys. In the next commit I'll add additional entries with a different suffix. There should be no noticable changes after this commit, this is just a restructuring.
2024-07-26gdb/testsuite: fix build-id compile option when used with clangAndrew Burgess1-2/+2
It was pointed out in this message: https://inbox.sourceware.org/gdb-patches/5d7a514b-5dad-446f-a021-444ea88ecf07@redhat.com That the test gdb.base/build-id-seqno.exp I added recently was FAILing when using Clang as the compiler. The problem was that I had failed to add 'build-id' as a compile option in the call to build_executable within the test script. For GCC this is fine as build-ids are included by default. For Clang though this meant the build-id was not included and the test would fail. So I added build-id to the compiler options.... and the test still didn't pass! Now the test fails to compile and I see this error from the compiler: gdb compile failed, clang-15: warning: -Wl,--build-id: 'linker' \ input unused [-Wunused-command-line-argument] It turns out that the build-id compile option causes our gdb.exp to add the '-Wl,--build-id' option into the compiler flags, which means its used when building the object file AND during the final link. However this option is unnecessary when creating the object file and Clang warns about this, which causes the build to fail. The solution is to change gdb.exp, instead of adding the build-id flags like this: lappend new_options "additional_flags=-Wl,--build-id" we should instead add them like: lappend new_options "ldflags=-Wl,--build-id" Now the flag is only appended during the link phase and Clang is happy. The gdb.base/build-id-seqno.exp test now passes with Clang. The same problem (adding to additional_flags instead of ldflags) exists for the no-build-id compile option, so I've fixed that too. While investigating this I also spotted two test scripts, gdb.base/index-cache.exp and gdb.dwarf2/per-bfd-sharing.exp which were setting ldflag directly rather than using the build-id compile option so I've updated these two tests to use the compile option which I think is neater. I've checked that all these tests still pass with both GCC and Clang. There should be no changes in what is actually tested after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-07-24[gdb/testsuite] Fix gdb.cp/m-static.exp on armTom de Vries1-0/+8
With test-case gdb.cp/m-static.exp on arm-linux, I get: ... (gdb) ptype test5.single_constructor^M type = class single_constructor {^M ^M public:^M single_constructor(void);^M ~single_constructor(void);^M } *(single_constructor * const)^M (gdb) FAIL: gdb.cp/m-static.exp: simple object instance, ptype constructor ... The test-case expects: - no empty line before "public:", and - no "~single_constructor(void)", but "~single_constructor()" The latter is due to commit 137c886e9a6 ("[gdb/c++] Print destructor the same for gcc and clang"). The failing test is in a part only enabled for is_aarch32_target == 1, so it looks like it was left behind. I'm assuming the same happened for the other difference. Fix this by updating the regexps to match the observed output. Tested on arm-linux. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-06-19[gdb/testsuite] Add string cat for tcl version < 8.6.2Tom de Vries1-7/+30
I noticed that we started using "string cat", which has been available since tcl version 8.6.2. Add a local implementation for use with older tcl versions. Tested on x86_64-linux. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-06-15[gdb/testsuite] Clean up lib/dg-add-core-file-count.shTom de Vries1-1/+1
Fix shellcheck warnings in script lib/dg-add-core-file-count.sh. Tested on x86_64-linux. Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-06-07gdb/aarch64: Disable displaced single-step for MOPS instructionsThiago Jung Bauermann1-0/+99
The AArch64 MOPS (Memory Operation) instructions provide a standardised instruction sequence to perform a memset, memcpy or memmove. A sequence is always composed of three instructions: a prologue instruction, a main instruction and an epilogue instruction. As an illustration, here are the implementations of these memory operations in glibc 2.39: (gdb) disassemble/r Dump of assembler code for function __memset_mops: => 0x0000fffff7e8d780 <+0>: d503201f nop 0x0000fffff7e8d784 <+4>: aa0003e3 mov x3, x0 0x0000fffff7e8d788 <+8>: 19c10443 setp [x3]!, x2!, x1 0x0000fffff7e8d78c <+12>: 19c14443 setm [x3]!, x2!, x1 0x0000fffff7e8d790 <+16>: 19c18443 sete [x3]!, x2!, x1 0x0000fffff7e8d794 <+20>: d65f03c0 ret End of assembler dump. (gdb) disassemble/r Dump of assembler code for function __memcpy_mops: => 0x0000fffff7e8c580 <+0>: d503201f nop 0x0000fffff7e8c584 <+4>: aa0003e3 mov x3, x0 0x0000fffff7e8c588 <+8>: 19010443 cpyfp [x3]!, [x1]!, x2! 0x0000fffff7e8c58c <+12>: 19410443 cpyfm [x3]!, [x1]!, x2! 0x0000fffff7e8c590 <+16>: 19810443 cpyfe [x3]!, [x1]!, x2! 0x0000fffff7e8c594 <+20>: d65f03c0 ret End of assembler dump. (gdb) disassemble/r Dump of assembler code for function __memmove_mops: => 0x0000fffff7e8d180 <+0>: d503201f nop 0x0000fffff7e8d184 <+4>: aa0003e3 mov x3, x0 0x0000fffff7e8d188 <+8>: 1d010443 cpyp [x3]!, [x1]!, x2! 0x0000fffff7e8d18c <+12>: 1d410443 cpym [x3]!, [x1]!, x2! 0x0000fffff7e8d190 <+16>: 1d810443 cpye [x3]!, [x1]!, x2! 0x0000fffff7e8d194 <+20>: d65f03c0 ret End of assembler dump. The Arm Architecture Reference Manual says that "the prologue, main, and epilogue instructions are expected to be run in succession and to appear consecutively in memory". Therefore this patch disables displaced stepping on them. The testcase verifies that MOPS sequences are correctly single-stepped. PR tdep/31666 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31666 Approved-By: Luis Machado <luis.machado@arm.com> Tested-By: Luis Machado <luis.machado@arm.com>
2024-06-05gdb/testsuite: remove trailing \r from rust_llvm_version resultAndrew Burgess1-1/+2
I noticed that the value returned by rust_llvm_version had a trailing carriage return. I don't think this is causing any problems right now, but looking at the code I don't think this was the desired behaviour. The current code runs 'rustc --version --verbose', splits the output at each '\n' and then loops over every line looking for the line that contains the LLVM version. There are two problems here. First, at the end of each captured line we have '\r\n', so when we split the lines on '\n', each of the lines will still end with a '\r' character. Second, though we loop over the lines, when we try to compare the line contents we actually compare the unsplit full output. Luckily this still finds the match, but this renders the loop over lines redundant. This commit makes two fixes: 1. I use regsub to convert all '\r\n' sequences to '\n'; now when we split on '\n' the lines will not end in '\r'. 2. Within the loop over lines block I now check the line contents rather than the unsplit full output; now we capture a value without a trailing '\r'. There's only one test (gdb.rust/simple.exp) that uses rust_llvm_version, and it doesn't care if there's a trailing '\r' or not, so this change should make no difference there. Approved-By: Tom Tromey <tom@tromey.com>
2024-06-04gdb/testsuite: tests for debug lookup within the sysrootAndrew Burgess1-0/+13
Add tests for looking up debug information within the sysroot via both build-id and gnu_debuglink. I wanted to ensure that the gnu_debuglink test couldn't make use of build-ids, so I added the 'no-build-id' flag to gdb_compile. As these tests rely on setting the sysroot, if I'm running a dynamically linked executable, GDB will try to find all shared libraries within the sysroot. This would mean I'd have to figure out and copy all shared libraries the executable uses, certainly possible, but a bit of a pain. So instead, I've just compiled the test executable as a static binary. Now there are no shared library dependencies. I can now split the debug information out from the test binary, and place it within the sysroot. When GDB is started and the executable loaded, we can check that GDB is finding the debug information within the sysroot. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31804 Approved-By: Tom de Vries <tdevries@suse.de>