]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
7 months agogdb/progspace: make program_space::objfiles_list private
Simon Marchi [Tue, 3 Sep 2024 18:41:51 +0000 (14:41 -0400)] 
gdb/progspace: make program_space::objfiles_list private

This field is only accessed within the program_space class, make it
private.

Change-Id: I0b53d78d3d11adf0dfadfb3ecace33d2996dd87b

7 months agogdb/progspace: link objfiles using owning_intrusive_list
Simon Marchi [Thu, 11 Jul 2024 16:07:00 +0000 (12:07 -0400)] 
gdb/progspace: link objfiles using owning_intrusive_list

This simplifies things a little bit, removing some `find_if` when
inserting or removing objfiles, and the whole
unwrapping_objfile_iterator thing.

Change-Id: Idd1851d36c7834820c9c1639a6a252de643eafba

7 months agoFix using Page-Up in TUI source window close to the top
Hannes Domani [Mon, 11 Nov 2024 16:13:28 +0000 (17:13 +0100)] 
Fix using Page-Up in TUI source window close to the top

Currently, when you're already less than a page from the top in the TUI
source window, and you press Page-Up, nothing happens, while I would
expect that it then scrolls the source up to the first line.

It's happening because scrolling a full page up would result in a
negative starting line number, which is then checked if it's higher than
the (unsigned) number of available lines, and since this will always be
true, the original starting line number is restored.
Afterwards it would check if the line number is too low, but since the
negative value was already gone, it didn't do much.

Fixed by moving the low line number check before the maximum line number
check.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb/testsuite: fix typo 'unsupport' to 'unsupported'
Andrew Burgess [Mon, 11 Nov 2024 16:09:16 +0000 (16:09 +0000)] 
gdb/testsuite: fix typo 'unsupport' to 'unsupported'

I noticed that in commit:

  commit 5cabc8098e65ac22d4245232ad20b19fa4729802
  Date:   Wed Jul 31 15:55:57 2024 +0100

      gdb/python: implement Python find_exec_by_build_id hook

I managed to typo 'unsupported' as 'unsupport'.  If you run the test
on a target that doesn't support core file creation then you'll get a
TCL error.

Fixed in this commit.

7 months agogdb/testsuite: fix failure in gdb.base/info_sources.exp
Andrew Burgess [Mon, 11 Nov 2024 10:51:46 +0000 (10:51 +0000)] 
gdb/testsuite: fix failure in gdb.base/info_sources.exp

I ran into an unexpected failure in gdb.base/info_sources.exp.  The
test in question runs this command:

  (gdb) info sources -d -- -d

That is, list all the source files whose directory name matches the
regexp '-d'.  The expectation is that no source files will be listed.

Unfortunately, when I ran the test some source files are listed; the
directory I am running in contains the pattern '-d', and so the test
fails.

As we cannot control where the developer is building and testing GDB,
I propose that instead of just testing with '-d' we should search
through all the letters a-z and find one that isn't present in the
source file directory name.  I'm still including the leading '-'
character in the regexp.

So now, unless GDB is being built in a directory that contains '-a',
'-b', '-c', .... '-z', the test will find one letter which isn't
present, and use that for the test.

To avoid test names changing between runs in different directories
I've had to tweak the test name to something more generic, but there
should be no change in which parts of GDB are actually being tested.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/testsuite] Reduce quoting in gdb.base/annota1.exp
Tom de Vries [Mon, 11 Nov 2024 15:02:57 +0000 (16:02 +0100)] 
[gdb/testsuite] Reduce quoting in gdb.base/annota1.exp

Reduce quoting in gdb.base/annota1.exp, mostly using string_to_regexp.

Tested on arm-linux and x86_64-linux.

7 months ago[gdb/testsuite] Fix gdb.base/annota1.exp on arm-linux
Tom de Vries [Mon, 11 Nov 2024 15:02:57 +0000 (16:02 +0100)] 
[gdb/testsuite] Fix gdb.base/annota1.exp on arm-linux

On arm-linux, gdb.base/annota1.exp fails:
...
PASS: gdb.base/annota1.exp: breakpoint info
run^M
^M
^Z^Zpost-prompt^M
Starting program: /home/linux/gdb/build/gdb/testsuite/outputs/gdb.base/annota1/annota1 ^M
^M
^Z^Zbreakpoints-invalid^M
^M
^Z^Zframes-invalid^M
^M
^Z^Zstarting^M
^M
^Z^Zframes-invalid^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".^M
^M
^Z^Zbreakpoints-invalid^M
^M
^Z^Zbreakpoint 1^M
^M
Breakpoint 1, ^M
^Z^Zframe-begin 0 0x40054a^M
^M
^Z^Zframe-function-name^M
main^M
^Z^Zframe-args^M
 ()^M
^Z^Zframe-source-begin^M
 at ^M
^Z^Zframe-source-file^M
/home/linux/gdb/src/gdb/testsuite/gdb.base/annota1.c^M
^Z^Zframe-source-file-end^M
:^M
^Z^Zframe-source-line^M
15^M
^Z^Zframe-source-end^M
^M
^M
^Z^Zsource /home/linux/gdb/binutils-gdb.git/gdb/testsuite/gdb.base/annota1.c:15:103:beg:0x40054a^M
^M
^Z^Zframe-end^M
^M
^Z^Zstopped^M
^M
^Z^Zpre-prompt^M
(gdb) ^M
^Z^Zprompt^M
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
...
because the regexp doesn't match the first frames-invalid annotation.

Fix this by adding an optional frames-invalid annotation in the regexp.

Tested on arm-linux and x86_64-linux.

7 months ago[gdb/testsuite] Avoid intermittent failures on another debuginfod test
Tom de Vries [Mon, 11 Nov 2024 14:57:38 +0000 (15:57 +0100)] 
[gdb/testsuite] Avoid intermittent failures on another debuginfod test

