Compare commits

...

109 Commits

Author SHA1 Message Date
Joel Brobecker
662243de0e Set GDB version number to 13.2.
This commit changes gdb/version.in to 13.2.
2023-05-27 11:46:47 +02:00
GDB Administrator
7c1c1bec17 Automatic date update in version.in 2023-05-27 00:01:08 +00:00
GDB Administrator
6e1c384eb0 Automatic date update in version.in 2023-05-26 00:01:03 +00:00
GDB Administrator
cc89d24220 Automatic date update in version.in 2023-05-25 00:01:05 +00:00
GDB Administrator
0db93c9a77 Automatic date update in version.in 2023-05-24 00:00:56 +00:00
GDB Administrator
ec9a76ceb4 Automatic date update in version.in 2023-05-23 00:01:35 +00:00
GDB Administrator
7caa595c0f Automatic date update in version.in 2023-05-22 00:00:46 +00:00
GDB Administrator
51537ecddb Automatic date update in version.in 2023-05-21 00:01:02 +00:00
Jan Vrany
bcd95b84d3 gdb: fix post-hook execution for remote targets
Commit b5661ff2 ("gdb: fix possible use-after-free when
executing commands") attempted to fix possible use-after-free
in case command redefines itself.

Commit 37e5833d ("gdb: fix command lookup in execute_command ()")
updated the previous fix to handle subcommands as well by using the
original command string to lookup the command again after its execution.

This fixed the test in gdb.base/define.exp but it turned out that it
does not work (at least) for "target remote" and "target extended-remote".

The problem is that the command buffer P passed to execute_command ()
gets overwritten in dont_repeat () while executing "target remote"
command itself:

	#0  dont_repeat () at top.c:822
	#1  0x000055555730982a in target_preopen (from_tty=1) at target.c:2483
	#2  0x000055555711e911 in remote_target::open_1 (name=0x55555881c7fe ":1234", from_tty=1, extended_p=0)
	    at remote.c:5946
	#3  0x000055555711d577 in remote_target::open (name=0x55555881c7fe ":1234", from_tty=1) at remote.c:5272
	#4  0x00005555573062f2 in open_target (args=0x55555881c7fe ":1234", from_tty=1, command=0x5555589d0490)
	    at target.c:853
	#5  0x0000555556ad22fa in cmd_func (cmd=0x5555589d0490, args=0x55555881c7fe ":1234", from_tty=1)
	    at cli/cli-decode.c:2737
	#6  0x00005555573487fd in execute_command (p=0x55555881c802 "4", from_tty=1) at top.c:688

Therefore the second call to lookup_cmd () at line 697 fails to find
command because the original command string is gone.

This commit addresses this particular problem by creating a *copy* of
original command string for the sole purpose of using it after command
execution to lookup the command again. It may not be the most efficient
way but it's safer given that command buffer is shared and overwritten
in hard-to-foresee situations.

Tested on x86_64-linux.

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

Approved-By: Tom Tromey <tom@tromey.com>
(cherry picked from commit b69378ced6)
2023-05-20 19:31:20 +01:00
GDB Administrator
c9cdea72da Automatic date update in version.in 2023-05-20 00:01:19 +00:00
GDB Administrator
dd397e126a Automatic date update in version.in 2023-05-19 00:01:15 +00:00
GDB Administrator
9fa7f3deb2 Automatic date update in version.in 2023-05-18 00:00:59 +00:00
GDB Administrator
0459630d58 Automatic date update in version.in 2023-05-17 00:01:02 +00:00
Khem Raj
186143c39e gdbserver/linux-low.cc: Fix a typo in ternary operator
Signed-off-by: Khem Raj <raj.khem@gmail.com>
(cherry picked from commit 2e977d9901)
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30450
2023-05-16 10:52:49 -06:00
GDB Administrator
53d9d0516b Automatic date update in version.in 2023-05-16 00:00:59 +00:00
Tom Tromey
49664141e1 Correctly handle forward DIE references in scanner
The cooked index scanner has special code to handle forward DIE
references.  However, a bug report lead to the discovery that this
code does not work -- the "deferred_entry::spec_offset" field is
written to but never used, i.e., the lookup is done using the wrong
key.

This patch fixes the bug and adds a regression test.

The test in the bug itself used a thread_local variable, which
provoked a failure at runtime.  This test instead uses "maint print
objfiles" and then inspects to ensure that the entry in question has a
parent.  This lets us avoid a clang dependency in the test.

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

(cherry picked from commit b10f2cd3f3)
2023-05-15 09:10:33 -06:00
GDB Administrator
df7e1a3c15 Automatic date update in version.in 2023-05-15 00:00:58 +00:00
GDB Administrator
29d0a4928e Automatic date update in version.in 2023-05-14 00:00:46 +00:00
GDB Administrator
dab27b8a37 Automatic date update in version.in 2023-05-13 00:00:51 +00:00
GDB Administrator
dbaf8426ea Automatic date update in version.in 2023-05-12 00:01:41 +00:00
GDB Administrator
bf1abbf3a1 Automatic date update in version.in 2023-05-11 00:00:45 +00:00
GDB Administrator
54fb01a5c4 Automatic date update in version.in 2023-05-10 00:01:45 +00:00
GDB Administrator
2f464f5237 Automatic date update in version.in 2023-05-09 00:01:28 +00:00
GDB Administrator
26570c3c45 Automatic date update in version.in 2023-05-08 00:01:13 +00:00
GDB Administrator
28962d16b6 Automatic date update in version.in 2023-05-07 00:01:03 +00:00
GDB Administrator
8415822ffa Automatic date update in version.in 2023-05-06 00:00:54 +00:00
Simon Marchi
caaf38247f gdb: fix -Wsingle-bit-bitfield-constant-conversion warning in z80-tdep.c
When building with clang 16, I see:

    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:338:32: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            info->prologue_type.load_args = 1;
                                          ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:345:36: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.critical = 1;
                                       ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:351:37: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.interrupt = 1;
                                        ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:367:36: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                  info->prologue_type.fp_sdcc = 1;
                                              ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:375:35: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.fp_sdcc = 1;
                                      ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:380:35: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.fp_sdcc = 1;
                                      ^ ~

Fix that by using "unsigned int" as the bitfield's underlying type.

(cherry picked from commit 07f2859348)

Change-Id: I3550a0112f993865dc70b18f02ab11bb5012693d
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30423
Approved-By: Tom Tromey <tom@tromey.com>
2023-05-05 15:27:06 -04:00
Simon Marchi
12e3f3bc6e gdbsupport: ignore -Wenum-constexpr-conversion in enum-flags.h
When building with clang 16, we get:

      CXX    gdb.o
    In file included from /home/smarchi/src/binutils-gdb/gdb/gdb.c:19:
    In file included from /home/smarchi/src/binutils-gdb/gdb/defs.h:65:
    /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
        integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                       ^

The error message does not make it clear in the context of which enum
flag this fails (i.e. what is T in this context), but it doesn't really
matter, we have similar warning/errors for many of them, if we let the
build go through.

clang is right that the value -1 is invalid for the enum type we cast -1
to.  However, we do need this expression in order to select an integer
type with the appropriate signedness.  That is, with the same signedness
as the underlying type of the enum.

I first wondered if that was really needed, if we couldn't use
std::underlying_type for that.  It turns out that the comment just above
says:

    /* Note that std::underlying_type<enum_type> is not what we want here,
       since that returns unsigned int even when the enum decays to signed
       int.  */

I was surprised, because std::is_signed<std::underlying_type<enum_type>>
returns the right thing.  So I tried replacing all this with
std::underlying_type, see if that would work.  Doing so causes some
build failures in unittests/enum-flags-selftests.c:

      CXX    unittests/enum-flags-selftests.o
    /home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:254:1: error: static assertion failed due to requirement 'gdb::is_same<selftests::enum_flags_tests::check_valid_expr254::archetype<enum_flags<s
    elftests::enum_flags_tests::RE>, selftests::enum_flags_tests::RE, enum_flags<selftests::enum_flags_tests::RE2>, selftests::enum_flags_tests::RE2, enum_flags<selftests::enum_flags_tests::URE>, selftests::enum_fla
    gs_tests::URE, int>, selftests::enum_flags_tests::check_valid_expr254::archetype<enum_flags<selftests::enum_flags_tests::RE>, selftests::enum_flags_tests::RE, enum_flags<selftests::enum_flags_tests::RE2>, selfte
    sts::enum_flags_tests::RE2, enum_flags<selftests::enum_flags_tests::URE>, selftests::enum_flags_tests::URE, unsigned int>>::value == true':
    CHECK_VALID (true,  int,  true ? EF () : EF2 ())
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:91:3: note: expanded from macro 'CHECK_VALID'
      CHECK_VALID_EXPR_6 (EF, RE, EF2, RE2, UEF, URE, VALID, EXPR_TYPE, EXPR)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:105:3: note: expanded from macro 'CHECK_VALID_EXPR_6'
      CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2,           \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:66:3: note: expanded from macro 'CHECK_VALID_EXPR_INT'
      static_assert (gdb::is_detected_exact<archetype<TYPES, EXPR_TYPE>,    \
      ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a bit hard to decode, but basically enumerations have the
following funny property that they decay into a signed int, even if
their implicit underlying type is unsigned.  This code:

    enum A {};
    enum B {};

    int main() {
      std::cout << std::is_signed<std::underlying_type<A>::type>::value
                << std::endl;
      std::cout << std::is_signed<std::underlying_type<B>::type>::value
                << std::endl;
      auto result = true ? A() : B();
      std::cout << std::is_signed<decltype(result)>::value << std::endl;
    }

produces:

    0
    0
    1

So, the "CHECK_VALID" above checks that this property works for enum flags the
same way as it would if you were using their underlying enum types.  And
somehow, changing integer_for_size to use std::underlying_type breaks that.

Since the current code does what we want, and I don't see any way of doing it
differently, ignore -Wenum-constexpr-conversion around it.

(cherry picked from commit ae61525fcf)

Change-Id: Ibc82ae7bbdb812102ae3f1dd099fc859dc6f3cc2
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30423
Approved-By: Tom Tromey <tom@tromey.com>
2023-05-05 15:27:04 -04:00
GDB Administrator
1eee7aa650 Automatic date update in version.in 2023-05-05 00:00:57 +00:00
GDB Administrator
e3c9db5ea3 Automatic date update in version.in 2023-05-04 00:00:45 +00:00
GDB Administrator
6c6747bc53 Automatic date update in version.in 2023-05-03 00:01:18 +00:00
GDB Administrator
6a880a3ac0 Automatic date update in version.in 2023-05-02 00:01:02 +00:00
GDB Administrator
372e8383ca Automatic date update in version.in 2023-05-01 00:01:01 +00:00
GDB Administrator
3c79bd3620 Automatic date update in version.in 2023-04-30 00:00:56 +00:00
GDB Administrator
106c36ff21 Automatic date update in version.in 2023-04-29 00:01:09 +00:00
GDB Administrator
a49112870d Automatic date update in version.in 2023-04-28 00:00:53 +00:00
GDB Administrator
10765a6650 Automatic date update in version.in 2023-04-27 00:01:02 +00:00
GDB Administrator
81b693a4e7 Automatic date update in version.in 2023-04-26 00:01:07 +00:00
GDB Administrator
3c2fcf70d6 Automatic date update in version.in 2023-04-25 00:00:58 +00:00
GDB Administrator
e78b5e649a Automatic date update in version.in 2023-04-24 00:00:46 +00:00
GDB Administrator
08af75307f Automatic date update in version.in 2023-04-23 00:01:14 +00:00
WANG Rui
3310ec8b5b gdb: Fix false match issue in skip_prologue_using_linetable
[ Changes in v2:
  - rebase on trunk
  Changes in v3:
  - add test-case ]

We should exclude matches to the ending PC to prevent false matches with the
next function, as prologue_end is located at the end PC.

  <fun1>:
    0x00: ... <-- start_pc
    0x04: ...
    0x08: ... <-- breakpoint
    0x0c: ret
  <fun2>:
    0x10: ret <-- end_pc | prologue_end of fun2

Tested on x86_64-linux.

Co-Authored-By: WANG Rui <r@hev.cc> (fix, tiny change [1])
Co-Authored-By: Tom de Vries <tdevries@suse.de> (test-case)
Approved-by: Kevin Buettner <kevinb@redhat.com>

[1] https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html

PR symtab/30369
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30369
2023-04-22 09:33:45 +02:00
GDB Administrator
6f0d75747f Automatic date update in version.in 2023-04-22 00:00:37 +00:00
GDB Administrator
1c2960e25c Automatic date update in version.in 2023-04-21 00:00:41 +00:00
GDB Administrator
e907ecf5e0 Automatic date update in version.in 2023-04-20 00:00:36 +00:00
GDB Administrator
b89160c2d8 Automatic date update in version.in 2023-04-19 00:01:21 +00:00
Tom de Vries
69eedc8e31 [gdb/symtab] Handle empty file name in .debug_line section
With DWARF 5, it's possible to produce an empty file name in the File Name
Table of the .debug_line section:
...
 The File Name Table (offset 0x112, lines 1, columns 2):
  Entry Dir     Name
  0     1       (indirect line string, offset: 0x2d):
...

Currently, when gdb reads an exec containing such debug info, it segfaults:
...
Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
0x000000000072cd38 in dwarf2_start_subfile (cu=0x2badc50, fe=..., lh=...) at \
  gdb/dwarf2/read.c:18716
18716     if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
...
because read_direct_string transforms "" into a nullptr, and we end up
dereferencing the nullptr.

Note that the behaviour of read_direct_string has been present since repo
creation.

Fix this in read_formatted_entries, by transforming nullptr filenames in to ""
filenames.

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>

PR symtab/30357
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30357
2023-04-18 05:47:21 +02:00
GDB Administrator
05eafba441 Automatic date update in version.in 2023-04-18 00:01:13 +00:00
GDB Administrator
264563f173 Automatic date update in version.in 2023-04-17 00:00:58 +00:00
GDB Administrator
7559342d20 Automatic date update in version.in 2023-04-16 00:01:02 +00:00
GDB Administrator
3b8178bea2 Automatic date update in version.in 2023-04-15 00:00:56 +00:00
GDB Administrator
ae435ba3a4 Automatic date update in version.in 2023-04-14 00:00:56 +00:00
GDB Administrator
cb9fbf2694 Automatic date update in version.in 2023-04-13 00:00:37 +00:00
GDB Administrator
116524243e Automatic date update in version.in 2023-04-12 00:00:34 +00:00
GDB Administrator
7840e64290 Automatic date update in version.in 2023-04-11 00:00:34 +00:00
GDB Administrator
38e89bef80 Automatic date update in version.in 2023-04-10 00:00:55 +00:00
GDB Administrator
30c525d47f Automatic date update in version.in 2023-04-09 00:00:40 +00:00
GDB Administrator
35bcb4f14a Automatic date update in version.in 2023-04-08 00:00:50 +00:00
GDB Administrator
c35a7c837c Automatic date update in version.in 2023-04-07 00:00:31 +00:00
GDB Administrator
f67d203032 Automatic date update in version.in 2023-04-06 00:00:38 +00:00
GDB Administrator
efac80d4bd Automatic date update in version.in 2023-04-05 00:00:40 +00:00
GDB Administrator
b125afa290 Automatic date update in version.in 2023-04-04 00:00:37 +00:00
GDB Administrator
b7b17d806f Automatic date update in version.in 2023-04-03 00:00:33 +00:00
GDB Administrator
9e8f5b2aa0 Automatic date update in version.in 2023-04-02 00:00:27 +00:00
GDB Administrator
db944ee7c0 Automatic date update in version.in 2023-04-01 00:00:38 +00:00
GDB Administrator
0d09cb5369 Automatic date update in version.in 2023-03-31 00:00:53 +00:00
GDB Administrator
03e1f78fd5 Automatic date update in version.in 2023-03-30 00:00:31 +00:00
GDB Administrator
681f30742a Automatic date update in version.in 2023-03-29 00:00:35 +00:00
GDB Administrator
f20ed6a420 Automatic date update in version.in 2023-03-28 00:00:30 +00:00
GDB Administrator
8a0897f135 Automatic date update in version.in 2023-03-27 00:00:21 +00:00
GDB Administrator
83d67ba77a Automatic date update in version.in 2023-03-26 00:00:26 +00:00
GDB Administrator
913105ea21 Automatic date update in version.in 2023-03-25 00:00:32 +00:00
Luis Machado
b3eff3e155 aarch64: Check for valid inferior thread/regcache before reading pauth registers
There were reports of gdb throwing internal errors when calling
inferior_thread ()/get_current_regcache () on a system with
Pointer Authentication enabled.

In such cases, gdb produces the following backtrace, or a variation
of it (for gdb's with the non-address removal implemented only in
the aarch64-linux-tdep.c file).

../../../repos/binutils-gdb/gdb/thread.c:86: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0xaaaae04a571f gdb_internal_backtrace_1
        ../../../repos/binutils-gdb/gdb/bt-utils.c:122
0xaaaae04a57f3 _Z22gdb_internal_backtracev
        ../../../repos/binutils-gdb/gdb/bt-utils.c:168
0xaaaae0b52ccf internal_vproblem
        ../../../repos/binutils-gdb/gdb/utils.c:401
0xaaaae0b5310b _Z15internal_verrorPKciS0_St9__va_list
        ../../../repos/binutils-gdb/gdb/utils.c:481
0xaaaae0e24b8f _Z18internal_error_locPKciS0_z
        ../../../repos/binutils-gdb/gdbsupport/errors.cc:58
0xaaaae0a88983 _Z15inferior_threadv
        ../../../repos/binutils-gdb/gdb/thread.c:86
0xaaaae0956c87 _Z20get_current_regcachev
        ../../../repos/binutils-gdb/gdb/regcache.c:428
0xaaaae035223f aarch64_remove_non_address_bits
        ../../../repos/binutils-gdb/gdb/aarch64-tdep.c:3572
0xaaaae03e8abb _Z31gdbarch_remove_non_address_bitsP7gdbarchm
        ../../../repos/binutils-gdb/gdb/gdbarch.c:3109
0xaaaae0a692d7 memory_xfer_partial
        ../../../repos/binutils-gdb/gdb/target.c:1620
0xaaaae0a695e3 _Z19target_xfer_partialP10target_ops13target_objectPKcPhPKhmmPm
        ../../../repos/binutils-gdb/gdb/target.c:1684
0xaaaae0a69e9f target_read_partial
        ../../../repos/binutils-gdb/gdb/target.c:1937
0xaaaae0a69fdf _Z11target_readP10target_ops13target_objectPKcPhml
        ../../../repos/binutils-gdb/gdb/target.c:1977
0xaaaae0a69937 _Z18target_read_memorymPhl
        ../../../repos/binutils-gdb/gdb/target.c:1773
0xaaaae08be523 ps_xfer_memory
        ../../../repos/binutils-gdb/gdb/proc-service.c:90
0xaaaae08be6db ps_pdread
        ../../../repos/binutils-gdb/gdb/proc-service.c:124
0x40001ed7c3b3 _td_fetch_value
        /build/glibc-RIFKjK/glibc-2.31/nptl_db/fetch-value.c:115
0x40001ed791ef td_ta_map_lwp2thr
        /build/glibc-RIFKjK/glibc-2.31/nptl_db/td_ta_map_lwp2thr.c:194
0xaaaae07f4473 thread_from_lwp
        ../../../repos/binutils-gdb/gdb/linux-thread-db.c:413
0xaaaae07f6d6f _ZN16thread_db_target4waitE6ptid_tP17target_waitstatus10enum_flagsI16target_wait_flagE
        ../../../repos/binutils-gdb/gdb/linux-thread-db.c:1420
0xaaaae0a6b33b _Z11target_wait6ptid_tP17target_waitstatus10enum_flagsI16target_wait_flagE
        ../../../repos/binutils-gdb/gdb/target.c:2586
0xaaaae0789cf7 do_target_wait_1
        ../../../repos/binutils-gdb/gdb/infrun.c:3825
0xaaaae0789e6f operator()
        ../../../repos/binutils-gdb/gdb/infrun.c:3884
0xaaaae078a167 do_target_wait
        ../../../repos/binutils-gdb/gdb/infrun.c:3903
0xaaaae078b0af _Z20fetch_inferior_eventv
        ../../../repos/binutils-gdb/gdb/infrun.c:4314
0xaaaae076652f _Z22inferior_event_handler19inferior_event_type
        ../../../repos/binutils-gdb/gdb/inf-loop.c:41
0xaaaae07dc68b handle_target_event
        ../../../repos/binutils-gdb/gdb/linux-nat.c:4206
0xaaaae0e25fbb handle_file_event
        ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:573
0xaaaae0e264f3 gdb_wait_for_event
        ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:694
0xaaaae0e24f9b _Z16gdb_do_one_eventi
        ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:217
0xaaaae080f033 start_event_loop
        ../../../repos/binutils-gdb/gdb/main.c:411
0xaaaae080f1b7 captured_command_loop
        ../../../repos/binutils-gdb/gdb/main.c:475
0xaaaae0810b97 captured_main
        ../../../repos/binutils-gdb/gdb/main.c:1318
0xaaaae0810c1b _Z8gdb_mainP18captured_main_args
        ../../../repos/binutils-gdb/gdb/main.c:1337
0xaaaae0338453 main
        ../../../repos/binutils-gdb/gdb/gdb.c:32
---------------------
../../../repos/binutils-gdb/gdb/thread.c:86: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

We also see failures across the testsuite if the tests get executed on a target
that has native support for the pointer authentication feature. But
gdb.base/break.exp and gdb.base/access-mem-running.exp are two examples of
tests that run into errors and internal errors.

This issue started after commit d88cb738e6, which
enabled more broad use of pointer authentication masks to remove non-address
bits of pointers, but wasn't immediately detected because systems with native
support for pointer authentication are not that common yet.

The above crash happens because gdb is in the middle of handling an event,
and do_target_wait_1 calls switch_to_inferior_no_thread, nullifying the
current thread.  This means a call to inferior_thread () will assert, and
attempting to call get_current_regcache () will also call inferior_thread (),
resulting in an assertion as well.

target_has_registers was one function that seemed useful for detecting these
types of situation where we don't have a register cache. The problem with that
is the inconsistent state of inferior_ptid, which is used by
target_has_registers.

Despite the call to switch_to_no_thread in switch_to_inferior_no_thread from
do_target_wait_1 in the backtrace above clearing inferior_ptid, the call to
ps_xfer_memory sets inferior_ptid momentarily before reading memory:

static ps_err_e
ps_xfer_memory (const struct ps_prochandle *ph, psaddr_t addr,
                gdb_byte *buf, size_t len, int write)
{
  scoped_restore_current_inferior restore_inferior;
  set_current_inferior (ph->thread->inf);

  scoped_restore_current_program_space restore_current_progspace;
  set_current_program_space (ph->thread->inf->pspace);

  scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
  inferior_ptid = ph->thread->ptid;

  CORE_ADDR core_addr = ps_addr_to_core_addr (addr);

  int ret;
  if (write)
    ret = target_write_memory (core_addr, buf, len);
  else
    ret = target_read_memory (core_addr, buf, len);
  return (ret == 0 ? PS_OK : PS_ERR);
}

Maybe this shouldn't happen, or maybe it is just an unfortunate state to be
in. But this prevents the use of target_has_registers to guard against the
lack of registers, since, although current_thread_ is still nullptr,
inferior_ptid is valid and is not null_ptid.

There is another crash scenario after we kill a previously active inferior, in
which case the gdbarch will still say we support pointer authentication but we
will also have no current thread (inferior_thread () will assert etc).

If the target has support for pointer authentication, gdb needs to use
a couple (or 4, for bare-metal) mask registers to mask off some bits of
pointers, and for that it needs to access the registers.

At some points, like the one from the backtrace above, there is no active
thread/current regcache because gdb is in the middle of doing event handling
and switching between threads.

Simon suggested the use of inferior_ptid to fetch the register cache, as
opposed to relying on the current register cache.  Though we need to make sure
inferior_ptid is valid (not null_ptid), I think this works nicely.

With inferior_ptid, we can do safety checks along the way, making sure we have
a thread to fetch a register cache from and checking if the thread is actually
stopped or running.

The following patch implements this idea with safety checks to make sure we
don't run into assertions or errors.  If any of the checks fail, we fallback to
using a default mask to remove non-address bits of a pointer.

I discussed with Pedro the possibility of caching the mask register values
(which are per-process and can change mid-execution), but there isn't a good
spot to cache those values. Besides, the mask registers can change constantly
for bare-metal debugging when switching between exception levels.

In some cases, it is just not possible to get access to these mask registers,
like the case where threads are running. In those cases, using a default mask
to remove the non-address bits should be enough.

This can happen when we let threads run in the background and then we attempt
to access a memory address (now that gdb is capable of reading memory even
with threads running).  Thus gdb will attempt to remove non-address bits
of that memory access, will attempt to access registers, running into errors.

Regression-tested on aarch64-linux Ubuntu 20.04.
2023-03-24 12:36:49 +00:00
GDB Administrator
d0eff5dbcb Automatic date update in version.in 2023-03-24 00:00:59 +00:00
GDB Administrator
3cfee3b5cb Automatic date update in version.in 2023-03-23 00:01:22 +00:00
GDB Administrator
8067be0fc6 Automatic date update in version.in 2023-03-22 00:00:54 +00:00
GDB Administrator
404b84adaf Automatic date update in version.in 2023-03-21 00:01:13 +00:00
GDB Administrator
56ac43d472 Automatic date update in version.in 2023-03-20 00:01:07 +00:00
GDB Administrator
0079429826 Automatic date update in version.in 2023-03-19 00:00:57 +00:00
GDB Administrator
502154cc76 Automatic date update in version.in 2023-03-18 00:01:12 +00:00
GDB Administrator
0c8d88bd9d Automatic date update in version.in 2023-03-17 00:00:49 +00:00
GDB Administrator
6dde7de287 Automatic date update in version.in 2023-03-16 00:01:15 +00:00
GDB Administrator
4947ba8ce9 Automatic date update in version.in 2023-03-15 00:01:07 +00:00
GDB Administrator
c866f18f05 Automatic date update in version.in 2023-03-14 00:01:31 +00:00
Tom Tromey
562403d4f5 Fix crash in inside_main_func
gdb 13.1 crashes while running the rust compiler's debugger tests.
The crash has a number of causes.

First, the rust compiler still uses the C++-like _Z mangling, but with
its own twist -- some hex digits added to the end of a symbol.  So,
while gdb finds the correct name of "main":

(top-gdb) p name
$13 = 0x292e0c0 "rustc_gdb_1031745::main"

It isn't found in the minsyms, because C++ demangling yields:

[99] t 0x90c0 _ZN17rustc_gdb_10317454main17h5b5be7fe16a97225E section .text  rustc_gdb_1031745::main::h5b5be7fe16a97225  zko06yobckx336v

This could perhaps be fixed.  I also filed a new PR to suggest
preferring the linkage name of the main program.

Next, the rust compiler emits both a DW_TAG_subprogram and a
DW_TAG_namespace for "main".  This happens because the file is named
"main.rs" -- i.e., the bug is specific to the source file name.  The
crash also seems to require the nested function inside of 'main', at
least for me.  The namespace always is generated, but perhaps this
changes the ordering in the DWARF.

When inside_main_func looks up the main symbol, it finds the namespace
symbol rather than the function.  (I filed a bug about fixing gdb's
symbol tables -- long overdue.)

Meanwhile, as I think it's important to fix this crash sooner rather
than later, this patch changes inside_main_func to check that the
symbol that is found is LOC_BLOCK.  This perhaps should have been done
in the first place, anyway.

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

(cherry picked from commit 5f056fcb3d)
2023-03-13 14:19:21 -06:00
GDB Administrator
792b1fd5a8 Automatic date update in version.in 2023-03-13 00:00:50 +00:00
GDB Administrator
f06873510d Automatic date update in version.in 2023-03-12 00:01:03 +00:00
GDB Administrator
b40137baaf Automatic date update in version.in 2023-03-11 00:00:59 +00:00
John Baldwin
a980a7d24b PR gdb/30214: Prefer local include paths to system include paths
Some systems may install binutils headers into a system location
(e.g. /usr/local/include on FreeBSD) which may also include headers
for other external packages used by GDB such as zlib or zstd.  If a
system include path such as /usr/local/include is added before local
include paths to directories within a clone or release tarball, then
headers from the external binutils package are used which can result
in build failures if the external binutils package is out of sync with
the version of GDB being built.

To fix, sort the include paths in INTERNAL_CFLAGS_BASE to add CFLAGS
for "local" componenets before external components.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30214
Reviewed-By: Tom Tromey <tom@tromey.com>
(cherry picked from commit a2fbb69038)
2023-03-10 12:06:42 -08:00
GDB Administrator
cb7fd28390 Automatic date update in version.in 2023-03-10 00:01:11 +00:00
GDB Administrator
885ab3db98 Automatic date update in version.in 2023-03-09 00:00:51 +00:00
GDB Administrator
b7d1a75ca7 Automatic date update in version.in 2023-03-08 00:01:01 +00:00
GDB Administrator
8487291757 Automatic date update in version.in 2023-03-07 00:01:33 +00:00
GDB Administrator
e54175bd12 Automatic date update in version.in 2023-03-06 00:00:58 +00:00
GDB Administrator
de76b54b28 Automatic date update in version.in 2023-03-05 00:00:57 +00:00
GDB Administrator
cb3c6519cd Automatic date update in version.in 2023-03-04 00:00:59 +00:00
GDB Administrator
31b17e2106 Automatic date update in version.in 2023-03-03 00:00:53 +00:00
GDB Administrator
76e8b48e86 Automatic date update in version.in 2023-03-02 00:01:02 +00:00
GDB Administrator
a003e63803 Automatic date update in version.in 2023-03-01 00:01:20 +00:00
GDB Administrator
a9dc6b99c1 Automatic date update in version.in 2023-02-28 00:00:59 +00:00
GDB Administrator
864009de89 Automatic date update in version.in 2023-02-27 00:00:33 +00:00
GDB Administrator
bc8af55ae5 Automatic date update in version.in 2023-02-26 00:00:33 +00:00
GDB Administrator
a55702108f Automatic date update in version.in 2023-02-25 00:00:33 +00:00
GDB Administrator
812ca62301 Automatic date update in version.in 2023-02-24 00:00:38 +00:00
GDB Administrator
da8e6a5da0 Automatic date update in version.in 2023-02-23 00:00:51 +00:00
GDB Administrator
d17e9c8c97 Automatic date update in version.in 2023-02-22 00:01:10 +00:00
GDB Administrator
0426ba8f52 Automatic date update in version.in 2023-02-21 00:00:44 +00:00
GDB Administrator
c0af3c5630 Automatic date update in version.in 2023-02-20 00:00:33 +00:00
Joel Brobecker
1d2740610c Bump GDB's version number to 13.1.90.DATE-git.
This commit changes gdb/version.in to 13.1.90.DATE-git.

This commit also makes the following changes in gdb/testsuite:

	* gdb.base/default.exp: Change $_gdb_minor to 2.
2023-02-19 18:00:08 +04:00
20 changed files with 479 additions and 31 deletions

View File

@@ -16,7 +16,7 @@
In releases, the date is not included in either version strings or
sonames. */
#define BFD_VERSION_DATE 20230219
#define BFD_VERSION_DATE 20230527
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
#define REPORT_BUGS_TO @report_bugs_to@

View File

@@ -629,8 +629,8 @@ INTERNAL_CPPFLAGS = $(CPPFLAGS) @GUILE_CPPFLAGS@ @PYTHON_CPPFLAGS@ \
# INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
INTERNAL_CFLAGS_BASE = \
$(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \
$(ZSTD_CFLAGS) $(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(BFD_CFLAGS) $(INCLUDE_CFLAGS) \
$(READLINE_CFLAGS) $(ZLIBINC) $(ZSTD_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
$(INTL_CFLAGS) $(INCGNU) $(INCSUPPORT) $(LIBBACKTRACE_INC) \
$(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS) $(SRCHIGH_CFLAGS) \
$(TOP_CFLAGS) $(PTHREAD_CFLAGS) $(DEBUGINFOD_CFLAGS)

View File

@@ -57,6 +57,9 @@
#include "elf/common.h"
#include "elf/aarch64.h"
/* For inferior_ptid and current_inferior (). */
#include "inferior.h"
/* Signal frame handling.
+------------+ ^
@@ -1986,29 +1989,60 @@ aarch64_linux_decode_memtag_section (struct gdbarch *gdbarch,
static CORE_ADDR
aarch64_remove_non_address_bits (struct gdbarch *gdbarch, CORE_ADDR pointer)
{
aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
/* By default, we assume TBI and discard the top 8 bits plus the VA range
select bit (55). */
select bit (55). Below we try to fetch information about pointer
authentication masks in order to make non-address removal more
precise. */
CORE_ADDR mask = AARCH64_TOP_BITS_MASK;
if (tdep->has_pauth ())
/* Check if we have an inferior first. If not, just use the default
mask.
We use the inferior_ptid here because the pointer authentication masks
should be the same across threads of a process. Since we may not have
access to the current thread (gdb may have switched to no inferiors
momentarily), we use the inferior ptid. */
if (inferior_ptid != null_ptid)
{
/* Fetch the PAC masks. These masks are per-process, so we can just
fetch data from whatever thread we have at the moment.
/* If we do have an inferior, attempt to fetch its thread's thread_info
struct. */
thread_info *thread
= find_thread_ptid (current_inferior ()->process_target (),
inferior_ptid);
Also, we have both a code mask and a data mask. For now they are the
same, but this may change in the future. */
struct regcache *regs = get_current_regcache ();
CORE_ADDR cmask, dmask;
/* If the thread is running, we will not be able to fetch the mask
registers. */
if (thread != nullptr && thread->state != THREAD_RUNNING)
{
/* Otherwise, fetch the register cache and the masks. */
struct regcache *regs
= get_thread_regcache (current_inferior ()->process_target (),
inferior_ptid);
if (regs->cooked_read (tdep->pauth_reg_base, &dmask) != REG_VALID)
dmask = mask;
/* Use the gdbarch from the register cache to check for pointer
authentication support, as it matches the features found in
that particular thread. */
aarch64_gdbarch_tdep *tdep
= gdbarch_tdep<aarch64_gdbarch_tdep> (regs->arch ());
if (regs->cooked_read (tdep->pauth_reg_base + 1, &cmask) != REG_VALID)
cmask = mask;
/* Is there pointer authentication support? */
if (tdep->has_pauth ())
{
/* We have both a code mask and a data mask. For now they are
the same, but this may change in the future. */
CORE_ADDR cmask, dmask;
mask |= aarch64_mask_from_pac_registers (cmask, dmask);
if (regs->cooked_read (tdep->pauth_reg_base, &dmask)
!= REG_VALID)
dmask = mask;
if (regs->cooked_read (tdep->pauth_reg_base + 1, &cmask)
!= REG_VALID)
cmask = mask;
mask |= aarch64_mask_from_pac_registers (cmask, dmask);
}
}
}
return aarch64_remove_top_bits (pointer, mask);

View File

@@ -215,6 +215,10 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
break;
}
/* Normalize nullptr string. */
if (string.has_value () && *string == nullptr)
string.emplace ("");
switch (content_type)
{
case DW_LNCT_path:

View File

@@ -18550,9 +18550,8 @@ cooked_indexer::make_index (cutu_reader *reader)
for (const auto &entry : m_deferred_entries)
{
CORE_ADDR key = form_addr (entry.die_offset, m_per_cu->is_dwz);
cooked_index_entry *parent
= (cooked_index_entry *) m_die_range_map.find (key);
void *obj = m_die_range_map.find (entry.spec_offset);
cooked_index_entry *parent = static_cast<cooked_index_entry *> (obj);
m_index_storage->add (entry.die_offset, entry.tag, entry.flags,
entry.name, parent, m_per_cu);
}

View File

@@ -2453,6 +2453,14 @@ inside_main_func (frame_info_ptr this_frame)
if (bs.symbol == nullptr)
return false;
/* We might have found some unrelated symbol. For example, the
Rust compiler can emit both a subprogram and a namespace with
the same name in the same scope; and due to how gdb's symbol
tables currently work, we can't request the one we'd
prefer. */
if (bs.symbol->aclass () != LOC_BLOCK)
return false;
const struct block *block = bs.symbol->value_block ();
gdb_assert (block != nullptr);
sym_addr = block->start ();

View File

@@ -3735,7 +3735,7 @@ skip_prologue_using_linetable (CORE_ADDR func_addr)
});
for (;
it < linetable->item + linetable->nitems && it->pc <= end_pc;
it < linetable->item + linetable->nitems && it->pc < end_pc;
it++)
if (it->prologue_end)
return {it->pc};

View File

@@ -607,7 +607,7 @@ set show_conv_list \
{$_gdb_setting_str = <internal function _gdb_setting_str>} \
{$_gdb_setting = <internal function _gdb_setting>} \
{$_gdb_major = 13} \
{$_gdb_minor = 1} \
{$_gdb_minor = 2} \
{$_shell_exitsignal = void} \
{$_shell_exitcode = 0} \
}

View File

@@ -0,0 +1,70 @@
# Copyright 2023 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that an empty file name in the .debug_line section doesn't cause
# problems.
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
return 0
}
# The .c files use __attribute__.
if ![is_c_compiler_gcc] {
return 0
}
standard_testfile main.c -dw.S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
declare_labels Llines
global srcdir subdir srcfile
cu { version 5 } {
compile_unit {
{language @DW_LANG_C}
{name $srcfile}
{stmt_list $Llines DW_FORM_sec_offset}
} {
subprogram {
{external 1 flag}
{MACRO_AT_func {main}}
}
}
}
lines {version 5} Llines {
include_dir "${srcdir}/${subdir}"
file_name "" 1
}
}
if { [build_executable "failed to prepare" ${testfile} \
[list $srcfile $asm_file] {nodebug}] } {
return -1
}
clean_restart
# If there's an ERROR during gdb_load, the assert will produce an UNRESOLVED
# rather than a FAIL.
gdb_assert { [gdb_load $binfile] == 0 }
# But this will produce an actual FAIL, which is more visible than
# ERROR/UNRESOLVED.
gdb_assert { [info exists gdb_spawn_id] }

