Commit Graph

113746 Commits

Author SHA1 Message Date
Simon Marchi
13ee541070 gdb: make-target-delegates.py: add type annotations
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-27 13:28:32 -05:00
Simon Marchi
c6cf3ced97 gdb: make-target-delegates.py: add Entry type
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-27 13:28:32 -05:00
Simon Marchi
dcca01ace7 gdb: make-target-delegates.py: make one string raw
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-27 13:28:32 -05:00
Simon Marchi
116e3492f2 gdb: gdbarch*.py, copyright.py: add type annotations
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-27 13:28:32 -05:00
Simon Marchi
05e4e89373 gdb: split gdbarch component types to gdbarch_types.py
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-27 13:28:32 -05:00
Simon Marchi
9f353051de gdb: pyproject.toml: set pyright typeCheckingMode = "strict"
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-27 13:28:32 -05:00
Simon Marchi
fbbe9eb8b5 gdb: gdbarch.py: remove Info.__init__
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-27 13:28:32 -05:00
Simon Marchi
c4e1b10cc2 gdb: gdbarch.py: spell out parameters of _Component.__init__
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-27 13:28:32 -05:00
Simon Marchi
09de95fbb7 gdb: reformat Python files with black 23.1.0
Change-Id: Ie8ec8870a16d71c5858f5d08958309d23c318302
Reviewed-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-02-27 13:28:32 -05:00
Simon Marchi
aa992b382f gdb: remove invalid / dead code from gdbarch.py
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-27 13:28:32 -05:00
Tom Tromey
debd0556e5 Fix crash with "finish" in Rust
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-27 11:12:11 -07:00
Tom Tromey
810fbe39b2 Remove old GNU indent directives
Now that gdb_indent.sh has been removed, I think it makes sense to
also remove the directives intended for GNU indent.
2023-02-27 11:04:44 -07:00
Tom Tromey
935d48567d Handle range types in ax-gdb.c
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-27 08:09:02 -07:00
Tom Tromey
013a623f4c Implement some agent expressions for Ada
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-27 08:09:02 -07:00
Pedro Alves
d11280feed Regenerate Linux syscall group info
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-27 15:01:13 +00:00
Pedro Alves
08c815c2bf Autogenerate gdb/syscalls/linux-defaults.xml.in (groups) from strace sources
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:

  e88e5e9ae6/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-27 15:01:07 +00:00
Clément Chigot
1b30ccce02 gas/testsuite: adjust another test for case insensitive file systems
As 1fafeaac85, "line.s" and "Line.s" are
identical in case insensitive file systems. Thus, gas doesn't trigger
an input file switch.

gas/ChangeLog:

        * testsuite/gas/elf/dwarf-5-macro.s: Change Line.s to Line2.s.
2023-02-27 15:17:49 +01:00
Andrew Burgess
85c7cb3c4b gdb: don't treat empty enums as flag enums
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-27 14:14:24 +00:00
Benson Muite
8034b0baea Do not change the timestamp when updating the gas asconfig file.
PR 28909 * doc/local.mk (asconfig.texi): Use "cp -p" to preserve timestamps. * Makefile.in: Regenerate.
2023-02-27 13:35:49 +00:00
Felix Willgerodt
c38463074e Fix missing "Core was generated by" when loading a x32 corefile. 2023-02-27 13:01:06 +00:00
Nick Clifton
85b922fcdd Updated Serbian translations for gold, gprof and opcodes sub-directories 2023-02-27 12:50:31 +00:00
Bruno Larsen
a3da2e7e55 gdb/testsuite: Improve testing of GDB's completion functions
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-27 10:52:23 +01:00
Tankut Baris Aktemur
4e08903f67 gdb, python: do minor modernization in execute_gdb_command
Use nullptr instead of NULL and boolify two local variables in
execute_gdb_command.

Approved-By: Tom Tromey <tom@tromey.com>
2023-02-27 10:28:40 +01:00
GDB Administrator
4dd74c176b Automatic date update in version.in 2023-02-27 00:00:09 +00:00
Tom Tromey
6fd9b78373 Remove expand_symtab_containing_pc
The function expand_symtab_containing_pc is unused; remove it.
Tested by rebuilding.
2023-02-26 10:46:30 -07:00
GDB Administrator
ff3b2421c6 Automatic date update in version.in 2023-02-26 00:00:19 +00:00
Andrew Burgess
83750264d7 gdb/amd64: replace xmalloc/alloca with gdb::byte_vector
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-25 11:09:15 +00:00
Andrew Burgess
82341e9798 opcodes/m68k: enable libopcodes styling for GDB
The following commit added libopcodes styling for m68k:

  commit c22ff44927
  Date:   Tue Feb 14 18:07:19 2023 +0100

      opcodes: style m68k disassembler output

but didn't set disassemble_info::created_styled_output in
disassemble.c, which is needed in order for GDB to start using the
libopcodes based styling.