With test-case gdb.debuginfod/solib-with-soname.exp on aarch64-linux, I ran
into:
...
(gdb) core-file solib-with-soname.core^M
Downloading 197.86 K file libfoo_1.so...^M
[New LWP 997314]^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
Core was generated by `solib-with-soname'.^M
Program terminated with signal SIGABRT, Aborted.^M
(gdb) FAIL: $exp: load core file, use debuginfod: load core file
...

The test-case doesn't expect the "197.86 K" part.

The same problem was fixed for another test-case in commit a723c56efb0
("gdb/testsuite: avoid intermittent failures on a debuginfod test").

Fix this in the same way: by updating the regexp.

Tested on aarch64-linux.

PR testsuite/32354
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32354

7 months agoUse an iterator range for 'using' directives
Tom Tromey [Wed, 23 Oct 2024 16:50:32 +0000 (10:50 -0600)] 
Use an iterator range for 'using' directives

This patch changes block::get_using to return an iterator range.  This
seemed cleaner to me than the current approach of returning a pointer
to the first using directive; all the callers actually use this to
iterate.

7 months agoEnsure that help text fits in 80 columns
Tom Tromey [Mon, 3 Jun 2024 15:40:47 +0000 (09:40 -0600)] 
Ensure that help text fits in 80 columns

This patch adds a new unit test that ensures that all help text wraps
at 80 columns.

7 months agoWrap help options when building help string
Tom Tromey [Mon, 3 Jun 2024 16:06:51 +0000 (10:06 -0600)] 
Wrap help options when building help string

When building a help string, it's possible that the resulting options
will go over 80 columns.  This patch changes this code to add line
wrapping where needed.

This can most be seen by looking "help bt" and in particular the
"-frame-info" help text.

7 months agoShorten internal problem help text
Tom Tromey [Mon, 10 Jun 2024 16:05:46 +0000 (10:05 -0600)] 
Shorten internal problem help text

The help text for various "internal problem" settings is longer than
80 columns.  This patch tightens this up a bit.  Note that these
commands are all "maint" commands so, IMO, it is sufficient if they
are clear to a gdb developer.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
7 months agoRemove the "title" from the remote packet help
Tom Tromey [Fri, 7 Jun 2024 19:20:36 +0000 (13:20 -0600)] 
Remove the "title" from the remote packet help

The help for remote packet controls includes the "title".  However
this is is just the parameter name, and not really useful to see
repeated in the help text.

Approved-By: Eli Zaretskii <eliz@gnu.org>
7 months agoClean up opaque-type-resolution help
Tom Tromey [Fri, 7 Jun 2024 18:52:20 +0000 (12:52 -0600)] 
Clean up opaque-type-resolution help

The opaque-type-resolution help says "if set before loading symbols",
but I don't think this is accurate.  As far as I know, this resolution
can be done at any time.

This patch cleans up the help, also shortening it to less than 80
characters.

Approved-By: Eli Zaretskii <eliz@gnu.org>
7 months agoWrap help strings at 80 columns
Tom Tromey [Mon, 3 Jun 2024 15:37:27 +0000 (09:37 -0600)] 
Wrap help strings at 80 columns

This patch ensures that all ordinary help strings are wrapped at 80
columns.  For the most part this consists of changing code like this
(note the embedded \n and the trailing backslash without a newline):

-Manage the space-separated list of debuginfod server URLs that GDB will query \
-when missing debuginfo, executables or source files.\nThe default value is \
-copied from the DEBUGINFOD_URLS environment variable."),

... to end each line with \n\, like:

+Manage the space-separated list of debuginfod server URLs that GDB will\n\
+query when missing debuginfo, executables or source files.\n\
+The default value is copied from the DEBUGINFOD_URLS environment variable."),

Approved-By: Eli Zaretskii <eliz@gnu.org>
7 months agoCall gdbpy_fix_doc_string_indentation for function help
Tom Tromey [Fri, 31 May 2024 16:13:17 +0000 (10:13 -0600)] 
Call gdbpy_fix_doc_string_indentation for function help

If you invoke "help function _caller_is", you'll see that the help
text is indented strangely.  The fix for this is to add a call to
gdbpy_fix_doc_string_indentation in the appropriate spot, as is
already done for Python commands and parameters.

7 months agoAdd setting to control frame language mismatch warning
Tom Tromey [Fri, 1 Nov 2024 16:08:34 +0000 (10:08 -0600)] 
Add setting to control frame language mismatch warning

A customer noted that there is no way to prevent the "current language
does not match this frame" warning.  This patch adds a new setting to
allow this warning to be suppressed.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
7 months agoRe-run isort
Tom Tromey [Mon, 11 Nov 2024 14:22:24 +0000 (07:22 -0700)] 
Re-run isort

pre-commit pointed out that one file needed a change to satisfy isort.
This patch is the result.

7 months agogdb: fix missing operator % on xmethod matcher output
Pedro Silva [Mon, 11 Nov 2024 08:07:07 +0000 (08:07 +0000)] 
gdb: fix missing operator % on xmethod matcher output

Fixed missing operator % on xmethod matcher registration output and, as
suggested on bug 32532, converted both uses of operator % to str.format.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32352
Change-Id: Ic471516292c2f1d6d1284aaeaea3ec14421decb8

7 months agold: Move note sections after .rodata section
H.J. Lu [Thu, 7 Nov 2024 04:39:19 +0000 (12:39 +0800)] 
ld: Move note sections after .rodata section

Move note sections after .rodata section so that note sections are
placed in the same PT_LOAD segment together with .rodata section,
instead of a separate PT_LOAD segment.

PR ld/32341
* scripttempl/misc-sections.sc: Move note sections to ...
* scripttempl/elf.sc: Here, after .rodata section.
* testsuite/ld-elf/pr32341.d: New file.
* testsuite/ld-elf/pr32341.s: Likewise.

Co-Authored-By: Nick Clifton <nickc@redhat.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agogdb/dwarf2/read.c: Handle empty CU name
Lancelot SIX [Tue, 5 Nov 2024 11:07:00 +0000 (11:07 +0000)] 
gdb/dwarf2/read.c: Handle empty CU name

I recently came across a case where a compiler would emit a CU with an
empty name.  In such case, the attribute object constructed by GDB will
return nullptr when as_string is called.  One place is not checking for
this possibility.  As a result, loading such binary results in a GDB
crash:

    $ gdb -q a.out
    Reading symbols from a.out...

    Fatal signal: Segmentation fault
    ----- Backtrace -----
    [...]
    0x742f4dd8afab __strcmp_avx2
            ../sysdeps/x86_64/multiarch/strcmp-avx2.S:283
    0x58593704a0bc prepare_one_comp_unit
            ../../gdb/dwarf2/read.c:21842
    0x585937053fd9 process_psymtab_comp_unit
            ../../gdb/dwarf2/read.c:4633
    0x585937053fd9 _ZN23cooked_index_debug_info11process_cusEmN9__gnu_cxx17__normal_iteratorIPSt10unique_ptrI18dwarf2_per_cu_data26dwarf2_per_cu_data_deleterESt6vectorIS5_SaIS5_EEEESA_
            ../../gdb/dwarf2/read.c:4943
    [...]
    ---------------------
    A fatal error internal to GDB has been detected, further
    debugging is not possible.  GDB will now terminate.

    This is a bug, please report it.  For instructions, see:
    <https://www.gnu.org/software/gdb/bugs/>.

    Segmentation fault (core dumped)

This seems to be a regression introduced by the following commit:

    commit 00105aa1c4d9933fe3cfe9bc1be0daefe9f8ca36
    Date:   Tue Sep 24 10:24:22 2024 +0200

        [gdb/symtab] Don't expand non-Ada CUs for info exceptions

This patch fixes this issue by checking if attr->as_string returns
nullptr.

Change-Id: I78fe7a090f0bd1045b8cb2f8d088a8d6cf57fe1c
Approved-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agold, LoongArch: print error about linking without -fPIC or -fPIE flag in more detail
Xin Wang [Fri, 1 Nov 2024 11:41:49 +0000 (19:41 +0800)] 
ld, LoongArch: print error about linking without -fPIC or -fPIE flag in more detail

7 months agoAutomatic date update in version.in
GDB Administrator [Mon, 11 Nov 2024 00:00:58 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agogdb/python: implement Python find_exec_by_build_id hook
Andrew Burgess [Wed, 31 Jul 2024 14:55:57 +0000 (15:55 +0100)] 
gdb/python: implement Python find_exec_by_build_id hook

Implement extension_language_ops::find_objfile_from_buildid within
GDB's Python API.  Doing this allows users to write Python extensions
that can help locate missing objfiles when GDB opens a core file.  A
handler might perform some project- or site-specific actions to find a
missing objfile.  Or might provide some project- or site-specific
advice to the user on how they can obtain the missing objfile.

The implementation is very similar to the approach taken in:

  commit 8f6c452b5a4e50fbb55ff1d13328b392ad1fd416
  Date:   Sun Oct 15 22:48:42 2023 +0100

      gdb: implement missing debug handler hook for Python

The following new commands are added as commands implemented in
Python, this is similar to how the Python missing debug and unwinder
commands are implemented:

  info missing-objfile-handlers
  enable missing-objfile-handler LOCUS HANDLER
  disable missing-objfile-handler LOCUS HANDLER

To make use of this extension hook a user will create missing objfile
handler objects, and registers these handlers with GDB.  When GDB
opens a core file and encounters a missing objfile each handler is
called in turn until one is able to help.  Here is a minimal handler
that does nothing useful:

  import gdb
  import gdb.missing_objfile

  class MyFirstHandler(gdb.missing_objfile.MissingObjfileHandler):
      def __init__(self):
          super().__init__("my_first_handler")

      def __call__(self, pspace, build_id, filename):
          # This handler does nothing useful.
          return None

  gdb.missing_objfile.register_handler(None, MyFirstHandler())

Returning None from the __call__ method tells GDB that this handler
was unable to find the missing objfile, and GDB should ask any other
registered handlers.

Possible return values from a handler:

  - None: This means the handler couldn't help.  GDB will call other
          registered handlers to see if they can help instead.

  - False: The handler has done all it can, but the objfile couldn't
            be found.  GDB will not call any other handlers, and will
    continue without the objfile.

  - True: The handler has installed the objfile into a location where
          GDB would normally expect to find it.  GDB should repeat its
  normal lookup process and the objfile should now be found.

  - A string: The handler can return a filename, which is the missing
              objfile.  GDB will load this file.

Handlers can be registered globally, or per program space.  GDB checks
the handlers for the current program space first, and then all of the
global handles.  The first handler that returns a value that is not
None, has "handled" the missing objfile, at which point GDB continues.

The implementation of this feature is mostly straight forward.  I have
reworked some of the missing debug file related code so that it can be
shared with this feature.  E.g. gdb/python/lib/gdb/missing_files.py is
mostly content moved from gdb/python/lib/gdb/missing_debug.py, but
updated to be more generic.  Now gdb/python/lib/gdb/missing_debug.py
and the new file gdb/python/lib/gdb/missing_objfile.py both call into
the missing_files.py file.

For gdb/python/lib/gdb/command/missing_files.py this is even more
extreme, gdb/python/lib/gdb/command/missing_debug.py is completely
gone now and gdb/python/lib/gdb/command/missing_files.py provides all
of the new commands in a generic way.

I have made one change to the existing Python API, I renamed the
attribute Progspace.missing_debug_handlers to
Progspace.missing_file_handlers.  I don't see this as too
problematic.  This attribute was only used to implement the missing
debug feature and was never documented beyond the fact that it
existed.  There was no reason for users to be touching this attribute.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
7 months agogdb: add extension hook ext_lang_find_objfile_from_buildid
Andrew Burgess [Wed, 31 Jul 2024 14:54:52 +0000 (15:54 +0100)] 
gdb: add extension hook ext_lang_find_objfile_from_buildid

Add a new ext_lang_find_objfile_from_buildid function which is called
from find_objfile_by_build_id and gives extension languages a chance
to find missing objfiles.

This commit adds the ext_lang_find_objfile_from_buildid function and
the extension_language_ops::find_objfile_from_buildid() hook, but does
not implement the hook for any extension languages, that will come in
the next commit.

This commit does rewrite find_objfile_by_build_id (build-id.c) to call
the new hook though.  The basic steps of find_objfile_by_build_id are
now this:

  1. Try to find the missing objfile using the build-id by looking in
  the debug-file-directory's .build-id/ sub-directory.  If we find the
  file then we're done.

  2. Ask debuginfod to download the missing file for us.  If we
  download the file successfully then we're done.

  3. Ask the extension language hook to find the file for us.  If the
  extension language asks us to try again then we repeat step (1) only
  and if we still don't have the file, we move to step (4).  If the
  extension language told us where the file is then we use that file
  and we're done.

  4. We didn't find the file.  Carry on without it.

Only step (3) is new in this logic, everything else was already done.

There are no tests added here as we can't currently write an extension
language callback.  The next commit will add the tests.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb: rename ext_lang_missing_debuginfo_result
Andrew Burgess [Wed, 31 Jul 2024 14:58:20 +0000 (15:58 +0100)] 
gdb: rename ext_lang_missing_debuginfo_result

In preparation for later commits in this series, rename
ext_lang_missing_debuginfo_result to ext_lang_missing_file_result.

A later commit will add additional Python APIs to handle different
types of missing files beyond just debuginfo.

This is just a rename commit, there should be no functional changes
after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb: use mapped file information to improve debuginfod text
Andrew Burgess [Wed, 31 Jul 2024 14:50:50 +0000 (15:50 +0100)] 
gdb: use mapped file information to improve debuginfod text

When opening a core-file GDB is able to use debuginfod to download the
executable that matches the core-file if GDB can find a build-id for
the executable in the core-file.

In this case GDB calls debuginfod_exec_query to download the
executable and GDB prints a message like:

  Downloading executable for /path/to/core-file...

which makes sense in that case.

For a long time GDB has also had the ability to download memory-mapped
files and shared libraries when opening a core-file.  However, recent
commits have made these cases more likely to trigger, which is a good
thing, but the messaging from GDB in these cases is not ideal.  When
downloading a memory-mapped file GDB prints:

  Downloading executable for /path/to/memory-mapped-file

And for a shared library:

  Downloading executable for /path/to/libfoo.so

These last two messages could, I think, be improved.

I propose making two changes.  First, I suggest instead of using
/path/to/core-file in the first case, we use the name of the
executable that GDB is fetching.  This makes the messaging consistent
in that we print the name of the file we're fetching rather than the
name of the file we're fetching something for.

I further propose that we replace 'executable for' with the more
generic word 'file'.  The messages will then become:

  Downloading file /path/to/exec-file...
  Downloading file /path/to/memory-mapped-file...
  Downloading file /path/to/libfoo.so...

I think these messages are clearer than what we used to have, and they
are consistent in that we name the thing being downloaded in all
cases.

There is one tiny problem.  The first case relies on GDB knowing the
name of the executable it wants to download.  The only place we can
currently get that from is, I think, the memory-mapped file list.

[ ASIDE: There is `bfd_core_file_failing_command` which reports the
  executable and argument list from the core file, but this
  information is not ideal for this task.  First, the executable and
  arguments are merged into a single string, and second, the string is
  a relatively short, fixed length string, so the executable name is
  often truncated.  For these reasons I don't consider fetching the
  executable name using this bfd function as a solution. ]

We do have to consider the case that the core file does not have any
mapped file information.  This shouldn't ever be the case for a Linux
target, but it's worth considering.

[ ASIDE: I mention Linux specifically because this only becomes a
  problem if we try to do a lookup via debuginfod, which requires that
  we have build-ids available.  Linux has special support for
  embedding build-ids into the core file, but I'm not sure if other
  kernels do this. ]

For the unlikely edge case of a core-file that has build-ids, but
doesn't have any mapped file information then I propose that we
synthesis a filename like: 'with build-id xxxxxx'.  We would then see
a message like:

  Downloading file with build-id xxxxxx...

Where 'xxxxxx' would be replaced by the actual build-id.

This isn't ideal, but I think is good enough, and, as I said, I think
this case is not going to be hit very often, or maybe at all.

We already had some tests that emitted two of the above messages,
which I've updated, these cover the mapped-file and shared library
case.

The message about downloading the exec for the core-file is actually
really hard to trigger now as usually the exec will also appear in the
memory-mapped file list and GDB will download the file at this stage.
Then when GDB needs the executable for loading the symbols it'll ask
debuginfod, and debuginfod will find the file in its cache, and so no
message will be printed.

If anyone has any ideas about how to trigger this case then I'm happy
to add additional tests.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Sun, 10 Nov 2024 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoAutomatic date update in version.in
GDB Administrator [Sat, 9 Nov 2024 00:01:04 +0000 (00:01 +0000)] 
Automatic date update in version.in

7 months agoAdd dw2-aranges.exp
Alexandra Hájková [Fri, 25 Oct 2024 08:30:32 +0000 (10:30 +0200)] 
Add dw2-aranges.exp

This test checks that GDB is able to load DWARF information when
.debug_aranges has a section address size that is set to 0.

This test was originally written by Jan Kratochvil to test commit
927aa2e778d from 2017, titled "DWARF-5: .debug_names index consumer".

This test was originally written using a static .S file and has
been present in the Fedora tree for a long time.

If dwarf2/aranges.c is modified to turn off the address_size check,
GDB will crash with SIGFPE when loading the executable with address
size set to zero.

I modified the DWARF assembler to make it possible to set the address
size to zero in a .debug_aranges section and used the DWARF assembler
to produce the assembly file.

Co-Authored-By: Jan Kratochvil <jan.kratochvil@redhat.com>
Approved-by: Kevin Buettner <kevinb@redhat.com>
7 months agogdbserver: remove pidof(process)
Simon Marchi [Wed, 6 Nov 2024 20:03:06 +0000 (15:03 -0500)] 
gdbserver: remove pidof(process)

This function doesn't seem so useful, use `process_info::pid` directly
instead.

Change-Id: I55d592f38b32a197957ed4c569993cd23a818cb4
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: remove pid_of(thread)
Simon Marchi [Wed, 6 Nov 2024 20:02:11 +0000 (15:02 -0500)] 
gdbserver: remove pid_of(thread)

This function doesn't seem so useful, use `thread_info::id::pid`
directly instead.

Change-Id: I7450c4223e5b0bf66788eeb5b070ab6f5287f798
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: remove lwpid_of(thread)
Simon Marchi [Wed, 6 Nov 2024 20:00:44 +0000 (15:00 -0500)] 
gdbserver: remove lwpid_of(thread)

This function doesn't seem so useful.  Use `thread_info::id::lwp`
directly.

Change-Id: Ib4a86eeeee6c1342bc1c092f083589ce28009be1
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: remove ptid_of(thread)
Simon Marchi [Wed, 6 Nov 2024 19:54:52 +0000 (14:54 -0500)] 
gdbserver: remove ptid_of(thread)

This function doesn't seem so useful.  Use `thread_info::id` directly.

Change-Id: I158cd06a752badd30f68424e329aa42d275e43b7
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: remove current_thread_ptid
Simon Marchi [Wed, 6 Nov 2024 19:50:30 +0000 (14:50 -0500)] 
gdbserver: remove current_thread_ptid

This function doesn't seem so useful.  Use `thread_info::id` directly.

Change-Id: I4ae4e7baa44e09704631a1c3a5a66e5b8b5a3594
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: remove current_ptid macro
Simon Marchi [Wed, 6 Nov 2024 19:47:41 +0000 (14:47 -0500)] 
gdbserver: remove current_ptid macro

I think it just makes things more obscure.  Use `thread_info::id`
directly instead.

Change-Id: I141d5fb08ebf45c13cc32c4bba62773249fcb356
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: remove get_thread_process
Simon Marchi [Thu, 7 Nov 2024 16:22:20 +0000 (16:22 +0000)] 
gdbserver: remove get_thread_process

Remove the `get_thread_process` function, use `thread_info::process`
instead.

In `server.cc`, use `current_process ()` instead of going through the
current thread.

Change-Id: Ifc61d65852e392d154b854a45d45df584ab3922e
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: make remove_thread a method of process_info
Simon Marchi [Thu, 7 Nov 2024 16:15:43 +0000 (16:15 +0000)] 
gdbserver: make remove_thread a method of process_info

Same idea as the previous patch, but for `remove_thread`.

Change-Id: I7e227655be5fcf29a3256e8389eb32051f27882d
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: make add_thread a method of process_info
Simon Marchi [Thu, 7 Nov 2024 16:17:56 +0000 (16:17 +0000)] 
gdbserver: make add_thread a method of process_info

Since thread_info objects are now basically children of process_info
objects, I think that makes sense.

Change-Id: I7f0a67b921b468e512851cb2f36015d1003412d7
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: add thread -> process backlink
Simon Marchi [Thu, 7 Nov 2024 16:16:59 +0000 (16:16 +0000)] 
gdbserver: add thread -> process backlink

In a few spots, we need to get to a process from a thread.  Having a
backlink from thread to process is cheap and makes the operation
trivial, add it.

Change-Id: I8a94b2919494b1dcaf954de2246386794308aa82
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdbserver: remove for_each_thread(pid, func)
Simon Marchi [Wed, 6 Nov 2024 18:39:48 +0000 (13:39 -0500)] 
gdbserver: remove for_each_thread(pid, func)

Remove this overload, prefer to use `process_info::for_each_thread`.  In
many instances, the `process_info` is already available, so this saves a
map lookup.  In other instances, add the `process_info` lookup at the
call site.

In `linux-arm-low.cc` and `win32-i386-low.cc`, use `current_process ()`
instead of `current_thread->id.pid ()`.  I presume that if
`current_process ()` and `current_thread` don't match, it's a bug
orthogonal to this change.

Change-Id: I751ed497cb1f313cf937b35125151bee9316fc51
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
7 months agogdb: LoongArch: Remove use of gdbarch_remove_non_address_bits hook
Schimpe, Christina [Tue, 5 Nov 2024 15:22:47 +0000 (15:22 +0000)] 
gdb: LoongArch: Remove use of gdbarch_remove_non_address_bits hook

LoongArch doesn't implement the hook gdbarch_remove_non_address_bits, so
there is no need to use the hook in gdb/loongarch-linux-nat.c.

Approved-By: Luis Machado <luis.machado@arm.com>
7 months agogdb: make the error message for unreadable objfiles more informative
Guinevere Larsen [Thu, 7 Nov 2024 19:15:20 +0000 (16:15 -0300)] 
gdb: make the error message for unreadable objfiles more informative

When GDB is unable to read an objfile, it prints the error message "I'm
sorry Dave, I can't do that. Symbol format `%s' unknown.". While it is a
great reference, an end user won't have much information about the
problem.