View File

@@ -0,0 +1,30 @@
/* Copyright 2023 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
int
main (void)
{
int main = 1; /* Main body. */
asm ("foo_label: .global foo_label");
int foo = 2; /* Foo body. */
asm ("foo_end: .global foo_end");
asm ("bar_label: .global bar_label");
int bar = 3; /* Bar body. */
asm ("bar_end: .global bar_end");
return main + foo + bar;
}

View File

@@ -0,0 +1,120 @@
# Copyright 2023 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that prologue analysis in foo is correct in the presence of a
# prologue_end marker in immediately following function bar.
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
return 0
}
standard_testfile .c .S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
global srcdir subdir srcfile srcfile2
declare_labels lines_label
cu {} {
compile_unit {
{language @DW_LANG_C}
{name dw2-prologue-end.c}
{stmt_list ${lines_label} DW_FORM_sec_offset}
} {
subprogram {
{external 1 flag}
{name foo}
{low_pc foo_label addr}
{high_pc foo_end addr}
}
subprogram {
{external 1 flag}
{name bar}
{low_pc bar_label addr}
{high_pc bar_end addr}
}
}
}
lines {version 5} lines_label {
set diridx [include_dir "${srcdir}/${subdir}"]
file_name "$srcfile" $diridx
program {
DW_LNS_set_file $diridx
DW_LNE_set_address foo_label
line [gdb_get_line_number "Foo body"]
DW_LNS_copy
DW_LNE_set_address bar_label
DW_LNS_set_prologue_end
line [gdb_get_line_number "Bar body"]
DW_LNS_copy
DW_LNE_set_address bar_end
DW_LNE_end_sequence
}
}
}
if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile $asm_file] {nodebug}] } {
return -1
}
# Don't runto main here, otherwise the following doesn't
# function as regression test for PR30369.
# Get the "break foo" address.
set break_addr ""
gdb_test_multiple "break foo" "" {
-re -wrap "at ($hex):\[^\r\n\]*" {
set break_addr $expect_out(1,string)
pass $gdb_test_name
}
}
if { $break_addr == "" } {
return
}
# Get the "foo_label" address.
set foo_label_addr ""
gdb_test_multiple "print /x &foo_label" "" {
-re -wrap "= ($hex)" {
set foo_label_addr $expect_out(1,string)
pass $gdb_test_name
}
}
if { $foo_label_addr == "" } {
return
}
# Check that bar immediately follows foo. Otherwise the following doesn't
# function as regression test for PR30369.
gdb_test "print &foo_end == &bar_label" " = 1"
# Check that the breakpoint is set at the expected address. Regression test
# for PR30369.
gdb_assert { $break_addr == $foo_label_addr }

