Commit Graph

120653 Commits

Author SHA1 Message Date
Simon Marchi
56246f3099 Convert typedef hash to new hash table
This converts the typedef hash to use the new hash table.

This patch found a latent bug in the typedef code.  Previously, the
hash function looked at the type name, but the hash equality function
used types_equal -- but that strips typedefs, meaning that equality of
types did not imply equality of hashes.  This patch fixes the problem
and updates the relevant test.

Change-Id: I0d10236b01e74bac79621244a1c0c56f90d65594
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
cd1a05c76f Convert abbrevs to new hash table
This converts the DWARF abbrevs themselves to use the new hash table.

Change-Id: I0320a733ecefe2cffeb25c068f17322dd3ab23e2
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
345009bbfb Convert abbrev cache to new hash table
This converts the DWARF abbrev cache to use the new hash table.

Change-Id: I5e88cd4030715954db2c43f873b77b6b8e73f5aa
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
41c2bfb82f Convert gnu-v3-abi.c to new hash table
This converts gnu-v3-abi.c to use the new hash table.

This change shows how a std::vector can easily be made directly from
the hash table, simplifying the earlier approach of constructing a
vector and a hash table at the same time.

Change-Id: Ia0c387a035a52300db6b6f5a3a2e5c69efa01155
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
9f33419814 Convert static links to new hash table
This converts the objfile static link table to the new hash map.

Change-Id: If978e895679899ca2af4ef01c12842b4184d88e6
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
112f6d85fb Convert type copying to new hash table
This converts the type copying code to use the new hash map.

Change-Id: I35f0a4946dcc5c5eb84820126cf716b600f3302f
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
c4b9453529 Convert compile/compile.c to new hash table
This converts compile/compile.c to use the new hash table.

Change-Id: I7df3b8d791ece731ae0d1d64cdc91a2e372f5d4f
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
5a616f1cf6 Convert disasm.c to new hash table
This converts disasm.c to use the new hash table.

Change-Id: I2efbe7ecc2964ec49e0b726ad4674e8eafc929f7
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
52dedd71c8 Convert py-framefilter.c to new hash table
This converts py-framefilter.c to use the new hash table.

Change-Id: I38f4eaa8ebbcd4fd6e5e8ddc462502a92bf62f5e
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
e77c31d28d Convert breakpoint.c to new hash table
This converts breakpoint.c to use the new hash table.

Change-Id: I6d997a6242969586a7f8f9eb22cc8dd8d3ac97ff
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
370e6d147c Convert dwarf2/macro.c to new hash table
This converts dwarf2/macro.c to use the new hash table.

Change-Id: I6af0d1178e2db330fe3a89d57763974145ed17c4
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
d64c62fdb4 Convert target-descriptions.c to new hash table
This converts target-descriptions.c to use the new hash table.

Change-Id: I03dfc6053c9856c5578548afcfdf58abf8b7ec2c
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
bf8006d65e Convert linespec.c to new hash table
This converts linespec.c to use the new hash table.

Note that more simplification could perhaps be done.  Currently, the
collectors in this code insert an element into a set and then, if the
element has not been seen before, append it to a vector.  If we know
the order does not matter, or if the results can be sorted later, we
could dispense with the vector.  This would simplify the code some
more.  (This technique is used in the vtable patch, later in this
series.)

Change-Id: Ie6828b1520d918d189ab5140dc8094a609152cf2
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
579dc13b74 Convert filename-seen-cache.h to new hash table
This converts filename-seen-cache.h to use the new hash table.
filename-seen-cache.c is removed.

Change-Id: Iffac1d5e49d1610049b7deeef6e98d49e644366a
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:04 -05:00
Simon Marchi
33d2aa8ccc Convert compile-c-symbols.c to new hash table
This converts compile-c-symbols.c to use the new hash table.

I made it use a set of string_view instead of a set of `symbol *`, to
avoid calling `symbol::natural_name` over and over.  This appears safe
to do, since I don't expect the storage behing the natural names to
change during the lifetime of the map.

Change-Id: Ie9f9334d4f03b9a8ae6886287f82cd435eee217c
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:03 -05:00
Simon Marchi
8f942ca8a5 gdbsupport: add unordered_dense.h 4.4.0
Add a copy of unordered_dense.h from [1].  This file implements an
efficient hash map and hash set with a nice C++ interface (a near
drop-in for std::unordered_map and std::unordered_set).  This is
expected to be used to replace uses of `htab_t`, for improved code
readability and type safety.  Performance-wise, it is preferred to the
std types (std::unordered_map and std::unordered_set) due to it using
open addressing vs closed addressing for the std types.

