aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-03-06[gdb/testsuite] Allow args in gdb_caching_procTom de Vries2-15/+18
Test-case gdb.base/morestack.exp contains: ... require {have_compile_flag -fsplit-stack} ... and I want to cache the result of have_compile_flag. Currently gdb_caching_proc doesn't allow args, so I could add: ... gdb_caching_proc have_compile_flag_fsplit_stack { return [have_compile_flag -fsplit-stack] } ... and then use that proc instead, but I find this cumbersome and maintenance-unfriendly. Instead, allow args in a gdb_caching_proc, such that I can simply do: ... -proc have_compile_flag { flag } { +gdb_caching_proc have_compile_flag { flag } { ... Note that gdb_caching_procs with args do not work with the gdb.base/gdb-caching-procs.exp test-case, so those procs are skipped. Tested on x86_64-linux. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06[gdb/testsuite] Use regular proc syntax for gdb_caching_procTom de Vries7-59/+62
A regular tcl proc with no args looks like: ... proc foo {} { return 1 } ... but a gdb_caching_proc deviates from that syntax by dropping the explicit no args bit: ... gdb_caching_proc foo { return 1 } ... Make the gdb_caching_proc use the same syntax as regular procs, such that we have instead: ... gdb_caching_proc foo {} { return 1 } ... Tested on x86_64-linux. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-01gdb: update some copyright years (2022 -> 2023)Simon Marchi2-2/+2
The copyright years in the ROCm files (e.g. solib-rocm.c) are wrong, they end in 2022 instead of 2023. I suppose because I posted (or at least prepared) the patches in 2022 but merged them in 2023, and forgot to update the year. I found a bunch of other files that are in the same situation. Fix them all up. Change-Id: Ia55f5b563606c2ba6a89046f22bc0bf1c0ff2e10 Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-28gdb/testsuite: fix failure in gdb.mi/mi-pending.exp with extended-remoteAndrew Burgess1-5/+14
I currently see this failure when running the gdb.mi/mi-pending.exp test using the native-extended-remote board: -break-insert -f -c x==4 mi-pendshr.c:pendfunc2 &"No source file named mi-pendshr.c.\n" ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="mi-pendshr.c:pendfunc2",cond="x==4",evaluated-by="host",times="0",original-location="mi-pendshr.c:pendfunc2"} (gdb) FAIL: gdb.mi/mi-pending.exp: MI pending breakpoint on mi-pendshr.c:pendfunc2 if x==4 (unexpected output) The failure is caused by the 'evaluated-by="host"' string, which only appears in the output when the test is run using the native-extended-remote board. I could fix this by just updating the pattern in gdb.mi/mi-pending.exp, but I have instead updated mi-pending.exp to make more use of the support procs in mi-support.exp. This did require making a couple of adjustments to mi-support.exp, but I think the result is that mi-pending.exp is now easier to read, and I see no failures with native-extended-remote anymore. One of the test names has changed after this work, I think the old test name was wrong - it described a breakpoint as pending when the breakpoint was not pending, I suspect a copy & paste error. But there's no changes to what is actually being tested after this patch. Approved-By: Pedro Alves <pedro@palves.net>
2023-02-28gdb/testsuite: introduce is_target_non_stop helper procAndrew Burgess1-0/+22
I noticed that several tests included copy & pasted code to run the 'maint show target-non-stop' command, and then switch based on the result. In this commit I factor this code out into a helper proc in lib/gdb.exp, and update all the places I could find that used this pattern to make use of the helper proc. There should be no change in what is tested after this commit. Reviewed-By: Pedro Alves <pedro@palves.net>
2023-02-28gdb/testsuite introduce foreach_mi_ui_mode helper procAndrew Burgess1-0/+44
Introduce foreach_mi_ui_mode, a helper proc which can be used when tests are going to be repeated once with the MI in the main UI, and once with the MI on a separate UI. The proc is used like this: foreach_mi_ui_mode VAR { # BODY } The BODY will be run twice, once with VAR set to 'main' and once with VAR set to 'separate', inside BODY we can then change the behaviour based on the current UI mode. The point of this proc is that we sometimes shouldn't run the separate UI tests (when gdb_debug_enabled is true), and this proc hides all this logic. If the separate UI mode should not be used then BODY will be run just once with VAR set to 'main'. I've updated two tests that can make use of this helper proc. I'm going to add another similar test in a later commit. There should be no change to what is tested with this commit. Approved-By: Pedro Alves <pedro@palves.net>
2023-02-28gdb/testsuite: extend the use of mi_clean_restartAndrew Burgess1-2/+2
The mi_clean_restart proc calls the mi_gdb_start proc passing no arguments. In this commit I add an extra (optional) argument to the mi_clean_restart proc, and pass this through to mi_gdb_start. The benefit of this is that we can now use mi_clean_restart when we also want to pass the 'separate-mi-tty' or 'separate-inferior-tty' flags to mi_gdb_start, and avoids having to otherwise duplicate the contents of mi_clean_restart in different tests. I've updated the obvious places where this new functionality can be used, and I'm seeing no test regressions. Reviewed-By: Pedro Alves <pedro@palves.net>
2023-02-28gdb: don't duplicate 'thread' field in MI breakpoint outputAndrew Burgess1-17/+41
When creating a thread-specific breakpoint with a single location, the 'thread' field would be repeated in the MI output. This can be seen in two existing tests gdb.mi/mi-nsmoribund.exp and gdb.mi/mi-pending.exp, e.g.: (gdb) -break-insert -p 1 bar ^done,bkpt={number="1",type="breakpoint",disp="keep", enabled="y", addr="0x000000000040110a",func="bar", file="/tmp/mi-thread-specific-bp.c", fullname="/tmp/mi-thread-specific-bp.c", line="32",thread-groups=["i1"], thread="1",thread="1", <================ DUPLICATION! times="0",original-location="bar"} I know we need to be careful when adjusting MI output, but I'm hopeful in this case, as the field is duplicated, and the field contents are always identical, that we might get away with removing one of the duplicates. The change in GDB is a fairly trivial condition change. We did have a couple of tests that contained the duplicate fields in their expected output, but given there was no comment pointing out this oddity either in the GDB code, or in the test, I suspect this was more a case of copying whatever output GDB produced and using that as the expected results. I've updated these tests to remove the duplication. I've update lib/mi-support.exp to provide support for building breakpoint patterns that contain the thread field, and I've made use of this in a new test I've added that is just about creating thread-specific breakpoints and checking the results. The two tests I mentioned above as being updated could also use the new lib/mi-support.exp functionality, but I'm going to do that in a later patch, this way it is clear what changes I'm actually proposing to make to the expected output. As I said, I hope that frontends will be able to handle this change, but I still think its worth adding a NEWS entry, that way, if someone runs into problems, there's a chance they can figure out what's going on. This should not impact CLI output at all. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Pedro Alves <pedro@palves.net>
2023-02-27gdb/testsuite: Improve testing of GDB's completion functionsBruno Larsen1-0/+16
When looking at some failures of gdb.linespec/cp-completion-aliases.exp, I noticed that when a completion test will fail, it always fails with a timeout. This is because most completion tests use gdb_test_multiple and only add a check for the correct output. This commit adds new options for both, tab and command completion. For command completion, the new option will check if the prompt was printed, and fail in this case. This is enough to know that the test has failed because the check comes after the PASS path. For tab completion, we have to check if GDB outputted more than just the input line, because sometimes GDB would have printed a partial line before finishing with the correct completion. Approved-By: Tom Tromey <tom@tromey.com>
2023-02-23Fix Tcl quoting in gdb_assertTom Tromey1-1/+1
The gdb_assert proc under-quotes the expression that is passed in. This leads to weird code in a couple of spots that tries to compensate: gdb_assert {{$all_regs eq $completed_regs}} ... The fix is to add a bit of quoting when evaluating the expression.
2023-02-23Remove 'eval' from gdb_breakpointTom Tromey1-6/+1
Now that Tcl has the {*} operator, we can remove the use of eval from gdb_breakpoint. Tested on x86-64 Fedora 36.
2023-02-21[gdb/testsuite] Require -fsplit-stack in gdb.base/morestack.expTom de Vries1-0/+8
On aarch64-linux, I run into: ... gdb compile failed, cc1: error: '-fsplit-stack' is not supported by this \ compiler configuration UNTESTED: gdb.base/morestack.exp: failed to prepare ... Fix this by requiring -fsplit-stack, such that we have instead: ... UNSUPPORTED: gdb.base/morestack.exp: require failed: \ expr [have_compile_flag -fsplit-stack] ... Tested on x86_64-linux and aarch64-linux.
2023-02-21[gdb/testsuite] Require syscall time in gdb.reverse/time-reverse.expTom de Vries1-0/+11
On aarch64-linux, I run into: ... Running gdb.reverse/time-reverse.exp ... gdb compile failed, gdb.reverse/time-reverse.c: In function 'main': gdb.reverse/time-reverse.c:39:12: error: 'SYS_time' undeclared \ (first use in this function); did you mean 'SYS_times'? syscall (SYS_time, &time_global); ^~~~~~~~ SYS_times gdb.reverse/time-reverse.c:39:12: note: each undeclared identifier is \ reported only once for each function it appears in UNTESTED: gdb.reverse/time-reverse.exp: failed to prepare ... Fix this by adding a new proc have_syscall, and requiring syscall time, such that we have instead: ... UNSUPPORTED: gdb.reverse/time-reverse.exp: require failed: \ expr [have_syscall time] ... Tested on x86_64-linux and aarch64-linux.
2023-02-14[gdb/testsuite] Factor out proc linux_kernel_versionTom de Vries1-0/+23
Factor out new proc linux_kernel_version from test-case gdb.arch/i386-pkru.exp. Tested on x86_64-linux.
2023-02-13gdb/testsuite: look for hipcc in env(ROCM_PATH)Lancelot SIX1-2/+5
If the hipcc compiler cannot be found in dejagnu's tool_root_dir, look for it in $::env(ROCM_PATH) (if set). If hipcc is still not found, fallback to "hipcc" so the compiler will be searched in the PATH. This removes the fallback to the hard-coded "/opt/rocm/bin" prefix. This change is done so ROCM tools are searched in a uniform manner. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13gdb/testsuite: allow_hipcc_tests tests the hipcc compilerLancelot SIX2-1/+72
Update allow_hipcc_tests so all gdb.rocm tests are skipped if we do not have a working hipcc compiler available. To achieve this, adjust gdb_simple_compile to ensure that the hip program is saved in a ".cpp" file before calling hipcc otherwise compilation will fail. One thing to note is that it is possible to have a hipcc installed with a CUDA backend. Compiling with this back-end will successfully result in an application, but GDB cannot debug it (at least for the offload part). In the context of the gdb.rocm tests, we want to detect such situation where gdb_simple_compile would give a false positive. To achieve this, this patch checks that there is at least one AMDGPU device available and that hipcc can compile for this or those targets. Detecting the device is done using the rocm_agent_enumerator tool which is installed with the all ROCm installations (it is used by hipcc to detect identify targets if this is not specified on the comand line). This patch also makes the allow_hipcc_tests proc a cached proc. Co-Authored-By: Pedro Alves <pedro@palves.net> Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13gdb/testsuite: require amd-dbgapi support to run rocm testsLancelot SIX1-0/+7
Update allow_hipcc_tests to check that GDB has the amd-dbgapi support built-in. Without this support, all tests using hipcc and the rocm stack will fail. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13gdb/testsuite: Rename skip_hipcc_tests to allow_hipcc_testsLancelot SIX1-3/+3
Rename skip_hipcc_tests to allow_hipcc_tests so it can be used as a "require" predicate in tests. Use require in gdb.rocm/simple.exp. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-10GDB/testsuite: Add `-nonl' option to `gdb_test'Maciej W. Rozycki1-1/+5
Add a `-nonl' option to `gdb_test' making it possible to match output from commands such as `output' that do not produce a new line sequence at the end, e.g.: (gdb) output 0 0(gdb)
2023-02-08Avoid FAILs in gdb.compileTom Tromey1-7/+52
Many gdb.compile C++ tests fail for me on Fedora 36. I think these are largely bugs in the plugin, though I didn't investigate too deeply. Once one failure is seen, this often cascades and sometimes there are many timeouts. For example, this can happen: (gdb) compile code var = a->get_var () warning: Could not find symbol "_ZZ9_gdb_exprP10__gdb_regsE1a" for compiled module "/tmp/gdbobj-0xdI6U/out2.o". 1 symbols were missing, cannot continue. I think this is probably a plugin bug because, IIRC, in theory these symbols should be exempt from a lookup via gdb. This patch arranges to catch any catastrophic failure and then simply exit the entire .exp file.
2023-02-02gdb: initial support for ROCm platform (AMDGPU) debuggingSimon Marchi3-0/+139
This patch adds the foundation for GDB to be able to debug programs offloaded to AMD GPUs using the AMD ROCm platform [1]. The latest public release of the ROCm release at the time of writing is 5.4, so this is what this patch targets. The ROCm platform allows host programs to schedule bits of code for execution on GPUs or similar accelerators. The programs running on GPUs are typically referred to as `kernels` (not related to operating system kernels). Programs offloaded with the AMD ROCm platform can be written in the HIP language [2], OpenCL and OpenMP, but we're going to focus on HIP here. The HIP language consists of a C++ Runtime API and kernel language. Here's an example of a very simple HIP program: #include "hip/hip_runtime.h" #include <cassert> __global__ void do_an_addition (int a, int b, int *out) { *out = a + b; } int main () { int *result_ptr, result; /* Allocate memory for the device to write the result to. */ hipError_t error = hipMalloc (&result_ptr, sizeof (int)); assert (error == hipSuccess); /* Run `do_an_addition` on one workgroup containing one work item. */ do_an_addition<<<dim3(1), dim3(1), 0, 0>>> (1, 2, result_ptr); /* Copy result from device to host. Note that this acts as a synchronization point, waiting for the kernel dispatch to complete. */ error = hipMemcpyDtoH (&result, result_ptr, sizeof (int)); assert (error == hipSuccess); printf ("result is %d\n", result); assert (result == 3); return 0; } This program can be compiled with: $ hipcc simple.cpp -g -O0 -o simple ... where `hipcc` is the HIP compiler, shipped with ROCm releases. This generates an ELF binary for the host architecture, containing another ELF binary with the device code. The ELF for the device can be inspected with: $ roc-obj-ls simple 1 host-x86_64-unknown-linux file://simple#offset=8192&size=0 1 hipv4-amdgcn-amd-amdhsa--gfx906 file://simple#offset=8192&size=34216 $ roc-obj-extract 'file://simple#offset=8192&size=34216' $ file simple-offset8192-size34216.co simple-offset8192-size34216.co: ELF 64-bit LSB shared object, *unknown arch 0xe0* version 1, dynamically linked, with debug_info, not stripped ^ amcgcn architecture that my `file` doesn't know about ----´ Running the program gives the very unimpressive result: $ ./simple result is 3 While running, this host program has copied the device program into the GPU's memory and spawned an execution thread on it. The goal of this GDB port is to let the user debug host threads and these GPU threads simultaneously. Here's a sample session using a GDB with this patch applied: $ ./gdb -q -nx --data-directory=data-directory ./simple Reading symbols from ./simple... (gdb) break do_an_addition Function "do_an_addition" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (do_an_addition) pending. (gdb) r Starting program: /home/smarchi/build/binutils-gdb-amdgpu/gdb/simple [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff5db7640 (LWP 1082911)] [New Thread 0x7ffef53ff640 (LWP 1082913)] [Thread 0x7ffef53ff640 (LWP 1082913) exited] [New Thread 0x7ffdecb53640 (LWP 1083185)] [New Thread 0x7ffff54bf640 (LWP 1083186)] [Thread 0x7ffdecb53640 (LWP 1083185) exited] [Switching to AMDGPU Wave 2:2:1:1 (0,0,0)/0] Thread 6 hit Breakpoint 1, do_an_addition (a=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>, b=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>, out=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>) at simple.cpp:24 24 *out = a + b; (gdb) info inferiors Num Description Connection Executable * 1 process 1082907 1 (native) /home/smarchi/build/binutils-gdb-amdgpu/gdb/simple (gdb) info threads Id Target Id Frame 1 Thread 0x7ffff5dc9240 (LWP 1082907) "simple" 0x00007ffff5e9410b in ?? () from /opt/rocm-5.4.0/lib/libhsa-runtime64.so.1 2 Thread 0x7ffff5db7640 (LWP 1082911) "simple" __GI___ioctl (fd=3, request=3222817548) at ../sysdeps/unix/sysv/linux/ioctl.c:36 5 Thread 0x7ffff54bf640 (LWP 1083186) "simple" __GI___ioctl (fd=3, request=3222817548) at ../sysdeps/unix/sysv/linux/ioctl.c:36 * 6 AMDGPU Wave 2:2:1:1 (0,0,0)/0 do_an_addition ( a=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>, b=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>, out=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>) at simple.cpp:24 (gdb) bt Python Exception <class 'gdb.error'>: Unhandled dwarf expression opcode 0xe1 #0 do_an_addition (a=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>, b=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>, out=<error reading variable: DWARF-2 expression error: `DW_OP_regx' operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>) at simple.cpp:24 (gdb) continue Continuing. result is 3 warning: Temporarily disabling breakpoints for unloaded shared library "file:///home/smarchi/build/binutils-gdb-amdgpu/gdb/simple#offset=8192&size=67208" [Thread 0x7ffff54bf640 (LWP 1083186) exited] [Thread 0x7ffff5db7640 (LWP 1082911) exited] [Inferior 1 (process 1082907) exited normally] One thing to notice is the host and GPU threads appearing under the same inferior. This is a design goal for us, as programmers tend to think of the threads running on the GPU as part of the same program as the host threads, so showing them in the same inferior in GDB seems natural. Also, the host and GPU threads share a global memory space, which fits the inferior model. Another thing to notice is the error messages when trying to read variables or printing a backtrace. This is expected for the moment, since the AMD GPU compiler produces some DWARF that uses some non-standard extensions: https://llvm.org/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.html There were already some patches posted by Zoran Zaric earlier to make GDB support these extensions: https://inbox.sourceware.org/gdb-patches/20211105113849.118800-1-zoran.zaric@amd.com/ We think it's better to get the basic support for AMD GPU in first, which will then give a better justification for GDB to support these extensions. GPU threads are named `AMDGPU Wave`: a wave is essentially a hardware thread using the SIMT (single-instruction, multiple-threads) [3] execution model. GDB uses the amd-dbgapi library [4], included in the ROCm platform, for a few things related to AMD GPU threads debugging. Different components talk to the library, as show on the following diagram: +---------------------------+ +-------------+ +------------------+ | GDB | amd-dbgapi target | <-> | AMD | | Linux kernel | | +-------------------+ | Debugger | +--------+ | | | amdgcn gdbarch | <-> | API | <=> | AMDGPU | | | +-------------------+ | | | driver | | | | solib-rocm | <-> | (dbgapi.so) | +--------+---------+ +---------------------------+ +-------------+ - The amd-dbgapi target is a target_ops implementation used to control execution of GPU threads. While the debugging of host threads works by using the ptrace / wait Linux kernel interface (as usual), control of GPU threads is done through a special interface (dubbed `kfd`) exposed by the `amdgpu` Linux kernel module. GDB doesn't interact directly with `kfd`, but instead goes through the amd-dbgapi library (AMD Debugger API on the diagram). Since it provides execution control, the amd-dbgapi target should normally be a process_stratum_target, not just a target_ops. More on that later. - The amdgcn gdbarch (describing the hardware architecture of the GPU execution units) offloads some requests to the amd-dbgapi library, so that knowledge about the various architectures doesn't need to be duplicated and baked in GDB. This is for example for things like the list of registers. - The solib-rocm component is an solib provider that fetches the list of code objects loaded on the device from the amd-dbgapi library, and makes GDB read their symbols. This is very similar to other solib providers that handle shared libraries, except that here the shared libraries are the pieces of code loaded on the device. Given that Linux host threads are managed by the linux-nat target, and the GPU threads are managed by the amd-dbgapi target, having all threads appear in the same inferior requires the two targets to be in that inferior's target stack. However, there can only be one process_stratum_target in a given target stack, since there can be only one target per slot. To achieve it, we therefore resort the hack^W solution of placing the amd-dbgapi target in the arch_stratum slot of the target stack, on top of the linux-nat target. Doing so allows the amd-dbgapi target to intercept target calls and handle them if they concern GPU threads, and offload to beneath otherwise. See amd_dbgapi_target::fetch_registers for a simple example: void amd_dbgapi_target::fetch_registers (struct regcache *regcache, int regno) { if (!ptid_is_gpu (regcache->ptid ())) { beneath ()->fetch_registers (regcache, regno); return; } // handle it } ptids of GPU threads are crafted with the following pattern: (pid, 1, wave id) Where pid is the inferior's pid and "wave id" is the wave handle handed to us by the amd-dbgapi library (in practice, a monotonically incrementing integer). The idea is that on Linux systems, the combination (pid != 1, lwp == 1) is not possible. lwp == 1 would always belong to the init process, which would also have pid == 1 (and it's improbable for the init process to offload work to the GPU and much less for the user to debug it). We can therefore differentiate GPU and non-GPU ptids this way. See ptid_is_gpu for more details. Note that we believe that this scheme could break down in the context of containers, where the initial process executed in a container has pid 1 (in its own pid namespace). For instance, if you were to execute a ROCm program in a container, then spawn a GDB in that container and attach to the process, it will likely not work. This is a known limitation. A workaround for this is to have a dummy process (like a shell) fork and execute the program of interest. The amd-dbgapi target watches native inferiors, and "attaches" to them using amd_dbgapi_process_attach, which gives it a notifier fd that is registered in the event loop (see enable_amd_dbgapi). Note that this isn't the same "attach" as in PTRACE_ATTACH, but being ptrace-attached is a precondition for amd_dbgapi_process_attach to work. When the debugged process enables the ROCm runtime, the amd-dbgapi target gets notified through that fd, and pushes itself on the target stack of the inferior. The amd-dbgapi target is then able to intercept target_ops calls. If the debugged process disables the ROCm runtime, the amd-dbgapi target unpushes itself from the target stack. This way, the amd-dbgapi target's footprint stays minimal when debugging a process that doesn't use the AMD ROCm platform, it does not intercept target calls. The amd-dbgapi library is found using pkg-config. Since enabling support for the amdgpu architecture (amdgpu-tdep.c) depends on the amd-dbgapi library being present, we have the following logic for the interaction with --target and --enable-targets: - if the user explicitly asks for amdgcn support with --target=amdgcn-*-* or --enable-targets=amdgcn-*-*, we probe for the amd-dbgapi and fail if not found - if the user uses --enable-targets=all, we probe for amd-dbgapi, enable amdgcn support if found, disable amdgcn support if not found - if the user uses --enable-targets=all and --with-amd-dbgapi=yes, we probe for amd-dbgapi, enable amdgcn if found and fail if not found - if the user uses --enable-targets=all and --with-amd-dbgapi=no, we do not probe for amd-dbgapi, disable amdgcn support - otherwise, amd-dbgapi is not probed for and support for amdgcn is not enabled Finally, a simple test is included. It only tests hitting a breakpoint in device code and resuming execution, pretty much like the example shown above. [1] https://docs.amd.com/category/ROCm_v5.4 [2] https://docs.amd.com/bundle/HIP-Programming-Guide-v5.4 [3] https://en.wikipedia.org/wiki/Single_instruction,_multiple_threads [4] https://docs.amd.com/bundle/ROCDebugger-API-Guide-v5.4 Change-Id: I591edca98b8927b1e49e4b0abe4e304765fed9ee Co-Authored-By: Zoran Zaric <zoran.zaric@amd.com> Co-Authored-By: Laurent Morichetti <laurent.morichetti@amd.com> Co-Authored-By: Tony Tye <Tony.Tye@amd.com> Co-Authored-By: Lancelot SIX <lancelot.six@amd.com> Co-Authored-By: Pedro Alves <pedro@palves.net>
2023-02-01gdb: defer warnings when loading separate debug filesAlexandra Hájková1-13/+25
Currently, when GDB loads debug information from a separate debug file, there are a couple of warnings that could be produced if things go wrong. In find_separate_debug_file_by_buildid (build-id.c) GDB can give a warning if the separate debug file doesn't include any actual debug information, and in separate_debug_file_exists (symfile.c) we can warn if the CRC checksum in the separate debug file doesn't match the checksum in the original executable. The problem here is that, when looking up debug information, GDB will try several different approaches, lookup by build-id, lookup by debug-link, and then a lookup from debuginfod. GDB can potentially give a warning from an earlier attempt, and then succeed with a later attempt. In the cases I have run into this is primarily a warning about some out of date debug information on my machine, but then GDB finds the correct information using debuginfod. This can be confusing to a user, they will see warnings from GDB when really everything is working just fine. For example: warning: the debug information found in "/usr/lib/debug//lib64/ld-2.32.so.debug" \ does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch). This diagnostic was printed on Fedora 33 even when the correct debuginfo was downloaded. In this patch I propose that we defer any warnings related to looking up debug information from a separate debug file. If any of the approaches are successful then GDB will not print any of the warnings. As far as the user is concerned, everything "just worked". Only if GDB completely fails to find any suitable debug information will the warnings be printed. The crc_mismatch test compiles two executables: crc_mismatch and crc_mismatch-2 and then strips them of debuginfo creating separate debug files. The test then replaces crc_mismatch-2.debug with crc_mismatch.debug to trigger "CRC mismatch" warning. A local debuginfod server is setup to supply the correct debug file, now when GDB looks up the debug info no warning is given. The build-id-no-debug-warning.exp is similar to the previous test. It triggers the "separate debug info file has no debug info" warning by replacing the build-id based .debug file with the stripped binary and then loading it to GDB. It then also sets up local debuginfod server with the correct debug file to download to make sure no warnings are emitted.
2023-01-31gdb/testsuite: adjust ensure_gdb_index to cooked_index_functions::dump changesSimon Marchi1-1/+1
Following 7d82b08e9e0a ("gdb/dwarf: dump cooked index contents in cooked_index_functions::dump"), I see some failures like: (gdb) mt print objfiles with-mf^M ^M Object file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/with-mf/with-mf: Objfile at 0x614000005040, bfd at 0x6120000e08c0, 18 minsyms ^M ^M Cooked index in use:^M ^M ... (gdb) FAIL: gdb.base/with-mf.exp: check if index present This is because the format of the "Cooked index in use" line changed slightly. Adjust ensure_gdb_index to expect the trailing colon. Change-Id: If0a87575c02d8a0bc0d4b8ead540c234c62760f8
2023-01-27gdb/testsuite: fix line feed scrolling in tuiterm.expAndrew Burgess1-2/+16
In a following commit I managed to trigger the line feed scrolling case in tuiterm.exp. This case is currently unhandled, and this commit fills in this missing functionality. The implementation is pretty simple, just scroll all the content up one line at a time until the cursor is back on the screen (a single line of scroll is all that should be needed). This change is untested in this commit, but is required by the next commit.
2023-01-26Use ordinary calling convention for clean_restartTom Tromey2-16/+6
clean_restart accepts a single optional argument. Rather than using {args} and handling the argument by hand, change it to use Tcl's own argument-checking.
2023-01-26gdb/testsuite/dap: make dap_wait_for_event_and_check return preceding messagesSimon Marchi1-6/+22
In the following patch, I change gdb.dap/basic-dap.exp such that after waiting for some event, it checks if it received another event meanwhile. To help with this, make dap_wait_for_event_and_check and _dap_dap_wait_for_event return a list with everything received before the event of interest. This is similar to what dap_check_request_and_response returns. Change-Id: I85c8980203a2dec833937e7552c2196bc137935d
2023-01-26gdb/testsuite/dap: rename dap_read_event to dap_wait_for_event_and_checkSimon Marchi1-3/+3
I think that name describes a bit better what the proc does, it is similar to "wait_for" in tuiterm.exp. Change-Id: Ie55aa011e6595dd1b5a874db13881ba572ace419
2023-01-26gdb/testsuite/dap: pass around dicts instead of TON objectsSimon Marchi1-25/+23
The DAP helper functions generally return TON objects. However, callers almost all immediately use ton::2dict to convert them to dicts, to access their contents. This commits makes things a bit simpler for them by having function return dicts directly instead. The downside is that the TON objects contain type information. For instance, a "2" in a TCL dict could have been the integer 2 or the string "2" in JSON. By converting to TCL dicts, we lose that information. If some tests specifically want to check the types of some fields, I think we can add intermediary functions that return TON objects, without having to complicate other callers who don't care. Change-Id: I2ca47bea355bf459090bae8680c6a917350b5c3f
2023-01-26gdb/testsuite/dap: remove catch from dap_read_eventSimon Marchi1-5/+1
This catch didn't cause me any trouble, but for the same reason as the preceding patch, I think it's a bit better to just let any exception propagate, to make for easier debugging. Change-Id: I1779e62c788b77fef2d50434edf4c3d2ec5e1c4c
2023-01-26gdb/testsuite/dap: make dap_request_and_response not catch / issue test resultSimon Marchi1-19/+6
Following some of my changes, dap_request_and_response was failing and I didn't know why. I think it's better to make it not catch any exception, and just make it do a simple "send request, read response". If an exception is thrown while sending a request or reading a response, things are going really badly, it's not like we'll want to recover from that and continue the test. Change-Id: I27568d3547f753c3a74e3e5a730d38a8caef9356
2023-01-26gdb/testsuite/dap: write requests to gdb.logSimon Marchi1-1/+1
This helps following what happens when reading gdb.log. The downside is that it becomes harder to tell what text is from GDB and what text is going to GDB, but I think that seeing responses without seeing requests is even more confusing. At least, the lines are prefix with >>>, so when you see this, you know that until the end of the line, it's something that was sent to GDB, and not GDB output. Change-Id: I1ba1acd8b16f4e64686c5ad268cc41082951c874
2023-01-26gdb/testsuite/dap: prefix some procs with _Simon Marchi1-12/+12
Prefix some procs that are only used internally with an underscore, to make it clear they are internal. If they need to be used by some test later, we can always un-prefix them. Change-Id: Iacb8e77363b5d1f8b98d9ba5a6d115aee5c8925d
2023-01-26[gdb/testsuite] Add and use is_x86_64_m64_targetTom de Vries1-0/+5
Add new proc is_x86_64_m64_target and use it where appropriate. Tested on x86_64-linux.
2023-01-25Move target check into allow_altivec_testsTom Tromey1-0/+5
Pedro pointed out that only PPC can possibly have altivec, so we can move the target check into allow_altivec_tests.
2023-01-25Introduce and use is_any_targetTom Tromey1-0/+10
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-25Rename skip_vsx_tests to allow formTom Tromey1-14/+14
This renames skip_vsx_tests to allow_vsx_tests and updates it users to use require.
2023-01-25Rename skip_power_isa_3_1_tests to allow formTom Tromey1-9/+9
This renames skip_power_isa_3_1_tests to allow_power_isa_3_1_tests and updates its users to use require.
2023-01-25Rename skip_float_test to allow formTom Tromey1-9/+9
This renames skip_float_test to allow_float_test and updates its users to use require.
2023-01-25Convert skip_altivec_tests to allow formTom Tromey1-14/+14
This renames skip_altivec_tests to allow_altivec_tests and updates its users to use require.
2023-01-22Minor fixup in allow_aarch64_sve_testsTom Tromey1-1/+1
An earlier patch failed to update a string in allow_aarch64_sve_tests.
2023-01-18Revert "X86: reverse-finish fix"Carl Love1-33/+0
This reverts commit b22548ddb30bfb167708e82d3bb932461c1b703a. This patch is being reverted since the patch series is causing regressions.
2023-01-17X86: reverse-finish fixCarl Love1-0/+33
PR record/29927 - reverse-finish requires two reverse next instructions to reach previous source line Currently on X86, when executing the finish command in reverse, gdb does a single step from the first instruction in the callee to get back to the caller. GDB stops on the last instruction in the source code line where the call was made. When stopped at the last instruction of the source code line, a reverse next or step command will stop at the first instruction of the same source code line thus requiring two step/next commands to reach the previous source code line. It should only require one step/next command to reach the previous source code line. By contrast, a reverse next or step command from the first line in a function stops at the first instruction in the source code line where the call was made. This patch fixes the reverse finish command so it will stop at the first instruction of the source line where the function call was made. The behavior on X86 for the reverse-finish command now matches doing a reverse-next from the beginning of the function. The proceed_to_finish flag in struct thread_control_state is no longer used. This patch removes the declaration, initialization and setting of the flag. This patch requires a number of regression tests to be updated. Test gdb.mi/mi-reverse.exp no longer needs to execute two steps to get to the previous line. The gdb output for tests gdb.reverse/until-precsave.exp and gdb.reverse/until-reverse.exp changed slightly. The expected result in tests gdb.reverse/amd64-failcall-reverse.exp and gdb.reverse/singlejmp-reverse.exp are updated to the correct expected result. This patch adds a new test gdb.reverse/finish-reverse-next.exp to test the reverse-finish command when returning from the entry point and from the body of the function. The step_until proceedure in test gdb.reverse/step-indirect-call-thunk.exp was moved to lib/gdb.exp and renamed cmd_until. The patch has been tested on X86 and PowerPC to verify no additional regression failures occured. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29927
2023-01-14Pass internal gdb flags to --configuration invocationsTom Tromey2-3/+3
The test suite uses the --configuration flag to feature-test gdb. However, when I added this, I neglected to pass the internal gdbflags to this, causing an error, which then caused failures in the test suite (which would not be seen if you'd ever run "make install"). This patch fixes the bug. Tested by removing my install tree first, to verify that I could reproduce the failure.
2023-01-13Rename to allow_tui_testsTom Tromey3-15/+6
This changes skip_tui_tests to invert the sense, and renames it to allow_tui_tests. It also rewrites this function to use the output of "gdb --configuration", and it adds a note about the state of the TUI to that output.
2023-01-13Rename to allow_guile_testsTom Tromey1-17/+4
This changes skip_guile_tests to invert the sense, and renames it to allow_guile_tests. It also rewrites this proc to check the output of "gdb --configuration", as was done for Python. Then it changes the code to use "require" where possible.
2023-01-13Rename to allow_hw_breakpoint_testsTom Tromey1-5/+5
This changes skip_hw_breakpoint_tests to invert the sense, and renames it to allow_hw_breakpoint_tests. This also converts some tests to use "require" -- I missed this particular check in the first series.
2023-01-13Rename to allow_tsx_testsTom Tromey1-10/+10
This changes skip_tsx_tests to invert the sense, and renames it to allow_tsx_tests.
2023-01-13Rename to allow_shlib_testsTom Tromey1-6/+6
This changes skip_shlib_tests to invert the sense, and renames it to allow_shlib_tests.
2023-01-13Rename to allow_rust_testsTom Tromey1-5/+5
This changes skip_rust_tests to invert the sense, and renames it to allow_rust_tests.
2023-01-13Rename to allow_python_testsTom Tromey1-3/+3
This changes skip_python_tests to invert the sense, and renames it to allow_python_tests.