This commit fixes this small oversight.  GDB now styles correctly.
2023-02-25 10:20:01 +00:00
GDB Administrator
95ebc6fdec Automatic date update in version.in 2023-02-25 00:00:12 +00:00
Khem Raj
2e977d9901 gdbserver/linux-low.cc: Fix a typo in ternary operator
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-02-24 12:09:05 -07:00
Tom Tromey
147699fd69 Remove struct buffer
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-24 11:53:03 -07:00
Tom Tromey
1293ecd838 Don't use struct buffer in top.c
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-24 11:52:48 -07:00
Tom Tromey
356628ee2a Don't use struct buffer in event-top.c
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-24 11:52:48 -07:00
Tom Tromey
71a64d8ba8 Don't use struct buffer in handle_qxfer_threads
This changes handle_qxfer_threads, in gdbserver, to use std::string
rather than struct buffer.
2023-02-24 11:52:48 -07:00
Tom Tromey
873a185be2 Don't use struct buffer in handle_qxfer_btrace
This changes handle_qxfer_btrace and handle_qxfer_btrace_conf, in
gdbserver, to use std::string rather than struct buffer.
2023-02-24 11:52:48 -07:00
Tom Tromey
c9d9117a12 Don't use struct buffer in handle_qxfer_traceframe_info
This changes handle_qxfer_traceframe_info, in gdbserver, to use
std::string rather than struct buffer.
2023-02-24 11:52:48 -07:00
Tom Tromey
588d301354 Remove struct buffer from tracefile-tfile.c
This changes tracefile-tfile.c to use std::string rather than struct
buffer.
2023-02-24 11:52:48 -07:00
Tom Tromey
52e5e48e53 Write the DWARF index in the background
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-24 11:46:53 -07:00
Tom Tromey
542a33e348 Only use the per-BFD object to write a DWARF index
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-24 11:46:53 -07:00
Simon Marchi
71797f1221 gdb: fix parenthesis position in comment
Change-Id: I535b597ab4482378910570d8dd69c090419941eb
2023-02-24 12:31:39 -05:00
Clément Chigot
2b69325792 testsuite: prune DOS drive letter in test outputs
On DOS systems, absolute paths start with the drive letter. This can
trigger failures in the regexp from dump tests, especially for those
checking for warnings or errors. They are usually skipping everything
before the first ":" as it has to be the file path.
  | [^:]*: warning: ...

In order to avoid modifying many regexps to allow such drive letters,
prune them from all the outputs if they are found at the beginning of
a line.

binutils/ChangeLog:

	* testsuite/lib/binutils-common.exp (prune_dump_output): New
	(run_dump_test): Use it.

ld/ChangeLog:

	* testsuite/ld-elf/noinit-sections-2.l: Remove DOS drive letter
	handler.
2023-02-24 14:35:10 +01:00
Jan Beulich
ae9a0a51e8 x86: allow to request ModR/M encoding
Several insns have a (typically shorter) non-ModR/M and a (typically
longer) ModR/M encoding. In most cases the former is used by default.
This isn't too dissimilar from register-only insns sometimes having two
encoding forms. In those cases {load} or {store} can be used to control
the encoding used. Extend this to ModR/M-less encodings which have a
ModR/M counterpart (note that BSWAP hasn't). For insn reading and
writing their (explicit) memory operand, both prefixes are honored;
otherwise only the applicable one is.

Note that for some forms of XCHG, {store} has already been performing
this function, apparently as an unnoticed side effect of adding D to
the template.
2023-02-24 14:00:11 +01:00
Jan Beulich
cafa5ef72e x86: MONITOR/MWAIT are not SSE3 insns
These have their own CPUID bit and hence they should also have their own
separate control.
2023-02-24 13:59:35 +01:00
Jan Beulich
c3bb24f566 x86-64: don't permit LAHF/SAHF with "generic64"
The feature isn't universally available on 64-bit CPUs.

Note that in i386-gen.c:isa_dependencies[] I'm only adding it to models
where I'm certain the functionality exists. For Nocona and Core I'm
uncertain in particular.
2023-02-24 13:58:35 +01:00
Jan Beulich
5eeeafe0a6 x86: have insns acting on segment selector values allow for consistent operands
While MOV to/from segment register as well as selector storing insns
already permit 32- and 64-bit GPR operands, selector loading insns and
ARPL do not. Split templates accordingly.
2023-02-24 13:57:31 +01:00
Jan Beulich
c34d1cc920 x86: restrict insn templates accepting negative 8-bit immediates
For shifts (but not ordinary rotates) and other cases where an immediate
describes e.g. a bit count or position, allowing negative operands is at
best confusing. An extreme example would be the two rotate-through-carry
insns, where a negative value would _not_ mean rotating the
corresponding number of bits in the other direction. To refuse such,
give meaning to the combination of Imm8 and Imm8S in templates (so far
these weren't used together anywhere). The issue was with
smallest_imm_type() blindly setting .imm8 for signed numbers determined
to fit in a byte.

VPROT{B,W,D,Q} is a little special: The rotate count there is a signed
quantity, so Imm8 is replaced by Imm8S. Adjust affected testcases
accordingly as well.

Another small adjustment to the testsuite is necessary: AAM and AAD were
never sensible to use with 0xffffff90 operands. This should have been an
error.
2023-02-24 13:56:57 +01:00
Tom de Vries
f1c8928395 [gdb/testsuite] Cleanup unnecessary expr from require line
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-24 13:52:12 +01:00
Maciej W. Rozycki
0676ec3c22 GDB: Fix out of bounds accesses with limited-length values
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-24 12:37:22 +00:00
Nick Clifton
7b1792f543 Enhance better_fit() function to prefer function symbols over non-function symbols. 2023-02-24 12:25:50 +00:00
Alan Modra
18e7a6587e PR30155, ld segfault in _bfd_nearby_section
The segfault was a symptom of messing with the absolute section next
field, confusing bfd_section_removed_from_list in linker.c:fix_syms.
That's not all that was going wrong.  The INSERT list of output
sections was being inserted into itself, ie. lost from the main
list of linker statements.

	PR 30155
	* ldlang.c (process_insert_statements): Handle pathological
	case of the insert script being inserted before the first
	output section statement in the default script.
	(output_prev_sec_find): Don't test section owner here.
	(insert_os_after): Change parameter to a list union pointer.
	(lang_insert_orphan): Test section owner here and adjust
	insert_os_after call.
2023-02-24 18:20:49 +10:30