So far this wasn't much of a problem, as it is very uncommon for GDB to
be unable to read an objfile. However, a future patch will allow users
to selectively disable support to some formats, making it somewhat
expected that the message will be seen by end users.

This commit makes the end message more informative and direct.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13299
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoaarch64: add flag OPD_F_UNSIGNED to distinguish signedness of immediate operands
Matthieu Longo [Fri, 7 Jun 2024 15:59:58 +0000 (16:59 +0100)] 
aarch64: add flag OPD_F_UNSIGNED to distinguish signedness of immediate operands

This patch introduces a new operand flag OPD_F_UNSIGNED to signal that
the immediate value should be treated as an unsigned value. The default
signedness of immediate operands is signed.

7 months agoaarch64: testsuite: remove hard-coded instruction addresses
Matthieu Longo [Fri, 7 Jun 2024 15:59:57 +0000 (16:59 +0100)] 
aarch64: testsuite: remove hard-coded instruction addresses

7 months agoaarch64: remove redundant register type R_N
Matthieu Longo [Fri, 7 Jun 2024 15:59:57 +0000 (16:59 +0100)] 
aarch64: remove redundant register type R_N

The register type R_N is redundant with R_ZR_SP. This patch removes it,
and replaces its usage by R_ZR_SP.

7 months agoaarch64: improve debuggability on array of enum
Matthieu Longo [Fri, 7 Jun 2024 15:59:57 +0000 (16:59 +0100)] 
aarch64: improve debuggability on array of enum