View File

@@ -0,0 +1,104 @@
# Copyright 2023 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that the DWARF reader works with a a DW_AT_specification that
# refers to a later DIE.
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
return 0
}
standard_testfile main.c -debug.S
# Set up the DWARF for the test.
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
global srcfile
cu {} {
DW_TAG_compile_unit {
{DW_AT_language @DW_LANG_C_plus_plus}
{DW_AT_name $srcfile}
{DW_AT_comp_dir /tmp}
} {
declare_labels spec myint
# The new indexer has special code to compute the full
# name of an object that uses a specification that appears
# later in the DWARF.
DW_TAG_variable {
{DW_AT_specification :$spec}
{DW_AT_location {
DW_OP_const1u 23
DW_OP_stack_value
} SPECIAL_expr}
}
myint: DW_TAG_base_type {
{DW_AT_byte_size 4 DW_FORM_sdata}
{DW_AT_encoding @DW_ATE_signed}
{DW_AT_name myint}
}
DW_TAG_namespace {
{DW_AT_name ns}
} {
spec: DW_TAG_variable {
{DW_AT_name v}
{DW_AT_type :$myint}
{DW_AT_declaration 1 DW_FORM_flag_present}
}
}
}
}
}
if {[prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile $asm_file] {nodebug}]} {
return -1
}
set in_v 0
gdb_test_multiple "maint print objfiles" "v has a parent" {
-re "^ *\\\[\[0-9\]\\\] *..cooked_index_entry\[^\r\n\]*" {
set in_v 0
exp_continue
}
-re "^ *name: *v\[\r\n\]*" {
set in_v 1
exp_continue
}
-re "^ *parent: *..cooked_index_entry .. (0|$hex)." {
if {$in_v} {
if {$expect_out(1,string) == "0"} {
fail $gdb_test_name
} else {
pass $gdb_test_name
}
set in_v 0
}
exp_continue
}
-re "^\[^\r\n\]*\[\r\n\]+" {
exp_continue
}
-re "$gdb_prompt " {
# Done.
}
}