I chose this particular implementation because it is simple to use, it's
a standalone header and it typically performs well in benchmarks I have
seen (e.g. [2]).  The license being MIT, my understanding is that it's
not a problem to use it and re-distribute it.

Add two additional files, gdbsupport/unordered_map.h and
gdbsupport/unordered_set.h, which make the map and set offered by
gdbsupport/unordered_dense.h available as gdb::unordered_map and
gdb::unordered_set.

[1] https://github.com/martinus/unordered_dense
[2] https://jacksonallan.github.io/c_cpp_hash_tables_benchmark/#conclusion-which-hash-table-to-choose

Change-Id: I0c7469ccf9a14540465479e58b2a5140a2440a7d
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:03 -05:00
Simon Marchi
27f4421427 gdb: make cooked_index_storage::get_abbrev_table_cache return a reference
It can never return nullptr, return a reference instead of a pointer.

Change-Id: Ibc6f16eb74dc16059152982600ca9f426d7f80a4
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:03 -05:00
Simon Marchi
c9e2e9992a gdb: constification around abbrev_table_cache and abbrev_table
Make `abbrev_table_cache::find` const, make it return a pointer to
`const abbrev_table`, adjust the fallouts.

Make `cooked_index_storage::get_abbrev_table_cache` const, make itreturn
a pointer to const `abbrev_table_cache`.

Change-Id: If63b4b3a4c253f3bd640b13bce4a854eb2d75ece
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:03 -05:00
Simon Marchi
020c5193ac gdb: rename abbrev_cache to abbrev_table_cache
This cache holds `abbrev_table` objects, so I think it's clearer and
more consistent to name it `abbrev_table_cache`.  Rename it and
everything that goes along with it.

Change-Id: I43448c0aa538dd2c3ae5efd2f7b3e7b827409d8c
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 22:07:03 -05:00
GDB Administrator
d73b6fc032 Automatic date update in version.in 2024-11-26 00:00:42 +00:00
Andrew Burgess
5066f36806 gdb: do better in breakpoint_free_objfile
The breakpoint_free_objfile function is called from the objfile
destructor, and has the job of removing references to the soon to be
deleted objfile from all breakpoint locations.

The current implementation of breakpoint_free_objfile seems to miss
lots of possible objfile references within bp_location.  Currently we
only check if bp_location::symtab is associated with the objfile in
question, but there's bp_location::section and bp_location::probe,
both of which might reference the soon to be deleted objfile.

Additionally bp_location::symbol and bp_location::msymbol if set will
surely be related to the objfile and should also be cleaned up.

I'm not aware that this causes any problems, but it doesn't seem like
a good idea to retain pointers to deleted state, so I propose that we
improve breakpoint_free_objfile to set these pointers back to nullptr.

In the future I plan to investigate the possibility of merging the
functionality of breakpoint_free_objfile into
disable_breakpoints_in_freed_objfile which is called via the
gdb::observers::free_objfile event.  However, I already have a patch series
in progress which touches this area of GDB, and I'd like to avoid
conflicting with that earlier series:

  https://inbox.sourceware.org/gdb-patches/cover.1724948606.git.aburgess@redhat.com

Once this patch, and that earlier series have landed then I'll see if
I can merge breakpoint_free_objfile, but I don't think that this needs
to block this patch.

There should be no user visible changes after this commit.
2024-11-25 16:45:25 +00:00
Andrew Burgess
df63932c96 gdb: remove an unnecessary scope block in update_breakpoint_locations
In update_breakpoint_locations there's a scope block which I don't
think adds any value.  There is one local defined within the scope,
the local is currently an 'int' but should be a 'bool', either way
there's no destructor being triggered when we exit the scope.

This commit changes the local to a 'bool', removes the unnecessary
scope, and re-indents the code.