The current space optmization on enum aarch64_opn_qualifier forced its
encoding using an unsigned char. This "hard-coded" optimization has the
bad consequence of making the array of such enums being completely
unreadable when debugging with GDB because the enum type is lost along
the way.
Keeping this space optimization, and the enum type as well, is possible
when the declaration of the enum is tagged with attribute((packed)).
attribute((packed)) is a GNU extension, and is wrapped in the macro
ATTRIBUTE_PACKED (defined in ansidecl.h), and should be used instead.

7 months agoaarch64: change returned type to bool to match semantic of functions
Matthieu Longo [Fri, 7 Jun 2024 15:59:57 +0000 (16:59 +0100)] 
aarch64: change returned type to bool to match semantic of functions

7 months agoaarch64: constify unchanged char* arguments
Matthieu Longo [Fri, 7 Jun 2024 15:59:57 +0000 (16:59 +0100)] 
aarch64: constify unchanged char* arguments

7 months agoaarch64: make comment clearer about the location
Matthieu Longo [Fri, 7 Jun 2024 15:59:57 +0000 (16:59 +0100)] 
aarch64: make comment clearer about the location

The enum aarch64_opnd_qualifiers in include/opcode/aarch64.h needs to
stay in sync with the array of struct operand_qualifier_data which
defines various properties for the different type of operands. For
instance, for:
- registers: the size of the register, the number of elements.
- immediates: lower and upper bits to determine the range of values.

7 months agogdb/testsuite: fix gdb.base/basic-edit-cmd.exp test
Andrew Burgess [Fri, 8 Nov 2024 11:19:33 +0000 (11:19 +0000)] 
gdb/testsuite: fix gdb.base/basic-edit-cmd.exp test

In the recent commit:

  commit 31ada87f91b4c5306d81c8a896df9764c32941f3
  Date:   Wed Nov 6 22:18:55 2024 +0000

      gdb: fixes and tests for the 'edit' command

the new gdb.base/basic-edit-cmd.exp was added.  The Linaro CI
highlighted an issue with the test which I failed to address before
pushing the above commit.

Part of the test loads a file into GDB and then uses the 'edit'
command with no arguments to edit the default location.  This default
location is expected to be the 'main' function.

On my local machine the line reported is the opening '{' of main, and
that is what the test checks for.

The Linaro CI though appears to see the first code line of main.

I think either result is fine as far as this test is concerned, so
I've expanded the test regexp to check for either line number.  This
should make the CI testing happy again.

7 months agogdb: fixes and tests for the 'edit' command
Andrew Burgess [Wed, 6 Nov 2024 22:18:55 +0000 (22:18 +0000)] 
gdb: fixes and tests for the 'edit' command

This commit was inspired by this mailing list post:

  https://inbox.sourceware.org/gdb-patches/osmtfvf5xe3yx4n7oirukidym4cik7lehhy4re5mxpset2qgwt@6qlboxhqiwgm

When reviewing that patch, the first thing I wanted to do was add some
tests for the 'edit' command because, as far as I can tell, there are
no real tests right now.

The approach I've taken for testing is to override the EDITOR
environment variable, setting this to just 'echo'.  Now when the
'edit' command is run, instead of entering an interactive editor, the
shell instead echos back the arguments that GDB is trying to pass to
the editor.  The output might look like this:

  (gdb) edit
  +22 /tmp/gdb/testsuite/gdb.base/edit-cmd.c
  (gdb)

We can then test this like any other normal command.  I then wrote
some basic tests covering a few situations like, using 'edit' before
the inferior is started.  Using 'edit' without any arguments, and
using 'edit' with a line number argument.

There are plenty of cases that are still not tested, for example, the
test program only has a single source file for example.  But we can
always add more tests later.

I then used these tests to validate the fix proposed in the above
patch.

The patch above does indeed fix some cases, specifically, when GDB
stops at a location (e.g. a breakpoint location) and then the 'edit'
command without any arguments is fixed.  But using the 'list' command
to show some other location, and then 'edit' to edit the just listed
location broken before and after the above patch.

I am instead proposing this alternative patch which I think fixes more
cases.  When GDB stops at a location then 'edit' with no arguments
should correctly edit the current line.  And using 'list XX' to list a
specific location, followed by 'edit' should also now edit the just
listed location.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17669

Co-Authored-By: Lluís Batlle i Rossell <viric@viric.name>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agobfd: Remove unused static find function from doc/chew.c
Mark Wielaard [Thu, 7 Nov 2024 17:40:03 +0000 (18:40 +0100)] 
bfd: Remove unused static find function from doc/chew.c

After commit 2e60790cf7c27d79f90f2dcb81e1930dc980bc1c "Remove the
paramstuff word" there is no caller left of the static find function
in doc/chew.c, so it should be removed.

* doc/chew.c (find): Remove.

7 months agoarm, objdump: print obsolote warning when 26-bit set in instructions
Andre Vieira [Fri, 8 Nov 2024 10:06:26 +0000 (10:06 +0000)] 
arm, objdump: print obsolote warning when 26-bit set in instructions

Arm has obsoleted the 26-bit addressing mode. Diagnose this when disasembling
these instructions by printing OBSOLETE.