View File

@@ -0,0 +1,35 @@
# Copyright (C) 2023 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Regression test for a crash in inside_main_func.
load_lib rust-support.exp
if {[skip_rust_tests]} { return }
standard_testfile main.rs
if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
{debug rust}]} {
return -1
}
set line [gdb_get_line_number "BREAK"]
# The bug was that this would crash.
if {![runto ${srcfile}:$line]} {
untested "could not run to breakpoint"
return -1
}
# Test that gdb is alive.
gdb_test "print 23" " = 23"

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2016-2023 Free Software Foundation, Inc.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
fn global_fn(x: u8) {
// BREAK
}
fn main() {
fn nested(y: u8) {
global_fn(y)
}
nested(23);
}

View File

@@ -587,6 +587,8 @@ execute_command (const char *p, int from_tty)
return;
}
std::string cmd_copy = p;
target_log_command (p);
while (*p == ' ' || *p == '\t')
@@ -693,7 +695,7 @@ execute_command (const char *p, int from_tty)
We need to lookup the command again since during its execution,
a command may redefine itself. In this case, C pointer
becomes invalid so we need to look it up again. */
const char *cmd2 = cmd_start;
const char *cmd2 = cmd_copy.c_str ();
c = lookup_cmd (&cmd2, cmdlist, "", nullptr, 1, 1);
if (c != nullptr)
execute_cmd_post_hook (c);

