aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.trace
AgeCommit message (Collapse)AuthorFilesLines
2 daysgdb/testsuite: fix duplicate test names in gdb.trace/Andrew Burgess4-30/+30
After this commit: commit 35f09cd5d7fdd1a64f4d1751e73c3495bef1ed99 Date: Wed Jul 31 15:04:25 2024 +0200 [gdb/testsuite] Detect trailing-text-in-parentheses duplicates we are now seeing some duplicate test names in gdb.trace/ tests when using native-gdbserver or native-extended-gdbserver boards. This is all due to tests that use some text in trailing parenthesis to make the test name unique. I've gone through and edited the test names as best I could to make them all unique. Hopefully the updated test names should all make sense. On my machine I'm no longer seeing any duplicates with either of the boards listed above. Acked-By: Tom de Vries <tdevries@suse.de>
2024-10-06[gdb] Fix common misspellingsTom de Vries2-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-23[gdb/testsuite] Fix gdb.trace/entry-values.exp on riscv64-linuxTom de Vries1-0/+2
On riscv64-linux, with test-case gdb.trace/entry-values.exp I run into: ... (gdb) disassemble bar^M Dump of assembler code for function bar:^M 0x0000000000000646 <+0>: addi sp,sp,-48^M 0x0000000000000648 <+2>: sd ra,40(sp)^M 0x000000000000064a <+4>: sd s0,32(sp)^M 0x000000000000064c <+6>: addi s0,sp,48^M 0x000000000000064e <+8>: mv a5,a0^M 0x0000000000000650 <+10>: sw a5,-36(s0)^M 0x0000000000000654 <+14>: li a5,2^M 0x0000000000000656 <+16>: sw a5,-20(s0)^M 0x000000000000065a <+20>: lw a4,-20(s0)^M 0x000000000000065e <+24>: lw a5,-36(s0)^M 0x0000000000000662 <+28>: mv a1,a4^M 0x0000000000000664 <+30>: mv a0,a5^M 0x0000000000000666 <+32>: jal 0x628 <foo>^M 0x000000000000066a <+36>: mv a5,a0^M 0x000000000000066c <+38>: mv a0,a5^M 0x000000000000066e <+40>: ld ra,40(sp)^M 0x0000000000000670 <+42>: ld s0,32(sp)^M 0x0000000000000672 <+44>: addi sp,sp,48^M 0x0000000000000674 <+46>: ret^M End of assembler dump.^M (gdb) FAIL: gdb.trace/entry-values.exp: disassemble bar FAIL: gdb.trace/entry-values.exp: find the call or branch instruction offset in bar ... Fix this by setting call_insn to jal for riscv64. Tested on riscv64-linux and x86_64-linux.
2024-09-13testsuite, trace: add guards if In-Process Agent library is not foundStephan Rohr12-5/+12
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-08-29gdb: reject inserting breakpoints between functionsAndrew Burgess2-3/+4
When debugging ROCm code, you might have something like this: __global__ void kernel () { ... // break here ... } int main () { // Code to call `kernel` } ... where kernel is a function compiled to execute on the GPU. It does not exist in the host x86-64 program that runs the main function, and GDB doesn't know about that function until it is called, at which point the runtime loads the corresponding code object and GDB learns about the code of the "kernel" function. Before the GPU code object is loaded, from the point of view of GDB, you might as well have blank lines instead of the "kernel" function. The DWARF in the host program doesn't describe anything at these lines. So, a common problem that users face is: - Start GDB with the host binary - Place a breakpoint by line number at the "break here" line - At this point, GDB only knows about the host code, the lines of the `kernel` function are a big void. - GDB finds no code mapped to the "break here" line and searches for the first following line that has code mapped to it. - GDB finds that the line with the opening bracket of the `main` function (or around there) has code mapped to it, places breakpoint there. - User runs the program. - The programs hits the breakpoint at the start of main. - User is confused, because they didn't ask for a breakpoint in main. If they continue, the code object eventually gets loaded, GDB reads the debug info from it, re-evaluates the breakpoint locations, and at this point the breakpoint is placed at the expected location. The goal of this patch is to get rid of this annoyance. A case similar to the one shown above can actually be simulated without GPU-specific code: using a single source file to generate a library and an executable loading that library (see the new test gdb.linespec/line-breakpoint-outside-function.c for an example). Before the library is loaded, trying to place a breakpoint in the library code results in the breakpoint "drifting" down to the main function. To address this problem, make it so that when a user requests a breakpoint outside a function, GDB makes a pending breakpoint, rather than placing a breakpoint at the next line with code, which happens to be in the next function. When the GPU kernel or shared library gets loaded, the breakpoint resolves to a location in the kernel or library. Note that we still want breakpoints placed inside a function to "drift" down to the next line with code. For example, here: 9 10 void foo() 11 { 12 int x; 13 14 x++; There is probably no code associated to lines 10, 12 and 13, but the user can still reasonably expect to be able to put a breakpoint there. In my experience, GCC maps the function prologue to the line with the opening curly bracket, so the user will be able to place a breakpoint there anyway (line 11 in the example). But I don't really see a use case to put a breakpoint above line 10 and expect to get a breakpoint in foo. So I think that is a reasonable behavior change for GDB. This is implemented using the following heuristic: - If a breakpoint is requested at line L but there is no code mapped to L, search for a following line with associated code (this already exists today). - However, if: 1. the found location falls in a function symbol's block 2. the found location's address is equal the entry PC of that function 3. the found location's line is greater that the requested line ... then we don't place a breakpoint at the found location, we will end up with a pending breakpoint. Change the message "No line X in file..." to "No compiled code for line X in file...". There is clearly a line 9 in the example above, so it would be weird to say "No line 9 in file...". What we mean is that there is no code associated to line 9. All the regressions that I found this patch to cause were: 1. tests specifically this behavior where placing a breakpoint before a function results in a breakpoint on that function, in which case I removed the tests or changed them to expect a pending breakpoint 2. linespec tests expecting things like "break -line N garbage" to error out because of the following garbage, but we now got a different error because line N now doesn't resolve to something anymore. For example, before: (gdb) break -line 3 if foofoofoo == 1 No symbol "foofoofoo" in current context. became (gdb) break -line 3 if foofoofoo == 1 No line 3 in the current file. These tests were modified to refer to a valid line with code, so that we can still test what we intended to test. Notes: - The CUDA compiler "solves" this problem by adding dummy function symbols between functions, that are never called. So when you try to insert a breakpoint in the not-yet-loaded kernel, the breakpoint still drifts, but is placed on some dummy symbol. For reasons that would be too long to explain here, the ROCm compiler does not do that, and it is not a desirable option. - You can have constructs like this: void host_function() { struct foo { static void __global__ kernel () { // Place breakpoint here } }; // Host code that calls `kernel` } The heuristic won't work then, as the breakpoint will drift somewhere inside the enclosing function, but won't be at the start of that function. So a bogus breakpoint location will be created on the host side. I don't think that people are going to use this kind of construct often though, so we can probably ignore it (or at least it shouldn't prevent making the more common case better). ROCm doesn't support passing a lambda kernel function to hipLaunchKernelGGL (the function used to launch kernels on the device), but if it eventually does, there will be the same problem. I think that to properly support this, we will need some DWARF improvements to be able to say "there is really nothing at these lines" in the line table. Co-Authored-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: I3cc12cfa823dc7d8e24dd4d35bced8e8baf7f9b6
2024-07-31[gdb/testsuite] Fix trailing-text-in-parentheses duplicatesTom de Vries1-2/+2
Fix all trailing-text-in-parentheses duplicates exposed by previous patch. Tested on x86_64-linux and aarch64-linux.
2024-06-14gdb/aarch64: prevent crash from in process agentAndrew Burgess2-0/+68
Since this commit: commit 0ee6b1c511c0e2a6793568692d2e5418cd6bc10d Date: Wed May 18 13:32:04 2022 -0700 Use aarch64_features to describe register features in target descriptions. There has been an issue with how aarch64 target descriptions are cached within gdbserver, and specifically, how this caching impacts the in process agent (IPA). The function initialize_tracepoint_ftlib (gdbserver/tracepoint.cc) is part of the IPA, this function is a constructor function, i.e. is called as part of the global initialisation process. We can't guarantee the ordering of when this function is called vs when other global state is initialised. Now initialize_tracepoint_ftlib calls initialize_tracepoint, which calls initialize_low_tracepoint, which for aarch64 calls aarch64_linux_read_description. The aarch64_linux_read_description function lives in linux-aarch64-tdesc.cc and after the above commit, depends on a std::unordered_map having been initialized. Prior to the above commit aarch64_linux_read_description used a global C style array, which obviously requires no runtime initialization. The consequence of the above is that any inferior linked with the IPA (for aarch64) will experience undefined behaviour (access to an uninitialized std::unordered_map) during startup, which for me manifests as a segfault. I propose fixing this by moving the std::unordered_map into the function body, but leaving it static. The map will now be initialized the first time the function is called, which removes the undefiend behaviour. The same problem exists for the expedited_registers global, however this global can just be made into a function local instead. The expedited_registers variable is used to build a pointer list which is then passed to init_target_desc, however init_target_desc copies the values it is given so expedited_registers does not need to live longer than its containing function. On most of the AArch64 machines I have access too tracing is not supported, and so the gdb.trace/*.exp tests that use the IPA just exit early reporting unsupported. I've added a test which links an inferior with the IPA and just starts the inferior. No tracing is performed. This exposes the current issue even on hosts that don't support tracing. After this patch the test passes.
2024-04-26gdb_is_target_remote -> gdb_protocol_is_remotePedro Alves3-12/+11
This is similar to the previous patch, but for gdb_protocol_is_remote. gdb_is_target_remote and its MI cousin mi_is_target_remote, use "maint print target-stack", which is unnecessary when checking whether gdb_protocol is "remote" or "extended-remote" would do. Checking gdb_protocol is more efficient, and can be done before starting GDB and running to main, unlike gdb_is_target_remote/mi_is_target_remote. This adds a new gdb_protocol_is_remote procedure, and uses it in place of gdb_is_target_remote/mi_is_target_remote throughout. There are no uses of gdb_is_target_remote/mi_is_target_remote left after this. Those will be eliminated in a following patch. In some spots, we no longer need to defer the check until after starting GDB, so the patch adjusts accordingly. Change-Id: I90267c132f942f63426f46dbca0b77dbfdf9d2ef Approved-By: Tom Tromey <tom@tromey.com>
2024-03-29[gdb/testsuite] Add missing includes in gdb.trace/collection.cTom de Vries1-0/+3
On fedora rawhide, with test-case gdb.trace/collection.exp, I get: ... gdb compile failed, collection.c: In function 'strings_test_func': collection.c:227:13: error: implicit declaration of function 'malloc' \ [-Wimplicit-function-declaration] 227 | longloc = malloc(500); | ^~~~~~ collection.c:1:1: note: \ include '<stdlib.h>' or provide a declaration of 'malloc' +++ |+#include <stdlib.h> 1 | /* This testcase is part of GDB, the GNU debugger. collection.c:228:3: error: implicit declaration of function 'strcpy' \ [-Wimplicit-function-declaration] 228 | strcpy(longloc, ... ); | ^~~~~~ collection.c:1:1: note: include '<string.h>' or provide a declaration of \ 'strcpy' +++ |+#include <string.h> 1 | /* This testcase is part of GDB, the GNU debugger. collection.c:230:8: error: implicit declaration of function 'strlen' \ [-Wimplicit-function-declaration] 230 | i += strlen (locstr); | ^~~~~~ collection.c:230:8: note: include '<string.h>' or provide a declaration of \ 'strlen' ... Fix this by adding the missing includes. Tested on aarch64-linux. Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-25[gdb/testsuite] Fix tdlabel_re referencesTom de Vries2-0/+3
Commit 467a34bb9e6 ("gdb tests: Allow for "LWP" or "process" in thread IDs from info threads") introduces a new global variable tdlabel_re, but fails to indicate it's global when used in procs in four test-cases. Fix this by adding "global tdlabel_re". Tested on aarch64-linux.
2024-03-22gdb tests: Allow for "LWP" or "process" in thread IDs from info threadsJohn Baldwin2-2/+2
Several tests assume that the first word after a thread ID in 'info threads' output is "Thread". However, several targets use "LWP" instead such as the FreeBSD and NetBSD native targets. The Linux native target also uses "LWP" if libthread_db is not being used. Targets that do not support threads use "process" as the first word via normal_pid_to_str. Add a tdlabel_re global variable as a regular-expression for a thread label in `info threads' that matches either "process", "Thread", or "LWP". Some other tests in the tree don't require a specific word, and some targets may use other first words (e.g. OpenBSD uses "thread" and Ravenscar threads use "Ravenscar Thread").
2024-03-05gdb/testsuite: fix duplicate test names in gdb.trace/circ.expAndrew Burgess1-31/+45
This fixes some duplicate test names in gdb.trace/circ.exp when using native-gdbserver and native-extended-gdbserver boards. In this test we set the trace buffer size twice. The same test name was used each time the size was adjusted. I've fixed this issue by: 1. Creating a new proc, set_trace_buffer_size, which factors out the code to change the buffer size, and uses test names based on the size we're setting the buffer too, 2. Calling the new proc each time we want to adjust the buffer size. After this the duplicate test names are resolved. There should be no change in what is tested after this commit.
2024-03-05gdb/testsuite: fix some more duplicate test names in gdb.trace/Andrew Burgess2-55/+46
This commit fixes some duplicate test names in the gdb.trace/ directory when run with the native-gdbserver and native-extended-gdbserver boards. In this case the duplicates relate to the calls to gdb_compile_pthreads which emits a fixed PASS message, as there are two calls to gdb_compile_pthreads we get a duplicate PASS message. In both cases the problem is fixed by adding a with_test_prefix around one of the compilations, however, I've made additional changes to clean up the tests a little while I was working on them: 1. Switch to use prepare_for_testing instead of gdb_compile_pthreads. By passing the 'pthreads' option this does call gdb_compile_pthreads under the hood, but using the standard compile function is cleaner, 2. Using prepare_for_testing removes the need to call clean_restart immediately afterwards, so those calls are removed, 3. I removed the unneeded $executable and $expfile globals, where the $executable global was used I've replaced this with $binfile, 4. When we compile two executables I've now given these different names so that both exist at the end of the test run, 5. Removed a gdb_reinitialize_dir call, this is covered by clean_restart, 6. Use gdb_test_no_output where it makes sense. I now see no duplicate test names when running these test scripts. There should be no change in what is being tested after this commit.
2024-02-01gdb/testsuite: fix some duplicate test names in gdb.trace/Andrew Burgess3-9/+15
This commit fixes some of the easier duplicate test names in the gdb.trace/ directory. All of these duplicates are resolved by either given tests a name, or by extended the existing name to make it more descriptive. There should be no change in what is tested after this commit.
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess85-85/+85
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2023-04-28gdb/testsuite: additional test fixes after gdb_test changesAndrew Burgess8-123/+102
After this commit: commit e2f620135d92f7cd670af4e524fffec7ac307666 Date: Thu Mar 30 13:26:25 2023 +0100 gdb/testsuite: change newline patterns used in gdb_test There were some regressions in gdb.trace/*.exp tests when run with the native-gdbserver board. This commit fixes these regressions. All the problems are caused by unnecessary trailing newline characters included in the patterns passed to gdb_test. After the above commit the testsuite is stricter when matching trailing newlines, and so the additional trailing newline characters are now causing the test to fail. Fix by removing all the excess trailing newline characters. In some cases this cleanup means we should use gdb_test_no_output, I've done that where appropriate. In a couple of other places I've made use of multi_line to better build the expected output pattern.
2023-04-27gdb/testsuite: change newline patterns used in gdb_testAndrew Burgess6-98/+108
This commit makes two changes to how we match newline characters in the gdb_test proc. First, for the newline pattern between the command output and the prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'. The old pattern would spot multiple newlines, and so there are a few places where, as part of this commit, I've needed to add an extra trailing '\r\n' to the pattern in the main test file, where GDB's output actually includes a blank line. But I think this is a good thing. If a command produces a blank line then we should be checking for it, the current gdb_test doesn't do that. But also, with the current gdb_test, if a blank line suddenly appears in the output, this is going to be silently ignored, and I think this is wrong, the test should fail in that case. Additionally, the existing pattern will happily match a partial newline. There are a strangely large number of tests that end with a random '.' character. Not matching a literal period, but matching any single character, this is then matching half of the trailing newline sequence, while the \[\r\n\]+ in gdb_test is matching the other half of the sequence. I can think of no reason why this would be intentional, I suspect that the expected output at one time included a period, which has since been remove, but I haven't bothered to check on this. In this commit I've removed all these unneeded trailing '.' characters. The basic rule of gdb_test after this is that the expected pattern needs to match everything up to, but not including the newline sequence immediately before the GDB prompt. This is generally how the proc is used anyway, so in almost all cases, this commit represents no significant change. Second, while I was cleaning up newline matching in gdb_test, I've also removed the '[\r\n]*' that was added to the start of the pattern passed to gdb_test_multiple. The addition of this pattern adds no value. If the user pattern matches at the start of a line then this would match against the newline sequence. But, due to the '*', if the user pattern doesn't match at the start of a line then this group doesn't care, it'll happily match nothing. As such, there's no value to it, it just adds more complexity for no gain, so I'm removing it. No tests will need updating as a consequence of this part of the patch. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-10Use require with target_infoTom Tromey1-4/+1
This changes many tests to use 'require' when checking target_info. In a few spots, the require is hoisted to the top of the file, to avoid doing any extra work when the test is going to be skipped anyway.
2023-01-30gdb: Make global feature array a per-remote target arrayChristina Schimpe2-3/+7
This patch applies the appropriate FIXME notes described in commit 5b6d1e4 "Multi-target support". "You'll notice that remote.c includes some FIXME notes. These refer to the fact that the global arrays that hold data for the remote packets supported are still globals. For example, if we connect to two different servers/stubs, then each might support different remote protocol features. They might even be different architectures, like e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a host/controller scenario as a single program. That isn't going to work correctly today, because of said globals. I'm leaving fixing that for another pass, since it does not appear to be trivial, and I'd rather land the base work first. It's already useful to be able to debug multiple instances of the same server (e.g., a distributed cluster, where you have full control over the servers installed), so I think as is it's already reasonable incremental progress." Using this patch it is possible to configure per-remote targets' feature packets. Given the following setup for two gdbservers: ~~~~ gdbserver --multi :1234 gdbserver --disable-packet=vCont --multi :2345 ~~~~ Before this patch configuring of range-stepping was not possible for one of two connected remote targets with different support for the vCont packet. As one of the targets supports vCont, it should be possible to configure "set range-stepping". However, the output of GDB looks like: (gdb) target extended-remote :1234 Remote debugging using :1234 (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) target extended-remote :2345 Remote debugging using :2345 (gdb) set range-stepping on warning: Range stepping is not supported by the current target (gdb) inferior 1 [Switching to inferior 1 [<null>] (<noexec>)] (gdb) set range-stepping on warning: Range stepping is not supported by the current target ~~~~ Two warnings are shown. The warning for inferior 1 should not appear as it is connected to a target supporting the vCont package. ~~~~ (gdb) target extended-remote :1234 Remote debugging using :1234 (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) target extended-remote :2345 Remote debugging using :2345 (gdb) set range-stepping on warning: Range stepping is not supported by the current target (gdb) inferior 1 [Switching to inferior 1 [<null>] (<noexec>)] (gdb) set range-stepping on (gdb) ~~~~ Now only one warning is shown for inferior 2, which is connected to a target not supporting vCont. The per-remote target feature array is realized by a new class remote_features, which stores the per-remote target array and provides functions to determine supported features of the target. A remote_target object now has a new member of that class. Each time a new remote_target object is initialized, a new per-remote target array is constructed based on the global remote_protocol_packets array. The global array is initialized in the function _initialize_remote and can be configured using the command line. Before this patch the command line configuration affected current targets and future remote targets (due to the global feature array used by all remote targets). This behavior is different and the configuration applies as follows: - If a target is connected, the command line configuration affects the current connection. All other existing remote targets are not affected. - If not connected, the command line configuration affects future connections. The show command displays the current remote target's configuration. If no remote target is selected the default configuration for future connections is shown. If we have for instance the following setup with inferior 2 being selected: ~~~~ (gdb) info inferiors Num Description Connection Executable 1 <null> 1 (extended-remote :1234) * 2 <null> 2 (extended-remote :2345) ~~~~ Before this patch, if we run 'set remote multiprocess-feature-packet', the following configuration was set: The feature array of all remote targets (in this setup the two connected targets) and all future remote connections are affected. After this patch, it will be configured as follows: The feature array of target with port :2345 which is currently selected will be configured. All other existing remote targets are not affected. The show command 'show remote multiprocess-feature-packet' will display the configuration of target with port :2345. Due to this configuration change, it is required to adapt the test "gdb/testsuite/gdb.multi/multi-target-info-inferiors.exp" to configure the multiprocess-feature-packet before the connections are created. To inform the gdb user about the new behaviour of the 'show remote PACKET-NAME' commands and the new configuration impact for remote targets using the 'set remote PACKET-NAME' commands the commands' outputs are adapted. Due to this change it is required to adapt each test using the set/show remote 'PACKET-NAME' commands.
2023-01-26Use clean_restart in gdb.traceTom Tromey20-140/+33
Change gdb.trace to use clean_restart more consistently.
2023-01-26Use mi_clean_restart moreTom Tromey2-30/+7
This changes a number of MI tests to use mi_clean_restart rather than separate calls. This reduces the number of lines, which is nice, and also provides a nicer model to copy for future tests.
2023-01-26Eliminate spurious returns from the test suiteTom Tromey4-8/+0
A number of tests end with "return". However, this is unnecessary. This patch removes all of these.
2023-01-25Add unsupported calls where neededTom Tromey1-0/+1
A number of tests will exit early without saying why. This patch adds "unsupported" at spots like this that I could readily find. There are definitely more of these; for example dw2-ranges.exp fails silently because a compilation fails. I didn't attempt to address these as that is a much larger task.
2023-01-25Introduce and use is_any_targetTom Tromey1-3/+1
A few tests work on two different targets that can't be detected with a single call to istarget -- that proc only accepts globs, not regular expressions. This patch introduces a new is_any_target proc and then converts these tests to use it in a 'require'.
2023-01-13Rename to allow_shlib_testsTom Tromey12-12/+12
This changes skip_shlib_tests to invert the sense, and renames it to allow_shlib_tests.
2023-01-13Use require gdb_trace_common_supports_archTom Tromey28-112/+28
This changes some tests to use "require gdb_trace_common_supports_arch".
2023-01-13Use require is_amd64_regs_targetTom Tromey1-4/+1
This changes some tests to use "require is_amd64_regs_target".
2023-01-13Use require !skip_shlib_testsTom Tromey12-36/+12
This changes some tests to use "require !skip_shlib_tests".
2023-01-13Use require dwarf2_supportTom Tromey2-6/+2
This changes some tests to use "require dwarf2_support".
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker85-85/+85
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-12-13gdb/testsuite: avoid creating temp file in gdb/testsuite/ directoryAndrew Burgess1-1/+1
After this commit: commit 33c1395cf5e9deec7733691ba32c450e5c27f757 Date: Fri Nov 11 15:26:46 2022 +0000 gdb/testsuite: fix gdb.trace/unavailable-dwarf-piece.exp with Clang The gdb.trace/unavailable-dwarf-piece.exp test script was creating a temporary file in the build/gdb/testsuite/ directory, instead of in the expected place in the outputs directory. Fix this by adding a call to standard_output_file.
2022-11-28gdb/testsuite: remove use of then keyword from gdb.trace/*.expAndrew Burgess22-38/+38
The canonical form of 'if' in modern TCL is 'if {} {}'. But there's still a bunch of places in the testsuite where we make use of the 'then' keyword, and sometimes these get copies into new tests, which just spreads poor practice. This commit removes all use of the 'then' keyword from the gdb.trace/ test script directory. There should be no changes in what is tested after this commit.
2022-11-18gdb/testsuite: fix gdb.trace/unavailable-dwarf-piece.exp with ClangAndrew Burgess1-2/+2
I noticed that the test gdb.trace/unavailable-dwarf-piece.exp was failing when run with Clang. Or rather, the test was not running as the test executable failed to compile. The problem is that Clang was emitting this warning: warning: argument unused during compilation: '-fdiagnostics-color=never' [-Wunused-command-line-argument] This warning is emitted when compiling the assembler file generated by the DWARF assembler. Most DWARF assembler tests generate the assembler file into a file with the '.S' extension. However, this particular test uses a '.s' extension. Now a .S file will be passed through the preprocessor, while a .s will be sent straight to the assembler. My guess is that Clang doesn't support the -fdiagnostics-color=never option for the assembler, but does for the preprocessor. That's a little annoying, but easily worked around. We don't care if our assembler file is passed through the preprocessor, so, in this commit, I just change the file extension from .s to .S, and the problem is fixed. Currently, the unavailable-dwarf-piece.exp script names the assembler file using standard_output_file, in this commit I've switched to make use of standard_testfile, as that seems to be the more common way of doing this sort of thing. With these changes the test now passes with Clang 9.0.1 and 15.0.2, and also still passes with gcc. Reviewed-By: Lancelot SIX <lancelot.six@amd.com>
2022-07-07Fix pedantically invalid DWARF in gdb.trace/unavailable-dwarf-piece.expPedro Alves1-2/+2
The DWARF spec says: Any debugging information entry representing the declaration of an object, module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and DW_AT_decl_column attributes, each of whose value is an unsigned integer ^^^^^^^^ constant. Grepping around the DWARF-assembler-based testcases, I noticed that gdb.trace/unavailable-dwarf-piece.exp emits decl_line with DW_FORM_sdata, a signed integer form. This commit tweaks it to use DW_FORM_udata instead. Unsurprisingly, this: $ make check \ TESTS="gdb.trace/unavailable-dwarf-piece.exp" \ RUNTESTFLAGS="--target_board=native-gdbserver" ... still passes cleanly for me after this change. I've noticed this because current llvm-dwarfdump crashed on an ROCm-internal DWARF-assembler-based testcase that incorrectly used signed forms for DW_AT_decl_file/DW_AT_decl_line. The older llvm-dwarfdump found on Ubuntu 20.04 (LLVM 10) reads the line numbers with signed forms as "0" instead of crashing. Here's the before/after fix for gdb.trace/unavailable-dwarf-piece.exp with that llvm-dwarfdump version: $ diff -up before.txt after.txt --- before.txt 2022-07-07 13:21:28.387690334 +0100 +++ after.txt 2022-07-07 13:21:39.379801092 +0100 @@ -18,7 +18,7 @@ DW_AT_name ("s") DW_AT_byte_size (3) DW_AT_decl_file (0) - DW_AT_decl_line (0) + DW_AT_decl_line (1) 0x0000002f: DW_TAG_member DW_AT_name ("a") @@ -41,7 +41,7 @@ DW_AT_name ("t") DW_AT_byte_size (3) DW_AT_decl_file (0) - DW_AT_decl_line (0) + DW_AT_decl_line (1) 0x00000054: DW_TAG_member DW_AT_name ("a") Change-Id: I5c866946356da421ff944019d0eca2607b2b738f
2022-06-24gdb/testsuite: remove unneeded calls to get_compiler_infoAndrew Burgess2-8/+0
It is not necessary to call get_compiler_info before calling test_compiler_info, and, after recent commits that removed setting up the gcc_compiled, true, and false globals from get_compiler_info, there is now no longer any need for any test script to call get_compiler_info directly. As a result every call to get_compiler_info outside of lib/gdb.exp is redundant, and this commit removes them all. There should be no change in what is tested after this commit.
2022-05-31gdb/testsuite: resolve duplicate test name in gdb.trace/signal.expAndrew Burgess1-3/+7
Spotted a duplicate test name in gdb.trace/signal.exp, resolved in this commit by making use of 'with_test_prefix'.
2022-05-30gdb/testsuite: fix gdb.trace/signal.exp on x86Simon Marchi1-1/+1
Patch 202be274a41a ("opcodes/i386: remove trailing whitespace from insns with zero operands") causes this regression: FAIL: gdb.trace/signal.exp: find syscall insn in kill It's because the test still expects to match a whitespace after the instruction, which the patch mentioned above removed. Remove the whitespaces for the regexp. Change-Id: Ie194273cc942bfd91332d4035f6eec55b7d3a428
2022-05-25gdb: Fix DUPLICATE and PATH regressions throughoutPedro Alves10-444/+451
The previous patch to add -prompt/-lbl to gdb_test introduced a regression: Before, you could specify an explicit empty message to indicate you didn't want to PASS, like so: gdb_test COMMAND PATTERN "" After said patch, gdb_test no longer distinguishes no-message-specified vs empty-message, so tests that previously would be silent on PASS, now started emitting PASS messages based on COMMAND. This in turn introduced a number of PATH/DUPLICATE violations in the testsuite. This commit fixes all the regressions I could see. This patch uses the new -nopass feature introduced in the previous commit, but tries to avoid it if possible. Most of the patch fixes DUPLICATE issues the usual way, of using with_test_prefix or explicit unique messages. See previous commit's log for more info. In addition to looking for DUPLICATEs, I also looked for cases where we would now end up with an empty message in gdb.sum, due to a gdb_test being passed both no message and empty command. E.g., this in gdb.ada/bp_reset.exp: gdb_run_cmd gdb_test "" "Breakpoint $decimal, foo\\.nested_sub \\(\\).*" was resulting in this in gdb.sum: PASS: gdb.ada/bp_reset.exp: I fixed such cases by passing an explicit message. We may want to make such cases error out. Tested on x86_64 GNU/Linux, native and native-extended-gdbserver. I see zero PATH cases now. I get zero DUPLICATEs with native testing now. I still see some DUPLICATEs with native-extended-gdbserver, but those were preexisting, unrelated to the gdb_test change. Change-Id: I5375f23f073493e0672190a0ec2e847938a580b2
2022-05-16gdb/testsuite: fix "continue outside of loop" TCL errorsBruno Larsen3-5/+5
Many test cases had a few lines in the beginning that look like: if { condition } { continue } Where conditions varied, but were mostly in the form of ![runto_main] or [skip_*_tests], making it quite clear that this code block was supposed to finish the test if it entered the code block. This generates TCL errors, as most of these tests are not inside loops. All cases on which this was an obvious mistake are changed in this patch.
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker85-85/+85
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-09-30gdb/testsuite: make runto_main not pass no-message to runtoSimon Marchi34-76/+0
As follow-up to this discussion: https://sourceware.org/pipermail/gdb-patches/2020-August/171385.html ... make runto_main not pass no-message to runto. This means that if we fail to run to main, for some reason, we'll emit a FAIL. This is the behavior we want the majority of (if not all) the time. Without this, we rely on tests logging a failure if runto_main fails, otherwise. They do so in a very inconsisteny mannet, sometimes using "fail", "unsupported" or "untested". The messages also vary widly. This patch removes all these messages as well. Also, remove a few "fail" where we call runto (and not runto_main). by default (without an explicit no-message argument), runto prints a failure already. In two places, gdb.multi/multi-re-run.exp and gdb.python/py-pp-registration.exp, remove "message" passed to runto. This removes a few PASSes that we don't care about (but FAILs will still be printed if we fail to run to where we want to). This aligns their behavior with the rest of the testsuite. Change-Id: Ib763c98c5f4fb6898886b635210d7c34bd4b9023
2021-09-25[gdb/testsuite] Minimize gdb restartsTom de Vries1-1/+0
Minimize gdb restarts, applying the following rules: - don't use prepare_for_testing unless necessary - don't use clean_restart unless necessary Also, if possible, replace build_for_executable + clean_restart with prepare_for_testing for brevity. Touches 68 test-cases. Tested on x86_64-linux.
2021-02-26testsuite: Remove extra \n from expected output of tsv notificationsJan Vrany1-5/+5
Commit 2450ad54 removed extra trailing \n from tsv notifications but did not update gdb.trace/mi-tsv-changed.exp accordingly. This commit removes the extra \n from expected output so gdb.trace/mi-tsv-changed.exp passes again. gdb/testsuite/ChangeLog: * gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Remove trailing \n from expected output.
2021-01-09Fix erroneous agent expression testTom Tromey1-1/+1
Testing of the expression rewrite revealed a buglet in ax.exp. One test does: gdb_test "maint agent (unsigned char)1L" ".*ext 8.*" However, zero extension is not actually needed in this case -- a simple "const8 1" is also correct here. This patch changes the test to look for a push of any width of the constant 1. gdb/testsuite/ChangeLog 2021-01-09 Tom Tromey <tom@tromey.com> * gdb.trace/ax.exp: Do not require an "ext".
2021-01-01Update copyright year range in all GDB filesJoel Brobecker85-85/+85
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-11-17Fix gdb.trace testcase build failures with ClangGary Benson1-1/+1
25 gdb.trace tests failed to build on x86 with Clang because the x86_trace_dummy function is optimized out, causing the builds to fail with variations on the following error: gdb compile failed, /usr/bin/ld: /gdbtest/build/gdb/testsuite/outputs/gdb.trace/backtrace/backtrace0.o: in function `main': /gdbtest/src/gdb/testsuite/gdb.trace/actions.c:146: undefined reference to `x86_trace_dummy' clang-12: error: linker command failed with exit code 1 This commit adds __attribute__ ((used)) to x86_trace_dummy to prevent this. gdb/testsuite/ChangeLog: * gdb.trace/trace-common.h (x86_trace_dummy): Add __attribute__ ((used)).
2020-10-13Eliminate mi_run_to_main, introduce mi_clean_restartPedro Alves3-16/+8
Since we now have mi_runto_main which is like runto_main, eliminate mi_run_to_main, in favor of a new MI clean_restart counterpart -- mi_clean_restart -- and mi_runto_main. This makes MI testcases look a bit more like CLI testcases. gdb/testsuite/ChangeLog: * lib/mi-support.exp (mi_clean_restart): New. (mi_run_to_main): Delete. All callers adjust to use mi_clean_restart / mi_runto_main. Change-Id: I34920bab4fea1f23fb752928c2969c1f6ad714b6
2020-10-13gdb/testsuite/: Use "-qualified" in explicit "break main", etc.Pedro Alves2-3/+3
Similar to the previous patch, but this time add "-q" to tests that do "break main", "list main", etc. explicitly. gdb/testsuite/ChangeLog: * config/monitor.exp: Use "list -q". * gdb.arch/gdb1558.exp: Use "break -q". * gdb.arch/i386-permbkpt.exp: Use "break -q". * gdb.arch/i386-prologue-skip-cf-protection.exp: Use "break -q". * gdb.base/break.exp: Use "break -q", "list -q" and "tbreak -q". * gdb.base/commands.exp: Use "break -q". * gdb.base/condbreak.exp: Use "break -q". * gdb.base/ctf-ptype.exp: Use "list -q". * gdb.base/define.exp: Use "break -q". * gdb.base/del.exp: Use "break -q". * gdb.base/fullname.exp: Use "break -q". * gdb.base/hbreak-in-shr-unsupported.exp: Use "hbreak -q". * gdb.base/hbreak-unmapped.exp: Use "hbreak -q". * gdb.base/hbreak2.exp: Use "hbreak -q" and "list -q". * gdb.base/hw-sw-break-same-address.exp: Use "break -q" and "hbreak -q". * gdb.base/included.exp: Use "list -q". * gdb.base/label.exp: Use "break -q". * gdb.base/lineinc.exp: Use "break -q". * gdb.base/list.exp: Use "list -q". * gdb.base/macscp.exp: Use "list -q". * gdb.base/pending.exp: Use "break -q". * gdb.base/prologue-include.exp: Use "break -q". * gdb.base/ptype.exp: Use "list -q". * gdb.base/sepdebug.exp: Use "break -q", "list -q" and "tbreak -q". * gdb.base/server-del-break.exp: Use "break -q". * gdb.base/style.exp: Use "break -q". * gdb.base/symbol-without-target_section.exp: Use "list -q". * gdb.base/watchpoint-reuse-slot.exp: Use "hbreak -q". * gdb.cp/exception.exp: Use "tbreak -q". * gdb.dwarf2/dw2-error.exp: Use "break -q". * gdb.dwarf2/fission-mix.exp: Use "break -q". * gdb.dwarf2/fission-reread.exp: Use "break -q". * gdb.dwarf2/pr13961.exp: Use "break -q". * gdb.linespec/explicit.exp: Use "list -q". * gdb.linespec/linespec.exp: Use "break -q". * gdb.mi/mi-simplerun.exp: Use "--qualified". * gdb.python/py-mi-objfile-gdb.py: Use "list -q". * gdb.server/bkpt-other-inferior.exp: Use "break -q". * gdb.server/connect-without-multi-process.exp: Use "break -q". * gdb.trace/change-loc.exp: Use "break -q". * gdb.trace/pending.exp: Use "break -q". * gdb.tui/basic.exp: Use "list -q". * gdb.tui/list-before.exp: Use "list -q". * gdb.tui/list.exp: Use "list -q". * lib/gdb.exp (gdb_has_argv0): Use "break -q". Change-Id: Iab9408e90ed71cbb111cd737d2d81b5ba8adb108
2020-09-13gdb/testsuite: Explicitly return from mainPedro Alves1-0/+2
I've been playing with a board file that forces every testcase to include a header file that does something like: #define main __gdb_testcase_main and then links an actual main() function that does some initialization and then jumps to __gdb_testcase_main. That runs into a number of testcases relying on main not having an explicit return statement, like e.g.,: gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-follow-exec.c:27:1: warning: non-void function does not return a value [-Wreturn-type] gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-signal.c:47:1: warning: non-void function does not return a value [-Wreturn-type] We don't get those warnings without my board because it is valid to not explicitly return from main. There's an implicit "return 0;". Since it doesn't hurt to be explicit, I've went ahead and added the explicit return statements. Also, a couple testcases either don't explicitly specify main's return type, or return void. Those are tweaked to explicitly return int. gdb/testsuite/ChangeLog: * gdb.base/catch-follow-exec.c (main): Add explicit return statement. * gdb.base/catch-signal.c (main): Likewise. * gdb.base/condbreak-call-false.c (main): Likewise. * gdb.base/consecutive.c (main): Add explicit return statement and return type. * gdb.base/cursal.c (main): Add explicit return statement. * gdb.base/cvexpr.c (main): Likewise. * gdb.base/display.c (main): Add explicit return statement and return type. * gdb.base/dprintf-detach.c (main): Add explicit return statement. * gdb.base/endianity.c (main): Likewise. * gdb.base/execd-prog.c (main): Likewise. * gdb.base/gdb1090.c (main): Likewise. * gdb.base/info_qt.c (main): Likewise. * gdb.base/lineinc.c (main): Likewise. * gdb.base/load-command.c (main): Likewise. * gdb.base/macscp1.c (main): Likewise. * gdb.base/pr10179-a.c (main): Likewise. * gdb.base/quit-live.c (main): Likewise. * gdb.base/scope0.c (main): Likewise. * gdb.base/settings.c (main): Likewise. * gdb.base/stack-checking.c (main): Return int. * gdb.base/varargs.c (main): Add explicit return statement. * gdb.cp/ambiguous.cc (main): Likewise. * gdb.cp/anon-struct.cc (main): Likewise. * gdb.cp/anon-union.cc (main): Likewise. * gdb.cp/bool.cc (main): Likewise. * gdb.cp/bs15503.cc (main): Likewise. * gdb.cp/cplusfuncs.cc (main): Likewise. * gdb.cp/cttiadd.cc (main): Likewise. * gdb.cp/extern-c.cc (main): Likewise. * gdb.cp/filename.cc (main): Likewise. * gdb.cp/formatted-ref.cc (main): Likewise. * gdb.cp/mb-ctor.cc (main): Likewise. * gdb.cp/member-ptr.cc (main): Likewise. * gdb.cp/minsym-fallback-main.cc (main): Likewise. * gdb.cp/overload-const.cc (main): Likewise. * gdb.cp/paren-type.cc (main): Likewise. * gdb.cp/parse-lang.cc (main): Likewise. * gdb.cp/pr-1023.cc (main): Likewise. * gdb.cp/psmang1.cc (main): Likewise. * gdb.cp/readnow-language.cc (main): Likewise. * gdb.cp/ref-params.cc (main): Likewise. * gdb.cp/rvalue-ref-params.cc (main): Likewise. * gdb.cp/virtbase2.cc (main): Likewise. * gdb.dwarf2/dw2-abs-hi-pc.c (main): Likewise. * gdb.dwarf2/dw2-namespaceless-anonymous.c (main): Likewise. * gdb.dwarf2/dw4-toplevel-types.cc (main): Likewise. * gdb.mi/mi-console.c (main): Likewise. * gdb.mi/mi-read-memory.c (main): Likewise. * gdb.modula2/multidim.c (main): Likewise. * gdb.opt/inline-small-func.c (main): Likewise. * gdb.python/py-rbreak.c (main): Likewise. * gdb.stabs/exclfwd1.c (main): Likewise. * gdb.trace/qtro.c (main): Likewise.
2020-08-20gdb: fix typo "breapoint" -> "breakpoint"Tankut Baris Aktemur1-1/+1
gdb/ChangeLog: 2020-08-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * infrun.c (process_event_stop_test): Fix typo "breapoint". gdb/testsuite/ChangeLog: 2020-08-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.base/print-file-var.exp: Fix typo "breapoint". * gdb.trace/strace.exp: Ditto.