Sync from SUSE:SLFO:Main gdb revision 2fe8218ba81a6662b6bfb745dc698c31
This commit is contained in:
parent
3930d7f403
commit
8eb1fded12
@ -1,50 +0,0 @@
|
||||
From 0f363ed540fef466f45eab4570c23853e1f14898 Mon Sep 17 00:00:00 2001
|
||||
From: Roland McGrath <mcgrathr@google.com>
|
||||
Date: Thu, 9 Feb 2023 10:47:17 -0800
|
||||
Subject: [PATCH] [aarch64] Avoid initializers for VLAs
|
||||
|
||||
Clang doesn't accept initializer syntax for variable-length
|
||||
arrays in C. Just use memset instead.
|
||||
---
|
||||
gdb/aarch64-linux-nat.c | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
|
||||
index e4158236db2..ecb2eeb9540 100644
|
||||
--- a/gdb/aarch64-linux-nat.c
|
||||
+++ b/gdb/aarch64-linux-nat.c
|
||||
@@ -56,6 +56,8 @@
|
||||
|
||||
#include "nat/aarch64-mte-linux-ptrace.h"
|
||||
|
||||
+#include <string.h>
|
||||
+
|
||||
#ifndef TRAP_HWBKPT
|
||||
#define TRAP_HWBKPT 0x0004
|
||||
#endif
|
||||
@@ -445,7 +447,9 @@ fetch_tlsregs_from_thread (struct regcache *regcache)
|
||||
gdb_assert (regno != -1);
|
||||
gdb_assert (tdep->tls_register_count > 0);
|
||||
|
||||
- uint64_t tpidrs[tdep->tls_register_count] = { 0 };
|
||||
+ uint64_t tpidrs[tdep->tls_register_count];
|
||||
+ memset(tpidrs, 0, sizeof(tpidrs));
|
||||
+
|
||||
struct iovec iovec;
|
||||
iovec.iov_base = tpidrs;
|
||||
iovec.iov_len = sizeof (tpidrs);
|
||||
@@ -471,7 +475,8 @@ store_tlsregs_to_thread (struct regcache *regcache)
|
||||
gdb_assert (regno != -1);
|
||||
gdb_assert (tdep->tls_register_count > 0);
|
||||
|
||||
- uint64_t tpidrs[tdep->tls_register_count] = { 0 };
|
||||
+ uint64_t tpidrs[tdep->tls_register_count];
|
||||
+ memset(tpidrs, 0, sizeof(tpidrs));
|
||||
|
||||
for (int i = 0; i < tdep->tls_register_count; i++)
|
||||
{
|
||||
|
||||
base-commit: a39101060cdf2ee239833106fb3bdf9585f858aa
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,202 +0,0 @@
|
||||
From 4e0e7ff14ba271576232160bf337639662a2ea23 Mon Sep 17 00:00:00 2001
|
||||
From: Tom Tromey <tom@tromey.com>
|
||||
Date: Thu, 16 Feb 2023 17:36:29 -0700
|
||||
Subject: [PATCH 2/3] Avoid manual memory management in go-lang.c
|
||||
|
||||
I noticed a couple of spots in go-lang.c that could be improved by
|
||||
using unique_ptr.
|
||||
|
||||
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
|
||||
---
|
||||
gdb/dwarf2/read.c | 2 +-
|
||||
gdb/go-exp.c | 287 +++++++++++++++++++++++-----------------------
|
||||
gdb/go-exp.y | 8 +-
|
||||
gdb/go-lang.c | 40 +++----
|
||||
gdb/go-lang.h | 11 +-
|
||||
5 files changed, 173 insertions(+), 175 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 8aa7f8c31e5..61f4bd75013 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -7890,7 +7890,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
|
||||
&& sym->aclass () == LOC_BLOCK)
|
||||
{
|
||||
gdb::unique_xmalloc_ptr<char> this_package_name
|
||||
- (go_symbol_package_name (sym));
|
||||
+ = go_symbol_package_name (sym);
|
||||
|
||||
if (this_package_name == NULL)
|
||||
continue;
|
||||
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
|
||||
index cbaa79ee18c..542a06d06d6 100644
|
||||
--- a/gdb/go-exp.y
|
||||
+++ b/gdb/go-exp.y
|
||||
@@ -1393,16 +1393,16 @@ classify_name (struct parser_state *par_state, const struct block *block)
|
||||
current package. */
|
||||
|
||||
{
|
||||
- char *current_package_name = go_block_package_name (block);
|
||||
+ gdb::unique_xmalloc_ptr<char> current_package_name
|
||||
+ = go_block_package_name (block);
|
||||
|
||||
if (current_package_name != NULL)
|
||||
{
|
||||
struct stoken sval =
|
||||
- build_packaged_name (current_package_name,
|
||||
- strlen (current_package_name),
|
||||
+ build_packaged_name (current_package_name.get (),
|
||||
+ strlen (current_package_name.get ()),
|
||||
copy.c_str (), copy.size ());
|
||||
|
||||
- xfree (current_package_name);
|
||||
sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN,
|
||||
&is_a_field_of_this);
|
||||
if (sym.symbol)
|
||||
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
|
||||
index 7549f14dc63..f9176ace71d 100644
|
||||
--- a/gdb/go-lang.c
|
||||
+++ b/gdb/go-lang.c
|
||||
@@ -163,11 +163,8 @@ unpack_package_and_object (char *buf,
|
||||
|
||||
Space for the resulting strings is malloc'd in one buffer.
|
||||
PACKAGEP,OBJECTP,METHOD_TYPE* will (typically) point into this buffer.
|
||||
- [There are a few exceptions, but the caller is still responsible for
|
||||
- freeing the resulting pointer.]
|
||||
A pointer to this buffer is returned, or NULL if symbol isn't a
|
||||
mangled Go symbol.
|
||||
- The caller is responsible for freeing the result.
|
||||
|
||||
*METHOD_TYPE_IS_POINTERP is set to a boolean indicating if
|
||||
the method type is a pointer.
|
||||
@@ -180,7 +177,7 @@ unpack_package_and_object (char *buf,
|
||||
If we ever need to unpack the method type, this routine should work
|
||||
for that too. */
|
||||
|
||||
-static char *
|
||||
+static gdb::unique_xmalloc_ptr<char>
|
||||
unpack_mangled_go_symbol (const char *mangled_name,
|
||||
const char **packagep,
|
||||
const char **objectp,
|
||||
@@ -209,9 +206,10 @@ unpack_mangled_go_symbol (const char *mangled_name,
|
||||
/* main.init is mangled specially. */
|
||||
if (strcmp (mangled_name, "__go_init_main") == 0)
|
||||
{
|
||||
- char *package = xstrdup ("main");
|
||||
+ gdb::unique_xmalloc_ptr<char> package
|
||||
+ = make_unique_xstrdup ("main");
|
||||
|
||||
- *packagep = package;
|
||||
+ *packagep = package.get ();
|
||||
*objectp = "init";
|
||||
return package;
|
||||
}
|
||||
@@ -219,9 +217,10 @@ unpack_mangled_go_symbol (const char *mangled_name,
|
||||
/* main.main is mangled specially (missing prefix). */
|
||||
if (strcmp (mangled_name, "main.main") == 0)
|
||||
{
|
||||
- char *package = xstrdup ("main");
|
||||
+ gdb::unique_xmalloc_ptr<char> package
|
||||
+ = make_unique_xstrdup ("main");
|
||||
|
||||
- *packagep = package;
|
||||
+ *packagep = package.get ();
|
||||
*objectp = "main";
|
||||
return package;
|
||||
}
|
||||
@@ -261,7 +260,8 @@ unpack_mangled_go_symbol (const char *mangled_name,
|
||||
|
||||
/* At this point we've decided we have a mangled Go symbol. */
|
||||
|
||||
- buf = xstrdup (mangled_name);
|
||||
+ gdb::unique_xmalloc_ptr<char> result = make_unique_xstrdup (mangled_name);
|
||||
+ buf = result.get ();
|
||||
|
||||
/* Search backwards looking for "N<digit(s)>". */
|
||||
p = buf + len;
|
||||
@@ -317,7 +317,7 @@ unpack_mangled_go_symbol (const char *mangled_name,
|
||||
}
|
||||
|
||||
unpack_package_and_object (buf, packagep, objectp);
|
||||
- return buf;
|
||||
+ return result;
|
||||
}
|
||||
|
||||
/* Implements the la_demangle language_defn routine for language Go.
|
||||
@@ -381,10 +381,9 @@ go_language::demangle_symbol (const char *mangled_name, int options) const
|
||||
return make_unique_xstrdup ((const char *) obstack_finish (&tempbuf));
|
||||
}
|
||||
|
||||
-/* Given a Go symbol, return its package or NULL if unknown.
|
||||
- Space for the result is malloc'd, caller must free. */
|
||||
+/* See go-lang.h. */
|
||||
|
||||
-char *
|
||||
+gdb::unique_xmalloc_ptr<char>
|
||||
go_symbol_package_name (const struct symbol *sym)
|
||||
{
|
||||
const char *mangled_name = sym->linkage_name ();
|
||||
@@ -393,8 +392,7 @@ go_symbol_package_name (const struct symbol *sym)
|
||||
const char *method_type_package_name;
|
||||
const char *method_type_object_name;
|
||||
int method_type_is_pointer;
|
||||
- char *name_buf;
|
||||
- char *result;
|
||||
+ gdb::unique_xmalloc_ptr<char> name_buf;
|
||||
|
||||
gdb_assert (sym->language () == language_go);
|
||||
name_buf = unpack_mangled_go_symbol (mangled_name,
|
||||
@@ -405,15 +403,12 @@ go_symbol_package_name (const struct symbol *sym)
|
||||
/* Some Go symbols don't have mangled form we interpret (yet). */
|
||||
if (name_buf == NULL)
|
||||
return NULL;
|
||||
- result = xstrdup (package_name);
|
||||
- xfree (name_buf);
|
||||
- return result;
|
||||
+ return make_unique_xstrdup (package_name);
|
||||
}
|
||||
|
||||
-/* Return the package that BLOCK is in, or NULL if there isn't one.
|
||||
- Space for the result is malloc'd, caller must free. */
|
||||
+/* See go-lang.h. */
|
||||
|
||||
-char *
|
||||
+gdb::unique_xmalloc_ptr<char>
|
||||
go_block_package_name (const struct block *block)
|
||||
{
|
||||
while (block != NULL)
|
||||
@@ -422,7 +417,8 @@ go_block_package_name (const struct block *block)
|
||||
|
||||
if (function != NULL)
|
||||
{
|
||||
- char *package_name = go_symbol_package_name (function);
|
||||
+ gdb::unique_xmalloc_ptr<char> package_name
|
||||
+ = go_symbol_package_name (function);
|
||||
|
||||
if (package_name != NULL)
|
||||
return package_name;
|
||||
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
|
||||
index f0929cc3ac5..8edfe6ed53a 100644
|
||||
--- a/gdb/go-lang.h
|
||||
+++ b/gdb/go-lang.h
|
||||
@@ -62,9 +62,14 @@ extern const char *go_main_name (void);
|
||||
|
||||
extern enum go_type go_classify_struct_type (struct type *type);
|
||||
|
||||
-extern char *go_symbol_package_name (const struct symbol *sym);
|
||||
-
|
||||
-extern char *go_block_package_name (const struct block *block);
|
||||
+/* Given a Go symbol, return its package or nullptr if unknown. */
|
||||
+extern gdb::unique_xmalloc_ptr<char> go_symbol_package_name
|
||||
+ (const struct symbol *sym);
|
||||
+
|
||||
+/* Return the package that BLOCK is in, or nullptr if there isn't
|
||||
+ one. */
|
||||
+extern gdb::unique_xmalloc_ptr<char> go_block_package_name
|
||||
+ (const struct block *block);
|
||||
|
||||
extern const struct builtin_go_type *builtin_go_type (struct gdbarch *);
|
||||
|
||||
--
|
||||
2.35.3
|
||||
|
53
change-gdb.base-examine-backwards.exp-for-aix.patch
Normal file
53
change-gdb.base-examine-backwards.exp-for-aix.patch
Normal file
@ -0,0 +1,53 @@
|
||||
From acc7b542a08819bec4aae767de547c531a7ab62e Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
|
||||
Date: Mon, 6 Nov 2023 07:26:24 -0600
|
||||
Subject: [PATCH 03/48] Change gdb.base/examine-backwards.exp for AIX.
|
||||
|
||||
In AIX unused or constant variables are collected as garbage by the linker and in the dwarf dump
|
||||
an address with all f's in hexadecimal are assigned. Hence the testcase fails with many failures stating
|
||||
it cannot access memory.
|
||||
|
||||
This patch is a small change to get it working in AIX as well.
|
||||
---
|
||||
gdb/testsuite/gdb.base/examine-backward.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/examine-backward.c b/gdb/testsuite/gdb.base/examine-backward.c
|
||||
index e30b58fb005..354c2e2f323 100644
|
||||
--- a/gdb/testsuite/gdb.base/examine-backward.c
|
||||
+++ b/gdb/testsuite/gdb.base/examine-backward.c
|
||||
@@ -36,11 +36,11 @@ literals. The content of each array is the same as followings:
|
||||
TestStrings, to avoid showing garbage when we look for strings
|
||||
backwards from TestStrings. */
|
||||
|
||||
-const unsigned char Barrier[] = {
|
||||
+unsigned char Barrier[] = {
|
||||
0x00,
|
||||
};
|
||||
|
||||
-const unsigned char TestStrings[] = {
|
||||
+unsigned char TestStrings[] = {
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
||||
0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
|
||||
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
|
||||
@@ -54,7 +54,7 @@ const unsigned char TestStrings[] = {
|
||||
0x00
|
||||
};
|
||||
|
||||
-const short TestStringsH[] = {
|
||||
+short TestStringsH[] = {
|
||||
0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048,
|
||||
0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050,
|
||||
0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
|
||||
@@ -67,7 +67,7 @@ const short TestStringsH[] = {
|
||||
0x0000
|
||||
};
|
||||
|
||||
-const int TestStringsW[] = {
|
||||
+int TestStringsW[] = {
|
||||
0x00000041, 0x00000042, 0x00000043, 0x00000044,
|
||||
0x00000045, 0x00000046, 0x00000047, 0x00000048,
|
||||
0x00000049, 0x0000004a, 0x0000004b, 0x0000004c,
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,148 +0,0 @@
|
||||
From 11a41bc318ba0307248eadf29bf7d4a1af31d3a8 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Tue, 16 May 2023 17:00:51 +0100
|
||||
Subject: [PATCH 2/2] Fix PR30369 regression on aarch64/arm (PR30506)
|
||||
|
||||
The gdb.dwarf2/dw2-prologue-end-2.exp test was failing for both AArch64 and
|
||||
Arm.
|
||||
|
||||
As Tom pointed out here (https://inbox.sourceware.org/gdb-patches/6663707c-4297-c2f2-a0bd-f3e84fc62aad@suse.de/),
|
||||
there are issues with both the prologue skipper for AArch64 and Arm and an
|
||||
incorrect assumption by the testcase.
|
||||
|
||||
This patch fixes both of AArch64's and Arm's prologue skippers to not skip past
|
||||
the end of a function. It also incorporates a fix to the testcase so it
|
||||
doesn't assume the prologue skipper will stop at the first instruction of the
|
||||
functions/labels.
|
||||
|
||||
Regression-tested on aarch64-linux/arm-linux Ubuntu 20.04/22.04 and
|
||||
x86_64-linux Ubuntu 20.04.
|
||||
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30506
|
||||
|
||||
Co-Authored-By: Tom de Vries <tdevries@suse.de>
|
||||
Co-Authored-By: Luis Machado <luis.machado@arm.com>
|
||||
---
|
||||
gdb/aarch64-tdep.c | 10 +++++++--
|
||||
gdb/arm-tdep.c | 21 ++++++++++++++++---
|
||||
.../gdb.dwarf2/dw2-prologue-end-2.exp | 12 +++++------
|
||||
3 files changed, 32 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
|
||||
index 499b87ef480..e21d18f5c8c 100644
|
||||
--- a/gdb/aarch64-tdep.c
|
||||
+++ b/gdb/aarch64-tdep.c
|
||||
@@ -896,12 +896,15 @@ aarch64_analyze_prologue_test (void)
|
||||
static CORE_ADDR
|
||||
aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
|
||||
{
|
||||
- CORE_ADDR func_addr, limit_pc;
|
||||
+ CORE_ADDR func_addr, func_end_addr, limit_pc;
|
||||
|
||||
/* See if we can determine the end of the prologue via the symbol
|
||||
table. If so, then return either PC, or the PC after the
|
||||
prologue, whichever is greater. */
|
||||
- if (find_pc_partial_function (pc, NULL, &func_addr, NULL))
|
||||
+ bool func_addr_found
|
||||
+ = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr);
|
||||
+
|
||||
+ if (func_addr_found)
|
||||
{
|
||||
CORE_ADDR post_prologue_pc
|
||||
= skip_prologue_using_sal (gdbarch, func_addr);
|
||||
@@ -921,6 +924,9 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
|
||||
if (limit_pc == 0)
|
||||
limit_pc = pc + 128; /* Magic. */
|
||||
|
||||
+ limit_pc
|
||||
+ = func_end_addr == 0? limit_pc : std::min (limit_pc, func_end_addr - 4);
|
||||
+
|
||||
/* Try disassembling prologue. */
|
||||
return aarch64_analyze_prologue (gdbarch, pc, limit_pc, NULL);
|
||||
}
|
||||
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
|
||||
index 58b9c5f4bd8..ecffb9223e1 100644
|
||||
--- a/gdb/arm-tdep.c
|
||||
+++ b/gdb/arm-tdep.c
|
||||
@@ -1768,12 +1768,18 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch)
|
||||
static CORE_ADDR
|
||||
arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
|
||||
{
|
||||
- CORE_ADDR func_addr, limit_pc;
|
||||
+ CORE_ADDR func_addr, func_end_addr, limit_pc;
|
||||
|
||||
/* See if we can determine the end of the prologue via the symbol table.
|
||||
If so, then return either PC, or the PC after the prologue, whichever
|
||||
is greater. */
|
||||
- if (find_pc_partial_function (pc, NULL, &func_addr, NULL))
|
||||
+ bool func_addr_found
|
||||
+ = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr);
|
||||
+
|
||||
+ /* Whether the function is thumb mode or not. */
|
||||
+ bool func_is_thumb = false;
|
||||
+
|
||||
+ if (func_addr_found)
|
||||
{
|
||||
CORE_ADDR post_prologue_pc
|
||||
= skip_prologue_using_sal (gdbarch, func_addr);
|
||||
@@ -1810,7 +1816,8 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
|
||||
associate prologue code with the opening brace; so this
|
||||
lets us skip the first line if we think it is the opening
|
||||
brace. */
|
||||
- if (arm_pc_is_thumb (gdbarch, func_addr))
|
||||
+ func_is_thumb = arm_pc_is_thumb (gdbarch, func_addr);
|
||||
+ if (func_is_thumb)
|
||||
analyzed_limit = thumb_analyze_prologue (gdbarch, func_addr,
|
||||
post_prologue_pc, NULL);
|
||||
else
|
||||
@@ -1836,6 +1843,14 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
|
||||
if (limit_pc == 0)
|
||||
limit_pc = pc + 64; /* Magic. */
|
||||
|
||||
+ /* Set the correct adjustment based on whether the function is thumb mode or
|
||||
+ not. We use it to get the address of the last instruction in the
|
||||
+ function (as opposed to the first address of the next function). */
|
||||
+ CORE_ADDR adjustment = func_is_thumb? 2 : 4;
|
||||
+
|
||||
+ limit_pc
|
||||
+ = func_end_addr == 0? limit_pc : std::min (limit_pc,
|
||||
+ func_end_addr - adjustment);
|
||||
|
||||
/* Check if this is Thumb code. */
|
||||
if (arm_pc_is_thumb (gdbarch, pc))
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp
|
||||
index 642b73fe2a1..da49902c13c 100644
|
||||
--- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp
|
||||
@@ -95,17 +95,17 @@ if { $break_addr == "" } {
|
||||
return
|
||||
}
|
||||
|
||||
-# Get the "foo_label" address.
|
||||
+# Get the "bar_label" address.
|
||||
|
||||
-set foo_label_addr ""
|
||||
-gdb_test_multiple "print /x &foo_label" "" {
|
||||
+set bar_label_addr ""
|
||||
+gdb_test_multiple "print /x &bar_label" "" {
|
||||
-re -wrap "= ($hex)" {
|
||||
- set foo_label_addr $expect_out(1,string)
|
||||
+ set bar_label_addr $expect_out(1,string)
|
||||
pass $gdb_test_name
|
||||
}
|
||||
}
|
||||
|
||||
-if { $foo_label_addr == "" } {
|
||||
+if { $bar_label_addr == "" } {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -117,4 +117,4 @@ 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 }
|
||||
+gdb_assert { $break_addr < $bar_label_addr }
|
||||
--
|
||||
2.35.3
|
||||
|
366
fix-regression-on-aarch64-linux-gdbserver.patch
Normal file
366
fix-regression-on-aarch64-linux-gdbserver.patch
Normal file
@ -0,0 +1,366 @@
|
||||
From 2a7e48ca27f4c080151ce9da5a29239aa5d3b66f Mon Sep 17 00:00:00 2001
|
||||
From: Tom Tromey <tromey@adacore.com>
|
||||
Date: Fri, 19 Apr 2024 07:54:19 -0600
|
||||
Subject: [PATCH 15/48] Fix regression on aarch64-linux gdbserver
|
||||
|
||||
Commit 9a03f218 ("Fix gdb.base/watchpoint-unaligned.exp on aarch64")
|
||||
fixed a watchpoint bug in gdb -- but did not touch the corresponding
|
||||
code in gdbserver.
|
||||
|
||||
This patch moves the gdb code into gdb/nat, so that it can be shared
|
||||
with gdbserver, and then changes gdbserver to use it, fixing the bug.
|
||||
|
||||
This is yet another case where having a single back end would prevent
|
||||
bugs.
|
||||
|
||||
I tested this using the AdaCore internal gdb testsuite.
|
||||
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29423
|
||||
Approved-By: Luis Machado <luis.machado@arm.com>
|
||||
---
|
||||
gdb/aarch64-nat.c | 115 ---------------------------------
|
||||
gdb/aarch64-nat.h | 8 ---
|
||||
gdb/nat/aarch64-hw-point.c | 115 +++++++++++++++++++++++++++++++++
|
||||
gdb/nat/aarch64-hw-point.h | 8 +++
|
||||
gdbserver/linux-aarch64-low.cc | 38 +----------
|
||||
5 files changed, 126 insertions(+), 158 deletions(-)
|
||||
|
||||
diff --git a/gdb/aarch64-nat.c b/gdb/aarch64-nat.c
|
||||
index a173e4e18d5..97e3048568a 100644
|
||||
--- a/gdb/aarch64-nat.c
|
||||
+++ b/gdb/aarch64-nat.c
|
||||
@@ -225,121 +225,6 @@ aarch64_remove_watchpoint (CORE_ADDR addr, int len, enum target_hw_bp_type type,
|
||||
return ret;
|
||||
}
|
||||
|
||||
-/* See aarch64-nat.h. */
|
||||
-
|
||||
-bool
|
||||
-aarch64_stopped_data_address (const struct aarch64_debug_reg_state *state,
|
||||
- CORE_ADDR addr_trap, CORE_ADDR *addr_p)
|
||||
-{
|
||||
- bool found = false;
|
||||
- for (int phase = 0; phase <= 1; ++phase)
|
||||
- for (int i = aarch64_num_wp_regs - 1; i >= 0; --i)
|
||||
- {
|
||||
- if (!(state->dr_ref_count_wp[i]
|
||||
- && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])))
|
||||
- {
|
||||
- /* Watchpoint disabled. */
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- const enum target_hw_bp_type type
|
||||
- = aarch64_watchpoint_type (state->dr_ctrl_wp[i]);
|
||||
- if (type == hw_execute)
|
||||
- {
|
||||
- /* Watchpoint disabled. */
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- if (phase == 0)
|
||||
- {
|
||||
- /* Phase 0: No hw_write. */
|
||||
- if (type == hw_write)
|
||||
- continue;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- /* Phase 1: Only hw_write. */
|
||||
- if (type != hw_write)
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- const unsigned int offset
|
||||
- = aarch64_watchpoint_offset (state->dr_ctrl_wp[i]);
|
||||
- const unsigned int len
|
||||
- = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
|
||||
- const CORE_ADDR addr_watch = state->dr_addr_wp[i] + offset;
|
||||
- const CORE_ADDR addr_watch_aligned
|
||||
- = align_down (state->dr_addr_wp[i], AARCH64_HWP_MAX_LEN_PER_REG);
|
||||
- const CORE_ADDR addr_orig = state->dr_addr_orig_wp[i];
|
||||
-
|
||||
- /* ADDR_TRAP reports the first address of the memory range
|
||||
- accessed by the CPU, regardless of what was the memory
|
||||
- range watched. Thus, a large CPU access that straddles
|
||||
- the ADDR_WATCH..ADDR_WATCH+LEN range may result in an
|
||||
- ADDR_TRAP that is lower than the
|
||||
- ADDR_WATCH..ADDR_WATCH+LEN range. E.g.:
|
||||
-
|
||||
- addr: | 4 | 5 | 6 | 7 | 8 |
|
||||
- |---- range watched ----|
|
||||
- |----------- range accessed ------------|
|
||||
-
|
||||
- In this case, ADDR_TRAP will be 4.
|
||||
-
|
||||
- The access size also can be larger than that of the watchpoint
|
||||
- itself. For instance, the access size of an stp instruction is 16.
|
||||
- So, if we use stp to store to address p, and set a watchpoint on
|
||||
- address p + 8, the reported ADDR_TRAP can be p + 8 (observed on
|
||||
- RK3399 SOC). But it also can be p (observed on M1 SOC). Checking
|
||||
- for this situation introduces the possibility of false positives,
|
||||
- so we only do this for hw_write watchpoints. */
|
||||
- const CORE_ADDR max_access_size = type == hw_write ? 16 : 8;
|
||||
- const CORE_ADDR addr_watch_base = addr_watch_aligned -
|
||||
- (max_access_size - AARCH64_HWP_MAX_LEN_PER_REG);
|
||||
- if (!(addr_trap >= addr_watch_base
|
||||
- && addr_trap < addr_watch + len))
|
||||
- {
|
||||
- /* Not a match. */
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- /* To match a watchpoint known to GDB core, we must never
|
||||
- report *ADDR_P outside of any ADDR_WATCH..ADDR_WATCH+LEN
|
||||
- range. ADDR_WATCH <= ADDR_TRAP < ADDR_ORIG is a false
|
||||
- positive on kernels older than 4.10. See PR
|
||||
- external/20207. */
|
||||
- if (addr_p != nullptr)
|
||||
- *addr_p = addr_orig;
|
||||
-
|
||||
- if (phase == 0)
|
||||
- {
|
||||
- /* Phase 0: Return first match. */
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- /* Phase 1. */
|
||||
- if (addr_p == nullptr)
|
||||
- {
|
||||
- /* First match, and we don't need to report an address. No need
|
||||
- to look for other matches. */
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- if (!found)
|
||||
- {
|
||||
- /* First match, and we need to report an address. Look for other
|
||||
- matches. */
|
||||
- found = true;
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- /* More than one match, and we need to return an address. No need to
|
||||
- look for further matches. */
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- return found;
|
||||
-}
|
||||
-
|
||||
/* Define AArch64 maintenance commands. */
|
||||
|
||||
static void
|
||||
diff --git a/gdb/aarch64-nat.h b/gdb/aarch64-nat.h
|
||||
index fee6bda2577..f95a9d745e5 100644
|
||||
--- a/gdb/aarch64-nat.h
|
||||
+++ b/gdb/aarch64-nat.h
|
||||
@@ -45,14 +45,6 @@ struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
|
||||
|
||||
void aarch64_remove_debug_reg_state (pid_t pid);
|
||||
|
||||
-/* Helper for the "stopped_data_address" target method. Returns TRUE
|
||||
- if a hardware watchpoint trap at ADDR_TRAP matches a set
|
||||
- watchpoint. The address of the matched watchpoint is returned in
|
||||
- *ADDR_P. */
|
||||
-
|
||||
-bool aarch64_stopped_data_address (const struct aarch64_debug_reg_state *state,
|
||||
- CORE_ADDR addr_trap, CORE_ADDR *addr_p);
|
||||
-
|
||||
/* Helper functions used by aarch64_nat_target below. See their
|
||||
definitions. */
|
||||
|
||||
diff --git a/gdb/nat/aarch64-hw-point.c b/gdb/nat/aarch64-hw-point.c
|
||||
index 3b8cdcba23b..9eb78923e86 100644
|
||||
--- a/gdb/nat/aarch64-hw-point.c
|
||||
+++ b/gdb/nat/aarch64-hw-point.c
|
||||
@@ -647,3 +647,118 @@ aarch64_region_ok_for_watchpoint (CORE_ADDR addr, int len)
|
||||
the checking is costly. */
|
||||
return 1;
|
||||
}
|
||||
+
|
||||
+/* See nat/aarch64-hw-point.h. */
|
||||
+
|
||||
+bool
|
||||
+aarch64_stopped_data_address (const struct aarch64_debug_reg_state *state,
|
||||
+ CORE_ADDR addr_trap, CORE_ADDR *addr_p)
|
||||
+{
|
||||
+ bool found = false;
|
||||
+ for (int phase = 0; phase <= 1; ++phase)
|
||||
+ for (int i = aarch64_num_wp_regs - 1; i >= 0; --i)
|
||||
+ {
|
||||
+ if (!(state->dr_ref_count_wp[i]
|
||||
+ && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])))
|
||||
+ {
|
||||
+ /* Watchpoint disabled. */
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ const enum target_hw_bp_type type
|
||||
+ = aarch64_watchpoint_type (state->dr_ctrl_wp[i]);
|
||||
+ if (type == hw_execute)
|
||||
+ {
|
||||
+ /* Watchpoint disabled. */
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (phase == 0)
|
||||
+ {
|
||||
+ /* Phase 0: No hw_write. */
|
||||
+ if (type == hw_write)
|
||||
+ continue;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ /* Phase 1: Only hw_write. */
|
||||
+ if (type != hw_write)
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ const unsigned int offset
|
||||
+ = aarch64_watchpoint_offset (state->dr_ctrl_wp[i]);
|
||||
+ const unsigned int len
|
||||
+ = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
|
||||
+ const CORE_ADDR addr_watch = state->dr_addr_wp[i] + offset;
|
||||
+ const CORE_ADDR addr_watch_aligned
|
||||
+ = align_down (state->dr_addr_wp[i], AARCH64_HWP_MAX_LEN_PER_REG);
|
||||
+ const CORE_ADDR addr_orig = state->dr_addr_orig_wp[i];
|
||||
+
|
||||
+ /* ADDR_TRAP reports the first address of the memory range
|
||||
+ accessed by the CPU, regardless of what was the memory
|
||||
+ range watched. Thus, a large CPU access that straddles
|
||||
+ the ADDR_WATCH..ADDR_WATCH+LEN range may result in an
|
||||
+ ADDR_TRAP that is lower than the
|
||||
+ ADDR_WATCH..ADDR_WATCH+LEN range. E.g.:
|
||||
+
|
||||
+ addr: | 4 | 5 | 6 | 7 | 8 |
|
||||
+ |---- range watched ----|
|
||||
+ |----------- range accessed ------------|
|
||||
+
|
||||
+ In this case, ADDR_TRAP will be 4.
|
||||
+
|
||||
+ The access size also can be larger than that of the watchpoint
|
||||
+ itself. For instance, the access size of an stp instruction is 16.
|
||||
+ So, if we use stp to store to address p, and set a watchpoint on
|
||||
+ address p + 8, the reported ADDR_TRAP can be p + 8 (observed on
|
||||
+ RK3399 SOC). But it also can be p (observed on M1 SOC). Checking
|
||||
+ for this situation introduces the possibility of false positives,
|
||||
+ so we only do this for hw_write watchpoints. */
|
||||
+ const CORE_ADDR max_access_size = type == hw_write ? 16 : 8;
|
||||
+ const CORE_ADDR addr_watch_base = addr_watch_aligned -
|
||||
+ (max_access_size - AARCH64_HWP_MAX_LEN_PER_REG);
|
||||
+ if (!(addr_trap >= addr_watch_base
|
||||
+ && addr_trap < addr_watch + len))
|
||||
+ {
|
||||
+ /* Not a match. */
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* To match a watchpoint known to GDB core, we must never
|
||||
+ report *ADDR_P outside of any ADDR_WATCH..ADDR_WATCH+LEN
|
||||
+ range. ADDR_WATCH <= ADDR_TRAP < ADDR_ORIG is a false
|
||||
+ positive on kernels older than 4.10. See PR
|
||||
+ external/20207. */
|
||||
+ if (addr_p != nullptr)
|
||||
+ *addr_p = addr_orig;
|
||||
+
|
||||
+ if (phase == 0)
|
||||
+ {
|
||||
+ /* Phase 0: Return first match. */
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ /* Phase 1. */
|
||||
+ if (addr_p == nullptr)
|
||||
+ {
|
||||
+ /* First match, and we don't need to report an address. No need
|
||||
+ to look for other matches. */
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!found)
|
||||
+ {
|
||||
+ /* First match, and we need to report an address. Look for other
|
||||
+ matches. */
|
||||
+ found = true;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* More than one match, and we need to return an address. No need to
|
||||
+ look for further matches. */
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return found;
|
||||
+}
|
||||
diff --git a/gdb/nat/aarch64-hw-point.h b/gdb/nat/aarch64-hw-point.h
|
||||
index 71ae2864927..2386cf60f90 100644
|
||||
--- a/gdb/nat/aarch64-hw-point.h
|
||||
+++ b/gdb/nat/aarch64-hw-point.h
|
||||
@@ -110,6 +110,14 @@ unsigned int aarch64_watchpoint_offset (unsigned int ctrl);
|
||||
unsigned int aarch64_watchpoint_length (unsigned int ctrl);
|
||||
enum target_hw_bp_type aarch64_watchpoint_type (unsigned int ctrl);
|
||||
|
||||
+/* Helper for the "stopped_data_address" target method. Returns TRUE
|
||||
+ if a hardware watchpoint trap at ADDR_TRAP matches a set
|
||||
+ watchpoint. The address of the matched watchpoint is returned in
|
||||
+ *ADDR_P. */
|
||||
+
|
||||
+bool aarch64_stopped_data_address (const struct aarch64_debug_reg_state *state,
|
||||
+ CORE_ADDR addr_trap, CORE_ADDR *addr_p);
|
||||
+
|
||||
int aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr,
|
||||
int len, int is_insert, ptid_t ptid,
|
||||
struct aarch64_debug_reg_state *state);
|
||||
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
|
||||
index fcbe7bb64d7..14346b89822 100644
|
||||
--- a/gdbserver/linux-aarch64-low.cc
|
||||
+++ b/gdbserver/linux-aarch64-low.cc
|
||||
@@ -577,41 +577,9 @@ aarch64_target::low_stopped_data_address ()
|
||||
|
||||
/* Check if the address matches any watched address. */
|
||||
state = aarch64_get_debug_reg_state (pid_of (current_thread));
|
||||
- for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
|
||||
- {
|
||||
- const unsigned int offset
|
||||
- = aarch64_watchpoint_offset (state->dr_ctrl_wp[i]);
|
||||
- const unsigned int len = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
|
||||
- const CORE_ADDR addr_watch = state->dr_addr_wp[i] + offset;
|
||||
- const CORE_ADDR addr_watch_aligned = align_down (state->dr_addr_wp[i], 8);
|
||||
- const CORE_ADDR addr_orig = state->dr_addr_orig_wp[i];
|
||||
-
|
||||
- if (state->dr_ref_count_wp[i]
|
||||
- && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])
|
||||
- && addr_trap >= addr_watch_aligned
|
||||
- && addr_trap < addr_watch + len)
|
||||
- {
|
||||
- /* ADDR_TRAP reports the first address of the memory range
|
||||
- accessed by the CPU, regardless of what was the memory
|
||||
- range watched. Thus, a large CPU access that straddles
|
||||
- the ADDR_WATCH..ADDR_WATCH+LEN range may result in an
|
||||
- ADDR_TRAP that is lower than the
|
||||
- ADDR_WATCH..ADDR_WATCH+LEN range. E.g.:
|
||||
-
|
||||
- addr: | 4 | 5 | 6 | 7 | 8 |
|
||||
- |---- range watched ----|
|
||||
- |----------- range accessed ------------|
|
||||
-
|
||||
- In this case, ADDR_TRAP will be 4.
|
||||
-
|
||||
- To match a watchpoint known to GDB core, we must never
|
||||
- report *ADDR_P outside of any ADDR_WATCH..ADDR_WATCH+LEN
|
||||
- range. ADDR_WATCH <= ADDR_TRAP < ADDR_ORIG is a false
|
||||
- positive on kernels older than 4.10. See PR
|
||||
- external/20207. */
|
||||
- return addr_orig;
|
||||
- }
|
||||
- }
|
||||
+ CORE_ADDR result;
|
||||
+ if (aarch64_stopped_data_address (state, addr_trap, &result))
|
||||
+ return result;
|
||||
|
||||
return (CORE_ADDR) 0;
|
||||
}
|
||||
--
|
||||
2.35.3
|
||||
|
80
fix-the-gdb.ada-inline-section-gc.exp-test.patch
Normal file
80
fix-the-gdb.ada-inline-section-gc.exp-test.patch
Normal file
@ -0,0 +1,80 @@
|
||||
From c21fd9f7d5911fce0c17af7094d8861d1195dfda Mon Sep 17 00:00:00 2001
|
||||
From: Carl Love <cel@linux.ibm.com>
|
||||
Date: Mon, 13 Nov 2023 14:14:08 -0500
|
||||
Subject: [PATCH 01/48] Fix the gdb.ada/inline-section-gc.exp test
|
||||
|
||||
The original intention of the test appears to be checking to make sure
|
||||
setting a breakpoint in an inlined function didn't set multiple
|
||||
breakpoints where one of them was at address 0.
|
||||
|
||||
The gdb.ada/inline-section-gc.exp test may pass or fail depending on the
|
||||
version of gnat. Per the discussion on IRC, the ada inlining appears to
|
||||
have some target dependencies. In this test there are two functions,
|
||||
callee and caller. Function calee is inlined into caller. The test sets
|
||||
a breakpoint in function callee. The reported location where the
|
||||
breakpoint is set may be at the requested location in callee or the
|
||||
location in caller after callee has been inlined. The test needs to
|
||||
accept either location as correct provided the breakpoint address is not
|
||||
zero.
|
||||
|
||||
This patch checks to see if the reported breakpoint is in function callee
|
||||
or function caller and fails if the breakpoint address is 0x0. The line
|
||||
number where the breakpoint is set will match the requested line if the
|
||||
breakpoint location is reported is callee.adb. If the breakpoint is
|
||||
reported in caller.adb, the line number in caller is the breakpoint
|
||||
location in callee where it is inlined into caller.
|
||||
|
||||
This patch fixes the single regression failure for the test on PowerPC.
|
||||
It does not introduce any failures on X86-64.
|
||||
---
|
||||
gdb/testsuite/gdb.ada/inline-section-gc.exp | 21 ++++++++++++++++---
|
||||
.../gdb.ada/inline-section-gc/caller.adb | 3 ++-
|
||||
2 files changed, 20 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.ada/inline-section-gc.exp b/gdb/testsuite/gdb.ada/inline-section-gc.exp
|
||||
index b707335eb04..4f8b8c95395 100644
|
||||
--- a/gdb/testsuite/gdb.ada/inline-section-gc.exp
|
||||
+++ b/gdb/testsuite/gdb.ada/inline-section-gc.exp
|
||||
@@ -34,8 +34,23 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $options] != ""} {
|
||||
|
||||
clean_restart ${testfile}
|
||||
|
||||
-set bp_location [gdb_get_line_number "BREAK" ${testdir}/callee.adb]
|
||||
+
|
||||
+# Depending on the version of gnat, the location of the set breakpoint may
|
||||
+# be reported as being at the requested location in file callee.adb or in
|
||||
+# file caller.adb where the callee function was inlined. Either way, only
|
||||
+# one breakpoint should be reported and its address should not be at 0x0.
|
||||
+set bp_location1 [gdb_get_line_number "BREAK" ${testdir}/callee.adb]
|
||||
+set bp_location2 [gdb_get_line_number "CALLEE_LOC" ${testdir}/caller.adb]
|
||||
+set test "break callee.adb:$bp_location1"
|
||||
+set message "Breakpoint set"
|
||||
+
|
||||
# The bug here was that gdb would set a breakpoint with two locations,
|
||||
# one of them at 0x0.
|
||||
-gdb_test "break callee.adb:$bp_location" \
|
||||
- "Breakpoint $decimal at $hex: file .*callee.adb, line $bp_location."
|
||||
+gdb_test_multiple $test $message {
|
||||
+ -re "Breakpoint $decimal at $hex: file .*callee.adb, line $bp_location1." {
|
||||
+ pass $test
|
||||
+ }
|
||||
+ -re "Breakpoint $decimal at $hex: file .*caller.adb, line $bp_location2." {
|
||||
+ pass $test
|
||||
+ }
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb b/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb
|
||||
index 66eb2d9a910..161f3e85542 100644
|
||||
--- a/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb
|
||||
+++ b/gdb/testsuite/gdb.ada/inline-section-gc/caller.adb
|
||||
@@ -18,4 +18,5 @@ with Callee;
|
||||
procedure Caller is
|
||||
begin
|
||||
Callee;
|
||||
-end Caller;
|
||||
+end Caller; -- CALLEE_LOC, this is where the inlined callee breakpoint
|
||||
+ -- is located.
|
||||
|
||||
base-commit: 582fc35843fdf71b82d645d83d2903e2546cc21a
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,29 +0,0 @@
|
||||
fixup-2-gdb-rhbz1553104-s390x-arch12-test
|
||||
|
||||
---
|
||||
gdb/testsuite/gdb.arch/s390x-arch12.exp | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.exp b/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
index 246c1e1c69a..7939a2d6932 100644
|
||||
--- a/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
+++ b/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
@@ -31,4 +31,18 @@ gdb_exit
|
||||
gdb_start
|
||||
gdb_load $ofile
|
||||
|
||||
+set supported 0
|
||||
+gdb_test_multiple "show arch" "" {
|
||||
+ -re -wrap "\"s390:64-bit\".*" {
|
||||
+ set supported 1
|
||||
+ }
|
||||
+ -re -wrap "" {
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+if { ! $supported } {
|
||||
+ unsupported "No s390x support"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
gdb_test "disas load_guarded" " <\\+28>:\tlgg\t%r1,0\\(%r1\\)\r\n\[^\r\n\]* <\\+34>:\tstg\t%r1,168\\(%r11\\)\r\n.*"
|
@ -1,26 +0,0 @@
|
||||
From 266359a17e77a53d4ebaa4f3b15c2ae39e43fca0 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Tue, 13 Jun 2023 15:07:22 +0200
|
||||
Subject: [PATCH 6/6] fixup gdb-lineno-makeup-test.patch
|
||||
|
||||
---
|
||||
gdb/testsuite/gdb.base/lineno-makeup.exp | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/lineno-makeup.exp b/gdb/testsuite/gdb.base/lineno-makeup.exp
|
||||
index 9e11d78bf9c..d31e063bdc2 100644
|
||||
--- a/gdb/testsuite/gdb.base/lineno-makeup.exp
|
||||
+++ b/gdb/testsuite/gdb.base/lineno-makeup.exp
|
||||
@@ -21,7 +21,8 @@ set binfuncfile [standard_output_file ${testfile}-func.bin]
|
||||
set binfile [standard_output_file ${testfile}]
|
||||
|
||||
if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } {
|
||||
- gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
||||
+ unsupported "Testcase compile failed, so all tests in this file will automatically fail."
|
||||
+ return
|
||||
}
|
||||
|
||||
set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output]
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,10 +1,19 @@
|
||||
From af4a87e2b3c2ac5acae1e6f4405fc59e1218de74 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 18 Apr 2024 14:26:58 +0200
|
||||
Subject: [PATCH] fixup-gdb-linux_perf-bundle
|
||||
|
||||
---
|
||||
gdb/gdb.c | 8 --------
|
||||
1 file changed, 8 deletions(-)
|
||||
|
||||
diff --git a/gdb/gdb.c b/gdb/gdb.c
|
||||
index 82e9e6da210..b5e28445630 100644
|
||||
index 41a9b70c222..6e3ff0755ab 100644
|
||||
--- a/gdb/gdb.c
|
||||
+++ b/gdb/gdb.c
|
||||
@@ -20,19 +20,11 @@
|
||||
#include "main.h"
|
||||
@@ -21,10 +21,6 @@
|
||||
#include "interps.h"
|
||||
#include "run-on-main-thread.h"
|
||||
|
||||
-#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
|
||||
-extern "C" void __libipt_init(void);
|
||||
@ -13,6 +22,8 @@ index 82e9e6da210..b5e28445630 100644
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -36,10 +32,6 @@ main (int argc, char **argv)
|
||||
|
||||
struct captured_main_args args;
|
||||
|
||||
-#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
|
||||
@ -22,3 +33,8 @@ index 82e9e6da210..b5e28445630 100644
|
||||
memset (&args, 0, sizeof args);
|
||||
args.argc = argc;
|
||||
args.argv = argv;
|
||||
|
||||
base-commit: 254988c36fe592e89af5d92e1d35a6eb4b09cbb0
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
fixup-gdb-rhbz1553104-s390x-arch12-test.patch
|
||||
|
||||
---
|
||||
gdb/testsuite/gdb.arch/s390x-arch12.exp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.exp b/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
index 4e902ff960d..246c1e1c69a 100644
|
||||
--- a/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
+++ b/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
set testfile "s390x-arch12"
|
||||
set uufile "${srcdir}/${subdir}/${testfile}.o.uu"
|
||||
-set ofile "${srcdir}/${subdir}/${testfile}.o"
|
||||
+set ofile [standard_output_file ${testfile}.o]
|
||||
|
||||
if { [catch "system \"uudecode -o ${ofile} ${uufile}\"" ] != 0 } {
|
||||
untested "failed uudecode"
|
70
fixup-powerpc-and-aarch64-fix-reverse-stepping-failu.patch
Normal file
70
fixup-powerpc-and-aarch64-fix-reverse-stepping-failu.patch
Normal file
@ -0,0 +1,70 @@
|
||||
From d60b57fe1a98094a7e4f19481193b2b5a9bb1e57 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 2 May 2024 12:02:50 +0200
|
||||
Subject: [PATCH 079/147] fixup PowerPC and aarch64: Fix reverse stepping
|
||||
failure
|
||||
|
||||
---
|
||||
gdb/infrun.c | 2 +-
|
||||
gdb/symtab.c | 3 +--
|
||||
gdb/symtab.h | 3 +--
|
||||
3 files changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/gdb/infrun.c b/gdb/infrun.c
|
||||
index 069ef144a76..7be98cfc252 100644
|
||||
--- a/gdb/infrun.c
|
||||
+++ b/gdb/infrun.c
|
||||
@@ -6897,7 +6897,7 @@ update_line_range_start (CORE_ADDR pc, struct execution_control_state *ecs)
|
||||
Given the PC, check the line table and return the PC that corresponds
|
||||
to the line table entry for the source line that PC is in. */
|
||||
CORE_ADDR start_line_pc = ecs->event_thread->control.step_range_start;
|
||||
- std::optional<CORE_ADDR> real_range_start;
|
||||
+ gdb::optional<CORE_ADDR> real_range_start;
|
||||
|
||||
/* Call find_line_range_start to get the smallest address in the
|
||||
linetable for multiple Line X entries in the line table. */
|
||||
diff --git a/gdb/symtab.c b/gdb/symtab.c
|
||||
index ef63ec93c5a..9a47796e5e0 100644
|
||||
--- a/gdb/symtab.c
|
||||
+++ b/gdb/symtab.c
|
||||
@@ -73,7 +73,6 @@
|
||||
#include "gdbsupport/gdb_string_view.h"
|
||||
#include "gdbsupport/pathstuff.h"
|
||||
#include "gdbsupport/common-utils.h"
|
||||
-#include <optional>
|
||||
|
||||
/* Forward declarations for local functions. */
|
||||
|
||||
@@ -3328,7 +3327,7 @@ sal_line_symtab_matches_p (const symtab_and_line &sal1,
|
||||
|
||||
/* See symtah.h. */
|
||||
|
||||
-std::optional<CORE_ADDR>
|
||||
+gdb::optional<CORE_ADDR>
|
||||
find_line_range_start (CORE_ADDR pc)
|
||||
{
|
||||
struct symtab_and_line current_sal = find_pc_line (pc, 0);
|
||||
diff --git a/gdb/symtab.h b/gdb/symtab.h
|
||||
index e17d15c595b..6a611d42880 100644
|
||||
--- a/gdb/symtab.h
|
||||
+++ b/gdb/symtab.h
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "gdb-demangle.h"
|
||||
#include "split-name.h"
|
||||
#include "frame.h"
|
||||
-#include <optional>
|
||||
|
||||
/* Opaque declarations. */
|
||||
struct ui_file;
|
||||
@@ -2377,7 +2376,7 @@ extern struct symtab_and_line find_pc_sect_line (CORE_ADDR,
|
||||
the starting PC of line X, and the ranges are contiguous.
|
||||
*/
|
||||
|
||||
-extern std::optional<CORE_ADDR> find_line_range_start (CORE_ADDR pc);
|
||||
+extern gdb::optional<CORE_ADDR> find_line_range_start (CORE_ADDR pc);
|
||||
|
||||
/* Wrapper around find_pc_line to just return the symtab. */
|
||||
|
||||
--
|
||||
2.35.3
|
||||
|
101
fixup-skip-tests.patch
Normal file
101
fixup-skip-tests.patch
Normal file
@ -0,0 +1,101 @@
|
||||
From c1da0d6449415cc1fe6f863526735e4325b0b3ac Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Wed, 1 May 2024 12:43:41 +0200
|
||||
Subject: [PATCH 1/2] fixup-skip-tests
|
||||
|
||||
---
|
||||
gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp | 4 +---
|
||||
gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp | 4 +---
|
||||
gdb/testsuite/gdb.cp/cxxexec.exp | 2 +-
|
||||
.../py-gdb-rhbz1007614-memleak-infpy_read_memory.exp | 4 ++--
|
||||
gdb/testsuite/gdb.python/rh634108-solib_address.exp | 6 +++---
|
||||
5 files changed, 8 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
|
||||
index 0c46489f315..5879319f27c 100644
|
||||
--- a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
|
||||
+++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
|
||||
@@ -13,9 +13,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-if {[skip_shlib_tests]} {
|
||||
- return 0
|
||||
-}
|
||||
+require allow_shlib_tests
|
||||
|
||||
set testfile "gcore-buildid-exec-but-not-solib"
|
||||
set srcmainfile ${testfile}-main.c
|
||||
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
|
||||
index 052bd84d420..73a9bb64903 100644
|
||||
--- a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
|
||||
+++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
|
||||
@@ -17,9 +17,7 @@
|
||||
# invalid IFUNC DW_AT_linkage_name: memmove strstr time
|
||||
# http://sourceware.org/bugzilla/show_bug.cgi?id=14166
|
||||
|
||||
-if {[skip_shlib_tests]} {
|
||||
- return 0
|
||||
-}
|
||||
+require allow_shlib_tests
|
||||
|
||||
set testfile "gnu-ifunc-strstr-workaround"
|
||||
set executable ${testfile}
|
||||
diff --git a/gdb/testsuite/gdb.cp/cxxexec.exp b/gdb/testsuite/gdb.cp/cxxexec.exp
|
||||
index 77c85587407..089a679a1a9 100644
|
||||
--- a/gdb/testsuite/gdb.cp/cxxexec.exp
|
||||
+++ b/gdb/testsuite/gdb.cp/cxxexec.exp
|
||||
@@ -13,7 +13,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-if { [skip_cplus_tests] } { continue }
|
||||
+require allow_cplus_tests
|
||||
|
||||
set testfile cxxexec
|
||||
if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.cc {c++ debug}] } {
|
||||
diff --git a/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.exp b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.exp
|
||||
index 2e6786d499a..d2693cfef1d 100644
|
||||
--- a/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.exp
|
||||
+++ b/gdb/testsuite/gdb.python/py-gdb-rhbz1007614-memleak-infpy_read_memory.exp
|
||||
@@ -13,6 +13,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
+require allow_python_tests
|
||||
+
|
||||
set testfile py-gdb-rhbz1007614-memleak-infpy_read_memory
|
||||
set srcfile ${testfile}.c
|
||||
set binfile [standard_output_file ${testfile}]
|
||||
@@ -21,8 +23,6 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
|
||||
return -1
|
||||
}
|
||||
|
||||
-if { [skip_python_tests] } { continue }
|
||||
-
|
||||
set pid_of_gdb [exp_pid -i [board_info host fileid]]
|
||||
|
||||
proc memory_v_pages_get {} {
|
||||
diff --git a/gdb/testsuite/gdb.python/rh634108-solib_address.exp b/gdb/testsuite/gdb.python/rh634108-solib_address.exp
|
||||
index ebf00babc34..2d950b79951 100644
|
||||
--- a/gdb/testsuite/gdb.python/rh634108-solib_address.exp
|
||||
+++ b/gdb/testsuite/gdb.python/rh634108-solib_address.exp
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=634108
|
||||
|
||||
+# Skip all tests if Python scripting is not enabled.
|
||||
+require allow_python_tests
|
||||
+
|
||||
gdb_exit
|
||||
gdb_start
|
||||
|
||||
-# Skip all tests if Python scripting is not enabled.
|
||||
-if { [skip_python_tests] } { continue }
|
||||
-
|
||||
gdb_test "python print (gdb.solib_name(0))" "None" "gdb.solib_name exists"
|
||||
|
||||
base-commit: 50ee7556c2430effed45ca542852f36368336dce
|
||||
--
|
||||
2.35.3
|
||||
|
BIN
gdb-13.2.tar.bz2
(Stored with Git LFS)
BIN
gdb-13.2.tar.bz2
(Stored with Git LFS)
Binary file not shown.
BIN
gdb-14.2.tar.bz2
(Stored with Git LFS)
Normal file
BIN
gdb-14.2.tar.bz2
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,109 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.3-bz202689-exec-from-pthread-test.patch
|
||||
|
||||
;; Testcase for exec() from threaded program (BZ 202689).
|
||||
;;=fedoratest
|
||||
|
||||
2007-01-17 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.threads/threaded-exec.exp, gdb.threads/threaded-exec.c: New files.
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.c b/gdb/testsuite/gdb.threads/threaded-exec.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.threads/threaded-exec.c
|
||||
@@ -0,0 +1,46 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2007 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
+ Boston, MA 02111-1307, USA. */
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <pthread.h>
|
||||
+#include <assert.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+
|
||||
+static void *
|
||||
+threader (void *arg)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+ pthread_t t1;
|
||||
+ int i;
|
||||
+
|
||||
+ i = pthread_create (&t1, NULL, threader, (void *) NULL);
|
||||
+ assert (i == 0);
|
||||
+ i = pthread_join (t1, NULL);
|
||||
+ assert (i == 0);
|
||||
+
|
||||
+ execl ("/bin/true", "/bin/true", NULL);
|
||||
+ abort ();
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.threads/threaded-exec.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.threads/threaded-exec.exp
|
||||
@@ -0,0 +1,41 @@
|
||||
+# threaded-exec.exp -- Check reset of the tracked threads on exec*(2)
|
||||
+# Copyright (C) 2007 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# Please email any bugs, comments, and/or additions to this file to:
|
||||
+# bug-gdb@prep.ai.mit.edu
|
||||
+
|
||||
+set testfile threaded-exec
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile [standard_output_file ${testfile}]
|
||||
+
|
||||
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+gdb_run_cmd
|
||||
+
|
||||
+gdb_test_multiple {} "Program exited" {
|
||||
+ -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
|
||||
+ pass "Program exited"
|
||||
+ }
|
||||
+}
|
@ -16,7 +16,7 @@ Subject: gdb-6.3-gstack-20050411.patch
|
||||
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
|
||||
--- a/gdb/Makefile.in
|
||||
+++ b/gdb/Makefile.in
|
||||
@@ -2011,7 +2011,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
|
||||
@@ -2035,7 +2035,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
|
||||
install: all
|
||||
@$(MAKE) $(FLAGS_TO_PASS) install-only
|
||||
|
||||
@ -25,7 +25,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in
|
||||
transformed_name=`t='$(program_transform_name)'; \
|
||||
echo gdb | sed -e "$$t"` ; \
|
||||
if test "x$$transformed_name" = x; then \
|
||||
@@ -2061,7 +2061,25 @@ install-guile:
|
||||
@@ -2085,7 +2085,25 @@ install-guile:
|
||||
install-python:
|
||||
$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
|
||||
|
||||
@ -52,7 +52,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in
|
||||
transformed_name=`t='$(program_transform_name)'; \
|
||||
echo gdb | sed -e $$t` ; \
|
||||
if test "x$$transformed_name" = x; then \
|
||||
@@ -2092,6 +2110,18 @@ uninstall: force $(CONFIG_UNINSTALL)
|
||||
@@ -2116,6 +2134,18 @@ uninstall: force $(CONFIG_UNINSTALL)
|
||||
rm -f $(DESTDIR)$(bindir)/$$transformed_name
|
||||
@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
|
||||
|
||||
|
@ -1,134 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.5-bz109921-DW_AT_decl_file-test.patch
|
||||
|
||||
;; Find symbols properly at their original (included) file (BZ 109921).
|
||||
;;=fedoratest
|
||||
|
||||
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=109921
|
||||
|
||||
It is duplicite to its upstream variant:
|
||||
http://sourceware.org/ml/gdb-cvs/2007-01/msg00157.html
|
||||
http://sourceware.org/ml/gdb-patches/2007-01/msg00434.html
|
||||
2007-01-21 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Daniel Jacobowitz <dan@codesourcery.com>
|
||||
|
||||
* gdb.base/included.c, gdb.base/included.exp,
|
||||
gdb.base/included.h: New files.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
2007-01-09 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.dwarf2/dw2-included.exp, gdb.dwarf2/dw2-included.c,
|
||||
gdb.dwarf2/dw2-included.h: New files.
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-included.c b/gdb/testsuite/gdb.dwarf2/dw2-included.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-included.c
|
||||
@@ -0,0 +1,26 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2006 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
+ USA. */
|
||||
+
|
||||
+#include "dw2-included.h"
|
||||
+
|
||||
+int
|
||||
+main()
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-included.exp b/gdb/testsuite/gdb.dwarf2/dw2-included.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-included.exp
|
||||
@@ -0,0 +1,47 @@
|
||||
+# Copyright 2006 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# Minimal DWARF-2 unit test
|
||||
+
|
||||
+# This test can only be run on targets which support DWARF-2.
|
||||
+# For now pick a sampling of likely targets.
|
||||
+if {![istarget *-*-linux*]
|
||||
+ && ![istarget *-*-gnu*]
|
||||
+ && ![istarget *-*-elf*]
|
||||
+ && ![istarget *-*-openbsd*]
|
||||
+ && ![istarget arm-*-eabi*]
|
||||
+ && ![istarget powerpc-*-eabi*]} {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+set testfile "dw2-included"
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile [standard_output_file ${testfile}]
|
||||
+
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+gdb_test "set listsize 1" ""
|
||||
+gdb_test "list integer" "int integer;\r"
|
||||
+gdb_test "ptype integer" "type = int\r"
|
||||
+# Path varies depending on the build location.
|
||||
+gdb_test "info variables integer" "\r\nFile \[^\r\n\]*/gdb.dwarf2/dw2-included.h:\r\n${decimal}:.*int integer;\r"
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-included.h b/gdb/testsuite/gdb.dwarf2/dw2-included.h
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-included.h
|
||||
@@ -0,0 +1,20 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2006 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
+ USA. */
|
||||
+
|
||||
+int integer;
|
@ -44,7 +44,7 @@ glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug:
|
||||
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
|
||||
--- a/gdb/printcmd.c
|
||||
+++ b/gdb/printcmd.c
|
||||
@@ -1300,6 +1300,10 @@ process_print_command_args (const char *args, value_print_options *print_opts,
|
||||
@@ -1308,6 +1308,11 @@ process_print_command_args (const char *args, value_print_options *print_opts,
|
||||
|
||||
if (exp != nullptr && *exp)
|
||||
{
|
||||
@ -52,9 +52,10 @@ diff --git a/gdb/printcmd.c b/gdb/printcmd.c
|
||||
+ function descriptors. */
|
||||
+ if (target_has_execution () && strcmp (exp, "errno") == 0)
|
||||
+ exp = "*(*(int *(*)(void)) __errno_location) ()";
|
||||
/* VOIDPRINT is true to indicate that we do want to print a void
|
||||
value, so invert it for parse_expression. */
|
||||
expression_up expr = parse_expression (exp, nullptr, !voidprint);
|
||||
+
|
||||
/* This setting allows large arrays to be printed by limiting the
|
||||
number of elements that are loaded into GDB's memory; we only
|
||||
need to load as many array elements as we plan to print. */
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
|
@ -1,135 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.5-ia64-libunwind-leak-test.patch
|
||||
|
||||
;; Test ia64 memory leaks of the code using libunwind.
|
||||
;;=fedoratest
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/unwind-leak.c b/gdb/testsuite/gdb.base/unwind-leak.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/unwind-leak.c
|
||||
@@ -0,0 +1,29 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2007 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+ Please email any bugs, comments, and/or additions to this file to:
|
||||
+ bug-gdb@prep.ai.mit.edu */
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ for (;;)
|
||||
+ alarm (0);
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/unwind-leak.exp b/gdb/testsuite/gdb.base/unwind-leak.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/unwind-leak.exp
|
||||
@@ -0,0 +1,88 @@
|
||||
+# Copyright 2007 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+if {[use_gdb_stub]} {
|
||||
+ untested "skipping test because of use_gdb_stub"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+set testfile unwind-leak
|
||||
+set srcfile ${testfile}.c
|
||||
+set shfile [standard_output_file ${testfile}-gdb.sh]
|
||||
+set binfile [standard_output_file ${testfile}]
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ untested "Couldn't compile test program"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Get things started.
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+set pid [exp_pid -i [board_info host fileid]]
|
||||
+
|
||||
+# For C programs, "start" should stop in main().
|
||||
+
|
||||
+gdb_test "start" \
|
||||
+ "main \\(\\) at .*$srcfile.*" \
|
||||
+ "start"
|
||||
+
|
||||
+set loc [gdb_get_line_number "alarm"]
|
||||
+gdb_breakpoint $loc
|
||||
+
|
||||
+proc memory_get {} {
|
||||
+ global pid
|
||||
+ set fd [open "/proc/$pid/statm"]
|
||||
+ gets $fd line
|
||||
+ close $fd
|
||||
+ # number of pages of data/stack
|
||||
+ scan $line "%*d%*d%*d%*d%*d%d" drs
|
||||
+ return $drs
|
||||
+}
|
||||
+
|
||||
+set cycles 100
|
||||
+# For 100 cycles it was 1308: from = 363 KB, to = 1671 KB
|
||||
+set permit_kb 100
|
||||
+verbose -log "cycles = $cycles, permit_kb = $permit_kb"
|
||||
+
|
||||
+set fail 0
|
||||
+set test "breakpoint stop/continue cycles"
|
||||
+for {set i $cycles} {$i > 0} {set i [expr {$i - 1}]} {
|
||||
+ gdb_test_multiple "continue" $test {
|
||||
+ -re "Breakpoint 2, main .*alarm .*.*${gdb_prompt} $" {
|
||||
+ }
|
||||
+ -re "Segmentation fault" {
|
||||
+ fail $test
|
||||
+ set i 0
|
||||
+ set fail 1
|
||||
+ }
|
||||
+ }
|
||||
+ if ![info exists from] {
|
||||
+ set from [memory_get]
|
||||
+ }
|
||||
+}
|
||||
+set to [memory_get]
|
||||
+if {!$fail} {
|
||||
+ verbose -log "from = $from KB, to = $to KB"
|
||||
+ if {$from > 0 && $to > 10 && $to < $from + $permit_kb} {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+}
|
@ -1,62 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.5-last-address-space-byte-test.patch
|
||||
|
||||
;; Testcase for deadlocking on last address space byte; for corrupted backtraces.
|
||||
;;=fedoratest
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/largecore-last-address-lock.exp b/gdb/testsuite/gdb.base/largecore-last-address-lock.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/largecore-last-address-lock.exp
|
||||
@@ -0,0 +1,49 @@
|
||||
+# Copyright 2006 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+# Get things started.
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+
|
||||
+# i386 (32-bit) only: gdb with Red Hat largecore patch did lock up:
|
||||
+# https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=103263
|
||||
+# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=210614
|
||||
+
|
||||
+# i386: Bug exists when the `target_xfer_memory' condition
|
||||
+# `(memaddr + len < region->hi)' operates on 64-bit operands on
|
||||
+# largecore-patched with 32-bit addresses and so it can get `false' with
|
||||
+# arbitrary `len'.
|
||||
+
|
||||
+# x86_64: The bug is not present as the operands and calculations have the same
|
||||
+# bit size. Would would still need to pass there the highest address
|
||||
+# (`memaddr == 0xffffffffffffffff') but we would need to pass `len == 0'
|
||||
+# to make the condition `(memaddr + len < region->hi)' false.
|
||||
+# `len == 0' would get caught eariler.
|
||||
+
|
||||
+# Error in the success case is immediate.
|
||||
+set timeoutold ${timeout}
|
||||
+set timeout 10
|
||||
+
|
||||
+gdb_test "x/xb 0xffffffff" \
|
||||
+ "Cannot access memory at address 0xffffffff" \
|
||||
+ "Read the last address space byte"
|
||||
+
|
||||
+set timeout ${timeoutold}
|
@ -1,95 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.5-missed-trap-on-step-test.patch
|
||||
|
||||
;; Test hiding unexpected breakpoints on intentional step commands.
|
||||
;;=fedoratest
|
||||
|
||||
Fix has been committed to:
|
||||
gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.c b/gdb/testsuite/gdb.base/watchpoint-during-step.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/watchpoint-during-step.c
|
||||
@@ -0,0 +1,30 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2007 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+ Please email any bugs, comments, and/or additions to this file to:
|
||||
+ bug-gdb@prep.ai.mit.edu */
|
||||
+
|
||||
+static int var;
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ var = 1;
|
||||
+ var = 2;
|
||||
+ var = 3;
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.exp b/gdb/testsuite/gdb.base/watchpoint-during-step.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/watchpoint-during-step.exp
|
||||
@@ -0,0 +1,44 @@
|
||||
+# Copyright 2007 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+set testfile watchpoint-during-step
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile [standard_output_file ${testfile}]
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ untested "Couldn't compile test program"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Get things started.
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+runto_main
|
||||
+
|
||||
+gdb_breakpoint [gdb_get_line_number "var = 2"]
|
||||
+gdb_continue_to_breakpoint "Find the first var set"
|
||||
+
|
||||
+gdb_test "step" ".*var = 3;" "Step to the next var set"
|
||||
+
|
||||
+gdb_test "watch var" "atchpoint .*: var" "Set the watchpoint"
|
||||
+
|
||||
+# Here is the target point. Be careful to not have breakpoint set on the line
|
||||
+# we step from as in this case it is a valid upstream KFAIL gdb/38
|
||||
+
|
||||
+gdb_test "step" ".*Old value = 2.*New value = 3.*" "Catch the watchpoint"
|
@ -1,193 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.5-sharedlibrary-path.patch
|
||||
|
||||
;; Fix TLS symbols resolving for shared libraries with a relative pathname.
|
||||
;; The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'.
|
||||
;;=fedoratest: One should recheck if it is really fixed upstream.
|
||||
|
||||
If you provided some relative path to the shared library, such as with
|
||||
export LD_LIBRARY_PATH=.
|
||||
then gdb would fail to match the shared library name during the TLS lookup.
|
||||
|
||||
Dropped the workaround/fix for gdb-6.8.50.20081128 - is it still needed?
|
||||
|
||||
The testsuite needs `gdb-6.3-bz146810-solib_absolute_prefix_is_empty.patch'.
|
||||
The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'.
|
||||
|
||||
2006-09-01 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* solib-svr4.c (svr4_fetch_objfile_link_map): Match even absolute
|
||||
requested pathnames to the internal loaded relative pathnames.
|
||||
|
||||
2007-10-16 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
Port to GDB-6.7.
|
||||
|
||||
2008-02-27 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
Port to gdb-6.7.50.20080227.
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-main.c b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c
|
||||
@@ -0,0 +1,31 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2006 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+ Please email any bugs, comments, and/or additions to this file to:
|
||||
+ bug-gdb@prep.ai.mit.edu */
|
||||
+
|
||||
+#include <pthread.h>
|
||||
+
|
||||
+extern __thread int var;
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ /* Ensure we link against pthreads even with --as-needed. */
|
||||
+ pthread_testcancel();
|
||||
+ return var;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2006 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+ Please email any bugs, comments, and/or additions to this file to:
|
||||
+ bug-gdb@prep.ai.mit.edu */
|
||||
+
|
||||
+__thread int var = 42;
|
||||
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
|
||||
@@ -0,0 +1,94 @@
|
||||
+# Copyright 2006 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# This test uses gdb_exit and gdb_start, which are not supported
|
||||
+# on non-extended-remote sessions.
|
||||
+if {[use_gdb_stub]} {
|
||||
+ untested "skipping test because of stub"
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set testfile tls-sepdebug
|
||||
+set srcmainfile ${testfile}-main.c
|
||||
+set srcsharedfile ${testfile}-shared.c
|
||||
+
|
||||
+set binmainfile [standard_output_file ${testfile}-main]
|
||||
+set binsharedbase ${testfile}-shared.so
|
||||
+set binsharedfile [standard_output_file ${binsharedbase}]
|
||||
+set binshareddebugfile [standard_output_file ${binsharedbase}.debug]
|
||||
+
|
||||
+# Use explicit -soname as otherwise the full path to the library would get
|
||||
+# encoded into ${binmainfile} making LD_LIBRARY_PATH tests useless.
|
||||
+
|
||||
+# FIXME: gcc dependency (-Wl,-soname).
|
||||
+
|
||||
+if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]] != "" } {
|
||||
+ untested "Couldn't compile test library"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# eu-strip(1) works fine but it is a part of `elfutils', not `binutils'.
|
||||
+if 0 then {
|
||||
+ remote_exec build "eu-strip -f ${binshareddebugfile} ${binsharedfile}"
|
||||
+} else {
|
||||
+ remote_exec build "objcopy --only-keep-debug ${binsharedfile} ${binshareddebugfile}"
|
||||
+ remote_exec build "objcopy --strip-debug ${binsharedfile}"
|
||||
+ remote_exec build "objcopy --add-gnu-debuglink=${binshareddebugfile} ${binsharedfile}"
|
||||
+}
|
||||
+
|
||||
+# Do not use `shlib=' as it will automatically add also -rpath for gcc.
|
||||
+
|
||||
+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcmainfile} ${binsharedfile}" "${binmainfile}" executable {debug}] != "" } {
|
||||
+ untested "Couldn't compile test program"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Get things started.
|
||||
+
|
||||
+# Test also the proper resolving of relative library names to absolute ones.
|
||||
+# \$PWD is easy - it is the absolute way
|
||||
+# ${subdir} would fail on "print var"
|
||||
+
|
||||
+set absdir [file dirname [standard_output_file ${binsharedbase}]]
|
||||
+foreach ld_library_path [list $absdir [relative_filename [pwd] $absdir]] name { absolute relative } {
|
||||
+
|
||||
+ gdb_exit
|
||||
+ gdb_start
|
||||
+ ###gdb_reinitialize_dir $srcdir/$subdir
|
||||
+
|
||||
+ gdb_test "set env LD_LIBRARY_PATH=$ld_library_path" \
|
||||
+ "" \
|
||||
+ "set env LD_LIBRARY_PATH is $name"
|
||||
+
|
||||
+ gdb_load ${binmainfile}
|
||||
+
|
||||
+ # For C programs, "start" should stop in main().
|
||||
+
|
||||
+ gdb_test "start" \
|
||||
+ "main \\(\\) at .*${srcmainfile}.*" \
|
||||
+ "start"
|
||||
+
|
||||
+ # Check for: Cannot find shared library `/usr/lib/debug/lib/libc-2.4.90.so.debug' in dynamic linker's load module list
|
||||
+ # as happens with TLS variables and `separate_debug_objfile_backlink'.
|
||||
+
|
||||
+ gdb_test "print var" \
|
||||
+ "\\\$1 = \[0-9\].*" \
|
||||
+ "print TLS variable from a shared library with $name-directory separate debug info file"
|
||||
+}
|
@ -1,14 +1,5 @@
|
||||
From 444f438fe775a9480b93dc7d63418e0e169b4fbd Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 21 Apr 2023 09:08:03 +0200
|
||||
Subject: [PATCH 1/5] gdb-6.6-buildid-locate-rpm-suse.patch
|
||||
|
||||
---
|
||||
gdb/build-id.c | 71 +++++++++-----------------------------------------
|
||||
1 file changed, 13 insertions(+), 58 deletions(-)
|
||||
|
||||
diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
index 86dfc8409b5..29aa10d8225 100644
|
||||
index 059a72fc050..58d73e70bad 100644
|
||||
--- a/gdb/build-id.c
|
||||
+++ b/gdb/build-id.c
|
||||
@@ -863,10 +863,8 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
|
||||
@ -109,28 +100,24 @@ index 86dfc8409b5..29aa10d8225 100644
|
||||
for (const char *el : array)
|
||||
{
|
||||
gdb_printf (" %s", el);
|
||||
@@ -1295,13 +1251,12 @@ debug_print_missing (const char *binary, const char *debug)
|
||||
gdb_printf (gdb_stdlog,
|
||||
_("Missing separate debuginfo for %s\n"), binary);
|
||||
@@ -1296,14 +1252,15 @@ debug_print_missing (const char *binary, const char *debug)
|
||||
_("Missing separate debuginfo for %s.\n"), binary);
|
||||
if (debug != NULL)
|
||||
{
|
||||
+#ifdef HAVE_LIBRPM
|
||||
if (access (debug, F_OK) == 0) {
|
||||
- gdb_printf (gdb_stdlog, _("Try: %s %s\n"),
|
||||
-#ifdef DNF_DEBUGINFO_INSTALL
|
||||
- "dnf"
|
||||
-#else
|
||||
#else
|
||||
- "yum"
|
||||
-#endif
|
||||
+ if (1) {
|
||||
#endif
|
||||
- " --enablerepo='*debug*' install", debug);
|
||||
+ {
|
||||
+ const char *p = strrchr (debug, '/');
|
||||
+ gdb_printf (gdb_stdlog, _("Try: %s%.2s%.38s\"\n"),
|
||||
+ "zypper install -C \"debuginfo(build-id)=",
|
||||
+ p - 2, p + 1);
|
||||
+ }
|
||||
} else
|
||||
gdb_printf (gdb_stdlog, _("The debuginfo package for this file is probably broken.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
base-commit: 91ac179279557e27e6a149cbb78e4052a348f109
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
@ -235,7 +235,7 @@ diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
|
||||
diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
--- a/gdb/build-id.c
|
||||
+++ b/gdb/build-id.c
|
||||
@@ -771,10 +771,10 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
|
||||
@@ -780,10 +780,10 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
|
||||
static rpmts (*rpmtsCreate_p) (void);
|
||||
extern rpmts rpmtsFree(rpmts ts);
|
||||
static rpmts (*rpmtsFree_p) (rpmts ts);
|
||||
@ -248,7 +248,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
const void *keyp,
|
||||
size_t keylen);
|
||||
#else /* !DLOPEN_LIBRPM */
|
||||
@@ -829,7 +829,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
|
||||
@@ -838,7 +838,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
|
||||
&& (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
|
||||
&& (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
|
||||
&& (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
|
||||
@ -257,7 +257,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
{
|
||||
warning (_("Opened library \"%s\" is incompatible (%s), "
|
||||
"missing debuginfos notifications will not be displayed"),
|
||||
@@ -917,7 +917,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
|
||||
@@ -926,7 +926,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
|
||||
|
||||
/* RPMDBI_PACKAGES requires keylen == sizeof (int). */
|
||||
/* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */
|
||||
@ -269,7 +269,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
diff --git a/gdb/config.in b/gdb/config.in
|
||||
--- a/gdb/config.in
|
||||
+++ b/gdb/config.in
|
||||
@@ -39,6 +39,9 @@
|
||||
@@ -42,6 +42,9 @@
|
||||
/* Handle .ctf type-info sections */
|
||||
#undef ENABLE_LIBCTF
|
||||
|
||||
@ -279,9 +279,9 @@ diff --git a/gdb/config.in b/gdb/config.in
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
#undef ENABLE_NLS
|
||||
@@ -259,6 +262,9 @@
|
||||
/* Define if you have the mpfr library. */
|
||||
#undef HAVE_LIBMPFR
|
||||
@@ -265,6 +268,9 @@
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
+/* Define if librpm library is being used. */
|
||||
+#undef HAVE_LIBRPM
|
||||
@ -292,7 +292,7 @@ diff --git a/gdb/config.in b/gdb/config.in
|
||||
diff --git a/gdb/configure b/gdb/configure
|
||||
--- a/gdb/configure
|
||||
+++ b/gdb/configure
|
||||
@@ -783,6 +783,11 @@ TARGET_OBS
|
||||
@@ -778,6 +778,11 @@ AMD_DBGAPI_CFLAGS
|
||||
ENABLE_BFD_64_BIT_FALSE
|
||||
ENABLE_BFD_64_BIT_TRUE
|
||||
subdirs
|
||||
@ -304,16 +304,16 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
GDB_DATADIR
|
||||
DEBUGDIR
|
||||
MAKEINFO_EXTRA_FLAGS
|
||||
@@ -912,6 +917,7 @@ with_gdb_datadir
|
||||
@@ -911,6 +916,7 @@ with_gdb_datadir
|
||||
with_relocated_sources
|
||||
with_auto_load_dir
|
||||
with_auto_load_safe_path
|
||||
+with_rpm
|
||||
enable_targets
|
||||
enable_64_bit_bfd
|
||||
enable_gdbmi
|
||||
@@ -992,6 +998,8 @@ PKG_CONFIG_PATH
|
||||
PKG_CONFIG_LIBDIR
|
||||
with_amd_dbgapi
|
||||
@@ -988,6 +994,8 @@ AMD_DBGAPI_CFLAGS
|
||||
AMD_DBGAPI_LIBS
|
||||
DEBUGINFOD_CFLAGS
|
||||
DEBUGINFOD_LIBS
|
||||
+RPM_CFLAGS
|
||||
@ -321,8 +321,8 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
YACC
|
||||
YFLAGS
|
||||
ZSTD_CFLAGS
|
||||
@@ -1678,6 +1686,8 @@ Optional Packages:
|
||||
do not restrict auto-loaded files locations
|
||||
@@ -1679,6 +1687,8 @@ Optional Packages:
|
||||
--with-amd-dbgapi support for the amd-dbgapi target (yes / no / auto)
|
||||
--with-debuginfod Enable debuginfo lookups with debuginfod
|
||||
(auto/yes/no)
|
||||
+ --with-rpm query rpm database for missing debuginfos (yes/no,
|
||||
@ -330,7 +330,7 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
--with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
|
||||
--with-curses use the curses library instead of the termcap
|
||||
library
|
||||
@@ -1761,6 +1771,8 @@ Some influential environment variables:
|
||||
@@ -1759,6 +1769,8 @@ Some influential environment variables:
|
||||
C compiler flags for DEBUGINFOD, overriding pkg-config
|
||||
DEBUGINFOD_LIBS
|
||||
linker flags for DEBUGINFOD, overriding pkg-config
|
||||
@ -339,7 +339,7 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
YACC The `Yet Another Compiler Compiler' implementation to use.
|
||||
Defaults to the first program found out of: `bison -y', `byacc',
|
||||
`yacc'.
|
||||
@@ -17848,6 +17860,494 @@ _ACEOF
|
||||
@@ -18039,6 +18051,495 @@ _ACEOF
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
|
||||
$as_echo "$with_auto_load_safe_path" >&6; }
|
||||
|
||||
@ -403,6 +403,7 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
+#include <rpm/rpmlib.h>
|
||||
+#include <dlfcn.h>
|
||||
+#include <errno.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+int
|
||||
+main ()
|
||||
@ -837,7 +838,7 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
diff --git a/gdb/configure.ac b/gdb/configure.ac
|
||||
--- a/gdb/configure.ac
|
||||
+++ b/gdb/configure.ac
|
||||
@@ -160,6 +160,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
|
||||
@@ -173,6 +173,200 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
|
||||
[Directories safe to hold auto-loaded files.])
|
||||
AC_MSG_RESULT([$with_auto_load_safe_path])
|
||||
|
||||
@ -887,6 +888,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac
|
||||
+#include <rpm/rpmlib.h>
|
||||
+#include <dlfcn.h>
|
||||
+#include <errno.h>
|
||||
+#include <string.h>
|
||||
+ ]], [[
|
||||
+ void *h;
|
||||
+ const char *const *rpmverp;
|
||||
@ -1048,7 +1050,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
|
||||
|
||||
/* readline include files. */
|
||||
#include "readline/readline.h"
|
||||
@@ -391,6 +392,8 @@ display_gdb_prompt (const char *new_prompt)
|
||||
@@ -404,6 +405,8 @@ display_gdb_prompt (const char *new_prompt)
|
||||
/* Reset the nesting depth used when trace-commands is set. */
|
||||
reset_command_nest_depth ();
|
||||
|
||||
@ -1057,7 +1059,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
|
||||
/* Do not call the python hook on an explicit prompt change as
|
||||
passed to this function, as this forms a secondary/local prompt,
|
||||
IE, displayed but not set. */
|
||||
@@ -852,7 +855,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
|
||||
@@ -788,7 +791,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
|
||||
command_handler (cmd);
|
||||
|
||||
if (ui->prompt_state != PROMPTED)
|
||||
@ -1072,7 +1074,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
|
||||
diff --git a/gdb/symfile.h b/gdb/symfile.h
|
||||
--- a/gdb/symfile.h
|
||||
+++ b/gdb/symfile.h
|
||||
@@ -352,6 +352,7 @@ extern void generic_load (const char *args, int from_tty);
|
||||
@@ -367,6 +367,7 @@ extern void generic_load (const char *args, int from_tty);
|
||||
/* build-id support. */
|
||||
extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
|
||||
extern void debug_print_missing (const char *binary, const char *debug);
|
||||
|
@ -14,7 +14,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1339862
|
||||
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
|
||||
--- a/gdb/solib-svr4.c
|
||||
+++ b/gdb/solib-svr4.c
|
||||
@@ -1321,14 +1321,28 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
|
||||
@@ -1320,14 +1320,28 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
|
||||
}
|
||||
|
||||
{
|
||||
@ -45,7 +45,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
|
||||
if (build_id != NULL)
|
||||
{
|
||||
char *name, *build_id_filename;
|
||||
@@ -1343,23 +1357,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
|
||||
@@ -1342,23 +1356,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
|
||||
xfree (name);
|
||||
}
|
||||
else
|
||||
|
@ -9,7 +9,7 @@ Subject: gdb-6.6-buildid-locate.patch
|
||||
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
|
||||
--- a/bfd/libbfd-in.h
|
||||
+++ b/bfd/libbfd-in.h
|
||||
@@ -115,7 +115,7 @@ static inline char *
|
||||
@@ -110,7 +110,7 @@ static inline char *
|
||||
bfd_strdup (const char *str)
|
||||
{
|
||||
size_t len = strlen (str) + 1;
|
||||
@ -21,7 +21,7 @@ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
|
||||
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
|
||||
--- a/bfd/libbfd.h
|
||||
+++ b/bfd/libbfd.h
|
||||
@@ -121,7 +121,7 @@ static inline char *
|
||||
@@ -116,7 +116,7 @@ static inline char *
|
||||
bfd_strdup (const char *str)
|
||||
{
|
||||
size_t len = strlen (str) + 1;
|
||||
@ -33,7 +33,7 @@ diff --git a/bfd/libbfd.h b/bfd/libbfd.h
|
||||
diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
--- a/gdb/build-id.c
|
||||
+++ b/gdb/build-id.c
|
||||
@@ -24,13 +24,71 @@
|
||||
@@ -24,14 +24,72 @@
|
||||
#include "gdbsupport/gdb_vecs.h"
|
||||
#include "symfile.h"
|
||||
#include "objfiles.h"
|
||||
@ -46,6 +46,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
+#include "gdb_bfd.h"
|
||||
+#include "gdbcmd.h"
|
||||
#include "gdbcore.h"
|
||||
#include "cli/cli-style.h"
|
||||
+#include "inferior.h"
|
||||
+#include "objfiles.h"
|
||||
+#include "observable.h"
|
||||
@ -104,9 +105,9 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
-build_id_bfd_get (bfd *abfd)
|
||||
+build_id_bfd_shdr_get (bfd *abfd)
|
||||
{
|
||||
if (!bfd_check_format (abfd, bfd_object)
|
||||
&& !bfd_check_format (abfd, bfd_core))
|
||||
@@ -43,6 +101,348 @@ build_id_bfd_get (bfd *abfd)
|
||||
/* Dynamic objfiles such as ones created by JIT reader API
|
||||
have no underlying bfd structure (that is, objfile->obfd
|
||||
@@ -50,6 +108,348 @@ build_id_bfd_get (bfd *abfd)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -455,7 +456,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
/* See build-id.h. */
|
||||
|
||||
int
|
||||
@@ -51,7 +451,7 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
|
||||
@@ -58,7 +458,7 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
|
||||
const struct bfd_build_id *found;
|
||||
int retval = 0;
|
||||
|
||||
@ -464,7 +465,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
|
||||
if (found == NULL)
|
||||
warning (_("File \"%s\" has no build-id, file skipped"),
|
||||
@@ -66,63 +466,166 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
|
||||
@@ -73,63 +473,166 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -664,7 +665,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
}
|
||||
|
||||
/* Common code for finding BFDs of a given build-id. This function
|
||||
@@ -131,7 +634,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
|
||||
@@ -138,7 +641,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
|
||||
|
||||
static gdb_bfd_ref_ptr
|
||||
build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|
||||
@ -673,7 +674,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
{
|
||||
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
|
||||
cause "/.build-id/..." lookups. */
|
||||
@@ -154,16 +657,17 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|
||||
@@ -161,16 +664,17 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|
||||
if (size > 0)
|
||||
{
|
||||
size--;
|
||||
@ -694,7 +695,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
if (debug_bfd != NULL)
|
||||
return debug_bfd;
|
||||
|
||||
@@ -174,7 +678,7 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|
||||
@@ -181,7 +685,7 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|
||||
if (!gdb_sysroot.empty ())
|
||||
{
|
||||
link = gdb_sysroot + link;
|
||||
@ -703,7 +704,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
if (debug_bfd != NULL)
|
||||
return debug_bfd;
|
||||
}
|
||||
@@ -183,30 +687,655 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|
||||
@@ -190,31 +694,663 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -721,6 +722,8 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+void debug_flush_missing (void);
|
||||
+
|
||||
+#ifdef HAVE_LIBRPM
|
||||
+
|
||||
+#include <rpm/rpmlib.h>
|
||||
@ -1220,7 +1223,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+debug_print_executable_changed (void)
|
||||
+debug_print_executable_changed (struct program_space *pspace, bool reload_p)
|
||||
+{
|
||||
+#ifdef HAVE_LIBRPM
|
||||
+ missing_rpm_change ();
|
||||
@ -1313,8 +1316,10 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
+ already requires its own separate lines. */
|
||||
+
|
||||
+ gdb_printf (gdb_stdlog,
|
||||
+ _("Missing separate debuginfo for %s\n"), binary);
|
||||
+ _("Missing separate debuginfo for %s.\n"), binary);
|
||||
+ if (debug != NULL)
|
||||
+ {
|
||||
+ if (access (debug, F_OK) == 0) {
|
||||
+ gdb_printf (gdb_stdlog, _("Try: %s %s\n"),
|
||||
+#ifdef DNF_DEBUGINFO_INSTALL
|
||||
+ "dnf"
|
||||
@ -1322,6 +1327,9 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
+ "yum"
|
||||
+#endif
|
||||
+ " --enablerepo='*debug*' install", debug);
|
||||
+ } else
|
||||
+ gdb_printf (gdb_stdlog, _("The debuginfo package for this file is probably broken.\n"));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
@ -1351,8 +1359,9 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
/* See build-id.h. */
|
||||
|
||||
std::string
|
||||
-find_separate_debug_file_by_buildid (struct objfile *objfile)
|
||||
+find_separate_debug_file_by_buildid (struct objfile *objfile,
|
||||
find_separate_debug_file_by_buildid (struct objfile *objfile,
|
||||
- deferred_warnings *warnings)
|
||||
+ deferred_warnings *warnings,
|
||||
+ gdb::unique_xmalloc_ptr<char> *build_id_filename_return)
|
||||
{
|
||||
const struct bfd_build_id *build_id;
|
||||
@ -1365,7 +1374,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
if (build_id != NULL)
|
||||
{
|
||||
if (separate_debug_file_debug)
|
||||
@@ -214,8 +1343,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
|
||||
@@ -222,8 +1358,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile,
|
||||
_("\nLooking for separate debug info (build-id) for "
|
||||
"%s\n"), objfile_name (objfile));
|
||||
|
||||
@ -1388,7 +1397,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
|
||||
/* Prevent looping on a stripped .debug file. */
|
||||
if (abfd != NULL
|
||||
&& filename_cmp (bfd_get_filename (abfd.get ()),
|
||||
@@ -228,3 +1370,22 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
|
||||
@@ -243,3 +1392,22 @@ find_separate_debug_file_by_buildid (struct objfile *objfile,
|
||||
|
||||
return std::string ();
|
||||
}
|
||||
@ -1427,7 +1436,7 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h
|
||||
|
||||
/* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value.
|
||||
Otherwise, issue a warning and return false. */
|
||||
@@ -38,21 +39,26 @@ extern int build_id_verify (bfd *abfd,
|
||||
@@ -38,14 +39,19 @@ extern int build_id_verify (bfd *abfd,
|
||||
can be found, return NULL. */
|
||||
|
||||
extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len,
|
||||
@ -1449,11 +1458,12 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h
|
||||
|
||||
/* Find the separate debug file for OBJFILE, by using the build-id
|
||||
associated with OBJFILE's BFD. If successful, returns the file name for the
|
||||
separate debug file, otherwise, return an empty string. */
|
||||
@@ -58,7 +64,8 @@ extern gdb_bfd_ref_ptr build_id_to_exec_bfd (size_t build_id_len,
|
||||
will be printed. */
|
||||
|
||||
-extern std::string find_separate_debug_file_by_buildid
|
||||
- (struct objfile *objfile);
|
||||
+extern std::string find_separate_debug_file_by_buildid (struct objfile *objfile,
|
||||
extern std::string find_separate_debug_file_by_buildid
|
||||
- (struct objfile *objfile, deferred_warnings *warnings);
|
||||
+ (struct objfile *objfile, deferred_warnings *warnings,
|
||||
+ gdb::unique_xmalloc_ptr<char> *build_id_filename_return);
|
||||
|
||||
/* Return an hex-string representation of BUILD_ID. */
|
||||
@ -1461,23 +1471,22 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h
|
||||
diff --git a/gdb/coffread.c b/gdb/coffread.c
|
||||
--- a/gdb/coffread.c
|
||||
+++ b/gdb/coffread.c
|
||||
@@ -734,7 +734,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||
/* Try to add separate debug file if no symbols table found. */
|
||||
if (!objfile->has_partial_symbols ())
|
||||
@@ -729,7 +729,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||
{
|
||||
- std::string debugfile = find_separate_debug_file_by_buildid (objfile);
|
||||
+ std::string debugfile = find_separate_debug_file_by_buildid (objfile,
|
||||
+ NULL);
|
||||
deferred_warnings warnings;
|
||||
std::string debugfile
|
||||
- = find_separate_debug_file_by_buildid (objfile, &warnings);
|
||||
+ = find_separate_debug_file_by_buildid (objfile, &warnings, NULL);
|
||||
|
||||
if (debugfile.empty ())
|
||||
debugfile = find_separate_debug_file_by_debuglink (objfile);
|
||||
debugfile
|
||||
diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
--- a/gdb/corelow.c
|
||||
+++ b/gdb/corelow.c
|
||||
@@ -22,6 +22,10 @@
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include "frame.h" /* required by inferior.h */
|
||||
#include "frame.h"
|
||||
+#include "auxv.h"
|
||||
+#include "build-id.h"
|
||||
+#include "elf/common.h"
|
||||
@ -1485,7 +1494,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
#include "inferior.h"
|
||||
#include "infrun.h"
|
||||
#include "symtab.h"
|
||||
@@ -391,6 +395,8 @@ add_to_thread_list (asection *asect, asection *reg_sect)
|
||||
@@ -380,6 +384,8 @@ add_to_thread_list (asection *asect, asection *reg_sect, inferior *inf)
|
||||
switch_to_thread (thr); /* Yes, make it current. */
|
||||
}
|
||||
|
||||
@ -1494,7 +1503,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
/* Issue a message saying we have no core to debug, if FROM_TTY. */
|
||||
|
||||
static void
|
||||
@@ -427,12 +433,14 @@ core_file_command (const char *filename, int from_tty)
|
||||
@@ -563,12 +569,14 @@ rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf)
|
||||
static void
|
||||
locate_exec_from_corefile_build_id (bfd *abfd, int from_tty)
|
||||
{
|
||||
@ -1511,7 +1520,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
|
||||
if (execbfd == nullptr)
|
||||
{
|
||||
@@ -460,7 +468,12 @@ locate_exec_from_corefile_build_id (bfd *abfd, int from_tty)
|
||||
@@ -596,7 +604,12 @@ locate_exec_from_corefile_build_id (bfd *abfd, int from_tty)
|
||||
exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty);
|
||||
symbol_file_add_main (bfd_get_filename (execbfd.get ()),
|
||||
symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0));
|
||||
@ -1524,7 +1533,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
}
|
||||
|
||||
/* See gdbcore.h. */
|
||||
@@ -1325,4 +1338,11 @@ _initialize_corelow ()
|
||||
@@ -1506,4 +1519,11 @@ _initialize_corelow ()
|
||||
maintenance_print_core_file_backed_mappings,
|
||||
_("Print core file's file-backed mappings."),
|
||||
&maintenanceprintlist);
|
||||
@ -1539,7 +1548,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
|
||||
--- a/gdb/doc/gdb.texinfo
|
||||
+++ b/gdb/doc/gdb.texinfo
|
||||
@@ -22037,6 +22037,27 @@ information files.
|
||||
@@ -22296,6 +22296,27 @@ information files.
|
||||
|
||||
@end table
|
||||
|
||||
@ -1570,16 +1579,16 @@ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
|
||||
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
|
||||
--- a/gdb/dwarf2/index-cache.c
|
||||
+++ b/gdb/dwarf2/index-cache.c
|
||||
@@ -101,7 +101,7 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
|
||||
@@ -96,7 +96,7 @@ index_cache_store_context::index_cache_store_context (const index_cache &ic,
|
||||
return;
|
||||
|
||||
/* Get build id of objfile. */
|
||||
- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd.get ());
|
||||
+ const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd.get ());
|
||||
- const bfd_build_id *build_id = build_id_bfd_get (per_bfd->obfd);
|
||||
+ const bfd_build_id *build_id = build_id_bfd_shdr_get (per_bfd->obfd);
|
||||
if (build_id == nullptr)
|
||||
{
|
||||
index_cache_debug ("objfile %s has no build id",
|
||||
@@ -118,7 +118,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
|
||||
@@ -111,7 +111,8 @@ index_cache_store_context::index_cache_store_context (const index_cache &ic,
|
||||
|
||||
if (dwz != nullptr)
|
||||
{
|
||||
@ -1592,7 +1601,7 @@ diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -5328,7 +5328,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner)
|
||||
@@ -3355,7 +3355,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner)
|
||||
static gdb::array_view<const gdb_byte>
|
||||
get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd)
|
||||
{
|
||||
@ -1601,7 +1610,7 @@ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
if (build_id == nullptr)
|
||||
return {};
|
||||
|
||||
@@ -5341,7 +5341,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd)
|
||||
@@ -3368,7 +3368,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd)
|
||||
static gdb::array_view<const gdb_byte>
|
||||
get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz)
|
||||
{
|
||||
@ -1613,18 +1622,19 @@ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
diff --git a/gdb/elfread.c b/gdb/elfread.c
|
||||
--- a/gdb/elfread.c
|
||||
+++ b/gdb/elfread.c
|
||||
@@ -1213,7 +1213,9 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
&& objfile->separate_debug_objfile == NULL
|
||||
&& objfile->separate_debug_objfile_backlink == NULL)
|
||||
@@ -1220,8 +1220,10 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
{
|
||||
- std::string debugfile = find_separate_debug_file_by_buildid (objfile);
|
||||
deferred_warnings warnings;
|
||||
|
||||
+ gdb::unique_xmalloc_ptr<char> build_id_filename;
|
||||
+ std::string debugfile
|
||||
+ = find_separate_debug_file_by_buildid (objfile, &build_id_filename);
|
||||
std::string debugfile
|
||||
- = find_separate_debug_file_by_buildid (objfile, &warnings);
|
||||
+ = find_separate_debug_file_by_buildid (objfile, &warnings,
|
||||
+ &build_id_filename);
|
||||
|
||||
if (debugfile.empty ())
|
||||
debugfile = find_separate_debug_file_by_debuglink (objfile);
|
||||
@@ -1229,7 +1231,7 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
debugfile = find_separate_debug_file_by_debuglink (objfile, &warnings);
|
||||
@@ -1239,7 +1241,7 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
{
|
||||
has_dwarf2 = false;
|
||||
const struct bfd_build_id *build_id
|
||||
@ -1633,7 +1643,7 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c
|
||||
const char *filename = bfd_get_filename (objfile->obfd.get ());
|
||||
|
||||
if (build_id != nullptr)
|
||||
@@ -1256,6 +1258,11 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
@@ -1265,6 +1267,11 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
has_dwarf2 = true;
|
||||
}
|
||||
}
|
||||
@ -1644,7 +1654,7 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c
|
||||
+ debug_print_missing (objfile_name (objfile), build_id_filename.get ());
|
||||
}
|
||||
}
|
||||
}
|
||||
/* If all the methods to collect the debuginfo failed, print the
|
||||
diff --git a/gdb/exec.c b/gdb/exec.c
|
||||
--- a/gdb/exec.c
|
||||
+++ b/gdb/exec.c
|
||||
@ -1669,8 +1679,8 @@ diff --git a/gdb/exec.c b/gdb/exec.c
|
||||
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
|
||||
--- a/gdb/objfiles.h
|
||||
+++ b/gdb/objfiles.h
|
||||
@@ -786,6 +786,10 @@ struct objfile
|
||||
bool skip_jit_symbol_lookup = false;
|
||||
@@ -884,6 +884,10 @@ struct objfile
|
||||
bool object_format_has_copy_relocs = false;
|
||||
};
|
||||
|
||||
+/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */
|
||||
@ -1704,7 +1714,7 @@ diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
|
||||
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
|
||||
--- a/gdb/solib-svr4.c
|
||||
+++ b/gdb/solib-svr4.c
|
||||
@@ -45,6 +45,7 @@
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "auxv.h"
|
||||
#include "gdb_bfd.h"
|
||||
#include "probe.h"
|
||||
@ -1712,7 +1722,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -1319,9 +1320,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
|
||||
@@ -1318,9 +1319,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1770,7 +1780,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
|
||||
diff --git a/gdb/source.c b/gdb/source.c
|
||||
--- a/gdb/source.c
|
||||
+++ b/gdb/source.c
|
||||
@@ -1196,7 +1196,7 @@ open_source_file (struct symtab *s)
|
||||
@@ -1167,7 +1167,7 @@ open_source_file (struct symtab *s)
|
||||
}
|
||||
|
||||
const struct bfd_build_id *build_id
|
||||
@ -1782,7 +1792,7 @@ diff --git a/gdb/source.c b/gdb/source.c
|
||||
diff --git a/gdb/symfile.h b/gdb/symfile.h
|
||||
--- a/gdb/symfile.h
|
||||
+++ b/gdb/symfile.h
|
||||
@@ -342,12 +342,18 @@ bool expand_symtabs_matching
|
||||
@@ -357,12 +357,18 @@ bool expand_symtabs_matching
|
||||
void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
|
||||
bool need_fullname);
|
||||
|
||||
@ -1804,7 +1814,7 @@ diff --git a/gdb/symfile.h b/gdb/symfile.h
|
||||
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
|
||||
--- a/gdb/testsuite/gdb.base/corefile.exp
|
||||
+++ b/gdb/testsuite/gdb.base/corefile.exp
|
||||
@@ -349,3 +349,33 @@ gdb_test_multiple "core-file $corefile" $test {
|
||||
@@ -347,3 +347,33 @@ gdb_test_multiple "core-file $corefile" $test {
|
||||
pass $test
|
||||
}
|
||||
}
|
||||
@ -1841,7 +1851,7 @@ diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefi
|
||||
diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp
|
||||
--- a/gdb/testsuite/gdb.base/gdbinit-history.exp
|
||||
+++ b/gdb/testsuite/gdb.base/gdbinit-history.exp
|
||||
@@ -185,7 +185,8 @@ proc test_empty_history_filename { } {
|
||||
@@ -179,7 +179,8 @@ proc test_empty_history_filename { } {
|
||||
global env
|
||||
global gdb_prompt
|
||||
|
||||
@ -1865,17 +1875,17 @@ diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.exp b/gdb/testsuite/gdb
|
||||
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
|
||||
--- a/gdb/testsuite/lib/gdb.exp
|
||||
+++ b/gdb/testsuite/lib/gdb.exp
|
||||
@@ -217,7 +217,8 @@ if ![info exists INTERNAL_GDBFLAGS] {
|
||||
"-nw" \
|
||||
@@ -226,7 +226,8 @@ if ![info exists INTERNAL_GDBFLAGS] {
|
||||
"-nx" \
|
||||
"-q" \
|
||||
{-iex "set height 0"} \
|
||||
- {-iex "set width 0"}]]
|
||||
+ {-iex "set width 0"} \
|
||||
+ {-iex "set build-id-verbose 0"}]]
|
||||
|
||||
set INTERNAL_GDBFLAGS [append_gdb_data_directory_option $INTERNAL_GDBFLAGS]
|
||||
}
|
||||
@@ -2349,6 +2350,17 @@ proc default_gdb_start { } {
|
||||
# If DEBUGINFOD_URLS is set, gdb will try to download sources and
|
||||
# debug info for f.i. system libraries. Prevent this.
|
||||
@@ -2434,6 +2435,17 @@ proc default_gdb_start { } {
|
||||
}
|
||||
}
|
||||
|
||||
@ -1896,7 +1906,7 @@ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
|
||||
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
|
||||
--- a/gdb/testsuite/lib/mi-support.exp
|
||||
+++ b/gdb/testsuite/lib/mi-support.exp
|
||||
@@ -330,6 +330,16 @@ proc default_mi_gdb_start { { flags {} } } {
|
||||
@@ -321,6 +321,16 @@ proc default_mi_gdb_start { { flags {} } } {
|
||||
warning "Couldn't set the width to 0."
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ Subject: gdb-6.6-testsuite-timeouts.patch
|
||||
diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp
|
||||
--- a/gdb/testsuite/gdb.base/annota1.exp
|
||||
+++ b/gdb/testsuite/gdb.base/annota1.exp
|
||||
@@ -39,6 +39,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
|
||||
@@ -37,6 +37,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
|
||||
|
||||
clean_restart ${binfile}
|
||||
|
||||
@ -21,7 +21,7 @@ diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1
|
||||
diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp
|
||||
--- a/gdb/testsuite/gdb.base/annota3.exp
|
||||
+++ b/gdb/testsuite/gdb.base/annota3.exp
|
||||
@@ -38,6 +38,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
|
||||
@@ -36,6 +36,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
|
||||
|
||||
clean_restart ${binfile}
|
||||
|
||||
|
@ -1,104 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.7-testsuite-stable-results.patch
|
||||
|
||||
;; Testsuite fixes for more stable/comparable results.
|
||||
;;=fedoratest
|
||||
|
||||
gdb/testsuite/gdb.base/fileio.c:
|
||||
gdb/testsuite/gdb.base/fileio.exp:
|
||||
2007-12-08 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.base/fileio.c (ROOTSUBDIR): New macro.
|
||||
(main): CHDIR into ROOTSUBDIR. CHOWN ROOTSUBDIR and CHDIR into
|
||||
ROOTSUBDIR if we are being run as root.
|
||||
* gdb.base/fileio.exp: Change the startup and finish cleanup.
|
||||
Change the test file reference to be into the `fileio.dir' directory.
|
||||
|
||||
sources/gdb/testsuite/gdb.base/dump.exp:
|
||||
Found on RHEL-5.s390x.
|
||||
|
||||
gdb-6.8.50.20090209/gdb/testsuite/gdb.base/auxv.exp:
|
||||
random FAIL: gdb.base/auxv.exp: matching auxv data from live and gcore
|
||||
|
||||
gdb-6.8.50.20090209/gdb/testsuite/gdb.base/annota1.exp:
|
||||
frames-invalid can happen asynchronously.
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c
|
||||
--- a/gdb/testsuite/gdb.base/fileio.c
|
||||
+++ b/gdb/testsuite/gdb.base/fileio.c
|
||||
@@ -559,6 +559,28 @@ strerrno (int err)
|
||||
int
|
||||
main ()
|
||||
{
|
||||
+ /* These tests
|
||||
+ Open for write but no write permission returns EACCES
|
||||
+ Unlinking a file in a directory w/o write access returns EACCES
|
||||
+ fail if we are being run as root - drop the privileges here. */
|
||||
+
|
||||
+ if (geteuid () == 0)
|
||||
+ {
|
||||
+ uid_t uid = 99;
|
||||
+
|
||||
+ if (chown (OUTDIR, uid, uid) != 0)
|
||||
+ {
|
||||
+ printf ("chown %d.%d %s: %s\n", (int) uid, (int) uid,
|
||||
+ OUTDIR, strerror (errno));
|
||||
+ exit (1);
|
||||
+ }
|
||||
+ if (setuid (uid) || geteuid () == 0)
|
||||
+ {
|
||||
+ printf ("setuid %d: %s\n", (int) uid, strerror (errno));
|
||||
+ exit (1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Don't change the order of the calls. They partly depend on each other */
|
||||
test_open ();
|
||||
test_write ();
|
||||
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
|
||||
--- a/gdb/testsuite/gdb.base/fileio.exp
|
||||
+++ b/gdb/testsuite/gdb.base/fileio.exp
|
||||
@@ -24,9 +24,9 @@ if [target_info exists gdb,nofileio] {
|
||||
standard_testfile
|
||||
|
||||
if {[is_remote host]} {
|
||||
- set outdir .
|
||||
+ set outdir "fileio.dir"
|
||||
} else {
|
||||
- set outdir [standard_output_file {}]
|
||||
+ set outdir [standard_output_file "fileio.dir"]
|
||||
}
|
||||
|
||||
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
|
||||
@@ -40,7 +40,8 @@ set dir2 [standard_output_file dir2.fileio.test]
|
||||
if {[file exists $dir2] && ![file writable $dir2]} {
|
||||
system "chmod +w $dir2"
|
||||
}
|
||||
-system "rm -rf [standard_output_file *.fileio.test]"
|
||||
+system "rm -rf [standard_output_file fileio.dir]"
|
||||
+system "mkdir -m777 [standard_output_file fileio.dir]"
|
||||
|
||||
set oldtimeout $timeout
|
||||
set timeout [expr "$timeout + 60"]
|
||||
@@ -81,7 +82,7 @@ gdb_test continue \
|
||||
|
||||
gdb_test "continue" ".*" ""
|
||||
|
||||
-catch "system \"chmod -f -w [standard_output_file nowrt.fileio.test]\""
|
||||
+catch "system \"chmod -f -w [standard_output_file fileio.dir/nowrt.fileio.test]\""
|
||||
|
||||
gdb_test continue \
|
||||
"Continuing\\..*open 5:.*EACCES$stop_msg" \
|
||||
@@ -268,9 +269,7 @@ gdb_test continue \
|
||||
gdb_exit
|
||||
|
||||
# Make dir2 writable again so rm -rf of a build tree Just Works.
|
||||
-if {[file exists $dir2] && ![file writable $dir2]} {
|
||||
- system "chmod +w $dir2"
|
||||
-}
|
||||
+system "chmod -R +w $outdir"
|
||||
|
||||
set timeout $oldtimeout
|
||||
return 0
|
@ -1,181 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.8-bz442765-threaded-exec-test.patch
|
||||
|
||||
;; Test various forms of threads tracking across exec() (BZ 442765).
|
||||
;;=fedoratest
|
||||
|
||||
Test various forms of threads tracking across exec(2).
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.c b/gdb/testsuite/gdb.threads/threaded-exec.c
|
||||
--- a/gdb/testsuite/gdb.threads/threaded-exec.c
|
||||
+++ b/gdb/testsuite/gdb.threads/threaded-exec.c
|
||||
@@ -18,21 +18,95 @@
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <stddef.h>
|
||||
-#include <pthread.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
+#include <stdio.h>
|
||||
|
||||
+#ifdef THREADS
|
||||
+
|
||||
+# include <pthread.h>
|
||||
|
||||
static void *
|
||||
threader (void *arg)
|
||||
{
|
||||
- return NULL;
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
+#endif
|
||||
+
|
||||
int
|
||||
-main (void)
|
||||
+main (int argc, char **argv)
|
||||
{
|
||||
+ char *exec_nothreads, *exec_threads, *cmd;
|
||||
+ int phase;
|
||||
+ char phase_s[8];
|
||||
+
|
||||
+ setbuf (stdout, NULL);
|
||||
+
|
||||
+ if (argc != 4)
|
||||
+ {
|
||||
+ fprintf (stderr, "%s <non-threaded> <threaded> <phase>\n", argv[0]);
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+#ifdef THREADS
|
||||
+ puts ("THREADS: Y");
|
||||
+#else
|
||||
+ puts ("THREADS: N");
|
||||
+#endif
|
||||
+ exec_nothreads = argv[1];
|
||||
+ printf ("exec_nothreads: %s\n", exec_nothreads);
|
||||
+ exec_threads = argv[2];
|
||||
+ printf ("exec_threads: %s\n", exec_threads);
|
||||
+ phase = atoi (argv[3]);
|
||||
+ printf ("phase: %d\n", phase);
|
||||
+
|
||||
+ /* Phases: threading
|
||||
+ 0: N -> N
|
||||
+ 1: N -> Y
|
||||
+ 2: Y -> Y
|
||||
+ 3: Y -> N
|
||||
+ 4: N -> exit */
|
||||
+
|
||||
+ cmd = NULL;
|
||||
+
|
||||
+#ifndef THREADS
|
||||
+ switch (phase)
|
||||
+ {
|
||||
+ case 0:
|
||||
+ cmd = exec_nothreads;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ cmd = exec_threads;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
|
||||
+ phase);
|
||||
+ return 1;
|
||||
+ case 3:
|
||||
+ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
|
||||
+ phase);
|
||||
+ return 1;
|
||||
+ case 4:
|
||||
+ return 0;
|
||||
+ default:
|
||||
+ assert (0);
|
||||
+ }
|
||||
+#else /* THREADS */
|
||||
+ switch (phase)
|
||||
+ {
|
||||
+ case 0:
|
||||
+ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
|
||||
+ argv[0], phase);
|
||||
+ return 1;
|
||||
+ case 1:
|
||||
+ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
|
||||
+ argv[0], phase);
|
||||
+ return 1;
|
||||
+ case 2:
|
||||
+ cmd = exec_threads;
|
||||
+ {
|
||||
pthread_t t1;
|
||||
int i;
|
||||
|
||||
@@ -40,7 +114,34 @@ main (void)
|
||||
assert (i == 0);
|
||||
i = pthread_join (t1, NULL);
|
||||
assert (i == 0);
|
||||
+ }
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ cmd = exec_nothreads;
|
||||
+ {
|
||||
+ pthread_t t1;
|
||||
+ int i;
|
||||
+
|
||||
+ i = pthread_create (&t1, NULL, threader, (void *) NULL);
|
||||
+ assert (i == 0);
|
||||
+ i = pthread_join (t1, NULL);
|
||||
+ assert (i == 0);
|
||||
+ }
|
||||
+ break;
|
||||
+ case 4:
|
||||
+ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
|
||||
+ argv[0], phase);
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ assert (0);
|
||||
+ }
|
||||
+#endif /* THREADS */
|
||||
+
|
||||
+ assert (cmd != NULL);
|
||||
+
|
||||
+ phase++;
|
||||
+ snprintf (phase_s, sizeof phase_s, "%d", phase);
|
||||
|
||||
- execl ("/bin/true", "/bin/true", NULL);
|
||||
- abort ();
|
||||
+ execl (cmd, cmd, exec_nothreads, exec_threads, phase_s, NULL);
|
||||
+ assert (0);
|
||||
}
|
||||
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.threads/threaded-exec.exp
|
||||
--- a/gdb/testsuite/gdb.threads/threaded-exec.exp
|
||||
+++ b/gdb/testsuite/gdb.threads/threaded-exec.exp
|
||||
@@ -20,9 +20,14 @@
|
||||
|
||||
set testfile threaded-exec
|
||||
set srcfile ${testfile}.c
|
||||
-set binfile [standard_output_file ${testfile}]
|
||||
+set binfile_nothreads [standard_output_file ${testfile}N]
|
||||
+set binfile_threads [standard_output_file ${testfile}Y]
|
||||
|
||||
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
|
||||
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_nothreads}" executable {additional_flags=-UTHREADS}] != "" } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile_threads}" executable {additional_flags=-DTHREADS}] != "" } {
|
||||
return -1
|
||||
}
|
||||
|
||||
@@ -30,9 +35,9 @@ gdb_exit
|
||||
gdb_start
|
||||
gdb_reinitialize_dir $srcdir/$subdir
|
||||
|
||||
-gdb_load ${binfile}
|
||||
+gdb_load ${binfile_nothreads}
|
||||
|
||||
-gdb_run_cmd
|
||||
+gdb_run_cmd [list ${binfile_nothreads} ${binfile_threads} 0]
|
||||
|
||||
gdb_test_multiple {} "Program exited" {
|
||||
-re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
|
47
gdb-arm-fix-epilogue-frame-id.patch
Normal file
47
gdb-arm-fix-epilogue-frame-id.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From 40b2857e42b477832ca7fc2771b6cde910e22f05 Mon Sep 17 00:00:00 2001
|
||||
From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
|
||||
Date: Tue, 23 Jan 2024 14:11:33 -0300
|
||||
Subject: [PATCH 4/7] gdb/arm: Fix epilogue frame id
|
||||
|
||||
arm_epilogue_frame_this_id has a comment saying that it fall backs to using
|
||||
the current PC if the function start address can't be identified, but it
|
||||
actually uses only the PC to make the frame id.
|
||||
|
||||
This patch makes the code match the comment. Another hint that it's what
|
||||
is intended is that arm_prologue_this_id, a function almost identical to
|
||||
it, does that.
|
||||
|
||||
The problem was found by code inspection. It fixes the following testsuite
|
||||
failures:
|
||||
|
||||
FAIL: gdb.base/unwind-on-each-insn.exp: foo: instruction 9: check frame-id matches
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-next third shr1
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-next second shr1
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-next first shr1
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-next generic
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function one
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function one
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function two
|
||||
FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function two
|
||||
|
||||
Tested on arm-linux-gnueabi-hf.
|
||||
---
|
||||
gdb/arm-tdep.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
|
||||
index 3b1682a2aea..21dad198dc7 100644
|
||||
--- a/gdb/arm-tdep.c
|
||||
+++ b/gdb/arm-tdep.c
|
||||
@@ -3252,7 +3252,7 @@ arm_epilogue_frame_this_id (frame_info_ptr this_frame,
|
||||
|
||||
arm_gdbarch_tdep *tdep
|
||||
= gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
|
||||
- *this_id = frame_id_build (arm_cache_get_prev_sp_value (cache, tdep), pc);
|
||||
+ *this_id = frame_id_build (arm_cache_get_prev_sp_value (cache, tdep), func);
|
||||
}
|
||||
|
||||
/* Implementation of function hook 'prev_register' in
|
||||
--
|
||||
2.35.3
|
||||
|
77
gdb-arm-remove-thumb-bit-in-arm_adjust_breakpoint_ad.patch
Normal file
77
gdb-arm-remove-thumb-bit-in-arm_adjust_breakpoint_ad.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From 51a5415b3313470cb62fda7ad6762fc1c41c8cbd Mon Sep 17 00:00:00 2001
|
||||
From: Simon Marchi <simon.marchi@efficios.com>
|
||||
Date: Tue, 7 Nov 2023 11:11:18 -0500
|
||||
Subject: [PATCH] gdb/arm: remove thumb bit in arm_adjust_breakpoint_address
|
||||
|
||||
When compiling gdb with -fsanitize=address on ARM, I get a crash in test
|
||||
gdb.arch/arm-disp-step.exp, reproduced easily with:
|
||||
|
||||
$ ./gdb -nx -q --data-directory=data-directory testsuite/outputs/gdb.arch/arm-disp-step/arm-disp-step -ex "break *test_call_end"
|
||||
Reading symbols from testsuite/outputs/gdb.arch/arm-disp-step/arm-disp-step...
|
||||
=================================================================
|
||||
==23295==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xb4a14fd1 at pc 0x01a48871 bp 0xbeab8490 sp 0xbeab8494
|
||||
|
||||
Since it doesn't require running the program, it can be reproduced locally on a
|
||||
dev machine other than ARM, after acquiring the test binary.
|
||||
|
||||
The length of the allocate buffer `buf` is 1, and we try to extract an
|
||||
integer of size 2 from it. The length of 1 comes from the subtraction
|
||||
`bpaddr - boundary`. Normally, on ARM, all instructions are aligned on
|
||||
a multiple of 2, so it's weird for this subtraction to result in 1. In
|
||||
this case, boundary comes from the result of find_pc_partial_function
|
||||
returning 0x549:
|
||||
|
||||
(gdb) p/x bpaddr
|
||||
$2 = 0x54a
|
||||
(gdb) p/x boundary
|
||||
$3 = 0x549
|
||||
(gdb) p/x bpaddr - boundary
|
||||
$4 = 0x1
|
||||
|
||||
0x549 is the address of the test_call_subr label, 0x548, with the thumb
|
||||
bit enabled. Before doing some math with the address, I think we need
|
||||
to strip the thumb bit, like is done elsewhere (for instance for bpaddr
|
||||
earlier in the same function).
|
||||
|
||||
I wonder if find_pc_partial_function should do that itself, in order to
|
||||
return an address that is suitable for arithmetic. In any case, that
|
||||
would be a change with a broad impact, so for now just fix the issue
|
||||
locally.
|
||||
|
||||
After the patch:
|
||||
|
||||
$ ./gdb -nx -q --data-directory=data-directory testsuite/outputs/gdb.arch/arm-disp-step/arm-disp-step -ex "break *test_call_end"
|
||||
Reading symbols from testsuite/outputs/gdb.arch/arm-disp-step/arm-disp-step...
|
||||
Breakpoint 1 at 0x54a: file /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.arch/arm-disp-step.S, line 103.
|
||||
|
||||
Change-Id: I74fc458dbea0d2c1e1f5eadd90755188df089288
|
||||
Approved-By: Luis Machado <luis.machado@arm.com>
|
||||
---
|
||||
gdb/arm-tdep.c | 9 ++++++---
|
||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
|
||||
index 21dad198dc7..e61342f3ccb 100644
|
||||
--- a/gdb/arm-tdep.c
|
||||
+++ b/gdb/arm-tdep.c
|
||||
@@ -5340,9 +5340,12 @@ arm_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
|
||||
|
||||
bpaddr = gdbarch_addr_bits_remove (gdbarch, bpaddr);
|
||||
|
||||
- if (find_pc_partial_function (bpaddr, NULL, &func_start, NULL)
|
||||
- && func_start > boundary)
|
||||
- boundary = func_start;
|
||||
+ if (find_pc_partial_function (bpaddr, NULL, &func_start, NULL))
|
||||
+ {
|
||||
+ func_start = gdbarch_addr_bits_remove (gdbarch, func_start);
|
||||
+ if (func_start > boundary)
|
||||
+ boundary = func_start;
|
||||
+ }
|
||||
|
||||
/* Search for a candidate IT instruction. We have to do some fancy
|
||||
footwork to distinguish a real IT instruction from the second
|
||||
|
||||
base-commit: eafca1ce3d589c731927e5481199db715bcbeff3
|
||||
--
|
||||
2.35.3
|
||||
|
219
gdb-arm-remove-tpidruro-register-from-non-freebsd-ta.patch
Normal file
219
gdb-arm-remove-tpidruro-register-from-non-freebsd-ta.patch
Normal file
@ -0,0 +1,219 @@
|
||||
From 7973eaf11e33ddd405830b9bd29495991db5901d Mon Sep 17 00:00:00 2001
|
||||
From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
|
||||
Date: Mon, 26 Feb 2024 19:11:45 -0300
|
||||
Subject: [PATCH 2/7] gdb/arm: Remove tpidruro register from non-FreeBSD target
|
||||
descriptions
|
||||
|
||||
Commit 92d48a1e4eac ("Add an arm-tls feature which includes the tpidruro
|
||||
register from CP15.") introduced the org.gnu.gdb.arm.tls feature, which
|
||||
adds the tpidruro register, and unconditionally enabled it in
|
||||
aarch32_create_target_description.
|
||||
|
||||
In Linux, the tpidruro register isn't available via ptrace in the 32-bit
|
||||
kernel but it is available for an aarch32 program running under an arm64
|
||||
kernel via the ptrace compat interface. This isn't currently implemented
|
||||
however, which causes GDB on arm-linux with 64-bit kernel to list the
|
||||
register but show it as unavailable, as reported by Tom de Vries:
|
||||
|
||||
$ gdb -q -batch a.out -ex start -ex 'p $tpidruro'
|
||||
Temporary breakpoint 1 at 0x512
|
||||
|
||||
Temporary breakpoint 1, 0xaaaaa512 in main ()
|
||||
$1 = <unavailable>
|
||||
|
||||
Simon Marchi then clarified:
|
||||
|
||||
> The only time we should be seeing some "unavailable" registers or memory
|
||||
> is in the context of tracepoints, for things that are not collected.
|
||||
> Seeing an unavailable register here is a sign that something is not
|
||||
> right.
|
||||
|
||||
Therefore, disable the TLS feature in aarch32 target descriptions for Linux
|
||||
and NetBSD targets (the latter also doesn't seem to support accessing
|
||||
tpidruro either, based on a quick look at arm-netbsd-nat.c).
|
||||
|
||||
This patch fixes the following tests:
|
||||
|
||||
Running gdb.base/inline-frame-cycle-unwind.exp ...
|
||||
FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 3: backtrace when the unwind is broken at frame 3
|
||||
FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: backtrace when the unwind is broken at frame 5
|
||||
FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 1: backtrace when the unwind is broken at frame 1
|
||||
|
||||
Tested with Ubuntu 22.04.3 on armv8l-linux-gnueabihf in native,
|
||||
native-gdbserver and native-extended-gdbserver targets with no regressions.
|
||||
|
||||
PR tdep/31418
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31418
|
||||
|
||||
Approved-By: John Baldwin <jhb@FreeBSD.org>
|
||||
---
|
||||
gdb/aarch32-tdep.c | 15 ++++++++++-----
|
||||
gdb/aarch32-tdep.h | 2 +-
|
||||
gdb/aarch64-linux-nat.c | 2 +-
|
||||
gdb/arch/aarch32.c | 5 +++--
|
||||
gdb/arch/aarch32.h | 2 +-
|
||||
gdb/arm-fbsd-tdep.c | 2 +-
|
||||
gdb/arm-linux-nat.c | 2 +-
|
||||
gdb/arm-linux-tdep.c | 2 +-
|
||||
gdb/arm-netbsd-nat.c | 2 +-
|
||||
gdbserver/linux-aarch32-tdesc.cc | 2 +-
|
||||
10 files changed, 21 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c
|
||||
index bfa88a96522..395328936e4 100644
|
||||
--- a/gdb/aarch32-tdep.c
|
||||
+++ b/gdb/aarch32-tdep.c
|
||||
@@ -22,15 +22,20 @@
|
||||
#include "gdbsupport/common-regcache.h"
|
||||
#include "arch/aarch32.h"
|
||||
|
||||
-static struct target_desc *tdesc_aarch32;
|
||||
+static struct target_desc *tdesc_aarch32_list[2];
|
||||
|
||||
/* See aarch32-tdep.h. */
|
||||
|
||||
const target_desc *
|
||||
-aarch32_read_description ()
|
||||
+aarch32_read_description (bool tls)
|
||||
{
|
||||
- if (tdesc_aarch32 == nullptr)
|
||||
- tdesc_aarch32 = aarch32_create_target_description ();
|
||||
+ struct target_desc *tdesc = tdesc_aarch32_list[tls];
|
||||
|
||||
- return tdesc_aarch32;
|
||||
+ if (tdesc == nullptr)
|
||||
+ {
|
||||
+ tdesc = aarch32_create_target_description (tls);
|
||||
+ tdesc_aarch32_list[tls] = tdesc;
|
||||
+ }
|
||||
+
|
||||
+ return tdesc;
|
||||
}
|
||||
diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h
|
||||
index bee4d4e9fc0..efc93351298 100644
|
||||
--- a/gdb/aarch32-tdep.h
|
||||
+++ b/gdb/aarch32-tdep.h
|
||||
@@ -22,6 +22,6 @@ struct target_desc;
|
||||
|
||||
/* Get the AArch32 target description. */
|
||||
|
||||
-const target_desc *aarch32_read_description ();
|
||||
+const target_desc *aarch32_read_description (bool tls);
|
||||
|
||||
#endif /* aarch32-tdep.h. */
|
||||
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
|
||||
index 768748a20db..c680d6de0c9 100644
|
||||
--- a/gdb/aarch64-linux-nat.c
|
||||
+++ b/gdb/aarch64-linux-nat.c
|
||||
@@ -887,7 +887,7 @@ aarch64_linux_nat_target::read_description ()
|
||||
|
||||
ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_VFP, &iovec);
|
||||
if (ret == 0)
|
||||
- return aarch32_read_description ();
|
||||
+ return aarch32_read_description (false);
|
||||
|
||||
CORE_ADDR hwcap = linux_get_hwcap ();
|
||||
CORE_ADDR hwcap2 = linux_get_hwcap2 ();
|
||||
diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
|
||||
index 5be2cc0156e..b7510ee41e9 100644
|
||||
--- a/gdb/arch/aarch32.c
|
||||
+++ b/gdb/arch/aarch32.c
|
||||
@@ -25,7 +25,7 @@
|
||||
/* See aarch32.h. */
|
||||
|
||||
target_desc *
|
||||
-aarch32_create_target_description ()
|
||||
+aarch32_create_target_description (bool tls)
|
||||
{
|
||||
target_desc_up tdesc = allocate_target_description ();
|
||||
|
||||
@@ -39,7 +39,8 @@ aarch32_create_target_description ()
|
||||
/* Create a vfpv3 feature, then a blank NEON feature. */
|
||||
regnum = create_feature_arm_arm_vfpv3 (tdesc.get (), regnum);
|
||||
tdesc_create_feature (tdesc.get (), "org.gnu.gdb.arm.neon");
|
||||
- regnum = create_feature_arm_arm_tls (tdesc.get (), regnum);
|
||||
+ if (tls)
|
||||
+ regnum = create_feature_arm_arm_tls (tdesc.get (), regnum);
|
||||
|
||||
return tdesc.release ();
|
||||
}
|
||||
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
|
||||
index 6b24ae94335..e06e260e370 100644
|
||||
--- a/gdb/arch/aarch32.h
|
||||
+++ b/gdb/arch/aarch32.h
|
||||
@@ -22,6 +22,6 @@
|
||||
|
||||
/* Create the AArch32 target description. */
|
||||
|
||||
-target_desc *aarch32_create_target_description ();
|
||||
+target_desc *aarch32_create_target_description (bool tls);
|
||||
|
||||
#endif /* aarch32.h. */
|
||||
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
|
||||
index b46fa91d0a0..a4cea77f388 100644
|
||||
--- a/gdb/arm-fbsd-tdep.c
|
||||
+++ b/gdb/arm-fbsd-tdep.c
|
||||
@@ -228,7 +228,7 @@ arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
|
||||
if (arm_hwcap & HWCAP_VFP)
|
||||
{
|
||||
if (arm_hwcap & HWCAP_NEON)
|
||||
- return aarch32_read_description ();
|
||||
+ return aarch32_read_description (tls);
|
||||
else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32))
|
||||
== (HWCAP_VFPv3 | HWCAP_VFPD32))
|
||||
return arm_read_description (ARM_FP_TYPE_VFPV3, tls);
|
||||
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
|
||||
index 70c6bc684fa..07af23d3881 100644
|
||||
--- a/gdb/arm-linux-nat.c
|
||||
+++ b/gdb/arm-linux-nat.c
|
||||
@@ -568,7 +568,7 @@ arm_linux_nat_target::read_description ()
|
||||
/* NEON implies VFPv3-D32 or no-VFP unit. Say that we only support
|
||||
Neon with VFPv3-D32. */
|
||||
if (arm_hwcap & HWCAP_NEON)
|
||||
- return aarch32_read_description ();
|
||||
+ return aarch32_read_description (false);
|
||||
else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
|
||||
return arm_read_description (ARM_FP_TYPE_VFPV3, false);
|
||||
|
||||
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
|
||||
index dfa816990ff..33748731cfd 100644
|
||||
--- a/gdb/arm-linux-tdep.c
|
||||
+++ b/gdb/arm-linux-tdep.c
|
||||
@@ -740,7 +740,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
|
||||
/* NEON implies VFPv3-D32 or no-VFP unit. Say that we only support
|
||||
Neon with VFPv3-D32. */
|
||||
if (arm_hwcap & HWCAP_NEON)
|
||||
- return aarch32_read_description ();
|
||||
+ return aarch32_read_description (false);
|
||||
else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
|
||||
return arm_read_description (ARM_FP_TYPE_VFPV3, false);
|
||||
|
||||
diff --git a/gdb/arm-netbsd-nat.c b/gdb/arm-netbsd-nat.c
|
||||
index d83714a46c3..018964b010d 100644
|
||||
--- a/gdb/arm-netbsd-nat.c
|
||||
+++ b/gdb/arm-netbsd-nat.c
|
||||
@@ -350,7 +350,7 @@ arm_netbsd_nat_target::read_description ()
|
||||
|
||||
len = sizeof(flag);
|
||||
if (sysctlbyname("machdep.neon_present", &flag, &len, NULL, 0) == 0 && flag)
|
||||
- return aarch32_read_description ();
|
||||
+ return aarch32_read_description (false);
|
||||
|
||||
return arm_read_description (ARM_FP_TYPE_VFPV3, false);
|
||||
}
|
||||
diff --git a/gdbserver/linux-aarch32-tdesc.cc b/gdbserver/linux-aarch32-tdesc.cc
|
||||
index e1380fa2a40..443f91e3585 100644
|
||||
--- a/gdbserver/linux-aarch32-tdesc.cc
|
||||
+++ b/gdbserver/linux-aarch32-tdesc.cc
|
||||
@@ -32,7 +32,7 @@ aarch32_linux_read_description ()
|
||||
{
|
||||
if (tdesc_aarch32 == nullptr)
|
||||
{
|
||||
- tdesc_aarch32 = aarch32_create_target_description ();
|
||||
+ tdesc_aarch32 = aarch32_create_target_description (false);
|
||||
|
||||
static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
|
||||
init_target_desc (tdesc_aarch32, expedite_regs);
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,24 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Nick Clifton <nickc@redhat.com>
|
||||
Date: Wed, 11 Jan 2023 12:13:46 +0000
|
||||
Subject: gdb-binutils29988-read_indexed_address.patch
|
||||
|
||||
;; Backport "Fix a potential illegal memory access in the BFD library..."
|
||||
;; (Nick Clifton, binutils/29988)
|
||||
|
||||
PR 29988
|
||||
* dwarf2.c (read_indexed_address): Fix check for an out of range
|
||||
offset.
|
||||
|
||||
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
|
||||
--- a/bfd/dwarf2.c
|
||||
+++ b/bfd/dwarf2.c
|
||||
@@ -1412,7 +1412,7 @@ read_indexed_address (uint64_t idx, struct comp_unit *unit)
|
||||
offset += unit->dwarf_addr_offset;
|
||||
if (offset < unit->dwarf_addr_offset
|
||||
|| offset > file->dwarf_addr_size
|
||||
- || file->dwarf_addr_size - offset < unit->offset_size)
|
||||
+ || file->dwarf_addr_size - offset < unit->addr_size)
|
||||
return 0;
|
||||
|
||||
info_ptr = file->dwarf_addr_buffer + offset;
|
41
gdb-build-fix-gdbserver-linux-aarch64-low.cc-build.patch
Normal file
41
gdb-build-fix-gdbserver-linux-aarch64-low.cc-build.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 0397481ff25b76d43b123f3d51828982ceb92834 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Wielaard <mark@klomp.org>
|
||||
Date: Fri, 3 May 2024 15:17:42 +0200
|
||||
Subject: [PATCH] [gdb/build] Fix gdbserver/linux-aarch64-low.cc build
|
||||
|
||||
Commit 0ee25f97d21e ("Fix regression on aarch64-linux gdbserver")
|
||||
removed the last use of i in gdbserver/linux-aarch64-low.cc
|
||||
(aarch64_target::low_stopped_data_address). Breaking the build on
|
||||
aarch64 with:
|
||||
|
||||
gdbserver/linux-aarch64-low.cc: In member function ?virtual CORE_ADDR aarch64_target::low_stopped_data_address()?:
|
||||
gdbserver/linux-aarch64-low.cc:557:12: error: unused variable ?i? [-Werror=unused-variable]
|
||||
557 | int pid, i;
|
||||
| ^
|
||||
cc1plus: all warnings being treated as errors
|
||||
|
||||
Fix this by removing the variable i completely.
|
||||
|
||||
Fixes: 0ee25f97d21e ("Fix regression on aarch64-linux gdbserver")
|
||||
---
|
||||
gdbserver/linux-aarch64-low.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
|
||||
index 14346b89822..ce0029b885f 100644
|
||||
--- a/gdbserver/linux-aarch64-low.cc
|
||||
+++ b/gdbserver/linux-aarch64-low.cc
|
||||
@@ -555,7 +555,7 @@ CORE_ADDR
|
||||
aarch64_target::low_stopped_data_address ()
|
||||
{
|
||||
siginfo_t siginfo;
|
||||
- int pid, i;
|
||||
+ int pid;
|
||||
struct aarch64_debug_reg_state *state;
|
||||
|
||||
pid = lwpid_of (current_thread);
|
||||
|
||||
base-commit: b33811a85ff53af77cdad995ad8cb50431c8c362
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,68 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Burgess <aburgess@redhat.com>
|
||||
Date: Thu, 14 Sep 2023 13:06:26 +0100
|
||||
Subject: gdb-bz2237392-dwarf-obstack-allocation.patch
|
||||
|
||||
;; Backport upstream commit 54392c4df604f20 to fix an incorrect
|
||||
;; obstack allocation that wold lead to memory corruption.
|
||||
|
||||
gdb: fix buffer overflow in DWARF reader
|
||||
|
||||
In this commit:
|
||||
|
||||
commit 48ac197b0c209ccf1f2de9704eb6cdf7c5c73a8e
|
||||
Date: Fri Nov 19 10:12:44 2021 -0700
|
||||
|
||||
Handle multiple addresses in call_site_target
|
||||
|
||||
a buffer overflow bug was introduced when the following code was
|
||||
added:
|
||||
|
||||
CORE_ADDR *saved = XOBNEWVAR (&objfile->objfile_obstack, CORE_ADDR,
|
||||
addresses.size ());
|
||||
std::copy (addresses.begin (), addresses.end (), saved);
|
||||
|
||||
The definition of XOBNEWVAR is (from libiberty.h):
|
||||
|
||||
#define XOBNEWVAR(O, T, S) ((T *) obstack_alloc ((O), (S)))
|
||||
|
||||
So 'saved' is going to point to addresses.size () bytes of memory,
|
||||
however, the std::copy will write addresses.size () number of
|
||||
CORE_ADDR sized entries to the address pointed to by 'saved', this is
|
||||
going to result in memory corruption.
|
||||
|
||||
The mistake is that we should have used XOBNEWVEC, which allocates a
|
||||
vector of entries, the definition of XOBNEWVEC is:
|
||||
|
||||
#define XOBNEWVEC(O, T, N) \
|
||||
((T *) obstack_alloc ((O), sizeof (T) * (N)))
|
||||
|
||||
Which means we will have set aside enough space to create a copy of
|
||||
the contents of the addresses vector.
|
||||
|
||||
I'm not sure how to create a test for this problem, this issue cropped
|
||||
up when debugging a particular i686 built binary, which just happened
|
||||
to trigger a glibc assertion (likely due to random memory corruption),
|
||||
debugging the same binary built for x86-64 appeared to work just fine.
|
||||
|
||||
Using valgrind on the failing GDB binary pointed straight to the cause
|
||||
of the problem, and with this patch in place there are no longer
|
||||
valgrind errors in this area.
|
||||
|
||||
If anyone has ideas for a test I'm happy to work on something.
|
||||
|
||||
Co-Authored-By: Keith Seitz <keiths@redhat.com>
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -12506,7 +12506,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
std::vector<CORE_ADDR> addresses;
|
||||
dwarf2_ranges_read_low_addrs (ranges_offset, target_cu,
|
||||
target_die->tag, addresses);
|
||||
- CORE_ADDR *saved = XOBNEWVAR (&objfile->objfile_obstack, CORE_ADDR,
|
||||
+ CORE_ADDR *saved = XOBNEWVEC (&objfile->objfile_obstack, CORE_ADDR,
|
||||
addresses.size ());
|
||||
std::copy (addresses.begin (), addresses.end (), saved);
|
||||
call_site->target.set_loc_array (addresses.size (), saved);
|
@ -1,102 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Tom Tromey <tromey@adacore.com>
|
||||
Date: Tue, 6 Dec 2022 12:07:12 -0700
|
||||
Subject: gdb-bz2237515-debuginfod-double-free.patch
|
||||
|
||||
;; Backport upstream commit f96328accde1e63 to fix a potential double
|
||||
;; free issue in the debuginfod code.
|
||||
|
||||
Avoid double-free with debuginfod
|
||||
|
||||
PR gdb/29257 points out a possible double free when debuginfod is in
|
||||
use. Aside from some ugly warts in the symbol code (an ongoing
|
||||
issue), the underlying issue in this particular case is that elfread.c
|
||||
seems to assume that symfile_bfd_open will return NULL on error,
|
||||
whereas in reality it throws an exception. As this code isn't
|
||||
prepared for an exception, bad things result.
|
||||
|
||||
This patch fixes the problem by introducing a non-throwing variant of
|
||||
symfile_bfd_open and using it in the affected places.
|
||||
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29257
|
||||
|
||||
diff --git a/gdb/elfread.c b/gdb/elfread.c
|
||||
--- a/gdb/elfread.c
|
||||
+++ b/gdb/elfread.c
|
||||
@@ -1222,10 +1222,12 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
|
||||
if (!debugfile.empty ())
|
||||
{
|
||||
- gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ()));
|
||||
+ gdb_bfd_ref_ptr debug_bfd
|
||||
+ (symfile_bfd_open_no_error (debugfile.c_str ()));
|
||||
|
||||
- symbol_file_add_separate (debug_bfd, debugfile.c_str (),
|
||||
- symfile_flags, objfile);
|
||||
+ if (debug_bfd != nullptr)
|
||||
+ symbol_file_add_separate (debug_bfd, debugfile.c_str (),
|
||||
+ symfile_flags, objfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1245,13 +1247,12 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||
if (fd.get () >= 0)
|
||||
{
|
||||
/* File successfully retrieved from server. */
|
||||
- gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (symfile_path.get ()));
|
||||
+ gdb_bfd_ref_ptr debug_bfd
|
||||
+ (symfile_bfd_open_no_error (symfile_path.get ()));
|
||||
|
||||
- if (debug_bfd == nullptr)
|
||||
- warning (_("File \"%s\" from debuginfod cannot be opened as bfd"),
|
||||
- filename);
|
||||
- else if (build_id_verify (debug_bfd.get (), build_id->size,
|
||||
- build_id->data))
|
||||
+ if (debug_bfd != nullptr
|
||||
+ && build_id_verify (debug_bfd.get (), build_id->size,
|
||||
+ build_id->data))
|
||||
{
|
||||
symbol_file_add_separate (debug_bfd, symfile_path.get (),
|
||||
symfile_flags, objfile);
|
||||
diff --git a/gdb/symfile.c b/gdb/symfile.c
|
||||
--- a/gdb/symfile.c
|
||||
+++ b/gdb/symfile.c
|
||||
@@ -1744,6 +1744,23 @@ symfile_bfd_open (const char *name)
|
||||
return sym_bfd;
|
||||
}
|
||||
|
||||
+/* See symfile.h. */
|
||||
+
|
||||
+gdb_bfd_ref_ptr
|
||||
+symfile_bfd_open_no_error (const char *name) noexcept
|
||||
+{
|
||||
+ try
|
||||
+ {
|
||||
+ return symfile_bfd_open (name);
|
||||
+ }
|
||||
+ catch (const gdb_exception_error &err)
|
||||
+ {
|
||||
+ warning ("%s", err.what ());
|
||||
+ }
|
||||
+
|
||||
+ return nullptr;
|
||||
+}
|
||||
+
|
||||
/* Return the section index for SECTION_NAME on OBJFILE. Return -1 if
|
||||
the section was not found. */
|
||||
|
||||
diff --git a/gdb/symfile.h b/gdb/symfile.h
|
||||
--- a/gdb/symfile.h
|
||||
+++ b/gdb/symfile.h
|
||||
@@ -269,6 +269,11 @@ extern void set_initial_language (void);
|
||||
|
||||
extern gdb_bfd_ref_ptr symfile_bfd_open (const char *);
|
||||
|
||||
+/* Like symfile_bfd_open, but will not throw an exception on error.
|
||||
+ Instead, it issues a warning and returns nullptr. */
|
||||
+
|
||||
+extern gdb_bfd_ref_ptr symfile_bfd_open_no_error (const char *) noexcept;
|
||||
+
|
||||
extern int get_section_index (struct objfile *, const char *);
|
||||
|
||||
extern int print_symbol_loading_p (int from_tty, int mainline, int full);
|
@ -1,26 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-ccache-workaround.patch
|
||||
|
||||
;; Workaround ccache making lineno non-zero for command-line definitions.
|
||||
;;=fedoratest: ccache is rarely used and it is even fixed now.
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp
|
||||
--- a/gdb/testsuite/gdb.base/macscp.exp
|
||||
+++ b/gdb/testsuite/gdb.base/macscp.exp
|
||||
@@ -20,6 +20,14 @@ set objfile [standard_output_file ${testfile}.o]
|
||||
|
||||
set options {debug macros additional_flags=-DFROM_COMMANDLINE=ARG}
|
||||
|
||||
+# Workaround ccache making lineno non-zero for command-line definitions.
|
||||
+if {[find_gcc] == "gcc" && [file executable "/usr/bin/gcc"]} {
|
||||
+ set result [catch "exec which gcc" output]
|
||||
+ if {$result == 0 && [string first "/ccache/" $output] > -1} {
|
||||
+ lappend options "compiler=/usr/bin/gcc"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
# Generate the intermediate object file. This is required by Darwin to
|
||||
# have access to the .debug_macinfo section.
|
||||
if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \
|
@ -1,3 +1,8 @@
|
||||
From 0bb6f49bb9ad577667075550ca2ad4cb49931078 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 18 Apr 2024 14:27:04 +0200
|
||||
Subject: [PATCH 2/2] gdb-cli-add-ignore-errors-command
|
||||
|
||||
[gdb/cli] Add ignore-errors command
|
||||
|
||||
While trying to reproduce a failing test-case from the testsuite on the
|
||||
@ -60,28 +65,29 @@ gdb/testsuite/ChangeLog:
|
||||
|
||||
* gdb.base/ignore-errors.exp: New test.
|
||||
* gdb.base/ignore-errors.gdb: New command file.
|
||||
|
||||
---
|
||||
gdb/cli/cli-cmds.c | 35 ++++++++++++++++++++++++++++++++
|
||||
gdb/doc/gdb.texinfo | 8 +++++++-
|
||||
gdb/testsuite/gdb.base/ignore-errors.exp | 24 ++++++++++++++++++++++
|
||||
gdb/cli/cli-cmds.c | 35 ++++++++++++++++++++++++
|
||||
gdb/doc/gdb.texinfo | 8 +++++-
|
||||
gdb/testsuite/gdb.base/ignore-errors.exp | 24 ++++++++++++++++
|
||||
gdb/testsuite/gdb.base/ignore-errors.gdb | 2 ++
|
||||
4 files changed, 68 insertions(+), 1 deletion(-)
|
||||
create mode 100644 gdb/testsuite/gdb.base/ignore-errors.exp
|
||||
create mode 100644 gdb/testsuite/gdb.base/ignore-errors.gdb
|
||||
|
||||
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
|
||||
index 31d398cb13b..4eff591b3df 100644
|
||||
index cfe7b71b0b7..0ae5530c558 100644
|
||||
--- a/gdb/cli/cli-cmds.c
|
||||
+++ b/gdb/cli/cli-cmds.c
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "gdbsupport/filestuff.h"
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "location.h"
|
||||
#include "block.h"
|
||||
#include "valprint.h"
|
||||
+#include "event-top.h"
|
||||
|
||||
#include "ui-out.h"
|
||||
#include "interps.h"
|
||||
@@ -2399,6 +2400,34 @@ gdb_maint_setting_str_internal_fn (struct gdbarch *gdbarch,
|
||||
return str_value_from_setting (*show_cmd->var, gdbarch);
|
||||
@@ -2544,6 +2545,34 @@ shell_internal_fn (struct gdbarch *gdbarch,
|
||||
return value::allocate_optimized_out (int_type);
|
||||
}
|
||||
|
||||
+/* Completer for "ignore-errors". */
|
||||
@ -115,7 +121,7 @@ index 31d398cb13b..4eff591b3df 100644
|
||||
void _initialize_cli_cmds ();
|
||||
void
|
||||
_initialize_cli_cmds ()
|
||||
@@ -2786,4 +2815,10 @@ when GDB is started."), GDBINIT).release ();
|
||||
@@ -2942,4 +2971,10 @@ when GDB is started."), GDBINIT).release ();
|
||||
c = add_cmd ("source", class_support, source_command,
|
||||
source_help_text, &cmdlist);
|
||||
set_cmd_completer (c, filename_completer);
|
||||
@ -127,10 +133,10 @@ index 31d398cb13b..4eff591b3df 100644
|
||||
+ set_cmd_completer (c, ignore_errors_command_completer);
|
||||
}
|
||||
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
|
||||
index 1cf3550885e..68e11585942 100644
|
||||
index 1abf91c4470..c277c16297c 100644
|
||||
--- a/gdb/doc/gdb.texinfo
|
||||
+++ b/gdb/doc/gdb.texinfo
|
||||
@@ -27680,7 +27680,8 @@ The lines in a command file are generally executed sequentially,
|
||||
@@ -29250,7 +29250,8 @@ The lines in a command file are generally executed sequentially,
|
||||
unless the order of execution is changed by one of the
|
||||
@emph{flow-control commands} described below. The commands are not
|
||||
printed as they are executed. An error in any command terminates
|
||||
@ -140,7 +146,7 @@ index 1cf3550885e..68e11585942 100644
|
||||
|
||||
@value{GDBN} first searches for @var{filename} in the current directory.
|
||||
If the file is not found there, and @var{filename} does not specify a
|
||||
@@ -27775,6 +27776,11 @@ the controlling expression.
|
||||
@@ -29345,6 +29346,11 @@ the controlling expression.
|
||||
@item end
|
||||
Terminate the block of commands that are the body of @code{if},
|
||||
@code{else}, or @code{while} flow-control commands.
|
||||
@ -190,3 +196,6 @@ index 00000000000..5962ff49b11
|
||||
@@ -0,0 +1,2 @@
|
||||
+ignore-errors run
|
||||
+echo here\n
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
From 3f5ef7bf512c7565279832bad3d5c743e9d8ae4b Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Wed, 24 May 2023 10:53:02 +0200
|
||||
Subject: [PATCH 1/4] [gdb/cli] Handle pending ^C after rl_callback_read_char
|
||||
for readline 7
|
||||
|
||||
In commit faf01aee1d0 ("[gdb] Handle pending ^C after rl_callback_read_char")
|
||||
we handled a problem (described in detail in that commit) for readline >= 8
|
||||
using public readline functions rl_pending_signal and rl_check_signals.
|
||||
|
||||
For readline 7 (note that we require at least readline 7 so there's no need to
|
||||
worry about readline 6), there was no fix though, because rl_check_signals was
|
||||
not available.
|
||||
|
||||
Fix this by instead using the private readline function _rl_signal_handler.
|
||||
|
||||
There is precedent for using private readline variables and functions, but
|
||||
it's something we want to get rid of (PR build/10723). Nevertheless, I think
|
||||
we can allow this specific instance because it's not used when building
|
||||
against readline >= 8.
|
||||
|
||||
[ In the meanwhile, a fix was committed in the devel branch of the readline
|
||||
repo, contained in commit 8d0c439 ("rollup of changes since readline-8.2"),
|
||||
first proposed here (
|
||||
https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00008.html ). ]
|
||||
|
||||
Tested on x86_64-linux, against system readline 7.0 on openSUSE Leap 15.4.
|
||||
|
||||
PR cli/27813
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27813
|
||||
---
|
||||
gdb/event-top.c | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/event-top.c b/gdb/event-top.c
|
||||
index 9181e4bdcff..399582698c1 100644
|
||||
--- a/gdb/event-top.c
|
||||
+++ b/gdb/event-top.c
|
||||
@@ -134,6 +134,9 @@ static struct async_signal_handler *async_sigterm_token;
|
||||
character is processed. */
|
||||
void (*after_char_processing_hook) (void);
|
||||
|
||||
+#if RL_VERSION_MAJOR == 7
|
||||
+EXTERN_C void _rl_signal_handler (int);
|
||||
+#endif
|
||||
|
||||
/* Wrapper function for calling into the readline library. This takes
|
||||
care of a couple things:
|
||||
@@ -200,8 +203,14 @@ gdb_rl_callback_read_char_wrapper_noexcept () noexcept
|
||||
pending signal. I'm not sure if that's possible, but it seems
|
||||
better to handle the scenario than to assert. */
|
||||
rl_check_signals ();
|
||||
+#elif RL_VERSION_MAJOR == 7
|
||||
+ /* Unfortunately, rl_check_signals is not available. Use private
|
||||
+ function _rl_signal_handler instead. */
|
||||
+
|
||||
+ while (rl_pending_signal () != 0)
|
||||
+ _rl_signal_handler (rl_pending_signal ());
|
||||
#else
|
||||
- /* Unfortunately, rl_check_signals is not available. */
|
||||
+#error "Readline major version >= 7 expected"
|
||||
#endif
|
||||
if (after_char_processing_hook)
|
||||
(*after_char_processing_hook) ();
|
||||
|
||||
base-commit: 7f7fcd7031430953f41b284069d1ed0cf3c8734a
|
||||
--
|
||||
2.35.3
|
||||
|
@ -19,7 +19,7 @@ Date: Wed Sep 25 11:52:50 2013 +0000
|
||||
diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp
|
||||
--- a/gdb/testsuite/gdb.base/solib-symbol.exp
|
||||
+++ b/gdb/testsuite/gdb.base/solib-symbol.exp
|
||||
@@ -29,6 +29,7 @@ set testfile "solib-symbol-main"
|
||||
@@ -27,6 +27,7 @@ set testfile "solib-symbol-main"
|
||||
set srcfile ${srcdir}/${subdir}/${testfile}.c
|
||||
set binfile [standard_output_file ${testfile}]
|
||||
set bin_flags [list debug shlib=${binfile_lib}]
|
||||
@ -27,16 +27,14 @@ diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/so
|
||||
|
||||
if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
|
||||
|| [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
|
||||
@@ -66,8 +67,26 @@ gdb_test "br foo2" \
|
||||
@@ -61,4 +62,28 @@ gdb_test "br foo2" \
|
||||
"Breakpoint.*: foo2. .2 locations..*" \
|
||||
"foo2 in mdlib"
|
||||
|
||||
-gdb_exit
|
||||
+# Test GDB warns for shared libraris which have not been found.
|
||||
|
||||
-return 0
|
||||
+
|
||||
+gdb_test "info sharedlibrary" "/${libname}.*"
|
||||
|
||||
+
|
||||
+clean_restart ${executable}
|
||||
+gdb_breakpoint "main"
|
||||
+gdb_run_cmd
|
||||
@ -49,10 +47,12 @@ diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/so
|
||||
+ pass $test
|
||||
+ }
|
||||
+}
|
||||
|
||||
+
|
||||
+clean_restart ${executable}
|
||||
+gdb_test_no_output "set solib-absolute-prefix /doESnotEXIST"
|
||||
+gdb_breakpoint "main"
|
||||
+gdb_run_cmd
|
||||
+gdb_test "" "warning: Could not load shared library symbols for \[0-9\]+ libraries,.*\r\nBreakpoint \[0-9\]+, main .*" \
|
||||
+ "warning for missing libraries"
|
||||
+
|
||||
gdb_exit
|
||||
|
150
gdb-exp-fix-cast-handling-for-indirection.patch
Normal file
150
gdb-exp-fix-cast-handling-for-indirection.patch
Normal file
@ -0,0 +1,150 @@
|
||||
From b96d3adafdb636898913710ec40ee86647665ae8 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 3 May 2024 09:37:19 +0200
|
||||
Subject: [PATCH 24/48] [gdb/exp] Fix cast handling for indirection
|
||||
|
||||
Consider a test-case compiled without debug info, containing:
|
||||
...
|
||||
char a = 'a';
|
||||
|
||||
char *
|
||||
a_loc (void)
|
||||
{
|
||||
return &a;
|
||||
}
|
||||
...
|
||||
|
||||
We get:
|
||||
...
|
||||
(gdb) p (char)*a_loc ()
|
||||
Cannot access memory at address 0x10
|
||||
...
|
||||
|
||||
There's a bug in unop_ind_base_operation::evaluate that evaluates
|
||||
"(char)*a_loc ()" the same as:
|
||||
...
|
||||
(gdb) p (char)*(char)a_loc ()
|
||||
Cannot access memory at address 0x10
|
||||
...
|
||||
|
||||
Fix this by instead doing:
|
||||
...
|
||||
(gdb) p (char)*a_loc ()
|
||||
'a_loc' has unknown return type; cast the call to its declared return type
|
||||
...
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
PR exp/31693
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31693
|
||||
---
|
||||
gdb/expop.h | 5 +--
|
||||
gdb/testsuite/gdb.base/cast-indirection.c | 31 ++++++++++++++++
|
||||
gdb/testsuite/gdb.base/cast-indirection.exp | 41 +++++++++++++++++++++
|
||||
3 files changed, 74 insertions(+), 3 deletions(-)
|
||||
create mode 100644 gdb/testsuite/gdb.base/cast-indirection.c
|
||||
create mode 100644 gdb/testsuite/gdb.base/cast-indirection.exp
|
||||
|
||||
diff --git a/gdb/expop.h b/gdb/expop.h
|
||||
index 25769d5b810..25d50fe00d0 100644
|
||||
--- a/gdb/expop.h
|
||||
+++ b/gdb/expop.h
|
||||
@@ -1513,9 +1513,8 @@ class unop_ind_base_operation
|
||||
struct expression *exp,
|
||||
enum noside noside) override
|
||||
{
|
||||
- if (expect_type != nullptr && expect_type->code () == TYPE_CODE_PTR)
|
||||
- expect_type = check_typedef (expect_type)->target_type ();
|
||||
- value *val = std::get<0> (m_storage)->evaluate (expect_type, exp, noside);
|
||||
+ value *val
|
||||
+ = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
return eval_op_ind (expect_type, exp, noside, val);
|
||||
}
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/cast-indirection.c b/gdb/testsuite/gdb.base/cast-indirection.c
|
||||
new file mode 100644
|
||||
index 00000000000..d59c66ead35
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/cast-indirection.c
|
||||
@@ -0,0 +1,31 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2024 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/>. */
|
||||
+
|
||||
+char a = 'a';
|
||||
+
|
||||
+char *
|
||||
+a_loc (void)
|
||||
+{
|
||||
+ return &a;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+ int res = *a_loc () == 'a';
|
||||
+ return !res;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/cast-indirection.exp b/gdb/testsuite/gdb.base/cast-indirection.exp
|
||||
new file mode 100644
|
||||
index 00000000000..f1fe4302d27
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/cast-indirection.exp
|
||||
@@ -0,0 +1,41 @@
|
||||
+# Copyright (C) 2024 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 "p (char)*a_loc ()" is handled as "p (char)*(char *)a_loc ()".
|
||||
+
|
||||
+standard_testfile
|
||||
+
|
||||
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
|
||||
+ {nodebug}] == -1} {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if ![runto_main] {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test "p a_loc ()" \
|
||||
+ "'a_loc' has unknown return type; cast the call to its declared return type"
|
||||
+
|
||||
+gdb_test "p *a_loc ()" \
|
||||
+ "'a_loc' has unknown return type; cast the call to its declared return type"
|
||||
+
|
||||
+gdb_test "p *(char *)a_loc ()" " = 97 'a'"
|
||||
+
|
||||
+gdb_test "p (char)*(char *)a_loc ()" " = 97 'a'"
|
||||
+
|
||||
+# Regression test for PR31693.
|
||||
+gdb_test "p (char)*a_loc ()" \
|
||||
+ "'a_loc' has unknown return type; cast the call to its declared return type"
|
||||
--
|
||||
2.35.3
|
||||
|
365
gdb-exp-fix-printing-of-out-of-bounds-struct-members.patch
Normal file
365
gdb-exp-fix-printing-of-out-of-bounds-struct-members.patch
Normal file
@ -0,0 +1,365 @@
|
||||
From 86e379aa22ba5e77ba0c6fa26588c5fd1d9e6abe Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Mon, 19 Feb 2024 09:59:15 +0100
|
||||
Subject: [PATCH 13/48] [gdb/exp] Fix printing of out of bounds struct members
|
||||
|
||||
When building gdb with -O0 -fsanitize=address, and running test-case
|
||||
gdb.ada/uninitialized_vars.exp, I run into:
|
||||
...
|
||||
(gdb) info locals
|
||||
a = 0
|
||||
z = (a => 1, b => false, c => 2.0)
|
||||
=================================================================
|
||||
==66372==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000097f58 at pc 0xffff52c0da1c bp 0xffffc90a1d40 sp 0xffffc90a1d80
|
||||
READ of size 4 at 0x602000097f58 thread T0
|
||||
#0 0xffff52c0da18 in memmove (/lib64/libasan.so.8+0x6da18)
|
||||
#1 0xbcab24 in unsigned char* std::__copy_move_backward<false, true, std::random_access_iterator_tag>::__copy_move_b<unsigned char const, unsigned char>(unsigned char const*, unsigned char const*, unsigned char*) /usr/include/c++/13/bits/stl_algobase.h:748
|
||||
#2 0xbc9bf4 in unsigned char* std::__copy_move_backward_a2<false, unsigned char const*, unsigned char*>(unsigned char const*, unsigned char const*, unsigned char*) /usr/include/c++/13/bits/stl_algobase.h:769
|
||||
#3 0xbc898c in unsigned char* std::__copy_move_backward_a1<false, unsigned char const*, unsigned char*>(unsigned char const*, unsigned char const*, unsigned char*) /usr/include/c++/13/bits/stl_algobase.h:778
|
||||
#4 0xbc715c in unsigned char* std::__copy_move_backward_a<false, unsigned char const*, unsigned char*>(unsigned char const*, unsigned char const*, unsigned char*) /usr/include/c++/13/bits/stl_algobase.h:807
|
||||
#5 0xbc4e6c in unsigned char* std::copy_backward<unsigned char const*, unsigned char*>(unsigned char const*, unsigned char const*, unsigned char*) /usr/include/c++/13/bits/stl_algobase.h:867
|
||||
#6 0xbc2934 in void gdb::copy<unsigned char const, unsigned char>(gdb::array_view<unsigned char const>, gdb::array_view<unsigned char>) gdb/../gdbsupport/array-view.h:223
|
||||
#7 0x20e0100 in value::contents_copy_raw(value*, long, long, long) gdb/value.c:1239
|
||||
#8 0x20e9830 in value::primitive_field(long, int, type*) gdb/value.c:3078
|
||||
#9 0x20e98f8 in value_field(value*, int) gdb/value.c:3095
|
||||
#10 0xcafd64 in print_field_values gdb/ada-valprint.c:658
|
||||
#11 0xcb0fa0 in ada_val_print_struct_union gdb/ada-valprint.c:857
|
||||
#12 0xcb1bb4 in ada_value_print_inner(value*, ui_file*, int, value_print_options const*) gdb/ada-valprint.c:1042
|
||||
#13 0xc66e04 in ada_language::value_print_inner(value*, ui_file*, int, value_print_options const*) const (/home/vries/gdb/build/gdb/gdb+0xc66e04)
|
||||
#14 0x20ca1e8 in common_val_print(value*, ui_file*, int, value_print_options const*, language_defn const*) gdb/valprint.c:1092
|
||||
#15 0x20caabc in common_val_print_checked(value*, ui_file*, int, value_print_options const*, language_defn const*) gdb/valprint.c:1184
|
||||
#16 0x196c524 in print_variable_and_value(char const*, symbol*, frame_info_ptr, ui_file*, int) gdb/printcmd.c:2355
|
||||
#17 0x1d99ca0 in print_variable_and_value_data::operator()(char const*, symbol*) gdb/stack.c:2308
|
||||
#18 0x1dabca0 in gdb::function_view<void (char const*, symbol*)>::bind<print_variable_and_value_data>(print_variable_and_value_data&)::{lambda(gdb::fv_detail::erased_callable, char const*, symbol*)#1}::operator()(gdb::fv_detail::erased_callable, char const*, symbol*) const gdb/../gdbsupport/function-view.h:305
|
||||
#19 0x1dabd14 in gdb::function_view<void (char const*, symbol*)>::bind<print_variable_and_value_data>(print_variable_and_value_data&)::{lambda(gdb::fv_detail::erased_callable, char const*, symbol*)#1}::_FUN(gdb::fv_detail::erased_callable, char const*, symbol*) gdb/../gdbsupport/function-view.h:299
|
||||
#20 0x1dab34c in gdb::function_view<void (char const*, symbol*)>::operator()(char const*, symbol*) const gdb/../gdbsupport/function-view.h:289
|
||||
#21 0x1d9963c in iterate_over_block_locals gdb/stack.c:2240
|
||||
#22 0x1d99790 in iterate_over_block_local_vars(block const*, gdb::function_view<void (char const*, symbol*)>) gdb/stack.c:2259
|
||||
#23 0x1d9a598 in print_frame_local_vars gdb/stack.c:2380
|
||||
#24 0x1d9afac in info_locals_command(char const*, int) gdb/stack.c:2458
|
||||
#25 0xfd7b30 in do_simple_func gdb/cli/cli-decode.c:95
|
||||
#26 0xfe5a2c in cmd_func(cmd_list_element*, char const*, int) gdb/cli/cli-decode.c:2735
|
||||
#27 0x1f03790 in execute_command(char const*, int) gdb/top.c:575
|
||||
#28 0x1384080 in command_handler(char const*) gdb/event-top.c:566
|
||||
#29 0x1384e2c in command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) gdb/event-top.c:802
|
||||
#30 0x1f731e4 in tui_command_line_handler gdb/tui/tui-interp.c:104
|
||||
#31 0x1382a58 in gdb_rl_callback_handler gdb/event-top.c:259
|
||||
#32 0x21dbb80 in rl_callback_read_char readline/readline/callback.c:290
|
||||
#33 0x1382510 in gdb_rl_callback_read_char_wrapper_noexcept gdb/event-top.c:195
|
||||
#34 0x138277c in gdb_rl_callback_read_char_wrapper gdb/event-top.c:234
|
||||
#35 0x1fe9b40 in stdin_event_handler gdb/ui.c:155
|
||||
#36 0x35ff1bc in handle_file_event gdbsupport/event-loop.cc:573
|
||||
#37 0x35ff9d8 in gdb_wait_for_event gdbsupport/event-loop.cc:694
|
||||
#38 0x35fd284 in gdb_do_one_event(int) gdbsupport/event-loop.cc:264
|
||||
#39 0x1768080 in start_event_loop gdb/main.c:408
|
||||
#40 0x17684c4 in captured_command_loop gdb/main.c:472
|
||||
#41 0x176cfc8 in captured_main gdb/main.c:1342
|
||||
#42 0x176d088 in gdb_main(captured_main_args*) gdb/main.c:1361
|
||||
#43 0xb73edc in main gdb/gdb.c:39
|
||||
#44 0xffff519b09d8 in __libc_start_call_main (/lib64/libc.so.6+0x309d8)
|
||||
#45 0xffff519b0aac in __libc_start_main@@GLIBC_2.34 (/lib64/libc.so.6+0x30aac)
|
||||
#46 0xb73c2c in _start (/home/vries/gdb/build/gdb/gdb+0xb73c2c)
|
||||
|
||||
0x602000097f58 is located 0 bytes after 8-byte region [0x602000097f50,0x602000097f58)
|
||||
allocated by thread T0 here:
|
||||
#0 0xffff52c65218 in calloc (/lib64/libasan.so.8+0xc5218)
|
||||
#1 0xcbc278 in xcalloc gdb/alloc.c:97
|
||||
#2 0x35f21e8 in xzalloc(unsigned long) gdbsupport/common-utils.cc:29
|
||||
#3 0x20de270 in value::allocate_contents(bool) gdb/value.c:937
|
||||
#4 0x20edc08 in value::fetch_lazy() gdb/value.c:4033
|
||||
#5 0x20dadc0 in value::entirely_covered_by_range_vector(std::vector<range, std::allocator<range> > const&) gdb/value.c:229
|
||||
#6 0xcb2298 in value::entirely_optimized_out() gdb/value.h:560
|
||||
#7 0x20ca6fc in value_check_printable gdb/valprint.c:1133
|
||||
#8 0x20caa8c in common_val_print_checked(value*, ui_file*, int, value_print_options const*, language_defn const*) gdb/valprint.c:1182
|
||||
#9 0x196c524 in print_variable_and_value(char const*, symbol*, frame_info_ptr, ui_file*, int) gdb/printcmd.c:2355
|
||||
#10 0x1d99ca0 in print_variable_and_value_data::operator()(char const*, symbol*) gdb/stack.c:2308
|
||||
#11 0x1dabca0 in gdb::function_view<void (char const*, symbol*)>::bind<print_variable_and_value_data>(print_variable_and_value_data&)::{lambda(gdb::fv_detail::erased_callable, char const*, symbol*)#1}::operator()(gdb::fv_detail::erased_callable, char const*, symbol*) const gdb/../gdbsupport/function-view.h:305
|
||||
#12 0x1dabd14 in gdb::function_view<void (char const*, symbol*)>::bind<print_variable_and_value_data>(print_variable_and_value_data&)::{lambda(gdb::fv_detail::erased_callable, char const*, symbol*)#1}::_FUN(gdb::fv_detail::erased_callable, char const*, symbol*) gdb/../gdbsupport/function-view.h:299
|
||||
#13 0x1dab34c in gdb::function_view<void (char const*, symbol*)>::operator()(char const*, symbol*) const gdb/../gdbsupport/function-view.h:289
|
||||
#14 0x1d9963c in iterate_over_block_locals gdb/stack.c:2240
|
||||
#15 0x1d99790 in iterate_over_block_local_vars(block const*, gdb::function_view<void (char const*, symbol*)>) gdb/stack.c:2259
|
||||
#16 0x1d9a598 in print_frame_local_vars gdb/stack.c:2380
|
||||
#17 0x1d9afac in info_locals_command(char const*, int) gdb/stack.c:2458
|
||||
#18 0xfd7b30 in do_simple_func gdb/cli/cli-decode.c:95
|
||||
#19 0xfe5a2c in cmd_func(cmd_list_element*, char const*, int) gdb/cli/cli-decode.c:2735
|
||||
#20 0x1f03790 in execute_command(char const*, int) gdb/top.c:575
|
||||
#21 0x1384080 in command_handler(char const*) gdb/event-top.c:566
|
||||
#22 0x1384e2c in command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) gdb/event-top.c:802
|
||||
#23 0x1f731e4 in tui_command_line_handler gdb/tui/tui-interp.c:104
|
||||
#24 0x1382a58 in gdb_rl_callback_handler gdb/event-top.c:259
|
||||
#25 0x21dbb80 in rl_callback_read_char readline/readline/callback.c:290
|
||||
#26 0x1382510 in gdb_rl_callback_read_char_wrapper_noexcept gdb/event-top.c:195
|
||||
#27 0x138277c in gdb_rl_callback_read_char_wrapper gdb/event-top.c:234
|
||||
#28 0x1fe9b40 in stdin_event_handler gdb/ui.c:155
|
||||
#29 0x35ff1bc in handle_file_event gdbsupport/event-loop.cc:573
|
||||
|
||||
SUMMARY: AddressSanitizer: heap-buffer-overflow (/lib64/libasan.so.8+0x6da18) in memmove
|
||||
...
|
||||
|
||||
The error happens when trying to print either variable y or y2:
|
||||
...
|
||||
type Variable_Record (A : Boolean := True) is record
|
||||
case A is
|
||||
when True =>
|
||||
B : Integer;
|
||||
when False =>
|
||||
C : Float;
|
||||
D : Integer;
|
||||
end case;
|
||||
end record;
|
||||
Y : Variable_Record := (A => True, B => 1);
|
||||
Y2 : Variable_Record := (A => False, C => 1.0, D => 2);
|
||||
...
|
||||
when the variables are uninitialized.
|
||||
|
||||
The error happens only when printing the entire variable:
|
||||
...
|
||||
(gdb) p y.a
|
||||
$2 = 216
|
||||
(gdb) p y.b
|
||||
There is no member named b.
|
||||
(gdb) p y.c
|
||||
$3 = 9.18340949e-41
|
||||
(gdb) p y.d
|
||||
$4 = 1
|
||||
(gdb) p y
|
||||
<AddressSanitizer: heap-buffer-overflow>
|
||||
...
|
||||
|
||||
The error happens as follows:
|
||||
- field a functions as discriminant, choosing either the b, or c+d variant.
|
||||
- when y.a happens to be set to 216, as above, gdb interprets this as the
|
||||
variable having the c+d variant (which is why trying to print y.b fails).
|
||||
- when printing y, gdb allocates a value, copies the bytes into it from the
|
||||
target, and then prints the value.
|
||||
- gdb allocates the value using the type size, which is 8. It's 8 because
|
||||
that's what the DW_AT_byte_size indicates. Note that for valid values of a,
|
||||
it gives correct results: if a is 0 (c+d variant), size is 12, if a is 1
|
||||
(b variant), size is 8.
|
||||
- gdb tries to print field d, which is at an 8 byte offset, and that results
|
||||
in a out-of-bounds access for the allocated 8-byte value.
|
||||
|
||||
Fix this by handling this case in value::contents_copy_raw, such that we have:
|
||||
...
|
||||
(gdb) p y
|
||||
$1 = (a => 24, c => 9.18340949e-41,
|
||||
d => <error reading variable: access outside bounds of object>)
|
||||
...
|
||||
|
||||
An alternative (additional) fix could be this: in compute_variant_fields_inner
|
||||
gdb reads the discriminant y.a to decide which variant is active. It would be
|
||||
nice to detect that the value (y.a == 24) is not a valid Boolean, and give up
|
||||
on choosing a variant altoghether. However, the situation regarding the
|
||||
internal type CODE_TYPE_BOOL is currently ambiguous (see PR31282) and it's not
|
||||
possible to reliably decide what valid values are.
|
||||
|
||||
The test-case source file gdb.ada/uninitialized-variable-record/parse.adb is
|
||||
a reduced version of gdb.ada/uninitialized_vars/parse.adb, so it copies the
|
||||
copyright years.
|
||||
|
||||
Note that the test-case needs gcc-12 or newer, it's unsupported for older gcc
|
||||
versions. [ So, it would be nice to rewrite it into a dwarf assembly
|
||||
test-case. ]
|
||||
|
||||
The test-case loops over all languages. This is inherited from an earlier
|
||||
attempt to fix this, which had language-specific fixes (in print_field_values,
|
||||
cp_print_value_fields, pascal_object_print_value_fields and
|
||||
f_language::value_print_inner). I've left this in, but I suppose it's not
|
||||
strictly necessary anymore.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
PR exp/31258
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31258
|
||||
---
|
||||
.../gdb.ada/uninitialized-variable-record.exp | 122 ++++++++++++++++++
|
||||
.../uninitialized-variable-record/parse.adb | 33 +++++
|
||||
gdb/value.c | 3 +
|
||||
3 files changed, 158 insertions(+)
|
||||
create mode 100644 gdb/testsuite/gdb.ada/uninitialized-variable-record.exp
|
||||
create mode 100644 gdb/testsuite/gdb.ada/uninitialized-variable-record/parse.adb
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.ada/uninitialized-variable-record.exp b/gdb/testsuite/gdb.ada/uninitialized-variable-record.exp
|
||||
new file mode 100644
|
||||
index 00000000000..7fc72395edf
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.ada/uninitialized-variable-record.exp
|
||||
@@ -0,0 +1,122 @@
|
||||
+# Copyright 2024 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/>.
|
||||
+
|
||||
+load_lib "ada.exp"
|
||||
+
|
||||
+require allow_ada_tests
|
||||
+
|
||||
+standard_ada_testfile parse
|
||||
+
|
||||
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+clean_restart ${testfile}
|
||||
+
|
||||
+set bp_location [gdb_get_line_number "START" ${testdir}/parse.adb]
|
||||
+runto "parse.adb:$bp_location"
|
||||
+
|
||||
+# Check that we have the expected value for variable y2.
|
||||
+
|
||||
+gdb_test "p y2" [string_to_regexp " = (a => false, c => 1.0, d => 2)"]
|
||||
+
|
||||
+# Shorthand.
|
||||
+
|
||||
+proc set_lang { lang } {
|
||||
+ gdb_test_multiple "set language $lang" "" {
|
||||
+ -re -wrap "" {
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+# Calculate the offset of y2.d.
|
||||
+
|
||||
+set re_cast [string_to_regexp "(access integer)"]
|
||||
+gdb_test_multiple "print &y2.d - &y2" "" {
|
||||
+ -re -wrap " = $re_cast ($hex)" {
|
||||
+ set offset_d $expect_out(1,string)
|
||||
+ pass $gdb_test_name
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+# Try to find a interesting discriminator value, such that at the same time:
|
||||
+# - the d field is part of the variable, and
|
||||
+# - the type size is too small to contain d.
|
||||
+
|
||||
+set interesting_discriminator -1
|
||||
+set_lang c
|
||||
+for { set i 0 } { $i < 256 } { incr i } {
|
||||
+ with_test_prefix $i {
|
||||
+
|
||||
+ # Patch in the discriminator value.
|
||||
+ gdb_test_multiple "set var *(unsigned char *)(&y2.a)=$i" "" {
|
||||
+ -re -wrap "" {
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ # Check that we have the variant with fields c+d instead of b.
|
||||
+ set have_b 0
|
||||
+ gdb_test_multiple "with language ada -- print y2.b" "" {
|
||||
+ -re -wrap " = $decimal" {
|
||||
+ set have_b 1
|
||||
+ }
|
||||
+ -re -wrap "" {
|
||||
+ }
|
||||
+ }
|
||||
+ if { $have_b } {
|
||||
+ # This is the variant with field b.
|
||||
+ continue
|
||||
+ }
|
||||
+
|
||||
+ set size 0
|
||||
+ gdb_test_multiple "print sizeof (y2)" "" {
|
||||
+ -re -wrap " = (.*)" {
|
||||
+ set size $expect_out(1,string)
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if { ! $size } {
|
||||
+ continue
|
||||
+ }
|
||||
+
|
||||
+ if { [expr $size > $offset_d] } {
|
||||
+ # Field d fits in the size.
|
||||
+ continue
|
||||
+ }
|
||||
+
|
||||
+ set interesting_discriminator $i
|
||||
+ break
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+require {expr $interesting_discriminator != -1}
|
||||
+
|
||||
+foreach lang [gdb_supported_languages] {
|
||||
+ with_test_prefix $lang {
|
||||
+ set_lang $lang
|
||||
+
|
||||
+ gdb_test_multiple "print y2" "" {
|
||||
+ -re -wrap ", d => $decimal.*" {
|
||||
+ fail $gdb_test_name
|
||||
+ }
|
||||
+ -re -wrap ", d = $decimal.*" {
|
||||
+ fail $gdb_test_name
|
||||
+ }
|
||||
+ -re -wrap "" {
|
||||
+ pass $gdb_test_name
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.ada/uninitialized-variable-record/parse.adb b/gdb/testsuite/gdb.ada/uninitialized-variable-record/parse.adb
|
||||
new file mode 100644
|
||||
index 00000000000..f00c75ca2dc
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.ada/uninitialized-variable-record/parse.adb
|
||||
@@ -0,0 +1,33 @@
|
||||
+-- Copyright 2009-2024 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/>.
|
||||
+
|
||||
+-- Based on gdb.ada/uninitialized_vars/parse.adb.
|
||||
+
|
||||
+procedure Parse is
|
||||
+
|
||||
+ type Variable_Record (A : Boolean := True) is record
|
||||
+ case A is
|
||||
+ when True =>
|
||||
+ B : Integer;
|
||||
+ when False =>
|
||||
+ C : Float;
|
||||
+ D : Integer;
|
||||
+ end case;
|
||||
+ end record;
|
||||
+ Y2 : Variable_Record := (A => False, C => 1.0, D => 2);
|
||||
+
|
||||
+begin
|
||||
+ null; -- START
|
||||
+end Parse;
|
||||
diff --git a/gdb/value.c b/gdb/value.c
|
||||
index 1cc32625629..56ae9db6603 100644
|
||||
--- a/gdb/value.c
|
||||
+++ b/gdb/value.c
|
||||
@@ -1188,6 +1188,9 @@ value::contents_copy_raw (struct value *dst, LONGEST dst_offset,
|
||||
gdb_assert (!dst->bits_any_optimized_out (TARGET_CHAR_BIT * dst_offset,
|
||||
TARGET_CHAR_BIT * length));
|
||||
|
||||
+ if ((src_offset + copy_length) * unit_size > enclosing_type ()-> length ())
|
||||
+ error (_("access outside bounds of object"));
|
||||
+
|
||||
/* Copy the data. */
|
||||
gdb::array_view<gdb_byte> dst_contents
|
||||
= dst->contents_all_raw ().slice (dst_offset * unit_size,
|
||||
--
|
||||
2.35.3
|
||||
|
86
gdb-exp-redo-cast-handling-for-indirection.patch
Normal file
86
gdb-exp-redo-cast-handling-for-indirection.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From a6800d9c8145f25001dd39afc3571e3350573e81 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Mon, 6 May 2024 14:23:25 +0200
|
||||
Subject: [PATCH] [gdb/exp] Redo cast handling for indirection
|
||||
|
||||
In commit ed8fd0a342f ("[gdb/exp] Fix cast handling for indirection"), I
|
||||
introduced the behaviour that even though we have:
|
||||
...
|
||||
(gdb) p *a_loc ()
|
||||
'a_loc' has unknown return type; cast the call to its declared return type
|
||||
...
|
||||
we get:
|
||||
...
|
||||
(gdb) p (char)*a_loc ()
|
||||
$1 = 97 'a'
|
||||
...
|
||||
|
||||
In other words, the unknown return type of a_loc is inferred from the cast,
|
||||
effectually evaluating:
|
||||
...
|
||||
(gdb) p (char)*(char *)a_loc ()
|
||||
...
|
||||
|
||||
This is convient for the case that errno is defined as:
|
||||
...
|
||||
#define errno (*__errno_location ())
|
||||
...
|
||||
and the return type of __errno_location is unknown but the macro definition is
|
||||
known, such that we can use:
|
||||
...
|
||||
(gdb) p (int)errno
|
||||
...
|
||||
instead of
|
||||
...
|
||||
(gdb) p *(int *)__errno_location ()
|
||||
...
|
||||
|
||||
However, as Pedro has pointed out in post-commit review [1], this makes it
|
||||
harder to reason about the semantics of an expression.
|
||||
|
||||
For instance, this:
|
||||
...
|
||||
(gdb) p (long long)*a_loc ()"
|
||||
...
|
||||
would be evaluated without debug info as:
|
||||
...
|
||||
(gdb) p (long long)*(long long *)a_loc ()"
|
||||
...
|
||||
but with debug info as:
|
||||
...
|
||||
(gdb) p (long long)*(char *)a_loc ()"
|
||||
...
|
||||
|
||||
Fix this by instead simply erroring out for this case:
|
||||
...
|
||||
(gdb) p (char)*a_loc ()
|
||||
'a_loc' has unknown return type; cast the call to its declared return type
|
||||
...
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
Approved-By: Pedro Alves <pedro@palves.net>
|
||||
|
||||
[1] https://sourceware.org/pipermail/gdb-patches/2024-May/208821.html
|
||||
---
|
||||
gdb/testsuite/gdb.base/cast-indirection.exp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/cast-indirection.exp b/gdb/testsuite/gdb.base/cast-indirection.exp
|
||||
index f1fe4302d27..7b9b5a5d677 100644
|
||||
--- a/gdb/testsuite/gdb.base/cast-indirection.exp
|
||||
+++ b/gdb/testsuite/gdb.base/cast-indirection.exp
|
||||
@@ -13,7 +13,7 @@
|
||||
# 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 "p (char)*a_loc ()" is handled as "p (char)*(char *)a_loc ()".
|
||||
+# Check that "p (char)*a_loc ()" is handled correctly.
|
||||
|
||||
standard_testfile
|
||||
|
||||
|
||||
base-commit: fc73000faa1798573090994167b7e2d451c211db
|
||||
--
|
||||
2.35.3
|
||||
|
@ -12,7 +12,269 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1270534
|
||||
diff --git a/gdb/configure b/gdb/configure
|
||||
--- a/gdb/configure
|
||||
+++ b/gdb/configure
|
||||
@@ -20915,6 +20915,7 @@ if test x"$prefer_curses" = xyes; then
|
||||
@@ -780,9 +780,6 @@ ENABLE_BFD_64_BIT_TRUE
|
||||
subdirs
|
||||
RPM_LIBS
|
||||
RPM_CFLAGS
|
||||
-PKG_CONFIG_LIBDIR
|
||||
-PKG_CONFIG_PATH
|
||||
-PKG_CONFIG
|
||||
GDB_DATADIR
|
||||
DEBUGDIR
|
||||
MAKEINFO_EXTRA_FLAGS
|
||||
@@ -990,12 +987,12 @@ PKG_CONFIG_PATH
|
||||
PKG_CONFIG_LIBDIR
|
||||
MAKEINFO
|
||||
MAKEINFOFLAGS
|
||||
+RPM_CFLAGS
|
||||
+RPM_LIBS
|
||||
AMD_DBGAPI_CFLAGS
|
||||
AMD_DBGAPI_LIBS
|
||||
DEBUGINFOD_CFLAGS
|
||||
DEBUGINFOD_LIBS
|
||||
-RPM_CFLAGS
|
||||
-RPM_LIBS
|
||||
YACC
|
||||
YFLAGS
|
||||
ZSTD_CFLAGS
|
||||
@@ -1684,11 +1681,11 @@ Optional Packages:
|
||||
[--with-auto-load-dir]
|
||||
--without-auto-load-safe-path
|
||||
do not restrict auto-loaded files locations
|
||||
+ --with-rpm query rpm database for missing debuginfos (yes/no,
|
||||
+ def. auto=librpm.so)
|
||||
--with-amd-dbgapi support for the amd-dbgapi target (yes / no / auto)
|
||||
--with-debuginfod Enable debuginfo lookups with debuginfod
|
||||
(auto/yes/no)
|
||||
- --with-rpm query rpm database for missing debuginfos (yes/no,
|
||||
- def. auto=librpm.so)
|
||||
--with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
|
||||
--with-curses use the curses library instead of the termcap
|
||||
library
|
||||
@@ -1761,6 +1758,8 @@ Some influential environment variables:
|
||||
MAKEINFO Parent configure detects if it is of sufficient version.
|
||||
MAKEINFOFLAGS
|
||||
Parameters for MAKEINFO.
|
||||
+ RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
|
||||
+ RPM_LIBS linker flags for RPM, overriding pkg-config
|
||||
AMD_DBGAPI_CFLAGS
|
||||
C compiler flags for AMD_DBGAPI, overriding pkg-config
|
||||
AMD_DBGAPI_LIBS
|
||||
@@ -1769,8 +1768,6 @@ Some influential environment variables:
|
||||
C compiler flags for DEBUGINFOD, overriding pkg-config
|
||||
DEBUGINFOD_LIBS
|
||||
linker flags for DEBUGINFOD, overriding pkg-config
|
||||
- RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
|
||||
- RPM_LIBS linker flags for RPM, overriding pkg-config
|
||||
YACC The `Yet Another Compiler Compiler' implementation to use.
|
||||
Defaults to the first program found out of: `bison -y', `byacc',
|
||||
`yacc'.
|
||||
@@ -11495,7 +11492,7 @@ else
|
||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
-#line 11486 "configure"
|
||||
+#line 11495 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
@@ -11601,7 +11598,7 @@ else
|
||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
-#line 11592 "configure"
|
||||
+#line 11601 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
@@ -18102,8 +18099,8 @@ $as_echo_n "checking specific librpm version... " >&6; }
|
||||
if test "$cross_compiling" = yes; then :
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
-as_fn_error "cannot run test program while cross compiling
|
||||
-See \`config.log' for more details." "$LINENO" 5; }
|
||||
+as_fn_error $? "cannot run test program while cross compiling
|
||||
+See \`config.log' for more details" "$LINENO" 5; }
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
@@ -18275,132 +18272,12 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
|
||||
$as_echo "no" >&6; }
|
||||
LIBS="$save_LIBS"
|
||||
if $DLOPEN_REQUIRE; then
|
||||
- as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
|
||||
+ as_fn_error $? "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
|
||||
fi
|
||||
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
|
||||
- if test -n "$ac_tool_prefix"; then
|
||||
- # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
|
||||
-set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
|
||||
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
-$as_echo_n "checking for $ac_word... " >&6; }
|
||||
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
|
||||
- $as_echo_n "(cached) " >&6
|
||||
-else
|
||||
- case $PKG_CONFIG in
|
||||
- [\\/]* | ?:[\\/]*)
|
||||
- ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
|
||||
- ;;
|
||||
- *)
|
||||
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
-for as_dir in $PATH
|
||||
-do
|
||||
- IFS=$as_save_IFS
|
||||
- test -z "$as_dir" && as_dir=.
|
||||
- for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
- ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
|
||||
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
- break 2
|
||||
- fi
|
||||
-done
|
||||
- done
|
||||
-IFS=$as_save_IFS
|
||||
-
|
||||
- ;;
|
||||
-esac
|
||||
-fi
|
||||
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
|
||||
-if test -n "$PKG_CONFIG"; then
|
||||
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
|
||||
-$as_echo "$PKG_CONFIG" >&6; }
|
||||
-else
|
||||
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
-$as_echo "no" >&6; }
|
||||
-fi
|
||||
-
|
||||
-
|
||||
-fi
|
||||
-if test -z "$ac_cv_path_PKG_CONFIG"; then
|
||||
- ac_pt_PKG_CONFIG=$PKG_CONFIG
|
||||
- # Extract the first word of "pkg-config", so it can be a program name with args.
|
||||
-set dummy pkg-config; ac_word=$2
|
||||
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
-$as_echo_n "checking for $ac_word... " >&6; }
|
||||
-if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
|
||||
- $as_echo_n "(cached) " >&6
|
||||
-else
|
||||
- case $ac_pt_PKG_CONFIG in
|
||||
- [\\/]* | ?:[\\/]*)
|
||||
- ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
|
||||
- ;;
|
||||
- *)
|
||||
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
-for as_dir in $PATH
|
||||
-do
|
||||
- IFS=$as_save_IFS
|
||||
- test -z "$as_dir" && as_dir=.
|
||||
- for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
- ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
|
||||
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
- break 2
|
||||
- fi
|
||||
-done
|
||||
- done
|
||||
-IFS=$as_save_IFS
|
||||
-
|
||||
- ;;
|
||||
-esac
|
||||
-fi
|
||||
-ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
|
||||
-if test -n "$ac_pt_PKG_CONFIG"; then
|
||||
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
|
||||
-$as_echo "$ac_pt_PKG_CONFIG" >&6; }
|
||||
-else
|
||||
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
-$as_echo "no" >&6; }
|
||||
-fi
|
||||
-
|
||||
- if test "x$ac_pt_PKG_CONFIG" = x; then
|
||||
- PKG_CONFIG=""
|
||||
- else
|
||||
- case $cross_compiling:$ac_tool_warned in
|
||||
-yes:)
|
||||
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
|
||||
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
|
||||
-ac_tool_warned=yes ;;
|
||||
-esac
|
||||
- PKG_CONFIG=$ac_pt_PKG_CONFIG
|
||||
- fi
|
||||
-else
|
||||
- PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
|
||||
-fi
|
||||
-
|
||||
-fi
|
||||
-if test -n "$PKG_CONFIG"; then
|
||||
- _pkg_min_version=0.9.0
|
||||
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
|
||||
-$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
|
||||
- if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
|
||||
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
-$as_echo "yes" >&6; }
|
||||
- else
|
||||
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
-$as_echo "no" >&6; }
|
||||
- PKG_CONFIG=""
|
||||
- fi
|
||||
-fi
|
||||
-
|
||||
pkg_failed=no
|
||||
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
|
||||
-$as_echo_n "checking for RPM... " >&6; }
|
||||
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rpm" >&5
|
||||
+$as_echo_n "checking for rpm... " >&6; }
|
||||
|
||||
if test -n "$RPM_CFLAGS"; then
|
||||
pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
|
||||
@@ -18437,6 +18314,30 @@ fi
|
||||
pkg_failed=untried
|
||||
fi
|
||||
|
||||
+if test $pkg_failed = no; then
|
||||
+ pkg_save_LDFLAGS="$LDFLAGS"
|
||||
+ LDFLAGS="$LDFLAGS $pkg_cv_RPM_LIBS"
|
||||
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
+/* end confdefs.h. */
|
||||
+
|
||||
+int
|
||||
+main ()
|
||||
+{
|
||||
+
|
||||
+ ;
|
||||
+ return 0;
|
||||
+}
|
||||
+_ACEOF
|
||||
+if ac_fn_c_try_link "$LINENO"; then :
|
||||
+
|
||||
+else
|
||||
+ pkg_failed=yes
|
||||
+fi
|
||||
+rm -f core conftest.err conftest.$ac_objext \
|
||||
+ conftest$ac_exeext conftest.$ac_ext
|
||||
+ LDFLAGS=$pkg_save_LDFLAGS
|
||||
+fi
|
||||
+
|
||||
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
@@ -18531,7 +18432,7 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
|
||||
LIBS="$LIBS $RPM_LIBS"
|
||||
else
|
||||
if $RPM_REQUIRE; then
|
||||
- as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
|
||||
+ as_fn_error $? "$RPM_PKG_ERRORS" "$LINENO" 5
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
|
||||
$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
|
||||
@@ -21164,6 +21065,7 @@ if test x"$prefer_curses" = xyes; then
|
||||
# search /usr/local/include, if ncurses is installed in /usr/local. A
|
||||
# default installation of ncurses on alpha*-dec-osf* will lead to such
|
||||
# a situation.
|
||||
@ -20,7 +282,7 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5
|
||||
$as_echo_n "checking for library containing waddstr... " >&6; }
|
||||
if ${ac_cv_search_waddstr+:} false; then :
|
||||
@@ -20939,7 +20940,7 @@ return waddstr ();
|
||||
@@ -21188,7 +21090,7 @@ return waddstr ();
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
@ -29,7 +291,7 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
if test -z "$ac_lib"; then
|
||||
ac_res="none required"
|
||||
else
|
||||
@@ -21013,6 +21014,7 @@ case $host_os in
|
||||
@@ -21260,6 +21162,7 @@ case $host_os in
|
||||
esac
|
||||
|
||||
# These are the libraries checked by Readline.
|
||||
@ -37,7 +299,7 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
|
||||
$as_echo_n "checking for library containing tgetent... " >&6; }
|
||||
if ${ac_cv_search_tgetent+:} false; then :
|
||||
@@ -21037,7 +21039,7 @@ return tgetent ();
|
||||
@@ -21284,7 +21187,7 @@ return tgetent ();
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
@ -49,17 +311,17 @@ diff --git a/gdb/configure b/gdb/configure
|
||||
diff --git a/gdb/configure.ac b/gdb/configure.ac
|
||||
--- a/gdb/configure.ac
|
||||
+++ b/gdb/configure.ac
|
||||
@@ -704,7 +704,8 @@ if test x"$prefer_curses" = xyes; then
|
||||
@@ -749,7 +749,8 @@ if test x"$prefer_curses" = xyes; then
|
||||
# search /usr/local/include, if ncurses is installed in /usr/local. A
|
||||
# default installation of ncurses on alpha*-dec-osf* will lead to such
|
||||
# a situation.
|
||||
- AC_SEARCH_LIBS(waddstr, [ncursesw ncurses cursesX curses])
|
||||
- AC_SEARCH_LIBS(waddstr, [ncursesw ncurses cursesX curses],
|
||||
+ # Fedora: Force libncursesw over libncurses to match the includes.
|
||||
+ AC_SEARCH_LIBS(waddstr, [ncursesw])
|
||||
|
||||
if test "$ac_cv_search_waddstr" != no; then
|
||||
curses_found=yes
|
||||
@@ -746,7 +747,8 @@ case $host_os in
|
||||
+ AC_SEARCH_LIBS(waddstr, [ncursesw],
|
||||
[curses_found=yes
|
||||
AC_DEFINE([HAVE_LIBCURSES], [1],
|
||||
[Define to 1 if curses is enabled.])
|
||||
@@ -789,7 +790,8 @@ case $host_os in
|
||||
esac
|
||||
|
||||
# These are the libraries checked by Readline.
|
||||
|
144
gdb-fix-heap-use-after-free-in-select_event_lwp.patch
Normal file
144
gdb-fix-heap-use-after-free-in-select_event_lwp.patch
Normal file
@ -0,0 +1,144 @@
|
||||
From 350172ea215c7074601e8424ff636563612f91e8 Mon Sep 17 00:00:00 2001
|
||||
From: Pedro Alves <pedro@palves.net>
|
||||
Date: Wed, 21 Feb 2024 16:23:55 +0000
|
||||
Subject: [PATCH 14/48] [gdb] Fix heap-use-after-free in select_event_lwp
|
||||
|
||||
PR gdb/31259 reveals one scenario where we run into a
|
||||
heap-use-after-free reported by thread sanitizer, while running
|
||||
gdb.base/vfork-follow-parent.exp.
|
||||
|
||||
The heap-use-after-free happens during the following scenario:
|
||||
|
||||
- linux_nat_wait_1 is about to return an event for T2. It stops all
|
||||
other threads, and while doing so, stop_wait_callback -> wait_lwp
|
||||
sees T1 exit, and decides to leave the exit event pending. It
|
||||
should have set the lp->stopped flag too, but does not -- this is
|
||||
the bug.
|
||||
|
||||
- The event for T2 is reported, is processed by infrun, and we're
|
||||
back at linux_nat_wait_1.
|
||||
|
||||
- linux_nat_wait_1 selects LWP T1 with the pending exit status to
|
||||
report.
|
||||
|
||||
- it sets variable lp to point to the corresponding lwp_info.
|
||||
|
||||
- it calls stop_callback and stop_wait_callback for all threads
|
||||
(because !target_is_non_stop_p ()).
|
||||
|
||||
- it calls select_event_lwp to maybe pick another thread than T1, to
|
||||
prevent starvation.
|
||||
|
||||
The problem is the following:
|
||||
|
||||
- while calling stop_wait_callback for all threads, it also does this
|
||||
for T1. While doing so, the corresponding lwp_info is deleted
|
||||
(callstack stop_wait_callback -> wait_lwp -> exit_lwp ->
|
||||
delete_lwp), leaving variable lp as a dangling pointer.
|
||||
|
||||
- variable lp is passed to select_event_lwp, which derefences it,
|
||||
which causes the heap-use-after-free.
|
||||
|
||||
Note that the comment here mentions "all other LWP's":
|
||||
...
|
||||
/* Now stop all other LWP's ... */
|
||||
iterate_over_lwps (minus_one_ptid, stop_callback);
|
||||
/* ... and wait until all of them have reported back that
|
||||
they're no longer running. */
|
||||
iterate_over_lwps (minus_one_ptid, stop_wait_callback);
|
||||
...
|
||||
|
||||
The reason the comments say "all other LWP's", and doesn't bother
|
||||
filtering out LP is that lp->stopped should be true at this point, and
|
||||
the callbacks (both stop_callback and stop_wait_callback) check that
|
||||
flag, and do nothing if set. I.e., they skip already-stopped threads,
|
||||
so they should skip LP.
|
||||
|
||||
In this particular scenario, though, we missed setting the stopped
|
||||
flag right in the first step described above, so LP was iterated over
|
||||
incorrectly.
|
||||
|
||||
The fix is to make wait_lwp set the lp->stopped flag when it decides
|
||||
to leave the exit event pending. However, going a bit further,
|
||||
gdbserver has a mark_lwp_dead function to centralize setting up
|
||||
various lwp flags such that the rest of the code doesn't mishandle
|
||||
them, and it seems like a good idea to do a similar thing in gdb as
|
||||
well. That is what this patch does.
|
||||
|
||||
PR gdb/31259
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31259
|
||||
Co-Authored-By: Tom de Vries <tdevries@suse.de>
|
||||
Change-Id: I4a6169976f89bf714c478cbb2b7d4c32365e62a9
|
||||
---
|
||||
gdb/linux-nat.c | 34 +++++++++++++++++++++++++---------
|
||||
1 file changed, 25 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
|
||||
index 7e36ced6292..ed445c5e5bb 100644
|
||||
--- a/gdb/linux-nat.c
|
||||
+++ b/gdb/linux-nat.c
|
||||
@@ -2029,6 +2029,27 @@ wait_for_signal ()
|
||||
}
|
||||
}
|
||||
|
||||
+/* Mark LWP dead, with STATUS as exit status pending to report
|
||||
+ later. */
|
||||
+
|
||||
+static void
|
||||
+mark_lwp_dead (lwp_info *lp, int status)
|
||||
+{
|
||||
+ /* Store the exit status lp->waitstatus, because lp->status would be
|
||||
+ ambiguous (W_EXITCODE(0,0) == 0). */
|
||||
+ lp->waitstatus = host_status_to_waitstatus (status);
|
||||
+
|
||||
+ /* If we're processing LP's status, there should be no other event
|
||||
+ already recorded as pending. */
|
||||
+ gdb_assert (lp->status == 0);
|
||||
+
|
||||
+ /* Dead LWPs aren't expected to report a pending sigstop. */
|
||||
+ lp->signalled = 0;
|
||||
+
|
||||
+ /* Prevent trying to stop it. */
|
||||
+ lp->stopped = 1;
|
||||
+}
|
||||
+
|
||||
/* Wait for LP to stop. Returns the wait status, or 0 if the LWP has
|
||||
exited. */
|
||||
|
||||
@@ -2114,9 +2135,8 @@ wait_lwp (struct lwp_info *lp)
|
||||
|
||||
/* If this is the leader exiting, it means the whole
|
||||
process is gone. Store the status to report to the
|
||||
- core. Store it in lp->waitstatus, because lp->status
|
||||
- would be ambiguous (W_EXITCODE(0,0) == 0). */
|
||||
- lp->waitstatus = host_status_to_waitstatus (status);
|
||||
+ core. */
|
||||
+ mark_lwp_dead (lp, status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2908,12 +2928,7 @@ linux_nat_filter_event (int lwpid, int status)
|
||||
linux_nat_debug_printf ("LWP %ld exited (resumed=%d)",
|
||||
lp->ptid.lwp (), lp->resumed);
|
||||
|
||||
- /* Dead LWP's aren't expected to reported a pending sigstop. */
|
||||
- lp->signalled = 0;
|
||||
-
|
||||
- /* Store the pending event in the waitstatus, because
|
||||
- W_EXITCODE(0,0) == 0. */
|
||||
- lp->waitstatus = host_status_to_waitstatus (status);
|
||||
+ mark_lwp_dead (lp, status);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3248,6 +3263,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
|
||||
}
|
||||
|
||||
gdb_assert (lp);
|
||||
+ gdb_assert (lp->stopped);
|
||||
|
||||
status = lp->status;
|
||||
lp->status = 0;
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,6 +1,6 @@
|
||||
From 75617e6d28b93814ac46ad85ad4fc2b133f61114 Mon Sep 17 00:00:00 2001
|
||||
From 1d02ba0f4adcba2595a67e88fb1ba6d35c7f8e5b Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 3 Nov 2023 16:25:33 +0100
|
||||
Date: Tue, 7 May 2024 11:33:57 +0200
|
||||
Subject: [PATCH] [gdb] Fix segfault in for_each_block, part 1
|
||||
|
||||
When running test-case gdb.base/vfork-follow-parent.exp on powerpc64 (likewise
|
||||
@ -75,7 +75,7 @@ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547
|
||||
gdb/breakpoint.c | 29 ++++++++-------
|
||||
gdb/inferior.c | 8 ++---
|
||||
gdb/inferior.h | 2 +-
|
||||
gdb/infrun.c | 20 +++++------
|
||||
gdb/infrun.c | 18 +++++-----
|
||||
gdb/linux-nat.c | 2 +-
|
||||
gdb/process-stratum-target.c | 2 +-
|
||||
gdb/progspace.c | 22 +++++-------
|
||||
@ -85,13 +85,13 @@ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547
|
||||
gdb/scoped-mock-context.h | 2 +-
|
||||
gdb/target-dcache.c | 11 +++---
|
||||
gdbsupport/refcounted-object.h | 17 +++++++++
|
||||
13 files changed, 103 insertions(+), 80 deletions(-)
|
||||
13 files changed, 102 insertions(+), 79 deletions(-)
|
||||
|
||||
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
|
||||
index f8d19356828..f4acb4ea8c4 100644
|
||||
index 01f187ca4fe..a22bdb091cd 100644
|
||||
--- a/gdb/breakpoint.c
|
||||
+++ b/gdb/breakpoint.c
|
||||
@@ -1605,7 +1605,7 @@ one_breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf,
|
||||
@@ -1723,7 +1723,7 @@ one_breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf,
|
||||
int bptoffset = 0;
|
||||
|
||||
if (!breakpoint_address_match (target_info->placed_address_space, 0,
|
||||
@ -100,7 +100,7 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
{
|
||||
/* The breakpoint is inserted in a different address space. */
|
||||
return;
|
||||
@@ -2278,7 +2278,7 @@ should_be_inserted (struct bp_location *bl)
|
||||
@@ -2409,7 +2409,7 @@ should_be_inserted (struct bp_location *bl)
|
||||
a breakpoint. */
|
||||
if ((bl->loc_type == bp_loc_software_breakpoint
|
||||
|| bl->loc_type == bp_loc_hardware_breakpoint)
|
||||
@ -109,7 +109,7 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
bl->address)
|
||||
/* The single-step breakpoint may be inserted at the location
|
||||
we're trying to step if the instruction branches to itself.
|
||||
@@ -2713,7 +2713,7 @@ insert_bp_location (struct bp_location *bl,
|
||||
@@ -2847,7 +2847,7 @@ insert_bp_location (struct bp_location *bl,
|
||||
read the breakpoint instead of returning the data saved in
|
||||
the breakpoint location's shadow contents. */
|
||||
bl->target_info.reqstd_address = bl->address;
|
||||
@ -118,7 +118,7 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
bl->target_info.length = bl->length;
|
||||
|
||||
/* When working with target-side conditions, we must pass all the conditions
|
||||
@@ -4276,7 +4276,7 @@ bp_location_inserted_here_p (const struct bp_location *bl,
|
||||
@@ -4429,7 +4429,7 @@ bp_location_inserted_here_p (const struct bp_location *bl,
|
||||
const address_space *aspace, CORE_ADDR pc)
|
||||
{
|
||||
if (bl->inserted
|
||||
@ -127,16 +127,16 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
aspace, pc))
|
||||
{
|
||||
/* An unmapped overlay can't be a match. */
|
||||
@@ -4355,7 +4355,7 @@ hardware_watchpoint_inserted_in_range (const address_space *aspace,
|
||||
@@ -4508,7 +4508,7 @@ hardware_watchpoint_inserted_in_range (const address_space *aspace,
|
||||
continue;
|
||||
|
||||
for (bp_location *loc : bpt->locations ())
|
||||
- if (loc->pspace->aspace == aspace && loc->inserted)
|
||||
+ if (loc->pspace->aspace.get () == aspace && loc->inserted)
|
||||
for (bp_location &loc : bpt.locations ())
|
||||
- if (loc.pspace->aspace == aspace && loc.inserted)
|
||||
+ if (loc.pspace->aspace.get () == aspace && loc.inserted)
|
||||
{
|
||||
CORE_ADDR l, h;
|
||||
|
||||
@@ -7153,10 +7153,10 @@ breakpoint_location_address_match (struct bp_location *bl,
|
||||
@@ -7330,10 +7330,10 @@ breakpoint_location_address_match (struct bp_location *bl,
|
||||
const address_space *aspace,
|
||||
CORE_ADDR addr)
|
||||
{
|
||||
@ -149,7 +149,7 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
bl->address, bl->length,
|
||||
aspace, addr)));
|
||||
}
|
||||
@@ -7173,7 +7173,7 @@ breakpoint_location_address_range_overlap (struct bp_location *bl,
|
||||
@@ -7350,7 +7350,7 @@ breakpoint_location_address_range_overlap (struct bp_location *bl,
|
||||
CORE_ADDR addr, int len)
|
||||
{
|
||||
if (gdbarch_has_global_breakpoints (target_gdbarch ())
|
||||
@ -158,7 +158,7 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
{
|
||||
int bl_len = bl->length != 0 ? bl->length : 1;
|
||||
|
||||
@@ -7230,8 +7230,10 @@ breakpoint_locations_match (const struct bp_location *loc1,
|
||||
@@ -7407,8 +7407,10 @@ breakpoint_locations_match (const struct bp_location *loc1,
|
||||
/* We compare bp_location.length in order to cover ranged
|
||||
breakpoints. Keep this in sync with
|
||||
bp_location_is_less_than. */
|
||||
@ -171,7 +171,7 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
&& (loc1->loc_type == loc2->loc_type || sw_hw_bps_match)
|
||||
&& loc1->length == loc2->length);
|
||||
}
|
||||
@@ -9297,8 +9299,9 @@ ranged_breakpoint::breakpoint_hit (const struct bp_location *bl,
|
||||
@@ -9568,8 +9570,9 @@ ranged_breakpoint::breakpoint_hit (const struct bp_location *bl,
|
||||
|| ws.sig () != GDB_SIGNAL_TRAP)
|
||||
return 0;
|
||||
|
||||
@ -183,7 +183,7 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
}
|
||||
|
||||
/* Implement the "resources_needed" method for ranged breakpoints. */
|
||||
@@ -11696,7 +11699,7 @@ code_breakpoint::breakpoint_hit (const struct bp_location *bl,
|
||||
@@ -12018,7 +12021,7 @@ code_breakpoint::breakpoint_hit (const struct bp_location *bl,
|
||||
|| ws.sig () != GDB_SIGNAL_TRAP)
|
||||
return 0;
|
||||
|
||||
@ -193,10 +193,10 @@ index f8d19356828..f4acb4ea8c4 100644
|
||||
return 0;
|
||||
|
||||
diff --git a/gdb/inferior.c b/gdb/inferior.c
|
||||
index b0ecca8b63a..87c61eeafd7 100644
|
||||
index 550bbd2827c..461f4fc076a 100644
|
||||
--- a/gdb/inferior.c
|
||||
+++ b/gdb/inferior.c
|
||||
@@ -775,15 +775,13 @@ remove_inferior_command (const char *args, int from_tty)
|
||||
@@ -831,15 +831,13 @@ remove_inferior_command (const char *args, int from_tty)
|
||||
struct inferior *
|
||||
add_inferior_with_spaces (void)
|
||||
{
|
||||
@ -213,7 +213,7 @@ index b0ecca8b63a..87c61eeafd7 100644
|
||||
inf = add_inferior (0);
|
||||
inf->pspace = pspace;
|
||||
inf->aspace = pspace->aspace;
|
||||
@@ -946,15 +944,13 @@ clone_inferior_command (const char *args, int from_tty)
|
||||
@@ -1002,15 +1000,13 @@ clone_inferior_command (const char *args, int from_tty)
|
||||
|
||||
for (i = 0; i < copies; ++i)
|
||||
{
|
||||
@ -231,10 +231,10 @@ index b0ecca8b63a..87c61eeafd7 100644
|
||||
inf->pspace = pspace;
|
||||
inf->aspace = pspace->aspace;
|
||||
diff --git a/gdb/inferior.h b/gdb/inferior.h
|
||||
index 4d001b0ad50..fa5c3c92eeb 100644
|
||||
index 29c90d15efa..4139791740f 100644
|
||||
--- a/gdb/inferior.h
|
||||
+++ b/gdb/inferior.h
|
||||
@@ -541,7 +541,7 @@ class inferior : public refcounted_object,
|
||||
@@ -577,7 +577,7 @@ class inferior : public refcounted_object,
|
||||
bool removable = false;
|
||||
|
||||
/* The address space bound to this inferior. */
|
||||
@ -244,10 +244,10 @@ index 4d001b0ad50..fa5c3c92eeb 100644
|
||||
/* The program space bound to this inferior. */
|
||||
struct program_space *pspace = NULL;
|
||||
diff --git a/gdb/infrun.c b/gdb/infrun.c
|
||||
index c078098a6f8..4073150d80c 100644
|
||||
index 7be98cfc252..3854c66bf6c 100644
|
||||
--- a/gdb/infrun.c
|
||||
+++ b/gdb/infrun.c
|
||||
@@ -501,8 +501,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \
|
||||
@@ -531,8 +531,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -258,7 +258,7 @@ index c078098a6f8..4073150d80c 100644
|
||||
child_inf->removable = true;
|
||||
clone_program_space (child_inf->pspace, parent_inf->pspace);
|
||||
}
|
||||
@@ -573,8 +573,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \
|
||||
@@ -610,8 +610,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \
|
||||
|
||||
child_inf->aspace = parent_inf->aspace;
|
||||
child_inf->pspace = parent_inf->pspace;
|
||||
@ -269,7 +269,7 @@ index c078098a6f8..4073150d80c 100644
|
||||
clone_program_space (parent_inf->pspace, child_inf->pspace);
|
||||
|
||||
/* The parent inferior is still the current one, so keep things
|
||||
@@ -583,8 +583,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \
|
||||
@@ -620,8 +620,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -280,7 +280,7 @@ index c078098a6f8..4073150d80c 100644
|
||||
child_inf->removable = true;
|
||||
child_inf->symfile_flags = SYMFILE_NO_READ;
|
||||
clone_program_space (child_inf->pspace, parent_inf->pspace);
|
||||
@@ -938,7 +938,6 @@ handle_vfork_child_exec_or_exit (int exec)
|
||||
@@ -1031,7 +1031,6 @@ handle_vfork_child_exec_or_exit (int exec)
|
||||
if (vfork_parent->pending_detach)
|
||||
{
|
||||
struct program_space *pspace;
|
||||
@ -288,7 +288,7 @@ index c078098a6f8..4073150d80c 100644
|
||||
|
||||
/* follow-fork child, detach-on-fork on. */
|
||||
|
||||
@@ -963,9 +962,8 @@ handle_vfork_child_exec_or_exit (int exec)
|
||||
@@ -1056,9 +1055,8 @@ handle_vfork_child_exec_or_exit (int exec)
|
||||
of" a hack. */
|
||||
|
||||
pspace = inf->pspace;
|
||||
@ -299,17 +299,8 @@ index c078098a6f8..4073150d80c 100644
|
||||
|
||||
if (print_inferior_events)
|
||||
{
|
||||
@@ -1019,7 +1017,7 @@ handle_vfork_child_exec_or_exit (int exec)
|
||||
/* Temporarily switch to the vfork parent, to facilitate ptrace
|
||||
calls done during maybe_new_address_space. */
|
||||
switch_to_thread (any_live_thread_of_inferior (vfork_parent));
|
||||
- address_space *aspace = maybe_new_address_space ();
|
||||
+ address_space_ref_ptr aspace = maybe_new_address_space ();
|
||||
|
||||
/* Switch back to the vfork child inferior. Switch to no-thread
|
||||
while running clone_program_space, so that clone_program_space
|
||||
@@ -5639,7 +5637,7 @@ handle_inferior_event (struct execution_control_state *ecs)
|
||||
= get_thread_arch_aspace_regcache (parent_inf->process_target (),
|
||||
@@ -5906,7 +5904,7 @@ handle_inferior_event (struct execution_control_state *ecs)
|
||||
= get_thread_arch_aspace_regcache (parent_inf,
|
||||
ecs->ws.child_ptid (),
|
||||
gdbarch,
|
||||
- parent_inf->aspace);
|
||||
@ -318,10 +309,10 @@ index c078098a6f8..4073150d80c 100644
|
||||
parent_pc = regcache_read_pc (regcache);
|
||||
|
||||
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
|
||||
index 2b206a4ec1e..474d3c7f945 100644
|
||||
index ed445c5e5bb..c8991cc3da4 100644
|
||||
--- a/gdb/linux-nat.c
|
||||
+++ b/gdb/linux-nat.c
|
||||
@@ -4316,7 +4316,7 @@ linux_nat_target::thread_address_space (ptid_t ptid)
|
||||
@@ -4365,7 +4365,7 @@ linux_nat_target::thread_address_space (ptid_t ptid)
|
||||
|
||||
inf = find_inferior_pid (this, pid);
|
||||
gdb_assert (inf != NULL);
|
||||
@ -331,7 +322,7 @@ index 2b206a4ec1e..474d3c7f945 100644
|
||||
|
||||
/* Return the cached value of the processor core for thread PTID. */
|
||||
diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c
|
||||
index 4722c5a0f28..e67012a8591 100644
|
||||
index 5c031203e89..4bcca4f39c2 100644
|
||||
--- a/gdb/process-stratum-target.c
|
||||
+++ b/gdb/process-stratum-target.c
|
||||
@@ -37,7 +37,7 @@ process_stratum_target::thread_address_space (ptid_t ptid)
|
||||
@ -344,10 +335,10 @@ index 4722c5a0f28..e67012a8591 100644
|
||||
|
||||
struct gdbarch *
|
||||
diff --git a/gdb/progspace.c b/gdb/progspace.c
|
||||
index 32bdfebcf7c..55df3b65dfe 100644
|
||||
index 1dbcd5875dd..b4d25ba6196 100644
|
||||
--- a/gdb/progspace.c
|
||||
+++ b/gdb/progspace.c
|
||||
@@ -54,8 +54,8 @@ address_space::address_space ()
|
||||
@@ -55,8 +55,8 @@ address_space::address_space ()
|
||||
return a pointer to an existing address space, in case inferiors
|
||||
share an address space on this target system. */
|
||||
|
||||
@ -358,7 +349,7 @@ index 32bdfebcf7c..55df3b65dfe 100644
|
||||
{
|
||||
int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
|
||||
|
||||
@@ -65,7 +65,7 @@ maybe_new_address_space (void)
|
||||
@@ -66,7 +66,7 @@ maybe_new_address_space (void)
|
||||
return program_spaces[0]->aspace;
|
||||
}
|
||||
|
||||
@ -367,7 +358,7 @@ index 32bdfebcf7c..55df3b65dfe 100644
|
||||
}
|
||||
|
||||
/* Start counting over from scratch. */
|
||||
@@ -93,9 +93,9 @@ remove_program_space (program_space *pspace)
|
||||
@@ -94,9 +94,9 @@ remove_program_space (program_space *pspace)
|
||||
|
||||
/* See progspace.h. */
|
||||
|
||||
@ -378,8 +369,8 @@ index 32bdfebcf7c..55df3b65dfe 100644
|
||||
+ aspace (std::move (aspace_))
|
||||
{
|
||||
program_spaces.push_back (this);
|
||||
}
|
||||
@@ -118,8 +118,6 @@ program_space::~program_space ()
|
||||
gdb::observers::new_program_space.notify (this);
|
||||
@@ -121,8 +121,6 @@ program_space::~program_space ()
|
||||
/* Defer breakpoint re-set because we don't want to create new
|
||||
locations for this pspace which we're tearing down. */
|
||||
clear_symtab_users (SYMFILE_DEFER_BP_RESET);
|
||||
@ -388,7 +379,7 @@ index 32bdfebcf7c..55df3b65dfe 100644
|
||||
}
|
||||
|
||||
/* See progspace.h. */
|
||||
@@ -389,18 +387,14 @@ update_address_spaces (void)
|
||||
@@ -408,18 +406,14 @@ update_address_spaces (void)
|
||||
|
||||
if (shared_aspace)
|
||||
{
|
||||
@ -409,7 +400,7 @@ index 32bdfebcf7c..55df3b65dfe 100644
|
||||
|
||||
for (inferior *inf : all_inferiors ())
|
||||
if (gdbarch_has_global_solist (target_gdbarch ()))
|
||||
@@ -437,5 +431,5 @@ initialize_progspace (void)
|
||||
@@ -456,5 +450,5 @@ initialize_progspace (void)
|
||||
modules have done that. Do this before
|
||||
initialize_current_architecture, because that accesses the ebfd
|
||||
of current_program_space. */
|
||||
@ -417,7 +408,7 @@ index 32bdfebcf7c..55df3b65dfe 100644
|
||||
+ current_program_space = new program_space (new_address_space ());
|
||||
}
|
||||
diff --git a/gdb/progspace.h b/gdb/progspace.h
|
||||
index 85215f0e2f1..07cca8c675c 100644
|
||||
index ee12d89c173..12f113f6d9c 100644
|
||||
--- a/gdb/progspace.h
|
||||
+++ b/gdb/progspace.h
|
||||
@@ -28,6 +28,8 @@
|
||||
@ -479,7 +470,7 @@ index 85215f0e2f1..07cca8c675c 100644
|
||||
|
||||
/* Releases a program space, and all its contents (shared libraries,
|
||||
objfiles, and any other references to the program space in other
|
||||
@@ -332,7 +368,7 @@ struct program_space
|
||||
@@ -336,7 +372,7 @@ struct program_space
|
||||
are global, then this field is ignored (we don't currently
|
||||
support inferiors sharing a program space if the target doesn't
|
||||
make breakpoints global). */
|
||||
@ -488,7 +479,7 @@ index 85215f0e2f1..07cca8c675c 100644
|
||||
|
||||
/* True if this program space's section offsets don't yet represent
|
||||
the final offsets of the "live" address space (that is, the
|
||||
@@ -379,28 +415,6 @@ struct program_space
|
||||
@@ -383,28 +419,6 @@ struct program_space
|
||||
target_section_table m_target_sections;
|
||||
};
|
||||
|
||||
@ -517,7 +508,7 @@ index 85215f0e2f1..07cca8c675c 100644
|
||||
/* The list of all program spaces. There's always at least one. */
|
||||
extern std::vector<struct program_space *>program_spaces;
|
||||
|
||||
@@ -443,7 +457,7 @@ class scoped_restore_current_program_space
|
||||
@@ -447,7 +461,7 @@ class scoped_restore_current_program_space
|
||||
/* Maybe create a new address space object, and add it to the list, or
|
||||
return a pointer to an existing address space, in case inferiors
|
||||
share an address space. */
|
||||
@ -527,10 +518,10 @@ index 85215f0e2f1..07cca8c675c 100644
|
||||
/* Update all program spaces matching to address spaces. The user may
|
||||
have created several program spaces, and loaded executables into
|
||||
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
|
||||
index 0daba893813..276cdcc03b8 100644
|
||||
index 97447d3e8f8..a4d6c1b5bf2 100644
|
||||
--- a/gdb/record-btrace.c
|
||||
+++ b/gdb/record-btrace.c
|
||||
@@ -2314,7 +2314,7 @@ record_btrace_replay_at_breakpoint (struct thread_info *tp)
|
||||
@@ -2321,7 +2321,7 @@ record_btrace_replay_at_breakpoint (struct thread_info *tp)
|
||||
if (insn == NULL)
|
||||
return 0;
|
||||
|
||||
@ -540,17 +531,17 @@ index 0daba893813..276cdcc03b8 100644
|
||||
}
|
||||
|
||||
diff --git a/gdb/regcache.c b/gdb/regcache.c
|
||||
index 56b6d047874..8a0b57e67b8 100644
|
||||
index 91b20b7a2a2..a78fe0a80e7 100644
|
||||
--- a/gdb/regcache.c
|
||||
+++ b/gdb/regcache.c
|
||||
@@ -1617,7 +1617,7 @@ get_thread_arch_aspace_regcache_and_check (process_stratum_target *target,
|
||||
@@ -1628,7 +1628,7 @@ get_thread_arch_aspace_regcache_and_check (inferior *inf_for_target_calls,
|
||||
the current inferior's gdbarch. Also use the current inferior's address
|
||||
space. */
|
||||
gdbarch *arch = current_inferior ()->gdbarch;
|
||||
- address_space *aspace = current_inferior ()->aspace;
|
||||
+ address_space *aspace = current_inferior ()->aspace.get ();
|
||||
regcache *regcache
|
||||
= get_thread_arch_aspace_regcache (target, ptid, arch, aspace);
|
||||
gdbarch *arch = inf_for_target_calls->gdbarch;
|
||||
- address_space *aspace = inf_for_target_calls->aspace;
|
||||
+ address_space *aspace = inf_for_target_calls->aspace.get ();
|
||||
regcache *regcache = get_thread_arch_aspace_regcache (inf_for_target_calls,
|
||||
ptid, arch, aspace);
|
||||
|
||||
diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h
|
||||
index 9ad7ebf5f0c..5f25dc7ed6b 100644
|
||||
@ -639,7 +630,7 @@ index d8fdb950043..294fd873df1 100644
|
||||
+
|
||||
#endif /* COMMON_REFCOUNTED_OBJECT_H */
|
||||
|
||||
base-commit: c55a452eaf9390d5659d3205f762aa2cb84511e1
|
||||
base-commit: 0bb6f49bb9ad577667075550ca2ad4cb49931078
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 1cd845ab3d405412aabf9b959aa527dd60143826 Mon Sep 17 00:00:00 2001
|
||||
From 3490f51a80a10d46dc1885ba672d9390a8221170 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 2 Nov 2023 14:51:02 +0100
|
||||
Subject: [PATCH] [gdb] Fix segfault in for_each_block, part 2
|
||||
Subject: [PATCH] Fix segfault in for_each_block, part 2
|
||||
|
||||
The previous commit describes PR gdb/30547, a segfault when running test-case
|
||||
gdb.base/vfork-follow-parent.exp on powerpc64 (likewise on s390x).
|
||||
@ -81,10 +81,10 @@ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547
|
||||
4 files changed, 19 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/gdb/infrun.c b/gdb/infrun.c
|
||||
index 9c1b1f04e4d..c078098a6f8 100644
|
||||
index 3854c66bf6c..d259e81df84 100644
|
||||
--- a/gdb/infrun.c
|
||||
+++ b/gdb/infrun.c
|
||||
@@ -1014,13 +1014,19 @@ handle_vfork_child_exec_or_exit (int exec)
|
||||
@@ -1105,13 +1105,19 @@ handle_vfork_child_exec_or_exit (int exec)
|
||||
go ahead and create a new one for this exiting
|
||||
inferior. */
|
||||
|
||||
@ -98,14 +98,14 @@ index 9c1b1f04e4d..c078098a6f8 100644
|
||||
+ /* Temporarily switch to the vfork parent, to facilitate ptrace
|
||||
+ calls done during maybe_new_address_space. */
|
||||
+ switch_to_thread (any_live_thread_of_inferior (vfork_parent));
|
||||
+ address_space *aspace = maybe_new_address_space ();
|
||||
+ address_space_ref_ptr aspace = maybe_new_address_space ();
|
||||
+
|
||||
+ /* Switch back to the vfork child inferior. Switch to no-thread
|
||||
+ while running clone_program_space, so that clone_program_space
|
||||
+ doesn't want to read the selected frame of a dead process. */
|
||||
+ switch_to_inferior_no_thread (inf);
|
||||
+
|
||||
+ inf->pspace = new program_space (aspace);
|
||||
+ inf->pspace = new program_space (std::move (aspace));
|
||||
inf->aspace = inf->pspace->aspace;
|
||||
set_current_program_space (inf->pspace);
|
||||
inf->removable = true;
|
||||
@ -123,10 +123,10 @@ index 0957d1b58a7..74549754806 100644
|
||||
|
||||
/* Check for 64-bit inferior process. This is the case when the host is
|
||||
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
|
||||
index d8a8fbdf706..500fb566bc1 100644
|
||||
index d14aba694e5..817505ea73e 100644
|
||||
--- a/gdb/ppc-linux-nat.c
|
||||
+++ b/gdb/ppc-linux-nat.c
|
||||
@@ -1918,6 +1918,8 @@ ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr,
|
||||
@@ -1914,6 +1914,8 @@ ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep,
|
||||
CORE_ADDR *valp)
|
||||
{
|
||||
@ -136,7 +136,7 @@ index d8a8fbdf706..500fb566bc1 100644
|
||||
if (tid == 0)
|
||||
tid = inferior_ptid.pid ();
|
||||
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
|
||||
index fc3917d30be..403f37d690d 100644
|
||||
index 8f54e9f6322..54167f49480 100644
|
||||
--- a/gdb/s390-linux-nat.c
|
||||
+++ b/gdb/s390-linux-nat.c
|
||||
@@ -949,10 +949,12 @@ s390_target_wordsize (void)
|
||||
@ -162,7 +162,7 @@ index fc3917d30be..403f37d690d 100644
|
||||
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
|
||||
const gdb_byte *ptr = *readptr;
|
||||
|
||||
base-commit: 59053f06bd94be51efacfa80f9a1f738e3e1ee9c
|
||||
base-commit: 1d02ba0f4adcba2595a67e88fb1ba6d35c7f8e5b
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
42
gdb-ftbs-swapped-calloc-args.patch
Normal file
42
gdb-ftbs-swapped-calloc-args.patch
Normal file
@ -0,0 +1,42 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Buettner <kevinb@redhat.com>
|
||||
Date: Wed, 17 Jan 2024 12:53:53 -0700
|
||||
Subject: gdb-ftbs-swapped-calloc-args.patch
|
||||
|
||||
Backport upstream commit 54195469c18ec9873cc5ba6907f768509473fa9b
|
||||
which fixes a build problem in which arguments to calloc were swapped.
|
||||
|
||||
[opcodes] ARC + PPC: Fix -Walloc-size warnings
|
||||
|
||||
Recently, -Walloc-size warnings started to kick in. Fix these two
|
||||
calloc() calls to match the intended usage pattern.
|
||||
|
||||
opcodes/ChangeLog:
|
||||
|
||||
* arc-dis.c (init_arc_disasm_info): Fix calloc() call.
|
||||
* ppc-dis.c (powerpc_init_dialect): Ditto.
|
||||
|
||||
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
|
||||
--- a/opcodes/arc-dis.c
|
||||
+++ b/opcodes/arc-dis.c
|
||||
@@ -147,7 +147,7 @@ static bool
|
||||
init_arc_disasm_info (struct disassemble_info *info)
|
||||
{
|
||||
struct arc_disassemble_info *arc_infop
|
||||
- = calloc (sizeof (*arc_infop), 1);
|
||||
+ = calloc (1, sizeof (*arc_infop));
|
||||
|
||||
if (arc_infop == NULL)
|
||||
return false;
|
||||
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
|
||||
--- a/opcodes/ppc-dis.c
|
||||
+++ b/opcodes/ppc-dis.c
|
||||
@@ -348,7 +348,7 @@ powerpc_init_dialect (struct disassemble_info *info)
|
||||
{
|
||||
ppc_cpu_t dialect = 0;
|
||||
ppc_cpu_t sticky = 0;
|
||||
- struct dis_private *priv = calloc (sizeof (*priv), 1);
|
||||
+ struct dis_private *priv = calloc (1, sizeof (*priv));
|
||||
|
||||
if (priv == NULL)
|
||||
return;
|
@ -1,138 +0,0 @@
|
||||
From 6c9e159dbd1a35aafa134fcd52982174236a8dd9 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 5 Oct 2023 23:22:11 +0200
|
||||
Subject: [PATCH 3/3] [gdb/go] Handle v3 go_0 mangled prefix
|
||||
|
||||
With gcc-10 we have:
|
||||
...
|
||||
(gdb) break package2.Foo^M
|
||||
Breakpoint 2 at 0x402563: file package2.go, line 5.^M
|
||||
(gdb) PASS: gdb.go/package.exp: setting breakpoint 1
|
||||
...
|
||||
but with gcc-11:
|
||||
...
|
||||
gdb) break package2.Foo^M
|
||||
Function "package2.Foo" not defined.^M
|
||||
Make breakpoint pending on future shared library load? (y or [n]) n^M
|
||||
(gdb) FAIL: gdb.go/package.exp: gdb_breakpoint: set breakpoint at package2.Foo
|
||||
...
|
||||
|
||||
In the gcc-10 case, though the exec contains dwarf, it's not used to set the
|
||||
breakpoint (which is an independent problem, filed as PR go/30941), instead
|
||||
the minimal symbol information is used.
|
||||
|
||||
The minimal symbol information changed between gcc-10 and gcc-11:
|
||||
...
|
||||
$ nm a.out.10 | grep Foo
|
||||
000000000040370d T go.package2.Foo
|
||||
0000000000404e50 R go.package2.Foo..f
|
||||
$ nm a.out.11 | grep Foo
|
||||
0000000000403857 T go_0package2.Foo
|
||||
0000000000405030 R go_0package2.Foo..f
|
||||
...
|
||||
|
||||
A new v3 mangling scheme was used. The mangling schemes define a separator
|
||||
character and mangling character:
|
||||
- for v2, dot is used both as separator character and mangling character, and
|
||||
- for v3, dot is used as separator character and underscore as mangling
|
||||
character.
|
||||
|
||||
For more details, see [1] and [2].
|
||||
|
||||
In v3, "_0" demangles to ".". [ See gcc commit a01dda3c23b ("compiler, libgo:
|
||||
change mangling scheme"), function Special_char_code::Special_char_code. ]
|
||||
|
||||
Handle the new go_0 prefix in unpack_mangled_go_symbol, which fixes the
|
||||
test-case.
|
||||
|
||||
Note that this doesn't fix this regression:
|
||||
...
|
||||
$ gccgo-10 package2.go -c -g0
|
||||
$ gccgo-10 package1.go package2.o -g0
|
||||
$ gdb -q -batch a.out -ex "break go.package2.Foo"
|
||||
Breakpoint 1 at 0x40370d
|
||||
$ gccgo-11 package2.go -c -g0
|
||||
$ gccgo-11 package1.go package2.o -g0
|
||||
$ gdb -q -batch a.out -ex "break go.package2.Foo"
|
||||
Function "go.package2.Foo" not defined.
|
||||
...
|
||||
|
||||
With gcc-10, we set a breakpoint on the mangled minimal symbol. That
|
||||
one has simply changed for gcc-11, so it's equivalent to using:
|
||||
...
|
||||
$ gdb -q -batch a.out -ex "break go_0package2.Foo"
|
||||
Breakpoint 1 at 0x403857
|
||||
...
|
||||
which does work.
|
||||
|
||||
Tested on x86_64-linux:
|
||||
- openSUSE Leap 15.4, using gccgo-7,
|
||||
- openSUSE Tumbleweed, using gccgo-13.
|
||||
|
||||
PR go/27238
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27238
|
||||
|
||||
[1] https://go-review.googlesource.com/c/gofrontend/+/271726
|
||||
[2] https://github.com/golang/go/issues/41862#issuecomment-707244103
|
||||
---
|
||||
gdb/go-lang.c | 30 +++++++++++++++++++++++++++---
|
||||
1 file changed, 27 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
|
||||
index f9176ace71d..8a5568f56e0 100644
|
||||
--- a/gdb/go-lang.c
|
||||
+++ b/gdb/go-lang.c
|
||||
@@ -233,16 +233,28 @@ unpack_mangled_go_symbol (const char *mangled_name,
|
||||
libgo_.*: used by gccgo's runtime
|
||||
|
||||
Thus we don't support -fgo-prefix (except as used by the runtime). */
|
||||
- if (!startswith (mangled_name, "go.")
|
||||
- && !startswith (mangled_name, "libgo_"))
|
||||
+ bool v3;
|
||||
+ if (startswith (mangled_name, "go_0"))
|
||||
+ /* V3 mangling detected, see
|
||||
+ https://go-review.googlesource.com/c/gofrontend/+/271726 . */
|
||||
+ v3 = true;
|
||||
+ else if (startswith (mangled_name, "go.")
|
||||
+ || startswith (mangled_name, "libgo_"))
|
||||
+ v3 = false;
|
||||
+ else
|
||||
return NULL;
|
||||
|
||||
/* Quick check for whether a search may be fruitful. */
|
||||
/* Ignore anything with @plt, etc. in it. */
|
||||
if (strchr (mangled_name, '@') != NULL)
|
||||
return NULL;
|
||||
+
|
||||
/* It must have at least two dots. */
|
||||
- first_dot = strchr (mangled_name, '.');
|
||||
+ if (v3)
|
||||
+ first_dot = strchr (mangled_name, '0');
|
||||
+ else
|
||||
+ first_dot = strchr (mangled_name, '.');
|
||||
+
|
||||
if (first_dot == NULL)
|
||||
return NULL;
|
||||
/* Treat "foo.bar" as unmangled. It can collide with lots of other
|
||||
@@ -263,6 +275,18 @@ unpack_mangled_go_symbol (const char *mangled_name,
|
||||
gdb::unique_xmalloc_ptr<char> result = make_unique_xstrdup (mangled_name);
|
||||
buf = result.get ();
|
||||
|
||||
+ if (v3)
|
||||
+ {
|
||||
+ /* Replace "go_0" with "\0go.". */
|
||||
+ buf[0] = '\0';
|
||||
+ buf[1] = 'g';
|
||||
+ buf[2] = 'o';
|
||||
+ buf[3] = '.';
|
||||
+
|
||||
+ /* Skip the '\0'. */
|
||||
+ buf++;
|
||||
+ }
|
||||
+
|
||||
/* Search backwards looking for "N<digit(s)>". */
|
||||
p = buf + len;
|
||||
saw_digit = method_type = NULL;
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,165 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-lineno-makeup-test.patch
|
||||
|
||||
;; Testcase for "Do not make up line information" fix by Daniel Jacobowitz.
|
||||
;;=fedoratest
|
||||
|
||||
New testcase for:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=466222
|
||||
(for the first / customer recommended fix)
|
||||
and the upstream fix:
|
||||
http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html
|
||||
[rfc] Do not make up line information
|
||||
http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/lineno-makeup-func.c b/gdb/testsuite/gdb.base/lineno-makeup-func.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c
|
||||
@@ -0,0 +1,21 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2009 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/>. */
|
||||
+
|
||||
+void
|
||||
+func (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/lineno-makeup.c b/gdb/testsuite/gdb.base/lineno-makeup.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/lineno-makeup.c
|
||||
@@ -0,0 +1,35 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2009 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/>. */
|
||||
+
|
||||
+/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number
|
||||
+ information (.debug_line) so we cannot use an external object file.
|
||||
+
|
||||
+ It must not be just a label as it would alias on the next function even for
|
||||
+ correct GDB. Therefore some stub data must be placed there.
|
||||
+
|
||||
+ We need to provide a real stub function body as at least s390
|
||||
+ (s390_analyze_prologue) would skip the whole body till reaching `main'. */
|
||||
+
|
||||
+extern void func (void);
|
||||
+asm ("func: .incbin \"" BINFILENAME "\"");
|
||||
+
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+ func ();
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/lineno-makeup.exp b/gdb/testsuite/gdb.base/lineno-makeup.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/lineno-makeup.exp
|
||||
@@ -0,0 +1,78 @@
|
||||
+# Copyright 2009 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/>.
|
||||
+
|
||||
+set testfile "lineno-makeup"
|
||||
+set srcfuncfile ${testfile}-func.c
|
||||
+set srcfile ${testfile}.c
|
||||
+set objfuncfile [standard_output_file ${testfile}-func.o]
|
||||
+set binfuncfile [standard_output_file ${testfile}-func.bin]
|
||||
+set binfile [standard_output_file ${testfile}]
|
||||
+
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output]
|
||||
+verbose -log "objcopy=$objcopy: $output"
|
||||
+if { $objcopy != 0 } {
|
||||
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+set binfuncfilesize [file size $binfuncfile]
|
||||
+verbose -log "file size $binfuncfile = $binfuncfilesize"
|
||||
+
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug additional_flags=-DBINFILENAME=\"$binfuncfile\"]] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+set b_addr ""
|
||||
+set test "break func"
|
||||
+gdb_test_multiple $test $test {
|
||||
+ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
|
||||
+ set b_addr $expect_out(1,string)
|
||||
+ pass $test
|
||||
+ }
|
||||
+ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" {
|
||||
+ set b_addr $expect_out(1,string)
|
||||
+ fail $test
|
||||
+ }
|
||||
+}
|
||||
+verbose -log "b_addr=<$b_addr>"
|
||||
+
|
||||
+set p_addr ""
|
||||
+set test "print func"
|
||||
+gdb_test_multiple $test $test {
|
||||
+ -re "\\$\[0-9\]+ = {<text variable, no debug info>} (0x\[0-9a-f\]+) <func>\r\n$gdb_prompt $" {
|
||||
+ set p_addr $expect_out(1,string)
|
||||
+ pass $test
|
||||
+ }
|
||||
+}
|
||||
+verbose -log "p_addr=<$p_addr>"
|
||||
+
|
||||
+set test "break address belongs to func"
|
||||
+if {$b_addr == $p_addr} {
|
||||
+ pass "$test (exact match)"
|
||||
+} else {
|
||||
+ set skip [expr $b_addr - $p_addr]
|
||||
+ if {$skip > 0 && $skip < $binfuncfilesize} {
|
||||
+ pass "$test (prologue skip by $skip bytes)"
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+}
|
@ -9,9 +9,9 @@ Subject: gdb-linux_perf-bundle.patch
|
||||
diff --git a/gdb/gdb.c b/gdb/gdb.c
|
||||
--- a/gdb/gdb.c
|
||||
+++ b/gdb/gdb.c
|
||||
@@ -20,11 +20,19 @@
|
||||
#include "main.h"
|
||||
@@ -21,6 +21,10 @@
|
||||
#include "interps.h"
|
||||
#include "run-on-main-thread.h"
|
||||
|
||||
+#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
|
||||
+extern "C" void __libipt_init(void);
|
||||
@ -20,6 +20,8 @@ diff --git a/gdb/gdb.c b/gdb/gdb.c
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -32,6 +36,10 @@ main (int argc, char **argv)
|
||||
|
||||
struct captured_main_args args;
|
||||
|
||||
+#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
|
||||
@ -32,7 +34,7 @@ diff --git a/gdb/gdb.c b/gdb/gdb.c
|
||||
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
|
||||
--- a/gdb/nat/linux-btrace.h
|
||||
+++ b/gdb/nat/linux-btrace.h
|
||||
@@ -27,6 +27,177 @@
|
||||
@@ -28,6 +28,177 @@
|
||||
# include <linux/perf_event.h>
|
||||
#endif
|
||||
|
||||
@ -213,7 +215,7 @@ diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
|
||||
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
|
||||
--- a/gdbsupport/common.m4
|
||||
+++ b/gdbsupport/common.m4
|
||||
@@ -166,7 +166,7 @@ AC_DEFUN([GDB_AC_COMMON], [
|
||||
@@ -168,7 +168,7 @@ AC_DEFUN([GDB_AC_COMMON], [
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <linux/perf_event.h>
|
||||
#ifndef PERF_ATTR_SIZE_VER5
|
||||
|
@ -1,62 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-opcodes-clflushopt-test.patch
|
||||
|
||||
;; Test clflushopt instruction decode (for RH BZ 1262471).
|
||||
;;=fedoratest
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.arch/amd64-clflushopt.S b/gdb/testsuite/gdb.arch/amd64-clflushopt.S
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.arch/amd64-clflushopt.S
|
||||
@@ -0,0 +1,19 @@
|
||||
+/* Copyright 2016 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/>.
|
||||
+
|
||||
+ This file is part of the gdb testsuite. */
|
||||
+
|
||||
+_start: .globl _start
|
||||
+ clflushopt (%edi)
|
||||
diff --git a/gdb/testsuite/gdb.arch/amd64-clflushopt.exp b/gdb/testsuite/gdb.arch/amd64-clflushopt.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.arch/amd64-clflushopt.exp
|
||||
@@ -0,0 +1,25 @@
|
||||
+# Copyright 2016 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/>.
|
||||
+
|
||||
+if { ![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"] } then {
|
||||
+ verbose "Skipping amd64 clflushopt test."
|
||||
+ return
|
||||
+}
|
||||
+
|
||||
+if [prepare_for_testing amd64-clflushopt.exp amd64-clflushopt amd64-clflushopt.S [list debug "additional_flags=-nostdlib"]] {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test "disas _start" "Dump of assembler code for function _start:\r\n *0x\[0-9a-f\]+ <\[+\]0>:\tclflushopt \\(%edi\\)\r\nEnd of assembler dump\\." "clflushopt"
|
@ -1,3 +1,8 @@
|
||||
From adfcabe4cc43766996a61bdf08ce1e9db7f18dcc Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 18 Apr 2024 14:27:04 +0200
|
||||
Subject: [PATCH] gdb-python-finishbreakpoint-update
|
||||
|
||||
[gdb/python] FinishBreakPoint update
|
||||
|
||||
I.
|
||||
@ -324,19 +329,18 @@ Tested on x86_64-linux with native and target board unix/-m32, by rebuilding
|
||||
and running the test-cases:
|
||||
- gdb.python/py-finish-breakpoint.exp
|
||||
- gdb.python/py-finish-breakpoint2.exp
|
||||
|
||||
---
|
||||
gdb/breakpoint.c | 10 ++++++++++
|
||||
gdb/doc/python.texi | 6 ++++--
|
||||
gdb/python/py-finishbreakpoint.c | 21 +++++++++++++++++++++
|
||||
gdb/testsuite/gdb.python/py-finish-breakpoint2.exp | 16 +++++++++++++---
|
||||
4 files changed, 48 insertions(+), 5 deletions(-)
|
||||
gdb/python/py-finishbreakpoint.c | 20 +++++++++++++++++++
|
||||
.../gdb.python/py-finish-breakpoint2.exp | 1 +
|
||||
4 files changed, 35 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
|
||||
index dbbea6b8bff..64a9a3d394f 100644
|
||||
index db7d2e6a8e5..01f187ca4fe 100644
|
||||
--- a/gdb/breakpoint.c
|
||||
+++ b/gdb/breakpoint.c
|
||||
@@ -15452,6 +15452,10 @@ initialize_breakpoint_ops (void)
|
||||
@@ -14683,6 +14683,10 @@ breakpoint_free_objfile (struct objfile *objfile)
|
||||
|
||||
static struct cmd_list_element *enablebreaklist = NULL;
|
||||
|
||||
@ -347,7 +351,7 @@ index dbbea6b8bff..64a9a3d394f 100644
|
||||
/* See breakpoint.h. */
|
||||
|
||||
cmd_list_element *commands_cmd_element = nullptr;
|
||||
@@ -16065,6 +16069,12 @@ This is useful for formatted output in user-defined commands."));
|
||||
@@ -15243,8 +15247,14 @@ This is useful for formatted output in user-defined commands."));
|
||||
|
||||
gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed,
|
||||
"breakpoint");
|
||||
@ -359,12 +363,14 @@ index dbbea6b8bff..64a9a3d394f 100644
|
||||
gdb::observers::thread_exit.attach (remove_threaded_breakpoints,
|
||||
"breakpoint");
|
||||
+#endif
|
||||
gdb::observers::inferior_removed.attach (remove_inferior_breakpoints,
|
||||
"breakpoint");
|
||||
}
|
||||
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
|
||||
index f4865b3d6a6..17a67800ba2 100644
|
||||
index 99670cca025..ba414b4e2c3 100644
|
||||
--- a/gdb/doc/python.texi
|
||||
+++ b/gdb/doc/python.texi
|
||||
@@ -5698,7 +5698,7 @@ attribute is @code{None}. This attribute is writable.
|
||||
@@ -6648,7 +6648,7 @@ is not writable.
|
||||
@tindex gdb.FinishBreakpoint
|
||||
|
||||
A finish breakpoint is a temporary breakpoint set at the return address of
|
||||
@ -373,7 +379,7 @@ index f4865b3d6a6..17a67800ba2 100644
|
||||
extends @code{gdb.Breakpoint}. The underlying breakpoint will be disabled
|
||||
and deleted when the execution will run out of the breakpoint scope (i.e.@:
|
||||
@code{Breakpoint.stop} or @code{FinishBreakpoint.out_of_scope} triggered).
|
||||
@@ -5717,7 +5717,9 @@ details about this argument.
|
||||
@@ -6667,7 +6667,9 @@ details about this argument.
|
||||
In some circumstances (e.g.@: @code{longjmp}, C@t{++} exceptions, @value{GDBN}
|
||||
@code{return} command, @dots{}), a function may not properly terminate, and
|
||||
thus never hit the finish breakpoint. When @value{GDBN} notices such a
|
||||
@ -385,25 +391,25 @@ index f4865b3d6a6..17a67800ba2 100644
|
||||
You may want to sub-class @code{gdb.FinishBreakpoint} and override this
|
||||
method:
|
||||
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
|
||||
index 1d8373d807e..a881103fdad 100644
|
||||
index 42a7e0706d2..fa7ec43fbb4 100644
|
||||
--- a/gdb/python/py-finishbreakpoint.c
|
||||
+++ b/gdb/python/py-finishbreakpoint.c
|
||||
@@ -398,6 +398,24 @@ bpfinishpy_handle_exit (struct inferior *inf)
|
||||
bpfinishpy_detect_out_scope_cb (bp, nullptr);
|
||||
@@ -433,6 +433,24 @@ bpfinishpy_handle_exit (struct inferior *inf)
|
||||
bpfinishpy_detect_out_scope_cb (&bp, nullptr, true);
|
||||
}
|
||||
|
||||
+/* Attached to `thread_exit' notifications, triggers all the necessary out of
|
||||
+ scope notifications. */
|
||||
+
|
||||
+static void
|
||||
+bpfinishpy_handle_thread_exit (struct thread_info *tp, int ignore)
|
||||
+bpfinishpy_handle_thread_exit (struct thread_info *tp, gdb::optional<ULONGEST>, bool)
|
||||
+{
|
||||
+ gdbpy_enter enter_py (target_gdbarch (), current_language);
|
||||
+
|
||||
+ for (breakpoint *bp : all_breakpoints_safe ())
|
||||
+ for (breakpoint &bp : all_breakpoints_safe ())
|
||||
+ {
|
||||
+ if (tp->global_num == bp->thread)
|
||||
+ bpfinishpy_detect_out_scope_cb (bp, nullptr);
|
||||
+ if (tp->global_num == bp.thread)
|
||||
+ bpfinishpy_detect_out_scope_cb (&bp, nullptr, true);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
@ -412,42 +418,30 @@ index 1d8373d807e..a881103fdad 100644
|
||||
+
|
||||
/* Initialize the Python finish breakpoint code. */
|
||||
|
||||
int
|
||||
@@ -414,6 +432,9 @@ gdbpy_initialize_finishbreakpoints (void)
|
||||
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
|
||||
@@ -452,6 +470,8 @@ gdbpy_initialize_finishbreakpoints (void)
|
||||
"py-finishbreakpoint");
|
||||
gdb::observers::inferior_exit.attach (bpfinishpy_handle_exit,
|
||||
"py-finishbreakpoint");
|
||||
+ gdb::observers::thread_exit.attach
|
||||
+ (bpfinishpy_handle_thread_exit,
|
||||
+ bpfinishpy_handle_thread_exit_observer_token, "py-finishbreakpoint");
|
||||
+ (bpfinishpy_handle_thread_exit, "py-finishbreakpoint");
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
|
||||
index 58e086ad3b4..46c39d0d108 100644
|
||||
index 66587b8b9a0..31479a05e6f 100644
|
||||
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
|
||||
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
|
||||
@@ -50,10 +50,20 @@ gdb_test "continue" "Breakpoint .*throw_exception_1.*" "run to exception 1"
|
||||
gdb_test "python print (len(gdb.breakpoints()))" "3" "check BP count"
|
||||
gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \
|
||||
"init ExceptionFinishBreakpoint" "set FinishBP after the exception"
|
||||
-gdb_test "continue" ".*stopped at ExceptionFinishBreakpoint.*" "check FinishBreakpoint in catch()"
|
||||
-gdb_test "python print (len(gdb.breakpoints()))" "3" "check finish BP removal"
|
||||
|
||||
-gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" "continue to second exception"
|
||||
+gdb_test_multiple "continue" "continue after setting FinishBreakpoint" {
|
||||
+ -re -wrap ".*stopped at ExceptionFinishBreakpoint.*" {
|
||||
+ pass "$gdb_test_name (scenario 1, triggered)"
|
||||
+ gdb_test "python print (len(gdb.breakpoints()))" "3" \
|
||||
+ "check finish BP removal"
|
||||
+ gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" \
|
||||
+ "continue to second exception"
|
||||
+ }
|
||||
+ -re -wrap ".*Breakpoint.* throw_exception_1.*" {
|
||||
+ pass "$gdb_test_name (scenario 2, not triggered)"
|
||||
+ }
|
||||
+}
|
||||
@@ -87,6 +87,7 @@ if { $need_continue } {
|
||||
gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" \
|
||||
"continue to second exception"
|
||||
}
|
||||
+
|
||||
gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \
|
||||
"init ExceptionFinishBreakpoint" "set FinishBP after the exception again"
|
||||
gdb_test "continue" ".*exception did not finish.*" "FinishBreakpoint with exception thrown not caught"
|
||||
|
||||
|
||||
base-commit: 6de9111c512de99fd8cb3ea89f9890b1d72f6ef0
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
125
gdb-python-fix-gdb.python-py-disasm.exp-on-arm-linux.patch
Normal file
125
gdb-python-fix-gdb.python-py-disasm.exp-on-arm-linux.patch
Normal file
@ -0,0 +1,125 @@
|
||||
From 4c7dab250c3581e691c2da87395e80244074d8bf Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Mon, 10 Jun 2024 17:53:30 +0200
|
||||
Subject: [PATCH] [gdb/python] Fix gdb.python/py-disasm.exp on arm-linux
|
||||
|
||||
After fixing test-case gdb.python/py-disasm.exp to recognize the arm nop:
|
||||
...
|
||||
nop {0}
|
||||
...
|
||||
we run into:
|
||||
...
|
||||
disassemble test^M
|
||||
Dump of assembler code for function test:^M
|
||||
0x004004d8 <+0>: push {r11} @ (str r11, [sp, #-4]!)^M
|
||||
0x004004dc <+4>: add r11, sp, #0^M
|
||||
0x004004e0 <+8>: nop {0}^M
|
||||
=> 0x004004e4 <+12>: Python Exception <class 'ValueError'>: Buffer \
|
||||
returned from read_memory is sized 0 instead of the expected 4^M
|
||||
^M
|
||||
unknown disassembler error (error = -1)^M
|
||||
(gdb) FAIL: $exp: global_disassembler=ShowInfoRepr: disassemble test
|
||||
...
|
||||
|
||||
This is caused by this code in gdbpy_disassembler::read_memory_func:
|
||||
...
|
||||
gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
|
||||
"read_memory",
|
||||
"KL", len, offset));
|
||||
...
|
||||
where len has type "unsigned int", while "K" means "unsigned long long" [1].
|
||||
|
||||
Fix this by using "I" instead, meaning "unsigned int".
|
||||
|
||||
Also, offset has type LONGEST, which is typedef'ed to int64_t, while "L" means
|
||||
"long long".
|
||||
|
||||
Fix this by using type gdb_py_longest for offset, in combination with format
|
||||
character "GDB_PY_LL_ARG". Likewise in disasmpy_info_read_memory.
|
||||
|
||||
Tested on arm-linux.
|
||||
|
||||
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
PR python/31845
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31845
|
||||
|
||||
[1] https://docs.python.org/3/c-api/arg.html
|
||||
|
||||
(cherry picked from commit 4cd214dce4579f86a85a96c882e0fc8c4d94601c)
|
||||
---
|
||||
gdb/python/py-disasm.c | 12 +++++++-----
|
||||
gdb/testsuite/gdb.python/py-disasm.exp | 2 +-
|
||||
gdb/testsuite/gdb.python/py-disasm.py | 2 +-
|
||||
3 files changed, 9 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
|
||||
index 6f0fed137e6..b2e95b3cba6 100644
|
||||
--- a/gdb/python/py-disasm.c
|
||||
+++ b/gdb/python/py-disasm.c
|
||||
@@ -668,12 +668,13 @@ disasmpy_info_read_memory (PyObject *self, PyObject *args, PyObject *kw)
|
||||
disasm_info_object *obj = (disasm_info_object *) self;
|
||||
DISASMPY_DISASM_INFO_REQUIRE_VALID (obj);
|
||||
|
||||
- LONGEST length, offset = 0;
|
||||
+ gdb_py_longest length, offset = 0;
|
||||
gdb::unique_xmalloc_ptr<gdb_byte> buffer;
|
||||
static const char *keywords[] = { "length", "offset", nullptr };
|
||||
|
||||
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "L|L", keywords,
|
||||
- &length, &offset))
|
||||
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw,
|
||||
+ GDB_PY_LL_ARG "|" GDB_PY_LL_ARG,
|
||||
+ keywords, &length, &offset))
|
||||
return nullptr;
|
||||
|
||||
/* The apparent address from which we are reading memory. Note that in
|
||||
@@ -850,13 +851,14 @@ gdbpy_disassembler::read_memory_func (bfd_vma memaddr, gdb_byte *buff,
|
||||
/* The DisassembleInfo.read_memory method expects an offset from the
|
||||
address stored within the DisassembleInfo object; calculate that
|
||||
offset here. */
|
||||
- LONGEST offset = (LONGEST) memaddr - (LONGEST) obj->address;
|
||||
+ gdb_py_longest offset
|
||||
+ = (gdb_py_longest) memaddr - (gdb_py_longest) obj->address;
|
||||
|
||||
/* Now call the DisassembleInfo.read_memory method. This might have been
|
||||
overridden by the user. */
|
||||
gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
|
||||
"read_memory",
|
||||
- "KL", len, offset));
|
||||
+ "I" GDB_PY_LL_ARG, len, offset));
|
||||
|
||||
/* Handle any exceptions. */
|
||||
if (result_obj == nullptr)
|
||||
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp
|
||||
index f2f9225168a..9d0f6ec1d01 100644
|
||||
--- a/gdb/testsuite/gdb.python/py-disasm.exp
|
||||
+++ b/gdb/testsuite/gdb.python/py-disasm.exp
|
||||
@@ -65,7 +65,7 @@ proc py_remove_all_disassemblers {} {
|
||||
#
|
||||
# Each different disassembler tests some different feature of the
|
||||
# Python disassembler API.
|
||||
-set nop "(nop|nop\t0)"
|
||||
+set nop "(nop|nop\t0|[string_to_regexp nop\t{0}])"
|
||||
set unknown_error_pattern "unknown disassembler error \\(error = -1\\)"
|
||||
set addr_pattern "\r\n=> ${curr_pc_pattern} <\[^>\]+>:\\s+"
|
||||
set base_pattern "${addr_pattern}${nop}"
|
||||
diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py
|
||||
index 67ba6756ea9..6a39b0764e6 100644
|
||||
--- a/gdb/testsuite/gdb.python/py-disasm.py
|
||||
+++ b/gdb/testsuite/gdb.python/py-disasm.py
|
||||
@@ -46,7 +46,7 @@ def check_building_disassemble_result():
|
||||
|
||||
|
||||
def is_nop(s):
|
||||
- return s == "nop" or s == "nop\t0"
|
||||
+ return s == "nop" or s == "nop\t0" or s == "nop\t{0}"
|
||||
|
||||
|
||||
# Remove all currently registered disassemblers.
|
||||
|
||||
base-commit: 22383ac8031b0e626e8ecd62e4378266065d067c
|
||||
--
|
||||
2.35.3
|
||||
|
@ -0,0 +1,70 @@
|
||||
From fc73000faa1798573090994167b7e2d451c211db Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 10 May 2024 08:46:21 +0200
|
||||
Subject: [PATCH] [gdb/python] Make gdb.UnwindInfo.add_saved_register more
|
||||
robust (fixup)
|
||||
|
||||
In commit 2236c5e384d ("[gdb/python] Make gdb.UnwindInfo.add_saved_register
|
||||
more robust") I added this code in unwind_infopy_add_saved_register:
|
||||
...
|
||||
if (value->optimized_out () || !value->entirely_available ())
|
||||
...
|
||||
which may throw c++ exceptions.
|
||||
|
||||
This needs to be caught and transformed into a python exception.
|
||||
|
||||
Fix this by using GDB_PY_HANDLE_EXCEPTION.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
Fixes: 2236c5e384d ("[gdb/python] Make gdb.UnwindInfo.add_saved_register more robust")
|
||||
(cherry picked from commit 408bc9c5fc757bd4b8adb1c3d54ecd672beaedb7)
|
||||
---
|
||||
gdb/python/py-unwind.c | 26 +++++++++++++++++---------
|
||||
1 file changed, 17 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
|
||||
index 471eb851674..e57c8c1adcf 100644
|
||||
--- a/gdb/python/py-unwind.c
|
||||
+++ b/gdb/python/py-unwind.c
|
||||
@@ -354,16 +354,24 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args, PyObject *kw)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
- if (value->optimized_out () || !value->entirely_available ())
|
||||
+
|
||||
+ try
|
||||
+ {
|
||||
+ if (value->optimized_out () || !value->entirely_available ())
|
||||
+ {
|
||||
+ /* If we allow this value to be registered here, pyuw_sniffer is going
|
||||
+ to run into an exception when trying to access its contents.
|
||||
+ Throwing an exception here just puts a burden on the user to
|
||||
+ implement the same checks on the user side. We could return False
|
||||
+ here and True otherwise, but again that might require changes in
|
||||
+ user code. So, handle this with minimal impact for the user, while
|
||||
+ improving robustness: silently ignore the register/value pair. */
|
||||
+ Py_RETURN_NONE;
|
||||
+ }
|
||||
+ }
|
||||
+ catch (const gdb_exception &except)
|
||||
{
|
||||
- /* If we allow this value to be registered here, pyuw_sniffer is going
|
||||
- to run into an exception when trying to access its contents.
|
||||
- Throwing an exception here just puts a burden on the user to
|
||||
- implement the same checks on the user side. We could return False
|
||||
- here and True otherwise, but again that might require changes in user
|
||||
- code. So, handle this with minimal impact for the user, while
|
||||
- improving robustness: silently ignore the register/value pair. */
|
||||
- Py_RETURN_NONE;
|
||||
+ GDB_PY_HANDLE_EXCEPTION (except);
|
||||
}
|
||||
|
||||
gdbpy_ref<> new_value = gdbpy_ref<>::new_reference (pyo_reg_value);
|
||||
|
||||
base-commit: a6f598be3d0477c5c59bd490573a5d457949658e
|
||||
--
|
||||
2.35.3
|
||||
|
61
gdb-python-make-gdb.unwindinfo.add_saved_register-mo.patch
Normal file
61
gdb-python-make-gdb.unwindinfo.add_saved_register-mo.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From eafca1ce3d589c731927e5481199db715bcbeff3 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Sat, 2 Mar 2024 09:35:22 +0100
|
||||
Subject: [PATCH 2/2] [gdb/python] Make gdb.UnwindInfo.add_saved_register more
|
||||
robust
|
||||
|
||||
On arm-linux, until commit bbb12eb9c84 ("gdb/arm: Remove tpidruro register
|
||||
from non-FreeBSD target descriptions") I ran into:
|
||||
...
|
||||
FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: \
|
||||
backtrace when the unwind is broken at frame 5
|
||||
...
|
||||
|
||||
What happens is the following:
|
||||
- the TestUnwinder from inline-frame-cycle-unwind.py calls
|
||||
gdb.UnwindInfo.add_saved_register with reg == tpidruro and value
|
||||
"<unavailable>",
|
||||
- pyuw_sniffer calls value->contents ().data () to access the value of the
|
||||
register, which throws an UNAVAILABLE_ERROR,
|
||||
- this causes the TestUnwinder unwinder to fail, after which another unwinder
|
||||
succeeds and returns the correct frame, and
|
||||
- the test-case fails because it's counting on the TestUnwinder to succeed and
|
||||
return an incorrect frame.
|
||||
|
||||
Fix this by checking for !value::entirely_available as well as
|
||||
valued::optimized_out in unwind_infopy_add_saved_register.
|
||||
|
||||
Tested on x86_64-linux and arm-linux.
|
||||
|
||||
PR python/31437
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31437
|
||||
---
|
||||
gdb/python/py-unwind.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
|
||||
index 1856e41e2a1..471eb851674 100644
|
||||
--- a/gdb/python/py-unwind.c
|
||||
+++ b/gdb/python/py-unwind.c
|
||||
@@ -354,6 +354,18 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args, PyObject *kw)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+ if (value->optimized_out () || !value->entirely_available ())
|
||||
+ {
|
||||
+ /* If we allow this value to be registered here, pyuw_sniffer is going
|
||||
+ to run into an exception when trying to access its contents.
|
||||
+ Throwing an exception here just puts a burden on the user to
|
||||
+ implement the same checks on the user side. We could return False
|
||||
+ here and True otherwise, but again that might require changes in user
|
||||
+ code. So, handle this with minimal impact for the user, while
|
||||
+ improving robustness: silently ignore the register/value pair. */
|
||||
+ Py_RETURN_NONE;
|
||||
+ }
|
||||
+
|
||||
gdbpy_ref<> new_value = gdbpy_ref<>::new_reference (pyo_reg_value);
|
||||
bool found = false;
|
||||
for (saved_reg ® : *unwind_info->saved_regs)
|
||||
--
|
||||
2.35.3
|
||||
|
229
gdb-remote-fix-abort-on-remote_close_error.patch
Normal file
229
gdb-remote-fix-abort-on-remote_close_error.patch
Normal file
@ -0,0 +1,229 @@
|
||||
From 0ad71e3088f345101085a1f72e81a000a100db18 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Sat, 27 Apr 2024 17:48:22 +0200
|
||||
Subject: [PATCH 25/48] [gdb/remote] Fix abort on REMOTE_CLOSE_ERROR
|
||||
|
||||
When running test-case gdb.server/connect-with-no-symbol-file.exp on
|
||||
aarch64-linux (specifically, an opensuse leap 15.5 container on a
|
||||
fedora asahi 39 system), I run into:
|
||||
...
|
||||
(gdb) detach^M
|
||||
Detaching from program: target:connect-with-no-symbol-file, process 185104^M
|
||||
Ending remote debugging.^M
|
||||
terminate called after throwing an instance of 'gdb_exception_error'^M
|
||||
...
|
||||
|
||||
The detailed backtrace of the corefile is:
|
||||
...
|
||||
(gdb) bt
|
||||
#0 0x0000ffff75504f54 in raise () from /lib64/libpthread.so.0
|
||||
#1 0x00000000007a86b4 in handle_fatal_signal (sig=6)
|
||||
at gdb/event-top.c:926
|
||||
#2 <signal handler called>
|
||||
#3 0x0000ffff74b977b4 in raise () from /lib64/libc.so.6
|
||||
#4 0x0000ffff74b98c18 in abort () from /lib64/libc.so.6
|
||||
#5 0x0000ffff74ea26f4 in __gnu_cxx::__verbose_terminate_handler() ()
|
||||
from /usr/lib64/libstdc++.so.6
|
||||
#6 0x0000ffff74ea011c in ?? () from /usr/lib64/libstdc++.so.6
|
||||
#7 0x0000ffff74ea0180 in std::terminate() () from /usr/lib64/libstdc++.so.6
|
||||
#8 0x0000ffff74ea0464 in __cxa_throw () from /usr/lib64/libstdc++.so.6
|
||||
#9 0x0000000001548870 in throw_it (reason=RETURN_ERROR,
|
||||
error=TARGET_CLOSE_ERROR, fmt=0x16c7810 "Remote connection closed", ap=...)
|
||||
at gdbsupport/common-exceptions.cc:203
|
||||
#10 0x0000000001548920 in throw_verror (error=TARGET_CLOSE_ERROR,
|
||||
fmt=0x16c7810 "Remote connection closed", ap=...)
|
||||
at gdbsupport/common-exceptions.cc:211
|
||||
#11 0x0000000001548a00 in throw_error (error=TARGET_CLOSE_ERROR,
|
||||
fmt=0x16c7810 "Remote connection closed")
|
||||
at gdbsupport/common-exceptions.cc:226
|
||||
#12 0x0000000000ac8f2c in remote_target::readchar (this=0x233d3d90, timeout=2)
|
||||
at gdb/remote.c:9856
|
||||
#13 0x0000000000ac9f04 in remote_target::getpkt (this=0x233d3d90,
|
||||
buf=0x233d40a8, forever=false, is_notif=0x0) at gdb/remote.c:10326
|
||||
#14 0x0000000000acf3d0 in remote_target::remote_hostio_send_command
|
||||
(this=0x233d3d90, command_bytes=13, which_packet=17,
|
||||
remote_errno=0xfffff1a3cf38, attachment=0xfffff1a3ce88,
|
||||
attachment_len=0xfffff1a3ce90) at gdb/remote.c:12567
|
||||
#15 0x0000000000ad03bc in remote_target::fileio_fstat (this=0x233d3d90, fd=3,
|
||||
st=0xfffff1a3d020, remote_errno=0xfffff1a3cf38)
|
||||
at gdb/remote.c:12979
|
||||
#16 0x0000000000c39878 in target_fileio_fstat (fd=0, sb=0xfffff1a3d020,
|
||||
target_errno=0xfffff1a3cf38) at gdb/target.c:3315
|
||||
#17 0x00000000007eee5c in target_fileio_stream::stat (this=0x233d4400,
|
||||
abfd=0x2323fc40, sb=0xfffff1a3d020) at gdb/gdb_bfd.c:467
|
||||
#18 0x00000000007f012c in <lambda(bfd*, void*, stat*)>::operator()(bfd *,
|
||||
void *, stat *) const (__closure=0x0, abfd=0x2323fc40, stream=0x233d4400,
|
||||
sb=0xfffff1a3d020) at gdb/gdb_bfd.c:955
|
||||
#19 0x00000000007f015c in <lambda(bfd*, void*, stat*)>::_FUN(bfd *, void *,
|
||||
stat *) () at gdb/gdb_bfd.c:956
|
||||
#20 0x0000000000f9b838 in opncls_bstat (abfd=0x2323fc40, sb=0xfffff1a3d020)
|
||||
at bfd/opncls.c:665
|
||||
#21 0x0000000000f90adc in bfd_stat (abfd=0x2323fc40, statbuf=0xfffff1a3d020)
|
||||
at bfd/bfdio.c:431
|
||||
#22 0x000000000065fe20 in reopen_exec_file () at gdb/corefile.c:52
|
||||
#23 0x0000000000c3a3e8 in generic_mourn_inferior ()
|
||||
at gdb/target.c:3642
|
||||
#24 0x0000000000abf3f0 in remote_unpush_target (target=0x233d3d90)
|
||||
at gdb/remote.c:6067
|
||||
#25 0x0000000000aca8b0 in remote_target::mourn_inferior (this=0x233d3d90)
|
||||
at gdb/remote.c:10587
|
||||
#26 0x0000000000c387cc in target_mourn_inferior (
|
||||
ptid=<error reading variable: Cannot access memory at address 0x2d310>)
|
||||
at gdb/target.c:2738
|
||||
#27 0x0000000000abfff0 in remote_target::remote_detach_1 (this=0x233d3d90,
|
||||
inf=0x22fce540, from_tty=1) at gdb/remote.c:6421
|
||||
#28 0x0000000000ac0094 in remote_target::detach (this=0x233d3d90,
|
||||
inf=0x22fce540, from_tty=1) at gdb/remote.c:6436
|
||||
#29 0x0000000000c37c3c in target_detach (inf=0x22fce540, from_tty=1)
|
||||
at gdb/target.c:2526
|
||||
#30 0x0000000000860424 in detach_command (args=0x0, from_tty=1)
|
||||
at gdb/infcmd.c:2817
|
||||
#31 0x000000000060b594 in do_simple_func (args=0x0, from_tty=1, c=0x231431a0)
|
||||
at gdb/cli/cli-decode.c:94
|
||||
#32 0x00000000006108c8 in cmd_func (cmd=0x231431a0, args=0x0, from_tty=1)
|
||||
at gdb/cli/cli-decode.c:2741
|
||||
#33 0x0000000000c65a94 in execute_command (p=0x232e52f6 "", from_tty=1)
|
||||
at gdb/top.c:570
|
||||
#34 0x00000000007a7d2c in command_handler (command=0x232e52f0 "")
|
||||
at gdb/event-top.c:566
|
||||
#35 0x00000000007a8290 in command_line_handler (rl=...)
|
||||
at gdb/event-top.c:802
|
||||
#36 0x0000000000c9092c in tui_command_line_handler (rl=...)
|
||||
at gdb/tui/tui-interp.c:103
|
||||
#37 0x00000000007a750c in gdb_rl_callback_handler (rl=0x23385330 "detach")
|
||||
at gdb/event-top.c:258
|
||||
#38 0x0000000000d910f4 in rl_callback_read_char ()
|
||||
at readline/readline/callback.c:290
|
||||
#39 0x00000000007a7338 in gdb_rl_callback_read_char_wrapper_noexcept ()
|
||||
at gdb/event-top.c:194
|
||||
#40 0x00000000007a73f0 in gdb_rl_callback_read_char_wrapper
|
||||
(client_data=0x22fbf640) at gdb/event-top.c:233
|
||||
#41 0x0000000000cbee1c in stdin_event_handler (error=0, client_data=0x22fbf640)
|
||||
at gdb/ui.c:154
|
||||
#42 0x000000000154ed60 in handle_file_event (file_ptr=0x232be730, ready_mask=1)
|
||||
at gdbsupport/event-loop.cc:572
|
||||
#43 0x000000000154f21c in gdb_wait_for_event (block=1)
|
||||
at gdbsupport/event-loop.cc:693
|
||||
#44 0x000000000154dec4 in gdb_do_one_event (mstimeout=-1)
|
||||
at gdbsupport/event-loop.cc:263
|
||||
#45 0x0000000000910f98 in start_event_loop () at gdb/main.c:400
|
||||
#46 0x0000000000911130 in captured_command_loop () at gdb/main.c:464
|
||||
#47 0x0000000000912b5c in captured_main (data=0xfffff1a3db58)
|
||||
at gdb/main.c:1338
|
||||
#48 0x0000000000912bf4 in gdb_main (args=0xfffff1a3db58)
|
||||
at gdb/main.c:1357
|
||||
#49 0x00000000004170f4 in main (argc=10, argv=0xfffff1a3dcc8)
|
||||
at gdb/gdb.c:38
|
||||
(gdb)
|
||||
...
|
||||
|
||||
The abort happens because a c++ exception escapes to c code, specifically
|
||||
opncls_bstat in bfd/opncls.c. Compiling with -fexceptions works around this.
|
||||
|
||||
Fix this by catching the exception just before it escapes, in stat_trampoline
|
||||
and likewise in few similar spot.
|
||||
|
||||
Add a new template catch_exceptions to do so in a consistent way.
|
||||
|
||||
Tested on aarch64-linux.
|
||||
|
||||
Approved-by: Pedro Alves <pedro@palves.net>
|
||||
|
||||
PR remote/31577
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31577
|
||||
---
|
||||
gdb/gdb_bfd.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
1 file changed, 56 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
|
||||
index 217753cf914..3c34cc5693f 100644
|
||||
--- a/gdb/gdb_bfd.c
|
||||
+++ b/gdb/gdb_bfd.c
|
||||
@@ -887,6 +887,29 @@ gdb_bfd_openw (const char *filename, const char *target)
|
||||
return gdb_bfd_ref_ptr::new_reference (result);
|
||||
}
|
||||
|
||||
+/* Wrap f (args) and handle exceptions by:
|
||||
+ - returning val, and
|
||||
+ - calling set_quit_flag or set_force_quit_flag, if needed. */
|
||||
+
|
||||
+template <typename R, R val, typename F, typename... Args>
|
||||
+static R
|
||||
+catch_exceptions (F &&f, Args&&... args)
|
||||
+{
|
||||
+ try
|
||||
+ {
|
||||
+ return f (std::forward<Args> (args)...);
|
||||
+ }
|
||||
+ catch (const gdb_exception &ex)
|
||||
+ {
|
||||
+ if (ex.reason == RETURN_QUIT)
|
||||
+ set_quit_flag ();
|
||||
+ else if (ex.reason == RETURN_FORCED_QUIT)
|
||||
+ set_force_quit_flag ();
|
||||
+ }
|
||||
+
|
||||
+ return val;
|
||||
+}
|
||||
+
|
||||
/* See gdb_bfd.h. */
|
||||
|
||||
gdb_bfd_ref_ptr
|
||||
@@ -896,21 +919,51 @@ gdb_bfd_openr_iovec (const char *filename, const char *target,
|
||||
auto do_open = [] (bfd *nbfd, void *closure) -> void *
|
||||
{
|
||||
auto real_opener = static_cast<gdb_iovec_opener_ftype *> (closure);
|
||||
- return (*real_opener) (nbfd);
|
||||
+ /* Prevent exceptions from escaping to C code and triggering an abort. */
|
||||
+ auto res = catch_exceptions<gdb_bfd_iovec_base *, nullptr> ([&]
|
||||
+ {
|
||||
+ return (*real_opener) (nbfd);
|
||||
+ });
|
||||
+ if (res == nullptr)
|
||||
+ {
|
||||
+ errno = EIO;
|
||||
+ bfd_set_error (bfd_error_system_call);
|
||||
+ }
|
||||
+ return res;
|
||||
};
|
||||
|
||||
auto read_trampoline = [] (bfd *nbfd, void *stream, void *buf,
|
||||
file_ptr nbytes, file_ptr offset) -> file_ptr
|
||||
{
|
||||
gdb_bfd_iovec_base *obj = static_cast<gdb_bfd_iovec_base *> (stream);
|
||||
- return obj->read (nbfd, buf, nbytes, offset);
|
||||
+ /* Prevent exceptions from escaping to C code and triggering an abort. */
|
||||
+ auto res = catch_exceptions<long int, -1> ([&]
|
||||
+ {
|
||||
+ return obj->read (nbfd, buf, nbytes, offset);
|
||||
+ });
|
||||
+ if (res == -1)
|
||||
+ {
|
||||
+ errno = EIO;
|
||||
+ bfd_set_error (bfd_error_system_call);
|
||||
+ }
|
||||
+ return res;
|
||||
};
|
||||
|
||||
auto stat_trampoline = [] (struct bfd *abfd, void *stream,
|
||||
struct stat *sb) -> int
|
||||
{
|
||||
gdb_bfd_iovec_base *obj = static_cast<gdb_bfd_iovec_base *> (stream);
|
||||
- return obj->stat (abfd, sb);
|
||||
+ /* Prevent exceptions from escaping to C code and triggering an abort. */
|
||||
+ auto res = catch_exceptions<int, -1> ([&]
|
||||
+ {
|
||||
+ return obj->stat (abfd, sb);
|
||||
+ });
|
||||
+ if (res == -1)
|
||||
+ {
|
||||
+ errno = EIO;
|
||||
+ bfd_set_error (bfd_error_system_call);
|
||||
+ }
|
||||
+ return res;
|
||||
};
|
||||
|
||||
auto close_trampoline = [] (struct bfd *nbfd, void *stream) -> int
|
||||
--
|
||||
2.35.3
|
||||
|
264
gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
Normal file
264
gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
Normal file
@ -0,0 +1,264 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Burgess <aburgess@redhat.com>
|
||||
Date: Sat, 25 Nov 2023 10:35:37 +0000
|
||||
Subject: gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
|
||||
|
||||
;; Back-port upstream commit acc117b57f7 as part of a fix for
|
||||
;; non-deterministic gdb-index generation (RH BZ 2232086).
|
||||
|
||||
gdb: C++-ify mapped_symtab from dwarf2/index-write.c
|
||||
|
||||
Make static the functions add_index_entry, find_slot, and hash_expand,
|
||||
member functions of the mapped_symtab class.
|
||||
|
||||
Fold an additional snippet of code from write_gdbindex into
|
||||
mapped_symtab::minimize, this code relates to minimisation, so this
|
||||
seems like a good home for it.
|
||||
|
||||
Make the n_elements, data, and m_string_obstack member variables of
|
||||
mapped_symtab private. Provide a new obstack() member function to
|
||||
provide access to the obstack when needed, and also add member
|
||||
functions begin(), end(), cbegin(), and cend() so that the
|
||||
mapped_symtab class can be treated like a contained and iterated
|
||||
over.
|
||||
|
||||
I've also taken this opportunity to split out the logic for whether
|
||||
the hash table (m_data) needs expanding, this is the new function
|
||||
hash_needs_expanding. This will be useful in a later commit.
|
||||
|
||||
There should be no user visible changes after this commit.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
|
||||
--- a/gdb/dwarf2/index-write.c
|
||||
+++ b/gdb/dwarf2/index-write.c
|
||||
@@ -187,86 +187,135 @@ struct mapped_symtab
|
||||
{
|
||||
mapped_symtab ()
|
||||
{
|
||||
- data.resize (1024);
|
||||
+ m_data.resize (1024);
|
||||
}
|
||||
|
||||
- /* Minimize each entry in the symbol table, removing duplicates. */
|
||||
+ /* If there are no elements in the symbol table, then reduce the table
|
||||
+ size to zero. Otherwise call symtab_index_entry::minimize each entry
|
||||
+ in the symbol table. */
|
||||
+
|
||||
void minimize ()
|
||||
{
|
||||
- for (symtab_index_entry &item : data)
|
||||
+ if (m_element_count == 0)
|
||||
+ m_data.resize (0);
|
||||
+
|
||||
+ for (symtab_index_entry &item : m_data)
|
||||
item.minimize ();
|
||||
}
|
||||
|
||||
- offset_type n_elements = 0;
|
||||
- std::vector<symtab_index_entry> data;
|
||||
+ /* Add an entry to SYMTAB. NAME is the name of the symbol. CU_INDEX is
|
||||
+ the index of the CU in which the symbol appears. IS_STATIC is one if
|
||||
+ the symbol is static, otherwise zero (global). */
|
||||
+
|
||||
+ void add_index_entry (const char *name, int is_static,
|
||||
+ gdb_index_symbol_kind kind, offset_type cu_index);
|
||||
+
|
||||
+ /* Access the obstack. */
|
||||
+ struct obstack *obstack ()
|
||||
+ { return &m_string_obstack; }
|
||||
+
|
||||
+private:
|
||||
+
|
||||
+ /* Find a slot in SYMTAB for the symbol NAME. Returns a reference to
|
||||
+ the slot.
|
||||
+
|
||||
+ Function is used only during write_hash_table so no index format
|
||||
+ backward compatibility is needed. */
|
||||
+
|
||||
+ symtab_index_entry &find_slot (const char *name);
|
||||
+
|
||||
+ /* Expand SYMTAB's hash table. */
|
||||
+
|
||||
+ void hash_expand ();
|
||||
+
|
||||
+ /* Return true if the hash table in data needs to grow. */
|
||||
+
|
||||
+ bool hash_needs_expanding () const
|
||||
+ { return 4 * m_element_count / 3 >= m_data.size (); }
|
||||
+
|
||||
+ /* A vector that is used as a hash table. */
|
||||
+ std::vector<symtab_index_entry> m_data;
|
||||
+
|
||||
+ /* The number of elements stored in the m_data hash. */
|
||||
+ offset_type m_element_count = 0;
|
||||
|
||||
/* Temporary storage for names. */
|
||||
auto_obstack m_string_obstack;
|
||||
-};
|
||||
|
||||
-/* Find a slot in SYMTAB for the symbol NAME. Returns a reference to
|
||||
- the slot.
|
||||
+public:
|
||||
+ using iterator = decltype (m_data)::iterator;
|
||||
+ using const_iterator = decltype (m_data)::const_iterator;
|
||||
|
||||
- Function is used only during write_hash_table so no index format backward
|
||||
- compatibility is needed. */
|
||||
+ iterator begin ()
|
||||
+ { return m_data.begin (); }
|
||||
|
||||
-static symtab_index_entry &
|
||||
-find_slot (struct mapped_symtab *symtab, const char *name)
|
||||
+ iterator end ()
|
||||
+ { return m_data.end (); }
|
||||
+
|
||||
+ const_iterator cbegin ()
|
||||
+ { return m_data.cbegin (); }
|
||||
+
|
||||
+ const_iterator cend ()
|
||||
+ { return m_data.cend (); }
|
||||
+};
|
||||
+
|
||||
+/* See class definition. */
|
||||
+
|
||||
+symtab_index_entry &
|
||||
+mapped_symtab::find_slot (const char *name)
|
||||
{
|
||||
offset_type index, step, hash = mapped_index_string_hash (INT_MAX, name);
|
||||
|
||||
- index = hash & (symtab->data.size () - 1);
|
||||
- step = ((hash * 17) & (symtab->data.size () - 1)) | 1;
|
||||
+ index = hash & (m_data.size () - 1);
|
||||
+ step = ((hash * 17) & (m_data.size () - 1)) | 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
- if (symtab->data[index].name == NULL
|
||||
- || strcmp (name, symtab->data[index].name) == 0)
|
||||
- return symtab->data[index];
|
||||
- index = (index + step) & (symtab->data.size () - 1);
|
||||
+ if (m_data[index].name == NULL
|
||||
+ || strcmp (name, m_data[index].name) == 0)
|
||||
+ return m_data[index];
|
||||
+ index = (index + step) & (m_data.size () - 1);
|
||||
}
|
||||
}
|
||||
|
||||
-/* Expand SYMTAB's hash table. */
|
||||
+/* See class definition. */
|
||||
|
||||
-static void
|
||||
-hash_expand (struct mapped_symtab *symtab)
|
||||
+void
|
||||
+mapped_symtab::hash_expand ()
|
||||
{
|
||||
- auto old_entries = std::move (symtab->data);
|
||||
+ auto old_entries = std::move (m_data);
|
||||
|
||||
- symtab->data.clear ();
|
||||
- symtab->data.resize (old_entries.size () * 2);
|
||||
+ gdb_assert (m_data.size () == 0);
|
||||
+ m_data.resize (old_entries.size () * 2);
|
||||
|
||||
for (auto &it : old_entries)
|
||||
if (it.name != NULL)
|
||||
{
|
||||
- auto &ref = find_slot (symtab, it.name);
|
||||
+ auto &ref = this->find_slot (it.name);
|
||||
ref = std::move (it);
|
||||
}
|
||||
}
|
||||
|
||||
-/* Add an entry to SYMTAB. NAME is the name of the symbol.
|
||||
- CU_INDEX is the index of the CU in which the symbol appears.
|
||||
- IS_STATIC is one if the symbol is static, otherwise zero (global). */
|
||||
+/* See class definition. */
|
||||
|
||||
-static void
|
||||
-add_index_entry (struct mapped_symtab *symtab, const char *name,
|
||||
- int is_static, gdb_index_symbol_kind kind,
|
||||
- offset_type cu_index)
|
||||
+void
|
||||
+mapped_symtab::add_index_entry (const char *name, int is_static,
|
||||
+ gdb_index_symbol_kind kind,
|
||||
+ offset_type cu_index)
|
||||
{
|
||||
- symtab_index_entry *slot = &find_slot (symtab, name);
|
||||
+ symtab_index_entry *slot = &this->find_slot (name);
|
||||
if (slot->name == NULL)
|
||||
{
|
||||
/* This is a new element in the hash table. */
|
||||
- ++symtab->n_elements;
|
||||
+ ++this->m_element_count;
|
||||
|
||||
/* We might need to grow the hash table. */
|
||||
- if (4 * symtab->n_elements / 3 >= symtab->data.size ())
|
||||
+ if (this->hash_needs_expanding ())
|
||||
{
|
||||
- hash_expand (symtab);
|
||||
+ this->hash_expand ();
|
||||
|
||||
/* This element will have a different slot in the new table. */
|
||||
- slot = &find_slot (symtab, name);
|
||||
+ slot = &this->find_slot (name);
|
||||
|
||||
/* But it should still be a new element in the hash table. */
|
||||
gdb_assert (slot->name == nullptr);
|
||||
@@ -387,7 +436,7 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool)
|
||||
|
||||
/* We add all the index vectors to the constant pool first, to
|
||||
ensure alignment is ok. */
|
||||
- for (symtab_index_entry &entry : symtab->data)
|
||||
+ for (symtab_index_entry &entry : *symtab)
|
||||
{
|
||||
if (entry.name == NULL)
|
||||
continue;
|
||||
@@ -416,7 +465,7 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool)
|
||||
|
||||
/* Now write out the hash table. */
|
||||
std::unordered_map<c_str_view, offset_type, c_str_view_hasher> str_table;
|
||||
- for (const auto &entry : symtab->data)
|
||||
+ for (const auto &entry : *symtab)
|
||||
{
|
||||
offset_type str_off, vec_off;
|
||||
|
||||
@@ -1151,7 +1200,7 @@ write_cooked_index (cooked_index *table,
|
||||
const auto it = cu_index_htab.find (entry->per_cu);
|
||||
gdb_assert (it != cu_index_htab.cend ());
|
||||
|
||||
- const char *name = entry->full_name (&symtab->m_string_obstack);
|
||||
+ const char *name = entry->full_name (symtab->obstack ());
|
||||
|
||||
if (entry->per_cu->lang () == language_ada)
|
||||
{
|
||||
@@ -1159,7 +1208,7 @@ write_cooked_index (cooked_index *table,
|
||||
gdb, it has to use the encoded name, with any
|
||||
suffixes stripped. */
|
||||
std::string encoded = ada_encode (name, false);
|
||||
- name = obstack_strdup (&symtab->m_string_obstack,
|
||||
+ name = obstack_strdup (symtab->obstack (),
|
||||
encoded.c_str ());
|
||||
}
|
||||
else if (entry->per_cu->lang () == language_cplus
|
||||
@@ -1191,8 +1240,8 @@ write_cooked_index (cooked_index *table,
|
||||
else
|
||||
kind = GDB_INDEX_SYMBOL_KIND_TYPE;
|
||||
|
||||
- add_index_entry (symtab, name, (entry->flags & IS_STATIC) != 0,
|
||||
- kind, it->second);
|
||||
+ symtab->add_index_entry (name, (entry->flags & IS_STATIC) != 0,
|
||||
+ kind, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1267,8 +1316,6 @@ write_gdbindex (dwarf2_per_bfd *per_bfd, cooked_index *table,
|
||||
symtab.minimize ();
|
||||
|
||||
data_buf symtab_vec, constant_pool;
|
||||
- if (symtab.n_elements == 0)
|
||||
- symtab.data.resize (0);
|
||||
|
||||
write_hash_table (&symtab, symtab_vec, constant_pool);
|
||||
|
101
gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
Normal file
101
gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
Normal file
@ -0,0 +1,101 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Burgess <aburgess@redhat.com>
|
||||
Date: Mon, 27 Nov 2023 13:19:39 +0000
|
||||
Subject: gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
|
||||
|
||||
;; Back-port upstream commit 3644f41dc80 as part of a fix for
|
||||
;; non-deterministic gdb-index generation (RH BZ 2232086).
|
||||
|
||||
gdb: generate dwarf-5 index identically as worker-thread count changes
|
||||
|
||||
Similar to the previous commit, this commit ensures that the dwarf-5
|
||||
index files are generated identically as the number of worker-threads
|
||||
changes.
|
||||
|
||||
Building the dwarf-5 index makes use of a closed hash table, the
|
||||
bucket_hash local within debug_names::build(). Entries are added to
|
||||
bucket_hash from m_name_to_value_set, which, in turn, is populated
|
||||
by calls to debug_names::insert() in write_debug_names. The insert
|
||||
calls are ordered based on the entries within the cooked_index, and
|
||||
the ordering within cooked_index depends on the number of worker
|
||||
threads that GDB is using.
|
||||
|
||||
My proposal is to sort each chain within the bucket_hash closed hash
|
||||
table prior to using this to build the dwarf-5 index.
|
||||
|
||||
The buckets within bucket_hash will always have the same ordering (for
|
||||
a given GDB build with a given executable), and by sorting the chains
|
||||
within each bucket, we can be sure that GDB will see each entry in a
|
||||
deterministic order.
|
||||
|
||||
I've extended the index creation test to cover this case.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
|
||||
--- a/gdb/dwarf2/index-write.c
|
||||
+++ b/gdb/dwarf2/index-write.c
|
||||
@@ -452,6 +452,11 @@ class c_str_view
|
||||
return strcmp (m_cstr, other.m_cstr) == 0;
|
||||
}
|
||||
|
||||
+ bool operator< (const c_str_view &other) const
|
||||
+ {
|
||||
+ return strcmp (m_cstr, other.m_cstr) < 0;
|
||||
+ }
|
||||
+
|
||||
/* Return the underlying C string. Note, the returned string is
|
||||
only a reference with lifetime of this object. */
|
||||
const char *c_str () const
|
||||
@@ -771,10 +776,18 @@ class debug_names
|
||||
}
|
||||
for (size_t bucket_ix = 0; bucket_ix < bucket_hash.size (); ++bucket_ix)
|
||||
{
|
||||
- const std::forward_list<hash_it_pair> &hashitlist
|
||||
- = bucket_hash[bucket_ix];
|
||||
+ std::forward_list<hash_it_pair> &hashitlist = bucket_hash[bucket_ix];
|
||||
if (hashitlist.empty ())
|
||||
continue;
|
||||
+
|
||||
+ /* Sort the items within each bucket. This ensures that the
|
||||
+ generated index files will be the same no matter the order in
|
||||
+ which symbols were added into the index. */
|
||||
+ hashitlist.sort ([] (const hash_it_pair &a, const hash_it_pair &b)
|
||||
+ {
|
||||
+ return a.it->first < b.it->first;
|
||||
+ });
|
||||
+
|
||||
uint32_t &bucket_slot = m_bucket_table[bucket_ix];
|
||||
/* The hashes array is indexed starting at 1. */
|
||||
store_unsigned_integer (reinterpret_cast<gdb_byte *> (&bucket_slot),
|
||||
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
--- a/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
@@ -47,6 +47,9 @@ remote_exec host "mkdir -p ${dir1}"
|
||||
with_timeout_factor $timeout_factor {
|
||||
gdb_test_no_output "save gdb-index $dir1" \
|
||||
"create gdb-index file"
|
||||
+
|
||||
+ gdb_test_no_output "save gdb-index -dwarf-5 $dir1" \
|
||||
+ "create dwarf-index files"
|
||||
}
|
||||
|
||||
# Close GDB.
|
||||
@@ -143,13 +146,16 @@ if { $worker_threads > 1 } {
|
||||
with_timeout_factor $timeout_factor {
|
||||
gdb_test_no_output "save gdb-index $dir2" \
|
||||
"create second gdb-index file"
|
||||
+
|
||||
+ gdb_test_no_output "save gdb-index -dwarf-5 $dir2" \
|
||||
+ "create second dwarf-index files"
|
||||
}
|
||||
|
||||
# Close GDB.
|
||||
gdb_exit
|
||||
|
||||
# Now check that the index files are identical.
|
||||
- foreach suffix { gdb-index } {
|
||||
+ foreach suffix { gdb-index debug_names debug_str } {
|
||||
set result \
|
||||
[remote_exec host \
|
||||
"cmp -s \"$dir1/${index_filename_base}.${suffix}\" \"$dir2/${index_filename_base}.${suffix}\""]
|
230
gdb-rhbz-2232086-generate-gdb-index-consistently.patch
Normal file
230
gdb-rhbz-2232086-generate-gdb-index-consistently.patch
Normal file
@ -0,0 +1,230 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Burgess <aburgess@redhat.com>
|
||||
Date: Fri, 24 Nov 2023 12:04:36 +0000
|
||||
Subject: gdb-rhbz-2232086-generate-gdb-index-consistently.patch
|
||||
|
||||
;; Back-port upstream commit aff250145af as part of a fix for
|
||||
;; non-deterministic gdb-index generation (RH BZ 2232086).
|
||||
|
||||
gdb: generate gdb-index identically regardless of work thread count
|
||||
|
||||
It was observed that changing the number of worker threads that GDB
|
||||
uses (maintenance set worker-threads NUM) would have an impact on the
|
||||
layout of the generated gdb-index.
|
||||
|
||||
The cause seems to be how the CU are distributed between threads, and
|
||||
then symbols that appear in multiple CU can be encountered earlier or
|
||||
later depending on whether a particular CU moves between threads.
|
||||
|
||||
I certainly found this behaviour was reproducible when generating an
|
||||
index for GDB itself, like:
|
||||
|
||||
gdb -q -nx -nh -batch \
|
||||
-eiex 'maint set worker-threads NUM' \
|
||||
-ex 'save gdb-index /tmp/'
|
||||
|
||||
And then setting different values for NUM will change the generated
|
||||
index.
|
||||
|
||||
Now, the question is: does this matter?
|
||||
|
||||
I would like to suggest that yes, this does matter. At Red Hat we
|
||||
generate a gdb-index as part of the build process, and we would
|
||||
ideally like to have reproducible builds: for the same source,
|
||||
compiled with the same tool-chain, we should get the exact same output
|
||||
binary. And we do .... except for the index.
|
||||
|
||||
Now we could simply force GDB to only use a single worker thread when
|
||||
we build the index, but, I don't think the idea of reproducible builds
|
||||
is that strange, so I think we should ensure that our generated
|
||||
indexes are always reproducible.
|
||||
|
||||
To achieve this, I propose that we add an extra step when building the
|
||||
gdb-index file. After constructing the initial symbol hash table
|
||||
contents, we will pull all the symbols out of the hash, sort them,
|
||||
then re-insert them in sorted order. This will ensure that the
|
||||
structure of the generated hash will remain consistent (given the same
|
||||
set of symbols).
|
||||
|
||||
I've extended the existing index-file test to check that the generated
|
||||
index doesn't change if we adjust the number of worker threads used.
|
||||
Given that this test is already rather slow, I've only made one change
|
||||
to the worker-thread count. Maybe this test should be changed to use
|
||||
a smaller binary, which is quicker to load, and for which we could
|
||||
then try many different worker thread counts.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
|
||||
--- a/gdb/dwarf2/index-write.c
|
||||
+++ b/gdb/dwarf2/index-write.c
|
||||
@@ -210,6 +210,13 @@ struct mapped_symtab
|
||||
void add_index_entry (const char *name, int is_static,
|
||||
gdb_index_symbol_kind kind, offset_type cu_index);
|
||||
|
||||
+ /* When entries are originally added into the data hash the order will
|
||||
+ vary based on the number of worker threads GDB is configured to use.
|
||||
+ This function will rebuild the hash such that the final layout will be
|
||||
+ deterministic regardless of the number of worker threads used. */
|
||||
+
|
||||
+ void sort ();
|
||||
+
|
||||
/* Access the obstack. */
|
||||
struct obstack *obstack ()
|
||||
{ return &m_string_obstack; }
|
||||
@@ -296,6 +303,65 @@ mapped_symtab::hash_expand ()
|
||||
}
|
||||
}
|
||||
|
||||
+/* See mapped_symtab class declaration. */
|
||||
+
|
||||
+void mapped_symtab::sort ()
|
||||
+{
|
||||
+ /* Move contents out of this->data vector. */
|
||||
+ std::vector<symtab_index_entry> original_data = std::move (m_data);
|
||||
+
|
||||
+ /* Restore the size of m_data, this will avoid having to expand the hash
|
||||
+ table (and rehash all elements) when we reinsert after sorting.
|
||||
+ However, we do reset the element count, this allows for some sanity
|
||||
+ checking asserts during the reinsert phase. */
|
||||
+ gdb_assert (m_data.size () == 0);
|
||||
+ m_data.resize (original_data.size ());
|
||||
+ m_element_count = 0;
|
||||
+
|
||||
+ /* Remove empty entries from ORIGINAL_DATA, this makes sorting quicker. */
|
||||
+ auto it = std::remove_if (original_data.begin (), original_data.end (),
|
||||
+ [] (const symtab_index_entry &entry) -> bool
|
||||
+ {
|
||||
+ return entry.name == nullptr;
|
||||
+ });
|
||||
+ original_data.erase (it, original_data.end ());
|
||||
+
|
||||
+ /* Sort the existing contents. */
|
||||
+ std::sort (original_data.begin (), original_data.end (),
|
||||
+ [] (const symtab_index_entry &a,
|
||||
+ const symtab_index_entry &b) -> bool
|
||||
+ {
|
||||
+ /* Return true if A is before B. */
|
||||
+ gdb_assert (a.name != nullptr);
|
||||
+ gdb_assert (b.name != nullptr);
|
||||
+
|
||||
+ return strcmp (a.name, b.name) < 0;
|
||||
+ });
|
||||
+
|
||||
+ /* Re-insert each item from the sorted list. */
|
||||
+ for (auto &entry : original_data)
|
||||
+ {
|
||||
+ /* We know that ORIGINAL_DATA contains no duplicates, this data was
|
||||
+ taken from a hash table that de-duplicated entries for us, so
|
||||
+ count this as a new item.
|
||||
+
|
||||
+ As we retained the original size of m_data (see above) then we
|
||||
+ should never need to grow m_data_ during this re-insertion phase,
|
||||
+ assert that now. */
|
||||
+ ++m_element_count;
|
||||
+ gdb_assert (!this->hash_needs_expanding ());
|
||||
+
|
||||
+ /* Lookup a slot. */
|
||||
+ symtab_index_entry &slot = this->find_slot (entry.name);
|
||||
+
|
||||
+ /* As discussed above, we should not find duplicates. */
|
||||
+ gdb_assert (slot.name == nullptr);
|
||||
+
|
||||
+ /* Move this item into the slot we found. */
|
||||
+ slot = std::move (entry);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* See class definition. */
|
||||
|
||||
void
|
||||
@@ -1311,6 +1377,9 @@ write_gdbindex (dwarf2_per_bfd *per_bfd, cooked_index *table,
|
||||
for (auto map : table->get_addrmaps ())
|
||||
write_address_map (map, addr_vec, cu_index_htab);
|
||||
|
||||
+ /* Ensure symbol hash is built domestically. */
|
||||
+ symtab.sort ();
|
||||
+
|
||||
/* Now that we've processed all symbols we can shrink their cu_indices
|
||||
lists. */
|
||||
symtab.minimize ();
|
||||
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
--- a/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
@@ -38,6 +38,9 @@ with_timeout_factor $timeout_factor {
|
||||
clean_restart $filename
|
||||
}
|
||||
|
||||
+# Record how many worker threads GDB is using.
|
||||
+set worker_threads [gdb_get_worker_threads]
|
||||
+
|
||||
# Generate an index file.
|
||||
set dir1 [standard_output_file "index_1"]
|
||||
remote_exec host "mkdir -p ${dir1}"
|
||||
@@ -116,3 +119,41 @@ proc check_symbol_table_usage { filename } {
|
||||
|
||||
set index_filename_base [file tail $filename]
|
||||
check_symbol_table_usage "$dir1/${index_filename_base}.gdb-index"
|
||||
+
|
||||
+# If GDB is using more than 1 worker thread then reduce the number of
|
||||
+# worker threads, regenerate the index, and check that we get the same
|
||||
+# index file back. At one point the layout of the index would vary
|
||||
+# based on the number of worker threads used.
|
||||
+if { $worker_threads > 1 } {
|
||||
+ # Start GDB, but don't load a file yet.
|
||||
+ clean_restart
|
||||
+
|
||||
+ # Adjust the number of threads to use.
|
||||
+ set reduced_threads [expr $worker_threads / 2]
|
||||
+ gdb_test_no_output "maint set worker-threads $reduced_threads"
|
||||
+
|
||||
+ with_timeout_factor $timeout_factor {
|
||||
+ # Now load the test binary.
|
||||
+ gdb_file_cmd $filename
|
||||
+ }
|
||||
+
|
||||
+ # Generate an index file.
|
||||
+ set dir2 [standard_output_file "index_2"]
|
||||
+ remote_exec host "mkdir -p ${dir2}"
|
||||
+ with_timeout_factor $timeout_factor {
|
||||
+ gdb_test_no_output "save gdb-index $dir2" \
|
||||
+ "create second gdb-index file"
|
||||
+ }
|
||||
+
|
||||
+ # Close GDB.
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Now check that the index files are identical.
|
||||
+ foreach suffix { gdb-index } {
|
||||
+ set result \
|
||||
+ [remote_exec host \
|
||||
+ "cmp -s \"$dir1/${index_filename_base}.${suffix}\" \"$dir2/${index_filename_base}.${suffix}\""]
|
||||
+ gdb_assert { [lindex $result 0] == 0 } \
|
||||
+ "$suffix files are identical"
|
||||
+ }
|
||||
+}
|
||||
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
|
||||
--- a/gdb/testsuite/lib/gdb.exp
|
||||
+++ b/gdb/testsuite/lib/gdb.exp
|
||||
@@ -10033,6 +10033,21 @@ proc is_target_non_stop { {testname ""} } {
|
||||
return $is_non_stop
|
||||
}
|
||||
|
||||
+# Return the number of worker threads that GDB is currently using.
|
||||
+
|
||||
+proc gdb_get_worker_threads { {testname ""} } {
|
||||
+ set worker_threads "UNKNOWN"
|
||||
+ gdb_test_multiple "maintenance show worker-threads" $testname {
|
||||
+ -wrap -re "The number of worker threads GDB can use is unlimited \\(currently ($::decimal)\\)\\." {
|
||||
+ set worker_threads $expect_out(1,string)
|
||||
+ }
|
||||
+ -wrap -re "The number of worker threads GDB can use is ($::decimal)\\." {
|
||||
+ set worker_threads $expect_out(1,string)
|
||||
+ }
|
||||
+ }
|
||||
+ return $worker_threads
|
||||
+}
|
||||
+
|
||||
# Check if the compiler emits epilogue information associated
|
||||
# with the closing brace or with the last statement line.
|
||||
#
|
222
gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
Normal file
222
gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
Normal file
@ -0,0 +1,222 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Burgess <aburgess@redhat.com>
|
||||
Date: Fri, 24 Nov 2023 11:50:35 +0000
|
||||
Subject: gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
|
||||
|
||||
;; Back-port upstream commit aa19bc1d259 as part of a fix for
|
||||
;; non-deterministic gdb-index generation (RH BZ 2232086).
|
||||
|
||||
gdb: reduce size of generated gdb-index file
|
||||
|
||||
I noticed in passing that out algorithm for generating the gdb-index
|
||||
file is incorrect. When building the hash table in add_index_entry we
|
||||
count every incoming entry rehash when the number of entries gets too
|
||||
large. However, some of the incoming entries will be duplicates,
|
||||
which don't actually result in new items being added to the hash
|
||||
table.
|
||||
|
||||
As a result, we grow the gdb-index hash table far too often.
|
||||
|
||||
With an unmodified GDB, generating a gdb-index for GDB, I see a file
|
||||
size of 90M, with a hash usage (in the generated index file) of just
|
||||
2.6%.
|
||||
|
||||
With a patched GDB, generating a gdb-index for the _same_ GDB binary,
|
||||
I now see a gdb-index file size of 30M, with a hash usage of 41.9%.
|
||||
|
||||
This is a 67% reduction in gdb-index file size.
|
||||
|
||||
Obviously, not every gdb-index file is going to see such big savings,
|
||||
however, the larger a program, and the more symbols that are
|
||||
duplicated between compilation units, the more GDB would over count,
|
||||
and so, over-grow the index.
|
||||
|
||||
The gdb-index hash table we create has a minimum size of 1024, and
|
||||
then we grow the hash when it is 75% full, doubling the hash table at
|
||||
that time. Given this, then we expect that either:
|
||||
|
||||
a. The hash table is size 1024, and less than 75% full, or
|
||||
b. The hash table is between 37.5% and 75% full.
|
||||
|
||||
I've include a test that checks some of these constraints -- I've not
|
||||
bothered to check the upper limit, and over full hash table isn't
|
||||
really a problem here, but if the fill percentage is less than 37.5%
|
||||
then this indicates that we've done something wrong (obviously, I also
|
||||
check for the 1024 minimum size).
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
|
||||
--- a/gdb/dwarf2/index-write.c
|
||||
+++ b/gdb/dwarf2/index-write.c
|
||||
@@ -254,20 +254,29 @@ add_index_entry (struct mapped_symtab *symtab, const char *name,
|
||||
int is_static, gdb_index_symbol_kind kind,
|
||||
offset_type cu_index)
|
||||
{
|
||||
- offset_type cu_index_and_attrs;
|
||||
+ symtab_index_entry *slot = &find_slot (symtab, name);
|
||||
+ if (slot->name == NULL)
|
||||
+ {
|
||||
+ /* This is a new element in the hash table. */
|
||||
+ ++symtab->n_elements;
|
||||
|
||||
- ++symtab->n_elements;
|
||||
- if (4 * symtab->n_elements / 3 >= symtab->data.size ())
|
||||
- hash_expand (symtab);
|
||||
+ /* We might need to grow the hash table. */
|
||||
+ if (4 * symtab->n_elements / 3 >= symtab->data.size ())
|
||||
+ {
|
||||
+ hash_expand (symtab);
|
||||
|
||||
- symtab_index_entry &slot = find_slot (symtab, name);
|
||||
- if (slot.name == NULL)
|
||||
- {
|
||||
- slot.name = name;
|
||||
+ /* This element will have a different slot in the new table. */
|
||||
+ slot = &find_slot (symtab, name);
|
||||
+
|
||||
+ /* But it should still be a new element in the hash table. */
|
||||
+ gdb_assert (slot->name == nullptr);
|
||||
+ }
|
||||
+
|
||||
+ slot->name = name;
|
||||
/* index_offset is set later. */
|
||||
}
|
||||
|
||||
- cu_index_and_attrs = 0;
|
||||
+ offset_type cu_index_and_attrs = 0;
|
||||
DW2_GDB_INDEX_CU_SET_VALUE (cu_index_and_attrs, cu_index);
|
||||
DW2_GDB_INDEX_SYMBOL_STATIC_SET_VALUE (cu_index_and_attrs, is_static);
|
||||
DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE (cu_index_and_attrs, kind);
|
||||
@@ -279,7 +288,7 @@ add_index_entry (struct mapped_symtab *symtab, const char *name,
|
||||
the last entry pushed), but a symbol could have multiple kinds in one CU.
|
||||
To keep things simple we don't worry about the duplication here and
|
||||
sort and uniquify the list after we've processed all symbols. */
|
||||
- slot.cu_indices.push_back (cu_index_and_attrs);
|
||||
+ slot->cu_indices.push_back (cu_index_and_attrs);
|
||||
}
|
||||
|
||||
/* See symtab_index_entry. */
|
||||
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
|
||||
@@ -0,0 +1,118 @@
|
||||
+# 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/>.
|
||||
+
|
||||
+# Load the GDB executable, and then 'save gdb-index', and make some
|
||||
+# checks of the generated index file.
|
||||
+
|
||||
+load_lib selftest-support.exp
|
||||
+
|
||||
+# Can't save an index with readnow.
|
||||
+if {[readnow]} {
|
||||
+ untested "cannot create an index when readnow is in use"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# A multiplier used to ensure slow tasks are less likely to timeout.
|
||||
+set timeout_factor 20
|
||||
+
|
||||
+set filename [selftest_prepare]
|
||||
+if { $filename eq "" } {
|
||||
+ unsupported "${gdb_test_file_name}.exp"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+with_timeout_factor $timeout_factor {
|
||||
+ # Start GDB, load FILENAME.
|
||||
+ clean_restart $filename
|
||||
+}
|
||||
+
|
||||
+# Generate an index file.
|
||||
+set dir1 [standard_output_file "index_1"]
|
||||
+remote_exec host "mkdir -p ${dir1}"
|
||||
+with_timeout_factor $timeout_factor {
|
||||
+ gdb_test_no_output "save gdb-index $dir1" \
|
||||
+ "create gdb-index file"
|
||||
+}
|
||||
+
|
||||
+# Close GDB.
|
||||
+gdb_exit
|
||||
+
|
||||
+# Validate that the index-file FILENAME has made efficient use of its
|
||||
+# symbol hash table. Calculate the number of symbols in the hash
|
||||
+# table and the total hash table size. The hash table starts with
|
||||
+# 1024 entries, and then doubles each time it is filled to 75%. At
|
||||
+# 75% filled, doubling the size takes it to 37.5% filled.
|
||||
+#
|
||||
+# Thus, the hash table is correctly filled if:
|
||||
+# 1. Its size is 1024 (i.e. it has not yet had its first doubling), or
|
||||
+# 2. Its filled percentage is over 37%
|
||||
+#
|
||||
+# We could check that it is not over filled, but I don't as that's not
|
||||
+# really an issue. But we did once have a bug where the table was
|
||||
+# doubled incorrectly, in which case we'd see a filled percentage of
|
||||
+# around 2% in some cases, which is a huge waste of disk space.
|
||||
+proc check_symbol_table_usage { filename } {
|
||||
+ # Open the file in binary mode and read-only mode.
|
||||
+ set fp [open $filename rb]
|
||||
+
|
||||
+ # Configure the channel to use binary translation.
|
||||
+ fconfigure $fp -translation binary
|
||||
+
|
||||
+ # Read the first 8 bytes of the file, which contain the header of
|
||||
+ # the index section.
|
||||
+ set header [read $fp [expr 7 * 4]]
|
||||
+
|
||||
+ # Scan the header to get the version, the CU list offset, and the
|
||||
+ # types CU list offset.
|
||||
+ binary scan $header iiiiii version \
|
||||
+ _ _ _ symbol_table_offset shortcut_offset
|
||||
+
|
||||
+ # The length of the symbol hash table (in entries).
|
||||
+ set len [expr ($shortcut_offset - $symbol_table_offset) / 8]
|
||||
+
|
||||
+ # Now walk the hash table and count how many entries are in use.
|
||||
+ set offset $symbol_table_offset
|
||||
+ set count 0
|
||||
+ while { $offset < $shortcut_offset } {
|
||||
+ seek $fp $offset
|
||||
+ set entry [read $fp 8]
|
||||
+ binary scan $entry ii name_ptr flags
|
||||
+ if { $name_ptr != 0 } {
|
||||
+ incr count
|
||||
+ }
|
||||
+
|
||||
+ incr offset 8
|
||||
+ }
|
||||
+
|
||||
+ # Close the file.
|
||||
+ close $fp
|
||||
+
|
||||
+ # Calculate how full the cache is.
|
||||
+ set pct [expr (100 * double($count)) / $len]
|
||||
+
|
||||
+ # Write our results out to the gdb.log.
|
||||
+ verbose -log "Hash table size: $len"
|
||||
+ verbose -log "Hash table entries: $count"
|
||||
+ verbose -log "Percentage usage: $pct%"
|
||||
+
|
||||
+ # The minimum fill percentage is actually 37.5%, but we give TCL a
|
||||
+ # little flexibility in case the FP maths give a result a little
|
||||
+ # off.
|
||||
+ gdb_assert { $len == 1024 || $pct > 37 } \
|
||||
+ "symbol hash table usage"
|
||||
+}
|
||||
+
|
||||
+set index_filename_base [file tail $filename]
|
||||
+check_symbol_table_usage "$dir1/${index_filename_base}.gdb-index"
|
@ -1,135 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch
|
||||
|
||||
;; Fix 'backport GDB 7.4 fix to RHEL 6.6 GDB' [Original Sourceware bug
|
||||
;; description: 'C++ (and objc): Internal error on unqualified name
|
||||
;; re-set', PR 11657] (RH BZ 1186476).
|
||||
;;=fedoratest
|
||||
|
||||
Comments from Sergio Durigan Junior:
|
||||
|
||||
The "proper" fix for this whole problem would be to backport the
|
||||
"ambiguous linespec" patch series. However, it is really not
|
||||
recommended to do that for RHEL GDB, because the patch series is too
|
||||
big and could introduce unwanted regressions. Instead, what we
|
||||
chose to do was to replace the gdb_assert call by a warning (which
|
||||
allows the user to continue the debugging session), and tell the
|
||||
user that, although more than one location was found for his/her
|
||||
breakpoint, only one will be used.
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2015 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 (int argc, char *argv[])
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc
|
||||
@@ -0,0 +1,26 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2015 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/>. */
|
||||
+
|
||||
+class C
|
||||
+ {
|
||||
+ public:
|
||||
+ C () {}
|
||||
+ C (int x) {}
|
||||
+ };
|
||||
+
|
||||
+C a;
|
||||
+C b (1);
|
||||
diff --git a/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp
|
||||
@@ -0,0 +1,51 @@
|
||||
+# Copyright 2015 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/>.
|
||||
+
|
||||
+if { [skip_cplus_tests] } { continue }
|
||||
+if { [skip_shlib_tests] } { continue }
|
||||
+if { [is_remote target] } { continue }
|
||||
+if { [target_info exists use_gdb_stub] } { continue }
|
||||
+
|
||||
+set testfile gdb-rhbz1186476-internal-error-unqualified-name-re-set-main
|
||||
+set srcfile $testfile.cc
|
||||
+set executable $testfile
|
||||
+set binfile [standard_output_file $executable]
|
||||
+
|
||||
+set libtestfile gdb-rhbz1186476-internal-error-unqualified-name-re-set
|
||||
+set libsrcfile $libtestfile.cc
|
||||
+set sofile [standard_output_file lib$libtestfile.so]
|
||||
+
|
||||
+# Create and source the file that provides information about the compiler
|
||||
+# used to compile the test case.
|
||||
+if [get_compiler_info "c++"] {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++ "additional_flags=-fPIC"}] != ""
|
||||
+ || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list additional_flags=-Wl,-rpath,[file dirname ${sofile}] "c++" shlib=${sofile} ]] != ""} {
|
||||
+ untested $libtestfile.exp
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+clean_restart $executable
|
||||
+
|
||||
+gdb_test_no_output "set breakpoint pending on"
|
||||
+# gdb_breakpoint would print a failure because of some warning messages
|
||||
+gdb_test "break C::C" "Breakpoint $decimal \\(C::C\\) pending."
|
||||
+
|
||||
+#gdb_test "run" "warning: Found more than one location for breakpoint #$decimal; only the first location will be used.(\r\n)+Breakpoint $decimal, C::C.*"
|
||||
+gdb_test "run"
|
||||
+
|
||||
+gdb_test "info break" " in C::C\\(\\) at .* in C::C\\(int\\) at .*"
|
@ -1,83 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-rhbz1350436-type-printers-error.patch
|
||||
|
||||
;; Test 'info type-printers' Python error (RH BZ 1350436).
|
||||
;;=fedoratest
|
||||
|
||||
Typo in Python support breaks info type-printers command
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1350436
|
||||
|
||||
[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers
|
||||
https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.python/py-typeprint.cc b/gdb/testsuite/gdb.python/py-typeprint.cc
|
||||
--- a/gdb/testsuite/gdb.python/py-typeprint.cc
|
||||
+++ b/gdb/testsuite/gdb.python/py-typeprint.cc
|
||||
@@ -31,6 +31,12 @@ templ<basic_string> s;
|
||||
|
||||
basic_string bs;
|
||||
|
||||
+class Other
|
||||
+{
|
||||
+};
|
||||
+
|
||||
+Other ovar;
|
||||
+
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp
|
||||
--- a/gdb/testsuite/gdb.python/py-typeprint.exp
|
||||
+++ b/gdb/testsuite/gdb.python/py-typeprint.exp
|
||||
@@ -50,3 +50,7 @@ gdb_test_no_output "enable type-printer string"
|
||||
gdb_test "whatis bs" "string" "whatis with enabled printer"
|
||||
|
||||
gdb_test "whatis s" "templ<string>"
|
||||
+
|
||||
+gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
|
||||
+ "info type-printers for other"
|
||||
+gdb_test "whatis ovar" "type = Another"
|
||||
diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py
|
||||
--- a/gdb/testsuite/gdb.python/py-typeprint.py
|
||||
+++ b/gdb/testsuite/gdb.python/py-typeprint.py
|
||||
@@ -15,8 +15,7 @@
|
||||
|
||||
import gdb
|
||||
|
||||
-
|
||||
-class Recognizer(object):
|
||||
+class StringRecognizer(object):
|
||||
def __init__(self):
|
||||
self.enabled = True
|
||||
|
||||
@@ -32,7 +31,27 @@ class StringTypePrinter(object):
|
||||
self.enabled = True
|
||||
|
||||
def instantiate(self):
|
||||
- return Recognizer()
|
||||
+ return StringRecognizer()
|
||||
|
||||
|
||||
gdb.type_printers.append(StringTypePrinter())
|
||||
+
|
||||
+class OtherRecognizer(object):
|
||||
+ def __init__(self):
|
||||
+ self.enabled = True
|
||||
+
|
||||
+ def recognize(self, type_obj):
|
||||
+ if type_obj.tag == 'Other':
|
||||
+ return 'Another'
|
||||
+ return None
|
||||
+
|
||||
+class OtherTypePrinter(object):
|
||||
+ def __init__(self):
|
||||
+ self.name = 'other'
|
||||
+ self.enabled = True
|
||||
+
|
||||
+ def instantiate(self):
|
||||
+ return OtherRecognizer()
|
||||
+
|
||||
+import gdb.types
|
||||
+gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())
|
@ -1,81 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Fri, 23 Mar 2018 20:42:44 +0100
|
||||
Subject: gdb-rhbz1553104-s390x-arch12-test.patch
|
||||
|
||||
;; [s390x] Backport arch12 instructions decoding (RH BZ 1553104).
|
||||
;; =fedoratest
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.S b/gdb/testsuite/gdb.arch/s390x-arch12.S
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.arch/s390x-arch12.S
|
||||
@@ -0,0 +1,4 @@
|
||||
+.text
|
||||
+.globl load_guarded
|
||||
+load_guarded:
|
||||
+.byte 0xeb,0xbf,0xf0,0x58,0x00,0x24,0xe3,0xf0,0xff,0x50,0xff,0x71,0xb9,0x04,0x00,0xbf,0xe3,0x20,0xb0,0xa0,0x00,0x24,0xe3,0x10,0xb0,0xa0,0x00,0x04,0xe3,0x10,0x10,0x00,0x00,0x4c,0xe3,0x10,0xb0,0xa8,0x00,0x24,0xe3,0x10,0xb0,0xa8,0x00,0x04,0xb9,0x04,0x00,0x21,0xe3,0x40,0xb1,0x20,0x00,0x04,0xeb,0xbf,0xb1,0x08,0x00,0x04,0x07,0xf4
|
||||
diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.exp b/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.arch/s390x-arch12.exp
|
||||
@@ -0,0 +1,34 @@
|
||||
+# Copyright 2018 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/>.
|
||||
+
|
||||
+#if { ![istarget s390x-*linux-*] || ![is_lp64_target] } {
|
||||
+# verbose "Skipping s390x-prologue-skip.exp"
|
||||
+# return
|
||||
+#}
|
||||
+
|
||||
+set testfile "s390x-arch12"
|
||||
+set uufile "${srcdir}/${subdir}/${testfile}.o.uu"
|
||||
+set ofile "${srcdir}/${subdir}/${testfile}.o"
|
||||
+
|
||||
+if { [catch "system \"uudecode -o ${ofile} ${uufile}\"" ] != 0 } {
|
||||
+ untested "failed uudecode"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_load $ofile
|
||||
+
|
||||
+gdb_test "disas load_guarded" " <\\+28>:\tlgg\t%r1,0\\(%r1\\)\r\n\[^\r\n\]* <\\+34>:\tstg\t%r1,168\\(%r11\\)\r\n.*"
|
||||
diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.o.uu b/gdb/testsuite/gdb.arch/s390x-arch12.o.uu
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.arch/s390x-arch12.o.uu
|
||||
@@ -0,0 +1,20 @@
|
||||
+begin 644 s390x-arch12.o
|
||||
+M?T5,1@("`0`````````````!`!8````!````````````````````````````
|
||||
+M``$X``````!```````!```<`!.N_\%@`)./P_U#_<;D$`+_C(+"@`"3C$+"@
|
||||
+M``3C$!```$SC$+"H`"3C$+"H``2Y!``AXT"Q(``$Z[^Q"``$!_0`+G-Y;71A
|
||||
+M8@`N<W1R=&%B`"YS:'-T<G1A8@`N=&5X=``N9&%T80`N8G-S````````````
|
||||
+M`````````````````````````````````P```0``````````````````````
|
||||
+M`````P```@```````````````````````````P```P``````````````````
|
||||
+M```````!$````0``````````````````````;&]A9%]G=6%R9&5D````````
|
||||
+M````````````````````````````````````````````````````````````
|
||||
+M`````````````````````````!L````!``````````8`````````````````
|
||||
+M``!``````````$`````````````````````$```````````````A`````0``
|
||||
+M```````#````````````````````@```````````````````````````````
|
||||
+M!```````````````)P````@``````````P```````````````````(``````
|
||||
+M``````````````````````````0``````````````!$````#````````````
|
||||
+M``````````````````"``````````"P````````````````````!````````
|
||||
+M```````!`````@``````````````````````````````L`````````!X````
|
||||
+M!@````0`````````"``````````8````"0````,`````````````````````
|
||||
+H`````````2@`````````#@````````````````````$`````````````
|
||||
+`
|
||||
+end
|
@ -1,105 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Buettner <kevinb@redhat.com>
|
||||
Date: Mon, 2 Oct 2023 15:05:23 -0700
|
||||
Subject: gdb-rhbz1773651-gdb-index-internal-error.patch
|
||||
|
||||
;; Backport upstream patch which prevents internal error when
|
||||
;; generating a gdb-index file (RH BZ 1773651).
|
||||
|
||||
Throw error when creating an overly large gdb-index file
|
||||
|
||||
The header in a .gdb_index section uses 32-bit unsigned offsets to
|
||||
refer to other areas of the section. Thus, there is a size limit of
|
||||
2^32-1 which is currently unaccounted for by GDB's code for outputting
|
||||
these sections.
|
||||
|
||||
At the moment, when GDB creates an overly large section, it will exit
|
||||
abnormally due to an internal error, which is caused by a failed
|
||||
assert in assert_file_size, which in turn is called from
|
||||
write_gdbindex_1, both of which are in gdb/dwarf2/index-write.c.
|
||||
|
||||
This is what happens when that assert fails:
|
||||
|
||||
$ gdb -q -nx -iex 'set auto-load no' -iex 'set debuginfod enabled off' -ex file ./libgraph_tool_inference.so -ex "save gdb-index `pwd`/"
|
||||
Reading symbols from ./libgraph_tool_inference.so...
|
||||
No executable file now.
|
||||
Discard symbol table from `libgraph_tool_inference.so'? (y or n) n
|
||||
Not confirmed.
|
||||
../../gdb/dwarf2/index-write.c:1069: internal-error: assert_file_size: Assertion `file_size == expected_size' failed.
|
||||
A problem internal to GDB has been detected,
|
||||
further debugging may prove unreliable.
|
||||
----- Backtrace -----
|
||||
0x55fddb4d78b0 gdb_internal_backtrace_1
|
||||
../../gdb/bt-utils.c:122
|
||||
0x55fddb4d78b0 _Z22gdb_internal_backtracev
|
||||
../../gdb/bt-utils.c:168
|
||||
0x55fddb98b5d4 internal_vproblem
|
||||
../../gdb/utils.c:396
|
||||
0x55fddb98b8de _Z15internal_verrorPKciS0_P13__va_list_tag
|
||||
../../gdb/utils.c:476
|
||||
0x55fddbb71654 _Z18internal_error_locPKciS0_z
|
||||
../../gdbsupport/errors.cc:58
|
||||
0x55fddb5a0f23 assert_file_size
|
||||
../../gdb/dwarf2/index-write.c:1069
|
||||
0x55fddb5a1ee0 assert_file_size
|
||||
/usr/include/c++/13/bits/stl_iterator.h:1158
|
||||
0x55fddb5a1ee0 write_gdbindex_1
|
||||
../../gdb/dwarf2/index-write.c:1119
|
||||
0x55fddb5a51be write_gdbindex
|
||||
../../gdb/dwarf2/index-write.c:1273
|
||||
[...]
|
||||
---------------------
|
||||
../../gdb/dwarf2/index-write.c:1069: internal-error: assert_file_size: Assertion `file_size == expected_size' failed.
|
||||
|
||||
This problem was encountered while building the python-graph-tool
|
||||
package on Fedora. The Fedora bugzilla bug can be found here:
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1773651
|
||||
|
||||
This commit prevents the internal error from occurring by calling error()
|
||||
when the file size exceeds 2^32-1.
|
||||
|
||||
Using a gdb built with this commit, I now see this behavior instead:
|
||||
|
||||
$ gdb -q -nx -iex 'set auto-load no' -iex 'set debuginfod enabled off' -ex file ./libgraph_tool_inference.so -ex "save gdb-index `pwd`/"
|
||||
Reading symbols from ./libgraph_tool_inference.so...
|
||||
No executable file now.
|
||||
Discard symbol table from `/mesquite2/fedora-bugs/1773651/libgraph_tool_inference.so'? (y or n) n
|
||||
Not confirmed.
|
||||
Error while writing index for `/mesquite2/fedora-bugs/1773651/libgraph_tool_inference.so': gdb-index maximum file size of 4294967295 exceeded
|
||||
(gdb)
|
||||
|
||||
I wish I could provide a test case, but due to the sizes of both the
|
||||
input and output files, I think that testing resources would be
|
||||
strained or exceeded in many environments.
|
||||
|
||||
My testing on Fedora 38 shows no regressions.
|
||||
|
||||
Approved-by: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
|
||||
--- a/gdb/dwarf2/index-write.c
|
||||
+++ b/gdb/dwarf2/index-write.c
|
||||
@@ -1082,7 +1082,7 @@ write_gdbindex_1 (FILE *out_file,
|
||||
{
|
||||
data_buf contents;
|
||||
const offset_type size_of_header = 6 * sizeof (offset_type);
|
||||
- offset_type total_len = size_of_header;
|
||||
+ size_t total_len = size_of_header;
|
||||
|
||||
/* The version number. */
|
||||
contents.append_offset (8);
|
||||
@@ -1109,6 +1109,13 @@ write_gdbindex_1 (FILE *out_file,
|
||||
|
||||
gdb_assert (contents.size () == size_of_header);
|
||||
|
||||
+ /* The maximum size of an index file is limited by the maximum value
|
||||
+ capable of being represented by 'offset_type'. Throw an error if
|
||||
+ that length has been exceeded. */
|
||||
+ size_t max_size = ~(offset_type) 0;
|
||||
+ if (total_len > max_size)
|
||||
+ error (_("gdb-index maximum file size of %zu exceeded"), max_size);
|
||||
+
|
||||
contents.file_write (out_file);
|
||||
cu_list.file_write (out_file);
|
||||
types_cu_list.file_write (out_file);
|
@ -1,108 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Buettner <kevinb@redhat.com>
|
||||
Date: Thu, 29 Jun 2023 18:20:30 -0700
|
||||
Subject: gdb-rhbz2160211-excessive-core-file-warnings.patch
|
||||
|
||||
;; Backport two commits, 0ad504dd464 and ea70f941f9b, from Lancelot SIX
|
||||
;; which prevent repeated warnings from being printed while loading a
|
||||
;; core file. (RH BZ 2160211)
|
||||
|
||||
gdb/corelow.c: avoid repeated warnings in build_file_mappings
|
||||
|
||||
When GDB opens a coredump it tries to locate and then open all files
|
||||
which were mapped in the process.
|
||||
|
||||
If a file is found but cannot be opened with BFD (bfd_open /
|
||||
bfd_check_format fails), then a warning is printed to the user. If the
|
||||
same file was mapped multiple times in the process's address space, the
|
||||
warning is printed once for each time the file was mapped. I find this
|
||||
un-necessarily noisy.
|
||||
|
||||
This patch makes it so the warning message is printed only once per
|
||||
file.
|
||||
|
||||
There was a comment in the code assuming that if the file was found on
|
||||
the system, opening it (bfd_open + bfd_check_format) should always
|
||||
succeed. A recent change in BFD (014a602b86f "Don't optimise bfd_seek
|
||||
to same position") showed that this assumption is not valid. For
|
||||
example, it is possible to have a core dump of a process which had
|
||||
mmaped an IO page from a DRI render node (/dev/dri/runderD$NUM). In
|
||||
such case the core dump does contain the information that portions of
|
||||
this special file were mapped in the host process, but trying to seek to
|
||||
position 0 will fail, making bfd_check_format fail. This patch removes
|
||||
this comment.
|
||||
|
||||
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
|
||||
Approved-By: Andrew Burgess <aburgess@redhat.com>
|
||||
|
||||
gdb/corelow.c: do not try to reopen a file if open failed once
|
||||
|
||||
In the current implementation, core_target::build_file_mappings will try
|
||||
to locate and open files which were mapped in the process for which the
|
||||
core dump was produced. If the file cannot be found or cannot be
|
||||
opened, GDB will re-try to open it once for each time it was mapped in
|
||||
the process's address space.
|
||||
|
||||
This patch makes it so GDB recognizes that it has already failed to open
|
||||
a given file once and does not re-try the process for each mapping.
|
||||
|
||||
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
|
||||
Approved-By: Andrew Burgess <aburgess@redhat.com>
|
||||
|
||||
diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
--- a/gdb/corelow.c
|
||||
+++ b/gdb/corelow.c
|
||||
@@ -237,6 +237,16 @@ core_target::build_file_mappings ()
|
||||
weed out non-file-backed mappings. */
|
||||
gdb_assert (filename != nullptr);
|
||||
|
||||
+ if (unavailable_paths.find (filename) != unavailable_paths.end ())
|
||||
+ {
|
||||
+ /* We have already seen some mapping for FILENAME but failed to
|
||||
+ find/open the file. There is no point in trying the same
|
||||
+ thing again so just record that the range [start, end) is
|
||||
+ unavailable. */
|
||||
+ m_core_unavailable_mappings.emplace_back (start, end - start);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
struct bfd *bfd = bfd_map[filename];
|
||||
if (bfd == nullptr)
|
||||
{
|
||||
@@ -254,11 +264,10 @@ core_target::build_file_mappings ()
|
||||
if (expanded_fname == nullptr)
|
||||
{
|
||||
m_core_unavailable_mappings.emplace_back (start, end - start);
|
||||
- /* Print just one warning per path. */
|
||||
- if (unavailable_paths.insert (filename).second)
|
||||
- warning (_("Can't open file %s during file-backed mapping "
|
||||
- "note processing"),
|
||||
- filename);
|
||||
+ unavailable_paths.insert (filename);
|
||||
+ warning (_("Can't open file %s during file-backed mapping "
|
||||
+ "note processing"),
|
||||
+ filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,18 +277,11 @@ core_target::build_file_mappings ()
|
||||
if (bfd == nullptr || !bfd_check_format (bfd, bfd_object))
|
||||
{
|
||||
m_core_unavailable_mappings.emplace_back (start, end - start);
|
||||
- /* If we get here, there's a good chance that it's due to
|
||||
- an internal error. We issue a warning instead of an
|
||||
- internal error because of the possibility that the
|
||||
- file was removed in between checking for its
|
||||
- existence during the expansion in exec_file_find()
|
||||
- and the calls to bfd_openr() / bfd_check_format().
|
||||
- Output both the path from the core file note along
|
||||
- with its expansion to make debugging this problem
|
||||
- easier. */
|
||||
+ unavailable_paths.insert (filename);
|
||||
warning (_("Can't open file %s which was expanded to %s "
|
||||
"during file-backed mapping note processing"),
|
||||
filename, expanded_fname.get ());
|
||||
+
|
||||
if (bfd != nullptr)
|
||||
bfd_close (bfd);
|
||||
return;
|
@ -1,107 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Buettner <kevinb@redhat.com>
|
||||
Date: Wed, 3 May 2023 11:28:24 -0700
|
||||
Subject: gdb-rhbz2192105-ftbs-dangling-pointer
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
;; Backport upstream patch fixing a "dangling pointer" build problem
|
||||
;; first seen when building with GCC 13.1.1 20230426 (Red Hat ;; 13.1.1-1).
|
||||
|
||||
Pass const frame_info_ptr reference for skip_[language_]trampoline
|
||||
|
||||
g++ 13.1.1 produces a -Werror=dangling-pointer=
|
||||
|
||||
In file included from ../../binutils-gdb/gdb/frame.h:75,
|
||||
from ../../binutils-gdb/gdb/symtab.h:40,
|
||||
from ../../binutils-gdb/gdb/language.c:33:
|
||||
In member function ‘void intrusive_list<T, AsNode>::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’,
|
||||
inlined from ‘void intrusive_list<T, AsNode>::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’ at gdbsupport/intrusive_list.h:332:24,
|
||||
inlined from ‘frame_info_ptr::frame_info_ptr(const frame_info_ptr&)’ at gdb/frame.h:241:26,
|
||||
inlined from ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’ at gdb/language.c:530:49:
|
||||
gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable ‘<anonymous>’ in ‘frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::m_back’ [-Werror=dangling-pointer=]
|
||||
415 | m_back = &elem;
|
||||
| ~~~~~~~^~~~~~~
|
||||
gdb/language.c: In function ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’:
|
||||
gdb/language.c:530:49: note: ‘<anonymous>’ declared here
|
||||
530 | CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
|
||||
gdb/frame.h:359:41: note: ‘frame_info_ptr::frame_list’ declared here
|
||||
359 | static intrusive_list<frame_info_ptr> frame_list;
|
||||
| ^~~~~~~~~~
|
||||
|
||||
Each new frame_info_ptr is being pushed on a static frame list and g++
|
||||
cannot see why that is safe in case the frame_info_ptr is created and
|
||||
destroyed immediately when passed as value.
|
||||
|
||||
It isn't clear why only in this one place g++ sees the issue (probably
|
||||
because it can inline enough code in this specific case).
|
||||
|
||||
Since passing the frame_info_ptr as const reference is cheaper, use
|
||||
that as workaround for this warning.
|
||||
|
||||
PR build/30413
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413
|
||||
|
||||
Tested-by: Kevin Buettner <kevinb@redhat.com>
|
||||
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
|
||||
Reviewed-by: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
|
||||
--- a/gdb/c-lang.c
|
||||
+++ b/gdb/c-lang.c
|
||||
@@ -1003,7 +1003,7 @@ class cplus_language : public language_defn
|
||||
|
||||
/* See language.h. */
|
||||
|
||||
- CORE_ADDR skip_trampoline (frame_info_ptr fi,
|
||||
+ CORE_ADDR skip_trampoline (const frame_info_ptr &fi,
|
||||
CORE_ADDR pc) const override
|
||||
{
|
||||
return cplus_skip_trampoline (fi, pc);
|
||||
diff --git a/gdb/language.c b/gdb/language.c
|
||||
--- a/gdb/language.c
|
||||
+++ b/gdb/language.c
|
||||
@@ -528,7 +528,7 @@ add_set_language_command ()
|
||||
Return the result from the first that returns non-zero, or 0 if all
|
||||
`fail'. */
|
||||
CORE_ADDR
|
||||
-skip_language_trampoline (frame_info_ptr frame, CORE_ADDR pc)
|
||||
+skip_language_trampoline (const frame_info_ptr &frame, CORE_ADDR pc)
|
||||
{
|
||||
for (const auto &lang : language_defn::languages)
|
||||
{
|
||||
diff --git a/gdb/language.h b/gdb/language.h
|
||||
--- a/gdb/language.h
|
||||
+++ b/gdb/language.h
|
||||
@@ -471,7 +471,7 @@ struct language_defn
|
||||
If that PC falls in a trampoline belonging to this language, return
|
||||
the address of the first pc in the real function, or 0 if it isn't a
|
||||
language tramp for this language. */
|
||||
- virtual CORE_ADDR skip_trampoline (frame_info_ptr fi, CORE_ADDR pc) const
|
||||
+ virtual CORE_ADDR skip_trampoline (const frame_info_ptr &fi, CORE_ADDR pc) const
|
||||
{
|
||||
return (CORE_ADDR) 0;
|
||||
}
|
||||
@@ -789,7 +789,7 @@ extern const char *language_str (enum language);
|
||||
|
||||
/* Check for a language-specific trampoline. */
|
||||
|
||||
-extern CORE_ADDR skip_language_trampoline (frame_info_ptr, CORE_ADDR pc);
|
||||
+extern CORE_ADDR skip_language_trampoline (const frame_info_ptr &, CORE_ADDR pc);
|
||||
|
||||
/* Return demangled language symbol, or NULL. */
|
||||
extern gdb::unique_xmalloc_ptr<char> language_demangle
|
||||
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
|
||||
--- a/gdb/objc-lang.c
|
||||
+++ b/gdb/objc-lang.c
|
||||
@@ -282,7 +282,7 @@ class objc_language : public language_defn
|
||||
|
||||
/* See language.h. */
|
||||
|
||||
- CORE_ADDR skip_trampoline (frame_info_ptr frame,
|
||||
+ CORE_ADDR skip_trampoline (const frame_info_ptr &frame,
|
||||
CORE_ADDR stop_pc) const override
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
@ -1,188 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Burgess <aburgess@redhat.com>
|
||||
Date: Tue, 20 Jun 2023 09:46:35 +0100
|
||||
Subject: gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch
|
||||
|
||||
;; Backport upstream commit f3eee5861743d635 to fix a crash triggered
|
||||
;; when debuginfod makes use of particular openssl settings.
|
||||
|
||||
gdb/debuginfod: cleanup debuginfod earlier
|
||||
|
||||
A GDB crash was discovered on Fedora GDB that was tracked back to an
|
||||
issue with the way that debuginfod is cleaned up.
|
||||
|
||||
The bug was reported on Fedora 37, 38, and 39. Here are the steps to
|
||||
reproduce:
|
||||
|
||||
1. The file /etc/ssl/openssl.cnf contains the following lines:
|
||||
|
||||
[provider_sect]
|
||||
default = default_sect
|
||||
##legacy = legacy_sect
|
||||
##
|
||||
[default_sect]
|
||||
activate = 1
|
||||
|
||||
##[legacy_sect]
|
||||
##activate = 1
|
||||
|
||||
The bug will occur when the '##' characters are removed so that the
|
||||
lines in question look like this:
|
||||
|
||||
[provider_sect]
|
||||
default = default_sect
|
||||
legacy = legacy_sect
|
||||
|
||||
[default_sect]
|
||||
activate = 1
|
||||
|
||||
[legacy_sect]
|
||||
activate = 1
|
||||
|
||||
2. Clean up any existing debuginfod cache data:
|
||||
|
||||
> rm -rf $HOME/.cache/debuginfod_client
|
||||
|
||||
3. Run GDB:
|
||||
|
||||
> gdb -nx -q -iex 'set trace-commands on' \
|
||||
-iex 'set debuginfod enabled on' \
|
||||
-iex 'set confirm off' \
|
||||
-ex 'start' -ex 'quit' /bin/ls
|
||||
+set debuginfod enabled on
|
||||
+set confirm off
|
||||
Reading symbols from /bin/ls...
|
||||
Downloading separate debug info for /usr/bin/ls
|
||||
... snip ...
|
||||
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffde38) at ../src/ls.c:1646
|
||||
1646 {
|
||||
+quit
|
||||
|
||||
Fatal signal: Segmentation fault
|
||||
----- Backtrace -----
|
||||
... snip ...
|
||||
|
||||
So GDB ends up crashing during exit.
|
||||
|
||||
What's happening is that when debuginfod is initialised
|
||||
debuginfod_begin is called (this is in the debuginfod library), this
|
||||
in turn sets up libcurl, which makes use of openssl. Somewhere during
|
||||
this setup process an at_exit function is registered to cleanup some
|
||||
state.
|
||||
|
||||
Back in GDB the debuginfod_client object is managed using this code:
|
||||
|
||||
/* Deleter for a debuginfod_client. */
|
||||
|
||||
struct debuginfod_client_deleter
|
||||
{
|
||||
void operator() (debuginfod_client *c)
|
||||
{
|
||||
debuginfod_end (c);
|
||||
}
|
||||
};
|
||||
|
||||
using debuginfod_client_up
|
||||
= std::unique_ptr<debuginfod_client, debuginfod_client_deleter>;
|
||||
|
||||
And then a global debuginfod_client_up is created to hold a pointer to
|
||||
the debuginfod_client object. As a global this will be cleaned up
|
||||
using the standard C++ global object destructor mechanism, which is
|
||||
run after the at_exit handlers.
|
||||
|
||||
However, it is expected that when debuginfod_end is called the
|
||||
debuginfod_client object will still be in a usable state, that is, we
|
||||
don't expect the at_exit handlers to have run and started cleaning up
|
||||
the library state.
|
||||
|
||||
To fix this issue we need to ensure that debuginfod_end is called
|
||||
before the at_exit handlers have a chance to run.
|
||||
|
||||
This commit removes the debuginfod_client_up type, and instead has GDB
|
||||
hold a raw pointer to the debuginfod_client object. We then make use
|
||||
of GDB's make_final_cleanup to register a function that will call
|
||||
debuginfod_end.
|
||||
|
||||
As GDB's final cleanups are called before exit is called, this means
|
||||
that debuginfod_end will be called before the at_exit handlers are
|
||||
called, and the crash identified above is resolved.
|
||||
|
||||
It's not obvious how this issue can easily be tested for. The bug does
|
||||
not appear to manifest when using a local debuginfod server, so we'd
|
||||
need to setup something more involved. For now I'm proposing this
|
||||
patch without any associated tests.
|
||||
|
||||
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
|
||||
--- a/gdb/debuginfod-support.c
|
||||
+++ b/gdb/debuginfod-support.c
|
||||
@@ -96,20 +96,6 @@ struct user_data
|
||||
ui_out::progress_update progress;
|
||||
};
|
||||
|
||||
-/* Deleter for a debuginfod_client. */
|
||||
-
|
||||
-struct debuginfod_client_deleter
|
||||
-{
|
||||
- void operator() (debuginfod_client *c)
|
||||
- {
|
||||
- debuginfod_end (c);
|
||||
- }
|
||||
-};
|
||||
-
|
||||
-using debuginfod_client_up
|
||||
- = std::unique_ptr<debuginfod_client, debuginfod_client_deleter>;
|
||||
-
|
||||
-
|
||||
/* Convert SIZE into a unit suitable for use with progress updates.
|
||||
SIZE should in given in bytes and will be converted into KB, MB, GB
|
||||
or remain unchanged. UNIT will be set to "B", "KB", "MB" or "GB"
|
||||
@@ -180,20 +166,45 @@ progressfn (debuginfod_client *c, long cur, long total)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+/* Cleanup ARG, which is a debuginfod_client pointer. */
|
||||
+
|
||||
+static void
|
||||
+cleanup_debuginfod_client (void *arg)
|
||||
+{
|
||||
+ debuginfod_client *client = static_cast<debuginfod_client *> (arg);
|
||||
+ debuginfod_end (client);
|
||||
+}
|
||||
+
|
||||
+/* Return a pointer to the single global debuginfod_client, initialising it
|
||||
+ first if needed. */
|
||||
+
|
||||
static debuginfod_client *
|
||||
get_debuginfod_client ()
|
||||
{
|
||||
- static debuginfod_client_up global_client;
|
||||
+ static debuginfod_client *global_client = nullptr;
|
||||
|
||||
if (global_client == nullptr)
|
||||
{
|
||||
- global_client.reset (debuginfod_begin ());
|
||||
+ global_client = debuginfod_begin ();
|
||||
|
||||
if (global_client != nullptr)
|
||||
- debuginfod_set_progressfn (global_client.get (), progressfn);
|
||||
+ {
|
||||
+ /* It is important that we cleanup the debuginfod_client object
|
||||
+ before calling exit. Some of the libraries used by debuginfod
|
||||
+ make use of at_exit handlers to perform cleanup.
|
||||
+
|
||||
+ If we wrapped the debuginfod_client in a unique_ptr and relied
|
||||
+ on its destructor to cleanup then this would be run as part of
|
||||
+ the global C++ object destructors, which is after the at_exit
|
||||
+ handlers, which is too late.
|
||||
+
|
||||
+ So instead, we make use of GDB's final cleanup mechanism. */
|
||||
+ make_final_cleanup (cleanup_debuginfod_client, global_client);
|
||||
+ debuginfod_set_progressfn (global_client, progressfn);
|
||||
+ }
|
||||
}
|
||||
|
||||
- return global_client.get ();
|
||||
+ return global_client;
|
||||
}
|
||||
|
||||
/* Check if debuginfod is enabled. If configured to do so, ask the user
|
77
gdb-rhbz2232086-refactor-selftest-support.patch
Normal file
77
gdb-rhbz2232086-refactor-selftest-support.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Burgess <aburgess@redhat.com>
|
||||
Date: Fri, 24 Nov 2023 11:10:08 +0000
|
||||
Subject: gdb-rhbz2232086-refactor-selftest-support.patch
|
||||
|
||||
;; Back-port upstream commit 1f0fab7ff86 as part of a fix for
|
||||
;; non-deterministic gdb-index generation (RH BZ 2232086).
|
||||
|
||||
gdb/testsuite: small refactor in selftest-support.exp
|
||||
|
||||
Split out the code that makes a copy of the GDB executable ready for
|
||||
self testing into a new proc. A later commit in this series wants to
|
||||
load the GDB executable into GDB (for creating an on-disk debug
|
||||
index), but doesn't need to make use of the full do_self_tests proc.
|
||||
|
||||
There should be no changes in what is tested after this commit.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
|
||||
--- a/gdb/testsuite/lib/selftest-support.exp
|
||||
+++ b/gdb/testsuite/lib/selftest-support.exp
|
||||
@@ -92,11 +92,13 @@ proc selftest_setup { executable function } {
|
||||
return 0
|
||||
}
|
||||
|
||||
-# A simple way to run some self-tests.
|
||||
-
|
||||
-proc do_self_tests {function body} {
|
||||
- global GDB tool
|
||||
-
|
||||
+# Prepare for running a self-test by moving the GDB executable to a
|
||||
+# location where we can use it as the inferior. Return the filename
|
||||
+# of the new location.
|
||||
+#
|
||||
+# If the current testing setup is not suitable for running a
|
||||
+# self-test, then return an empty string.
|
||||
+proc selftest_prepare {} {
|
||||
# Are we testing with a remote board? In that case, the target
|
||||
# won't have access to the GDB's auxilliary data files
|
||||
# (data-directory, etc.). It's simpler to just skip.
|
||||
@@ -120,19 +122,31 @@ proc do_self_tests {function body} {
|
||||
# Run the test with self. Copy the file executable file in case
|
||||
# this OS doesn't like to edit its own text space.
|
||||
|
||||
- set GDB_FULLPATH [find_gdb $GDB]
|
||||
+ set gdb_fullpath [find_gdb $::GDB]
|
||||
|
||||
if {[is_remote host]} {
|
||||
- set xgdb x$tool
|
||||
+ set xgdb x$::tool
|
||||
} else {
|
||||
- set xgdb [standard_output_file x$tool]
|
||||
+ set xgdb [standard_output_file x$::tool]
|
||||
}
|
||||
|
||||
# Remove any old copy lying around.
|
||||
remote_file host delete $xgdb
|
||||
|
||||
+ set filename [remote_download host $gdb_fullpath $xgdb]
|
||||
+
|
||||
+ return $filename
|
||||
+}
|
||||
+
|
||||
+# A simple way to run some self-tests.
|
||||
+
|
||||
+proc do_self_tests {function body} {
|
||||
+ set file [selftest_prepare]
|
||||
+ if { $file eq "" } {
|
||||
+ return
|
||||
+ }
|
||||
+
|
||||
gdb_start
|
||||
- set file [remote_download host $GDB_FULLPATH $xgdb]
|
||||
|
||||
# When debugging GDB with GDB, some operations can take a relatively long
|
||||
# time, especially if the build is non-optimized. Bump the timeout for the
|
@ -1,50 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
|
||||
Date: Thu, 21 Sep 2023 18:52:49 +0200
|
||||
Subject: gdb-rhbz2233961-CVE-2022-4806.patch
|
||||
|
||||
;; Backport PR29922, SHT_NOBITS section
|
||||
;; avoids section size sanity check.
|
||||
|
||||
PR29922, SHT_NOBITS section avoids section size sanity check
|
||||
|
||||
PR 29922
|
||||
* dwarf2.c (find_debug_info): Ignore sections without
|
||||
SEC_HAS_CONTENTS.
|
||||
|
||||
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
|
||||
--- a/bfd/dwarf2.c
|
||||
+++ b/bfd/dwarf2.c
|
||||
@@ -4831,16 +4831,19 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections,
|
||||
{
|
||||
look = debug_sections[debug_info].uncompressed_name;
|
||||
msec = bfd_get_section_by_name (abfd, look);
|
||||
- if (msec != NULL)
|
||||
+ /* Testing SEC_HAS_CONTENTS is an anti-fuzzer measure. Of
|
||||
+ course debug sections always have contents. */
|
||||
+ if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0)
|
||||
return msec;
|
||||
|
||||
look = debug_sections[debug_info].compressed_name;
|
||||
msec = bfd_get_section_by_name (abfd, look);
|
||||
- if (msec != NULL)
|
||||
+ if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0)
|
||||
return msec;
|
||||
|
||||
for (msec = abfd->sections; msec != NULL; msec = msec->next)
|
||||
- if (startswith (msec->name, GNU_LINKONCE_INFO))
|
||||
+ if ((msec->flags & SEC_HAS_CONTENTS) != 0
|
||||
+ && startswith (msec->name, GNU_LINKONCE_INFO))
|
||||
return msec;
|
||||
|
||||
return NULL;
|
||||
@@ -4848,6 +4851,9 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections,
|
||||
|
||||
for (msec = after_sec->next; msec != NULL; msec = msec->next)
|
||||
{
|
||||
+ if ((msec->flags & SEC_HAS_CONTENTS) == 0)
|
||||
+ continue;
|
||||
+
|
||||
look = debug_sections[debug_info].uncompressed_name;
|
||||
if (strcmp (msec->name, look) == 0)
|
||||
return msec;
|
@ -1,115 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
|
||||
Date: Sat, 14 Oct 2023 12:37:50 +0200
|
||||
Subject: gdb-rhbz2233965-memory-leak.patch
|
||||
|
||||
;; Backport PR29925, Memory leak in find_abstract_instance
|
||||
|
||||
PR29925, Memory leak in find_abstract_instance
|
||||
|
||||
The testcase in the PR had a variable with both DW_AT_decl_file and
|
||||
DW_AT_specification, where the DW_AT_specification also specified
|
||||
DW_AT_decl_file. This leads to a memory leak as the file name is
|
||||
malloced and duplicates are not expected.
|
||||
|
||||
I've also changed find_abstract_instance to not use a temp for "name",
|
||||
because that can result in a change in behaviour from the usual last
|
||||
of duplicate attributes wins.
|
||||
|
||||
PR 29925
|
||||
* dwarf2.c (find_abstract_instance): Delete "name" variable.
|
||||
Free *filename_ptr before assigning new file name.
|
||||
(scan_unit_for_symbols): Similarly free func->file and
|
||||
var->file before assigning.
|
||||
|
||||
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
|
||||
--- a/bfd/dwarf2.c
|
||||
+++ b/bfd/dwarf2.c
|
||||
@@ -3441,7 +3441,6 @@ find_abstract_instance (struct comp_unit *unit,
|
||||
struct abbrev_info *abbrev;
|
||||
uint64_t die_ref = attr_ptr->u.val;
|
||||
struct attribute attr;
|
||||
- const char *name = NULL;
|
||||
|
||||
if (recur_count == 100)
|
||||
{
|
||||
@@ -3602,9 +3601,9 @@ find_abstract_instance (struct comp_unit *unit,
|
||||
case DW_AT_name:
|
||||
/* Prefer DW_AT_MIPS_linkage_name or DW_AT_linkage_name
|
||||
over DW_AT_name. */
|
||||
- if (name == NULL && is_str_form (&attr))
|
||||
+ if (*pname == NULL && is_str_form (&attr))
|
||||
{
|
||||
- name = attr.u.str;
|
||||
+ *pname = attr.u.str;
|
||||
if (mangle_style (unit->lang) == 0)
|
||||
*is_linkage = true;
|
||||
}
|
||||
@@ -3612,7 +3611,7 @@ find_abstract_instance (struct comp_unit *unit,
|
||||
case DW_AT_specification:
|
||||
if (is_int_form (&attr)
|
||||
&& !find_abstract_instance (unit, &attr, recur_count + 1,
|
||||
- &name, is_linkage,
|
||||
+ pname, is_linkage,
|
||||
filename_ptr, linenumber_ptr))
|
||||
return false;
|
||||
break;
|
||||
@@ -3622,7 +3621,7 @@ find_abstract_instance (struct comp_unit *unit,
|
||||
non-string forms into these attributes. */
|
||||
if (is_str_form (&attr))
|
||||
{
|
||||
- name = attr.u.str;
|
||||
+ *pname = attr.u.str;
|
||||
*is_linkage = true;
|
||||
}
|
||||
break;
|
||||
@@ -3630,8 +3629,11 @@ find_abstract_instance (struct comp_unit *unit,
|
||||
if (!comp_unit_maybe_decode_line_info (unit))
|
||||
return false;
|
||||
if (is_int_form (&attr))
|
||||
- *filename_ptr = concat_filename (unit->line_table,
|
||||
- attr.u.val);
|
||||
+ {
|
||||
+ free (*filename_ptr);
|
||||
+ *filename_ptr = concat_filename (unit->line_table,
|
||||
+ attr.u.val);
|
||||
+ }
|
||||
break;
|
||||
case DW_AT_decl_line:
|
||||
if (is_int_form (&attr))
|
||||
@@ -3643,7 +3645,6 @@ find_abstract_instance (struct comp_unit *unit,
|
||||
}
|
||||
}
|
||||
}
|
||||
- *pname = name;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4139,8 +4140,11 @@ scan_unit_for_symbols (struct comp_unit *unit)
|
||||
|
||||
case DW_AT_decl_file:
|
||||
if (is_int_form (&attr))
|
||||
- func->file = concat_filename (unit->line_table,
|
||||
- attr.u.val);
|
||||
+ {
|
||||
+ free (func->file);
|
||||
+ func->file = concat_filename (unit->line_table,
|
||||
+ attr.u.val);
|
||||
+ }
|
||||
break;
|
||||
|
||||
case DW_AT_decl_line:
|
||||
@@ -4182,8 +4186,11 @@ scan_unit_for_symbols (struct comp_unit *unit)
|
||||
|
||||
case DW_AT_decl_file:
|
||||
if (is_int_form (&attr))
|
||||
- var->file = concat_filename (unit->line_table,
|
||||
- attr.u.val);
|
||||
+ {
|
||||
+ free (var->file);
|
||||
+ var->file = concat_filename (unit->line_table,
|
||||
+ attr.u.val);
|
||||
+ }
|
||||
break;
|
||||
|
||||
case DW_AT_decl_line:
|
48
gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
Normal file
48
gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
Normal file
@ -0,0 +1,48 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
|
||||
Date: Mon, 8 Jan 2024 13:24:05 +0100
|
||||
Subject: gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
|
||||
|
||||
gdb/python: avoid use of _PyOS_ReadlineTState
|
||||
|
||||
In python/py-gdb-readline.c we make use of _PyOS_ReadlineTState,
|
||||
however, this variable is no longer public in Python 3.13, and so GDB
|
||||
no longer builds.
|
||||
|
||||
We are making use of _PyOS_ReadlineTState in order to re-acquire the
|
||||
Python Global Interpreter Lock (GIL). The _PyOS_ReadlineTState
|
||||
variable is set in Python's outer readline code prior to calling the
|
||||
user (GDB) supplied readline callback function, which for us is
|
||||
gdbpy_readline_wrapper. The gdbpy_readline_wrapper function is called
|
||||
without the GIL held.
|
||||
|
||||
Instead of using _PyOS_ReadlineTState, I propose that we switch to
|
||||
calling PyGILState_Ensure() and PyGILState_Release(). These functions
|
||||
will acquire the GIL based on the current thread. I think this should
|
||||
be sufficient; I can't imagine why we'd be running
|
||||
gdbpy_readline_wrapper on one thread on behalf of a different Python
|
||||
thread.... that would be unexpected I think.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
|
||||
--- a/gdb/python/py-gdb-readline.c
|
||||
+++ b/gdb/python/py-gdb-readline.c
|
||||
@@ -56,13 +56,11 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
|
||||
if (except.reason == RETURN_QUIT)
|
||||
return NULL;
|
||||
|
||||
- /* The thread state is nulled during gdbpy_readline_wrapper,
|
||||
- with the original value saved in the following undocumented
|
||||
- variable (see Python's Parser/myreadline.c and
|
||||
- Modules/readline.c). */
|
||||
- PyEval_RestoreThread (_PyOS_ReadlineTState);
|
||||
+
|
||||
+ /* This readline callback is called without the GIL held. */
|
||||
+ gdbpy_gil gil;
|
||||
+
|
||||
gdbpy_convert_exception (except);
|
||||
- PyEval_SaveThread ();
|
||||
return NULL;
|
||||
}
|
||||
|
81
gdb-rhbz2250652-gdbpy_gil.patch
Normal file
81
gdb-rhbz2250652-gdbpy_gil.patch
Normal file
@ -0,0 +1,81 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
|
||||
Date: Mon, 8 Jan 2024 13:12:15 +0100
|
||||
Subject: gdb-rhbz2250652-gdbpy_gil.patch
|
||||
|
||||
gdb: move gdbpy_gil into python-internal.h
|
||||
|
||||
Move gdbpy_gil class into python-internal.h, the next
|
||||
commit wants to make use of this class from a file other
|
||||
than python.c.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
|
||||
--- a/gdb/python/python-internal.h
|
||||
+++ b/gdb/python/python-internal.h
|
||||
@@ -754,6 +754,30 @@ class gdbpy_allow_threads
|
||||
PyThreadState *m_save;
|
||||
};
|
||||
|
||||
+/* A helper class to save and restore the GIL, but without touching
|
||||
+ the other globals that are handled by gdbpy_enter. */
|
||||
+
|
||||
+class gdbpy_gil
|
||||
+{
|
||||
+public:
|
||||
+
|
||||
+ gdbpy_gil ()
|
||||
+ : m_state (PyGILState_Ensure ())
|
||||
+ {
|
||||
+ }
|
||||
+
|
||||
+ ~gdbpy_gil ()
|
||||
+ {
|
||||
+ PyGILState_Release (m_state);
|
||||
+ }
|
||||
+
|
||||
+ DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
|
||||
+
|
||||
+private:
|
||||
+
|
||||
+ PyGILState_STATE m_state;
|
||||
+};
|
||||
+
|
||||
/* Use this after a TRY_EXCEPT to throw the appropriate Python
|
||||
exception. */
|
||||
#define GDB_PY_HANDLE_EXCEPTION(Exception) \
|
||||
diff --git a/gdb/python/python.c b/gdb/python/python.c
|
||||
--- a/gdb/python/python.c
|
||||
+++ b/gdb/python/python.c
|
||||
@@ -257,30 +257,6 @@ gdbpy_enter::finalize ()
|
||||
python_gdbarch = target_gdbarch ();
|
||||
}
|
||||
|
||||
-/* A helper class to save and restore the GIL, but without touching
|
||||
- the other globals that are handled by gdbpy_enter. */
|
||||
-
|
||||
-class gdbpy_gil
|
||||
-{
|
||||
-public:
|
||||
-
|
||||
- gdbpy_gil ()
|
||||
- : m_state (PyGILState_Ensure ())
|
||||
- {
|
||||
- }
|
||||
-
|
||||
- ~gdbpy_gil ()
|
||||
- {
|
||||
- PyGILState_Release (m_state);
|
||||
- }
|
||||
-
|
||||
- DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
|
||||
-
|
||||
-private:
|
||||
-
|
||||
- PyGILState_STATE m_state;
|
||||
-};
|
||||
-
|
||||
/* Set the quit flag. */
|
||||
|
||||
static void
|
55
gdb-rhbz2261580-intrusive_list-assertion-fix.patch
Normal file
55
gdb-rhbz2261580-intrusive_list-assertion-fix.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Buettner <kevinb@redhat.com>
|
||||
Date: Mon, 29 Jan 2024 14:51:22 -0700
|
||||
Subject: gdb-rhbz2261580-intrusive_list-assertion-fix.patch
|
||||
|
||||
;; Backport upstream workaround for GCC 14 problem which cause assertion
|
||||
;; failures in GDB.
|
||||
|
||||
[gdb/build] Workaround gcc PR113599
|
||||
|
||||
Since gcc commit d3f48f68227 ("c++: non-dependent .* operand folding
|
||||
[PR112427]"), with gdb we run into PR gcc/113599 [1], a wrong-code bug, as
|
||||
reported in PR build/31281.
|
||||
|
||||
Work around this by flipping inherit order:
|
||||
...
|
||||
-class thread_info : public refcounted_object,
|
||||
- public intrusive_list_node<thread_info>
|
||||
+class thread_info : public intrusive_list_node<thread_info>,
|
||||
+ public refcounted_object
|
||||
...
|
||||
|
||||
An argument could be made that this isn't necessary, because this occurred in
|
||||
an unreleased gcc version.
|
||||
|
||||
However, I think it could be useful when bisecting gcc for other problems in
|
||||
building gdb. Having this workaround means the bisect won't reintroduce the
|
||||
problem. Furthermore, the workaround is harmless.
|
||||
|
||||
Tested on Fedora rawhide x86_64.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31281
|
||||
|
||||
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113599
|
||||
|
||||
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
|
||||
--- a/gdb/gdbthread.h
|
||||
+++ b/gdb/gdbthread.h
|
||||
@@ -242,10 +242,11 @@ using private_thread_info_up = std::unique_ptr<private_thread_info>;
|
||||
strong reference, and is thus not accounted for in the thread's
|
||||
refcount.
|
||||
|
||||
- The intrusive_list_node base links threads in a per-inferior list. */
|
||||
+ The intrusive_list_node base links threads in a per-inferior list.
|
||||
+ We place it first in the inherit order to work around PR gcc/113599. */
|
||||
|
||||
-class thread_info : public refcounted_object,
|
||||
- public intrusive_list_node<thread_info>
|
||||
+class thread_info : public intrusive_list_node<thread_info>,
|
||||
+ public refcounted_object
|
||||
{
|
||||
public:
|
||||
explicit thread_info (inferior *inf, ptid_t ptid);
|
@ -1,731 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Fedora GDB patches <invalid@email.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
|
||||
|
||||
;; Include testcase for `Unable to see a variable inside a module (XLF)' (BZ 823789).
|
||||
;;=fedoratest
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.fortran/xlf-variable.S b/gdb/testsuite/gdb.fortran/xlf-variable.S
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.fortran/xlf-variable.S
|
||||
@@ -0,0 +1,638 @@
|
||||
+/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
+
|
||||
+ This file is part of GDB.
|
||||
+
|
||||
+ 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/>. */
|
||||
+
|
||||
+/* This file has been generated from the file named `xlf-variable.f', which
|
||||
+ should be present in this directory. The command used to generate this
|
||||
+ file was:
|
||||
+
|
||||
+ xlf -qnoopt -g9 -S xlf-variable.f -o xlf-variable.S
|
||||
+
|
||||
+ After issuing this command, you must hand-edit this file and remove the
|
||||
+ mentions for `_xlfExit', since it is only present in XLF-specific
|
||||
+ libraries. You must also make sure to remove the file named `mod1.mod'
|
||||
+ which will be created in the compilation directory.
|
||||
+
|
||||
+ In order to generated this file, the following XLF package was used:
|
||||
+
|
||||
+ xlf.14.1.0.0.linux.eval.tar.gz
|
||||
+
|
||||
+ These instructions may be different for different versions of the XLF
|
||||
+ compiler. */
|
||||
+
|
||||
+.set r0,0; .set SP,1; .set RTOC,2; .set r3,3; .set r4,4
|
||||
+.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
|
||||
+.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
|
||||
+.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
|
||||
+.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
|
||||
+.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
|
||||
+.set r30,30; .set r31,31
|
||||
+.set fp0,0; .set fp1,1; .set fp2,2; .set fp3,3; .set fp4,4
|
||||
+.set fp5,5; .set fp6,6; .set fp7,7; .set fp8,8; .set fp9,9
|
||||
+.set fp10,10; .set fp11,11; .set fp12,12; .set fp13,13; .set fp14,14
|
||||
+.set fp15,15; .set fp16,16; .set fp17,17; .set fp18,18; .set fp19,19
|
||||
+.set fp20,20; .set fp21,21; .set fp22,22; .set fp23,23; .set fp24,24
|
||||
+.set fp25,25; .set fp26,26; .set fp27,27; .set fp28,28; .set fp29,29
|
||||
+.set fp30,30; .set fp31,31
|
||||
+.set v0,0; .set v1,1; .set v2,2; .set v3,3; .set v4,4
|
||||
+.set v5,5; .set v6,6; .set v7,7; .set v8,8; .set v9,9
|
||||
+.set v10,10; .set v11,11; .set v12,12; .set v13,13; .set v14,14
|
||||
+.set v15,15; .set v16,16; .set v17,17; .set v18,18; .set v19,19
|
||||
+.set v20,20; .set v21,21; .set v22,22; .set v23,23; .set v24,24
|
||||
+.set v25,25; .set v26,26; .set v27,27; .set v28,28; .set v29,29
|
||||
+.set v30,30; .set v31,31
|
||||
+.set q0,0; .set q1,1; .set q2,2; .set q3,3; .set q4,4
|
||||
+.set q5,5; .set q6,6; .set q7,7; .set q8,8; .set q9,9
|
||||
+.set q10,10; .set q11,11; .set q12,12; .set q13,13; .set q14,14
|
||||
+.set q15,15; .set q16,16; .set q17,17; .set q18,18; .set q19,19
|
||||
+.set q20,20; .set q21,21; .set q22,22; .set q23,23; .set q24,24
|
||||
+.set q25,25; .set q26,26; .set q27,27; .set q28,28; .set q29,29
|
||||
+.set q30,30; .set q31,31
|
||||
+.set MQ,0; .set XER,1; .set FROM_RTCU,4; .set FROM_RTCL,5; .set FROM_DEC,6
|
||||
+.set LR,8; .set CTR,9; .set TID,17; .set DSISR,18; .set DAR,19; .set TO_RTCU,20
|
||||
+.set TO_RTCL,21; .set TO_DEC,22; .set SDR_0,24; .set SDR_1,25; .set SRR_0,26
|
||||
+.set SRR_1,27
|
||||
+.set BO_dCTR_NZERO_AND_NOT,0; .set BO_dCTR_NZERO_AND_NOT_1,1
|
||||
+.set BO_dCTR_ZERO_AND_NOT,2; .set BO_dCTR_ZERO_AND_NOT_1,3
|
||||
+.set BO_IF_NOT,4; .set BO_IF_NOT_1,5; .set BO_IF_NOT_2,6
|
||||
+.set BO_IF_NOT_3,7; .set BO_dCTR_NZERO_AND,8; .set BO_dCTR_NZERO_AND_1,9
|
||||
+.set BO_dCTR_ZERO_AND,10; .set BO_dCTR_ZERO_AND_1,11; .set BO_IF,12
|
||||
+.set BO_IF_1,13; .set BO_IF_2,14; .set BO_IF_3,15; .set BO_dCTR_NZERO,16
|
||||
+.set BO_dCTR_NZERO_1,17; .set BO_dCTR_ZERO,18; .set BO_dCTR_ZERO_1,19
|
||||
+.set BO_ALWAYS,20; .set BO_ALWAYS_1,21; .set BO_ALWAYS_2,22
|
||||
+.set BO_ALWAYS_3,23; .set BO_dCTR_NZERO_8,24; .set BO_dCTR_NZERO_9,25
|
||||
+.set BO_dCTR_ZERO_8,26; .set BO_dCTR_ZERO_9,27; .set BO_ALWAYS_8,28
|
||||
+.set BO_ALWAYS_9,29; .set BO_ALWAYS_10,30; .set BO_ALWAYS_11,31
|
||||
+.set CR0_LT,0; .set CR0_GT,1; .set CR0_EQ,2; .set CR0_SO,3
|
||||
+.set CR1_FX,4; .set CR1_FEX,5; .set CR1_VX,6; .set CR1_OX,7
|
||||
+.set CR2_LT,8; .set CR2_GT,9; .set CR2_EQ,10; .set CR2_SO,11
|
||||
+.set CR3_LT,12; .set CR3_GT,13; .set CR3_EQ,14; .set CR3_SO,15
|
||||
+.set CR4_LT,16; .set CR4_GT,17; .set CR4_EQ,18; .set CR4_SO,19
|
||||
+.set CR5_LT,20; .set CR5_GT,21; .set CR5_EQ,22; .set CR5_SO,23
|
||||
+.set CR6_LT,24; .set CR6_GT,25; .set CR6_EQ,26; .set CR6_SO,27
|
||||
+.set CR7_LT,28; .set CR7_GT,29; .set CR7_EQ,30; .set CR7_SO,31
|
||||
+.set TO_LT,16; .set TO_GT,8; .set TO_EQ,4; .set TO_LLT,2; .set TO_LGT,1
|
||||
+
|
||||
+ .file "xlf-variable.f"
|
||||
+ .globl __mod1_NMOD_____mod1
|
||||
+ .type __mod1_NMOD_____mod1,@function
|
||||
+ .size __mod1_NMOD_____mod1,32
|
||||
+ .globl main
|
||||
+ .type main,@function
|
||||
+ .size main,68
|
||||
+ .globl __mod1_NMOD_sub1
|
||||
+ .type __mod1_NMOD_sub1,@function
|
||||
+ .size __mod1_NMOD_sub1,136
|
||||
+ .globl _main
|
||||
+ .type _main,@function
|
||||
+ .size _main,68
|
||||
+
|
||||
+ .section ".text"
|
||||
+ .align 7
|
||||
+.LC.text:
|
||||
+__mod1_NMOD_____mod1:
|
||||
+ stwu SP,-32(SP)
|
||||
+ stw r31,28(SP)
|
||||
+ or r31,SP,SP
|
||||
+ b $+0x4
|
||||
+ addi r11,r31,32
|
||||
+ lwz r31,-4(r11)
|
||||
+ or SP,r11,r11
|
||||
+ bclr BO_ALWAYS,CR0_LT
|
||||
+.LC.text32:
|
||||
+
|
||||
+__mod1_NMOD_sub1:
|
||||
+ stwu SP,-32(SP)
|
||||
+ stw r31,28(SP)
|
||||
+ stw r30,24(SP)
|
||||
+ or r31,SP,SP
|
||||
+ addis r30,r0,.const_dr@ha
|
||||
+ addi r30,r30,.const_dr@l
|
||||
+ addis r3,r0,__N_mod1@ha
|
||||
+ addi r3,r3,__N_mod1@l
|
||||
+ addi r0,r0,1
|
||||
+ stb r0,4(r3)
|
||||
+ addi r4,r0,14
|
||||
+ stb r4,5(r3)
|
||||
+ stb r0,7(r3)
|
||||
+ addis r5,r0,__N__mod1@ha
|
||||
+ addi r5,r5,__N__mod1@l
|
||||
+ stw r5,0(r3)
|
||||
+ lbz r5,6(r3)
|
||||
+ rlwinm r5,r5,0,25,25
|
||||
+ ori r5,r5,0x0040
|
||||
+ stb r5,6(r3)
|
||||
+ lwz r5,0(r3)
|
||||
+ lfs fp0,0(r30)
|
||||
+ stfs fp0,0(r5)
|
||||
+ stb r0,4(r3)
|
||||
+ stb r4,5(r3)
|
||||
+ addi r4,r0,0
|
||||
+ stb r4,6(r3)
|
||||
+ stb r0,7(r3)
|
||||
+ b $+0x4
|
||||
+ addi r11,r31,32
|
||||
+ lwz r30,-8(r11)
|
||||
+ lwz r31,-4(r11)
|
||||
+ or SP,r11,r11
|
||||
+ bclr BO_ALWAYS,CR0_LT
|
||||
+.LC.text168:
|
||||
+ .long 0
|
||||
+ .skip 0x54
|
||||
+.LC.text256:
|
||||
+
|
||||
+main:
|
||||
+_main:
|
||||
+ mfspr r0,LR
|
||||
+ stwu SP,-32(SP)
|
||||
+ stw r31,28(SP)
|
||||
+ stw r0,36(SP)
|
||||
+ or r31,SP,SP
|
||||
+ bl __mod1_NMOD_sub1
|
||||
+ addi r3,r0,0
|
||||
+.LC.text288:
|
||||
+
|
||||
+ tw TO_EQ,r14,r14
|
||||
+ addi r3,r0,0
|
||||
+ b $+0x4
|
||||
+ addi r11,r31,32
|
||||
+ lwz r31,-4(r11)
|
||||
+ lwz r0,4(r11)
|
||||
+ mtspr LR,r0
|
||||
+ or SP,r11,r11
|
||||
+ bclr BO_ALWAYS,CR0_LT
|
||||
+.LC.text324:
|
||||
+
|
||||
+
|
||||
+ .section ".rodata","a"
|
||||
+ .align 2
|
||||
+.LC.rodata:
|
||||
+ .type .const_dr,@object
|
||||
+ .size .const_dr,4
|
||||
+.const_dr:
|
||||
+ .long 0x40400000
|
||||
+
|
||||
+ .section ".eh_frame","wa"
|
||||
+ .align 2
|
||||
+.LC.eh_frame:
|
||||
+ .long 0x0000000c
|
||||
+ .long 0x00000000
|
||||
+ .long 0x0100047c
|
||||
+ .long 0x410c0100
|
||||
+ .long 0x0000001c
|
||||
+ .long 0x00000014
|
||||
+ .long .LC.text
|
||||
+ .long 0x00000020
|
||||
+ .long 0x410e2041
|
||||
+ .long 0x9f01410d
|
||||
+ .long 0x1f410a42
|
||||
+ .long 0xdf420b00
|
||||
+ .long 0x00000020
|
||||
+ .long 0x00000034
|
||||
+ .long .LC.text32
|
||||
+ .long 0x00000088
|
||||
+ .long 0x410e2041
|
||||
+ .long 0x9f01419e
|
||||
+ .long 0x02410d1f
|
||||
+ .long 0x590a42de
|
||||
+ .long 0x41df420b
|
||||
+ .long 0x0000000c
|
||||
+ .long 0x00000000
|
||||
+ .long 0x0100047c
|
||||
+ .long 0x410c0100
|
||||
+ .long 0x00000020
|
||||
+ .long 0x00000014
|
||||
+ .long .LC.text256
|
||||
+ .long 0x00000044
|
||||
+ .long 0x420e2041
|
||||
+ .long 0x9f014111
|
||||
+ .long 0x417f410d
|
||||
+ .long 0x1f460a42
|
||||
+ .long 0xdf440b00
|
||||
+
|
||||
+ .section ".data","wa"
|
||||
+ .align 4
|
||||
+.LC.data:
|
||||
+ .globl __N_mod1
|
||||
+ .type __N_mod1,@object
|
||||
+ .size __N_mod1,8
|
||||
+__N_mod1:
|
||||
+ .long 0x00000000
|
||||
+ .long 0x01000001
|
||||
+
|
||||
+ .section ".except.1","wa"
|
||||
+ .align 1
|
||||
+.LC.except.1:
|
||||
+ .long .LC.text288
|
||||
+ .byte 0x01
|
||||
+ .byte 0x09
|
||||
+
|
||||
+ .ident "Fri Jun 15 16:35:45 2012 .IBM XL Fortran for Linux, V14.1 (5765-J05, 5725-C75) Version 14.01.0000.0000.Fri Jun 15 16:35:45 2012 .IBM XL Fortran for Linux, V14.1 (5765-J05, 5725-C75) Version 14.01.0000.0000."
|
||||
+
|
||||
+ .section ".debug_aranges"
|
||||
+ .align 0
|
||||
+.LC.debug_aranges:
|
||||
+ .long 0x0000001c
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_info
|
||||
+ .long 0x04000000
|
||||
+ .byte 0x00
|
||||
+ .byte 0x00
|
||||
+ .long .LC.text
|
||||
+ .long 0x000000a8
|
||||
+ .long 0x00000000
|
||||
+ .long 0x00000000
|
||||
+ .long 0x0000001c
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_info273
|
||||
+ .long 0x04000000
|
||||
+ .byte 0x00
|
||||
+ .byte 0x00
|
||||
+ .long .LC.text256
|
||||
+ .long 0x00000044
|
||||
+ .long 0x00000000
|
||||
+ .long 0x00000000
|
||||
+
|
||||
+ .section ".debug_pubnames"
|
||||
+ .align 0
|
||||
+.LC.debug_pubnames:
|
||||
+ .long 0x0000002f
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_info
|
||||
+ .long 0x00000111
|
||||
+ .long 0x000000dc
|
||||
+ .long 0x79000000
|
||||
+ .long 0x00ec7a00
|
||||
+ .long 0x000000fc
|
||||
+ .long 0x5f5f6d6f
|
||||
+ .long 0x64315f4e
|
||||
+ .long 0x4d4f445f
|
||||
+ .long 0x73756231
|
||||
+ .long 0x00000000
|
||||
+ .long 0x00000000
|
||||
+ .byte 0x18
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_info273
|
||||
+ .long 0x00000127
|
||||
+ .long 0x0000010f
|
||||
+ .long 0x5f6d6169
|
||||
+ .long 0x6e000000
|
||||
+ .byte 0x00
|
||||
+ .byte 0x00
|
||||
+
|
||||
+ .section ".debug_info"
|
||||
+ .align 0
|
||||
+.LC.debug_info:
|
||||
+ .long 0x0000010d
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_abbrev
|
||||
+ .long 0x0401786c
|
||||
+ .long 0x662d7661
|
||||
+ .long 0x72696162
|
||||
+ .long 0x6c652e66
|
||||
+ .byte 0x00
|
||||
+ .long .LC.debug_line
|
||||
+ .long .LC.text
|
||||
+ .long .LC.text168
|
||||
+ .long 0x082f726f
|
||||
+ .long 0x6f742f73
|
||||
+ .long 0x65726769
|
||||
+ .long 0x6f646a2f
|
||||
+ .long 0x6764622d
|
||||
+ .long 0x372e302e
|
||||
+ .long 0x312d3432
|
||||
+ .long 0x2e656c35
|
||||
+ .long 0x2f676462
|
||||
+ .long 0x2d372e30
|
||||
+ .long 0x2e312f67
|
||||
+ .long 0x64622f74
|
||||
+ .long 0x65737473
|
||||
+ .long 0x75697465
|
||||
+ .long 0x2f676462
|
||||
+ .long 0x2e666f72
|
||||
+ .long 0x7472616e
|
||||
+ .long 0x0049424d
|
||||
+ .long 0x20584c20
|
||||
+ .long 0x466f7274
|
||||
+ .long 0x72616e20
|
||||
+ .long 0x666f7220
|
||||
+ .long 0x4c696e75
|
||||
+ .long 0x782c2056
|
||||
+ .long 0x31342e31
|
||||
+ .long 0x20283537
|
||||
+ .long 0x36352d4a
|
||||
+ .long 0x30352c20
|
||||
+ .long 0x35373235
|
||||
+ .long 0x2d433735
|
||||
+ .long 0x29205665
|
||||
+ .long 0x7273696f
|
||||
+ .long 0x6e203134
|
||||
+ .long 0x2e30312e
|
||||
+ .long 0x30303030
|
||||
+ .long 0x2e303030
|
||||
+ .long 0x30000249
|
||||
+ .long 0x4e544547
|
||||
+ .long 0x45520004
|
||||
+ .long 0x05030005
|
||||
+ .long 0x02524541
|
||||
+ .long 0x4c000404
|
||||
+ .long 0x04050000
|
||||
+ .long 0x0000c706
|
||||
+ .long 0x6d6f6431
|
||||
+ .long 0x00070503
|
||||
+ .long __N_mod1
|
||||
+ .long 0x79000100
|
||||
+ .long 0x01000000
|
||||
+ .long 0xd0070503
|
||||
+ .long __N__mod1
|
||||
+ .long 0x7a000100
|
||||
+ .long 0x01000000
|
||||
+ .long 0xc7087375
|
||||
+ .byte 0x62
|
||||
+ .byte 0x31
|
||||
+ .byte 0x00
|
||||
+ .long .LC.text32
|
||||
+ .long .LC.text168
|
||||
+ .long 0x01180101
|
||||
+ .byte 0x6f
|
||||
+ .byte 0x00
|
||||
+ .byte 0x00
|
||||
+.LC.debug_info273:
|
||||
+ .long 0x00000123
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_abbrev97
|
||||
+ .long 0x0401786c
|
||||
+ .long 0x662d7661
|
||||
+ .long 0x72696162
|
||||
+ .long 0x6c652e66
|
||||
+ .byte 0x00
|
||||
+ .long .LC.debug_line98
|
||||
+ .long .LC.text256
|
||||
+ .long .LC.text324
|
||||
+ .long 0x082f726f
|
||||
+ .long 0x6f742f73
|
||||
+ .long 0x65726769
|
||||
+ .long 0x6f646a2f
|
||||
+ .long 0x6764622d
|
||||
+ .long 0x372e302e
|
||||
+ .long 0x312d3432
|
||||
+ .long 0x2e656c35
|
||||
+ .long 0x2f676462
|
||||
+ .long 0x2d372e30
|
||||
+ .long 0x2e312f67
|
||||
+ .long 0x64622f74
|
||||
+ .long 0x65737473
|
||||
+ .long 0x75697465
|
||||
+ .long 0x2f676462
|
||||
+ .long 0x2e666f72
|
||||
+ .long 0x7472616e
|
||||
+ .long 0x0049424d
|
||||
+ .long 0x20584c20
|
||||
+ .long 0x466f7274
|
||||
+ .long 0x72616e20
|
||||
+ .long 0x666f7220
|
||||
+ .long 0x4c696e75
|
||||
+ .long 0x782c2056
|
||||
+ .long 0x31342e31
|
||||
+ .long 0x20283537
|
||||
+ .long 0x36352d4a
|
||||
+ .long 0x30352c20
|
||||
+ .long 0x35373235
|
||||
+ .long 0x2d433735
|
||||
+ .long 0x29205665
|
||||
+ .long 0x7273696f
|
||||
+ .long 0x6e203134
|
||||
+ .long 0x2e30312e
|
||||
+ .long 0x30303030
|
||||
+ .long 0x2e303030
|
||||
+ .long 0x30000249
|
||||
+ .long 0x4e544547
|
||||
+ .long 0x45520004
|
||||
+ .long 0x05030005
|
||||
+ .long 0x02524541
|
||||
+ .long 0x4c000404
|
||||
+ .long 0x04000000
|
||||
+ .long 0xb9050000
|
||||
+ .long 0x0000c706
|
||||
+ .long 0x000000f4
|
||||
+ .long 0x26264e26
|
||||
+ .long 0x6d6f6431
|
||||
+ .long 0x00080779
|
||||
+ .long 0x00022300
|
||||
+ .long 0x000000d4
|
||||
+ .long 0x00060000
|
||||
+ .long 0x010f2626
|
||||
+ .long 0x4e26266d
|
||||
+ .long 0x6f643100
|
||||
+ .long 0x04077a00
|
||||
+ .long 0x02230000
|
||||
+ .long 0x0000c700
|
||||
+ .long 0x085f6d61
|
||||
+ .byte 0x69
|
||||
+ .byte 0x6e
|
||||
+ .byte 0x00
|
||||
+ .long .LC.text256
|
||||
+ .long .LC.text324
|
||||
+ .long 0x0201016f
|
||||
+ .long 0x000000b9
|
||||
+ .byte 0x00
|
||||
+
|
||||
+ .section ".debug_abbrev"
|
||||
+ .align 0
|
||||
+.LC.debug_abbrev:
|
||||
+ .long 0x01110103
|
||||
+ .long 0x08100611
|
||||
+ .long 0x01120113
|
||||
+ .long 0x0b1b0825
|
||||
+ .long 0x08000002
|
||||
+ .long 0x24000308
|
||||
+ .long 0x0b0b3e0b
|
||||
+ .long 0x00000324
|
||||
+ .long 0x000b0b3e
|
||||
+ .long 0x0b000004
|
||||
+ .long 0x15000000
|
||||
+ .long 0x050f0033
|
||||
+ .long 0x0b491300
|
||||
+ .long 0x00061e01
|
||||
+ .long 0x03080000
|
||||
+ .long 0x07340002
|
||||
+ .long 0x0a03083a
|
||||
+ .long 0x0b3b0b3f
|
||||
+ .long 0x0c491300
|
||||
+ .long 0x00082e00
|
||||
+ .long 0x03081101
|
||||
+ .long 0x12013a0b
|
||||
+ .long 0x3b0b3f0c
|
||||
+ .long 0x400a0000
|
||||
+ .byte 0x00
|
||||
+.LC.debug_abbrev97:
|
||||
+ .long 0x01110103
|
||||
+ .long 0x08100611
|
||||
+ .long 0x01120113
|
||||
+ .long 0x0b1b0825
|
||||
+ .long 0x08000002
|
||||
+ .long 0x24000308
|
||||
+ .long 0x0b0b3e0b
|
||||
+ .long 0x00000324
|
||||
+ .long 0x000b0b3e
|
||||
+ .long 0x0b000004
|
||||
+ .long 0x15004913
|
||||
+ .long 0x0000050f
|
||||
+ .long 0x00330b49
|
||||
+ .long 0x13000006
|
||||
+ .long 0x13010113
|
||||
+ .long 0x03080b0b
|
||||
+ .long 0x0000070d
|
||||
+ .long 0x00030838
|
||||
+ .long 0x0a491300
|
||||
+ .long 0x00082e00
|
||||
+ .long 0x03081101
|
||||
+ .long 0x1201360b
|
||||
+ .long 0x3f0c400a
|
||||
+ .long 0x49130000
|
||||
+ .byte 0x00
|
||||
+
|
||||
+ .section ".debug_line"
|
||||
+ .align 0
|
||||
+.LC.debug_line:
|
||||
+ .long 0x0000005e
|
||||
+ .long 0x00020000
|
||||
+ .long 0x00220101
|
||||
+ .long 0x9cdc0a00
|
||||
+ .long 0x01010101
|
||||
+ .long 0x00000001
|
||||
+ .long 0x00786c66
|
||||
+ .long 0x2d766172
|
||||
+ .long 0x6961626c
|
||||
+ .long 0x652e6600
|
||||
+ .long 0x00000000
|
||||
+ .long 0x04010005
|
||||
+ .byte 0x02
|
||||
+ .long .LC.text
|
||||
+ .long 0x03130109
|
||||
+ .long 0x000c0309
|
||||
+ .long 0x01090014
|
||||
+ .long 0x037b0109
|
||||
+ .long 0x00180301
|
||||
+ .long 0x01090038
|
||||
+ .long 0x03010109
|
||||
+ .long 0x000c0301
|
||||
+ .long 0x01090014
|
||||
+ .long 0x03010109
|
||||
+ .long 0x00180001
|
||||
+ .byte 0x01
|
||||
+.LC.debug_line98:
|
||||
+ .long 0x00000046
|
||||
+ .long 0x00020000
|
||||
+ .long 0x00220101
|
||||
+ .long 0x9cdc0a00
|
||||
+ .long 0x01010101
|
||||
+ .long 0x00000001
|
||||
+ .long 0x00786c66
|
||||
+ .long 0x2d766172
|
||||
+ .long 0x6961626c
|
||||
+ .long 0x652e6600
|
||||
+ .long 0x00000000
|
||||
+ .long 0x04010005
|
||||
+ .byte 0x02
|
||||
+ .long .LC.text256
|
||||
+ .long 0x031f0109
|
||||
+ .long 0x00140300
|
||||
+ .long 0x01090004
|
||||
+ .long 0x03010109
|
||||
+ .long 0x002c0001
|
||||
+ .byte 0x01
|
||||
+
|
||||
+ .section ".debug_frame"
|
||||
+ .align 0
|
||||
+.LC.debug_frame:
|
||||
+ .long 0x0000000c
|
||||
+ .long 0xffffffff
|
||||
+ .long 0x0100047c
|
||||
+ .long 0x410c0100
|
||||
+ .long 0x0000001c
|
||||
+ .long .LC.debug_frame
|
||||
+ .long .LC.text
|
||||
+ .long 0x00000020
|
||||
+ .long 0x410e2041
|
||||
+ .long 0x9f01410d
|
||||
+ .long 0x1f410a42
|
||||
+ .long 0xdf420b00
|
||||
+ .long 0x00000020
|
||||
+ .long .LC.debug_frame
|
||||
+ .long .LC.text32
|
||||
+ .long 0x00000088
|
||||
+ .long 0x410e2041
|
||||
+ .long 0x9f01419e
|
||||
+ .long 0x02410d1f
|
||||
+ .long 0x590a42de
|
||||
+ .long 0x41df420b
|
||||
+.LC.debug_frame84:
|
||||
+ .long 0x0000000c
|
||||
+ .long 0xffffffff
|
||||
+ .long 0x0100047c
|
||||
+ .long 0x410c0100
|
||||
+ .long 0x00000020
|
||||
+ .long .LC.debug_frame84
|
||||
+ .long .LC.text256
|
||||
+ .long 0x00000044
|
||||
+ .long 0x420e2041
|
||||
+ .long 0x9f014111
|
||||
+ .long 0x417f410d
|
||||
+ .long 0x1f460a42
|
||||
+ .long 0xdf440b00
|
||||
+
|
||||
+ .section ".debug_pubtypes"
|
||||
+ .align 0
|
||||
+.LC.debug_pubtypes:
|
||||
+ .long 0x00000023
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_info
|
||||
+ .long 0x00000111
|
||||
+ .long 0x000000b9
|
||||
+ .long 0x494e5445
|
||||
+ .long 0x47455200
|
||||
+ .long 0x000000c7
|
||||
+ .long 0x5245414c
|
||||
+ .long 0x00000000
|
||||
+ .long 0x00000000
|
||||
+ .byte 0x3e
|
||||
+ .byte 0x00
|
||||
+ .byte 0x02
|
||||
+ .long .LC.debug_info273
|
||||
+ .long 0x00000127
|
||||
+ .long 0x000000b9
|
||||
+ .long 0x494e5445
|
||||
+ .long 0x47455200
|
||||
+ .long 0x000000c7
|
||||
+ .long 0x5245414c
|
||||
+ .long 0x00000000
|
||||
+ .long 0xda26264e
|
||||
+ .long 0x266d6f64
|
||||
+ .long 0x31000000
|
||||
+ .long 0x00f42626
|
||||
+ .long 0x4e26266d
|
||||
+ .long 0x6f643100
|
||||
+ .long 0x00000000
|
||||
+
|
||||
+ .comm __N__mod1,4,16
|
||||
diff --git a/gdb/testsuite/gdb.fortran/xlf-variable.exp b/gdb/testsuite/gdb.fortran/xlf-variable.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.fortran/xlf-variable.exp
|
||||
@@ -0,0 +1,37 @@
|
||||
+# Copyright 2012 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/>.
|
||||
+
|
||||
+# This test can only be run on PPC64 machines.
|
||||
+
|
||||
+if { ![istarget powerpc64-*] || ![is_ilp32_target] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+set testfile "xlf-variable"
|
||||
+set srcfile ${testfile}.S
|
||||
+
|
||||
+if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if { ![runto_main] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test "step" ".*y => z.*" "y => z"
|
||||
+gdb_test "step" ".*y = 3\.0.*" "y = 3.0"
|
||||
+gdb_test "step" ".*nullify \\(y\\).*" "nullify (y)"
|
||||
+gdb_test "print z" "= 3" "z = 3"
|
||||
+gdb_test "ptype z" "= REAL" "z is REAL"
|
||||
diff --git a/gdb/testsuite/gdb.fortran/xlf-variable.f b/gdb/testsuite/gdb.fortran/xlf-variable.f
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.fortran/xlf-variable.f
|
||||
@@ -0,0 +1,33 @@
|
||||
+c Copyright 2012 Free Software Foundation, Inc.
|
||||
+c
|
||||
+c This program is free software; you can redistribute it and/or modify
|
||||
+c it under the terms of the GNU General Public License as published by
|
||||
+c the Free Software Foundation; either version 3 of the License, or
|
||||
+c (at your option) any later version.
|
||||
+c
|
||||
+c This program is distributed in the hope that it will be useful,
|
||||
+c but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+c GNU General Public License for more details.
|
||||
+c
|
||||
+c You should have received a copy of the GNU General Public License
|
||||
+c along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+c This file is the Fortran source file for xlf-variable.f.
|
||||
+c It was used to generate the assembly output called xlf-variable.S,
|
||||
+c which was generated using IBM's XLF compiler.
|
||||
+
|
||||
+ module mod1
|
||||
+ real, pointer :: y
|
||||
+ real, target :: z
|
||||
+ contains
|
||||
+ subroutine sub1
|
||||
+ y => z
|
||||
+ y = 3.0
|
||||
+ nullify (y)
|
||||
+ end subroutine
|
||||
+ end module
|
||||
+
|
||||
+ use mod1
|
||||
+ call sub1
|
||||
+ end
|
50
gdb-s390-add-arch14-record-replay-support.patch
Normal file
50
gdb-s390-add-arch14-record-replay-support.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From 6cfb7bf81be3ab6f131dbc6a27eefca516cf7517 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Arnez <arnez@linux.ibm.com>
|
||||
Date: Tue, 13 Feb 2024 18:55:29 +0100
|
||||
Subject: [PATCH 2/2] gdb: s390: Add arch14 record/replay support
|
||||
|
||||
Enable recording of the new "arch14" instructions on z/Architecture
|
||||
targets, except for the specialized-function-assist instruction NNPA.
|
||||
---
|
||||
gdb/s390-tdep.c | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
|
||||
index 54b5c89e5e3..dcac407caef 100644
|
||||
--- a/gdb/s390-tdep.c
|
||||
+++ b/gdb/s390-tdep.c
|
||||
@@ -5534,6 +5534,14 @@ s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
|
||||
case 0xe635: /* VLRL - vector load rightmost with immed. length */
|
||||
case 0xe637: /* VLRLR - vector load rightmost with length */
|
||||
case 0xe649: /* VLIP - vector load immediate decimal */
|
||||
+ case 0xe656: /* VCLFNH - vector fp convert and lengthen from NNP high */
|
||||
+ case 0xe65e: /* VCLFNL - vector fp convert and lengthen from NNP low */
|
||||
+ case 0xe655: /* VCNF - vector fp convert to NNP */
|
||||
+ case 0xe65d: /* VCFN - vector fp convert from NNP */
|
||||
+ case 0xe674: /* VSCHP - decimal scale and convert to HFP */
|
||||
+ case 0xe675: /* VCRNF - vector fp convert and round to NNP */
|
||||
+ case 0xe67c: /* VSCSHP - decimal scale and convert and split to HFP */
|
||||
+ case 0xe67d: /* VCSPH - vector convert HFP to scaled decimal */
|
||||
case 0xe700: /* VLEB - vector load element */
|
||||
case 0xe701: /* VLEH - vector load element */
|
||||
case 0xe702: /* VLEG - vector load element */
|
||||
@@ -5791,11 +5799,16 @@ s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
|
||||
|
||||
/* 0xe747-0xe749 undefined */
|
||||
|
||||
+ case 0xe651: /* VCLZDP - vector count leading zero digits */
|
||||
+ case 0xe654: /* VUPKZH - vector unpack zoned high */
|
||||
case 0xe658: /* VCVD - vector convert to decimal 32 bit */
|
||||
case 0xe659: /* VSRP - vector shift and round decimal */
|
||||
case 0xe65a: /* VCVDG - vector convert to decimal 64 bit*/
|
||||
case 0xe65b: /* VPSOP - vector perform sign operation decimal */
|
||||
+ case 0xe65c: /* VUPKZL - vector unpack zoned low */
|
||||
+ case 0xe670: /* VPKZR - vector pack zoned register */
|
||||
case 0xe671: /* VAP - vector add decimal */
|
||||
+ case 0xe672: /* VSRPR - vector shift and round decimal register */
|
||||
case 0xe673: /* VSP - vector subtract decimal */
|
||||
case 0xe678: /* VMP - vector multiply decimal */
|
||||
case 0xe679: /* VMSP - vector multiply decimal */
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,45 +0,0 @@
|
||||
From 1bbcd2144710c4b1daa9c404df0ebc80c3461747 Mon Sep 17 00:00:00 2001
|
||||
From: Ilya Leoshkevich <iii@linux.ibm.com>
|
||||
Date: Thu, 22 Jun 2023 01:03:04 +0200
|
||||
Subject: [PATCH 11/12] gdb: support rseq auxvs
|
||||
|
||||
Linux kernel commit commit 317c8194e6ae ("rseq: Introduce feature size
|
||||
and alignment ELF auxiliary vector entries") introduced two new auxvs:
|
||||
AT_RSEQ_FEATURE_SIZE and AT_RSEQ_ALIGN. Support them in GDB. This
|
||||
fixes auxv.exp on kernels >= v6.3.
|
||||
---
|
||||
gdb/auxv.c | 4 ++++
|
||||
include/elf/common.h | 2 ++
|
||||
2 files changed, 6 insertions(+)
|
||||
|
||||
diff --git a/gdb/auxv.c b/gdb/auxv.c
|
||||
index 812b2807554..3ce5ccd3342 100644
|
||||
--- a/gdb/auxv.c
|
||||
+++ b/gdb/auxv.c
|
||||
@@ -493,6 +493,10 @@ default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
|
||||
AUXV_FORMAT_STR);
|
||||
TAG (AT_RANDOM, _("Address of 16 random bytes"), AUXV_FORMAT_HEX);
|
||||
TAG (AT_HWCAP2, _("Extension of AT_HWCAP"), AUXV_FORMAT_HEX);
|
||||
+ TAG (AT_RSEQ_FEATURE_SIZE, _("rseq supported feature size"),
|
||||
+ AUXV_FORMAT_HEX);
|
||||
+ TAG (AT_RSEQ_ALIGN, _("rseq allocation alignment"),
|
||||
+ AUXV_FORMAT_HEX);
|
||||
TAG (AT_EXECFN, _("File name of executable"), AUXV_FORMAT_STR);
|
||||
TAG (AT_SECURE, _("Boolean, was exec setuid-like?"), AUXV_FORMAT_DEC);
|
||||
TAG (AT_SYSINFO, _("Special system info/entry points"), AUXV_FORMAT_HEX);
|
||||
diff --git a/include/elf/common.h b/include/elf/common.h
|
||||
index 16587f6fb06..a37b1f9a264 100644
|
||||
--- a/include/elf/common.h
|
||||
+++ b/include/elf/common.h
|
||||
@@ -1353,6 +1353,8 @@
|
||||
may differ from AT_PLATFORM. */
|
||||
#define AT_RANDOM 25 /* Address of 16 random bytes. */
|
||||
#define AT_HWCAP2 26 /* Extension of AT_HWCAP. */
|
||||
+#define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size */
|
||||
+#define AT_RSEQ_ALIGN 28 /* rseq allocation alignment */
|
||||
#define AT_EXECFN 31 /* Filename of executable. */
|
||||
/* Pointer to the global system page used for system calls and other
|
||||
nice things. */
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,299 +0,0 @@
|
||||
From 7f4601b0a51f400bd1b1bc0f7895254d467e3bb4 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 21 Jul 2023 08:25:25 +0200
|
||||
Subject: [PATCH] [gdb/symtab] Add optimized out static var to cooked index
|
||||
|
||||
Consider the test-case:
|
||||
...
|
||||
$ cat main.c
|
||||
int main (void) { return 0; }
|
||||
$ cat static-optimized-out.c
|
||||
static int aaa;
|
||||
...
|
||||
compiled like this:
|
||||
...
|
||||
$ gcc-12 static-optimized-out.c main.c -g -O2 -flto
|
||||
...
|
||||
|
||||
There's a difference in behaviour depending on symtab expansion state:
|
||||
...
|
||||
$ gdb -q -batch a.out -ex "print aaa"
|
||||
No symbol "aaa" in current context.
|
||||
$ gdb -q -batch a.out -ex "maint expand-symtab" -ex "print aaa"
|
||||
$1 = <optimized out>
|
||||
...
|
||||
|
||||
The reason for the difference is that the optimized out variable aaa:
|
||||
...
|
||||
<1><104>: Abbrev Number: 2 (DW_TAG_variable)
|
||||
<105> DW_AT_name : aaa
|
||||
<109> DW_AT_decl_file : 1
|
||||
<10a> DW_AT_decl_line : 18
|
||||
<10b> DW_AT_decl_column : 12
|
||||
<10c> DW_AT_type : <0x110>
|
||||
...
|
||||
is not added to the cooked index because of this clause in abbrev_table::read:
|
||||
...
|
||||
else if (!has_location && !has_specification_or_origin && !has_external
|
||||
&& cur_abbrev->tag == DW_TAG_variable)
|
||||
cur_abbrev->interesting = false;
|
||||
...
|
||||
|
||||
Fix this inconsistency by making sure that the optimized out variable is added
|
||||
to the cooked index.
|
||||
|
||||
Regression tested on x86_64-linux.
|
||||
|
||||
Add two test-cases, a C test-case gdb.opt/static-optimized-out.exp and a dwarf
|
||||
assembly test-case gdb.dwarf2/static-optimized-out.exp.
|
||||
|
||||
Tested gdb.opt/static-optimized-out.exp with gcc-8 to gcc-12, for which we now
|
||||
consistently get:
|
||||
...
|
||||
(gdb) print aaa^M
|
||||
$1 = <optimized out>^M
|
||||
...
|
||||
and with gcc 7.5.0 and clang 13.0.1, for which we still consistently get:
|
||||
...
|
||||
(gdb) print aaa^M
|
||||
No symbol "aaa" in current context.^M
|
||||
...
|
||||
due to missing debug info for the variable.
|
||||
|
||||
PR symtab/30656
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30656
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
---
|
||||
gdb/dwarf2/abbrev.c | 9 ---
|
||||
.../gdb.dwarf2/static-optimized-out.exp | 69 +++++++++++++++++++
|
||||
gdb/testsuite/gdb.opt/main.c | 22 ++++++
|
||||
gdb/testsuite/gdb.opt/static-optimized-out.c | 18 +++++
|
||||
.../gdb.opt/static-optimized-out.exp | 49 +++++++++++++
|
||||
5 files changed, 158 insertions(+), 9 deletions(-)
|
||||
create mode 100644 gdb/testsuite/gdb.dwarf2/static-optimized-out.exp
|
||||
create mode 100644 gdb/testsuite/gdb.opt/main.c
|
||||
create mode 100644 gdb/testsuite/gdb.opt/static-optimized-out.c
|
||||
create mode 100644 gdb/testsuite/gdb.opt/static-optimized-out.exp
|
||||
|
||||
diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c
|
||||
index 1ebf8f6eed5..3a429fd41b1 100644
|
||||
--- a/gdb/dwarf2/abbrev.c
|
||||
+++ b/gdb/dwarf2/abbrev.c
|
||||
@@ -162,7 +162,6 @@ abbrev_table::read (struct dwarf2_section_info *section,
|
||||
bool has_specification_or_origin = false;
|
||||
bool has_name = false;
|
||||
bool has_linkage_name = false;
|
||||
- bool has_location = false;
|
||||
bool has_external = false;
|
||||
|
||||
/* Now read in declarations. */
|
||||
@@ -217,11 +216,6 @@ abbrev_table::read (struct dwarf2_section_info *section,
|
||||
has_linkage_name = true;
|
||||
break;
|
||||
|
||||
- case DW_AT_const_value:
|
||||
- case DW_AT_location:
|
||||
- has_location = true;
|
||||
- break;
|
||||
-
|
||||
case DW_AT_sibling:
|
||||
if (is_csize && cur_attr.form == DW_FORM_ref4)
|
||||
sibling_offset = size;
|
||||
@@ -296,9 +290,6 @@ abbrev_table::read (struct dwarf2_section_info *section,
|
||||
cur_abbrev->interesting = false;
|
||||
else if (!tag_interesting_for_index (cur_abbrev->tag))
|
||||
cur_abbrev->interesting = false;
|
||||
- else if (!has_location && !has_specification_or_origin && !has_external
|
||||
- && cur_abbrev->tag == DW_TAG_variable)
|
||||
- cur_abbrev->interesting = false;
|
||||
else
|
||||
cur_abbrev->interesting = true;
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp
|
||||
new file mode 100644
|
||||
index 00000000000..1547a8acbc0
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp
|
||||
@@ -0,0 +1,69 @@
|
||||
+# 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 optimized out static variable is printed the same independent
|
||||
+# of state of symtab expansion. See also gdb.opt/static-optimized-out.exp.
|
||||
+
|
||||
+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 -dw.S
|
||||
+
|
||||
+# Make DWARF for the test.
|
||||
+set asm_file [standard_output_file $srcfile2]
|
||||
+Dwarf::assemble $asm_file {
|
||||
+ cu {} {
|
||||
+ compile_unit {
|
||||
+ {
|
||||
+ language @DW_LANG_C
|
||||
+ }
|
||||
+ } {
|
||||
+ declare_labels integer_label
|
||||
+
|
||||
+ integer_label: DW_TAG_base_type {
|
||||
+ {DW_AT_byte_size 4 DW_FORM_sdata}
|
||||
+ {DW_AT_encoding @DW_ATE_signed}
|
||||
+ {DW_AT_name integer}
|
||||
+ }
|
||||
+
|
||||
+ DW_TAG_variable {
|
||||
+ {name var}
|
||||
+ {type :$integer_label}
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+if { [prepare_for_testing "failed to prepare" ${testfile} \
|
||||
+ [list $srcfile $asm_file] {nodebug}] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test "print var" " = <optimized out>"
|
||||
+
|
||||
+# Expand all symbol tables.
|
||||
+gdb_test_no_output "maint expand-symtabs"
|
||||
+
|
||||
+# Make sure we do an actual lookup rather than just returning the same as
|
||||
+# before.
|
||||
+gdb_test_no_output "maint flush symbol-cache"
|
||||
+
|
||||
+with_test_prefix "after expand-symtabs" {
|
||||
+ gdb_test "print var" " = <optimized out>"
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.opt/main.c b/gdb/testsuite/gdb.opt/main.c
|
||||
new file mode 100644
|
||||
index 00000000000..c6beff77dbe
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.opt/main.c
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ 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)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.opt/static-optimized-out.c b/gdb/testsuite/gdb.opt/static-optimized-out.c
|
||||
new file mode 100644
|
||||
index 00000000000..44287fbd6d2
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.opt/static-optimized-out.c
|
||||
@@ -0,0 +1,18 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ 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/>. */
|
||||
+
|
||||
+static int aaa;
|
||||
diff --git a/gdb/testsuite/gdb.opt/static-optimized-out.exp b/gdb/testsuite/gdb.opt/static-optimized-out.exp
|
||||
new file mode 100644
|
||||
index 00000000000..bd673b6503e
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.opt/static-optimized-out.exp
|
||||
@@ -0,0 +1,49 @@
|
||||
+# 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 optimized out static variable is printed the same independent
|
||||
+# of state of symtab expansion. See also gdb.dwarf2/static-optimized-out.exp.
|
||||
+
|
||||
+standard_testfile .c main.c
|
||||
+
|
||||
+set opts {}
|
||||
+lappend opts debug
|
||||
+lappend opts "optimize=-O2 -flto"
|
||||
+
|
||||
+if { [prepare_for_testing "failed to prepare" $testfile \
|
||||
+ [list $srcfile $srcfile2] $opts] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+set val ""
|
||||
+gdb_test_multiple "print aaa" "" {
|
||||
+ -re -wrap "\r\n(?:\\$$decimal = )?(\[^\r\n\]*)" {
|
||||
+ set val $expect_out(1,string)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+if { $val == "" } {
|
||||
+ return
|
||||
+}
|
||||
+
|
||||
+# Expand all symbol tables.
|
||||
+gdb_test_no_output "maint expand-symtab"
|
||||
+
|
||||
+# Make sure we do an actual lookup rather than just returning the same as
|
||||
+# before.
|
||||
+gdb_test_no_output "maint flush symbol-cache"
|
||||
+
|
||||
+# Now check that we get the same result in both cases.
|
||||
+gdb_test "print aaa" [string_to_regexp $val] "consistency"
|
||||
|
||||
base-commit: 800c393f89a94f49b01dff99f693cb13c5e28116
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,81 +0,0 @@
|
||||
From 04d0d6ebdc6d08f5a7ec0d4c89eb1835deef54dc Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Sun, 13 Aug 2023 14:08:06 +0200
|
||||
Subject: [PATCH] [gdb/symtab] Don't deduplicate variables in gdb-index
|
||||
|
||||
When running test-case gdb.python/py-symbol.exp with target board
|
||||
cc-with-gdb-index, we run into:
|
||||
...
|
||||
(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M
|
||||
1^M
|
||||
(gdb) FAIL: gdb.python/py-symbol.exp: print (len (gdb.lookup_static_symbols ('rr')))
|
||||
...
|
||||
|
||||
[ Note that the test-case contains rr in both py-symtab.c:
|
||||
...
|
||||
static int __attribute__ ((used)) rr = 42; /* line of rr */
|
||||
...
|
||||
and py-symtab-2.c:
|
||||
...
|
||||
static int __attribute__ ((used)) rr = 99; /* line of other rr */
|
||||
... ]
|
||||
|
||||
This passes with gdb-12-branch, and fails with gdb-13-branch.
|
||||
|
||||
AFAIU the current code in symtab_index_entry::minimize makes the assumption
|
||||
that it's fine to store only one copy of rr in the gdb-index, because
|
||||
"print rr" will only ever print one, and always the same.
|
||||
|
||||
But that fails to recognize that gdb supports gdb.lookup_static_symbols, which
|
||||
returns a list of variables rather than the first one.
|
||||
|
||||
In other words, the current approach breaks feature parity between cooked
|
||||
index and gdb-index.
|
||||
|
||||
Note btw that also debug-names has both instances:
|
||||
...
|
||||
[ 5] #00597969 rr:
|
||||
<4> DW_TAG_variable DW_IDX_compile_unit=3 DW_IDX_GNU_internal=1
|
||||
<4> DW_TAG_variable DW_IDX_compile_unit=4 DW_IDX_GNU_internal=1
|
||||
...
|
||||
|
||||
Fix this in symtab_index_entry::minimize, by not deduplicating variables.
|
||||
|
||||
Tested on x86_64-linux, with target boards unix and cc-with-gdb-index.
|
||||
|
||||
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
|
||||
|
||||
PR symtab/30720
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30720
|
||||
---
|
||||
gdb/dwarf2/index-write.c | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
|
||||
index d10583568c0..ea67f73ac3c 100644
|
||||
--- a/gdb/dwarf2/index-write.c
|
||||
+++ b/gdb/dwarf2/index-write.c
|
||||
@@ -294,7 +294,7 @@ symtab_index_entry::minimize ()
|
||||
auto from = std::unique (cu_indices.begin (), cu_indices.end ());
|
||||
cu_indices.erase (from, cu_indices.end ());
|
||||
|
||||
- /* We don't want to enter a variable or type more than once, so
|
||||
+ /* We don't want to enter a type more than once, so
|
||||
remove any such duplicates from the list as well. When doing
|
||||
this, we want to keep the entry from the first CU -- but this is
|
||||
implicit due to the sort. This choice is done because it's
|
||||
@@ -304,8 +304,7 @@ symtab_index_entry::minimize ()
|
||||
[&] (offset_type val)
|
||||
{
|
||||
gdb_index_symbol_kind kind = GDB_INDEX_SYMBOL_KIND_VALUE (val);
|
||||
- if (kind != GDB_INDEX_SYMBOL_KIND_TYPE
|
||||
- && kind != GDB_INDEX_SYMBOL_KIND_VARIABLE)
|
||||
+ if (kind != GDB_INDEX_SYMBOL_KIND_TYPE)
|
||||
return false;
|
||||
|
||||
val &= ~GDB_INDEX_CU_MASK;
|
||||
|
||||
base-commit: 2521ac7ed0c495b9e804c4356939b9be7166853c
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 6d472b241c96f181f88867860e92f1dfe7364903 Mon Sep 17 00:00:00 2001
|
||||
From 0218e033b415df76be0a14871447bbd94dce62a3 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Sat, 16 Sep 2023 04:07:22 +0200
|
||||
Subject: [PATCH 08/11] [gdb/symtab] Don't defer backward refs, inter-cu
|
||||
Subject: [PATCH 10/13] [gdb/symtab] Don't defer backward refs, inter-cu
|
||||
intra-shard case
|
||||
|
||||
In patch "[gdb/symtab] Resolve deferred entries, inter-shard case" we've
|
||||
@ -16,10 +16,10 @@ Tested on x86_64-linux.
|
||||
1 file changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 0ab3e1a1500..d2d50b5c9cc 100644
|
||||
index a97f738a54e..e7904532434 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -6709,6 +6709,12 @@ class cooked_index_storage
|
||||
@@ -4709,6 +4709,12 @@ class cooked_index_storage
|
||||
m_index->set_parent_valid (start, end);
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ index 0ab3e1a1500..d2d50b5c9cc 100644
|
||||
private:
|
||||
|
||||
/* Hash function for a cutu_reader. */
|
||||
@@ -6857,6 +6863,12 @@ class cooked_indexer
|
||||
@@ -4857,6 +4863,12 @@ class cooked_indexer
|
||||
{
|
||||
m_index_storage->set_parent_valid (start, end);
|
||||
}
|
||||
@ -45,7 +45,7 @@ index 0ab3e1a1500..d2d50b5c9cc 100644
|
||||
};
|
||||
|
||||
/* Subroutine of dwarf2_build_psymtabs_hard to simplify it.
|
||||
@@ -18387,7 +18399,22 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
@@ -16482,7 +16494,22 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
else
|
||||
{
|
||||
/* Inter-CU case. */
|
||||
|
@ -1,7 +1,7 @@
|
||||
From dac6c3b27a77589078add7e4e4586515ac85610d Mon Sep 17 00:00:00 2001
|
||||
From 8a444a93d4bd78355fc4e6ecb1935cc2b0a6a997 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 15 Sep 2023 08:38:00 +0200
|
||||
Subject: [PATCH 04/11] [gdb/symtab] Factor out m_deferred_entries usage
|
||||
Subject: [PATCH 04/13] [gdb/symtab] Factor out m_deferred_entries usage
|
||||
|
||||
Factor out usage of cooked_indexer::m_deferred_entries in new member
|
||||
functions defer_entry, handle_deferred_entries and resolve_deferred_entry.
|
||||
@ -12,10 +12,10 @@ Tested on x86_64-linux.
|
||||
1 file changed, 28 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 1092cb1dca9..ff5be8e7dc5 100644
|
||||
index d48f3010063..afdf9e870a8 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -6822,6 +6822,32 @@ class cooked_indexer
|
||||
@@ -4822,6 +4822,32 @@ class cooked_indexer
|
||||
we'll know the containing context of all the DIEs that we might
|
||||
have scanned. This vector stores these deferred entries. */
|
||||
std::vector<deferred_entry> m_deferred_entries;
|
||||
@ -48,7 +48,7 @@ index 1092cb1dca9..ff5be8e7dc5 100644
|
||||
};
|
||||
|
||||
/* Subroutine of dwarf2_build_psymtabs_hard to simplify it.
|
||||
@@ -18519,7 +18545,7 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
@@ -16611,7 +16637,7 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
if (name != nullptr)
|
||||
{
|
||||
if (defer != 0)
|
||||
@ -57,7 +57,7 @@ index 1092cb1dca9..ff5be8e7dc5 100644
|
||||
this_die, name, defer, abbrev->tag, flags
|
||||
});
|
||||
else
|
||||
@@ -18624,12 +18650,7 @@ cooked_indexer::make_index (cutu_reader *reader)
|
||||
@@ -16716,12 +16742,7 @@ cooked_indexer::make_index (cutu_reader *reader)
|
||||
return;
|
||||
index_dies (reader, reader->info_ptr, nullptr, false);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 6ac3acf29782a059258fdfe21bd55f1716fc46ed Mon Sep 17 00:00:00 2001
|
||||
From b2f260d117dc11b8e90d4e9bf7f4b2cbd63d1d49 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Tue, 22 Aug 2023 13:17:47 +0200
|
||||
Subject: [PATCH 02/11] [gdb/symtab] Factor out m_die_range_map usage
|
||||
Subject: [PATCH 02/13] [gdb/symtab] Factor out m_die_range_map usage
|
||||
|
||||
Factor out usage of cooked_indexer::m_die_range_map into new class parent_map
|
||||
with member functions find_parent and set_parent, and static member function
|
||||
@ -9,15 +9,15 @@ form_addr.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
---
|
||||
gdb/dwarf2/cooked-index.h | 32 ++++++++++++++++++++++++++
|
||||
gdb/dwarf2/read.c | 48 +++++++++++++++++++++------------------
|
||||
2 files changed, 58 insertions(+), 22 deletions(-)
|
||||
gdb/dwarf2/cooked-index.h | 32 +++++++++++++++++++++++++++
|
||||
gdb/dwarf2/read.c | 46 ++++++++++++++++++++-------------------
|
||||
2 files changed, 56 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
|
||||
index 2ef1f4b27e9..1c967bdbf86 100644
|
||||
index 5aacb321c91..979541fbf60 100644
|
||||
--- a/gdb/dwarf2/cooked-index.h
|
||||
+++ b/gdb/dwarf2/cooked-index.h
|
||||
@@ -233,6 +233,38 @@ struct cooked_index_entry : public allocate_on_obstack
|
||||
@@ -239,6 +239,38 @@ struct cooked_index_entry : public allocate_on_obstack
|
||||
bool for_name) const;
|
||||
};
|
||||
|
||||
@ -53,14 +53,14 @@ index 2ef1f4b27e9..1c967bdbf86 100644
|
||||
+ addrmap_mutable m_parent_map;
|
||||
+};
|
||||
+
|
||||
class cooked_index_vector;
|
||||
class cooked_index;
|
||||
|
||||
/* An index of interesting DIEs. This is "cooked", in contrast to a
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 00471d20d41..1092cb1dca9 100644
|
||||
index 466d3e59878..d48f3010063 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -6722,16 +6722,6 @@ class cooked_indexer
|
||||
@@ -4722,16 +4722,6 @@ class cooked_indexer
|
||||
|
||||
private:
|
||||
|
||||
@ -77,7 +77,7 @@ index 00471d20d41..1092cb1dca9 100644
|
||||
/* A helper function to scan the PC bounds of READER and record them
|
||||
in the storage's addrmap. */
|
||||
void check_bounds (cutu_reader *reader);
|
||||
@@ -6799,7 +6789,20 @@ class cooked_indexer
|
||||
@@ -4799,7 +4789,20 @@ class cooked_indexer
|
||||
/* An addrmap that maps from section offsets (see the form_addr
|
||||
method) to newly-created entries. See m_deferred_entries to
|
||||
understand this. */
|
||||
@ -99,7 +99,7 @@ index 00471d20d41..1092cb1dca9 100644
|
||||
|
||||
/* A single deferred entry. */
|
||||
struct deferred_entry
|
||||
@@ -18317,15 +18320,13 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
@@ -16412,15 +16415,13 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
|
||||
if (*parent_entry == nullptr)
|
||||
{
|
||||
@ -118,15 +118,13 @@ index 00471d20d41..1092cb1dca9 100644
|
||||
}
|
||||
|
||||
unsigned int bytes_read;
|
||||
@@ -18444,11 +18445,15 @@ cooked_indexer::recurse (cutu_reader *reader,
|
||||
|
||||
if (parent_entry != nullptr)
|
||||
@@ -16538,11 +16539,13 @@ cooked_indexer::recurse (cutu_reader *reader,
|
||||
{
|
||||
- CORE_ADDR start = form_addr (parent_entry->die_offset,
|
||||
/* Both start and end are inclusive, so use both "+ 1" and "- 1" to
|
||||
limit the range to the children of parent_entry. */
|
||||
- CORE_ADDR start = form_addr (parent_entry->die_offset + 1,
|
||||
- reader->cu->per_cu->is_dwz);
|
||||
- CORE_ADDR end = form_addr (sect_offset (info_ptr - 1 - reader->buffer),
|
||||
+ /* Both start and end are inclusive, so use both "+ 1" and "- 1" to
|
||||
+ limit the range to the children of parent_entry. */
|
||||
+ CORE_ADDR start
|
||||
+ = parent_map::form_addr (parent_entry->die_offset + 1,
|
||||
+ reader->cu->per_cu->is_dwz);
|
||||
@ -138,7 +136,7 @@ index 00471d20d41..1092cb1dca9 100644
|
||||
}
|
||||
|
||||
return info_ptr;
|
||||
@@ -18621,8 +18626,7 @@ cooked_indexer::make_index (cutu_reader *reader)
|
||||
@@ -16715,8 +16718,7 @@ cooked_indexer::make_index (cutu_reader *reader)
|
||||
|
||||
for (const auto &entry : m_deferred_entries)
|
||||
{
|
||||
|
@ -1,202 +0,0 @@
|
||||
From e2f41776aa9ca2f625bbc50e9bb498e2a95dba25 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Sat, 5 Aug 2023 17:57:13 +0200
|
||||
Subject: [PATCH] [gdb/symtab] Find main language without symtab expansion
|
||||
|
||||
When loading an executable using "file a.out", the language is set according
|
||||
to a.out, which can involve looking up the language of symbol "main", which
|
||||
will cause the symtab expansion for the containing CU.
|
||||
|
||||
Expansion of lto debug info can be slow, so in commit d3214198119 ("[gdb] Use
|
||||
partial symbol table to find language for main") a feature was added to avoid
|
||||
the symtab expansion.
|
||||
|
||||
This feature stopped working after commit 7f4307436fd ("Fix "start" for D,
|
||||
Rust, etc").
|
||||
|
||||
[ The commit addresses problems related to command start, which requires finding
|
||||
the main function:
|
||||
- for language D, "main" was found instead of "D main", and
|
||||
- for Rust, the correct function was found, but attributed the wrong name
|
||||
(not fully qualified). ]
|
||||
|
||||
Reimplement the feature by adding
|
||||
cooked_index_functions::lookup_global_symbol_language.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
PR symtab/30661
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30661
|
||||
---
|
||||
gdb/dwarf2/read.c | 41 +++++++++++++++++++++++++++++++
|
||||
gdb/testsuite/gdb.base/main-c.exp | 33 +++++++++++++++++++++++++
|
||||
gdb/testsuite/gdb.cp/main-cp.exp | 33 +++++++++++++++++++++++++
|
||||
gdb/testsuite/gdb.cp/main.cc | 22 +++++++++++++++++
|
||||
4 files changed, 129 insertions(+)
|
||||
create mode 100644 gdb/testsuite/gdb.base/main-c.exp
|
||||
create mode 100644 gdb/testsuite/gdb.cp/main-cp.exp
|
||||
create mode 100644 gdb/testsuite/gdb.cp/main.cc
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 04bc0e1cbbd..8aa7f8c31e5 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -18621,6 +18621,47 @@ struct cooked_index_functions : public dwarf2_base_index_functions
|
||||
if (dwarf2_has_info (objfile, nullptr))
|
||||
dwarf2_build_psymtabs (objfile);
|
||||
}
|
||||
+
|
||||
+ enum language lookup_global_symbol_language (struct objfile *objfile,
|
||||
+ const char *name,
|
||||
+ domain_enum domain,
|
||||
+ bool *symbol_found_p) override
|
||||
+ {
|
||||
+ *symbol_found_p = false;
|
||||
+
|
||||
+ if (!(domain == VAR_DOMAIN && streq (name, "main")))
|
||||
+ return language_unknown;
|
||||
+
|
||||
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
|
||||
+ struct dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
|
||||
+ if (per_bfd->index_table == nullptr)
|
||||
+ return language_unknown;
|
||||
+
|
||||
+ /* Expansion of large CUs can be slow. By returning the language of main
|
||||
+ here for C and C++, we avoid CU expansion during set_initial_language.
|
||||
+ But by doing a symbol lookup in the cooked index, we are forced to wait
|
||||
+ for finalization to complete. See PR symtab/30174 for ideas how to
|
||||
+ bypass that as well. */
|
||||
+ cooked_index_vector *table
|
||||
+ = (gdb::checked_static_cast<cooked_index_vector *>
|
||||
+ (per_objfile->per_bfd->index_table.get ()));
|
||||
+ table->wait ();
|
||||
+
|
||||
+ for (const cooked_index_entry *entry : table->find (name, false))
|
||||
+ {
|
||||
+ if (entry->tag != DW_TAG_subprogram)
|
||||
+ continue;
|
||||
+
|
||||
+ enum language lang = entry->per_cu->lang ();
|
||||
+ if (!(lang == language_c || lang == language_cplus))
|
||||
+ continue;
|
||||
+
|
||||
+ *symbol_found_p = true;
|
||||
+ return lang;
|
||||
+ }
|
||||
+
|
||||
+ return language_unknown;
|
||||
+ }
|
||||
};
|
||||
|
||||
dwarf2_per_cu_data *
|
||||
diff --git a/gdb/testsuite/gdb.base/main-c.exp b/gdb/testsuite/gdb.base/main-c.exp
|
||||
new file mode 100644
|
||||
index 00000000000..bcbd0fca7e4
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/main-c.exp
|
||||
@@ -0,0 +1,33 @@
|
||||
+# 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 finding main to set the current language doesn't cause any symtab
|
||||
+# to be expanded.
|
||||
+
|
||||
+standard_testfile main.c
|
||||
+
|
||||
+if { [readnow] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if { ![string eq [have_index $binfile] ""] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test_no_output "maint info symtabs"
|
||||
diff --git a/gdb/testsuite/gdb.cp/main-cp.exp b/gdb/testsuite/gdb.cp/main-cp.exp
|
||||
new file mode 100644
|
||||
index 00000000000..86d626bdbaf
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.cp/main-cp.exp
|
||||
@@ -0,0 +1,33 @@
|
||||
+# 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 finding main to set the current language doesn't cause any symtab
|
||||
+# to be expanded.
|
||||
+
|
||||
+standard_testfile main.cc
|
||||
+
|
||||
+if { [readnow] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if { ![string eq [have_index $binfile] ""] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test_no_output "maint info symtabs"
|
||||
diff --git a/gdb/testsuite/gdb.cp/main.cc b/gdb/testsuite/gdb.cp/main.cc
|
||||
new file mode 100644
|
||||
index 00000000000..c6beff77dbe
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.cp/main.cc
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ 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)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
|
||||
base-commit: ebceffa1196651683a7a6d31abb4b3b5adc6c168
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 19185006cfe0901da907da4f09fbc197aba976a2 Mon Sep 17 00:00:00 2001
|
||||
From c79ecacd3f75cfb0ec1a3afc49ca3f30b1759009 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 11 Aug 2023 01:36:50 +0200
|
||||
Subject: [PATCH 11/11] [gdb/symtab] Fix DW_TAG_inlined_subroutine entries in
|
||||
Subject: [PATCH 13/13] [gdb/symtab] Fix DW_TAG_inlined_subroutine entries in
|
||||
the cooked index
|
||||
|
||||
We get incorrect qualified names in the cooked index for
|
||||
@ -19,10 +19,10 @@ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30728
|
||||
1 file changed, 32 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index e2d4fe8cde6..418acaabc60 100644
|
||||
index 93708ef11b9..a4f982962ae 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -18369,52 +18369,49 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
@@ -16464,52 +16464,49 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
const gdb_byte *new_info_ptr = (new_reader->buffer
|
||||
+ to_underlying (origin_offset));
|
||||
|
||||
|
@ -1,84 +0,0 @@
|
||||
From e5972def532f3ed248dfbd2f220f28dc367f4ca1 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 24 Mar 2023 15:45:56 +0100
|
||||
Subject: [PATCH 07/12] [gdb/symtab] Fix line number of static const class
|
||||
member
|
||||
|
||||
Since commit 6d263fe46e0 ("Avoid bad breakpoints with --gc-sections"), there
|
||||
was a silent regression on openSUSE Leap 15.4 for test-case
|
||||
gdb.cp/m-static.exp, from:
|
||||
...
|
||||
(gdb) info variable everywhere^M
|
||||
All variables matching regular expression "everywhere":^M
|
||||
^M
|
||||
File /home/vries/tmp.local-remote-host-native/m-static.h:^M
|
||||
8: const int gnu_obj_4::everywhere;^M
|
||||
(gdb)
|
||||
...
|
||||
to:
|
||||
...
|
||||
(gdb) info variable everywhere^M
|
||||
All variables matching regular expression "everywhere":^M
|
||||
^M
|
||||
File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M
|
||||
8: const int gnu_obj_4::everywhere;^M
|
||||
^M
|
||||
File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static1.cc:^M
|
||||
8: const int gnu_obj_4::everywhere;^M
|
||||
(gdb)
|
||||
...
|
||||
|
||||
Another regression was found due to that commit, and it was fixed in commit
|
||||
99d679e7b30 ("[gdb/symtab] Fix "file index out of range" complaint") by
|
||||
limiting the scope of the fix in the original commit.
|
||||
|
||||
Fix this regression by yet further limiting the scope of that fix, making sure
|
||||
that this bit in dwarf_decode_lines is executed again for m-static1.cc:
|
||||
...
|
||||
/* Make sure a symtab is created for every file, even files
|
||||
which contain only variables (i.e. no code with associated
|
||||
line numbers). */
|
||||
...
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
PR symtab/30265
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30265
|
||||
---
|
||||
gdb/dwarf2/read.c | 3 +--
|
||||
gdb/testsuite/gdb.cp/m-static.exp | 4 +++-
|
||||
2 files changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index f39eba7a008..04bc0e1cbbd 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -9633,8 +9633,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
|
||||
then there won't be any interesting code in the CU, but a check later on
|
||||
(in lnp_state_machine::check_line_address) will fail to properly exclude
|
||||
an entry that was removed via --gc-sections. */
|
||||
- if (have_code)
|
||||
- dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping);
|
||||
+ dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping && have_code);
|
||||
}
|
||||
|
||||
/* Process DW_TAG_compile_unit or DW_TAG_partial_unit. */
|
||||
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
|
||||
index a67b4cd3736..049e88299da 100644
|
||||
--- a/gdb/testsuite/gdb.cp/m-static.exp
|
||||
+++ b/gdb/testsuite/gdb.cp/m-static.exp
|
||||
@@ -183,8 +183,10 @@ gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const flo
|
||||
if { $non_dwarf } { setup_xfail *-*-* }
|
||||
gdb_test "info variable everywhere" \
|
||||
[multi_line \
|
||||
+ {All variables matching regular expression "everywhere":} \
|
||||
+ "" \
|
||||
"File (.*/)?m-static\[.\]h:" \
|
||||
- "$decimal:\tconst int gnu_obj_4::everywhere;.*"]
|
||||
+ "$decimal:\tconst int gnu_obj_4::everywhere;"]
|
||||
|
||||
# Perhaps at some point test4 should also include a test for a static
|
||||
# const int that was initialized in the header file. But I'm not sure
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,66 +0,0 @@
|
||||
From 1362bc937bd54dbd22dd7b3c7ae9d8ab6ca7bbfc Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Wed, 6 Sep 2023 11:00:01 +0200
|
||||
Subject: [PATCH 10/12] [gdb/symtab] Fix too many symbols in
|
||||
gdbpy_lookup_static_symbols
|
||||
|
||||
When running test-case gdb.python/py-symbol.exp with target board
|
||||
cc-with-dwz-m, we run into:
|
||||
...
|
||||
(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M
|
||||
4^M
|
||||
(gdb) FAIL: gdb.python/py-symbol.exp: \
|
||||
print (len (gdb.lookup_static_symbols ('rr')))
|
||||
...
|
||||
while with target board unix we have instead:
|
||||
...
|
||||
(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M
|
||||
2^M
|
||||
(gdb) PASS: gdb.python/py-symbol.exp: \
|
||||
print (len (gdb.lookup_static_symbols ('rr')))
|
||||
...
|
||||
|
||||
The problem is that the loop in gdbpy_lookup_static_symbols loops over compunits
|
||||
representing both CUs and PUs:
|
||||
...
|
||||
for (compunit_symtab *cust : objfile->compunits ())
|
||||
...
|
||||
|
||||
When doing a lookup on a PU, the user link is followed until we end up at a CU,
|
||||
and the lookup is done in that CU.
|
||||
|
||||
In other words, when doing a lookup in the loop for a PU we duplicate the
|
||||
lookup for a CU that is already handled by the loop.
|
||||
|
||||
Fix this by skipping PUs in the loop in gdb.lookup_static_symbols.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
PR symtab/25261
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25261
|
||||
---
|
||||
gdb/python/py-symbol.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
|
||||
index b8777966c47..ed4250bc2c7 100644
|
||||
--- a/gdb/python/py-symbol.c
|
||||
+++ b/gdb/python/py-symbol.c
|
||||
@@ -582,9 +582,12 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
for (compunit_symtab *cust : objfile->compunits ())
|
||||
{
|
||||
- const struct blockvector *bv;
|
||||
+ /* Skip included compunits to prevent including compunits from
|
||||
+ being searched twice. */
|
||||
+ if (cust->user != nullptr)
|
||||
+ continue;
|
||||
|
||||
- bv = cust->blockvector ();
|
||||
+ const struct blockvector *bv = cust->blockvector ();
|
||||
const struct block *block = bv->static_block ();
|
||||
|
||||
if (block != nullptr)
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 933f8ee225d4ccd3db9b81312dba76ae5a50b4ea Mon Sep 17 00:00:00 2001
|
||||
From bc970668f83cf142c4955d1cbeaa24e8bcc4b238 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 25 Aug 2023 09:30:54 +0200
|
||||
Subject: [PATCH 03/11] [gdb/symtab] Handle nullptr parent in
|
||||
Subject: [PATCH 03/13] [gdb/symtab] Handle nullptr parent in
|
||||
parent_map::set_parent
|
||||
|
||||
Set_parent uses m_die_range_map.set_empty, which doesn't allow
|
||||
@ -18,10 +18,10 @@ Tested on x86_64-linux.
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
|
||||
index 1c967bdbf86..f4abc7a974e 100644
|
||||
index 979541fbf60..79fbfe88c03 100644
|
||||
--- a/gdb/dwarf2/cooked-index.h
|
||||
+++ b/gdb/dwarf2/cooked-index.h
|
||||
@@ -257,7 +257,9 @@ class parent_map
|
||||
@@ -263,7 +263,9 @@ class parent_map
|
||||
void set_parent (CORE_ADDR start, CORE_ADDR end,
|
||||
const cooked_index_entry *parent_entry)
|
||||
{
|
||||
|
@ -1,59 +0,0 @@
|
||||
From c67e982325c5b2249b0e29d07a9dc1985614e898 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Wed, 6 Sep 2023 10:14:50 +0200
|
||||
Subject: [PATCH 08/12] [gdb/symtab] Handle PU in iterate_over_some_symtabs
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When running test-case gdb.base/setshow.exp with target board cc-with-dwz I
|
||||
run into:
|
||||
...
|
||||
(gdb) info line 1^M
|
||||
Line 1 of "setshow.c" is at address 0x400527 <main> but contains no code.^M
|
||||
Line 1 of "setshow.c" is at address 0x400527 <main> but contains no code.^M
|
||||
(gdb) FAIL: gdb.base/setshow.exp: test_setshow_annotate: annotation_level 1
|
||||
...
|
||||
while the expected output is:
|
||||
...
|
||||
Line 1 of "setshow.c" is at address 0x400527 <main> but contains no code.
|
||||
<EFBFBD><EFBFBD>setshow.c:1:0:beg:0x400527
|
||||
...
|
||||
|
||||
The second line of the expected output is missing due to the first line of the
|
||||
expected output being repeated, so the problem is that the "Line 1" line is
|
||||
printed twice.
|
||||
|
||||
This happens because the PU imported by the CU reuses the filetab of the CU,
|
||||
and both the CU and PU are visited by iterate_over_some_symtabs.
|
||||
|
||||
Fix this by skipping PUs in iterate_over_some_symtabs.
|
||||
|
||||
Tested on x86_64-linux, target boards unix, cc-with-dwz and cc-with-dwz-m.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
PR symtab/30797
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30797
|
||||
---
|
||||
gdb/symtab.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/gdb/symtab.c b/gdb/symtab.c
|
||||
index a662d7d1869..fe7cc679b6b 100644
|
||||
--- a/gdb/symtab.c
|
||||
+++ b/gdb/symtab.c
|
||||
@@ -550,6 +550,10 @@ iterate_over_some_symtabs (const char *name,
|
||||
|
||||
for (cust = first; cust != NULL && cust != after_last; cust = cust->next)
|
||||
{
|
||||
+ /* Skip included compunits. */
|
||||
+ if (cust->user != nullptr)
|
||||
+ continue;
|
||||
+
|
||||
for (symtab *s : cust->filetabs ())
|
||||
{
|
||||
if (compare_filenames_for_search (s->filename, name))
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,159 +0,0 @@
|
||||
From 8f53ac47d3f9c3800c8429d9187961ba81707d8b Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Wed, 16 Aug 2023 23:43:25 +0200
|
||||
Subject: [PATCH 1/2] [gdb/symtab] Handle self-reference DIE
|
||||
|
||||
While working on a dwarf assembly test-case I accidentally created the
|
||||
following pathological dwarf:
|
||||
...
|
||||
<1><be>: Abbrev Number: 3 (DW_TAG_class_type)
|
||||
<bf> DW_AT_name : c1
|
||||
<c2> DW_AT_specification: <0xbe>
|
||||
...
|
||||
and noticed gdb segfaulting during cooked index creating due to running out of
|
||||
stack. This is a regression from gdb-12, where gdb just hung.
|
||||
|
||||
Fix this by inhibiting the scan_attributes self-recursion for self-references.
|
||||
|
||||
The same test-case with -readnow makes gdb hang, so also fix this in
|
||||
dwarf2_attr and follow_die_ref.
|
||||
|
||||
Note that this doesn't fix the same problems for the more complicated case of:
|
||||
...
|
||||
<1><be>: Abbrev Number: 3 (DW_TAG_class_type)
|
||||
<bf> DW_AT_name : c1
|
||||
<c2> DW_AT_specification: <0xc6>
|
||||
<1><c6>: Abbrev Number: 4 (DW_TAG_class_type)
|
||||
<c7> DW_AT_name : c2
|
||||
<ca> DW_AT_specification: <0xbe>
|
||||
...
|
||||
but the approach for deciding whether to fix pathological dwarf cases is as
|
||||
per PR27981 comment 3:
|
||||
...
|
||||
yes if it is cheap/obvious, and no if it is something complicated or expensive.
|
||||
...
|
||||
and at this point I'm not sure whether fixing this will fall in the first
|
||||
category.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
---
|
||||
gdb/dwarf2/read.c | 22 +++++++++--
|
||||
gdb/testsuite/gdb.dwarf2/self-spec.exp | 54 ++++++++++++++++++++++++++
|
||||
2 files changed, 73 insertions(+), 3 deletions(-)
|
||||
create mode 100644 gdb/testsuite/gdb.dwarf2/self-spec.exp
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 61f4bd75013..1be5f381432 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -18289,9 +18289,15 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
new_info_ptr,
|
||||
&bytes_read);
|
||||
new_info_ptr += bytes_read;
|
||||
- scan_attributes (scanning_per_cu, new_reader, new_info_ptr, new_info_ptr,
|
||||
- new_abbrev, name, linkage_name, flags, nullptr,
|
||||
- parent_entry, maybe_defer, true);
|
||||
+
|
||||
+ if (new_reader->cu == reader->cu && new_info_ptr == watermark_ptr)
|
||||
+ {
|
||||
+ /* Self-reference, we're done. */
|
||||
+ }
|
||||
+ else
|
||||
+ scan_attributes (scanning_per_cu, new_reader, new_info_ptr,
|
||||
+ new_info_ptr, new_abbrev, name, linkage_name,
|
||||
+ flags, nullptr, parent_entry, maybe_defer, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19783,7 +19789,11 @@ dwarf2_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu)
|
||||
if (!spec)
|
||||
break;
|
||||
|
||||
+ struct die_info *prev_die = die;
|
||||
die = follow_die_ref (die, spec, &cu);
|
||||
+ if (die == prev_die)
|
||||
+ /* Self-reference, we're done. */
|
||||
+ break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -22521,6 +22531,12 @@ follow_die_ref (struct die_info *src_die, const struct attribute *attr,
|
||||
struct dwarf2_cu *cu = *ref_cu;
|
||||
struct die_info *die;
|
||||
|
||||
+ if (attr->form != DW_FORM_GNU_ref_alt && src_die->sect_off == sect_off)
|
||||
+ {
|
||||
+ /* Self-reference, we're done. */
|
||||
+ return src_die;
|
||||
+ }
|
||||
+
|
||||
die = follow_die_offset (sect_off,
|
||||
(attr->form == DW_FORM_GNU_ref_alt
|
||||
|| cu->per_cu->is_dwz),
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/self-spec.exp b/gdb/testsuite/gdb.dwarf2/self-spec.exp
|
||||
new file mode 100644
|
||||
index 00000000000..77e92549fd1
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/self-spec.exp
|
||||
@@ -0,0 +1,54 @@
|
||||
+# 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 gdb doesn't hang or segfault on reading a DIE with a
|
||||
+# specification reference to itself.
|
||||
+
|
||||
+load_lib dwarf.exp
|
||||
+
|
||||
+if {![dwarf2_support]} {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+standard_testfile main.c .S
|
||||
+
|
||||
+# Create the DWARF.
|
||||
+set asm_file [standard_output_file $srcfile2]
|
||||
+Dwarf::assemble $asm_file {
|
||||
+ cu {} {
|
||||
+ compile_unit {{language @DW_LANG_C_plus_plus}} {
|
||||
+ declare_labels c1
|
||||
+ c1: class_type {
|
||||
+ {name c1}
|
||||
+ {specification :$c1}
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" {}] {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+set index [have_index $binfile]
|
||||
+if { ![string eq $index ""] } {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+if { [readnow] } {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+gdb_test "maint expand-symtabs"
|
||||
|
||||
base-commit: 6c9e159dbd1a35aafa134fcd52982174236a8dd9
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,92 +0,0 @@
|
||||
From 800c393f89a94f49b01dff99f693cb13c5e28116 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Mon, 28 Aug 2023 16:27:58 +0200
|
||||
Subject: [PATCH 2/2] [gdb/symtab] Handle self-reference in
|
||||
inherit_abstract_dies
|
||||
|
||||
Building gdb with gcc 7.5.0 and -flto -O2 -flto-partition=one generates a
|
||||
self-referencing DIE:
|
||||
...
|
||||
<2><91dace>: Abbrev Number: 405 (DW_TAG_label)
|
||||
<91dad0> DW_AT_abstract_origin: <0x91dace>
|
||||
...
|
||||
|
||||
When encountering the self-reference DIE in inherit_abstract_dies we loop
|
||||
following the abstract origin, effectively hanging gdb.
|
||||
|
||||
Fix this by handling self-referencing DIEs in the loop in
|
||||
inherit_abstract_dies.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
|
||||
PR symtab/30799
|
||||
https://sourceware.org/bugzilla/show_bug.cgi?id=30799
|
||||
---
|
||||
gdb/dwarf2/read.c | 7 +++++++
|
||||
gdb/testsuite/gdb.dwarf2/self-spec.exp | 16 +++++++++++++++-
|
||||
2 files changed, 22 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 1be5f381432..970dd54c7a5 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -11938,8 +11938,15 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (attr == nullptr)
|
||||
break;
|
||||
|
||||
+ die_info *prev_child_origin_die = child_origin_die;
|
||||
child_origin_die = follow_die_ref (child_origin_die, attr,
|
||||
&child_origin_cu);
|
||||
+
|
||||
+ if (prev_child_origin_die == child_origin_die)
|
||||
+ {
|
||||
+ /* Handle DIE with self-reference. */
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* If missing DW_AT_abstract_origin, try the corresponding child
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/self-spec.exp b/gdb/testsuite/gdb.dwarf2/self-spec.exp
|
||||
index 77e92549fd1..f04ff6da42e 100644
|
||||
--- a/gdb/testsuite/gdb.dwarf2/self-spec.exp
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/self-spec.exp
|
||||
@@ -14,7 +14,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Check that gdb doesn't hang or segfault on reading a DIE with a
|
||||
-# specification reference to itself.
|
||||
+# specification/abstract_origin reference to itself.
|
||||
|
||||
load_lib dwarf.exp
|
||||
|
||||
@@ -29,11 +29,25 @@ set asm_file [standard_output_file $srcfile2]
|
||||
Dwarf::assemble $asm_file {
|
||||
cu {} {
|
||||
compile_unit {{language @DW_LANG_C_plus_plus}} {
|
||||
+ # Check handling of self-referencing DIE.
|
||||
declare_labels c1
|
||||
c1: class_type {
|
||||
{name c1}
|
||||
{specification :$c1}
|
||||
}
|
||||
+
|
||||
+ # Check handling of self-referencing child DIE. Regression test
|
||||
+ # for PR30799.
|
||||
+ declare_labels f1 abstract_f1 f1_l
|
||||
+ abstract_f1: subprogram {}
|
||||
+ f1: subprogram {
|
||||
+ {MACRO_AT_func {main}}
|
||||
+ {abstract_origin :$abstract_f1}
|
||||
+ } {
|
||||
+ f1_l: label {
|
||||
+ {abstract_origin :$f1_l}
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
From be9718e911aff34896dcf1c3dfa41bfe34e5a9f4 Mon Sep 17 00:00:00 2001
|
||||
From 0e706742f37ee90629350780263b573f326f1a5f Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 7 Dec 2023 10:38:05 +0100
|
||||
Subject: [PATCH 10/11] [gdb/symtab] Keep track of all parents for cooked index
|
||||
Subject: [PATCH 12/13] [gdb/symtab] Keep track of all parents for cooked index
|
||||
|
||||
Keep track of all parents for cooked index.
|
||||
|
||||
@ -11,10 +11,10 @@ Tested on x86_64-linux.
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 39f6e480e19..e2d4fe8cde6 100644
|
||||
index de7b655d26c..93708ef11b9 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -18626,9 +18626,15 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
@@ -16718,9 +16718,15 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
});
|
||||
}
|
||||
else
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 439271c6fc28387ea7b6fb6e8bb07963e8b3fd7d Mon Sep 17 00:00:00 2001
|
||||
From e8285c8b37d28033209cad6579db4b9f6a48a01a Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Sun, 24 Sep 2023 11:41:39 +0200
|
||||
Subject: [PATCH 06/11] [gdb/symtab] Keep track of processed DIEs in shard
|
||||
Subject: [PATCH 08/13] [gdb/symtab] Keep track of processed DIEs in shard
|
||||
|
||||
For optimizations in two following patches, we keep track in each shard which
|
||||
DIEs have been processed.
|
||||
@ -14,10 +14,10 @@ Tested on x86_64-linux.
|
||||
3 files changed, 40 insertions(+)
|
||||
|
||||
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
|
||||
index 4a0ccc78c5d..cef57a96384 100644
|
||||
index 3231d25db5a..c096da57d62 100644
|
||||
--- a/gdb/dwarf2/cooked-index.c
|
||||
+++ b/gdb/dwarf2/cooked-index.c
|
||||
@@ -541,6 +541,7 @@ cooked_index_vector::handle_deferred_entries ()
|
||||
@@ -723,6 +723,7 @@ cooked_index::handle_deferred_entries ()
|
||||
{
|
||||
shard->m_die_range_map.reset (nullptr);
|
||||
shard->m_deferred_entries.reset (nullptr);
|
||||
@ -26,18 +26,18 @@ index 4a0ccc78c5d..cef57a96384 100644
|
||||
}
|
||||
|
||||
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
|
||||
index a06d99532ed..9d836379666 100644
|
||||
index 66424c37f7c..fa895233035 100644
|
||||
--- a/gdb/dwarf2/cooked-index.h
|
||||
+++ b/gdb/dwarf2/cooked-index.h
|
||||
@@ -312,6 +312,7 @@ class cooked_index
|
||||
@@ -316,6 +316,7 @@ class cooked_index_shard
|
||||
{
|
||||
m_die_range_map.reset (new parent_map);
|
||||
m_deferred_entries.reset (new std::vector<deferred_entry>);
|
||||
+ m_die_range_map_valid.reset (new addrmap_mutable);
|
||||
}
|
||||
|
||||
/* Create a new cooked_index_entry and register it with this object.
|
||||
@@ -403,6 +404,18 @@ class cooked_index
|
||||
DISABLE_COPY_AND_ASSIGN (cooked_index_shard);
|
||||
@@ -407,6 +408,18 @@ class cooked_index_shard
|
||||
const cooked_index_entry *resolve_deferred_entry
|
||||
(const deferred_entry &entry, const cooked_index_entry *parent_entry);
|
||||
|
||||
@ -56,7 +56,7 @@ index a06d99532ed..9d836379666 100644
|
||||
private:
|
||||
|
||||
/* Return the entry that is believed to represent the program's
|
||||
@@ -466,6 +479,8 @@ class cooked_index
|
||||
@@ -470,6 +483,8 @@ class cooked_index_shard
|
||||
understand this. */
|
||||
std::unique_ptr<parent_map> m_die_range_map;
|
||||
|
||||
@ -66,10 +66,10 @@ index a06d99532ed..9d836379666 100644
|
||||
method in a class (or perhaps namespace) scope, with the
|
||||
definition appearing outside this scope... just one of the many
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 41fa8affcd0..ba21b6a14c9 100644
|
||||
index 5b7c0969ed7..09598e702bc 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -6697,6 +6697,12 @@ class cooked_index_storage
|
||||
@@ -4697,6 +4697,12 @@ class cooked_index_storage
|
||||
m_index->defer_entry (de);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ index 41fa8affcd0..ba21b6a14c9 100644
|
||||
private:
|
||||
|
||||
/* Hash function for a cutu_reader. */
|
||||
@@ -6840,6 +6846,11 @@ class cooked_indexer
|
||||
@@ -4840,6 +4846,11 @@ class cooked_indexer
|
||||
{
|
||||
m_index_storage->defer_entry (de);
|
||||
}
|
||||
@ -94,9 +94,9 @@ index 41fa8affcd0..ba21b6a14c9 100644
|
||||
};
|
||||
|
||||
/* Subroutine of dwarf2_build_psymtabs_hard to simplify it.
|
||||
@@ -18512,6 +18523,11 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
@@ -16604,6 +16615,11 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
+ to_underlying (reader->cu->header.sect_off)
|
||||
+ reader->cu->header.get_length ());
|
||||
+ reader->cu->header.get_length_with_initial ());
|
||||
|
||||
+ const CORE_ADDR start_cu
|
||||
+ = parent_map::form_addr (sect_offset (info_ptr - reader->buffer),
|
||||
@ -106,7 +106,7 @@ index 41fa8affcd0..ba21b6a14c9 100644
|
||||
while (info_ptr < end_ptr)
|
||||
{
|
||||
sect_offset this_die = (sect_offset) (info_ptr - reader->buffer);
|
||||
@@ -18662,6 +18678,14 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
@@ -16754,6 +16770,14 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 541d6970c278dc5a8e9e32246b7139261a687592 Mon Sep 17 00:00:00 2001
|
||||
From 0f53dc7e5cc07e30d11f3f5a0645239535824890 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 7 Dec 2023 10:36:07 +0100
|
||||
Subject: [PATCH 09/11] [gdb/symtab] Recurse into c++ DW_TAG_subprogram DIEs
|
||||
Subject: [PATCH 11/13] [gdb/symtab] Recurse into c++ DW_TAG_subprogram DIEs
|
||||
for cooked index
|
||||
|
||||
Recurse into c++ DW_TAG_subprogram DIEs for cooked index, to add
|
||||
@ -13,10 +13,10 @@ Tested on x86_64-linux.
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index d2d50b5c9cc..39f6e480e19 100644
|
||||
index e7904532434..de7b655d26c 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -18689,7 +18689,8 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
@@ -16781,7 +16781,8 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
|
||||
case DW_TAG_subprogram:
|
||||
if ((m_language == language_fortran
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 0bba1c5bdbcb404327ba4d5f35254b96d2e48108 Mon Sep 17 00:00:00 2001
|
||||
From f72f115b4c012e3748a2e702d7b970be19974885 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Mon, 11 Dec 2023 15:41:26 +0100
|
||||
Subject: [PATCH 01/11] [gdb/symtab] Refactor condition in scan_attributes
|
||||
Subject: [PATCH 01/13] [gdb/symtab] Refactor condition in scan_attributes
|
||||
|
||||
In scan_attributes there's code:
|
||||
...
|
||||
@ -34,10 +34,10 @@ Tested on x86_64-linux.
|
||||
1 file changed, 10 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 2339cceb829..00471d20d41 100644
|
||||
index 50fa302b43a..466d3e59878 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -18315,15 +18315,17 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
@@ -16410,15 +16410,17 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
const gdb_byte *new_info_ptr = (new_reader->buffer
|
||||
+ to_underlying (origin_offset));
|
||||
|
||||
@ -49,8 +49,8 @@ index 2339cceb829..00471d20d41 100644
|
||||
+ if (*parent_entry == nullptr)
|
||||
{
|
||||
- CORE_ADDR lookup = form_addr (origin_offset, origin_is_dwz);
|
||||
- *parent_entry
|
||||
- = (cooked_index_entry *) m_die_range_map.find (lookup);
|
||||
- void *obj = m_die_range_map.find (lookup);
|
||||
- *parent_entry = static_cast <cooked_index_entry *> (obj);
|
||||
+ CORE_ADDR addr = form_addr (origin_offset, origin_is_dwz);
|
||||
+ if (new_reader->cu == reader->cu
|
||||
+ && new_info_ptr > watermark_ptr)
|
||||
@ -64,7 +64,7 @@ index 2339cceb829..00471d20d41 100644
|
||||
|
||||
unsigned int bytes_read;
|
||||
|
||||
base-commit: d445b7300b129a4886132ec31a23c7c2c894fa75
|
||||
base-commit: 3490f51a80a10d46dc1885ba672d9390a8221170
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 7464f06e1a7ccf4c5908e563e4cf684744919dac Mon Sep 17 00:00:00 2001
|
||||
From e2d7097cf236c9ea6959785754d067833fc302af Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Tue, 22 Aug 2023 14:24:42 +0200
|
||||
Subject: [PATCH 05/11] [gdb/symtab] Resolve deferred entries, inter-shard case
|
||||
Subject: [PATCH 05/13] [gdb/symtab] Resolve deferred entries, inter-shard case
|
||||
|
||||
Generically solve the case of inter-CU dependencies, including inter-shard
|
||||
dependencies:
|
||||
@ -29,10 +29,10 @@ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30846
|
||||
3 files changed, 254 insertions(+), 56 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
|
||||
index 2b7f9054fe5..4a0ccc78c5d 100644
|
||||
index 58ea541a5c9..3231d25db5a 100644
|
||||
--- a/gdb/dwarf2/cooked-index.c
|
||||
+++ b/gdb/dwarf2/cooked-index.c
|
||||
@@ -200,6 +200,12 @@ cooked_index_entry::write_scope (struct obstack *storage,
|
||||
@@ -228,6 +228,12 @@ cooked_index_entry::write_scope (struct obstack *storage,
|
||||
|
||||
/* See cooked-index.h. */
|
||||
|
||||
@ -43,25 +43,25 @@ index 2b7f9054fe5..4a0ccc78c5d 100644
|
||||
+/* See cooked-index.h. */
|
||||
+
|
||||
const cooked_index_entry *
|
||||
cooked_index::add (sect_offset die_offset, enum dwarf_tag tag,
|
||||
cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag,
|
||||
cooked_index_flag flags, const char *name,
|
||||
@@ -402,6 +408,8 @@ cooked_index::find (const std::string &name, bool completing)
|
||||
cooked_index_vector::cooked_index_vector (vec_type &&vec)
|
||||
@@ -446,6 +452,8 @@ cooked_index_shard::wait (bool allow_quit) const
|
||||
cooked_index::cooked_index (vec_type &&vec)
|
||||
: m_vector (std::move (vec))
|
||||
{
|
||||
+ handle_deferred_entries ();
|
||||
+
|
||||
for (auto &idx : m_vector)
|
||||
idx->finalize ();
|
||||
}
|
||||
@@ -467,6 +475,75 @@ cooked_index_vector::get_main () const
|
||||
return result;
|
||||
|
||||
@@ -649,6 +657,75 @@ cooked_index::maybe_write_index (dwarf2_per_bfd *per_bfd,
|
||||
global_index_cache.store (per_bfd, ctx);
|
||||
}
|
||||
|
||||
+/* See cooked-index.h. */
|
||||
+
|
||||
+const cooked_index_entry *
|
||||
+cooked_index::resolve_deferred_entry
|
||||
+cooked_index_shard::resolve_deferred_entry
|
||||
+ (const deferred_entry &de, const cooked_index_entry *parent_entry)
|
||||
+{
|
||||
+ reset_parent_deferred (parent_map::form_addr (de.die_offset, de.per_cu_2->is_dwz,
|
||||
@ -73,8 +73,8 @@ index 2b7f9054fe5..4a0ccc78c5d 100644
|
||||
+/* See cooked-index.h. */
|
||||
+
|
||||
+const cooked_index_entry *
|
||||
+cooked_index_vector::find_parent_deferred_entry
|
||||
+ (const cooked_index::deferred_entry &entry) const
|
||||
+cooked_index::find_parent_deferred_entry
|
||||
+ (const cooked_index_shard::deferred_entry &entry) const
|
||||
+{
|
||||
+ const cooked_index_entry *parent_entry = nullptr;
|
||||
+ for (auto &parent_map_shard : m_vector)
|
||||
@ -93,7 +93,7 @@ index 2b7f9054fe5..4a0ccc78c5d 100644
|
||||
+/* See cooked-index.h. */
|
||||
+
|
||||
+void
|
||||
+cooked_index_vector::handle_deferred_entries ()
|
||||
+cooked_index::handle_deferred_entries ()
|
||||
+{
|
||||
+ bool changed;
|
||||
+ bool deferred;
|
||||
@ -127,11 +127,11 @@ index 2b7f9054fe5..4a0ccc78c5d 100644
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void _initialize_cooked_index ();
|
||||
void
|
||||
_initialize_cooked_index ()
|
||||
/* Wait for all the index cache entries to be written before gdb
|
||||
exits. */
|
||||
static void
|
||||
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
|
||||
index f4abc7a974e..a06d99532ed 100644
|
||||
index 79fbfe88c03..66424c37f7c 100644
|
||||
--- a/gdb/dwarf2/cooked-index.h
|
||||
+++ b/gdb/dwarf2/cooked-index.h
|
||||
@@ -34,6 +34,7 @@
|
||||
@ -141,8 +141,8 @@ index f4abc7a974e..a06d99532ed 100644
|
||||
+#include <unordered_set>
|
||||
|
||||
struct dwarf2_per_cu_data;
|
||||
|
||||
@@ -236,19 +237,29 @@ struct cooked_index_entry : public allocate_on_obstack
|
||||
struct dwarf2_per_bfd;
|
||||
@@ -242,19 +243,29 @@ struct cooked_index_entry : public allocate_on_obstack
|
||||
class parent_map
|
||||
{
|
||||
public:
|
||||
@ -173,7 +173,7 @@ index f4abc7a974e..a06d99532ed 100644
|
||||
const void *obj = m_parent_map.find (lookup);
|
||||
return static_cast<const cooked_index_entry *> (obj);
|
||||
}
|
||||
@@ -259,12 +270,28 @@ class parent_map
|
||||
@@ -265,12 +276,28 @@ class parent_map
|
||||
{
|
||||
/* Calling set_empty with nullptr is currently not allowed. */
|
||||
if (parent_entry != nullptr)
|
||||
@ -202,26 +202,24 @@ index f4abc7a974e..a06d99532ed 100644
|
||||
+ std::unordered_set<CORE_ADDR> m_deferred;
|
||||
};
|
||||
|
||||
class cooked_index_vector;
|
||||
@@ -279,9 +306,14 @@ class cooked_index_vector;
|
||||
class cooked_index
|
||||
class cooked_index;
|
||||
@@ -285,7 +312,12 @@ class cooked_index;
|
||||
class cooked_index_shard
|
||||
{
|
||||
public:
|
||||
- cooked_index () = default;
|
||||
DISABLE_COPY_AND_ASSIGN (cooked_index);
|
||||
|
||||
+ cooked_index ()
|
||||
- cooked_index_shard () = default;
|
||||
+ cooked_index_shard ()
|
||||
+ {
|
||||
+ m_die_range_map.reset (new parent_map);
|
||||
+ m_deferred_entries.reset (new std::vector<deferred_entry>);
|
||||
+ }
|
||||
+
|
||||
DISABLE_COPY_AND_ASSIGN (cooked_index_shard);
|
||||
|
||||
/* Create a new cooked_index_entry and register it with this object.
|
||||
Entries are owned by this object. The new item is returned. */
|
||||
const cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag,
|
||||
@@ -325,6 +357,52 @@ class cooked_index
|
||||
@@ -329,6 +361,52 @@ class cooked_index_shard
|
||||
for completion, will be returned. */
|
||||
range find (const std::string &name, bool completing);
|
||||
range find (const std::string &name, bool completing) const;
|
||||
|
||||
+ /* Find the parent of DIE LOOKUP. */
|
||||
+ const cooked_index_entry *
|
||||
@ -272,7 +270,7 @@ index f4abc7a974e..a06d99532ed 100644
|
||||
private:
|
||||
|
||||
/* Return the entry that is believed to represent the program's
|
||||
@@ -382,6 +460,20 @@ class cooked_index
|
||||
@@ -386,6 +464,20 @@ class cooked_index_shard
|
||||
that the 'get' method is never called on this future, only
|
||||
'wait'. */
|
||||
gdb::future<void> m_future;
|
||||
@ -293,25 +291,25 @@ index f4abc7a974e..a06d99532ed 100644
|
||||
};
|
||||
|
||||
/* The main index of DIEs. The parallel DIE indexers create
|
||||
@@ -459,6 +551,13 @@ class cooked_index_vector : public dwarf_scanner_base
|
||||
@@ -469,6 +561,13 @@ class cooked_index : public dwarf_scanner_base
|
||||
|
||||
private:
|
||||
|
||||
+ /* Find the parent corresponding to deferred entry ENTRY. */
|
||||
+ const cooked_index_entry *find_parent_deferred_entry
|
||||
+ (const cooked_index::deferred_entry &entry) const;
|
||||
+ (const cooked_index_shard::deferred_entry &entry) const;
|
||||
+
|
||||
+ /* Create cooked_index_entries for the deferred entries. */
|
||||
+ void handle_deferred_entries ();
|
||||
+
|
||||
/* The vector of cooked_index objects. This is stored because the
|
||||
entries are stored on the obstacks in those objects. */
|
||||
vec_type m_vector;
|
||||
/* Maybe write the index to the index cache. */
|
||||
void maybe_write_index (dwarf2_per_bfd *per_bfd,
|
||||
const index_cache_store_context &);
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index ff5be8e7dc5..41fa8affcd0 100644
|
||||
index afdf9e870a8..5b7c0969ed7 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -6672,6 +6672,31 @@ class cooked_index_storage
|
||||
@@ -4672,6 +4672,31 @@ class cooked_index_storage
|
||||
return &m_addrmap;
|
||||
}
|
||||
|
||||
@ -335,7 +333,7 @@ index ff5be8e7dc5..41fa8affcd0 100644
|
||||
+ }
|
||||
+
|
||||
+ /* Defer creating a cooked_index_entry corresponding to deferred_entry DE. */
|
||||
+ void defer_entry (cooked_index::deferred_entry de)
|
||||
+ void defer_entry (cooked_index_shard::deferred_entry de)
|
||||
+ {
|
||||
+ m_index->defer_entry (de);
|
||||
+ }
|
||||
@ -343,7 +341,7 @@ index ff5be8e7dc5..41fa8affcd0 100644
|
||||
private:
|
||||
|
||||
/* Hash function for a cutu_reader. */
|
||||
@@ -6794,59 +6819,26 @@ class cooked_indexer
|
||||
@@ -4794,59 +4819,26 @@ class cooked_indexer
|
||||
/* Find the parent of DIE LOOKUP. */
|
||||
const cooked_index_entry *find_parent (CORE_ADDR lookup) const
|
||||
{
|
||||
@ -399,7 +397,7 @@ index ff5be8e7dc5..41fa8affcd0 100644
|
||||
- /* Create cooked_index_entries for the deferred entries. */
|
||||
- void handle_deferred_entries ()
|
||||
+ /* Defer creating a cooked_index_entry corresponding to deferred_entry DE. */
|
||||
+ void defer_entry (const cooked_index::deferred_entry &de)
|
||||
+ void defer_entry (const cooked_index_shard::deferred_entry &de)
|
||||
{
|
||||
- for (const auto &entry : m_deferred_entries)
|
||||
- {
|
||||
@ -411,7 +409,7 @@ index ff5be8e7dc5..41fa8affcd0 100644
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18346,13 +18338,36 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
@@ -16441,13 +16433,36 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
|
||||
|
||||
if (*parent_entry == nullptr)
|
||||
{
|
||||
@ -453,7 +451,7 @@ index ff5be8e7dc5..41fa8affcd0 100644
|
||||
}
|
||||
|
||||
unsigned int bytes_read;
|
||||
@@ -18475,10 +18490,12 @@ cooked_indexer::recurse (cutu_reader *reader,
|
||||
@@ -16567,10 +16582,12 @@ cooked_indexer::recurse (cutu_reader *reader,
|
||||
limit the range to the children of parent_entry. */
|
||||
CORE_ADDR start
|
||||
= parent_map::form_addr (parent_entry->die_offset + 1,
|
||||
@ -468,7 +466,7 @@ index ff5be8e7dc5..41fa8affcd0 100644
|
||||
set_parent (start, end, parent_entry);
|
||||
}
|
||||
|
||||
@@ -18545,9 +18562,16 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
@@ -16637,9 +16654,16 @@ cooked_indexer::index_dies (cutu_reader *reader,
|
||||
if (name != nullptr)
|
||||
{
|
||||
if (defer != 0)
|
||||
@ -488,7 +486,7 @@ index ff5be8e7dc5..41fa8affcd0 100644
|
||||
else
|
||||
this_entry = m_index_storage->add (this_die, abbrev->tag, flags,
|
||||
name, this_parent_entry,
|
||||
@@ -18649,8 +18673,6 @@ cooked_indexer::make_index (cutu_reader *reader)
|
||||
@@ -16741,8 +16765,6 @@ cooked_indexer::make_index (cutu_reader *reader)
|
||||
if (!reader->comp_unit_die->has_children)
|
||||
return;
|
||||
index_dies (reader, reader->info_ptr, nullptr, false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
From a4bf216accd43b25ea9b9b7507c93eb973872a82 Mon Sep 17 00:00:00 2001
|
||||
From 3b2f2b376bb80edadacc582161c362612947e3a6 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Sun, 24 Sep 2023 11:43:24 +0200
|
||||
Subject: [PATCH 07/11] [gdb/symtab] Resolve deferred entries, intra-shard case
|
||||
Subject: [PATCH 09/13] [gdb/symtab] Resolve deferred entries, intra-shard case
|
||||
|
||||
In patch "[gdb/symtab] Resolve deferred entries, inter-shard case" we've
|
||||
solved the generic case of handling deferred entries.
|
||||
@ -17,24 +17,24 @@ Tested on x86_64-linux.
|
||||
3 files changed, 52 insertions(+)
|
||||
|
||||
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
|
||||
index cef57a96384..d8a12bee265 100644
|
||||
index c096da57d62..ebed21d510c 100644
|
||||
--- a/gdb/dwarf2/cooked-index.c
|
||||
+++ b/gdb/dwarf2/cooked-index.c
|
||||
@@ -408,6 +408,7 @@ cooked_index::find (const std::string &name, bool completing)
|
||||
cooked_index_vector::cooked_index_vector (vec_type &&vec)
|
||||
@@ -452,6 +452,7 @@ cooked_index_shard::wait (bool allow_quit) const
|
||||
cooked_index::cooked_index (vec_type &&vec)
|
||||
: m_vector (std::move (vec))
|
||||
{
|
||||
+ /* Handle deferred entries, inter-cu case. */
|
||||
handle_deferred_entries ();
|
||||
|
||||
for (auto &idx : m_vector)
|
||||
@@ -477,6 +478,40 @@ cooked_index_vector::get_main () const
|
||||
@@ -659,6 +660,40 @@ cooked_index::maybe_write_index (dwarf2_per_bfd *per_bfd,
|
||||
|
||||
/* See cooked-index.h. */
|
||||
|
||||
+const cooked_index_entry *
|
||||
+cooked_index::find_parent_deferred_entry
|
||||
+ (const cooked_index::deferred_entry &entry) const
|
||||
+cooked_index_shard::find_parent_deferred_entry
|
||||
+ (const cooked_index_shard::deferred_entry &entry) const
|
||||
+{
|
||||
+ return find_parent (entry.spec_offset);
|
||||
+}
|
||||
@ -42,7 +42,7 @@ index cef57a96384..d8a12bee265 100644
|
||||
+/* See cooked-index.h. */
|
||||
+
|
||||
+void
|
||||
+cooked_index::handle_deferred_entries ()
|
||||
+cooked_index_shard::handle_deferred_entries ()
|
||||
+{
|
||||
+ for (auto it = m_deferred_entries->begin (); it != m_deferred_entries->end (); )
|
||||
+ {
|
||||
@ -67,19 +67,19 @@ index cef57a96384..d8a12bee265 100644
|
||||
+/* See cooked-index.h. */
|
||||
+
|
||||
const cooked_index_entry *
|
||||
cooked_index::resolve_deferred_entry
|
||||
cooked_index_shard::resolve_deferred_entry
|
||||
(const deferred_entry &de, const cooked_index_entry *parent_entry)
|
||||
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
|
||||
index 9d836379666..bda1ed1e155 100644
|
||||
index fa895233035..106e3091a90 100644
|
||||
--- a/gdb/dwarf2/cooked-index.h
|
||||
+++ b/gdb/dwarf2/cooked-index.h
|
||||
@@ -404,6 +404,13 @@ class cooked_index
|
||||
@@ -408,6 +408,13 @@ class cooked_index_shard
|
||||
const cooked_index_entry *resolve_deferred_entry
|
||||
(const deferred_entry &entry, const cooked_index_entry *parent_entry);
|
||||
|
||||
+ /* Find the parent entry for deferred_entry ENTRY. */
|
||||
+ const cooked_index_entry *find_parent_deferred_entry
|
||||
+ (const cooked_index::deferred_entry &entry) const;
|
||||
+ (const cooked_index_shard::deferred_entry &entry) const;
|
||||
+
|
||||
+ /* Create cooked_index_entries for the deferred entries. */
|
||||
+ void handle_deferred_entries ();
|
||||
@ -88,10 +88,10 @@ index 9d836379666..bda1ed1e155 100644
|
||||
void set_parent_valid (CORE_ADDR start, CORE_ADDR end)
|
||||
{
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index ba21b6a14c9..0ab3e1a1500 100644
|
||||
index 09598e702bc..a97f738a54e 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -6697,6 +6697,12 @@ class cooked_index_storage
|
||||
@@ -4697,6 +4697,12 @@ class cooked_index_storage
|
||||
m_index->defer_entry (de);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ index ba21b6a14c9..0ab3e1a1500 100644
|
||||
/* Mark parents in range [START, END] as valid . */
|
||||
void set_parent_valid (CORE_ADDR start, CORE_ADDR end)
|
||||
{
|
||||
@@ -7183,6 +7189,10 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile)
|
||||
@@ -5183,6 +5189,10 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile)
|
||||
errors.push_back (std::move (except));
|
||||
}
|
||||
}
|
||||
|
224
gdb-symtab-return-correct-reader-for-top-level-cu-in.patch
Normal file
224
gdb-symtab-return-correct-reader-for-top-level-cu-in.patch
Normal file
@ -0,0 +1,224 @@
|
||||
From 84b9218d98eb2ac242fe3afc81598206279f7b13 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 22 Aug 2024 10:00:27 +0200
|
||||
Subject: [PATCH] [gdb/symtab] Return correct reader for top-level CU in
|
||||
cooked_indexer::ensure_cu_exists
|
||||
|
||||
With the test-case included in this patch, we run into:
|
||||
...
|
||||
$ gdb -q -batch $exec
|
||||
Dwarf Error: Could not find abbrev number 3 in CU at offset 0xdb \
|
||||
[in module $exec]
|
||||
...
|
||||
|
||||
The debug info consists of two CUs:
|
||||
...
|
||||
Compilation Unit @ offset 0xb2:
|
||||
Length: 0x25 (32-bit)
|
||||
Version: 4
|
||||
Abbrev Offset: 0x6c
|
||||
Pointer Size: 8
|
||||
<0><bd>: Abbrev Number: 1 (DW_TAG_compile_unit)
|
||||
<be> DW_AT_language : 2 (non-ANSI C)
|
||||
<1><bf>: Abbrev Number: 2 (DW_TAG_subprogram)
|
||||
<c0> DW_AT_low_pc : 0x4004a7
|
||||
<c8> DW_AT_high_pc : 0x4004b2
|
||||
<d0> DW_AT_specification: <0xe8>
|
||||
<1><d4>: Abbrev Number: 3 (DW_TAG_subprogram)
|
||||
<d5> DW_AT_name : main
|
||||
<1><da>: Abbrev Number: 0
|
||||
Compilation Unit @ offset 0xdb:
|
||||
Length: 0xf (32-bit)
|
||||
Version: 4
|
||||
Abbrev Offset: 0x86
|
||||
Pointer Size: 8
|
||||
<0><e6>: Abbrev Number: 1 (DW_TAG_compile_unit)
|
||||
<e7> DW_AT_language : 2 (non-ANSI C)
|
||||
<1><e8>: Abbrev Number: 2 (DW_TAG_subprogram)
|
||||
<e9> DW_AT_specification: <0xd4>
|
||||
<1><ed>: Abbrev Number: 0
|
||||
...
|
||||
where:
|
||||
- DIE 0xbf in CU@0xb2 contains an inter-CU reference to
|
||||
- DIE 0xe8 in CU@0xdb, which contains an inter-CU reference to
|
||||
- DIE 0xd4 back in CU@0xb2.
|
||||
|
||||
The dwarf error is caused by this bit of code in
|
||||
cooked_indexer::ensure_cu_exists:
|
||||
...
|
||||
if (per_cu == m_per_cu)
|
||||
return reader;
|
||||
...
|
||||
|
||||
The dwarf error happens as follows:
|
||||
- a cutu_reader A is created for CU@0xb2
|
||||
- using cutu_reader A, the cooked index reader starts indexing dies, with
|
||||
m_per_cu set to CU@0xb2
|
||||
- while indexing it scans the attributes of DIE 0xbf and encounters the
|
||||
inter-CU reference to DIE 0xe8
|
||||
- it calls cooked_indexer::ensure_cu_exists, which creates a cutu_reader B for
|
||||
CU@0xdb and returns it
|
||||
- using cutu_reader B, it continues scanning attributes of DIE 0xe8 and
|
||||
encounters the inter-CU reference to DIE 0xd4
|
||||
- it calls cooked_indexer::ensure_cu_exists, the problematic bit is triggered
|
||||
and cutu_reader B is returned
|
||||
- using cutu_reader B, it continues scanning attributes of DIE 0xd4
|
||||
- this goes wrong because:
|
||||
- the attributes of the DIE are encoded using the abbreviation table at
|
||||
offset 0x6c, while
|
||||
- the decoding is done using cutu_reader B which uses the abbreviation table
|
||||
at offset 0x86.
|
||||
|
||||
Fix this by removing the problematic if clause.
|
||||
|
||||
Since cutu_reader A is not preserved in m_index_storage,
|
||||
cooked_indexer::ensure_cu_exists cannot find it there and creates a duplicate
|
||||
cutu_reader C for CU@0xb2. Fix this in process_psymtab_comp_unit by preserving
|
||||
the cutu_reader A as well in m_index_storage.
|
||||
|
||||
Tested on x86_64-linux and aarch64-linux.
|
||||
|
||||
PR symtab/32081
|
||||
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32081
|
||||
|
||||
Approved-By: Tom Tromey <tom@tromey.com>
|
||||
Reported-By: Andreas Schwab <schwab@linux-m68k.org>
|
||||
---
|
||||
gdb/dwarf2/read.c | 35 ++++++-----
|
||||
.../dw2-inter-cu-forth-and-back.exp | 60 +++++++++++++++++++
|
||||
2 files changed, 80 insertions(+), 15 deletions(-)
|
||||
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 8f2d7a34aef..b72b5fe8c83 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -4880,28 +4880,35 @@ process_psymtab_comp_unit (dwarf2_per_cu_data *this_cu,
|
||||
dwarf2_per_objfile *per_objfile,
|
||||
cooked_index_storage *storage)
|
||||
{
|
||||
- cutu_reader reader (this_cu, per_objfile, nullptr, nullptr, false,
|
||||
- storage->get_abbrev_cache ());
|
||||
+ cutu_reader *reader = storage->get_reader (this_cu);
|
||||
+ if (reader == nullptr)
|
||||
+ {
|
||||
+ cutu_reader new_reader (this_cu, per_objfile, nullptr, nullptr, false,
|
||||
+ storage->get_abbrev_cache ());
|
||||
|
||||
- if (reader.comp_unit_die == nullptr)
|
||||
- return;
|
||||
+ if (new_reader.comp_unit_die == nullptr || new_reader.dummy_p)
|
||||
+ return;
|
||||
|
||||
- if (reader.dummy_p)
|
||||
- {
|
||||
- /* Nothing. */
|
||||
+ std::unique_ptr<cutu_reader> copy
|
||||
+ (new cutu_reader (std::move (new_reader)));
|
||||
+ reader = storage->preserve (std::move (copy));
|
||||
}
|
||||
- else if (this_cu->is_debug_types)
|
||||
- build_type_psymtabs_reader (&reader, storage);
|
||||
- else if (reader.comp_unit_die->tag != DW_TAG_partial_unit)
|
||||
+
|
||||
+ if (reader->comp_unit_die == nullptr || reader->dummy_p)
|
||||
+ return;
|
||||
+
|
||||
+ if (this_cu->is_debug_types)
|
||||
+ build_type_psymtabs_reader (reader, storage);
|
||||
+ else if (reader->comp_unit_die->tag != DW_TAG_partial_unit)
|
||||
{
|
||||
bool nope = false;
|
||||
if (this_cu->scanned.compare_exchange_strong (nope, true))
|
||||
{
|
||||
- prepare_one_comp_unit (reader.cu, reader.comp_unit_die,
|
||||
+ prepare_one_comp_unit (reader->cu, reader->comp_unit_die,
|
||||
language_minimal);
|
||||
gdb_assert (storage != nullptr);
|
||||
- cooked_indexer indexer (storage, this_cu, reader.cu->lang ());
|
||||
- indexer.make_index (&reader);
|
||||
+ cooked_indexer indexer (storage, this_cu, reader->cu->lang ());
|
||||
+ indexer.make_index (reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16280,8 +16287,6 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader,
|
||||
if (!per_cu->scanned.compare_exchange_strong (nope, true))
|
||||
return nullptr;
|
||||
}
|
||||
- if (per_cu == m_per_cu)
|
||||
- return reader;
|
||||
|
||||
cutu_reader *result = m_index_storage->get_reader (per_cu);
|
||||
if (result == nullptr)
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp
|
||||
new file mode 100644
|
||||
index 00000000000..62674bdb700
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp
|
||||
@@ -0,0 +1,60 @@
|
||||
+# Copyright 2024 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 cooked index reader can handle inter-CU references:
|
||||
+# - DIE1@CU1 -> DIE2@CU2
|
||||
+# - DIE2@CU2 -> DIE3@CU1.
|
||||
+
|
||||
+load_lib dwarf.exp
|
||||
+
|
||||
+# This test can only be run on targets which support DWARF-2 and use gas.
|
||||
+require dwarf2_support
|
||||
+
|
||||
+standard_testfile main.c .S
|
||||
+
|
||||
+# Create the DWARF.
|
||||
+set asm_file [standard_output_file $srcfile2]
|
||||
+Dwarf::assemble $asm_file {
|
||||
+ declare_labels label1 label2
|
||||
+
|
||||
+ cu {} {
|
||||
+ compile_unit {{language @DW_LANG_C}} {
|
||||
+ subprogram {
|
||||
+ {MACRO_AT_range { main }}
|
||||
+ {DW_AT_specification %$label1}
|
||||
+ }
|
||||
+
|
||||
+ label2: subprogram {
|
||||
+ {DW_AT_name main}
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ cu {} {
|
||||
+ compile_unit {{language @DW_LANG_C}} {
|
||||
+ label1: subprogram {
|
||||
+ {DW_AT_specification %$label2}
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+if [prepare_for_testing "failed to prepare" $testfile \
|
||||
+ [list $asm_file $srcfile] {nodebug}] {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Regression test for PR32081.
|
||||
+gdb_assert { ![regexp -nocase "error:" $gdb_file_cmd_msg] } "No Error message"
|
||||
|
||||
base-commit: 102b31b0b7f62e6e4f685e725f325f2ab6283c2a
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
From b1136560e772dd4c74f1fbb41f6ba840b92fb9d6 Mon Sep 17 00:00:00 2001
|
||||
From 1b878333913343630472f89b4bc42f51b1619308 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Wed, 1 Nov 2023 00:33:12 +0100
|
||||
Subject: [PATCH 2/2] [gdb/symtab] Work around gas PR28629
|
||||
Subject: [PATCH 1/2] [gdb/symtab] Work around gas PR28629
|
||||
|
||||
When running test-case gdb.tui/tui-layout-asm-short-prog.exp on AlmaLinux 9.2
|
||||
ppc64le, I run into:
|
||||
@ -76,12 +76,12 @@ Approved-By: Tom Tromey <tom@tromey.com>
|
||||
gdb/dwarf2/cu.c | 1 +
|
||||
gdb/dwarf2/cu.h | 1 +
|
||||
gdb/dwarf2/read.c | 37 +++++++-
|
||||
.../gdb.dwarf2/dw2-gas-workaround.exp | 94 +++++++++++++++++++
|
||||
4 files changed, 132 insertions(+), 1 deletion(-)
|
||||
.../gdb.dwarf2/dw2-gas-workaround.exp | 92 +++++++++++++++++++
|
||||
4 files changed, 130 insertions(+), 1 deletion(-)
|
||||
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
|
||||
|
||||
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
|
||||
index 42fd4f4441b..6b5d956649f 100644
|
||||
index a908ec908cd..f9b05dfc709 100644
|
||||
--- a/gdb/dwarf2/cu.c
|
||||
+++ b/gdb/dwarf2/cu.c
|
||||
@@ -40,6 +40,7 @@ dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
|
||||
@ -93,7 +93,7 @@ index 42fd4f4441b..6b5d956649f 100644
|
||||
processing_has_namespace_info (false),
|
||||
load_all_dies (false)
|
||||
diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h
|
||||
index 710aeb5b237..9b1e8775ff4 100644
|
||||
index 6c611710503..ef8db480e3f 100644
|
||||
--- a/gdb/dwarf2/cu.h
|
||||
+++ b/gdb/dwarf2/cu.h
|
||||
@@ -265,6 +265,7 @@ struct dwarf2_cu
|
||||
@ -105,19 +105,19 @@ index 710aeb5b237..9b1e8775ff4 100644
|
||||
|
||||
/* When true, the file that we're processing is known to have
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 472684a5817..2339cceb829 100644
|
||||
index fc4667b782f..50fa302b43a 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -146,6 +146,8 @@ static int dwarf2_loclist_index;
|
||||
static int dwarf2_locexpr_block_index;
|
||||
@@ -147,6 +147,8 @@ static int dwarf2_locexpr_block_index;
|
||||
static int dwarf2_loclist_block_index;
|
||||
static int ada_block_index;
|
||||
|
||||
+static bool producer_is_gas_lt_2_38 (struct dwarf2_cu *cu);
|
||||
+
|
||||
/* Size of .debug_loclists section header for 32-bit DWARF format. */
|
||||
#define LOCLIST_HEADER_SIZE32 12
|
||||
|
||||
@@ -9663,6 +9665,27 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
@@ -7665,6 +7667,27 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
|
||||
|
||||
file_and_directory &fnd = find_file_and_directory (die, cu);
|
||||
|
||||
@ -145,7 +145,7 @@ index 472684a5817..2339cceb829 100644
|
||||
cu->start_compunit_symtab (fnd.get_name (), fnd.intern_comp_dir (objfile),
|
||||
lowpc);
|
||||
|
||||
@@ -13377,7 +13400,10 @@ check_producer (struct dwarf2_cu *cu)
|
||||
@@ -11427,7 +11450,10 @@ check_producer (struct dwarf2_cu *cu)
|
||||
else if (producer_is_clang (cu->producer, &major, &minor))
|
||||
cu->producer_is_clang = true;
|
||||
else if (producer_is_gas (cu->producer, &major, &minor))
|
||||
@ -157,7 +157,7 @@ index 472684a5817..2339cceb829 100644
|
||||
else
|
||||
{
|
||||
/* For other non-GCC compilers, expect their behavior is DWARF version
|
||||
@@ -13413,6 +13439,15 @@ producer_is_codewarrior (struct dwarf2_cu *cu)
|
||||
@@ -11463,6 +11489,15 @@ producer_is_codewarrior (struct dwarf2_cu *cu)
|
||||
return cu->producer_is_codewarrior;
|
||||
}
|
||||
|
||||
@ -175,10 +175,10 @@ index 472684a5817..2339cceb829 100644
|
||||
{
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
|
||||
new file mode 100644
|
||||
index 00000000000..416778f51b7
|
||||
index 00000000000..ca2b10f23b3
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
|
||||
@@ -0,0 +1,94 @@
|
||||
@@ -0,0 +1,92 @@
|
||||
+# Copyright 2023 Free Software Foundation, Inc.
|
||||
+
|
||||
+# This program is free software; you can redistribute it and/or modify
|
||||
@ -199,9 +199,7 @@ index 00000000000..416778f51b7
|
||||
+load_lib dwarf.exp
|
||||
+
|
||||
+# This test can only be run on targets which support DWARF-2 and use gas.
|
||||
+if { ![dwarf2_support] } {
|
||||
+ return -1
|
||||
+}
|
||||
+require dwarf2_support
|
||||
+
|
||||
+standard_testfile dw2-lines.c -dw2.S
|
||||
+
|
||||
@ -273,6 +271,8 @@ index 00000000000..416778f51b7
|
||||
+ pass $gdb_test_name
|
||||
+ }
|
||||
+}
|
||||
|
||||
base-commit: d9951c3c9ea2e542d071710e9706ed505046fe36
|
||||
--
|
||||
2.35.3
|
||||
|
||||
|
137
gdb-symtab-work-around-pr-gas-29517-dwarf2-case.patch
Normal file
137
gdb-symtab-work-around-pr-gas-29517-dwarf2-case.patch
Normal file
@ -0,0 +1,137 @@
|
||||
From 582fc35843fdf71b82d645d83d2903e2546cc21a Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Wed, 1 May 2024 15:10:50 +0200
|
||||
Subject: [PATCH 2/2] [gdb/symtab] Work around PR gas/29517, dwarf2 case
|
||||
|
||||
In commit 1d45d90934b ("[gdb/symtab] Work around PR gas/29517") we added a
|
||||
workaround for PR gas/29517.
|
||||
|
||||
The problem is present in gas version 2.39, and fixed in 2.40, so the
|
||||
workaround is only active for gas version == 2.39.
|
||||
|
||||
However, the problem in gas is only fixed for dwarf version >= 3, which
|
||||
supports DW_TAG_unspecified_type.
|
||||
|
||||
Fix this by also activating the workaround for dwarf version == 2.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
PR symtab/31689
|
||||
https://sourceware.org/bugzilla/show_bug.cgi?id=31689
|
||||
---
|
||||
gdb/dwarf2/read.c | 5 +++-
|
||||
.../gdb.dwarf2/dw2-unspecified-type-foo.c | 7 ++++++
|
||||
.../gdb.dwarf2/dw2-unspecified-type.c | 3 ++-
|
||||
.../gdb.dwarf2/dw2-unspecified-type.exp | 23 ++++++++++++++++++-
|
||||
4 files changed, 35 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index 761437f6631..fc4667b782f 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -14646,10 +14646,13 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
|
||||
type = die_type (die, cu);
|
||||
|
||||
+ /* PR gas/29517 occurs in 2.39, and is fixed in 2.40, but it's only fixed
|
||||
+ for dwarf version >= 3 which supports DW_TAG_unspecified_type. */
|
||||
if (type->code () == TYPE_CODE_VOID
|
||||
&& !type->is_stub ()
|
||||
&& die->child == nullptr
|
||||
- && producer_is_gas_2_39 (cu))
|
||||
+ && (cu->per_cu->version () == 2
|
||||
+ || producer_is_gas_2_39 (cu)))
|
||||
{
|
||||
/* Work around PR gas/29517, pretend we have an DW_TAG_unspecified_type
|
||||
return type. */
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type-foo.c b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type-foo.c
|
||||
index 164e781c9f0..bcf525a4d2e 100644
|
||||
--- a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type-foo.c
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type-foo.c
|
||||
@@ -21,3 +21,10 @@ foo (void)
|
||||
asm ("foo_label: .globl foo_label");
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+int
|
||||
+foo2 (void)
|
||||
+{
|
||||
+ asm ("foo2_label: .globl foo2_label");
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c
|
||||
index e07d9517ff2..9e600f9dcce 100644
|
||||
--- a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c
|
||||
@@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
extern int foo (void);
|
||||
+extern int foo2 (void);
|
||||
|
||||
int
|
||||
bar (void)
|
||||
@@ -27,6 +28,6 @@ bar (void)
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
- int res = foo () + bar ();
|
||||
+ int res = foo () + bar () + foo2 ();
|
||||
return res;
|
||||
}
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
|
||||
index a6f2a57e33e..947246ba44d 100644
|
||||
--- a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
|
||||
@@ -34,11 +34,19 @@ lassign $bar_res \
|
||||
bar_start bar_len
|
||||
set bar_end "$bar_start + $bar_len"
|
||||
|
||||
+set foo2_res \
|
||||
+ [function_range foo2 \
|
||||
+ [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]]
|
||||
+lassign $foo2_res \
|
||||
+ foo2_start foo2_len
|
||||
+set foo2_end "$foo2_start + $foo2_len"
|
||||
+
|
||||
# Create the DWARF.
|
||||
set asm_file [standard_output_file $srcfile3]
|
||||
Dwarf::assemble $asm_file {
|
||||
global foo_start foo_end
|
||||
global bar_start bar_end
|
||||
+ global foo2_start foo2_end
|
||||
declare_labels unspecified_type_label
|
||||
|
||||
cu {} {
|
||||
@@ -68,6 +76,19 @@ Dwarf::assemble $asm_file {
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ cu { version 2 } {
|
||||
+ compile_unit {
|
||||
+ {language @DW_LANG_Mips_Assembler}
|
||||
+ {producer "GNU AS 2.40.0"}
|
||||
+ } {
|
||||
+ DW_TAG_subprogram {
|
||||
+ {name foo2}
|
||||
+ {low_pc $foo2_start addr}
|
||||
+ {high_pc $foo2_end addr}
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
if [prepare_for_testing "failed to prepare" $testfile \
|
||||
@@ -79,7 +100,7 @@ if ![runto_main] {
|
||||
return -1
|
||||
}
|
||||
|
||||
-foreach f {foo bar} {
|
||||
+foreach f {foo bar foo2} {
|
||||
# Print the function type. Return type should be stub type, which is printed
|
||||
# as void.
|
||||
gdb_test "ptype $f" "type = void \\(void\\)"
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 92a5f5ae1b71d152d943ee896bf6cd073d50daa7 Mon Sep 17 00:00:00 2001
|
||||
From 7a2731d9d1c0926d22905b9d07e32a7b63c43b34 Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Thu, 28 Sep 2023 13:55:07 +0200
|
||||
Subject: [PATCH 02/12] [gdb/symtab] Work around PR gas/29517
|
||||
Subject: [PATCH 57/65] Work around PR gas/29517
|
||||
|
||||
When using glibc debuginfo generated with gas 2.39, we run into PR gas/29517:
|
||||
...
|
||||
@ -61,14 +61,14 @@ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30911
|
||||
---
|
||||
gdb/dwarf2/cu.c | 1 +
|
||||
gdb/dwarf2/cu.h | 1 +
|
||||
gdb/dwarf2/read.c | 22 ++++++++++++
|
||||
gdb/dwarf2/read.c | 23 ++++++++++++
|
||||
gdb/producer.c | 8 ++++-
|
||||
.../gdb.dwarf2/dw2-unspecified-type.c | 9 ++++-
|
||||
.../gdb.dwarf2/dw2-unspecified-type.exp | 36 +++++++++++++++----
|
||||
6 files changed, 68 insertions(+), 9 deletions(-)
|
||||
6 files changed, 69 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
|
||||
index 9c1691c90e9..42fd4f4441b 100644
|
||||
index 89de40daab0..a908ec908cd 100644
|
||||
--- a/gdb/dwarf2/cu.c
|
||||
+++ b/gdb/dwarf2/cu.c
|
||||
@@ -40,6 +40,7 @@ dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
|
||||
@ -80,7 +80,7 @@ index 9c1691c90e9..42fd4f4441b 100644
|
||||
load_all_dies (false)
|
||||
{
|
||||
diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h
|
||||
index e8dbde9c019..710aeb5b237 100644
|
||||
index 0c15d8b02db..6c611710503 100644
|
||||
--- a/gdb/dwarf2/cu.h
|
||||
+++ b/gdb/dwarf2/cu.h
|
||||
@@ -265,6 +265,7 @@ struct dwarf2_cu
|
||||
@ -92,10 +92,10 @@ index e8dbde9c019..710aeb5b237 100644
|
||||
/* When true, the file that we're processing is known to have
|
||||
debugging info for C++ namespaces. GCC 3.3.x did not produce
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
index b9e7e18f2a6..f39eba7a008 100644
|
||||
index a5c48baa6f8..e5e557c17d3 100644
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -13370,6 +13370,8 @@ check_producer (struct dwarf2_cu *cu)
|
||||
@@ -11426,6 +11426,8 @@ check_producer (struct dwarf2_cu *cu)
|
||||
cu->producer_is_codewarrior = true;
|
||||
else if (producer_is_clang (cu->producer, &major, &minor))
|
||||
cu->producer_is_clang = true;
|
||||
@ -104,7 +104,7 @@ index b9e7e18f2a6..f39eba7a008 100644
|
||||
else
|
||||
{
|
||||
/* For other non-GCC compilers, expect their behavior is DWARF version
|
||||
@@ -13405,6 +13407,15 @@ producer_is_codewarrior (struct dwarf2_cu *cu)
|
||||
@@ -11461,6 +11463,15 @@ producer_is_codewarrior (struct dwarf2_cu *cu)
|
||||
return cu->producer_is_codewarrior;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ index b9e7e18f2a6..f39eba7a008 100644
|
||||
/* Return the accessibility of DIE, as given by DW_AT_accessibility.
|
||||
If that attribute is not available, return the appropriate
|
||||
default. */
|
||||
@@ -16581,6 +16592,17 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
@@ -14635,6 +14646,18 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
|
||||
type = die_type (die, cu);
|
||||
|
||||
@ -131,7 +131,8 @@ index b9e7e18f2a6..f39eba7a008 100644
|
||||
+ {
|
||||
+ /* Work around PR gas/29517, pretend we have an DW_TAG_unspecified_type
|
||||
+ return type. */
|
||||
+ type = init_type (cu->per_objfile->objfile, TYPE_CODE_VOID, 0, NULL);
|
||||
+ type = (type_allocator (cu->per_objfile->objfile, cu->lang ())
|
||||
+ .new_type (TYPE_CODE_VOID, 0, nullptr));
|
||||
+ type->set_is_stub (true);
|
||||
+ }
|
||||
+
|
||||
@ -186,10 +187,10 @@ index 1df09214d4a..e07d9517ff2 100644
|
||||
return res;
|
||||
}
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
|
||||
index a353395592e..bd707204fba 100644
|
||||
index 5fa6ee544b2..a6f2a57e33e 100644
|
||||
--- a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
|
||||
@@ -29,10 +29,18 @@ lassign $foo_res \
|
||||
@@ -27,10 +27,18 @@ lassign $foo_res \
|
||||
foo_start foo_len
|
||||
set foo_end "$foo_start + $foo_len"
|
||||
|
||||
@ -208,7 +209,7 @@ index a353395592e..bd707204fba 100644
|
||||
declare_labels unspecified_type_label
|
||||
|
||||
cu {} {
|
||||
@@ -47,7 +55,19 @@ Dwarf::assemble $asm_file {
|
||||
@@ -45,7 +53,19 @@ Dwarf::assemble $asm_file {
|
||||
{high_pc $foo_end addr}
|
||||
{type :$unspecified_type_label}
|
||||
}
|
||||
@ -228,7 +229,7 @@ index a353395592e..bd707204fba 100644
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,12 +81,14 @@ if ![runto_main] {
|
||||
@@ -59,12 +79,14 @@ if ![runto_main] {
|
||||
return -1
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user