View File

@@ -1 +1 @@
13.1
13.2

View File

@@ -98,11 +98,11 @@ struct z80_unwind_cache
struct
{
int called:1; /* there is return address on stack */
int load_args:1; /* prologues loads args using POPs */
int fp_sdcc:1; /* prologue saves and adjusts frame pointer IX */
int interrupt:1; /* __interrupt handler */
int critical:1; /* __critical function */
unsigned int called : 1; /* there is return address on stack */
unsigned int load_args : 1; /* prologues loads args using POPs */
unsigned int fp_sdcc : 1; /* prologue saves and adjusts frame pointer IX */
unsigned int interrupt : 1; /* __interrupt handler */
unsigned int critical : 1; /* __critical function */
} prologue_type;
/* Table indicating the location of each and every register. */

View File

@@ -5390,7 +5390,7 @@ proc_xfer_memory (CORE_ADDR memaddr, unsigned char *readbuf,
if (lseek (fd, memaddr, SEEK_SET) != -1)
bytes = (readbuf != nullptr
? read (fd, readbuf, len)
? write (fd, writebuf, len));
: write (fd, writebuf, len));
#endif
if (bytes < 0)

View File

@@ -91,9 +91,12 @@ template<> struct integer_for_size<8, 1> { typedef int64_t type; };
template<typename T>
struct enum_underlying_type
{
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
typedef typename
integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
type;
DIAGNOSTIC_POP
};
namespace enum_flags_detail

View File

@@ -76,6 +76,11 @@
# define DIAGNOSTIC_ERROR_SWITCH \
DIAGNOSTIC_ERROR ("-Wswitch")
# if __has_warning ("-Wenum-constexpr-conversion")
# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \
DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion")
# endif
#elif defined (__GNUC__) /* GCC */
# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
@@ -155,4 +160,8 @@
# define DIAGNOSTIC_ERROR_SWITCH
#endif
#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
#endif
#endif /* DIAGNOSTICS_H */