7 months agoarm, objdump: Make objdump use bfd's machine detection to drive disassembly
Andre Vieira [Fri, 8 Nov 2024 10:06:26 +0000 (10:06 +0000)] 
arm, objdump: Make objdump use bfd's machine detection to drive disassembly

For any arm elf target, disable an old piece of code that forced disassembly to
disassemble for 'unknown architecture' which once upon a time meant it would
disassemble ANY arm instruction.  This is no longer true with the addition of
Armv8.1-M Mainline, as there are conflicting encodings for different thumb
instructions.

BFD however can detect what architecture the object file was assembled for
using information in the notes section.  So if available, we use that,
otherwise we default to the old 'unknown' behaviour.

With the changes above code, a mode changing 'bx lr' assembled for armv4 with
the option --fix-v4bx will result in an object file that is recognized by bfd
as one for the armv4 architecture.  The disassembler now disassembles this
encoding as a BX even for Armv4 architectures, but warns the user when
disassembling for Armv4 that this instruction is only valid from Armv4T
onwards.

Remove the unused and wrongfully defined ARM_ARCH_V8A_CRC, and
define and use a ARM_ARCH_V8R_CRC to make sure instructions enabled by
-march=armv8-r+crc are disassembled correctly.

Patch up some of the tests cases, see a brief explanation for each below.

inst.d:
This test checks the assembly & disassembly of basic instructions in armv3m. I
changed the expected behaviour for teqp, cmnp cmpp and testp instructions to
properly print p when disassembling, whereas before, in the 'unknown' case it
would disassemble these as UNPREDICTABLE as they were changed in later
architectures.

nops.d:
Was missing an -march, added one to make sure we were testing the right
behavior of NOP<c> instructions.

unpredictable.d:
Was missing an -march, added armv6 as that reproduced the behaviour being
tested.

7 months ago[gdb/tdep] Use raw_supply_zeroed in i387_supply_xsave
Tom de Vries [Fri, 8 Nov 2024 09:00:14 +0000 (10:00 +0100)] 
[gdb/tdep] Use raw_supply_zeroed in i387_supply_xsave

Use reg_buffer::raw_supply_zeroed in i387_supply_xsave.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/tdep] Use raw_supply_zeroed for NIOS r0 reg
Tom de Vries [Fri, 8 Nov 2024 09:00:14 +0000 (10:00 +0100)] 
[gdb/tdep] Use raw_supply_zeroed for NIOS r0 reg

Use reg_buffer::raw_supply_zeroed for NIOS register r0.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/tdep] Use raw_supply_zeroed for Alpha r31 reg
Tom de Vries [Fri, 8 Nov 2024 09:00:14 +0000 (10:00 +0100)] 
[gdb/tdep] Use raw_supply_zeroed for Alpha r31 reg

Use reg_buffer::raw_supply_zeroed for Alpha register r31.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/tdep] Use raw_supply_zeroed for PA-RISC r0 reg
Tom de Vries [Fri, 8 Nov 2024 09:00:14 +0000 (10:00 +0100)] 
[gdb/tdep] Use raw_supply_zeroed for PA-RISC r0 reg

Use reg_buffer::raw_supply_zeroed for PA-RISC register r0.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/tdep] Use raw_supply_zeroed for IA-64 gr0 and fr0 regs
Tom de Vries [Fri, 8 Nov 2024 09:00:13 +0000 (10:00 +0100)] 
[gdb/tdep] Use raw_supply_zeroed for IA-64 gr0 and fr0 regs

Use reg_buffer::raw_supply_zeroed for IA-64 registers gr0 and fr0.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Fri, 8 Nov 2024 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoarm: Skip two failing tests for wince & pe targets
Andre Simoes Dias Vieira [Thu, 7 Nov 2024 15:50:49 +0000 (15:50 +0000)] 
arm: Skip two failing tests for wince & pe targets

We don't seem to support any m-profile assembly/disassembly tests for wince or
pe, so skipping the pacbti one too.

The pr29494 test needs to be skipped because it uses assembly syntax that is
not supported in wince/pe like for instance eabi_attribute directives.

7 months agoDeprecate the ARM simulator.
Nick Clifton [Thu, 7 Nov 2024 14:53:26 +0000 (14:53 +0000)] 
Deprecate the ARM simulator.

    The ARM simulator is no longer able to simulator modern ARM cores, so it
    is being deprecated.  Once this change has been active for a while - and
    assuming that no problems have been found - the ARm simulator codebase
    will be removed.

7 months agogdbserver: add process specific thread list and map
Stephan Rohr [Tue, 22 Oct 2024 14:01:19 +0000 (07:01 -0700)] 
gdbserver: add process specific thread list and map

Replace the servers global thread list with a process specific thread
list and a ptid -> thread map similar to 'inferior::ptid_thread_map' on
GDB side.  Optimize the 'find_thread' and 'find_thread_ptid' functions
to use std::unordered_map::find for faster lookup of threads without
iterating over all processes and threads, if applicable.  This becomes
important when debugging applications with a large thread count, e.g.,
in the context of GPU debugging.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
7 months agogdbserver: change 'all_processes' and 'all_threads' list type
Stephan Rohr [Wed, 16 Oct 2024 09:34:52 +0000 (02:34 -0700)] 
gdbserver: change 'all_processes' and 'all_threads' list type

This patch replaces the 'std::list' type of 'all_processes' and
'all_threads' with the more lightweight 'owning_intrusive_list'
type.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Thu, 7 Nov 2024 00:00:53 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoPowerPC: Merge rfc2655 and rfc2656 test cases into one future test case
Peter Bergner [Wed, 6 Nov 2024 19:37:10 +0000 (13:37 -0600)] 
PowerPC: Merge rfc2655 and rfc2656 test cases into one future test case

gas/
* testsuite/gas/ppc/rfc02655.[ds]: Rename from this...
* testsuite/gas/ppc/future.[ds]: ... to this.
* testsuite/gas/ppc/rfc02656.[ds]: Delete.  Move tests to future.[ds].
* testsuite/gas/ppc/ppc.exp: Update for file name changes.

7 months ago[gdb/tdep] Use raw_supply_zeroed for SPARC g0 reg
Tom de Vries [Wed, 6 Nov 2024 15:42:58 +0000 (16:42 +0100)] 
[gdb/tdep] Use raw_supply_zeroed for SPARC g0 reg

Use reg_buffer::raw_supply_zeroed for SPARC register g0.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb: remove exact_match parameter from find_line_symtab
Klaus Gerlicher [Thu, 10 Oct 2024 08:23:11 +0000 (08:23 +0000)] 
gdb: remove exact_match parameter from find_line_symtab

struct symtab *find_line_symtab (struct symtab *, int, int *, bool *);

The last parameter is bool* that when set will receive information
if the match was exact. This parameter is never used by any callsite
and can therefore be removed.

This will become:

symtab *find_line_symtab (symtab *sym_tab, int line, int *index);

