aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2025-01-04[gdb/tdep] Fix gdb.base/finish-pretty.exp on s390xTom de Vries3-2/+72
On s390x-linux, with test-case gdb.base/finish-pretty.exp I ran into: ... (gdb) finish Run till exit from #0 foo () at finish-pretty.c:28 main () at finish-pretty.c:40 40 return v.a + v.b; Value returned has type: struct s. Cannot determine contents (gdb) FAIL: $exp: finish foo prettyprinted function result ... The function being finished is foo, which returns a value of type struct s. The ABI [1] specifies: - that the value is returned in a storage buffer allocated by the caller, and - that the address of this buffer is passed as a hidden argument in r2. GDB fails to print the value when finishing foo, because it doesn't know the address of the buffer. Implement the gdbarch_get_return_buf_addr hook for s390x to fix this. This is based on ppc_sysv_get_return_buf_addr, the only other implementation of gdbarch_get_return_buf_addr. For readability I've factored out dwarf_reg_on_entry. There is one difference with ppc_sysv_get_return_buf_addr: only NO_ENTRY_VALUE_ERROR is caught. If this patch is approved, I intend to submit a follow-up patch to fix this in ppc_sysv_get_return_buf_addr as well. The hook is not guaranteed to work, because it attempts to get the value r2 had at function entry. The hook can be called after function entry, and the ABI doesn't guarantee that r2 is the same throughout the function. Using -fvar-tracking adds debug information, which allows the hook to succeed more often, and indeed after adding this to the test-case, it passes. Do likewise in one more test-case. Tested on s390x-linux. Fixes: - gdb.ada/finish-large.exp - gdb.base/finish-pretty.exp - gdb.base/retval-large-struct.exp - gdb.cp/non-trivial-retval.exp - gdb.ada/array_return.exp AFAICT, I've also enabled the hook for s390 and from the ABI I get the impression that it should work, but I haven't been able to test it. [1] https://github.com/IBM/s390x-abi
2025-01-04[gdb/selftest] Fix 'help_doc_invariants' self-testEli Zaretskii1-3/+3
Running selftest help_doc_invariants. help doc broken invariant: command 'signal-event' help doc has over-long line Self test failed: self-test failed at unittests/command-def-selftests.c:121 The reason is that doc string of 'signal-event' doesn't have newlines at end of its line. Fix by adding newlines.
2025-01-04[gdb] Fix compilation error in event-top.cEli Zaretskii1-1/+1
CXX event-top.o In file included from d:\usr\include\winsock2.h:69, from ./../gdbsupport/gdb_select.h:30, from event-top.c:43: event-top.c: In function 'fd_set* fd_copy(fd_set*, const fd_set*, int)': event-top.c:1279:22: error: invalid conversion from 'const fd_set*' to 'fd_set*' [-fpermissive] 1279 | if (FD_ISSET (i, src)) | ^ | | | const fd_set* d:\usr\include\winsock.h:164:50: note: initializing argument 2 of 'int __FD_ISSET(SOCKET, fd_set*)' 164 | __CRT_ALIAS int __FD_ISSET( SOCKET __fd, fd_set *__set ) | ~~~~~~~~^~~~~ Use an explicit type cast to prevent this. * gdb/event-top.c (fd_copy): Type-cast in call to FD_ISSET.
2025-01-04[gdb/cli] Warn about forced return from signal trampolineTom de Vries2-2/+9
The Linaro CI reported a regression on arm-linux in test-case gdb.base/sigstep.exp following commit 7b46460a619 ("[gdb/symtab] Apply workaround for PR gas/31115 a bit more") [1]: ... (gdb) return^M Make __default_sa_restorer return now? (y or n) n^M Not confirmed^M (gdb) FAIL: $exp: return from handleri: \ leave signal trampoline (got interactive prompt) ... After installing package glibc-debuginfo and adding --with-separate-debug-dir to the configure flags, I managed to reproduce the FAIL. The regression seems to be a progression in the sense that the function name for the signal trampoline is found. After reading up on the signal trampoline [2] and the return command [3], my understanding is that forced returning from the signal trampoline is potentially unsafe, given that for instance the process signal mask won't be restored. Fix this by: - rather than using the name, using "signal trampoline" in the query, and - adding a warning about returning from a signal trampoline, giving us: ... (gdb) return^M warning: Returning from signal trampoline does not fully restore pre-signal \ state, such as process signal mask.^M Make signal trampoline return now? (y or n) y^M 87 dummy = 0; dummy = 0; while (!done);^M (gdb) PASS: $exp: return from handleri: leave signal trampoline (in main) ... Tested on x86_64-linux. Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org> [1] https://linaro.atlassian.net/browse/GNU-1459 [2] https://man7.org/linux/man-pages/man2/sigreturn.2.html [3] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Returning.html
2025-01-04[gdb/testsuite] Skip stabs board in make-check-all.shTom de Vries1-1/+1
I ran make-check-all.sh with gdb.linespec/explicit.exp, and the only problems were found with target board stabs. With target board unix the test-case runs in two seconds, but with target board stabs it takes 12 seconds due to a timeout. Stabs support in gdb has been unmaintained for a while, and there's an ongoing discussion to deprecate and remove it (PR symtab/31210). It seems unnecessary to excercise this unmaintained feature in make-check-all.sh, so drop it. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31210
2025-01-03skip -gfile: call fnmatch without FNM_FILE_NAMEFangrui Song4-42/+8
fnmatch is called with the FNM_FILE_NAME flag so that `skip -gfi /usr/*` doesn't match /usr/include/*. This makes the file matching feature not useful for STL headers that reside in multiple directories. In addition, the user cannot use a single `*` to match multiple leading path components. Let's drop the FNM_FILE_NAME flag and remove the assertion from gdb_filename_fnmatch (originally for the auto-load feature).
2024-12-31Use 'flags' when expanding symtabs in gdbpy_lookup_static_symbolsTom Tromey4-5/+32
This changes gdbpy_lookup_static_symbols to pass the 'flags' parameter to expand_symtabs_matching. This should refine the search somewhat. Note this is "just" a performance improvement, as the loop over symtabs already checks 'flags'. v2 also removes 'SEARCH_GLOBAL_BLOCK' and updates py-symbol.exp to verify that this works properly. Thanks to Tom for this insight. Co-Authored-By: Tom de Vries <tdevries@suse.de>
2024-12-29Update gdb/NEWS after GDB 16 branch creation.Joel Brobecker1-1/+3
This commit a new section for the next release branch, and renames the section of the current branch, now that it has been cut.
2024-12-29Bump version to 17.0.50.DATE-git.Joel Brobecker2-2/+2
Now that the GDB 16 branch has been created, this commit bumps the version number in gdb/version.in to 17.0.50.DATE-git For the record, the GDB 16 branch was created from commit ee29a3c4ac7adc928ae6ed1fed3b59c940a519a4. Also, as a result of the version bump, the following changes have been made in gdb/testsuite: * gdb.base/default.exp: Change $_gdb_major to 17.
2024-12-24gdb/testsuite: add some xfail in gdb.base/startup-with-shell.expAndrew Burgess1-0/+9
There are two tests that fail in gdb.base/startup-with-shell.exp when using the native-extended-remote board. I plan to fix these issues, and I've posted a series that does just that: https://inbox.sourceware.org/gdb-patches/cover.1730731085.git.aburgess@redhat.com But until that series is reviewed, I thought I'd merge this commit, which marks the FAIL as XFAIL and links them to the relevant bug number. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28392 Tested-By: Guinevere Larsen <guinevere@redhat.com>
2024-12-24gdb/freebsd: port core file context parsing to FreeBSDAndrew Burgess3-2/+146
This commit implements the gdbarch_core_parse_exec_context method for FreeBSD. This is much simpler than for Linux. On FreeBSD, at least the version (13.x) that I have installer, there are additional entries in the auxv vector that point directly to the argument and environment vectors, this makes it trivial to find this information. If these extra auxv entries are not available on earlier FreeBSD, then that's fine. The fallback behaviour will be for GDB to act as it always has up to this point, you'll just not get the extra functionality. Other differences compared to Linux are that FreeBSD has AT_FREEBSD_EXECPATH instead of AT_EXECFN, the AT_FREEBSD_EXECPATH is the full path to the executable. On Linux AT_EXECFN is the command the user typed, so this can be a relative path. This difference is handy as on FreeBSD we don't parse the mapped files from the core file (are they even available?). So having the EXECPATH means we can use that as the absolute path to the executable. However, if the user ran a symlink then AT_FREEBSD_EXECPATH will be the absolute path to the symlink, not to the underlying file. This is probably a good thing, but it does mean there is one case we test on Linux that fails on FreeBSD. On Linux if we create a symlink to an executable, then run the symlink and generate a corefile. Now delete the symlink and load the core file. On Linux GDB will still find (and open) the original executable. This is because we use the mapped file information to find the absolute path to the executable, and the mapped file information only stores the real file names, not symlink names. This is a total edge case, I only added the deleted symlink test originally because I could see that this would work on Linux. Though it is neat that Linux finds this, I don't feel too bad that this fails on FreeBSD. Other than this, everything seems to work on x86-64 FreeBSD (13.4) which is all I have setup right now. I don't see why other architectures wouldn't work too, but I haven't tested them.
2024-12-24gdb: improve GDB's ability to auto-load the exec for a core fileAndrew Burgess5-29/+455
GDB already has a limited mechanism for auto-loading the executable corresponding to a core file, this can be found in the function locate_exec_from_corefile_build_id in corelow.c. However, this approach uses the build-id of the core file to look in either the debug directory (for a symlink back to the executable) or by asking debuginfod. This is great, and works fine if the core file is a "system" binary, but often, when I'm debugging a core file, it's part of my development cycle, so there's no build-id symlink in the debug directory, and debuginfod doesn't know about the binary either, so GDB can't auto load the executable.... ... but the executable is right there! This commit builds on the earlier commits in this series to make GDB smarter. On GNU/Linux, when we parse the execution context from the core file (see linux-tdep.c), we already grab the command pointed to by AT_EXECFN. If this is an absolute path then GDB can use this to locate the executable, a build-id check ensures we've found the correct file. With this small change GDB suddenly becomes a lot better at auto-loading the executable for a core file. But we can do better! Often the AT_EXECFN is not an absolute path. If it is a relative path then we check for this path relative to the core file. This helps if a user does something like: $ ./build/bin/some_prog Aborted (core dumped) $ gdb -c corefile In this case the core file in the current directory will have an AT_EXECFN value of './build/bin/some_prog', so if we look for that path relative to the location of the core file this might result in a hit, again, a build-id check ensures we found the right file. But we can do better still! What if the user moves the core file? Or the user is using some tool to manage core files (e.g. the systemd core file management tool), and the user downloads the core file to a location from which the relative path no longer works? Well in this case we can make use of the core file's mapped file information (the NT_FILE note). The executable will be included in the mapped file list, and the path within the mapped file list will be an absolute path. We can search for mapped file information based on an address within the mapped file, and the auxv vector happens to include an AT_ENTRY value, which is the entry address in the main executable. If we look up the mapped file containing this address we'll have the absolute path to the main executable, a build-id check ensures this really is the file we're looking for. It might be tempting to jump straight to the third approach, however, there is one small downside to the third approach: if the executable is a symlink then the AT_EXECFN string will be the name of the symlink, that is, the thing the user asked to run. The mapped file entry will be the name of the actual file, i.e. the symlink target. When we auto-load the executable based on the third approach, the file loaded might have a different name to that which the user expects, though the build-id check (almost) guarantees that we've loaded the correct binary. But there's one more thing we can check for! If the user has placed the core file and the executable into a directory together, for example, as might happen with a bug report, then neither the absolute path check, nor the relative patch check will find the executable. So GDB will also look for a file with the right name in the same directory as the core file. Again, a build-id check is performed to ensure we find the correct file. Of course, it's still possible that GDB is unable to find the executable using any of these approaches. In this case, nothing changes, GDB will check in the debug info directory for a build-id based link back to the executable, and if that fails, GDB will ask debuginfod for the executable. If this all fails, then, as usual, the user is able to load the correct executable with the 'file' command, but hopefully, this should be needed far less from now on.
2024-12-24gdb/testsuite: make some of the core file / build-id tests harderAndrew Burgess3-148/+130
We have a few tests that load core files, which depend on GDB not auto-loading the executable that matches the core file. One of these tests (corefile-buildid.exp) exercises GDB's ability to load the executable via the build-id links in the debug directory, while the other two tests are just written assuming that GDB hasn't auto-loaded the executable. In the next commit, GDB is going to get better at finding the executable for a core file, and as a consequence these tests could start to fail if the testsuite is being run using a compiler that adds build-ids by default, and is on a target (currently only Linux) with the improved executable auto-loading. To avoid these test failures, this commit updates some of the tests. coredump-filter.exp and corefile.exp are updated to unload the executable should it be auto-loaded. This means that the following output from GDB will match the expected patterns. If the executable wasn't auto-loaded then the new step to unload is harmless. The corefile-buildid.exp test needed some more significant changes. For this test it is important that the executable be moved aside so that GDB can't locate it, but we do still need the executable around somewhere, so that the debug directory can link to it. The point of the test is that the executable _should_ be auto-loaded, but using the debug directory, not using GDB's context parsing logic. While looking at this test I noticed two additional problems, first we were creating the core file more times than we needed. We only need to create one core file for each test binary (total two), while we previously created one core file for each style of debug info directory (total four). The extra core files should be identical, and were just overwriting each other, harmless, but still pointless work. The other problem is that after running an earlier test we modified the test binary in order to run a later test. This means it's not possible to manually re-run the first test as the binary for that test is destroyed. As part of the rewrite in this commit I've addressed these issues. This test does change many of the test names, but there should be no real changes in what is being tested after this commit. However, when the next commit is added, and GDB gets better at auto-loading the executable for a core file, these tests should still be testing what is expected.
2024-12-24gdb: parse and set the inferior environment from core filesAndrew Burgess5-5/+106
Extend the core file context parsing mechanism added in the previous commit to also store the environment parsed from the core file. This environment can then be injected into the inferior object. The benefit of this is that when examining a core file in GDB, the 'show environment' command will now show the environment extracted from a core file. Consider this example: $ env -i GDB_TEST_VAR=FOO ./gen-core Segmentation fault (core dumped) $ gdb -c ./core.1669829 ... [New LWP 1669829] Core was generated by `./gen-core'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x0000000000401111 in ?? () (gdb) show environment GDB_TEST_VAR=foo (gdb) There's a new test for this functionality.
2024-12-24gdb: add gdbarch method to get execution context from core fileAndrew Burgess10-4/+579
Add a new gdbarch method which can read the execution context from a core file. An execution context, for this commit, means the filename of the executable used to generate the core file and the arguments passed to the executable. In later commits this will be extended further to include the environment in which the executable was run, but this commit is already pretty big, so I've split that part out into a later commit. Initially this new gdbarch method is only implemented for Linux targets, but a later commit will add FreeBSD support too. Currently when GDB opens a core file, GDB reports the command and arguments used to generate the core file. For example: (gdb) core-file ./core.521524 [New LWP 521524] Core was generated by `./gen-core abc def'. However, this information comes from the psinfo structure in the core file, and this struct only allows 80 characters for the command and arguments combined. If the command and arguments exceed this then they are truncated. Additionally, neither the executable nor the arguments are quoted in the psinfo structure, so if, for example, the executable was named 'aaa bbb' (i.e. contains white space) and was run with the arguments 'ccc' and 'ddd', then when this core file was opened by GDB we'd see: (gdb) core-file ./core.521524 [New LWP 521524] Core was generated by `./aaa bbb ccc ddd'. It is impossible to know if 'bbb' is part of the executable filename, or another argument. However, the kernel places the executable command onto the user stack, this is pointed to by the AT_EXECFN entry in the auxv vector. Additionally, the inferior arguments are all available on the user stack. The new gdbarch method added in this commit extracts this information from the user stack and allows GDB to access it. The information on the stack is writable by the user, so a user application can start up, edit the arguments, override the AT_EXECFN string, and then dump core. In this case GDB will report incorrect information, however, it is worth noting that the psinfo structure is also filled (by the kernel) by just copying information from the user stack, so, if the user edits the on stack arguments, the values reported in psinfo will change, so the new approach is no worse than what we currently have. The benefit of this approach is that GDB gets to report the full executable name and all the arguments without the 80 character limit, and GDB is aware which parts are the executable name, and which parts are arguments, so we can, for example, style the executable name. Another benefit is that, now we know all the arguments, we can poke these into the inferior object. This means that after loading a core file a user can 'show args' to see the arguments used. A user could even transition from core file debugging to live inferior debugging using, e.g. 'run', and GDB would restart the inferior with the correct arguments. Now the downside: finding the AT_EXECFN string is easy, the auxv entry points directly too it. However, finding the arguments is a little trickier. There's currently no easy way to get a direct pointer to the arguments. Instead, I've got a heuristic which I believe should find the arguments in most cases. The algorithm is laid out in linux-tdep.c, I'll not repeat it here, but it's basically a search of the user stack, starting from AT_EXECFN. If the new heuristic fails then GDB just falls back to the old approach, asking bfd to read the psinfo structure for us, which gives the old 80 character limited answer. For testing, I've run this series on (all GNU/Linux) x86-64. s390, ppc64le, and the new test passes in each case. I've done some very basic testing on ARM which does things a little different than the other architectures mentioned, see ARM specific notes in linux_corefile_parse_exec_context_1 for details.
2024-12-22Fix -Wenum-constexpr-conversion in enum-flags.hCarlos Galvez1-27/+0
This fixes PR 31331: https://sourceware.org/bugzilla/show_bug.cgi?id=31331 Currently, enum-flags.h is suppressing the warning -Wenum-constexpr-conversion coming from recent versions of Clang. This warning is intended to be made a compiler error (non-downgradeable) in future versions of Clang: https://github.com/llvm/llvm-project/issues/59036 The rationale is that casting a value of an integral type into an enumeration is Undefined Behavior if the value does not fit in the range of values of the enum: https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1766 Undefined Behavior is not allowed in constant expressions, leading to an ill-formed program. In this case, in enum-flags.h, we are casting the value -1 to an enum of a positive range only, which is UB as per the Standard and thus not allowed in a constexpr context. The purpose of doing this instead of using std::underlying_type is because, for C-style enums, std::underlying_type typically returns "unsigned int". However, when operating with it arithmetically, the enum is promoted to *signed* int, which is what we want to avoid. This patch solves this issue as follows: * Use std::underlying_type and remove the custom enum_underlying_type. * Ensure that operator~ is called always on an unsigned integer. We do this by casting the input enum into std::size_t, which can fit any unsigned integer. We have the guarantee that the cast is safe, because we have checked that the underlying type is unsigned. If the enum had negative values, the underlying type would be signed. This solves the issue with C-style enums, but also solves a hidden issue: enums with underlying type of std::uint8_t or std::uint16_t are *also* promoted to signed int. Now they are all explicitly casted to the largest unsigned int type and operator~ is safe to use. * There is one more thing that needs fix. Currently, operator~ is implemented as follows: return (enum_type) ~underlying(e); After applying ~underlying(e), the result is a very large value, which we then cast to "enum_type". This cast is Undefined Behavior if the large value does not fit in the range of the enum. For C++ enums (scoped and/or with explicit underlying type), the range of the enum is the entire range of the underlying type, so the cast is safe. However, for C-style enums, the range is the smallest bit-field that can hold all the values of the enumeration. So the range is a lot smaller and casting a large value to the enum would invoke Undefined Behavior. To solve this problem, we create a new trait EnumHasFixedUnderlyingType, to ensure operator~ may only be called on C++-style enums. This behavior is roughly the same as what we had on trunk, but relying on different properties of the enums. * Once this is implemented, the following tests fail to compile: CHECK_VALID (true, int, true ? EF () : EF2 ()) This is because it expects the enums to be promoted to signed int, instead of unsigned int (which is the true underlying type). I propose to remove these tests altogether, because: - The comment nearby say they are not very important. - Comparing 2 enums of different type like that is strange, relies on integer promotions and thus hurts readability. As per comments in the related PR, we likely don't want this type of code in gdb code anyway, so there's no point in testing it. - Most importantly, this type of comparison will be ill-formed in C++26 for regular enums, so enum_flags does not need to emulate that. Since this is the only place where the warning was suppressed, remove also the corresponding macro in include/diagnostics.h. The change has been tested by running the entire gdb test suite (make check) and comparing the results (testsuite/gdb.sum) against trunk. No noticeable differences have been observed. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31331 Tested-by: Keith Seitz <keiths@redhat.com> Approved-By: Tom Tromey <tom@tromey.com>
2024-12-22gdb/hurd: remove VLA usageFlavio Cruz1-4/+5
Compilation will fail with -Werror=vla, which seems to be the default. Note that we don't need to allocate num_threads + 1 since the matching algorithm works only on the num_threads as returned by task_threads. Change-Id: I276928d0ff3c52c7c7fe4edb857e5789cdabfcf7
2024-12-20Add gstack scriptKeith Seitz9-5/+408
This commit adds support for a `gstack' command which Fedora has been carrying for many years. gstack is a natural counterpart to the gcore command. Whereas gcore dumps a core file, gstack prints stack traces of a running process. There are many improvements over Fedora's version of this script. The dependency on procfs is gone; gstack will run anywhere gdb runs. The only runtime dependencies are bash and awk. The script includes suggestions from gdb/32325 to include versioning and help. [If this approach to gdb/32325 is acceptable, I could propagate the solution to gcore/gdb-add-index.] I've rewritten the documentation, integrating it into the User Manual. The manpage is now output using this one source. Example run (on x86_64 Fedora 40) $ gstack --help Usage: gstack [-h|--help] [-v|--version] PID Print a stack trace of a running program -h, --help Print this message then exit. -v, --version Print version information then exit. $ gstack -v GNU gstack (GDB) 16.0.50.20241119-git $ gstack 12345678 Process 12345678 not found. $ gstack $(pidof emacs) Thread 6 (Thread 0x7fd5ec1c06c0 (LWP 2491423) "pool-spawner"): #0 0x00007fd6015ca3dd in syscall () at /lib64/libc.so.6 #1 0x00007fd60b31eccd in g_cond_wait () at /lib64/libglib-2.0.so.0 #2 0x00007fd60b28a61b in g_async_queue_pop_intern_unlocked () at /lib64/libglib-2.0.so.0 #3 0x00007fd60b2f1a03 in g_thread_pool_spawn_thread () at /lib64/libglib-2.0.so.0 #4 0x00007fd60b2f0813 in g_thread_proxy () at /lib64/libglib-2.0.so.0 #5 0x00007fd6015486d7 in start_thread () at /lib64/libc.so.6 #6 0x00007fd6015cc60c in clone3 () at /lib64/libc.so.6 #7 0x0000000000000000 in ??? () Thread 5 (Thread 0x7fd5eb9bf6c0 (LWP 2491424) "gmain"): #0 0x00007fd6015be87d in poll () at /lib64/libc.so.6 #1 0x0000000000000001 in ??? () #2 0xffffffff00000001 in ??? () #3 0x0000000000000001 in ??? () #4 0x000000002104cfd0 in ??? () #5 0x00007fd5eb9be320 in ??? () #6 0x00007fd60b321c34 in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0 Thread 4 (Thread 0x7fd5eb1be6c0 (LWP 2491425) "gdbus"): #0 0x00007fd6015be87d in poll () at /lib64/libc.so.6 #1 0x0000000020f9b558 in ??? () #2 0xffffffff00000003 in ??? () #3 0x0000000000000003 in ??? () #4 0x00007fd5d8000b90 in ??? () #5 0x00007fd5eb1bd320 in ??? () #6 0x00007fd60b321c34 in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0 Thread 3 (Thread 0x7fd5ea9bd6c0 (LWP 2491426) "emacs"): #0 0x00007fd6015ca3dd in syscall () at /lib64/libc.so.6 #1 0x00007fd60b31eccd in g_cond_wait () at /lib64/libglib-2.0.so.0 #2 0x00007fd60b28a61b in g_async_queue_pop_intern_unlocked () at /lib64/libglib-2.0.so.0 #3 0x00007fd60b28a67c in g_async_queue_pop () at /lib64/libglib-2.0.so.0 #4 0x00007fd603f4d0d9 in fc_thread_func () at /lib64/libpangoft2-1.0.so.0 #5 0x00007fd60b2f0813 in g_thread_proxy () at /lib64/libglib-2.0.so.0 #6 0x00007fd6015486d7 in start_thread () at /lib64/libc.so.6 #7 0x00007fd6015cc60c in clone3 () at /lib64/libc.so.6 #8 0x0000000000000000 in ??? () Thread 2 (Thread 0x7fd5e9e6d6c0 (LWP 2491427) "dconf worker"): #0 0x00007fd6015be87d in poll () at /lib64/libc.so.6 #1 0x0000000000000001 in ??? () #2 0xffffffff00000001 in ??? () #3 0x0000000000000001 in ??? () #4 0x00007fd5cc000b90 in ??? () #5 0x00007fd5e9e6c320 in ??? () #6 0x00007fd60b321c34 in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0 Thread 1 (Thread 0x7fd5fcc45280 (LWP 2491417) "emacs"): #0 0x00007fd6015c9197 in pselect () at /lib64/libc.so.6 #1 0x0000000000000000 in ??? () Since this is essentially a complete rewrite of the original script and documentation, I've chosen to only keep a 2024 copyright date. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
2024-12-20Minor cleanups in rust-lang.cTom Tromey1-13/+8
This patch is a few minor cleanups to rust-lang.c: renaming a badly-named local variable, moving a couple of declarations into 'for' headers, and using 'bool' in one spot.
2024-12-20[gdb/cli] Don't prefill for operate-and-get-next of last commandTom de Vries2-6/+52
Consider operate-and-get-next [1] in bash: ... $ <echo 1>echo 1<enter> 1 $ <echo 2>echo 2<enter> 2 $ <Ctrl-r>(reverse-i-search)`': <echo 1>echo 1<Ctrl-o> 1 $ echo 2<Ctrl-o> 2 $ echo 1 ... So, typing Ctrl-o: - executes the recalled command, and - prefills the next one (which then can be executed again with Ctrl-o). We have the same functionality in gdb, but when recalling the last command from history with bash we have no prefill: ... $ <echo 1>echo 1<enter> 1 $ <Ctrl-r>(reverse-i-search)`': <echo 1>echo 1<Ctrl-o> 1 $ ... but with gdb do we have a prefill: ... (gdb) echo 1\n 1 (gdb) <Ctrl-r>(reverse-i-search)`': <echo 1>echo 1\n<Ctrl-o> 1 (gdb) echo 1\n ... Following the principle of least surprise [2], I think gdb should do what bash does. Fix this by: - signalling this case in gdb_rl_operate_and_get_next using "operate_saved_history = -1", and - handling operate_saved_history == -1 in gdb_rl_operate_and_get_next_completion. Tested on aarch64-linux. Approved-By: Tom Tromey <tom@tromey.com> PR cli/32485 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32485 [1] https://www.man7.org/linux/man-pages/man3/readline.3.html [2] https://en.wikipedia.org/wiki/Principle_of_least_astonishment
2024-12-20Use block::is_static_block in ada-lang.cTom Tromey1-1/+1
This changes one spot in ada-lang.c to use block::is_static_block rather than a hand-rolled implementation. Note this also fixes the call -- what is currently written there is wrong. Approved-By: Tom de Vries <tdevries@suse.de>
2024-12-20Fix latent bug in gdbpy_lookup_static_symbolsTom Tromey1-3/+4
gdbpy_lookup_static_symbols is missing an error check for the case where symbol_to_symbol_object returns NULL. Approved-By: Tom de Vries <tdevries@suse.de>
2024-12-20[gdb/testsuite] Use -nostdlib in gdb.linespec/explicit.expTom de Vries2-1/+12
On openSUSE Leap 15.6 ppc64le-linux, with gdb.linespec/explicit.exp I run into: ... (gdb) b -source thread_pointer.h FAIL: $exp: complete after -source: tab complete "b -source thr" Quit^M ... The test-case already contains a related workaround: ... # Get rid of symbols from shared libraries, otherwise # "b -source thr<tab>" could find some system library's # source. gdb_test_no_output "nosharedlibrary" ... but that doesn't work in this case because the debug info is in the executable itself: ... The File Name Table (offset 0xb5): Entry Dir Time Size Name 1 0 0 0 abi-note.c 2 1 0 0 types.h 3 2 0 0 stdint-intn.h 4 2 0 0 stdint-uintn.h 5 3 0 0 elf.h 6 4 0 0 thread_pointer.h ... due to debug info in some glibc object file. Fix this by: - using -nostdlib, ensuring only debug info from the three test-case sources is present in the executable, and - adding a _start wrapping main. Tested on x86_64-linux and ppc64le-linux. Reviewed-By: Keith Seitz <keiths@redhat.com> PR testsuite/31229 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31229
2024-12-19gdb, gdbserver: introduce the 'x' RSP packet for binary memory readTankut Baris Aktemur3-14/+105
Introduce an RSP packet, 'x', for reading from the remote server memory in binary format. The binary write packet, 'X' already exists. The 'x' packet is essentially the same as 'm', except that the returned data is in binary format. For transferring relatively large data from the memory of the remote process, the 'x' packet can reduce the transfer costs. For example, without this patch, fetching ~100MB of data from a remote target takes (gdb) dump binary memory temp.o 0x00007f3ba4c576c0 0x00007f3bab709400 2024-03-13 16:17:42.626 - command started 2024-03-13 16:18:24.151 - command finished Command execution time: 32.136785 (cpu), 41.525515 (wall) (gdb) whereas with this patch, we obtain (gdb) dump binary memory temp.o 0x00007fec39fce6c0 0x00007fec40a80400 2024-03-13 16:20:48.609 - command started 2024-03-13 16:21:16.873 - command finished Command execution time: 20.447970 (cpu), 28.264202 (wall) (gdb) We see improvements not only when reading bulk data as above, but also when making a large number of small memory access requests. For example, without this patch: (gdb) pipe x/100000xw $pc | wc -l 2024-03-13 16:04:57.112 - command started 25000 2024-03-13 16:05:10.798 - command finished Command execution time: 9.952364 (cpu), 13.686581 (wall) With this patch: (gdb) pipe x/100000xw $pc | wc -l 2024-03-13 16:06:48.160 - command started 25000 2024-03-13 16:06:57.750 - command finished Command execution time: 6.541425 (cpu), 9.589839 (wall) (gdb) Another example, where we create a core file of a GDB process. (gdb) gcore /tmp/core.1 ... Command execution time: 85.496967 (cpu), 133.224373 (wall) vs. (gdb) gcore /tmp/core.1 ... Command execution time: 48.328885 (cpu), 115.032289 (wall) Regression-tested on X86-64 using the unix (default) and native-extended-gdbserver board files. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
2024-12-19doc: fine-tune the documentation of the 'm' RSP packetTankut Baris Aktemur1-6/+7
Revise a sentence to avoid misinterpretation. Move @cindex entries before the text they index. Refer to trace frames regarding partial reads. Approved-By: Eli Zaretskii <eliz@gnu.org>
2024-12-18[doc] Update gdb-add-index manpageKeith Seitz1-6/+42
The current gdb-add-index manual page is a bit out-of-date. This commit fixes a few deficiencies: - gdb-add-index does not use objdump; it uses objcopy and readelf - missing info on environment variables (in appropriate ENVIRONMENT section). - missing mention of -dwarf-5 option - adds important notice about FILENAME being writable - explains exit status - the script adds appropriate section(s) to the file; it does not output new files with the section(s) Approved-By: Eli Zaretskii <eliz@gnu.org>
2024-12-18Run check-include-guards.pyTom Tromey427-1280/+1280
This patch is the result of running check-include-guards.py on the current tree. Running it a second time causes no changes. Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-12-18Add an include-checking scriptTom Tromey1-0/+127
This adds a new Python script that checks the header guards of all gdb source files. It enforces a fairly strict formatting and naming scheme. In particular, for a file "x/y-z.h" (relative to the repository root), the include guard will be named "X_Y_Z_H". Only the '#ifndef' form is allowed, not "#if !defined(...)". The trailing comment on the "#endif" is also required. The script also tries to update files that appear to have the required lines if they are in the wrong form or use the wrong name. Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-12-18Fix some minor header file irregularitiesTom Tromey7-7/+20
The script in the next patch noticed some irregularities in some headers: trailing or leading blank lines, or in one case a missing copyright header. This patch fixes these. Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-12-18Fix typo in Python documentationTom Tromey1-1/+1
Oleg pointed out that when renaming from "status" to "enabled" in the Python TUI events patch, I neglected to update one spot in the documentation. This patch fixes this. I'm checking it in as obvious. You can verify that this change is correct by examining gdb/python/py-event-types.def. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32162
2024-12-17Minor C++-ification in rust-parse.cTom Tromey1-25/+20
This patch changes a few spots in rust-parse.c to use 'bool', and also declares a couple of loop iteration variables in the loop headers. I'm checking this in.
2024-12-17Hurd: do not include defs.h when compiling MiG stubs since they are compiled ↵Flavio Cruz2-2/+5
as C files Otherwise, GDB will fail to compile for Hurd. Approved-By: Tom Tromey <tom@tromey.com>
2024-12-17gdb: syscalls: Update ARM64 xml filesTiezhu Yang2-0/+8
There are some new syscalls in the latest upstream Linux kernel [1], some archs updated the xml files in the recent commit 19f3450f7429 ("[gdb/syscalls] Add syscalls {set,get,list,remove}xattrat"), also update ARM64 to reflect the reality. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6140be90ec70 Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Approved-By: Tom de Vries <tdevries@suse.de>
2024-12-17gdb: syscalls: Update LoongArch xml filesTiezhu Yang2-2/+16
There are some new syscalls in the latest upstream Linux kernel [1][2][3], update the xml files for LoongArch to reflect the reality. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7697a0fe0154 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ff388fe5c481 [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6140be90ec70 Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Approved-By: Tom de Vries <tdevries@suse.de>
2024-12-17gdb: syscalls: Remove tips for LoongArch xml filesTiezhu Yang2-45/+2
After commit "gdb: syscalls: Handle __NR3264_ prefixed syscall number", no need to do special handling when generating xml file for LoongArch, just remove the tips in the file comment. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Approved-By: Tom de Vries <tdevries@suse.de>
2024-12-17gdb: syscalls: Handle __NR3264_ prefixed syscall numberTiezhu Yang1-4/+14
In gdb commit a08dc2aa004b ("gdb: syscalls: Add loongarch-linux.xml.in"), we find: There exist some __NR3264_ prefixed syscall numbers, replace them with digital numbers according to /usr/include/asm-generic/unistd.h and sort them by syscall number manually, maybe we can modify the script to do it automatically in the future. It is time to do it now, just handle __NR3264_ prefixed syscall number automatically in the script update-linux.sh. By the way, a Linux kernel patch did the similar change [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d6e1cc6b7220 Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Approved-By: Tom de Vries <tdevries@suse.de>
2024-12-16Greatly speed up rbreakTom Tromey1-15/+24
While debugging another issue, I noticed that 'rbreak' on a large program was very slow. In particular, with 'maint time 1': (gdb) with pagination off -- rbreak ^command_display [...] Command execution time: 1940.646332 (cpu), 1960.771517 (wall) "ps" also reported that, after this command, gdb's VSZ was 4619360. Looking into this, I found something strange. When 'rbreak' found a function "f" in file "file.adb", it would try to set the breakpoint using "break 'file.adb':'f'". This then interacted somewhat poorly with linespec. linespec first expands all the symtabs matching "file.adb", but in this program this results in thousands of CU expansions (probably due to inlining, but I did not investigate). There is probably a linespec bug here. It would make more sense for it to combine the file- and symbol- lookups, as this is more efficient. I plan to file a bug about this at least. I tracked this "file:function" style of linespec to the earliest days of gdb. Back then, "break function" would only break on the first "function" that was found -- it wasn't until much later that we changed gdb to break on all matching functions. So, I think that rbreak was written this way to try to work around this limitation, and it seems to me that this change obsoleted the need for rbreak to mention the file at all. That is, "break file:function" is redundant now, because plain "break function" will redo that same work -- just more efficiently. (The only exception to this is the case where a file is given to rbreak -- here the extra filtering is still needed.) This patch implements this. On the aforementioned large program, with this patch, rbreak still sets all the desired breakpoints (879 of them) but is now much faster: (gdb) with pagination off -- rbreak ^command_display [...] Command execution time: 91.702648 (cpu), 92.770430 (wall) It also reduces the VSZ number to 2539216. Regression tested on x86-64 Fedora 40. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14340 Approved-By: Pedro Alves <pedro@palves.net>
2024-12-16Don't let exception terminate 'rbreak'Tom Tromey7-19/+78
'rbreak' searches symbols and then sets a number of breakpoints. If setting one of the breakpoints fails, then 'rbreak' will terminate before examining the remaining symbols. However, it seems to me that it is better for 'rbreak' to keep going in this situation. That is what this patch implements. This problem can be seen by writing an Ada program that uses "pragma import" to reference a symbol that does not have debug info. In this case, the program will link but setting a breakpoint on the imported name will not work. I don't think it's possible to write a reliable test for this, as it depends on the order in which symtabs are examined. New in v2: rbreak now shows how many breakpoints it made and also how many errors it encountered. Regression tested on x86-64 Fedora 40. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-16Re-run isortTom Tromey1-1/+1
I noticed that an earlier commit caused a change in the isort output. This patch repairs the problem.
2024-12-16gdb/testsuite: rename test source file to avoid glibc clashAndrew Burgess2-14/+42
After posting this series: https://inbox.sourceware.org/gdb-patches/cover.1733742925.git.aburgess@redhat.com I got a failure report from the Linaro CI system. I eventually tracked the issue down to a filename clash with glibc. I was able to reproduce the issue when I installed the glibc debug information on to my local machine, and ran the gdb.base/dlmopen.exp test as updated in the above series. Here's what's happening: There is a file called dlmopen.c within glibc, within the glibc source tree the file can be found at ./dlfcn/dlmopen.c. When this file is compiled it appears that the glibc build system first enters the dlfcn directory, and then compiles the file using the relative path ./dlmopen.c, here's a snippet of the DWARF: <0><d5d27>: Abbrev Number: 12 (DW_TAG_compile_unit) <d5d28> DW_AT_producer : (alt indirect string, offset: 0x16433) t <d5d2c> DW_AT_language : 29 (C11) <d5d2d> DW_AT_name : (indirect line string, offset: 0x5c8f): dlmopen.c <d5d31> DW_AT_comp_dir : (indirect line string, offset: 0xb478): /usr/src/debug/glibc-2.38-19.fc39.x86_64/dlfcn <d5d35> DW_AT_low_pc : 0x8a4c0 <d5d3d> DW_AT_high_pc : 408 <d5d3f> DW_AT_stmt_list : 0x68ec1 The important thing here is the DW_AT_name, which is just "dlmopen.c". The gdb.base/dlmopen.exp test also has a source file called "dlmopen.c". The dlmopen.exp test makes use of the clean_restart TCL proc, which calls gdb_reinitialize_dir, which resets the source directories search path to '$cdir:$cwd', and then prepends the test source directory to the front of the list, so the source directory search path will look something like: /tmp/src/gdb/testsuite/gdb.base/gdb.base:$cdir:$cwd In the existing test we try to place a breakpoint on 'dlmopen.c:64'. This is the line tagged 'bp.main' in the source file. This currently works fine. GDB searches through the symtabs and finds two matches, the test dlmopen.c, and the glibc dlmopen.c. For each GDB tries to convert line 64 into an address. For the testsuite source file this is fine, we get the address of the line tagged 'bp.main' from the source, and the breakpoint is created. For the glibc source file though, at least, for the version available to me, line 64 happens to be the closing '}' of a function, and there isn't a line table entry for this exact line. So GDB searches forward looking for the next line in order to place a breakpoint there. The next line GDB finds is the start of the next function, and so GDB rejects this location due to commit: commit dcaa85e58c4ef50a92908e071ded631ce48c971c Date: Wed May 1 10:47:47 2024 +0100 gdb: reject inserting breakpoints between functions So we managed to avoid creating two breakpoint locations in this case, but only by pure good luck. In my updates to the test though I try to create a breakpoint at line 61 in addition to the breakpoint at line 64. So now the breakpoint spec is 'dlmopen.c:61'. Just as before, GDB identifies the 'dlmopen.c' could mean two files, and searches for line 61 in both. The test source works as expected and the breakpoint is created in the desired location. But this time, line 61 in the glibc source file is an actual line, with actual code, and so GDB places a breakpoint at this location. This second breakpoint, in glibc is entirely unexpected (by the dlmopen.exp test script). Unfortunately, the inferior hits this second glibc breakpoint before it hits the actual breakpoint within the main test executable, this throws the test off and causes some failures. In trying to fix this, I did wonder if I could just specify the full path to the source file, instead of using just 'dlmopen.c:61'. However, this doesn't work. Remember that the glibc source file is recorded as just 'dlmopen.c'. So, when GDB tries to figure out the absolute path to this source file, the source directory search path is used. In this case, the first entry in the source directory search path is the gdb.base/ directory in the GDB source tree. GDB looks in this directory and finds a dlmopen.c, and so GDB assumes that this is the file in question. Thus, GDB actually thinks that both files _are_ the same source file. Indeed, when GDB stops at the incorrect (glibc) breakpoint, and lists the source code, it actually lists the source code from the correct file. This confused me to begin with, GDB reported the wrong function (the glibc function), but listed code from the correct file and line. Now on my machine I have installed the package that provides the glibc source code. If I change the source directory search path so that $cdir is first instead of the gdb.base/ from the GDB source tree, this fixes the listing the wrong file problem. GDB does not realise that the files are different, and if I create the breakpoint using the absolute path then only a single breakpoint location is created. However, this relies on the developer having both the glibc debug information, and the glibc source package installed, this doesn't seem like a great requirement to have in place. So instead, I propose that we just take the easy way out, rename the test source file. By doing this all the issues are avoided. The test now creates a breakpoint at 'dlmopen-main.c:61', and there is only one file with this name found, so we only get a single breakpoint location created. I renamed the source file, but not the dlmopen.exp file because the test already makes use of multiple source files, so having a range of different names didn't feel that bad, but if this bothers people, I could rename both the .exp and main .c file, just let me know. If you want to explore this issue for yourself then try with installing the glibc debug information for your system, and ensure that your GDBs under test are able to find the glibc debug information. You can then either apply the series I linked above, or, you can modify the existing test source so that the line tagged as 'bp.main' becomes line 61, I just deleted 3 lines from the big comment at the head of the file. Of course, reproducing this does depend on how glibc is compiled, which could change from system to system, or overtime. I reproduced this issue on Fedora 39 with glibc-2.38-19. With this patch applied I no longer see any regressions when I apply the above linked series. While making these changes I took the opportunity to update the test script to make better use of standard_testfile and build_executable. Reviewed-By: Keith Seitz <keiths@redhat.com> Approved-By: Tom Tromey <tom@tromey.com>
2024-12-14fix Windows buildoltolm1-1/+2
Fix the Windows build that was broken in "Introduce \"command\" styling". Approved-By: Tom Tromey <tom@tromey.com>
2024-12-14[gdb/dap] Fix regressions with python 3.6Tom de Vries1-1/+2
With test-case gdb.dap/ada-arrays.exp, on Leap openSUSE 15.6 with python 3.6, I run into: ... Python Exception <class 'TypeError'>: 'type' object is not subscriptable Error occurred in Python: 'type' object is not subscriptable ERROR: tcl error sourcing ada-arrays.exp. ... This is due to using a python 3.9 construct: ... thread_ids: dict[int, int] = {} ... Fix this by using typing.Dict instead. Tested on x86_64-linux.
2024-12-13[gdb] Fix tsan warning: signal handler spoils errnoTom de Vries3-0/+3
When building gdb with -fsanitize=thread and running test-case gdb.base/bg-exec-sigint-bp-cond.exp, I run into: ... ==================^M WARNING: ThreadSanitizer: signal handler spoils errno (pid=25422)^M #0 handler_wrapper gdb/posix-hdep.c:66^M #1 decltype ({parm#2}({parm#3}...)) gdb::handle_eintr<>() \ gdbsupport/eintr.h:67^M #2 gdb::waitpid(int, int*, int) gdbsupport/eintr.h:78^M #3 run_under_shell gdb/cli/cli-cmds.c:926^M ... Likewise in: - tui_sigwinch_handler with test-case gdb.python/tui-window.exp, and - handle_sighup with test-case gdb.base/quit-live.exp. Fix this by saving the original errno, and restoring it before returning [1]. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> [1] https://www.gnu.org/software/libc/manual/html_node/POSIX-Safety-Concepts.html
2024-12-13gdb/dap: allow some requests when the process is runningoltolm2-2/+2
It is impossible to set a breakpoint when the process is running, which I find annoying. LLDB does not have this restriction. I made `setBreakpoints` and `breakpointLocations` work when the process is running. Probably more requests can be changed, but I only need these two at the moment. Approved-By: Tom Tromey <tom@tromey.com>
2024-12-13gdb-dap: fix gdb.error: Frame is invalid.Oleg Tolmatcev2-18/+34
When you try to use a frame on one thread and it was created on another you get an error. I fixed it by creating a map from a frame ID to a thread ID. When a frame is created it is added to the map. When you try to find a frame for an id it checks if it is on the correct thread and if not switches to that thread. I had to store the frame id instead of the frame itself in a "_ScopeReference". Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32133 Approved-By: Tom Tromey <tom@tromey.com>
2024-12-12Reuse "title" style for list headersTom Tromey4-6/+13
This patch reuses the "title" style for titles -- in particular the header line of a list display. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Reviewed-By: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-12Replace uses of "title" style with "command"Tom Tromey4-16/+17
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-12Introduce "command" stylingTom Tromey22-65/+143
This adds a new "command" style that is used when styling the name of a gdb command. Note that not every instance of a command name that is output by gdb is changed here. There is currently no way to style error() strings, and there is no way to mark up command help strings. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31747 Reviewed-By: Eli Zaretskii <eliz@gnu.org> Reviewed-By: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-12Lock bfd_stat and bfd_get_mtimeTom Tromey7-9/+47
PR gdb/31713 points out some races when using the background DWARF reader. This particular patch fixes some of these, namely the ones when using the sim. In this case, the 'load' command calls reopen_exec_file, which calls bfd_stat, which introduces a race. BFD only locks globals -- concurrent use of a single BFD must be handled by the application. To this end, this patch adds locked wrappers for bfd_stat and bfd_get_mtime. I couldn't reproduce these data races but the original reporter tested the patch and confirms that it helps. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31713 Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-12Fix formatting in gdb.ada/lazy-string.expTom Tromey1-3/+3
This fixes a formatting issue and corrects a comment in the new gdb.ada/lazy-string.exp. I meant to do this in an earlier patch but forgot to save.