aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2023-02-27Fix value chain use-after-freeTom Tromey14-54/+173
Hannes filed a bug showing a crash, where a pretty-printer written in Python could cause a use-after-free. He sent a patch, but I thought a different approach was needed. In a much earlier patch (see bug #12533), we changed the Python code to release new values from the value chain when constructing a gdb.Value. The rationale for this is that if you write a command that does a lot of computations in a loop, all the values will be kept live by the value chain, resulting in gdb using a large amount of memory. However, suppose a value is passed to Python from some code in gdb that needs to use the value after the call into Python. In this scenario, value_to_value_object will still release the value -- and because gdb code doesn't generally keep strong references to values (a consequence of the ancient decision to use the value chain to avoid memory management), this will result in a use-after-free. This scenario can happen, as it turns out, when a value is passed to Python for pretty-printing. Now, normally this route boxes the value via value_to_value_object_no_release, avoiding the problematic release from the value chain. However, if you then call Value.cast, the underlying value API might return the same value, when is then released from the chain. This patch fixes the problem by changing how value boxing is done. value_to_value_object no longer removes a value from the chain. Instead, every spot in gdb that might construct new values uses a scoped_value_mark to ensure that the requirements of bug #12533 are met. And, because incoming values aren't ever released from the chain (the Value.cast one comes earlier on the chain than the scoped_value_mark), the bug can no longer occur. (Note that many spots in the Python layer already take this approach, so not many places needed to be touched.) In the future I think we should replace the use of raw "value *" with value_ref_ptr pretty much everywhere. This will ensure lifetime safety throughout gdb. The test case in this patch comes from Hannes' original patch. I only made a trivial ("require") change to it. However, while this fails for him, I can't make it fail on this machine; nevertheless, he tried my patch and reported the bug as being fixed. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30044
2023-02-27Remove infrun_thread_thread_exit observerPedro Alves1-9/+0
After the previous patches, I believe this observer isn't necessary anymore for anything. Remove it. Change-Id: Idb33fb6b6f55589c8c523a92169b3ca95a23d0b9
2023-02-27all-stop "follow-fork parent" and selecting another threadPedro Alves3-9/+335
With: - catch a fork in thread 1 - select thread 2 - set follow-fork child - next ... follow_fork notices that thread 1 had last stopped for a fork which hasn't been followed yet, and because thread 1 is not the current thread, GDB aborts the execution command, presenting the stop in thread 1. That makes sense, as only the forking thread (thread 1) survives in the child, so better stop and let the user decide how to proceed. However, with: - catch a fork in thread 1 - select thread 2 - set follow-fork parent << note difference here - next ... GDB does the same: follow_fork notices that thread 1 had last stopped for a fork which hasn't been followed yet, and because thread 1 is not the current thread, GDB aborts the execution command, presenting the stop in thread 1. Aborting/stopping in this case doesn't make sense to me. As we're following the parent, thread 2 will still continue to exist in the parent. What the child does after we've followed the parent shouldn't matter -- it can go on running free, be detached, etc., depending on "set schedule-multiple", "set detach-on-fork", etc. That does not influence the execution command that the user issued for the parent thread. So this patch changes GDB in that direction -- in follow_fork, if following the parent, and we've switched threads meanwhile, switch back to the unfollowed thread, follow it (stay with the parent), and don't abort/stop. If we're following a fork (as opposed to vfork), then switch back again to the thread that the user was trying to resume. If following a vfork, however, stay with the vforking-thread selected, as we will need to see a vfork_done event first, before we can resume any other thread. As I was working on this, I managed to end up calling target_resume for a solo-thread resume (to collect the vfork_done event), with scope_ptid pointing at the vfork parent thread, and inferior_ptid pointing to the vfork child. For a solo-thread resume, the scope_ptid argument to target_resume must the same as inferior_ptid. The mistake was caught by the assertion in target_resume, like so: ... [infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [1722839.1722839.0] at 0x5555555553c3 [infrun] do_target_resume: resume_ptid=1722839.1722939.0, step=0, sig=GDB_SIGNAL_0 ../../src/gdb/target.c:2661: internal-error: target_resume: Assertion `inferior_ptid.matches (scope_ptid)' failed. ... but I think it doesn't hurt to catch such a mistake earlier, hence the change in internal_resume_ptid. Change-Id: I896705506a16d2488b1bfb4736315dd966f4e412
2023-02-27Make follow_fork not rely on get_last_target_statusPedro Alves2-32/+71
Currently, if - you're in all-stop mode, - the inferior last stopped because of a fork catchpoint, when you next resume the program, gdb checks whether it had last stopped for a fork/vfork, and if so, a) if the current thread is the one that forked, gdb follows the parent/child, depending on "set follow-fork" mode. b) if the current thread is some other thread (because you switched threads meanwhile), gdb switches back to that thread, gdb follows the parent/child, and stops the resumption command. There's a problem in b), however -- if you have "set schedule-multiple off", which is the default, or "set scheduler-locking on", gdb will still switch back to the forking thread, even if you didn't want to resume it. For example, with: (gdb) catch fork (gdb) c * thread 1 stops for fork (gdb) thread 2 (gdb) set scheduler-locking on (gdb) c gdb switches back to thread 1, and follows the fork. Or with: (gdb) add-inferior -exec prog (gdb) inferior 2 (gdb) start (gdb) inferior 1 (gdb) catch fork (gdb) c * thread 1.1 stops for fork (gdb) inferior 2 (gdb) set schedule-multiple off # this is the default (gdb) c gdb switches back to thread 1.1, and follows the fork. Another issue is that, because follow_fork relies on get_last_target_status to find the thread that has a pending fork, it is possible to confuse it. For example, "run" or "start" call init_wait_for_inferior, which clears the last target status, so this: (gdb) catch fork (gdb) c * thread 1 stops for fork (gdb) add-inferior -exec prog (gdb) inferior 2 (gdb) start (gdb) set follow-fork child (gdb) inferior 1 (gdb) n ... does not follow to the fork child of inferior 1, because the get_last_target_status call in follow_fork doesn't return a TARGET_WAITKIND_FORKED. Thanks to Simon for this example. All of the above are fixed by this patch. It changes follow_fork to not look at get_last_target_status, but to instead iterate over the set of threads that the user is resuming, and find the one that has a pending_follow kind of fork/vfork. gdb.base/foll-fork.exp is augmented to exercise the last "start" scenario described above. The other cases will be exercised in the testcase added by the following patch. Change-Id: Ifcca77e7b2456277387f40660ef06cec2b93b97e
2023-02-27Improve "info program"Pedro Alves6-46/+263
With gdb.base/catch-follow-exec.exp, we currently see: ~~~~~~~~~~~~~~~ (gdb) continue Continuing. process 693251 is executing new program: /usr/bin/ls [New inferior 2] [New process 693251] [Switching to process 693251] Thread 2.1 "ls" hit Catchpoint 2 (exec'd /usr/bin/ls), 0x00007ffff7fd0100 in _start () from /lib64/ld-linux-x86-64.so.2 (gdb) info prog No selected thread. ~~~~~~~~~~~~~~~ Note the "No selected thread" output. That is totally bogus, because there _is_ a selected thread. What GDB really means, is that it can't find the thread that had the latest (user-visible) stop. And that happens because "info program" gets that info from get_last_target_status, and the last target status has been cleared. However, GDB also checks if there is a selected thread, here: if (ptid == null_ptid || ptid == minus_one_ptid) error (_("No selected thread.")); .. the null_ptid part. That is also bogus, because what matters is the thread that last reported a stop, not the current thread: - in all-stop mode, "info program" displays info about the last stop. That may have happened on a thread different from the selected thread. - in non-stop mode, because all threads are controlled individually, "info program" shows info about the last stop of the selected thread. The current code already behaves this way, though in a poor way. This patch reimplements it, such that the all-stop version now finds the thread that last reported an event via the 'previous_thread' strong reference. Being a strong reference means that if that thread has exited since the event was reported, 'previous_thread' will still point to it, so we can say that the thread exited meanwhile. The patch also extends "info program" output a little, to let the user know which thread we are printing info for. For example, for the gdb.base/catch-follow-exec.exp case we shown above, we now get: (gdb) info prog Last stopped for thread 2.1 (process 710867). Using the running image of child process 710867. Program stopped at 0x7ffff7fd0100. It stopped at breakpoint 2. Type "info stack" or "info registers" for more information. (gdb) while in non-stop mode, we get: (gdb) info prog Selected thread 2.1 (process 710867). Using the running image of child process 710867. Program stopped at 0x7ffff7fd0100. It stopped at breakpoint 2. Type "info stack" or "info registers" for more information. (gdb) In both cases, the first line of output is new. The existing code considered these running/exited cases as an error, but I think that that's incorrect, since this is IMO just plain execution info as well. So the patch makes those cases regular prints, not errors. If the thread is running, we get, in non-stop mode: (gdb) info prog Selected thread 2.1 (process 710867). Selected thread is running. ... and in all-stop: (gdb) info prog Last stopped for thread 2.1 (process 710867). Thread is now running. If the thread has exited, we get, in non-stop mode: (gdb) info prog Selected thread 2.1 (process 710867). Selected thread has exited. ... and in all-stop: (gdb) info prog Last stopped for thread 2.1 (process 710867). Thread has since exited. The gdb.base/info-program.exp testcase was much extended to test all-stop/non-stop and single-threaded/multi-threaded. Change-Id: I51d9d445f772d872af3eead3449ad4aa445781b1
2023-02-27Convert previous_inferior_ptid to strong reference to thread_infoPedro Alves4-15/+42
I originally wrote this patch, because while working on some other patch, I spotted a regression in the gdb.multi/multi-target-no-resumed.exp.exp testcase. Debugging the issue, I realized that the problem was related to how I was using previous_inferior_ptid to look up the thread the user had last selected. The problem is that previous_inferior_ptid alone doesn't tell you which target that ptid is from, and I was just always using the current target, which was incorrect. Two different targets may have threads with the same ptid. I decided to fix this by replacing previous_inferior_ptid with a strong reference to the thread, called previous_thread. I have since found a new motivation for this change -- I would like to tweak "info program" to not rely on get_last_target_status returning a ptid that still exists in the thread list. With both the follow_fork changes later in this series, and the step-over-thread-exit changes, that can happen, as we'll delete threads and not clear the last waitstatus. A new update_previous_thread function is added that can be used to update previous_thread from inferior_ptid. This must be called in several places that really want to get rid of previous_thread thread, and reset the thread id counter, otherwise we get regressions like these: (gdb) info threads -gid Id GId Target Id Frame - * 1 1 Thread 2974541.2974541 "tids-gid-reset" main () at src/gdb/testsuite/gdb.multi/tids-gid-reset.c:21 - (gdb) PASS: gdb.multi/tids-gid-reset.exp: single-inferior: after restart: info threads -gid + * 1 2 Thread 2958361.2958361 "tids-gid-reset" main () at src/gdb/testsuite/gdb.multi/tids-gid-reset.c:21 + (gdb) FAIL: gdb.multi/tids-gid-reset.exp: single-inferior: after restart: info threads -gid and: Core was generated by `build/gdb/testsuite/outputs/gdb.reverse/sigall-precsave/si'. Program terminated with signal SIGTRAP, Trace/breakpoint trap. #0 gen_ABRT () at src/gdb/testsuite/gdb.reverse/sigall-reverse.c:398 398 kill (getpid (), SIGABRT); +[Current thread is 1 (LWP 2662066)] Restored records from core file build/gdb/testsuite/outputs/gdb.reverse/sigall-precsave/sigall.precsave. #0 gen_ABRT () at src/gdb/testsuite/gdb.reverse/sigall-reverse.c:398 398 kill (getpid (), SIGABRT); continue Continuing. -Program received signal SIGABRT, Aborted. +Thread 1 received signal SIGABRT, Aborted. 0x00007ffff7dfd55b in kill () at ../sysdeps/unix/syscall-template.S:78 78 ../sysdeps/unix/syscall-template.S: No such file or directory. -(gdb) PASS: gdb.reverse/sigall-precsave.exp: sig-test-1: get signal ABRT +(gdb) FAIL: gdb.reverse/sigall-precsave.exp: sig-test-1: get signal ABRT I.e., GDB was failing to restart the thread counter back to 1, because the previous_thread thread was being help due to the strong reference. Tested on GNU/Linux native, gdbserver and gdbserver + "maint set target-non-stop on". gdb/ChangeLog: yyyy-mm-dd Pedro Alves <pedro@palves.net> * infcmd.c (kill_command, detach_command, disconnect_command): Call update_previous_thread. * infrun.c (previous_inferior_ptid): Delete. (previous_thread): New. (update_previous_thread): New. (proceed, init_wait_for_inferior): Call update_previous_thread. (normal_stop): Adjust to compare previous_thread and inferior_thread. Call update_previous_thread. * infrun.h (update_previous_thread): Declare. * target.c (target_pre_inferior, target_preopen): Call update_previous_thread. Change-Id: I42779a1ee51a996fa1e8f6e1525c6605dbfd42c7
2023-02-27Tweak "Using the running image of ..." outputPedro Alves4-4/+4
Currently, "info files" and "info program" on a few native targets show: (gdb) info files Symbols from "/home/pedro/gdb/tests/threads". Native process: Using the running image of child Thread 0x7ffff7d89740 (LWP 1097968). ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... (gdb) info program Using the running image of child Thread 0x7ffff7d89740 (LWP 1097968). ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Program stopped at 0x555555555278. ... This patch changes them to: (gdb) info files Symbols from "/home/pedro/gdb/tests/threads". Native process: Using the running image of child process 1097968. ^^^^^^^^^^^^^^^ ... (gdb) info program Using the running image of child process 1097968. ^^^^^^^^^^^^^^^ Program stopped at 0x555555555278. ... ... which I think makes a lot more sense in this context. The "info program" manual entry even says: "Display information about the status of your program: whether it is running or not, what process it is, and why it stopped." ^^^^^^^^^^^^^ This change affects ptrace targets, procfs targets, and Windows. Approved-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: I6aab061ff494a84ba3398cf98fd49efd7a6ec1ca
2023-02-27gdb: make-target-delegates.py: add type annotationsSimon Marchi1-16/+33
Fixes all warnings given by pyright. Change-Id: I480521bfc62960c4eccd9d32c886392b05a1ddaa Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: make-target-delegates.py: add Entry typeSimon Marchi1-16/+39
Add the Entry type and use it in the `entries` map, rather than using an ad-hoc str -> str map that comes from the re.match. This will make it easier to make typing work in a subsequent patch, but it also helps readers know what attributes exist for entries, which is not clear currently. Change-Id: I5b58dee1ed7ae85987b99bd417e641ede718624c Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: make-target-delegates.py: make one string rawSimon Marchi1-1/+1
Fixes the following flake8 warning: make-target-delegates.py:36:39: W605 invalid escape sequence '\s' Change-Id: I25eeb296f55765e17e5217a2d1e49018f63a3acd Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: gdbarch*.py, copyright.py: add type annotationsSimon Marchi4-49/+51
Add type annotations to gdbarch*.py to fix all errors shown by pyright. There is one change in copyright.py too, to fix this one: /home/simark/src/binutils-gdb/gdb/gdbarch.py /home/simark/src/binutils-gdb/gdb/gdbarch.py:206:13 - error: Type of "copyright" is partially unknown Type of "copyright" is "(tool: Unknown, description: Unknown) -> str" (reportUnknownMemberType) Change-Id: Ia109b53e267f6e2f5bd79a1288d0d5c9508c9ac4 Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: split gdbarch component types to gdbarch_types.pySimon Marchi3-168/+190
Editing gdbarch-components.py is not an experience in an editor that is minimally smart about Python. Because gdbarch-components.py is read and exec'd by gdbarch.py, it doesn't import the Info / Method / Function / Value types. And because these types are defined in gdbarch.py, it can't import them, as that would make a cyclic dependency. Solve this by introducing a third file, gdbarch_types.py, to define these types. Make gdbarch.py and gdbarch-components.py import it. Also, replace the read & exec of gdbarch-components.py by a regular import. For this to work though, gdbarch-components.py needs to be renamed to gdbarch_components.py. Change-Id: Ibe994d56ef9efcc0698b3ca9670d4d9bf8bbb853 Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: pyproject.toml: set pyright typeCheckingMode = "strict"Simon Marchi1-0/+3
While working on other projects, I found the pyright type checker very helpful when editing Python code. I don't think I have to explain the advantages of type checking to a crowd used to C/C++. Setting typeCheckingMode to "strict" makes pyright flag a bit more type issues than the default of "basic". Change-Id: I38818ec59f7f73c2ab020cc9226286cdd485abc7 Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: gdbarch.py: remove Info.__init__Simon Marchi1-6/+1
Info.__init__ currently assigns `self.predicate = None`. This was helpful to ensure that all component types had a `predicate` attribute. The generator code could then avoid having code like "if the component is anything but Info, use predicate". Since the previous commit, all component types have a predicate attribute which defaults to False. We can therefore remove the assignment in Info.__init__, and in turn remove Info.__init__. We however need to make the printer parameter of _Component.__init__ optional, as Info don't need a printer. Change-Id: I611edeca9cc9837eb49dddfe038595e1ff3b7239 Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: gdbarch.py: spell out parameters of _Component.__init__Simon Marchi1-5/+30
The way _Component uses kwargs is handy to save a few characters, but it doesn't play well with static analysis. When editing gdbarch.py, my editor (which uses pylance under the hood) knows nothing about the properties of components. So it's full of squiggly lines, and typing analysis (which I find really helpful) doesn't work. I therefore think it would be better to spell out the parameters. Change-Id: Iaf561beb0d0fbe170ce1c79252a291e0945e1830 Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: reformat Python files with black 23.1.0Simon Marchi13-9/+11
Change-Id: Ie8ec8870a16d71c5858f5d08958309d23c318302 Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27gdb: remove invalid / dead code from gdbarch.pySimon Marchi1-2/+0
My editor flagged that the variable `c` (in the lines removed by this patch) was unknown. I guess it ends up working because there is a `c` variable in the global scope. I tried putting `assert False` inside that if, and it is not hit, showing that we never enter this if. So, remove it. There is no change in the generated files. Change-Id: Id3b9f67719e88cada7c6fde673c8d7842ab13617 Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27Fix crash with "finish" in RustTom Tromey3-1/+70
PR rust/30090 points out that a certain "finish" in a Rust program will cause gdb to crash. This happens due to some confusion about field indices in rust_language::print_enum. The fix is to use value_primitive_field so that the correct type can be passed; other spots in rust-lang.c already do this. Note that the enclosed test case comes with an xfail. This is needed because for this function, rustc doesn't follow the platform ABI. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30090
2023-02-27Remove old GNU indent directivesTom Tromey15-29/+6
Now that gdb_indent.sh has been removed, I think it makes sense to also remove the directives intended for GNU indent.
2023-02-27Handle range types in ax-gdb.cTom Tromey3-22/+42
A range type can usually be treated the same as its underlying integer type, at least for the purposes of agent expressions. This patch arranges for range types to be handled this way in ax-gdb.c, letting a somewhat larger subset of Ada expressions be compiled.
2023-02-27Implement some agent expressions for AdaTom Tromey4-8/+138
Ada historically has not implemented agent expressions, and some Ada constructs probably cannot reasonably be converted to agent expressions. However, a subset of simple operations can be, and this patch represents a first step in that direction. On one internal AdaCore test case, this improves the performance of a conditional breakpoint from 5 minutes to 5 seconds. The main tricky part in this patch is ensuring the converted expressions detect the cases that will not work. This is done by examining the code in the corresponding evaluation methods.
2023-02-27Regenerate Linux syscall group infoPedro Alves15-856/+1001
This commit makes use of the new script to regenerate the Linux syscall group info against strace git hash e88e5e9ae6da68f22d15f9be3193b1412ac9aa02. Like so: $ cd gdb/syscalls/ $ ./update-linux-defaults.sh ~/strace.git/ Generating linux-defaults.xml.in $ make for f in aarch64-linux.xml amd64-linux.xml arm-linux.xml bfin-linux.xml \ i386-linux.xml mips-n32-linux.xml mips-n64-linux.xml \ mips-o32-linux.xml ppc64-linux.xml ppc-linux.xml s390-linux.xml \ s390x-linux.xml sparc64-linux.xml sparc-linux.xml; do \ xsltproc --output $f apply-defaults.xsl $f.in; \ done The result is that a lot more syscalls end up assigned to groups. Some lose their group info, but that just mirrors what strace does. The gdb/syscalls/linux-defaults.xml.in file shows a large diff because the new version is ASCII sorted, while the current version was somewhat (but not consistently) sorted by "family" of syscalls. If I sort the old file and diff against the new, the difference is like this: <syscall name="accept4" groups="network"/> <syscall name="accept" groups="network"/> <syscall name="access" groups="file"/> <syscall name="acct" groups="file"/> - <syscall name="arch_prctl" groups="process"/> <syscall name="bind" groups="network"/> + <syscall name="bpf" groups="descriptor"/> <syscall name="break" groups="memory"/> <syscall name="brk" groups="memory"/> + <syscall name="bsd43_fstatfs" groups="descriptor"/> + <syscall name="bsd43_fstat" groups="descriptor"/> + <syscall name="bsd43_killpg" groups="process"/> + <syscall name="bsd43_kill" groups="process"/> + <syscall name="bsd43_lstat" groups="file"/> + <syscall name="bsd43_madvise" groups="memory"/> + <syscall name="bsd43_mincore" groups="memory"/> + <syscall name="bsd43_mmap" groups="descriptor,memory"/> + <syscall name="bsd43_mprotect" groups="memory"/> + <syscall name="bsd43_mremap" groups="memory"/> + <syscall name="bsd43_munmap" groups="memory"/> + <syscall name="bsd43_oldfstat" groups="descriptor"/> + <syscall name="bsd43_oldstat" groups="file"/> + <syscall name="bsd43_quotactl" groups="file"/> + <syscall name="bsd43_sbreak" groups="memory"/> + <syscall name="bsd43_sbrk" groups="memory"/> + <syscall name="bsd43_statfs" groups="file"/> + <syscall name="bsd43_stat" groups="file"/> + <syscall name="cacheflush" groups="memory"/> <syscall name="chdir" groups="file"/> <syscall name="chmod" groups="file"/> <syscall name="chown32" groups="file"/> <syscall name="chown" groups="file"/> <syscall name="chroot" groups="file"/> + <syscall name="clone2" groups="process"/> + <syscall name="clone3" groups="process"/> <syscall name="clone" groups="process"/> <syscall name="close" groups="descriptor"/> <syscall name="connect" groups="network"/> + <syscall name="copy_file_range" groups="descriptor"/> <syscall name="creat" groups="descriptor,file"/> <syscall name="dup2" groups="descriptor"/> <syscall name="dup3" groups="descriptor"/> @@ -28,14 +52,17 @@ <syscall name="epoll_create1" groups="descriptor"/> <syscall name="epoll_create" groups="descriptor"/> <syscall name="epoll_ctl" groups="descriptor"/> + <syscall name="epoll_pwait2" groups="descriptor"/> <syscall name="epoll_pwait" groups="descriptor"/> <syscall name="epoll_wait" groups="descriptor"/> <syscall name="eventfd2" groups="descriptor"/> <syscall name="eventfd" groups="descriptor"/> + <syscall name="execveat" groups="descriptor,file,process"/> <syscall name="execve" groups="file,process"/> <syscall name="execv" groups="file,process"/> <syscall name="exit_group" groups="process"/> <syscall name="exit" groups="process"/> + <syscall name="faccessat2" groups="descriptor,file"/> <syscall name="faccessat" groups="descriptor,file"/> <syscall name="fadvise64_64" groups="descriptor"/> <syscall name="fadvise64" groups="descriptor"/> @@ -57,7 +84,11 @@ <syscall name="flock" groups="descriptor"/> <syscall name="fork" groups="process"/> <syscall name="fremovexattr" groups="descriptor"/> + <syscall name="fsconfig" groups="descriptor,file"/> <syscall name="fsetxattr" groups="descriptor"/> + <syscall name="fsmount" groups="descriptor"/> + <syscall name="fsopen" groups="descriptor"/> + <syscall name="fspick" groups="descriptor,file"/> <syscall name="fstat64" groups="descriptor"/> <syscall name="fstatat64" groups="descriptor,file"/> <syscall name="fstatfs64" groups="descriptor"/> @@ -72,16 +103,26 @@ <syscall name="getdents" groups="descriptor"/> <syscall name="get_mempolicy" groups="memory"/> <syscall name="getpeername" groups="network"/> + <syscall name="getpmsg" groups="network"/> <syscall name="getsockname" groups="network"/> <syscall name="getsockopt" groups="network"/> <syscall name="getxattr" groups="file"/> - <syscall name="inotify_add_watch" groups="descriptor"/> + <syscall name="inotify_add_watch" groups="descriptor,file"/> <syscall name="inotify_init1" groups="descriptor"/> <syscall name="inotify_init" groups="descriptor"/> <syscall name="inotify_rm_watch" groups="descriptor"/> <syscall name="ioctl" groups="descriptor"/> + <syscall name="io_destroy" groups="memory"/> + <syscall name="io_setup" groups="memory"/> + <syscall name="io_uring_enter" groups="descriptor,signal"/> + <syscall name="io_uring_register" groups="descriptor,memory"/> + <syscall name="io_uring_setup" groups="descriptor"/> <syscall name="ipc" groups="ipc"/> - <syscall name="kill" groups="signal"/> + <syscall name="kexec_file_load" groups="descriptor"/> + <syscall name="kill" groups="signal,process"/> + <syscall name="landlock_add_rule" groups="descriptor"/> + <syscall name="landlock_create_ruleset" groups="descriptor"/> + <syscall name="landlock_restrict_self" groups="descriptor"/> <syscall name="lchown32" groups="file"/> <syscall name="lchown" groups="file"/> <syscall name="lgetxattr" groups="file"/> @@ -98,19 +139,31 @@ <syscall name="lstat" groups="file"/> <syscall name="madvise" groups="memory"/> <syscall name="mbind" groups="memory"/> + <syscall name="memfd_create" groups="descriptor"/> + <syscall name="memfd_secret" groups="descriptor"/> <syscall name="migrate_pages" groups="memory"/> <syscall name="mincore" groups="memory"/> <syscall name="mkdirat" groups="descriptor,file"/> <syscall name="mkdir" groups="file"/> <syscall name="mknodat" groups="descriptor,file"/> <syscall name="mknod" groups="file"/> + <syscall name="mlock2" groups="memory"/> <syscall name="mlockall" groups="memory"/> <syscall name="mlock" groups="memory"/> <syscall name="mmap2" groups="descriptor,memory"/> <syscall name="mmap" groups="descriptor,memory"/> + <syscall name="mount_setattr" groups="descriptor,file"/> <syscall name="mount" groups="file"/> + <syscall name="move_mount" groups="descriptor,file"/> <syscall name="move_pages" groups="memory"/> <syscall name="mprotect" groups="memory"/> + <syscall name="mq_getsetattr" groups="descriptor"/> + <syscall name="mq_notify" groups="descriptor"/> + <syscall name="mq_open" groups="descriptor"/> + <syscall name="mq_timedreceive" groups="descriptor"/> + <syscall name="mq_timedreceive_time64" groups="descriptor"/> + <syscall name="mq_timedsend" groups="descriptor"/> + <syscall name="mq_timedsend_time64" groups="descriptor"/> <syscall name="mremap" groups="memory"/> <syscall name="msgctl" groups="ipc"/> <syscall name="msgget" groups="ipc"/> @@ -126,45 +179,98 @@ <syscall name="oldfstat" groups="descriptor"/> <syscall name="oldlstat" groups="file"/> <syscall name="oldstat" groups="file"/> + <syscall name="oldumount" groups="file"/> + <syscall name="openat2" groups="descriptor,file"/> <syscall name="openat" groups="descriptor,file"/> <syscall name="open_by_handle_at" groups="descriptor"/> <syscall name="open" groups="descriptor,file"/> + <syscall name="open_tree" groups="descriptor,file"/> + <syscall name="osf_fstatfs64" groups="descriptor"/> + <syscall name="osf_fstatfs" groups="descriptor"/> + <syscall name="osf_fstat" groups="descriptor"/> + <syscall name="osf_lstat" groups="file"/> + <syscall name="osf_mincore" groups="memory"/> + <syscall name="osf_mremap" groups="memory"/> + <syscall name="osf_old_fstat" groups="descriptor"/> + <syscall name="osf_old_killpg" groups="process"/> + <syscall name="osf_old_lstat" groups="file"/> + <syscall name="osf_old_stat" groups="file"/> + <syscall name="osf_sbrk" groups="memory"/> + <syscall name="osf_select" groups="descriptor"/> + <syscall name="osf_shmat" groups="ipc,memory"/> + <syscall name="osf_sigprocmask" groups="signal"/> + <syscall name="osf_statfs64" groups="file"/> + <syscall name="osf_statfs" groups="file"/> + <syscall name="osf_stat" groups="file"/> + <syscall name="osf_utimes" groups="file"/> + <syscall name="osf_wait4" groups="process"/> <syscall name="pause" groups="signal"/> <syscall name="perf_event_open" groups="descriptor"/> + <syscall name="pidfd_getfd" groups="descriptor"/> + <syscall name="pidfd_open" groups="descriptor"/> + <syscall name="pidfd_send_signal" groups="descriptor,signal,process"/> <syscall name="pipe2" groups="descriptor"/> <syscall name="pipe" groups="descriptor"/> <syscall name="pivot_root" groups="file"/> + <syscall name="pkey_mprotect" groups="memory"/> <syscall name="poll" groups="descriptor"/> + <syscall name="posix_fstatfs" groups="descriptor"/> + <syscall name="posix_fstat" groups="descriptor"/> + <syscall name="posix_kill" groups="process"/> + <syscall name="posix_lstat" groups="file"/> + <syscall name="posix_madvise" groups="memory"/> + <syscall name="posix_mmap" groups="descriptor,memory"/> + <syscall name="posix_munmap" groups="memory"/> + <syscall name="posix_sbreak" groups="memory"/> + <syscall name="posix_SGI_madvise" groups="memory"/> + <syscall name="posix_SGI_mmap" groups="descriptor,memory"/> + <syscall name="posix_SGI_mprotect" groups="memory"/> + <syscall name="posix_SGI_msync" groups="memory"/> + <syscall name="posix_SGI_munmap" groups="memory"/> + <syscall name="posix_statfs" groups="file"/> + <syscall name="posix_stat" groups="file"/> <syscall name="ppoll" groups="descriptor"/> + <syscall name="ppoll_time64" groups="descriptor"/> <syscall name="pread64" groups="descriptor"/> <syscall name="pread" groups="descriptor"/> + <syscall name="preadv2" groups="descriptor"/> <syscall name="preadv" groups="descriptor"/> + <syscall name="process_madvise" groups="descriptor"/> + <syscall name="process_mrelease" groups="descriptor"/> <syscall name="pselect6" groups="descriptor"/> + <syscall name="pselect6_time64" groups="descriptor"/> + <syscall name="putpmsg" groups="network"/> <syscall name="pwrite64" groups="descriptor"/> <syscall name="pwrite" groups="descriptor"/> + <syscall name="pwritev2" groups="descriptor"/> <syscall name="pwritev" groups="descriptor"/> + <syscall name="quotactl_fd" groups="descriptor"/> <syscall name="quotactl" groups="file"/> <syscall name="readahead" groups="descriptor"/> <syscall name="readdir" groups="descriptor"/> - <syscall name="read" groups="descriptor"/> <syscall name="readlinkat" groups="descriptor,file"/> <syscall name="readlink" groups="file"/> + <syscall name="read" groups="descriptor"/> <syscall name="readv" groups="descriptor"/> <syscall name="recvfrom" groups="network"/> - <syscall name="recv" groups="network"/> + <syscall name="recvmmsg_time64" groups="network"/> <syscall name="recvmmsg" groups="network"/> <syscall name="recvmsg" groups="network"/> + <syscall name="recv" groups="network"/> <syscall name="remap_file_pages" groups="memory"/> <syscall name="removexattr" groups="file"/> + <syscall name="renameat2" groups="descriptor,file"/> <syscall name="renameat" groups="descriptor,file"/> <syscall name="rename" groups="file"/> + <syscall name="riscv_flush_icache" groups="memory"/> <syscall name="rmdir" groups="file"/> <syscall name="rt_sigaction" groups="signal"/> <syscall name="rt_sigpending" groups="signal"/> <syscall name="rt_sigprocmask" groups="signal"/> - <syscall name="rt_sigqueueinfo" groups="signal"/> + <syscall name="rt_sigqueueinfo" groups="signal,process"/> <syscall name="rt_sigreturn" groups="signal"/> <syscall name="rt_sigsuspend" groups="signal"/> + <syscall name="rt_sigtimedwait_time64" groups="signal"/> <syscall name="rt_sigtimedwait" groups="signal"/> <syscall name="rt_tgsigqueueinfo" groups="process,signal"/> <syscall name="select" groups="descriptor"/> @@ -172,12 +278,14 @@ <syscall name="semget" groups="ipc"/> <syscall name="semop" groups="ipc"/> <syscall name="semtimedop" groups="ipc"/> + <syscall name="semtimedop_time64" groups="ipc"/> <syscall name="sendfile64" groups="descriptor,network"/> <syscall name="sendfile" groups="descriptor,network"/> - <syscall name="send" groups="network"/> <syscall name="sendmmsg" groups="network"/> <syscall name="sendmsg" groups="network"/> + <syscall name="send" groups="network"/> <syscall name="sendto" groups="network"/> + <syscall name="set_mempolicy_home_node" groups="memory"/> <syscall name="set_mempolicy" groups="memory"/> <syscall name="setns" groups="descriptor"/> <syscall name="setsockopt" groups="network"/> @@ -198,38 +306,78 @@ <syscall name="sigreturn" groups="signal"/> <syscall name="sigsuspend" groups="signal"/> <syscall name="socketcall" groups="descriptor"/> - <syscall name="socket" groups="network"/> <syscall name="socketpair" groups="network"/> + <syscall name="socket" groups="network"/> <syscall name="splice" groups="descriptor"/> <syscall name="ssetmask" groups="signal"/> <syscall name="stat64" groups="file"/> <syscall name="statfs64" groups="file"/> <syscall name="statfs" groups="file"/> <syscall name="stat" groups="file"/> + <syscall name="statx" groups="descriptor,file"/> + <syscall name="svr4_fstatfs" groups="descriptor"/> + <syscall name="svr4_fstat" groups="descriptor"/> + <syscall name="svr4_fstatvfs" groups="descriptor"/> + <syscall name="svr4_fxstat" groups="descriptor"/> + <syscall name="svr4_kill" groups="process"/> + <syscall name="svr4_lstat" groups="file"/> + <syscall name="svr4_lxstat" groups="file"/> + <syscall name="svr4_mincore" groups="memory"/> + <syscall name="svr4_mmap" groups="descriptor,memory"/> + <syscall name="svr4_mprotect" groups="memory"/> + <syscall name="svr4_munmap" groups="memory"/> + <syscall name="svr4_sbreak" groups="memory"/> + <syscall name="svr4_statfs" groups="file"/> + <syscall name="svr4_stat" groups="file"/> + <syscall name="svr4_statvfs" groups="file"/> + <syscall name="svr4_xstat" groups="file"/> <syscall name="swapoff" groups="file"/> <syscall name="swapon" groups="file"/> <syscall name="symlinkat" groups="descriptor,file"/> <syscall name="symlink" groups="file"/> + <syscall name="sync_file_range2" groups="descriptor"/> <syscall name="sync_file_range" groups="descriptor"/> <syscall name="syncfs" groups="descriptor"/> + <syscall name="sysv_brk" groups="memory"/> + <syscall name="sysv_fstatfs" groups="descriptor"/> + <syscall name="sysv_fstat" groups="descriptor"/> + <syscall name="sysv_fstatvfs" groups="descriptor"/> + <syscall name="sysv_fxstat" groups="descriptor"/> + <syscall name="sysv_kill" groups="process"/> + <syscall name="sysv_lstat" groups="file"/> + <syscall name="sysv_lxstat" groups="file"/> + <syscall name="sysv_madvise" groups="memory"/> + <syscall name="sysv_mmap64" groups="descriptor,memory"/> + <syscall name="sysv_mmap" groups="descriptor,memory"/> + <syscall name="sysv_mprotect" groups="memory"/> + <syscall name="sysv_msync" groups="memory"/> + <syscall name="sysv_munmap" groups="memory"/> + <syscall name="sysv_quotactl" groups="file"/> + <syscall name="sysv_statfs" groups="file"/> + <syscall name="sysv_stat" groups="file"/> + <syscall name="sysv_statvfs" groups="file"/> + <syscall name="sysv_xstat" groups="file"/> <syscall name="tee" groups="descriptor"/> - <syscall name="tgkill" groups="signal"/> + <syscall name="tgkill" groups="signal,process"/> <syscall name="timerfd_create" groups="descriptor"/> + <syscall name="timerfd_gettime64" groups="descriptor"/> <syscall name="timerfd_gettime" groups="descriptor"/> - <syscall name="timerfd" groups="descriptor"/> + <syscall name="timerfd_settime64" groups="descriptor"/> <syscall name="timerfd_settime" groups="descriptor"/> - <syscall name="tkill" groups="signal"/> + <syscall name="timerfd" groups="descriptor"/> + <syscall name="tkill" groups="signal,process"/> <syscall name="truncate64" groups="file"/> <syscall name="truncate" groups="file"/> <syscall name="umount2" groups="file"/> <syscall name="umount" groups="file"/> <syscall name="unlinkat" groups="descriptor,file"/> <syscall name="unlink" groups="file"/> - <syscall name="unshare" groups="process"/> <syscall name="uselib" groups="file"/> - <syscall name="utime" groups="file"/> + <syscall name="userfaultfd" groups="descriptor"/> <syscall name="utimensat" groups="descriptor,file"/> + <syscall name="utimensat_time64" groups="descriptor,file"/> <syscall name="utimes" groups="file"/> + <syscall name="utime" groups="file"/> <syscall name="vfork" groups="process"/> <syscall name="vmsplice" groups="descriptor"/> <syscall name="wait4" groups="process"/> Change-Id: I679d59d42fb2a914bf7a99e4c558e9696e5adff1
2023-02-27Autogenerate gdb/syscalls/linux-defaults.xml.in (groups) from strace sourcesPedro Alves1-0/+91
I noticed that "catch syscall group:process" doesn't catch clone3, while it does catch clone. The catch syscall group information is recorded in the gdb/syscalls/linux-defaults.xml.in file, which says: <!-- The group field information was based on strace. --> So I looked at the strace sources, to confirm that clone3 is in fact recorded in the "process" group there too, and to check what other syscalls might be missing groups. After some digging, I found that strace records the group info in C arrays, with entries like: ... [ 61] = { 4, TP, SEN(wait4), "wait4" }, [ 62] = { 2, TS|TP, SEN(kill), "kill" }, [ 63] = { 1, 0, SEN(uname), "uname" }, ... You can see the current master's table for Linux x86-64 here: https://github.com/strace/strace/blob/e88e5e9ae6da68f22d15f9be3193b1412ac9aa02/src/linux/x86_64/syscallent.h The column with TS|TP above is what defines each syscall's groups. So I wrote a script that extracts this information and generates linux-defaults.xml.in. Approved-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: I679d59d42fb2a914bf7a99e4c558e9696e5adff1
2023-02-27gdb: don't treat empty enums as flag enumsAndrew Burgess3-0/+81
In C++ it is possible to use an empty enum as a strong typedef. For example, a user could write: enum class my_type : unsigned char {}; Now my_type can be used like 'unsigned char' except the compiler will not allow implicit conversion too and from the native 'unsigned char' type. This is used in the standard library for things like std::byte. Currently, when GDB prints a value of type my_type, it looks like this: (gdb) print my_var $1 = (unknown: 0x4) Which isn't great. This gets worse when we consider something like: std::vector<my_type> vec; When using a pretty-printer, this could look like this: std::vector of length 2, capacity 2 = {(unknown: 0x2), (unknown: 0x4)} Clearly not great. This is described in PR gdb/30148. The problem here is in dwarf2/read.c, we assume all enums are flag enums unless we find an enumerator with a non-flag like value. Clearly an empty enum contains no non-flag values, so we assume the enum is a flag enum. I propose adding an extra check here; that is, an empty enum should never be a flag enum. With this the above cases look more like: (gdb) print my_var $1 = 4 and: std::vector of length 2, capacity 2 = {2, 4} Which look much better. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30148 Reviewed-By: Tom Tromey <tom@tromey.com>
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-27gdb, python: do minor modernization in execute_gdb_commandTankut Baris Aktemur1-12/+13
Use nullptr instead of NULL and boolify two local variables in execute_gdb_command. Approved-By: Tom Tromey <tom@tromey.com>
2023-02-26Remove expand_symtab_containing_pcTom Tromey2-27/+0
The function expand_symtab_containing_pc is unused; remove it. Tested by rebuilding.
2023-02-25gdb/amd64: replace xmalloc/alloca with gdb::byte_vectorAndrew Burgess1-12/+9
Replace a couple of uses of xmalloc and alloc with a gdb::byte_vector local variable instead. There should be no user visible changes after this commit. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-24Remove struct bufferTom Tromey5-6/+0
I've long wanted to remove 'struct buffer', and thanks to Simon's earlier patch, I was finally able to do so. My feeling has been that gdb already has several decent structures available for growing strings: std::string of course, but also obstack and even objalloc from BFD and dyn-string from libiberty. The previous patches in this series removed all the uses of struct buffer, so this one can remove the code and the remaining #includes.
2023-02-24Don't use struct buffer in top.cTom Tromey1-14/+8
This changes top.c to use std::string rather than struct buffer. Like the event-top.c change, this is not completely ideal in that it requires a copy of the string.
2023-02-24Don't use struct buffer in event-top.cTom Tromey1-14/+6
This changes event-top.c to use std::string rather than struct buffer. This isn't completely ideal, in that it requires a copy of the string to be made.
2023-02-24Remove struct buffer from tracefile-tfile.cTom Tromey1-11/+10
This changes tracefile-tfile.c to use std::string rather than struct buffer.
2023-02-24Write the DWARF index in the backgroundTom Tromey4-19/+101
The new DWARF cooked indexer interacts poorly with the DWARF index cache. In particular, the cache will require gdb to wait for the cooked index to be finalized. As this happens in the foreground, it means that users with this setting enabled will see a slowdown. This patch changes gdb to write the cache entry a worker thread. (As usual, in the absence of threads, this work is simply done immediately in the main thread.) Some care is taken to ensure that this can't crash, and that gdb will not exit before the task is complete. To avoid use-after-free problems, the DWARF per-BFD object explicitly waits for the index cache task to complete. To avoid gdb exiting early, an exit observer is used to wait for all such pending tasks. In normal use, neither of these waits will be very visible. For users using "-batch" to pre-generate the index, though, it would be. However I don't think there is much to be done about this, as it was the status quo ante.
2023-02-24Only use the per-BFD object to write a DWARF indexTom Tromey5-60/+48
The DWARF index does not need access to the objfile or per-objfile objects when writing -- it's entirely based on the objfile-independent per-BFD data. This patch implements this idea by changing the entire API to only be passed the per-BFD object. This simplifies some lifetime reasoning for the next patch. This patch removes some code that ensures that the BFD came from a file. It seems to me that checking for the existence of a build-id is good enough for the index cache.
2023-02-24gdb: fix parenthesis position in commentSimon Marchi1-1/+1
Change-Id: I535b597ab4482378910570d8dd69c090419941eb
2023-02-24[gdb/testsuite] Cleanup unnecessary expr from require lineTom de Vries1-1/+1
In a recent commit I've added: ... require {expr [have_compile_flag -fsplit-stack]} ... but actually the expr bit is unnecessary, and we can just use: ... require {have_compile_flag -fsplit-stack} ... Reported-By: Tom Tromey <tom@tromey.com>
2023-02-24GDB: Fix out of bounds accesses with limited-length valuesMaciej W. Rozycki1-3/+14
Fix accesses to limited-length values in `contents_copy_raw' and `contents_copy_raw_bitwise' so that they observe the limit of the original allocation. Reported by Simon Marchi as a heap-buffer-overflow AddressSanitizer issue triggered with gdb.ada/limited-length.exp. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-23gdb/doc: The RISC-V vector registers didn't changePalmer Dabbelt1-5/+1
When we merged the GDB vector register support we did it a bit early, just eating the risk in the very unlikely case that the vector register names changed. They didn't, so we can now remove the caveat in the docs that they might.
2023-02-23gdb: remove --disable-gdbmi configure optionSimon Marchi3-48/+5
I noticed that the --disable-gdbmi option was broken for almost a year (since 740b42ceb7c "gdb/python/mi: create MI commands using python"). The problem today is the python/py-cmd.c file. It is included in the build if Python support is enabled, and it calls into some MI functions (e.g. insert_mi_cmd_entry). If MI support is disabled, we get some undefined symbols like: mold: error: undefined symbol: insert_mi_cmd_entry(std::unique_ptr<mi_command, std::default_delete<mi_command> >) >>> referenced by py-micmd.c >>> python/py-micmd.o:(micmdpy_install_command(micmdpy_object*)) The python/py-cmd.c file should be included in the build if both Python and MI support are enabled. It is not a case we support today, but it could be done with a bit more configure code. However, I think we should just remove the --disable-gdbmi option, and just include MI support unconditionally. Tom Tromey proposed a while ago to remove this option, but it ended staying: https://inbox.sourceware.org/gdb-patches/20180628172132.28843-1-tom@tromey.com/ However, there was no strong opposition to remove it. The argument was just "bah, it doesn't hurt anybody". But given today's case, I would rather remove complexity rather than add some. I couldn't find anybody caring deeply for that option, and it's not like MI adds any external dependency. It's just a bit more code. Removing the option will not break anybody using --disable-gdbmi (it can be found in many build scripts [1]), since we don't flag invalid configure flags. So, remove the option from configure.ac, and adjust Makefile.in accordingly to always include the MI objects in the build. [1] https://github.com/search?q=%22--disable-gdbmi%22&type=code Change-Id: Ifcaa8c9fc4abc6fa686ed5fd984598644f745240 Approved-By: Tom Tromey <tom@tromey.com>
2023-02-23Fix Tcl quoting in gdb_assertTom Tromey3-5/+5
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-23gdb: add AMDGPU header files to HFILES_NO_SRCDIRSimon Marchi1-0/+2
Commit 18b4d0736bc5 ("gdb: initial support for ROCm platform (AMDGPU) debugging") missed adding these header files to the HFILES_NO_SRCDIR list in the Makefile. Fix that now. Change-Id: Ifd387096aef3d147b51aefa2037da5bf6373ea64
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-23gdb: LoongArch: Support reg aliases in info reg commandHui Li1-0/+21
According to LoongArch ELF ABI specification [1], support the register aliases in "info register" command. Without this patch: ``` (gdb) info reg a0 Invalid register `a0' ``` With this patch: ``` (gdb) info reg a0 a0 0x1 1 ``` [1] https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_register_convention Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2023-02-23gdb: LoongArch: Modify the result of the info reg commandHui Li1-0/+39
The "info register" command should only display general registers, but it shows the information of all registers in the current code, add loongarch_register_reggroup_p() so that we can get the expected result. Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2023-02-22gdb.reverse/time-reverse.exp: test both time syscall and C time functionPedro Alves2-22/+57
Instead of only testing this on systems that have a SYS_time syscall, test it everywhere using the time(2) C function, and in addition, run the tests again using the SYS_time syscall. The C variant ensures that if some platform uses some syscall we are not aware of yet, we'll still exercise it, and likely fail, at which point we should teach GDB about the syscall. The explicit syscall variant is useful on platforms where the C function does not call a syscall at all by default, e.g., on some systems the C time function wraps an implementation provided by the vDSO. Approved-By: Tom de Vries <tdevries@suse.de> Change-Id: Id4b755d76577d02c46b8acbfa249d9c31b587633
2023-02-21Issue error on erroneous expressionTom Tromey2-1/+9
A while back I discovered that this does not issue an error: (gdb) p $x = (void * ) 57 $3 = (void *) 0x39 (gdb) p $x + 7 = 3 $6 = (void *) 0x3 This patch fixes the bug. Regression tested on x86-64 Fedora 36. Reviewed-By: Bruno Larsen <blarsen@redhat.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19312
2023-02-21gdb: add --with-curses to --configuration outputPhilippe Blain4-9/+22
'gdb --configuration' does not mention if GDB was built with curses. Since b5075fb68d4 (Rename to allow_tui_tests, 2023-01-08) it does show --enable-tui (or --disable-tui), but one might want to know if GDB was built with curses independently of the availability of the TUI. Since configure.ac uses AC_SEARCH_LIBS to check for the curses library, we do not get an automatically defined HAVE_LIBCURSES symbol in config.in. We do have symbols defined by AC_CHECK_HEADERS (HAVE_CURSES_H, etc.) but it would be cumbersome to use those in print_gdb_configuration because we would have to check for all 6 symbols corresponding the 6 headers listed. This would also increase the maintenance burden if support for other variations of curses are added. Instead, define 'HAVE_LIBCURSES' ourselves by adding an 'action-if-found' argument to AC_SEARCH_LIBS, and use it in print_gdb_configuration. While at it, remove the condition on 'ac_cv_search_waddstr' and set 'curses_found' directly in 'action-if-found'. Change-Id: Id90e3d73990e169cee51bcc3e1d52072cfacd5b8 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-21[gdb/testsuite] Require compilation flags in two gdb.arch/aarch64 test-casesTom de Vries2-0/+4
With test-cases gdb.arch/aarch64-mte-core.exp and gdb.arch/aarch64-pauth.exp I run into compilation errors due to unsupported compilation flags. Fix this by requiring the compilation flags, such that I have instead: ... UNSUPPORTED: gdb.arch/aarch64-mte-core.exp: require failed: \ have_compile_flag -march=armv8.5-a+memtag UNSUPPORTED: gdb.arch/aarch64-pauth.exp: require failed: \ have_compile_flag -mbranch-protection=pac-ret+leaf ... Tested on aarch64-linux.
2023-02-21[gdb/testsuite] Require istarget x86* in ↵Tom de Vries1-0/+2
gdb.reverse/step-indirect-call-thunk.exp On aarch64-linux, I run into: ... Running gdb.reverse/step-indirect-call-thunk.exp ... gdb compile failed, gcc: error: unrecognized command line option \ '-mindirect-branch=thunk'; did you mean '-findirect-inlining'? gcc: error: unrecognized command line option '-mfunction-return=thunk'; \ did you mean '-Wfunction-elimination'? UNTESTED: gdb.reverse/step-indirect-call-thunk.exp: failed to prepare ... Fix this by requiring istarget "x86*", similar to what was added in gdb.base/step-indirect-call-thunk.exp by commit 43127ae5714 ("Fix gdb.base/step-indirect-call-thunk.exp"), such that we have instead: ... UNSUPPORTED: gdb.reverse/step-indirect-call-thunk.exp: require failed: \ istarget "x86* ... Tested on x86_64-linux and aarch64-linux.
2023-02-21[gdb/testsuite] Require -fsplit-stack in gdb.base/morestack.expTom de Vries2-0/+10
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.