Approved-By: Tom Tromey <tom@tromey.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Wed, 6 Nov 2024 00:00:43 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoAutomatic date update in version.in
GDB Administrator [Tue, 5 Nov 2024 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoTurn decode_line_2_compare_items into operator<
Tom Tromey [Mon, 4 Nov 2024 17:08:41 +0000 (10:08 -0700)] 
Turn decode_line_2_compare_items into operator<

This rewrites decode_line_2_compare_items to be an operator< on the
relevant type.  This simplifies the code a little.

Reviewed-by: Keith Seitz <keiths@redhat.com>
7 months agogdb: cleanup includes in *-typeprint.[ch]
Simon Marchi [Mon, 4 Nov 2024 17:48:55 +0000 (17:48 +0000)] 
gdb: cleanup includes in *-typeprint.[ch]

Remove includes reported as unused by clangd.

Include "gdb-hashtab.h" in typeprint.h for the use of "htab_up".

Change-Id: I5b04ec14e71800e2d6ad622838e39b7033e168cf

7 months agogdb: cleanup includes in gdbtypes.h
Simon Marchi [Mon, 4 Nov 2024 17:46:01 +0000 (17:46 +0000)] 
gdb: cleanup includes in gdbtypes.h

Remove some includes reported as unused by clangd.

Change-Id: Ifc74f782d5aaafd1d719816821860352090c6667

7 months agoRemove gdb::hash_enum
Tom Tromey [Fri, 1 Nov 2024 19:07:16 +0000 (13:07 -0600)] 
Remove gdb::hash_enum

gdb::hash_enum is a workaround for a small oversight in C++11:
std::hash was not defined for enumeration types.  This was rectified
in C++14 and so we can remove the local workaround.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
7 months agogdb: use option framework for add-inferior and clone-inferior
Andrew Burgess [Mon, 30 Sep 2024 15:01:26 +0000 (16:01 +0100)] 
gdb: use option framework for add-inferior and clone-inferior

Convert the add-inferior and clone-inferior commands to make use of
the option framework.  This improves the tab completion for these
commands.

Previously the add-inferior command used a trick to simulate
completion of -exec argument.  The command use filename completion for
everything on the command line, thus you could do:

  (gdb) add-inferior /path/to/some/fil<TAB>

and GDB would complete the file name, even though add-inferior doesn't
really take a filename as an argument.  This helped a little though
because, if the user did this:

  (gdb) add-inferior -exec /path/to/some/fil<TAB>

then the file name would be completed.  However, GDB didn't really
understand the options, so couldn't offer completion of the options
themselves.

After this commit, the add-inferior command makes use of the recently
added gdb::option::filename_option_def feature.  This means that the
user now has full completion of the option names, and that file names
will still complete for the '-exec' option, but will no longer
complete if the '-exec' option is not used.

I have also converted the clone-inferior command, though this command
does not use any file name options.  This command does now have proper
completion of the command options.

7 months agogdb: add filename option support
Andrew Burgess [Wed, 11 Sep 2024 14:25:32 +0000 (15:25 +0100)] 
gdb: add filename option support

This commit adds support for filename options to GDB's option
sub-system (see cli/cli-option.{c,h}).

The new filename options support quoted and escaped filenames, and tab
completion is fully supported.

This commit adds the new option, and adds these options to the
'maintenance test-options' command as '-filename', along with some
tests that exercise this new option.

I've split the -filename testing into two.  In gdb.base/options.exp we
use the -filename option with some arbitrary strings.  This tests that
GDB can correctly extract the value from a filename option, and that
GDB can complete other options after a filename option.  However,
these tests don't actually pass real filenames, nor do they test
filename completion.

In gdb.base/filename-completion.exp I have added some tests that test
the -filename option with real filenames, and exercise filename tab
completion.

This commit doesn't include any real uses of the new filename options,
that will come in the next commit.

7 months agogdb/testsuite: spring clean the gdb.stabs/gdb11479.exp test
Andrew Burgess [Tue, 29 Oct 2024 14:59:23 +0000 (14:59 +0000)] 
gdb/testsuite: spring clean the gdb.stabs/gdb11479.exp test

I had reason to look at the gdb.stabs/gdb11479.exp test script and
figured it could do with a small clean up.  I've:

  - Made use of standard_testfile and the variables it defines.

  - Made use of with_test_prefix and removed the prefix from the end
    of each test name.

  - Avoid overwriting the test binary when we recompile, instead use a
    different name for each recompilation.

  - Add '.' at the end of each comment.

There should be no changes in what is tested with this commit.

Reviewed-By: Keith Seitz <keiths@redhat.com>
7 months agoFix AIX core dump while main thread exits.
Aditya Vidyadhar Kamath [Mon, 4 Nov 2024 08:42:05 +0000 (02:42 -0600)] 
Fix AIX core dump while main thread exits.

Consider the test case:
void *thread_main(void *) {
  std::cout << getpid() << std::endl;
  sleep(20);
  return nullptr;
}

int main(void) {
  pthread_t thread;
  pthread_create(&thread, nullptr, thread_main, nullptr);
  pthread_join(thread, nullptr);

  return 0;
}

This program creates a thread via main that sleeps for 20 seconds.

When we debug this with gdb we get,
Reading symbols from ./test...
(gdb) b main
Breakpoint 1 at 0x10000934: file test.c, line 11.
(gdb) r
Starting program: /read_only_gdb/binutils-gdb/gdb/test

Breakpoint 1, main () at test.c:11
11   pthread_create(&thread, nullptr, thread_main, nullptr);
(gdb) c
Continuing.
15335884
[New Thread 258 (tid 31130079)]
Thread 2 received signal SIGINT, Interrupt.
[Switching to Thread 258 (tid 31130079)]
0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) thread 1
[Switching to thread 1 (Thread 1 (tid 25493845))]
(gdb) c
Continuing.
[Thread 1 (tid 25493845) exited]
[Thread 258 (tid 31130079) exited]
inferior.c:405: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----

There are two bugs here. One is the core dump. The other is the main thread information
not captured.

So, while I was debugging the first part the reason, the reason I figured out was
the last for loop in sync_threadlists ().

Once both my threads exit we delete them as below:

