|
|
79b363 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
79b363 |
From: Keith Seitz <keiths@redhat.com>
|
|
|
79b363 |
Date: Wed, 26 Jan 2022 08:56:18 -0800
|
|
|
79b363 |
Subject: gdb-rhbz2042257-ftbs-updates.patch
|
|
|
79b363 |
MIME-Version: 1.0
|
|
|
79b363 |
Content-Type: text/plain; charset=UTF-8
|
|
|
79b363 |
Content-Transfer-Encoding: 8bit
|
|
|
79b363 |
|
|
|
79b363 |
;; Fix build problems.
|
|
|
79b363 |
;; (RHBZ 2042257, Keith Seitz, Andrew Burgess)
|
|
|
79b363 |
|
|
|
79b363 |
1) Reference array of structs instead of first member during memcpy
|
|
|
79b363 |
|
|
|
79b363 |
aarch64-tdep.c defines the following macro:
|
|
|
79b363 |
|
|
|
79b363 |
do \
|
|
|
79b363 |
{ \
|
|
|
79b363 |
unsigned int mem_len = LENGTH; \
|
|
|
79b363 |
if (mem_len) \
|
|
|
79b363 |
{ \
|
|
|
79b363 |
MEMS = XNEWVEC (struct aarch64_mem_r, mem_len); \
|
|
|
79b363 |
memcpy(&MEMS->len, &RECORD_BUF[0], \
|
|
|
79b363 |
sizeof(struct aarch64_mem_r) * LENGTH); \
|
|
|
79b363 |
} \
|
|
|
79b363 |
} \
|
|
|
79b363 |
while (0)
|
|
|
79b363 |
|
|
|
79b363 |
This is simlpy allocating a new array and copying it. However, for
|
|
|
79b363 |
the destination address, it is actually copying into the first member
|
|
|
79b363 |
of the first element of the array (`&MEMS->len"). This elicits a
|
|
|
79b363 |
warning with GCC 12:
|
|
|
79b363 |
|
|
|
79b363 |
../../binutils-gdb/gdb/aarch64-tdep.c: In function ‘int aarch64_process_record(gdbarch*, regcache*, CORE_ADDR)’:
|
|
|
79b363 |
../../binutils-gdb/gdb/aarch64-tdep.c:3711:23: error: writing 16 bytes into a region of size 8 [-Werror=stringop-overflow=]
|
|
|
79b363 |
3711 | memcpy(&MEMS->len, &RECORD_BUF[0], \
|
|
|
79b363 |
| ^
|
|
|
79b363 |
../../binutils-gdb/gdb/aarch64-tdep.c:4394:3: note: in expansion of macro ‘MEM_ALLOC’
|
|
|
79b363 |
4394 | MEM_ALLOC (aarch64_insn_r->aarch64_mems, aarch64_insn_r->mem_rec_count,
|
|
|
79b363 |
| ^~~~~~~~~
|
|
|
79b363 |
../../binutils-gdb/gdb/aarch64-tdep.c:3721:12: note: destination object ‘aarch64_mem_r::len’ of size 8
|
|
|
79b363 |
3721 | uint64_t len; /* Record length. */
|
|
|
79b363 |
| ^~~
|
|
|
79b363 |
|
|
|
79b363 |
The simple fix is to reference the array, `MEMS' as the destination of the copy.
|
|
|
79b363 |
|
|
|
79b363 |
Tested by rebuilding.
|
|
|
79b363 |
|
|
|
79b363 |
2) Fix build with current GCC: EL_EXPLICIT(location) always non-NULL
|
|
|
79b363 |
|
|
|
79b363 |
Compiling GDB with current GCC (1b4a63593b) runs into this:
|
|
|
79b363 |
|
|
|
79b363 |
src/gdb/location.c: In function 'int event_location_empty_p(const event_location*)':
|
|
|
79b363 |
src/gdb/location.c:963:38: error: the address of 'event_location::<unnamed union>::explicit_loc' will never be NULL [-Werror=address]
|
|
|
79b363 |
963 | return (EL_EXPLICIT (location) == NULL
|
|
|
79b363 |
| ^
|
|
|
79b363 |
src/gdb/location.c:57:30: note: 'event_location::<unnamed union>::explicit_loc' declared here
|
|
|
79b363 |
57 | struct explicit_location explicit_loc;
|
|
|
79b363 |
| ^~~~~~~~~~~~
|
|
|
79b363 |
|
|
|
79b363 |
GCC is right, EL_EXPLICIT is defined as returning the address of an
|
|
|
79b363 |
union field:
|
|
|
79b363 |
|
|
|
79b363 |
/* An explicit location. */
|
|
|
79b363 |
struct explicit_location explicit_loc;
|
|
|
79b363 |
#define EL_EXPLICIT(P) (&((P)->u.explicit_loc))
|
|
|
79b363 |
|
|
|
79b363 |
and thus must always be non-NULL.
|
|
|
79b363 |
|
|
|
79b363 |
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
|
|
|
79b363 |
--- a/gdb/aarch64-tdep.c
|
|
|
79b363 |
+++ b/gdb/aarch64-tdep.c
|
|
|
79b363 |
@@ -3666,7 +3666,7 @@ When on, AArch64 specific debugging is enabled."),
|
|
|
79b363 |
if (mem_len) \
|
|
|
79b363 |
{ \
|
|
|
79b363 |
MEMS = XNEWVEC (struct aarch64_mem_r, mem_len); \
|
|
|
79b363 |
- memcpy(&MEMS->len, &RECORD_BUF[0], \
|
|
|
79b363 |
+ memcpy(MEMS, &RECORD_BUF[0], \
|
|
|
79b363 |
sizeof(struct aarch64_mem_r) * LENGTH); \
|
|
|
79b363 |
} \
|
|
|
79b363 |
} \
|
|
|
79b363 |
diff --git a/gdb/location.c b/gdb/location.c
|
|
|
79b363 |
--- a/gdb/location.c
|
|
|
79b363 |
+++ b/gdb/location.c
|
|
|
79b363 |
@@ -960,12 +960,11 @@ event_location_empty_p (const struct event_location *location)
|
|
|
79b363 |
return 0;
|
|
|
79b363 |
|
|
|
79b363 |
case EXPLICIT_LOCATION:
|
|
|
79b363 |
- return (EL_EXPLICIT (location) == NULL
|
|
|
79b363 |
- || (EL_EXPLICIT (location)->source_filename == NULL
|
|
|
79b363 |
- && EL_EXPLICIT (location)->function_name == NULL
|
|
|
79b363 |
- && EL_EXPLICIT (location)->label_name == NULL
|
|
|
79b363 |
- && (EL_EXPLICIT (location)->line_offset.sign
|
|
|
79b363 |
- == LINE_OFFSET_UNKNOWN)));
|
|
|
79b363 |
+ return (EL_EXPLICIT (location)->source_filename == NULL
|
|
|
79b363 |
+ && EL_EXPLICIT (location)->function_name == NULL
|
|
|
79b363 |
+ && EL_EXPLICIT (location)->label_name == NULL
|
|
|
79b363 |
+ && (EL_EXPLICIT (location)->line_offset.sign
|
|
|
79b363 |
+ == LINE_OFFSET_UNKNOWN));
|
|
|
79b363 |
|
|
|
79b363 |
case PROBE_LOCATION:
|
|
|
79b363 |
return EL_PROBE (location) == NULL;
|