Within the (now removed) scope was a `for' loop.  Inside the loop I
have converted this:

  for (....)
    {
      if (CONDITION)
        {
          /* Body */
        }
    }

to this:

  for (....)
    {
      if (!CONDITION)
        continue;

      /* Body */
    }

which means that the body doesn't need to be indented as much, making
things easier to read.

There should be no functional change after this commit.

Reviewed-By: Klaus Gerlicher <klaus.gerlicher@intel.com>
2024-11-25 16:45:25 +00:00
Andrew Burgess
2778a124e3 gdb: remove bp_location::objfile
The bp_location::objfile member variable is never used, so lets delete
it.

There should be no user visible changes after this commit.
2024-11-25 16:45:25 +00:00
Alexandra Hájková
280cdb642b gdbreplay: Calculate the checksum if missing
Recalculate the checksum and replace whatever is at the end
of the packet with the newly calculated checksum. Then
replay the packet with the checksum added.

The motivation for this change is that I'd like to add a TCL test
which starts a communication with gdbsever setting the remotelog file.
Then, it modifies the remotelog, injects an error message instead of
the expected replay to some packet in order to test GDB reacts to
the error response properly.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-25 16:58:52 +01:00
Nick Clifton
3b00205cd8 Updated Bulgarian, Romanian and French translations for various sub-directories. New Georgian translation for the gold sub-directory. 2024-11-25 15:53:22 +00:00
Andrew Burgess
c2baada054 gdb/testsuite: force TERM setting for some filename completion tests
Some of the filename completion tests perform mid-line completion.
That is we enter a partial line, then move the cursor back to the
middle of the line and perform completion.

The problem is that, emitting characters into the middle of a terminal
line relies on first emitting some control characters.  And which
control characters are emitted will depend on the current TERM
setting.

When I initially added the mid-line completion tests I setup two
regexp that covered two different terminal types, but PR gdb/32338
identifies additional terminal types that emit different sequences of
control characters.

Rather than trying to handle all possible terminal types, lets just
force the TERM variable to something simple (i.e. "dumb") and then
just support that one case.  The thing being tested for here was that
GDB would complete a filename in the middle of a line, the specific
terminal type was not really important.

I've simplified the regexp used to match the completion in two places,
and I now force TERM to be "dumb" for the mid-line completion tests.
I've tested this by setting my global environment TERM to 'ansi',
'xterm', 'xterm-mono', and 'dumb', and I see no failures in any mode
now.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32338
Tested-By: Tom de Vries <tdevries@suse.de>
2024-11-25 11:54:42 +00:00
Hui Li
7ffa83b32e gdb: Add LoongArch process record/replay support in NEWS and doc
At present, process record/replay and reverse debugging has been
implemented on LoongArch. Update the NEWS and doc to record this
new change.

Signed-off-by: Hui Li <lihui@loongson.cn>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-11-25 19:16:11 +08:00
Hui Li
33afccfaa8 gdb: LoongArch: Add system call support for process record/replay
The process record and replay function also need record Linux
system call instruction. This patch adds LoongArch system call
number definitions in gdb/arch/loongarch-syscall.h, and adds
loongarch_linux_syscall_record() in gdb/loongarch-linux-tdep.c
to record system call execute log. With this patch, the main
functions of process record/replay and reverse debugging are
implemented.

The LoongArch system call numbers definitions are obtained from Linux kernel.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/asm/unistd.h

Signed-off-by: Hui Li <lihui@loongson.cn>
Approved-By: Guinevere Larsen <guinevere@redhat.com> (record-full)
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-11-25 19:15:51 +08:00
Hui Li
886ebc2b1f gdb: LoongArch: Add basic process record/replay support
GDB provides a special process record and replay target that can
record a log of the process execution, and replay it later with
both forward and reverse execution commands. This patch adds the
basic support of process record and replay on LoongArch, it allows
users to debug basic LoongArch instructions and provides reverse
debugging support.

Here is a simple example on LoongArch:

$ cat test.c
int a = 0;
int main()
  {
    a = 1;
    a = 2;
    return 0;
  }
$ gdb test
...
(gdb) start
...
Temporary breakpoint 1, main () at test.c:4
4	    a = 1;
(gdb) record
(gdb) p a
$1 = 0
(gdb) n
5	    a = 2;
(gdb) n
6	    return 0;
(gdb) p a
$2 = 2
(gdb) rn
5	    a = 2;
(gdb) rn

Reached end of recorded history; stopping.
Backward execution from here not possible.
main () at test.c:4
4	    a = 1;
(gdb) p a
$3 = 0
(gdb) record stop
Process record is stopped and all execution logs are deleted.
(gdb) c
Continuing.
[Inferior 1 (process 129178) exited normally]

Signed-off-by: Hui Li <lihui@loongson.cn>
Approved-By: Guinevere Larsen <guinevere@redhat.com> (record-full)
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-11-25 19:15:02 +08:00
Hui Li
19b5accc3f gdb: LoongArch: Add instruction definition for process record
GDB provides a special process record function that can record a log
of the process execution. The core of this feature is need to record
the execution of all instructions. This patch adds opcode definitions
and judgments in gdb/arch/loongarch-insn.h. This is preparation for
later patch on LoongArch, there is no effect for the other archs with
this patch.

The LoongArch opcode and mask definitions are obtained from
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=opcodes/loongarch-opc.c
LoongArch instruction description refer to the LoongArch Reference Manual:
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Signed-off-by: Hui Li <lihui@loongson.cn>
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-11-25 19:13:08 +08:00
GDB Administrator
66df4f72b6 Automatic date update in version.in 2024-11-25 00:00:46 +00:00
Tom de Vries
6206516653 opcodes: fix Werror=format build breaker in opcodes/riscv-dis.c
I build gdb on arm-linux and ran into:
...
  CC       riscv-dis.lo
opcodes/riscv-dis.c: In function ‘print_insn_args’:
opcodes/riscv-dis.c:743:29: error: format ‘%lu’ expects argument of type \
  ‘long unsigned int’, but argument 4 has type ‘insn_t’ \
  {aka ‘long long unsigned int’} [-Werror=format=]
  743 |                          "%lu", EXTRACT_ZCMT_INDEX (l));
      |                           ~~^
      |                             |
      |                             long unsigned int
      |                           %llu
...

Fix this by printing the insn_t value, which is a uint64_t, using PRIu64.

Tested by finishing the build.
2024-11-24 09:21:28 +01:00
GDB Administrator
3198eb6627 Automatic date update in version.in 2024-11-24 00:00:57 +00:00
Tom de Vries
2c781c5fcf [sim] Run spellcheck.sh in sim (part 2)
Run gdb/contrib/spellcheck.sh on directory sim.

Fix these todos:
...
TODO: inbetween -> between, in between, in-between
TODO: behavour -> behavior, behaviour
TODO: firts -> flirts, first
TODO: wich -> which, witch
...

Tested by rebuilding on x86_64-linux.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-23 13:07:38 +01:00
Tom de Vries
9f43244a41 [gdb/contrib] Add two words to common-misspellings.txt
While reviewing changes generated by spellcheck.sh for directory sim, I
noticed two more misspellings:
...
arrithemetic->arithmetic
electricaly->electrically
...

Add them to common-misspellings.txt, and fix them in directory sim.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-23 13:07:38 +01:00
Tom de Vries
d2d240ff89 [sim] Run spellcheck.sh in sim (part 1)
Run gdb/contrib/spellcheck.sh on directory sim.

Fix auto-corrected typos:
...
accessable -> accessible
accidently -> accidentally
accomodate -> accommodate
adress -> address
afair -> affair
agains -> against
agressively -> aggressively
annuled -> annulled
arbitary -> arbitrary
arround -> around
auxillary -> auxiliary
availablity -> availability
clasic -> classic
comming -> coming
controled -> controlled
controling -> controlling
destory -> destroy
existance -> existence
explictly -> explicitly
faciliate -> facilitate
fouth -> fourth
fullfilled -> fulfilled
guarentee -> guarantee
hinderance -> hindrance
independant -> independent
inital -> initial
loosing -> losing
occurance -> occurrence
occured -> occurred
occuring -> occurring
omited -> omitted
oportunity -> opportunity
parallely -> parallelly
permissable -> permissible
postive -> positive
powerfull -> powerful
preceed -> precede
preceeding -> preceding
preceeds -> precedes
primative -> primitive
probaly -> probably
programable -> programmable
propogate -> propagate
propper -> proper
recieve -> receive
reconized -> recognized
refered -> referred
refering -> referring
relevent -> relevant
responisble -> responsible
retreive -> retrieve
safty -> safety
specifiying -> specifying
spontanous -> spontaneous
sqaure -> square
successfull -> successful
supress -> suppress
sytem -> system
thru -> through
transfered -> transferred
trigered -> triggered
unfortunatly -> unfortunately
upto -> up to
usefull -> useful
wierd -> weird
writen -> written
doesnt -> doesn't
isnt -> isn't
...

Manually undid the "andd -> and" transformation in sim/testsuite/cr16/andd.cgs
and sim/cr16/simops.c.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-23 13:07:38 +01:00
Tom de Vries
8dfa29fcbd [sim] Rename local variable in ARMul_NthReg
Rename local variable in ARMul_NthReg from upto to up_to, to avoid being
rewritten by gdb/contrib/spellcheck.sh.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-23 13:07:38 +01:00
Tom de Vries
60d465be9d [gdbsupport] Rerun autoreconf -f
Rerun autoreconf -f in gdbsupport, reverting "behaviour" -> "behavior" changes
in generated files aclocal.m4 and configure.
2024-11-23 12:40:36 +01:00
Tom de Vries
ac51afb51c [gdb/contrib] Add two rules in common-misspellings.txt
Eli mentioned [1] that given that we use US English spelling in our
documentation, we should use "behavior" instead of "behaviour".

In wikipedia-common-misspellings.txt there's a rule:
...
behavour->behavior, behaviour
...
which leaves this as a choice.

Add an overriding rule to hardcode the choice to common-misspellings.txt:
...
behavour->behavior
...
and add a rule to rewrite behaviour into behavior:
...
behaviour->behavior
...
and re-run spellcheck.sh on gdb*.

Tested on x86_64-linux.

[1] https://sourceware.org/pipermail/gdb-patches/2024-November/213371.html
2024-11-23 12:20:34 +01:00
GDB Administrator
63eedf3b09 Automatic date update in version.in 2024-11-23 00:00:36 +00:00
Sam James
12db6ae445 Sync toplevel configure fixup
Apparently I missed that we needed to sync config/acx.m4. I only
noticed this because our packaging has a grep for certain messages
post-merge.

```
work/binutils/configure: 5814: ACX_PROG_CARGO: not found
```

Fix that by syncing the macro too, which I missed in 987db70ace.
2024-11-22 20:57:06 +00:00
Guinevere Larsen
ab8c2180a3 gdb/record: introduce recoding support for vpor
This commit adds recording support for the AVX instruction vpor, and the
AVX2 extension. Since the encoding of vpor and vpxor are the same, and
their semantics are basically the same, modulo the mathematical
operation, they are handled by the same switch case block.

This also updates the vpxor function, to test vpor and vpxor, and
updates the name to vpor_xor_test to better reflect what it does.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 17:40:26 -03:00
Guinevere Larsen
b19c86e2db gdb/record: Add support for recording vpmovmskb
This commit adds support for recording the AVX instruction vpmovmskb,
and tests to the relevant file. The test didn't really support checking
general purpose registers, so this commit also adds a proc to
gdb.reverse/i386-avx-reverse.exp, which can be used to test them

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 17:40:25 -03:00
Guinevere Larsen
f21055a4e9 gdb/record: Add support for all vpcmpeq instructions
This commit adds support to recording instructions of the form
VPCMPEQ[B|W|D]. They are all encoded in the same way and only
differentiated by the opcode, so they are all processed together. This
commit also updates the test to (quite exhaustively) test the new
instruction.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 17:40:25 -03:00
Guinevere Larsen
2bb2f15e0b gdb/record: add support for vpxor instruction
This commit adds support for recording the instruction vpxor,
introduced in the AVX extension, and extended in AVX2 to use 256 bit
registers. The test gdb.reverse/i386-avx-reverse.exp has been extended
to test this instruction as well.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 17:40:25 -03:00
Guinevere Larsen
3cfa137ca5 gdb: Introduce RAII signal handler setter
This patch is motivated by the wait function for the record-full target,
that would install a custom signal handler for SIGINT, but could throw
an exception and never reset the SIGINT handler.  This is clearly a bad
idea, so this patch introduces the class scoped_signal_handler in a new
.h file.  The file is added to gdbsupport, even though only gdb code is
using it, because it feels like an addition that would be useful for
more than just directly gdb.

The implementation of the RAII class is based on the implementation
on gdb/utils.c. That is, it uses preprocessor ifdefs to probe for
sigaction support, and uses it if possible, defaulting to a raw call to
signal only if sigaction isn't supported. sigaction is preferred based
on the "portability" section of the manual page for the signal function.

There are 3 places where this class can just be dropped in,
gdb/record-full.c, gdb/utils.c and gdb/extension.c. This third place
already had a specialized RAII signal handler setter, but it is
substituted for the new general purpose one.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 17:38:31 -03:00
Vladimir Mezentsev
4e943705e3 gprofng: fix build with -std=gnu23
Fix function pointer types accordingly.
Remove unused function pointers.

gprofng/ChangeLog
2024-11-21  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/32374
	PR gprofng/32373
	* common/cpuid.c: Define ATTRIBUTE_UNUSED if necessary.
	* libcollector/libcol_util.c (sysinfo): Remove unused pointer.
	* src/collector_module.h: Likewise.
	* libcollector/dispatcher.c (setitimer): Fix prototype.
	* libcollector/linetrace.c (system, grantpt, ptsname): Likewise.
	* testsuite/gprofng.display/mttest/mttest.c (dump_arrays): Likewise.
	* testsuite/gprofng.display/synprog/endcases.c (xinline_code,
	s_inline_code): Likewise.
	* testsuite/gprofng.display/synprog/inc_inline.h (ext_inline_code):
	Likewise.
	* testsuite/gprofng.display/synprog/synprog.c (doabort): Rename nullptr.
2024-11-22 12:03:45 -08:00
Hannes Domani
d2f4f6bf54 Use appropriate context flags for Wow64 processes
When I implemented debugging of Wow64 processes, I missed that there are
extra ContextFlags defines for them.
It's a bit surprising that the wrong ones actually worked, except that
CONTEXT_EXTENDED_REGISTERS is not available for x86_64, and they are
needed for i686, since that's where the xmm registers are stored.

So this replaces the ContextFlags values with their WOW64_* equivalents.
On gdbserver this also duplicates the fallback logic if the
GetThreadContext call failed with CONTEXT_EXTENDED_REGISTERS.

Fixes these fails:
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm0
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm0
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm1
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm1
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm2
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm2
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm3
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm3
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm4
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm4
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm5
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm5
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm6
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm6
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm7
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm7
FAIL: gdb.arch/i386-sse.exp: check contents of data[0]
FAIL: gdb.arch/i386-sse.exp: check contents of data[1]
FAIL: gdb.arch/i386-sse.exp: check contents of data[2]
FAIL: gdb.arch/i386-sse.exp: check contents of data[3]
FAIL: gdb.arch/i386-sse.exp: check contents of data[4]
FAIL: gdb.arch/i386-sse.exp: check contents of data[5]
FAIL: gdb.arch/i386-sse.exp: check contents of data[6]
FAIL: gdb.arch/i386-sse.exp: check contents of data[7]

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 20:10:26 +01:00
Sam James
987db70ace Sync toplevel configure with GCC
This syncs us with GCC as of r15-5590-gf34422e06c38eb.

Some changes will need to be propagated to the GCC side (so I've kept those
and not clobbered them) which I will handle shortly.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 19:05:34 +00:00
Tom de Vries
372d0a4c96 [gdb/python] Handle failure to initialize without exiting
I tried out making python initialization fail by passing an incorrect
PYTHONHOME, and got:
...
$ PYTHONHOME=foo ./gdb.sh -q
Python path configuration:
  PYTHONHOME = 'foo'
  ...
Python initialization failed: \
  failed to get the Python codec of the filesystem encoding
Python not initialized
$
...

The relevant part of the code is:
...
static void
gdbpy_initialize (const struct extension_language_defn *extlang)
{
  if (!do_start_initialization () && py_isinitialized && PyErr_Occurred ())
    gdbpy_print_stack ();

   gdbpy_enter enter_py;
...

What happens is:
- gdbpy_enter::gdbpy_enter () is called, where we run into:
  'if (!gdb_python_initialized) error (_("Python not initialized"));'
- the error propagates to gdb's toplevel
- gdb print the error and exits.

It seems unnecesssary that we exit gdb.  We could continue the
session without python support.

Fix this by:
- bailing out of gdbpy_initialize if !do_start_initialization
- bailing out of finalize_python if !gdb_python_initialized

This gets us instead:
...
$ PYTHONHOME=foo gdb -q
Python path configuration:
  PYTHONHOME = 'foo'
  ...
Python initialization failed: \
  failed to get the Python codec of the filesystem encoding
(gdb) python print (1)
Python not initialized
(gdb)
...

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 19:34:24 +01:00