for (struct thread_info *it : all_threads ())
      {
if (in_queue_threads.count (priv->pdtid) == 0
        && in_thread_list (proc_target, it->ptid)
        && pid == it->ptid.pid ())
      {
        delete_thread (it);
        data->exited_threads.insert (priv->pdtid);

But once these two threads are deleted, all_threads ()
has one more thread whose tid and pid are 0.

gdb) c
Continuing.
In for loop 8782296 is pid, 19857879 is tid
[Thread 1 (tid 19857879) exited]
In for loop 8782296 is pid, 30933401 is tid
[Thread 258 (tid 30933401) exited]
In for loop 0 is pid, 0 is tid
[Inferior 1 (process 8782296) exited normally]
(gdb) q

I used a printf in the for loop mentioned above for explaination.

You see the loop enters the third time with 0 as pid.

The reason being though the threads are removed but not deleted since they are
not deletable ().

Hence we use all_threads_safe () iterator instead.

The second part to the bug is the lack of information of the main thread.
Andrew was right here (https://sourceware.org/pipermail/gdb-patches/2024-September/211875.html)
Thank you Andrew.

The thread has loaded but then ptrace () call when we tried to fetch_regs_kernel_thread
failed. This returned EPERM as errno.

if (!ptrace32 (PTT_READ_GPRS, tid, (uintptr_t) gprs32, 0, NULL))
        memset (gprs32, 0, sizeof (gprs32));

Hence all registers were set to 0 and we did not get the required infromation.
This issue will be fixed within the AIX ptrace call.

Approved By: Ulrich Weigand <ulrich.weigand@de.ibm.com>.

7 months agoAutomatic date update in version.in
GDB Administrator [Mon, 4 Nov 2024 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoAutomatic date update in version.in
GDB Administrator [Sun, 3 Nov 2024 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoAutomatic date update in version.in
GDB Administrator [Sat, 2 Nov 2024 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agogprofng: use gprofng- prefix for gprofng binaries
Vladimir Mezentsev [Thu, 31 Oct 2024 04:18:39 +0000 (21:18 -0700)] 
gprofng: use gprofng- prefix for gprofng binaries

gprofng application names have a gp- prefix (gp-display-text, gp-archive, etc.).
But our man pages use the gprofng- prefix (gprofng-display-text,
gprofng-archive, etc.).
I renamed the gprofng binaries and temporarily created the gp-* links for
compatibility with the old gprofng-gui.
We plan to remove these links in version 2.46.

gprofng/ChangeLog
2024-10-31  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* doc/gprofng-archive.texi: Rename gprofng application names.
* doc/gprofng-collect-app.texi: Likewise.
* doc/gprofng-display-html.texi: Likewise.
* doc/gprofng-display-src.texi: Likewise.
* doc/gprofng-display-text.texi: Likewise.
* doc/gprofng.texi: Likewise.
* doc/gprofng_ug.texi: Likewise.
* gp-display-html/Makefile.am: Likewise.
* gp-display-html/gp-display-html.in: Likewise.
* libcollector/collector.c: Likewise.
* src/Application.cc: Likewise.
* src/Experiment.cc: Likewise.
* src/Makefile.am: Likewise.
* src/gp-archive.cc: Likewise.
* src/gp-collect-app.cc: Likewise.
* src/gp-display-src.cc: Likewise.
* src/gp-display-text.cc: Likewise.
* src/gprofng.cc: Likewise.
* src/Makefile.in: Rebuild.
* gp-display-html/Makefile.in: Rebuild.

7 months agoFix 32303 ./configure --help: replace --enable-gprofng with --disable-gprofng
Vladimir Mezentsev [Fri, 1 Nov 2024 00:23:26 +0000 (17:23 -0700)] 
Fix 32303 ./configure --help: replace --enable-gprofng with --disable-gprofng

ChangeLog
2024-10-31  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR 32303
* configure.ac: Replace --enable-gprofng with --disable-gprofng
* configure: Rebuild.

7 months agold: generate SFrame stack trace info for .plt.got
Indu Bhagat [Fri, 1 Nov 2024 22:36:35 +0000 (15:36 -0700)] 
ld: generate SFrame stack trace info for .plt.got

PR/32298 sframe: no SFrame stack trace info generated for .plt.got

Add support to generate SFrame stack trace info for .plt.got section.
Enhance the current definition of struct elf_x86_sframe_plt to include
initialized SFrame FDE/FREs applicable for .plt.got section.  There are
two variants of .plt.got entries: 16 byte and 8 byte.

8 byte:
    ff 25 00 00 00 00     jmpq  *name@GOTPCREL(%rip)
    66 90                 xchg  %ax,%ax

16 byte:
    f3 0f 1e fa           endbr64
    ff 25 66 2f 00 00     jmpq  *name@GOTPCREL(%rip)
    66 0f 1f 44 00 00     nopw   0x0(%rax,%rax,1)

For the testcase, define some application symbols such that their PLT
entry is placed in .plt.got and ensure SFrame information is generated
with and without -z ibtplt.

ChangeLog:
PR/32298
* bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
PLT GOT entry size is different for IBT vs non IBT PLTs.
* bfd/elfxx-x86.c (enum dynobj_sframe_plt_type): New enum for
SFRAME_PLT_GOT.
(_bfd_x86_elf_create_sframe_plt): Handle SFRAME_PLT_GOT.
(_bfd_x86_elf_write_sframe_plt): Likewise.
(_bfd_x86_elf_late_size_sections): Likewise.
(_bfd_x86_elf_finish_dynamic_sections): Likewise.
* bfd/elfxx-x86.h (struct elf_x86_sframe_plt): Add new members
to keep information about PLT GOT entries.
(struct elf_x86_link_hash_table): Add support for creating
SFrame section for .plt.got.
* ld/testsuite/ld-x86-64/x86-64.exp: Add new tests.
* ld/testsuite/ld-x86-64/sframe-pltgot-1.d: New test.
* ld/testsuite/ld-x86-64/sframe-pltgot-1.s: New test.
* ld/testsuite/ld-x86-64/sframe-pltgot-2.d: New test.

7 months agold: fix wrong SFrame info for lazy IBT PLT
Josh Poimboeuf [Fri, 1 Nov 2024 22:36:03 +0000 (15:36 -0700)] 
ld: fix wrong SFrame info for lazy IBT PLT

Fix PR/32296 sframe: wrong SFrame info for pltN and .plt.sec for -z ibtplt

The x86 psABI defines a 2-PLT scheme for IBT which uses .plt and
.plt.sec entries.  It was observed that SFrame information for .plt.sec
section was incorrect.  The erroneous assumption was that SFrame stack
trace information for .plt.sec with lazy binding is the same as SFrame
stack trace information for .plt with lazy binding.  This is corrected
now by initializing a new SFrame PLT helper object
elf_x86_64_sframe_ibt_plt for lazy PLT with IBT.

Add a testcase where linking with -z ibtplt generates .plt.sec entries and
ensure correct SFrame information for it.

Committed by Indu Bhagat.

ChangeLog:
PR/32296
* bfd/elf64-x86-64.c (elf_x86_64_sframe_ibt_pltn_fre2): New
definition elf_x86_64_sframe_ibt_plt.  Use it in
elf_x86_64_sframe_plt.
(elf_x86_64_link_setup_gnu_properties): Lazy IBT PLT entries are
different from lazy PLT.
        * bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Adjust for
SFrame for IBT PLT.
        * ld/testsuite/ld-x86-64/x86-64.exp: Add new test.
        * ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d: New test.

7 months agold: fix PR/32297
Josh Poimboeuf [Fri, 1 Nov 2024 22:26:13 +0000 (15:26 -0700)] 
ld: fix PR/32297

When _creating_ SFrame information for the linker created .plt.sec, the
code correctly checks for presence of .plt.sec.  When _writing_ the
SFrame section for the corresponding .plt.sec, however, the conditionals
were wrongly checking for splt.  This was causing an assertion at link
time.

This issue has been known to affect glibc build with SFrame enabled.

No testcase is added just yet.  A later commit ensures correct SFrame
stack trace information is created for .plt.got. A test case (where only
.plt and .plt.got are created) is added then.

PR/32297 sframe: bfd assertion with empty main on IBT enabled system

Committed by Indu Bhagat.

ChangeLog:
PR/32297
* bfd/elfxx-x86.c (_bfd_x86_elf_late_size_sections): Check for
  plt_second member not for splt.

7 months agox86-64: Add a test for hidden undefined symbol
H.J. Lu [Fri, 1 Nov 2024 21:19:35 +0000 (05:19 +0800)] 
x86-64: Add a test for hidden undefined symbol

Linker should report an error for hidden undefined symbol when building
a shared library without the "recompile with -fPIC" message:

$ cat x.c
extern int foo __attribute__ ((visibility ("hidden")));

int
func (void)
{
  return foo;
}
$ gcc -c -fPIC -O2 x.c
$ objdump -dwr x.o

x.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <func>:
   0: 8b 05 00 00 00 00     mov    0x0(%rip),%eax        # 6 <func+0x6> 2: R_X86_64_PC32 foo-0x4
   6: c3                    ret
$ ld -shared -o x.so x.o
ld: x.o: in function `func':
x.c:(.text+0x2): undefined reference to `foo'
ld: x.o: relocation R_X86_64_PC32 against undefined hidden symbol `foo' can not be used when making a shared object
ld: final link failed: bad value
$

since -fPIC has been used.

* testsuite/ld-x86-64/hidden6.d: New file.
* testsuite/ld-x86-64/hidden6.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run hidden6.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agoFix compile error due to [[noreturn]] with clang
Andrew Oates [Fri, 25 Oct 2024 23:35:34 +0000 (19:35 -0400)] 
Fix compile error due to [[noreturn]] with clang

Since commit d9deb60b2e9e94b532f43a7d3ddddf5ddf6dbdd3, I get the
following compiler error when building binutils (cross-compiling) on
macos:

 CXX    remote-sim.o
../../gdb/remote-sim.c:334:28: error: assigning to 'void (*)(host_callback *, const char *, ...) __attribute__((noreturn))' (aka 'void (*)(host_callback_struct *, const char *, ...) __attribute__((noreturn))') from incompatible type 'void (host_callback
*, const char *, ...)' (aka 'void (host_callback_struct *, const char *, ...)')
      gdb_callback.error = gdb_os_error;
                           ^~~~~~~~~~~~
1 error generated.

This appears to be due to the mismatch between ATTRIBUTE_NORETURN and
[[noreturn]] on gdb_os_error.  Reverting the change for gdb_os_error
resolves the issue.  Removing ATTTRIBUTE_NORETURN on the
declaration of host_callback::error also works, but deprives the
compiler of data.

Tested by compiling on macos both with the system clang, as well as with
GCC 14.  With clang, remote-sim.c does not compile (per above) without
this patch.  With GCC, it compiles with and without the patch (it
doesn't link, but AFAICT that is unrelated).

The clang bug is reported upstream at
https://github.com/llvm/llvm-project/issues/113511

Approved-By: Tom Tromey <tom@tromey.com>
7 months agoAdd gdb.events.tui_enabled
Tom Tromey [Wed, 25 Sep 2024 14:27:51 +0000 (08:27 -0600)] 
Add gdb.events.tui_enabled

This adds a new event source so that Python scripts can track whether
or not the TUI is presently enabled.

v2 of the patch renames "status" -> "enabled".

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32162
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Keith Seitz <keiths@redhat.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Fri, 1 Nov 2024 00:00:55 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoPrevent use-after-free of bfd filename in gdb_bfd_close_or_warn
Domani Johannes [Thu, 31 Oct 2024 12:40:04 +0000 (13:40 +0100)] 
Prevent use-after-free of bfd filename in gdb_bfd_close_or_warn

On Windows gcore is not implemented, and if you try it, you get an
heap-use-after-free error:

(gdb) gcore C:/gdb/build64/gdb-git-python3/gdb/testsuite/outputs/gdb.base/gcore-buffer-overflow/gcore-buffer-overflow.test
warning: cannot close "=================================================================
==10108==ERROR: AddressSanitizer: heap-use-after-free on address 0x1259ea503110 at pc 0x7ff6806e3936 bp 0x0062e01ed990 sp 0x0062e01ed140
READ of size 111 at 0x1259ea503110 thread T0
    #0 0x7ff6806e3935 in strlen C:/gcc/src/gcc-14.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:391
    #1 0x7ff6807169c4 in __pformat_puts C:/gcc/src/mingw-w64-v12.0.0/mingw-w64-crt/stdio/mingw_pformat.c:558
    #2 0x7ff6807186c1 in __mingw_pformat C:/gcc/src/mingw-w64-v12.0.0/mingw-w64-crt/stdio/mingw_pformat.c:2514
    #3 0x7ff680713614 in __mingw_vsnprintf C:/gcc/src/mingw-w64-v12.0.0/mingw-w64-crt/stdio/mingw_vsnprintf.c:41
    #4 0x7ff67f34419f in vsnprintf(char*, unsigned long long, char const*, char*) C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h:484
    #5 0x7ff67f34419f in string_vprintf[abi:cxx11](char const*, char*) C:/gdb/src/gdb.git/gdbsupport/common-utils.cc:106
    #6 0x7ff67b37b739 in cli_ui_out::do_message(ui_file_style const&, char const*, char*) C:/gdb/src/gdb.git/gdb/cli-out.c:227
    #7 0x7ff67ce3d030 in ui_out::call_do_message(ui_file_style const&, char const*, ...) C:/gdb/src/gdb.git/gdb/ui-out.c:571
    #8 0x7ff67ce4255a in ui_out::vmessage(ui_file_style const&, char const*, char*) C:/gdb/src/gdb.git/gdb/ui-out.c:740
    #9 0x7ff67ce2c873 in ui_file::vprintf(char const*, char*) C:/gdb/src/gdb.git/gdb/ui-file.c:73
    #10 0x7ff67ce7f83d in gdb_vprintf(ui_file*, char const*, char*) C:/gdb/src/gdb.git/gdb/utils.c:1881
    #11 0x7ff67ce7f83d in vwarning(char const*, char*) C:/gdb/src/gdb.git/gdb/utils.c:181
    #12 0x7ff67f3530eb in warning(char const*, ...) C:/gdb/src/gdb.git/gdbsupport/errors.cc:33
    #13 0x7ff67baed27f in gdb_bfd_close_warning C:/gdb/src/gdb.git/gdb/gdb_bfd.c:437
    #14 0x7ff67baed27f in gdb_bfd_close_or_warn C:/gdb/src/gdb.git/gdb/gdb_bfd.c:646
    #15 0x7ff67baed27f in gdb_bfd_unref(bfd*) C:/gdb/src/gdb.git/gdb/gdb_bfd.c:739
    #16 0x7ff68094b6f2 in gdb_bfd_ref_policy::decref(bfd*) C:/gdb/src/gdb.git/gdb/gdb_bfd.h:82
    #17 0x7ff68094b6f2 in gdb::ref_ptr<bfd, gdb_bfd_ref_policy>::~ref_ptr() C:/gdb/src/gdb.git/gdbsupport/gdb_ref_ptr.h:91
    #18 0x7ff67badf4d2 in gcore_command C:/gdb/src/gdb.git/gdb/gcore.c:176

0x1259ea503110 is located 16 bytes inside of 4064-byte region [0x1259ea503100,0x1259ea5040e0)
freed by thread T0 here:
    #0 0x7ff6806b1687 in free C:/gcc/src/gcc-14.2.0/libsanitizer/asan/asan_malloc_win.cpp:90
    #1 0x7ff67f2ae807 in objalloc_free C:/gdb/src/gdb.git/libiberty/objalloc.c:187
    #2 0x7ff67d7f56e3 in _bfd_free_cached_info C:/gdb/src/gdb.git/bfd/opncls.c:247
    #3 0x7ff67d7f2782 in _bfd_delete_bfd C:/gdb/src/gdb.git/bfd/opncls.c:180
    #4 0x7ff67d7f5df9 in bfd_close_all_done C:/gdb/src/gdb.git/bfd/opncls.c:960
    #5 0x7ff67d7f62ec in bfd_close C:/gdb/src/gdb.git/bfd/opncls.c:925
    #6 0x7ff67baecd27 in gdb_bfd_close_or_warn C:/gdb/src/gdb.git/gdb/gdb_bfd.c:643
    #7 0x7ff67baecd27 in gdb_bfd_unref(bfd*) C:/gdb/src/gdb.git/gdb/gdb_bfd.c:739
    #8 0x7ff68094b6f2 in gdb_bfd_ref_policy::decref(bfd*) C:/gdb/src/gdb.git/gdb/gdb_bfd.h:82
    #9 0x7ff68094b6f2 in gdb::ref_ptr<bfd, gdb_bfd_ref_policy>::~ref_ptr() C:/gdb/src/gdb.git/gdbsupport/gdb_ref_ptr.h:91
    #10 0x7ff67badf4d2 in gcore_command C:/gdb/src/gdb.git/gdb/gcore.c:176

It happens because gdb_bfd_close_or_warn uses a bfd-internal name for
the failing-close warning, after the close is finished, and the name
already freed:

static int
gdb_bfd_close_or_warn (struct bfd *abfd)
{
  int ret;
  const char *name = bfd_get_filename (abfd);

  for (asection *sect : gdb_bfd_sections (abfd))
    free_one_bfd_section (sect);

  ret = bfd_close (abfd);

  if (!ret)
    gdb_bfd_close_warning (name,
   bfd_errmsg (bfd_get_error ()));

  return ret;
}

Fixed by making a copy of the name for the warning.

Approved-By: Andrew Burgess <aburgess@redhat.com>
7 months agogas/doc/riscv: Fixed misaligned instruction table
Nelson Chu [Thu, 31 Oct 2024 03:43:07 +0000 (11:43 +0800)] 
gas/doc/riscv: Fixed misaligned instruction table

gas/
* doc/c-riscv.texi: Fixed misaligned instruction table.

7 months agoRISC-V: Dump instruction without checking architecture support as usual.
Nelson Chu [Fri, 27 Oct 2023 00:39:17 +0000 (08:39 +0800)] 
RISC-V: Dump instruction without checking architecture support as usual.

Since QEMU have supported -Max option to to enable all normal extensions,
the dis-assembler should also add an option, -M,max to do the same thing.
For the instruction, which have overlapped encodings like zfinx, will not
be considered by the -M,max option.

opcodes/
* riscv-dis.c (all_ext): New static boolean.  If set, disassemble
without checking architectire string.
(riscv_disassemble_insn): Likewise.
(parse_riscv_dis_option_without_args): Recognized -M,max option.
binutils/
* NEWS: Updated.

7 months agoAutomatic date update in version.in
GDB Administrator [Thu, 31 Oct 2024 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agold-elf/pr25207.d: Pass --no-rosegment to ld
H.J. Lu [Wed, 30 Oct 2024 21:04:15 +0000 (05:04 +0800)] 
ld-elf/pr25207.d: Pass --no-rosegment to ld

Pass --no-rosegment to ld to support linker configured with
--enable-rosegment,

PR ld/25207
* ld-elf/pr25207.d: Pass --no-rosegment to ld.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 months agogdb: Update SECURITY.txt to mention extension scripts and internal errors
Guinevere Larsen [Thu, 13 Jun 2024 18:34:26 +0000 (15:34 -0300)] 
gdb: Update SECURITY.txt to mention extension scripts and internal errors

Given the recent CVE filed for GDB (CVE-2024-36699), I decided to update
the gdb/SECURITY.txt to be more explicit about some details. Specifically,
we now explicitly say that internal errors aren't security
vulnerabilities, and mention that users should review plugins before
running them, and under which conditions a plugin can cause a security
bug.

Reviewed-By: Tom Tromey <tom@tromey.com>
Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
7 months ago[gdb/tdep] Use std::array in amd64-windows-tdep.c
Tom de Vries [Wed, 30 Oct 2024 12:30:51 +0000 (13:30 +0100)] 
[gdb/tdep] Use std::array in amd64-windows-tdep.c

I noticed commit 84786372e1c ("Fix size of register buffer") fixing a
stack-buffer-overflow found by AddressSanitizer in
amd64_windows_store_arg_in_reg:
...
-  gdb_byte buf[8];
+  gdb_byte buf[16];
...
and wondered if we could have found this without AddressSanitizer.

I realized that the problem is that this:
...
  gdb_byte buf[N];
  ...
  regcache->cooked_write (regno, buf);
...
is using the deprecated variant of cooked_write instead of the one using
gdb::array_view:
...
  /* Transfer of pseudo-registers.  */
  void cooked_write (int regnum, gdb::array_view<const gdb_byte> src);

  /* Deprecated overload of the above.  */
  void cooked_write (int regnum, const gdb_byte *src);
...
and consequently cooked_write does not know the size of buf.

Fix this by using std::array, and likewise in other places in
gdb/amd64-windows-tdep.c.

In the process I fixed another out of bounds access here:
...
gdb_byte imm16[2];
  ...
cache->prev_sp = cur_sp
  + extract_unsigned_integer (imm16, 4, byte_order);
...
where we're reading 4 bytes from the 2-byte buffer imm16.

Tested by rebuilding on x86_64-linux.

Tested-By: Hannes Domani <ssbssa@yahoo.de>
7 months agox86: add a helper to copy insn operand info
Jan Beulich [Wed, 30 Oct 2024 11:13:22 +0000 (12:13 +0100)] 
x86: add a helper to copy insn operand info

We're doing such in fairly many places, and yet more are likely to
appear; centralize the logic, much like we already have
swap_2_operands().

While there also correct mis-indentation in adjacent code in
process_operands().

7 months agox86/APX: support JMPABS also in assembler
Jan Beulich [Wed, 30 Oct 2024 11:12:54 +0000 (12:12 +0100)] 
x86/APX: support JMPABS also in assembler

Without this APX support isn't really complete.

For Intel syntax displacement form is needed, such that symbolic
operands won't need prefixing by "offset". (The other form is actually
not used at all in Intel syntax.)

For the record: To restrict displacement form to Intel syntax is not
something I actually agree with.