Compare commits
No commits in common. 'c9' and 'c8' have entirely different histories.
@ -1,3 +1,3 @@
|
||||
1056e2743a825ecce46ec9eec37f0b357831012b SOURCES/gdb-10.2.tar.xz
|
||||
ee66294d87a109f88a459d0da5d0bb2da5135f45 SOURCES/gdb-8.2.tar.xz
|
||||
1ad1d2c6f0141b37bbe32b8add91b5691ecc6412 SOURCES/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz
|
||||
89b3dd85676090dd4a923425f7668446d729f5f3 SOURCES/v2.0.4.tar.gz
|
||||
a08830edc095f4ea8ae516a154942105379c5f67 SOURCES/v2.0.tar.gz
|
||||
|
@ -1,3 +1,3 @@
|
||||
SOURCES/gdb-10.2.tar.xz
|
||||
SOURCES/gdb-8.2.tar.xz
|
||||
SOURCES/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz
|
||||
SOURCES/v2.0.4.tar.gz
|
||||
SOURCES/v2.0.tar.gz
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,32 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Cagney <cagney@gnu.org>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.3-ppc64displaysymbol-20041124.patch
|
||||
|
||||
;; Include the pc's section when doing a symbol lookup so that the
|
||||
;; correct symbol is found.
|
||||
;;=push: Write new testcase.
|
||||
|
||||
2004-11-24 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* printcmd.c (build_address_symbolic): Find a section for the
|
||||
address.
|
||||
|
||||
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
|
||||
--- a/gdb/printcmd.c
|
||||
+++ b/gdb/printcmd.c
|
||||
@@ -587,6 +587,14 @@ build_address_symbolic (struct gdbarch *gdbarch,
|
||||
addr = overlay_mapped_address (addr, section);
|
||||
}
|
||||
}
|
||||
+ /* To ensure that the symbol returned belongs to the correct setion
|
||||
+ (and that the last [random] symbol from the previous section
|
||||
+ isn't returned) try to find the section containing PC. First try
|
||||
+ the overlay code (which by default returns NULL); and second try
|
||||
+ the normal section code (which almost always succeeds). */
|
||||
+ section = find_pc_overlay (addr);
|
||||
+ if (section == NULL)
|
||||
+ section = find_pc_section (addr);
|
||||
|
||||
/* First try to find the address in the symbol table, then
|
||||
in the minsyms. Take the closest one. */
|
@ -0,0 +1,118 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Cagney <cagney@gnu.org>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.3-ppc64syscall-20040622.patch
|
||||
|
||||
;; Better parse 64-bit PPC system call prologues.
|
||||
;;=push: Write new testcase.
|
||||
|
||||
2004-06-22 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* rs6000-tdep.c (struct rs6000_framedata): Add field "func_start".
|
||||
(skip_prologue): Delete local variable "orig_pc", use
|
||||
"func_start". Add local variable "num_skip_linux_syscall_insn",
|
||||
use to skip over first half of a GNU/Linux syscall and update
|
||||
"func_start".
|
||||
|
||||
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
|
||||
--- a/gdb/rs6000-tdep.c
|
||||
+++ b/gdb/rs6000-tdep.c
|
||||
@@ -134,6 +134,7 @@ static const char *powerpc_vector_abi_string = "auto";
|
||||
|
||||
struct rs6000_framedata
|
||||
{
|
||||
+ CORE_ADDR func_start; /* True function start. */
|
||||
int offset; /* total size of frame --- the distance
|
||||
by which we decrement sp to allocate
|
||||
the frame */
|
||||
@@ -1426,7 +1427,6 @@ static CORE_ADDR
|
||||
skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
||||
struct rs6000_framedata *fdata)
|
||||
{
|
||||
- CORE_ADDR orig_pc = pc;
|
||||
CORE_ADDR last_prologue_pc = pc;
|
||||
CORE_ADDR li_found_pc = 0;
|
||||
gdb_byte buf[4];
|
||||
@@ -1445,12 +1445,14 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
||||
int minimal_toc_loaded = 0;
|
||||
int prev_insn_was_prologue_insn = 1;
|
||||
int num_skip_non_prologue_insns = 0;
|
||||
+ int num_skip_ppc64_gnu_linux_syscall_insn = 0;
|
||||
int r0_contains_arg = 0;
|
||||
const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
|
||||
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
||||
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
||||
|
||||
memset (fdata, 0, sizeof (struct rs6000_framedata));
|
||||
+ fdata->func_start = pc;
|
||||
fdata->saved_gpr = -1;
|
||||
fdata->saved_fpr = -1;
|
||||
fdata->saved_vr = -1;
|
||||
@@ -1484,6 +1486,55 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
||||
break;
|
||||
op = extract_unsigned_integer (buf, 4, byte_order);
|
||||
|
||||
+ /* A PPC64 GNU/Linux system call function is split into two
|
||||
+ sub-functions: a non-threaded fast-path (__NAME_nocancel)
|
||||
+ which does not use a frame; and a threaded slow-path
|
||||
+ (Lpseudo_cancel) that does create a frame. Ref:
|
||||
+ nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
|
||||
+
|
||||
+ *INDENT-OFF*
|
||||
+ NAME:
|
||||
+ SINGLE_THREAD_P
|
||||
+ bne- .Lpseudo_cancel
|
||||
+ __NAME_nocancel:
|
||||
+ li r0,162
|
||||
+ sc
|
||||
+ bnslr+
|
||||
+ b 0x7fe014ef64 <.__syscall_error>
|
||||
+ Lpseudo_cancel:
|
||||
+ stdu r1,-128(r1)
|
||||
+ ...
|
||||
+ *INDENT-ON*
|
||||
+
|
||||
+ Unfortunatly, because the latter case uses a local label (not
|
||||
+ in the symbol table) a PC in "Lpseudo_cancel" appears to be
|
||||
+ in "__NAME_nocancel". The following code recognizes this,
|
||||
+ adjusting FUNC_START to point to where "Lpseudo_cancel"
|
||||
+ should be, and parsing the prologue sequence as if
|
||||
+ "Lpseudo_cancel" was the entry point. */
|
||||
+
|
||||
+ if (((op & 0xffff0000) == 0x38000000 /* li r0,N */
|
||||
+ && pc == fdata->func_start + 0
|
||||
+ && num_skip_ppc64_gnu_linux_syscall_insn == 0)
|
||||
+ || (op == 0x44000002 /* sc */
|
||||
+ && pc == fdata->func_start + 4
|
||||
+ && num_skip_ppc64_gnu_linux_syscall_insn == 1)
|
||||
+ || (op == 0x4ca30020 /* bnslr+ */
|
||||
+ && pc == fdata->func_start + 8
|
||||
+ && num_skip_ppc64_gnu_linux_syscall_insn == 2))
|
||||
+ {
|
||||
+ num_skip_ppc64_gnu_linux_syscall_insn++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */
|
||||
+ && pc == fdata->func_start + 12
|
||||
+ && num_skip_ppc64_gnu_linux_syscall_insn == 3)
|
||||
+ {
|
||||
+ num_skip_ppc64_gnu_linux_syscall_insn = -1;
|
||||
+ fdata->func_start = pc;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
if ((op & 0xfc1fffff) == 0x7c0802a6)
|
||||
{ /* mflr Rx */
|
||||
/* Since shared library / PIC code, which needs to get its
|
||||
@@ -1673,9 +1724,9 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
||||
we have no line table information or the line info tells
|
||||
us that the subroutine call is not part of the line
|
||||
associated with the prologue. */
|
||||
- if ((pc - orig_pc) > 8)
|
||||
+ if ((pc - fdata->func_start) > 8)
|
||||
{
|
||||
- struct symtab_and_line prologue_sal = find_pc_line (orig_pc, 0);
|
||||
+ struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0);
|
||||
struct symtab_and_line this_sal = find_pc_line (pc, 0);
|
||||
|
||||
if ((prologue_sal.line == 0)
|
@ -0,0 +1,35 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Cagney <cagney@gnu.org>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.3-readnever-20050907.patch
|
||||
|
||||
;; Add readnever option
|
||||
;;=push
|
||||
|
||||
2004-11-18 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* dwarf2read.c: Include "top.c".
|
||||
(dwarf2_has_info): Check for readnever_symbol_files.
|
||||
* symfile.c (readnever_symbol_files): Define.
|
||||
* top.h (readnever_symbol_files): Declare.
|
||||
* main.c (captured_main): Add --readnever option.
|
||||
(print_gdb_help): Ditto.
|
||||
|
||||
2004-11-18 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* gdb.texinfo (File Options): Document --readnever.
|
||||
|
||||
Pushed upstream: https://sourceware.org/ml/gdb-cvs/2017-12/msg00007.html
|
||||
|
||||
diff --git a/gdb/gcore.in b/gdb/gcore.in
|
||||
--- a/gdb/gcore.in
|
||||
+++ b/gdb/gcore.in
|
||||
@@ -97,7 +97,7 @@ for pid in "$@"
|
||||
do
|
||||
# `</dev/null' to avoid touching interactive terminal if it is
|
||||
# available but not accessible as GDB would get stopped on SIGTTIN.
|
||||
- "$binary_path/@GDB_TRANSFORM_NAME@" </dev/null --nx --batch \
|
||||
+ "$binary_path/@GDB_TRANSFORM_NAME@" </dev/null --nx --batch --readnever \
|
||||
-ex "set pagination off" -ex "set height 0" -ex "set width 0" \
|
||||
"${dump_all_cmds[@]}" \
|
||||
-ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,42 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Elena Zannoni <ezannoni@redhat.com>
|
||||
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
||||
Subject: gdb-6.3-test-self-20050110.patch
|
||||
|
||||
;; Get selftest working with sep-debug-info
|
||||
;;=fedoratest
|
||||
|
||||
2004-02-23 Elena Zannoni <ezannoni@redhat.com>
|
||||
|
||||
* gdb.gdb/selftest.exp: Make sure that the debug directory is
|
||||
set up properly.
|
||||
* gdb.gdb/complaints.exp: Ditto.
|
||||
* gdb.gdb/xfullpath.exp: Ditto.
|
||||
* gdb.gdb/observer.exp: Ditto.
|
||||
|
||||
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
|
||||
@@ -151,18 +151,18 @@ proc do_self_tests {function body} {
|
||||
}
|
||||
|
||||
# Remove any old copy lying around.
|
||||
- remote_file host delete $xgdb
|
||||
+ #remote_file host delete $xgdb
|
||||
|
||||
gdb_start
|
||||
- set file [remote_download host $GDB_FULLPATH $xgdb]
|
||||
+ #set file [remote_download host $GDB_FULLPATH $xgdb]
|
||||
|
||||
- set result [selftest_setup $file $function]
|
||||
+ set result [selftest_setup $GDB_FULLPATH $function]
|
||||
if {$result == 0} then {
|
||||
set result [uplevel $body]
|
||||
}
|
||||
|
||||
gdb_exit
|
||||
- catch "remote_file host delete $file"
|
||||
+ #catch "remote_file host delete $file"
|
||||
|
||||
if {$result < 0} then {
|
||||
warning "Couldn't test self"
|
@ -0,0 +1,24 @@
|
||||
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-bz203661-emit-relocs.patch
|
||||
|
||||
;; Fix debuginfo addresses resolving for --emit-relocs Linux kernels (BZ 203661).
|
||||
;;=push+jan: There was some mail thread about it, this patch may be a hack.
|
||||
|
||||
diff --git a/gdb/symfile.c b/gdb/symfile.c
|
||||
--- a/gdb/symfile.c
|
||||
+++ b/gdb/symfile.c
|
||||
@@ -3584,6 +3584,12 @@ default_symfile_relocate (struct objfile *objfile, asection *sectp,
|
||||
DWO file. */
|
||||
bfd *abfd = sectp->owner;
|
||||
|
||||
+ /* Executable files have all the relocations already resolved.
|
||||
+ Handle files linked with --emit-relocs.
|
||||
+ http://sources.redhat.com/ml/gdb/2006-08/msg00137.html */
|
||||
+ if ((abfd->flags & EXEC_P) != 0)
|
||||
+ return NULL;
|
||||
+
|
||||
/* We're only interested in sections with relocation
|
||||
information. */
|
||||
if ((sectp->flags & SEC_RELOC) == 0)
|
@ -0,0 +1,304 @@
|
||||
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-bz216711-clone-is-outermost.patch
|
||||
|
||||
;; Fix bogus 0x0 unwind of the thread's topmost function clone(3) (BZ 216711).
|
||||
;;=fedora
|
||||
|
||||
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=216711
|
||||
|
||||
FIXME: This workaround should be dropped and
|
||||
glibc/sysdeps/unix/sysv/linux/x86_64/clone.S should get CFI for the child
|
||||
instead.
|
||||
|
||||
2006-12-17 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb/amd64-linux-tdep.c (linux_clone_code): New variable.
|
||||
(LINUX_CLONE_LEN): New definition.
|
||||
(amd64_linux_clone_running, amd64_linux_outermost_frame): New function.
|
||||
(amd64_linux_init_abi): Initialize `outermost_frame_p'.
|
||||
* gdb/i386-tdep.c (i386_gdbarch_init): Likewise.
|
||||
* gdb/i386-tdep.h (gdbarch_tdep): Add `outermost_frame_p' member.
|
||||
* gdb/amd64-tdep.c (amd64_frame_this_id): Call `outermost_frame_p'.
|
||||
|
||||
2006-12-17 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.threads/bt-clone-stop.exp, gdb.threads/bt-clone-stop.c:
|
||||
New file.
|
||||
|
||||
2007-10-16 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
Port to GDB-6.7.
|
||||
|
||||
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
|
||||
--- a/gdb/amd64-linux-tdep.c
|
||||
+++ b/gdb/amd64-linux-tdep.c
|
||||
@@ -291,6 +291,80 @@ amd64_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
|
||||
|
||||
/* Set the program counter for process PTID to PC. */
|
||||
|
||||
+/* Detect the outermost frame; during unwind of
|
||||
+ #5 0x000000305cec68c3 in clone () from /lib64/tls/libc.so.6
|
||||
+ avoid the additional bogus frame
|
||||
+ #6 0x0000000000000000 in ??
|
||||
+ We compare if the `linux_clone_code' block is _before_ unwound PC. */
|
||||
+
|
||||
+static const unsigned char linux_clone_code[] =
|
||||
+{
|
||||
+/* libc/sysdeps/unix/sysv/linux/x86_64/clone.S */
|
||||
+/* #ifdef RESET_PID */
|
||||
+/* ... */
|
||||
+/* mov $SYS_ify(getpid), %eax */
|
||||
+/* 0xb8, 0x27, 0x00, 0x00, 0x00 */
|
||||
+/* OR */
|
||||
+/* mov $SYS_ify(getpid), %rax */
|
||||
+/* 0x48, 0xc7, 0xc0, 0x27, 0x00, 0x00, 0x00 */
|
||||
+/* so just: */
|
||||
+ 0x27, 0x00, 0x00, 0x00,
|
||||
+/* syscall */
|
||||
+ 0x0f, 0x05,
|
||||
+/* movl %eax, %fs:PID */
|
||||
+ 0x64, 0x89, 0x04, 0x25, 0x94, 0x00, 0x00, 0x00,
|
||||
+/* movl %eax, %fs:TID */
|
||||
+ 0x64, 0x89, 0x04, 0x25, 0x90, 0x00, 0x00, 0x00,
|
||||
+/* #endif */
|
||||
+/* |* Set up arguments for the function call. *| */
|
||||
+/* popq %rax |* Function to call. *| */
|
||||
+ 0x58,
|
||||
+/* popq %rdi |* Argument. *| */
|
||||
+ 0x5f,
|
||||
+/* call *%rax$ */
|
||||
+ 0xff, 0xd0
|
||||
+};
|
||||
+
|
||||
+#define LINUX_CLONE_LEN (sizeof linux_clone_code)
|
||||
+
|
||||
+static int
|
||||
+amd64_linux_clone_running (struct frame_info *this_frame)
|
||||
+{
|
||||
+ CORE_ADDR pc = get_frame_pc (this_frame);
|
||||
+ unsigned char buf[LINUX_CLONE_LEN];
|
||||
+
|
||||
+ if (!safe_frame_unwind_memory (this_frame, pc - LINUX_CLONE_LEN, buf,
|
||||
+ LINUX_CLONE_LEN))
|
||||
+ return 0;
|
||||
+
|
||||
+ if (memcmp (buf, linux_clone_code, LINUX_CLONE_LEN) != 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+amd64_linux_outermost_frame (struct frame_info *this_frame)
|
||||
+{
|
||||
+ CORE_ADDR pc = get_frame_pc (this_frame);
|
||||
+ const char *name;
|
||||
+
|
||||
+ find_pc_partial_function (pc, &name, NULL, NULL);
|
||||
+
|
||||
+ /* If we have NAME, we can optimize the search.
|
||||
+ `clone' NAME still needs to have the code checked as its name may be
|
||||
+ present in the user code.
|
||||
+ `__clone' NAME should not be present in the user code but in the initial
|
||||
+ parts of the `__clone' implementation the unwind still makes sense.
|
||||
+ More detailed unwinding decision would be too much sensitive to possible
|
||||
+ subtle changes in specific glibc revisions. */
|
||||
+ if (name == NULL || strcmp (name, "clone") == 0
|
||||
+ || strcmp ("__clone", name) == 0)
|
||||
+ return (amd64_linux_clone_running (this_frame) != 0);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
|
||||
{
|
||||
@@ -1808,6 +1882,8 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
|
||||
|
||||
tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET;
|
||||
|
||||
+ tdep->outermost_frame_p = amd64_linux_outermost_frame;
|
||||
+
|
||||
/* Add the %orig_rax register used for syscall restarting. */
|
||||
set_gdbarch_write_pc (gdbarch, amd64_linux_write_pc);
|
||||
|
||||
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
|
||||
--- a/gdb/amd64-tdep.c
|
||||
+++ b/gdb/amd64-tdep.c
|
||||
@@ -2595,6 +2595,7 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame,
|
||||
{
|
||||
struct amd64_frame_cache *cache =
|
||||
amd64_frame_cache (this_frame, this_cache);
|
||||
+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
|
||||
|
||||
if (!cache->base_p)
|
||||
return UNWIND_UNAVAILABLE;
|
||||
@@ -2603,6 +2604,10 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame,
|
||||
if (cache->base == 0)
|
||||
return UNWIND_OUTERMOST;
|
||||
|
||||
+ /* Detect OS dependent outermost frames; such as `clone'. */
|
||||
+ if (tdep->outermost_frame_p && tdep->outermost_frame_p (this_frame))
|
||||
+ return UNWIND_OUTERMOST;
|
||||
+
|
||||
return UNWIND_NO_REASON;
|
||||
}
|
||||
|
||||
@@ -2737,6 +2742,7 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame,
|
||||
{
|
||||
struct amd64_frame_cache *cache =
|
||||
amd64_sigtramp_frame_cache (this_frame, this_cache);
|
||||
+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
|
||||
|
||||
if (!cache->base_p)
|
||||
(*this_id) = frame_id_build_unavailable_stack (get_frame_pc (this_frame));
|
||||
@@ -2745,6 +2751,11 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame,
|
||||
/* This marks the outermost frame. */
|
||||
return;
|
||||
}
|
||||
+ else if (tdep->outermost_frame_p && tdep->outermost_frame_p (this_frame))
|
||||
+ {
|
||||
+ /* Detect OS dependent outermost frames; such as `clone'. */
|
||||
+ return;
|
||||
+ }
|
||||
else
|
||||
(*this_id) = frame_id_build (cache->base + 16, get_frame_pc (this_frame));
|
||||
}
|
||||
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
|
||||
--- a/gdb/i386-tdep.c
|
||||
+++ b/gdb/i386-tdep.c
|
||||
@@ -8406,6 +8406,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
||||
|
||||
tdep->xsave_xcr0_offset = -1;
|
||||
|
||||
+ /* Unwinding stops on i386 automatically. */
|
||||
+ tdep->outermost_frame_p = NULL;
|
||||
+
|
||||
tdep->record_regmap = i386_record_regmap;
|
||||
|
||||
set_gdbarch_type_align (gdbarch, i386_type_align);
|
||||
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
|
||||
--- a/gdb/i386-tdep.h
|
||||
+++ b/gdb/i386-tdep.h
|
||||
@@ -251,6 +251,9 @@ struct gdbarch_tdep
|
||||
|
||||
/* Regsets. */
|
||||
const struct regset *fpregset;
|
||||
+
|
||||
+ /* Detect OS dependent outermost frames; such as `clone'. */
|
||||
+ int (*outermost_frame_p) (struct frame_info *this_frame);
|
||||
};
|
||||
|
||||
/* Floating-point registers. */
|
||||
diff --git a/gdb/testsuite/gdb.threads/bt-clone-stop.c b/gdb/testsuite/gdb.threads/bt-clone-stop.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.threads/bt-clone-stop.c
|
||||
@@ -0,0 +1,39 @@
|
||||
+/* 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||
+ MA 02110-1301, USA. */
|
||||
+
|
||||
+
|
||||
+#include <pthread.h>
|
||||
+#include <unistd.h>
|
||||
+#include <assert.h>
|
||||
+
|
||||
+
|
||||
+void *threader (void *arg)
|
||||
+{
|
||||
+ assert (0);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int main (void)
|
||||
+{
|
||||
+ pthread_t t1;
|
||||
+
|
||||
+ pthread_create (&t1, NULL, threader, (void *) NULL);
|
||||
+ for (;;)
|
||||
+ pause();
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.threads/bt-clone-stop.exp b/gdb/testsuite/gdb.threads/bt-clone-stop.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.threads/bt-clone-stop.exp
|
||||
@@ -0,0 +1,61 @@
|
||||
+# 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.
|
||||
+
|
||||
+# Backtraced `clone' must not have `PC == 0' as its previous frame.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set testfile bt-clone-stop
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile [standard_output_file ${testfile}]
|
||||
+if { [gdb_compile_pthreads "${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}
|
||||
+
|
||||
+# threader: threader.c:8: threader: Assertion `0' failed.
|
||||
+# Program received signal SIGABRT, Aborted.
|
||||
+
|
||||
+gdb_test "run" \
|
||||
+ {Thread 2 "bt-clone-stop" received signal SIGABRT.*} \
|
||||
+ "run"
|
||||
+
|
||||
+# Former gdb unwind (the first function is `clone'):
|
||||
+# #5 0x0000003421ecd62d in ?? () from /lib64/libc.so.6
|
||||
+# #6 0x0000000000000000 in ?? ()
|
||||
+# (gdb)
|
||||
+# Tested `amd64_linux_outermost_frame' functionality should omit the line `#6'.
|
||||
+#
|
||||
+# Two `-re' cases below must be in this order (1st is a subset of the 2nd one).
|
||||
+# Unhandled case below should not happen and it is fortunately handled by
|
||||
+# `amd64_linux_outermost_frame' as FAIL (and result `0x0 entry output invalid').
|
||||
+gdb_test_multiple "bt" "0x0 entry output invalid" {
|
||||
+ -re "in threader \\(.*\n#\[0-9\]* *0x0* in .*$gdb_prompt $" {
|
||||
+ fail "0x0 entry found"
|
||||
+ }
|
||||
+ -re "in threader \\(.*$gdb_prompt $" {
|
||||
+ pass "0x0 entry not found"
|
||||
+ }
|
||||
+}
|
@ -0,0 +1,102 @@
|
||||
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-bz218379-ppc-solib-trampoline-test.patch
|
||||
|
||||
;; Test sideeffects of skipping ppc .so libs trampolines (BZ 218379).
|
||||
;;=fedoratest
|
||||
|
||||
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/step-over-trampoline.c b/gdb/testsuite/gdb.base/step-over-trampoline.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/step-over-trampoline.c
|
||||
@@ -0,0 +1,28 @@
|
||||
+/* 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 <stdio.h>
|
||||
+
|
||||
+int main (void)
|
||||
+{
|
||||
+ puts ("hello world");
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/step-over-trampoline.exp b/gdb/testsuite/gdb.base/step-over-trampoline.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/step-over-trampoline.exp
|
||||
@@ -0,0 +1,54 @@
|
||||
+# 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
|
||||
+}
|
||||
+
|
||||
+set testfile step-over-trampoline
|
||||
+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}
|
||||
+
|
||||
+# For C programs, "start" should stop in main().
|
||||
+
|
||||
+gdb_test "start" \
|
||||
+ "main \\(\\) at .*$srcfile.*" \
|
||||
+ "start"
|
||||
+
|
||||
+# main () at hello2.c:5
|
||||
+# 5 puts("hello world\n");
|
||||
+# (gdb) next
|
||||
+# 0x100007e0 in call___do_global_ctors_aux ()
|
||||
+
|
||||
+gdb_test_multiple "next" "invalid `next' output" {
|
||||
+ -re "\nhello world.*return 0;.*" {
|
||||
+ pass "stepped over"
|
||||
+ }
|
||||
+ -re " in call___do_global_ctors_aux \\(\\).*" {
|
||||
+ fail "stepped into trampoline"
|
||||
+ }
|
||||
+}
|
@ -0,0 +1,197 @@
|
||||
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.6-buildid-locate-core-as-arg.patch
|
||||
|
||||
;;=push+jan
|
||||
|
||||
http://sourceware.org/ml/gdb-patches/2010-01/msg00558.html
|
||||
|
||||
[ Fixed up since the mail. ]
|
||||
|
||||
On Thu, 21 Jan 2010 18:17:15 +0100, Doug Evans wrote:
|
||||
> Not an exhaustive list, but if we go down the path of converting "gdb
|
||||
> corefile" to "gdb -c corefile", then we also need to think about "file
|
||||
> corefile" being converted to "core corefile" [or "target core
|
||||
> corefile", "core" is apparently deprecated in favor of "target core"]
|
||||
> and "target exec corefile" -> "target core corefile". Presumably
|
||||
> "file corefile" (and "target exec corefile") would discard the
|
||||
> currently selected executable. But maybe not. Will that be confusing
|
||||
> for users? I don't know.
|
||||
|
||||
While thinking about it overriding some GDB _commands_ was not my intention.
|
||||
|
||||
There is a general assumption if I have a shell COMMAND and some FILE I can do
|
||||
$ COMMAND FILE
|
||||
and COMMAND will appropriately load the FILE.
|
||||
|
||||
FSF GDB currently needs to specify also the executable file for core files
|
||||
which already inhibits this intuitive expectation. OTOH with the build-id
|
||||
locating patch which could allow such intuitive start notneeding the
|
||||
executable file. Still it currently did not work due to the required "-c":
|
||||
$ COMMAND -c COREFILE
|
||||
|
||||
Entering "file", "core-file" or "attach" commands is already explicit enough
|
||||
so that it IMO should do what the command name says without any
|
||||
autodetections. The second command line argument
|
||||
(captured_main->pid_or_core_arg) is also autodetected (for PID or CORE) but
|
||||
neither "attach" accepts a core file nor "core-file" accepts a PID.
|
||||
|
||||
The patch makes sense only with the build-id patchset so this is not submit
|
||||
for FSF GDB inclusion yet. I am fine with your patch (+/- Hui Zhu's pending
|
||||
bfd_check_format_matches) as the patch below is its natural extension.
|
||||
|
||||
Sorry for the delay,
|
||||
Jan
|
||||
|
||||
2010-01-25 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* exceptions.h (enum errors <IS_CORE_ERROR>): New.
|
||||
* exec.c: Include exceptions.h.
|
||||
(exec_file_attach <bfd_core>): Call throw_error (IS_CORE_ERROR, ...).
|
||||
* main.c (exec_or_core_file_attach): New.
|
||||
(captured_main <optind < argc>): Set also corearg.
|
||||
(captured_main <strcmp (execarg, symarg) == 0>): New variable func.
|
||||
Call exec_or_core_file_attach if COREARG matches EXECARG. Call
|
||||
symbol_file_add_main only if CORE_BFD remained NULL.
|
||||
|
||||
Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html
|
||||
2010-01-20 Doug Evans <dje@google.com>
|
||||
|
||||
* exec.c (exec_file_attach): Print a more useful error message if the
|
||||
user did "gdb core".
|
||||
|
||||
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
|
||||
--- a/gdb/common/common-exceptions.h
|
||||
+++ b/gdb/common/common-exceptions.h
|
||||
@@ -104,6 +104,9 @@ enum errors {
|
||||
"_ERROR" is appended to the name. */
|
||||
MAX_COMPLETIONS_REACHED_ERROR,
|
||||
|
||||
+ /* Attempt to load a core file as executable. */
|
||||
+ IS_CORE_ERROR,
|
||||
+
|
||||
/* Add more errors here. */
|
||||
NR_ERRORS
|
||||
};
|
||||
diff --git a/gdb/exec.c b/gdb/exec.c
|
||||
--- a/gdb/exec.c
|
||||
+++ b/gdb/exec.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "gdb_bfd.h"
|
||||
#include "gcore.h"
|
||||
#include "source.h"
|
||||
+#include "exceptions.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include "readline/readline.h"
|
||||
@@ -357,12 +358,27 @@ exec_file_attach (const char *filename, int from_tty)
|
||||
|
||||
if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
|
||||
{
|
||||
+ int is_core;
|
||||
+
|
||||
+ /* If the user accidentally did "gdb core", print a useful
|
||||
+ error message. Check it only after bfd_object has been checked as
|
||||
+ a valid executable may get recognized for example also as
|
||||
+ "trad-core". */
|
||||
+ is_core = bfd_check_format (exec_bfd, bfd_core);
|
||||
+
|
||||
/* Make sure to close exec_bfd, or else "run" might try to use
|
||||
it. */
|
||||
exec_close ();
|
||||
- error (_("\"%s\": not in executable format: %s"),
|
||||
- scratch_pathname,
|
||||
- gdb_bfd_errmsg (bfd_get_error (), matching));
|
||||
+
|
||||
+ if (is_core != 0)
|
||||
+ throw_error (IS_CORE_ERROR,
|
||||
+ _("\"%s\" is a core file.\n"
|
||||
+ "Please specify an executable to debug."),
|
||||
+ scratch_pathname);
|
||||
+ else
|
||||
+ error (_("\"%s\": not in executable format: %s"),
|
||||
+ scratch_pathname,
|
||||
+ gdb_bfd_errmsg (bfd_get_error (), matching));
|
||||
}
|
||||
|
||||
if (build_section_table (exec_bfd, §ions, §ions_end))
|
||||
diff --git a/gdb/main.c b/gdb/main.c
|
||||
--- a/gdb/main.c
|
||||
+++ b/gdb/main.c
|
||||
@@ -447,6 +447,37 @@ struct cmdarg
|
||||
char *string;
|
||||
};
|
||||
|
||||
+/* Call exec_file_attach. If it detected FILENAME is a core file call
|
||||
+ core_file_command. Print the original exec_file_attach error only if
|
||||
+ core_file_command failed to find a matching executable. */
|
||||
+
|
||||
+static void
|
||||
+exec_or_core_file_attach (const char *filename, int from_tty)
|
||||
+{
|
||||
+ volatile struct gdb_exception e;
|
||||
+
|
||||
+ gdb_assert (exec_bfd == NULL);
|
||||
+
|
||||
+ TRY
|
||||
+ {
|
||||
+ exec_file_attach (filename, from_tty);
|
||||
+ }
|
||||
+ CATCH (e, RETURN_MASK_ALL)
|
||||
+ {
|
||||
+ if (e.error == IS_CORE_ERROR)
|
||||
+ {
|
||||
+ core_file_command ((char *) filename, from_tty);
|
||||
+
|
||||
+ /* Iff the core file found its executable suppress the error message
|
||||
+ from exec_file_attach. */
|
||||
+ if (exec_bfd != NULL)
|
||||
+ return;
|
||||
+ }
|
||||
+ throw_exception (e);
|
||||
+ }
|
||||
+ END_CATCH
|
||||
+}
|
||||
+
|
||||
static void
|
||||
captured_main_1 (struct captured_main_args *context)
|
||||
{
|
||||
@@ -883,6 +914,8 @@ captured_main_1 (struct captured_main_args *context)
|
||||
{
|
||||
symarg = argv[optind];
|
||||
execarg = argv[optind];
|
||||
+ if (optind + 1 == argc && corearg == NULL)
|
||||
+ corearg = argv[optind];
|
||||
optind++;
|
||||
}
|
||||
|
||||
@@ -1033,11 +1066,25 @@ captured_main_1 (struct captured_main_args *context)
|
||||
&& symarg != NULL
|
||||
&& strcmp (execarg, symarg) == 0)
|
||||
{
|
||||
+ catch_command_errors_const_ftype *func;
|
||||
+
|
||||
+ /* Call exec_or_core_file_attach only if the file was specified as
|
||||
+ a command line argument (and not an a command line option). */
|
||||
+ if (corearg != NULL && strcmp (corearg, execarg) == 0)
|
||||
+ {
|
||||
+ func = exec_or_core_file_attach;
|
||||
+ corearg = NULL;
|
||||
+ }
|
||||
+ else
|
||||
+ func = exec_file_attach;
|
||||
+
|
||||
/* The exec file and the symbol-file are the same. If we can't
|
||||
open it, better only print one error message.
|
||||
- catch_command_errors returns non-zero on success! */
|
||||
- if (catch_command_errors (exec_file_attach, execarg,
|
||||
- !batch_flag))
|
||||
+ catch_command_errors returns non-zero on success!
|
||||
+ Do not load EXECARG as a symbol file if it has been already processed
|
||||
+ as a core file. */
|
||||
+ if (catch_command_errors (func, execarg, !batch_flag)
|
||||
+ && core_bfd == NULL)
|
||||
catch_command_errors (symbol_file_add_main_adapter, symarg,
|
||||
!batch_flag);
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
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.6-scheduler_locking-step-is-default.patch
|
||||
|
||||
;; Make upstream `set scheduler-locking step' as default.
|
||||
;;=push+jan: How much is scheduler-locking relevant after non-stop?
|
||||
|
||||
diff --git a/gdb/infrun.c b/gdb/infrun.c
|
||||
--- a/gdb/infrun.c
|
||||
+++ b/gdb/infrun.c
|
||||
@@ -2193,7 +2193,7 @@ static const char *const scheduler_enums[] = {
|
||||
schedlock_replay,
|
||||
NULL
|
||||
};
|
||||
-static const char *scheduler_mode = schedlock_replay;
|
||||
+static const char *scheduler_mode = schedlock_step;
|
||||
static void
|
||||
show_scheduler_mode (struct ui_file *file, int from_tty,
|
||||
struct cmd_list_element *c, const char *value)
|
||||
diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp
|
||||
--- a/gdb/testsuite/gdb.mi/mi-cli.exp
|
||||
+++ b/gdb/testsuite/gdb.mi/mi-cli.exp
|
||||
@@ -199,7 +199,7 @@ mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" \
|
||||
# Test that the token is output even for CLI commands
|
||||
# Also test that *stopped includes frame information.
|
||||
mi_gdb_test "34 next" \
|
||||
- ".*34\\\^running.*\\*running,thread-id=\"all\"" \
|
||||
+ ".*34\\\^running.*\\*running,thread-id=\"1\"" \
|
||||
"34 next: run"
|
||||
|
||||
# Test that the new current source line is output to the console
|
||||
diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
|
||||
--- a/gdb/testsuite/gdb.mi/mi-console.exp
|
||||
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
|
||||
@@ -60,6 +60,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
|
||||
|
||||
mi_run_to_main
|
||||
|
||||
+# thread-id=\"all\" vs. thread-id=\"1\" below:
|
||||
+mi_gdb_test "210-gdb-set scheduler-locking off" "210\\^done" "set scheduler-locking off"
|
||||
+
|
||||
# The output we get from the target depends on how it is hosted. If
|
||||
# we are semihosted (e.g., the sim or a remote target that supports
|
||||
# the File I/O remote protocol extension), we see the target I/O
|
||||
diff --git a/gdb/testsuite/gdb.mi/mi-logging.exp b/gdb/testsuite/gdb.mi/mi-logging.exp
|
||||
--- a/gdb/testsuite/gdb.mi/mi-logging.exp
|
||||
+++ b/gdb/testsuite/gdb.mi/mi-logging.exp
|
||||
@@ -53,7 +53,7 @@ close $chan
|
||||
|
||||
set mi_log_prompt "\[(\]gdb\[)\] \[\r\n\]+"
|
||||
|
||||
-if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] {
|
||||
+if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] {
|
||||
pass "log file contents"
|
||||
} else {
|
||||
fail "log file contents"
|
||||
@@ -76,7 +76,7 @@ set chan [open $milogfile]
|
||||
set logcontent [read $chan]
|
||||
close $chan
|
||||
|
||||
-if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] {
|
||||
+if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] {
|
||||
pass "redirect log file contents"
|
||||
} else {
|
||||
fail "redirect log file contents"
|
||||
diff --git a/gdb/testsuite/gdb.opt/inline-cmds.exp b/gdb/testsuite/gdb.opt/inline-cmds.exp
|
||||
--- a/gdb/testsuite/gdb.opt/inline-cmds.exp
|
||||
+++ b/gdb/testsuite/gdb.opt/inline-cmds.exp
|
||||
@@ -331,7 +331,7 @@ proc mi_cli_step {cli_output_re message} {
|
||||
|
||||
send_gdb "interpreter-exec console \"step\"\n"
|
||||
gdb_expect {
|
||||
- -re "\\^running\r\n\\*running,thread-id=\"all\"\r\n${mi_gdb_prompt}${cli_output_re}" {
|
||||
+ -re "\\^running\r\n\\*running,thread-id=\"1\"\r\n${mi_gdb_prompt}${cli_output_re}" {
|
||||
pass $message
|
||||
}
|
||||
timeout {
|
@ -0,0 +1,37 @@
|
||||
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-bz436037-reg-no-longer-active.patch
|
||||
|
||||
;; Fix register assignments with no GDB stack frames (BZ 436037).
|
||||
;;=push+jan: This fix is incorrect.
|
||||
|
||||
diff --git a/gdb/valops.c b/gdb/valops.c
|
||||
--- a/gdb/valops.c
|
||||
+++ b/gdb/valops.c
|
||||
@@ -1104,6 +1104,8 @@ value_assign (struct value *toval, struct value *fromval)
|
||||
struct gdbarch *gdbarch;
|
||||
int value_reg;
|
||||
|
||||
+ value_reg = VALUE_REGNUM (toval);
|
||||
+
|
||||
/* Figure out which frame this is in currently.
|
||||
|
||||
We use VALUE_FRAME_ID for obtaining the value's frame id instead of
|
||||
@@ -1113,8 +1115,14 @@ value_assign (struct value *toval, struct value *fromval)
|
||||
frame. */
|
||||
frame = frame_find_by_id (VALUE_FRAME_ID (toval));
|
||||
|
||||
- value_reg = VALUE_REGNUM (toval);
|
||||
-
|
||||
+ /* "set $reg+=1" should work on programs with no debug info,
|
||||
+ but frame_find_by_id returns NULL here (RH bug 436037).
|
||||
+ Use current frame, it represents CPU state in this case.
|
||||
+ If frame_find_by_id is changed to do it internally
|
||||
+ (it is contemplated there), remove this. */
|
||||
+ if (!frame)
|
||||
+ frame = get_current_frame ();
|
||||
+ /* Probably never happens. */
|
||||
if (!frame)
|
||||
error (_("Value being assigned to is no longer active."));
|
||||
|
@ -0,0 +1,78 @@
|
||||
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-quit-never-aborts.patch
|
||||
|
||||
;; Make the GDB quit processing non-abortable to cleanup everything properly.
|
||||
;;=fedora: It was useful only after gdb-6.8-attach-signalled-detach-stopped.patch .
|
||||
|
||||
We may abort the process of detaching threads with multiple SIGINTs - which are
|
||||
being sent during a testcase terminating its child GDB.
|
||||
|
||||
Some of the threads may not be properly PTRACE_DETACHed which hurts if they
|
||||
should have been detached with SIGSTOP (as they are accidentally left running
|
||||
on the debugger termination).
|
||||
|
||||
diff --git a/gdb/defs.h b/gdb/defs.h
|
||||
--- a/gdb/defs.h
|
||||
+++ b/gdb/defs.h
|
||||
@@ -168,6 +168,10 @@ extern void default_quit_handler (void);
|
||||
/* Flag that function quit should call quit_force. */
|
||||
extern volatile int sync_quit_force_run;
|
||||
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+extern int quit_flag_cleanup;
|
||||
+#endif
|
||||
+
|
||||
extern void quit (void);
|
||||
|
||||
/* Helper for the QUIT macro. */
|
||||
diff --git a/gdb/extension.c b/gdb/extension.c
|
||||
--- a/gdb/extension.c
|
||||
+++ b/gdb/extension.c
|
||||
@@ -820,6 +820,11 @@ check_quit_flag (void)
|
||||
int i, result = 0;
|
||||
const struct extension_language_defn *extlang;
|
||||
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+ if (quit_flag_cleanup)
|
||||
+ return 0;
|
||||
+#endif
|
||||
+
|
||||
ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
|
||||
{
|
||||
if (extlang->ops->check_quit_flag != NULL)
|
||||
diff --git a/gdb/top.c b/gdb/top.c
|
||||
--- a/gdb/top.c
|
||||
+++ b/gdb/top.c
|
||||
@@ -1606,7 +1606,13 @@ quit_force (int *exit_arg, int from_tty)
|
||||
|
||||
qt.from_tty = from_tty;
|
||||
|
||||
+#ifndef NEED_DETACH_SIGSTOP
|
||||
/* We want to handle any quit errors and exit regardless. */
|
||||
+#else
|
||||
+ /* We want to handle any quit errors and exit regardless but we should never
|
||||
+ get user-interrupted to properly detach the inferior. */
|
||||
+ quit_flag_cleanup = 1;
|
||||
+#endif
|
||||
|
||||
/* Get out of tfind mode, and kill or detach all inferiors. */
|
||||
TRY
|
||||
diff --git a/gdb/utils.c b/gdb/utils.c
|
||||
--- a/gdb/utils.c
|
||||
+++ b/gdb/utils.c
|
||||
@@ -108,6 +108,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time;
|
||||
|
||||
static int debug_timestamp = 0;
|
||||
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+/* Nonzero means we are already processing the quitting cleanups and we should
|
||||
+ no longer get aborted. */
|
||||
+
|
||||
+int quit_flag_cleanup;
|
||||
+#endif
|
||||
+
|
||||
/* Nonzero means that strings with character values >0x7F should be printed
|
||||
as octal escapes. Zero means just print the value (e.g. it's an
|
||||
international character, and the terminal or window can cope.) */
|
@ -0,0 +1,19 @@
|
||||
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-sparc64-silence-memcpy-check.patch
|
||||
|
||||
;; Silence memcpy check which returns false positive (sparc64)
|
||||
;;=push: But it is just a GCC workaround, look up the existing GCC PR for it.
|
||||
|
||||
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
|
||||
--- a/gdb/sparc-tdep.c
|
||||
+++ b/gdb/sparc-tdep.c
|
||||
@@ -1462,6 +1462,7 @@ sparc32_store_return_value (struct type *type, struct regcache *regcache,
|
||||
if (sparc_floating_p (type) || sparc_complex_floating_p (type))
|
||||
{
|
||||
/* Floating return values. */
|
||||
+ len = (len <= 8) ? len : 8;
|
||||
memcpy (buf, valbuf, len);
|
||||
regcache->cooked_write (SPARC_F0_REGNUM, buf);
|
||||
if (len > 4)
|
@ -0,0 +1,90 @@
|
||||
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-watchpoint-conditionals-test.patch
|
||||
|
||||
;; Test the watchpoints conditionals works.
|
||||
;;=fedoratest
|
||||
|
||||
For:
|
||||
http://sourceware.org/ml/gdb-patches/2008-04/msg00379.html
|
||||
http://sourceware.org/ml/gdb-cvs/2008-04/msg00104.html
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.base/watchpoint-cond.c b/gdb/testsuite/gdb.base/watchpoint-cond.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/watchpoint-cond.c
|
||||
@@ -0,0 +1,31 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2008 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/>.
|
||||
+
|
||||
+ Please email any bugs, comments, and/or additions to this file to:
|
||||
+ bug-gdb@prep.ai.mit.edu */
|
||||
+
|
||||
+int
|
||||
+main (int argc, char **argv)
|
||||
+{
|
||||
+ static int i = 0; /* `static' to start initialized. */
|
||||
+ int j = 2;
|
||||
+
|
||||
+ for (j = 0; j < 30; j++)
|
||||
+ i = 30 - j;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/watchpoint-cond.exp b/gdb/testsuite/gdb.base/watchpoint-cond.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/watchpoint-cond.exp
|
||||
@@ -0,0 +1,37 @@
|
||||
+# Copyright 2008 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 watchpoint-cond
|
||||
+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}
|
||||
+
|
||||
+if { [runto_main] < 0 } {
|
||||
+ untested watchpoint-cond
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test "watch i if i < 20" "atchpoint \[0-9\]+: i"
|
||||
+gdb_test "cont" "atchpoint \[0-9\]+: i.*Old value = 20.*New value = 19.*"
|
@ -0,0 +1,68 @@
|
||||
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-7.2.50-sparc-add-workaround-to-broken-debug-files.patch
|
||||
|
||||
;; Toolchain on sparc is slightly broken and debuginfo files are generated
|
||||
;; with non 64bit aligned tables/offsets.
|
||||
;; See for example readelf -S ../Xvnc.debug.
|
||||
;;
|
||||
;; As a consenquence calculation of sectp->filepos as used in
|
||||
;; dwarf2_read_section (gdb/dwarf2read.c:1525) will return a non aligned buffer
|
||||
;; that cannot be used directly as done with MMAP.
|
||||
;; Usage will result in a BusError.
|
||||
;;
|
||||
;; While we figure out what's wrong in the toolchain and do a full archive
|
||||
;; rebuild to fix it, we need to be able to use gdb :)
|
||||
;;=push
|
||||
|
||||
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
|
||||
--- a/gdb/gdb_bfd.c
|
||||
+++ b/gdb/gdb_bfd.c
|
||||
@@ -24,12 +24,14 @@
|
||||
#include "hashtab.h"
|
||||
#include "filestuff.h"
|
||||
#include "vec.h"
|
||||
+#ifndef __sparc__
|
||||
#ifdef HAVE_MMAP
|
||||
#include <sys/mman.h>
|
||||
#ifndef MAP_FAILED
|
||||
#define MAP_FAILED ((void *) -1)
|
||||
#endif
|
||||
#endif
|
||||
+#endif
|
||||
#include "target.h"
|
||||
#include "gdb/fileio.h"
|
||||
#include "inferior.h"
|
||||
@@ -484,6 +486,7 @@ free_one_bfd_section (bfd *abfd, asection *sectp, void *ignore)
|
||||
|
||||
if (sect != NULL && sect->data != NULL)
|
||||
{
|
||||
+#ifndef __sparc__
|
||||
#ifdef HAVE_MMAP
|
||||
if (sect->map_addr != NULL)
|
||||
{
|
||||
@@ -493,6 +496,7 @@ free_one_bfd_section (bfd *abfd, asection *sectp, void *ignore)
|
||||
gdb_assert (res == 0);
|
||||
}
|
||||
else
|
||||
+#endif
|
||||
#endif
|
||||
xfree (sect->data);
|
||||
}
|
||||
@@ -659,6 +663,7 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
|
||||
if (descriptor->data != NULL)
|
||||
goto done;
|
||||
|
||||
+#ifndef __sparc__
|
||||
#ifdef HAVE_MMAP
|
||||
if (!bfd_is_section_compressed (abfd, sectp))
|
||||
{
|
||||
@@ -693,6 +698,7 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_MMAP */
|
||||
+#endif
|
||||
|
||||
/* Handle compressed sections, or ordinary uncompressed sections in
|
||||
the no-mmap case. */
|
@ -0,0 +1,89 @@
|
||||
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-archer-pie-addons-keep-disabled.patch
|
||||
|
||||
;;=push+jan: Breakpoints disabling matching should not be based on address.
|
||||
|
||||
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
|
||||
--- a/gdb/breakpoint.c
|
||||
+++ b/gdb/breakpoint.c
|
||||
@@ -15522,6 +15522,50 @@ initialize_breakpoint_ops (void)
|
||||
|
||||
static struct cmd_list_element *enablebreaklist = NULL;
|
||||
|
||||
+void
|
||||
+breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta)
|
||||
+{
|
||||
+ struct bp_location *bl, **blp_tmp;
|
||||
+ int changed = 0;
|
||||
+
|
||||
+ gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
|
||||
+
|
||||
+ ALL_BP_LOCATIONS (bl, blp_tmp)
|
||||
+ {
|
||||
+ struct obj_section *osect;
|
||||
+
|
||||
+ /* BL->SECTION can be correctly NULL for breakpoints with multiple
|
||||
+ locations expanded through symtab. */
|
||||
+
|
||||
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
|
||||
+ {
|
||||
+ CORE_ADDR relocated_address;
|
||||
+ CORE_ADDR delta_offset;
|
||||
+
|
||||
+ delta_offset = ANOFFSET (delta, osect->the_bfd_section->index);
|
||||
+ if (delta_offset == 0)
|
||||
+ continue;
|
||||
+ relocated_address = bl->address + delta_offset;
|
||||
+
|
||||
+ if (obj_section_addr (osect) <= relocated_address
|
||||
+ && relocated_address < obj_section_endaddr (osect))
|
||||
+ {
|
||||
+ if (bl->inserted)
|
||||
+ remove_breakpoint (bl);
|
||||
+
|
||||
+ bl->address += delta_offset;
|
||||
+ bl->requested_address += delta_offset;
|
||||
+
|
||||
+ changed = 1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (changed)
|
||||
+ qsort (bp_locations, bp_locations_count, sizeof (*bp_locations),
|
||||
+ bp_locations_compare);
|
||||
+}
|
||||
+
|
||||
void
|
||||
_initialize_breakpoint (void)
|
||||
{
|
||||
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
|
||||
--- a/gdb/breakpoint.h
|
||||
+++ b/gdb/breakpoint.h
|
||||
@@ -1679,6 +1679,9 @@ extern const char *ep_parse_optional_if_clause (const char **arg);
|
||||
UIOUT iff debugging multiple threads. */
|
||||
extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout);
|
||||
|
||||
+extern void breakpoints_relocate (struct objfile *objfile,
|
||||
+ struct section_offsets *delta);
|
||||
+
|
||||
/* Print the specified breakpoint. */
|
||||
extern void print_breakpoint (breakpoint *bp);
|
||||
|
||||
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
|
||||
--- a/gdb/objfiles.c
|
||||
+++ b/gdb/objfiles.c
|
||||
@@ -883,6 +883,11 @@ objfile_relocate1 (struct objfile *objfile,
|
||||
obj_section_addr (s));
|
||||
}
|
||||
|
||||
+ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if
|
||||
+ their addresses match. */
|
||||
+ if (objfile->separate_debug_objfile_backlink == NULL)
|
||||
+ breakpoints_relocate (objfile, delta);
|
||||
+
|
||||
/* Data changed. */
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
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-archer-pie-addons.patch
|
||||
|
||||
;;=push+jan: May get obsoleted by Tom's unrelocated objfiles patch.
|
||||
|
||||
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
|
||||
--- a/gdb/gdbtypes.h
|
||||
+++ b/gdb/gdbtypes.h
|
||||
@@ -505,6 +505,7 @@ enum field_loc_kind
|
||||
{
|
||||
FIELD_LOC_KIND_BITPOS, /**< bitpos */
|
||||
FIELD_LOC_KIND_ENUMVAL, /**< enumval */
|
||||
+ /* This address is unrelocated by the objfile's ANOFFSET. */
|
||||
FIELD_LOC_KIND_PHYSADDR, /**< physaddr */
|
||||
FIELD_LOC_KIND_PHYSNAME, /**< physname */
|
||||
FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */
|
||||
@@ -556,6 +557,7 @@ union field_location
|
||||
field. Otherwise, physname is the mangled label of the
|
||||
static field. */
|
||||
|
||||
+ /* This address is unrelocated by the objfile's ANOFFSET. */
|
||||
CORE_ADDR physaddr;
|
||||
const char *physname;
|
||||
|
||||
@@ -1438,6 +1440,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
|
||||
#define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval)
|
||||
#define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0)
|
||||
#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
|
||||
+/* This address is unrelocated by the objfile's ANOFFSET. */
|
||||
#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
|
||||
#define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
|
||||
#define SET_FIELD_BITPOS(thisfld, bitpos) \
|
||||
@@ -1449,6 +1452,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
|
||||
#define SET_FIELD_PHYSNAME(thisfld, name) \
|
||||
(FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \
|
||||
FIELD_STATIC_PHYSNAME (thisfld) = (name))
|
||||
+/* This address is unrelocated by the objfile's ANOFFSET. */
|
||||
#define SET_FIELD_PHYSADDR(thisfld, addr) \
|
||||
(FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \
|
||||
FIELD_STATIC_PHYSADDR (thisfld) = (addr))
|
||||
@@ -1465,6 +1469,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
|
||||
#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
|
||||
#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n))
|
||||
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
|
||||
+/* This address is unrelocated by the objfile's ANOFFSET. */
|
||||
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
|
||||
#define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))
|
||||
#define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
|
||||
diff --git a/gdb/value.c b/gdb/value.c
|
||||
--- a/gdb/value.c
|
||||
+++ b/gdb/value.c
|
||||
@@ -2829,7 +2829,8 @@ value_static_field (struct type *type, int fieldno)
|
||||
{
|
||||
case FIELD_LOC_KIND_PHYSADDR:
|
||||
retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
|
||||
- TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
|
||||
+ TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)
|
||||
+ + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
|
||||
break;
|
||||
case FIELD_LOC_KIND_PHYSNAME:
|
||||
{
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,357 @@
|
||||
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-attach-fail-reasons-5of5.patch
|
||||
|
||||
;; Print reasons for failed attach/spawn incl. SELinux deny_ptrace (BZ 786878).
|
||||
;;=push+jan
|
||||
|
||||
http://sourceware.org/ml/gdb-patches/2012-03/msg00171.html
|
||||
|
||||
Hi,
|
||||
|
||||
and here is the last bit for new SELinux 'deny_ptrace':
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=786878
|
||||
|
||||
As even PTRACE_TRACEME fails in such case it needs to install hook for even
|
||||
that event.
|
||||
|
||||
Thanks,
|
||||
Jan
|
||||
|
||||
gdb/
|
||||
2012-03-06 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* common/linux-ptrace.c [HAVE_SELINUX_SELINUX_H]: include
|
||||
selinux/selinux.h.
|
||||
(linux_ptrace_attach_warnings): Call linux_ptrace_create_warnings.
|
||||
(linux_ptrace_create_warnings): New.
|
||||
* common/linux-ptrace.h (linux_ptrace_create_warnings): New declaration.
|
||||
* config.in: Regenerate.
|
||||
* configure: Regenerate.
|
||||
* configure.ac: Check selinux/selinux.h and the selinux library.
|
||||
* inf-ptrace.c (inf_ptrace_me): Check the ptrace result.
|
||||
* linux-nat.c (linux_nat_create_inferior): New variable ex. Wrap
|
||||
to_create_inferior into TRY_CATCH, call linux_ptrace_create_warnings.
|
||||
|
||||
gdb/gdbserver/
|
||||
* config.in: Regenerate.
|
||||
* configure: Regenerate.
|
||||
* configure.ac: Check selinux/selinux.h and the selinux library.
|
||||
* linux-low.c (linux_traceme): New function.
|
||||
(linux_create_inferior, linux_tracefork_child): Call it instead of
|
||||
direct ptrace.
|
||||
|
||||
diff --git a/gdb/config.in b/gdb/config.in
|
||||
--- a/gdb/config.in
|
||||
+++ b/gdb/config.in
|
||||
@@ -276,6 +276,9 @@
|
||||
/* Define if librpm library is being used. */
|
||||
#undef HAVE_LIBRPM
|
||||
|
||||
+/* Define to 1 if you have the `selinux' library (-lselinux). */
|
||||
+#undef HAVE_LIBSELINUX
|
||||
+
|
||||
/* Define to 1 if you have the <libunwind-ia64.h> header file. */
|
||||
#undef HAVE_LIBUNWIND_IA64_H
|
||||
|
||||
@@ -399,6 +402,9 @@
|
||||
/* Define to 1 if you have the `scm_new_smob' function. */
|
||||
#undef HAVE_SCM_NEW_SMOB
|
||||
|
||||
+/* Define to 1 if you have the <selinux/selinux.h> header file. */
|
||||
+#undef HAVE_SELINUX_SELINUX_H
|
||||
+
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
diff --git a/gdb/configure b/gdb/configure
|
||||
--- a/gdb/configure
|
||||
+++ b/gdb/configure
|
||||
@@ -15854,6 +15854,64 @@ cat >>confdefs.h <<_ACEOF
|
||||
_ACEOF
|
||||
|
||||
|
||||
+for ac_header in selinux/selinux.h
|
||||
+do :
|
||||
+ ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default"
|
||||
+if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then :
|
||||
+ cat >>confdefs.h <<_ACEOF
|
||||
+#define HAVE_SELINUX_SELINUX_H 1
|
||||
+_ACEOF
|
||||
+
|
||||
+fi
|
||||
+
|
||||
+done
|
||||
+
|
||||
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5
|
||||
+$as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; }
|
||||
+if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then :
|
||||
+ $as_echo_n "(cached) " >&6
|
||||
+else
|
||||
+ ac_check_lib_save_LIBS=$LIBS
|
||||
+LIBS="-lselinux $LIBS"
|
||||
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
+/* end confdefs.h. */
|
||||
+
|
||||
+/* Override any GCC internal prototype to avoid an error.
|
||||
+ Use char because int might match the return type of a GCC
|
||||
+ builtin and then its argument prototype would still apply. */
|
||||
+#ifdef __cplusplus
|
||||
+extern "C"
|
||||
+#endif
|
||||
+char security_get_boolean_active ();
|
||||
+int
|
||||
+main ()
|
||||
+{
|
||||
+return security_get_boolean_active ();
|
||||
+ ;
|
||||
+ return 0;
|
||||
+}
|
||||
+_ACEOF
|
||||
+if ac_fn_c_try_link "$LINENO"; then :
|
||||
+ ac_cv_lib_selinux_security_get_boolean_active=yes
|
||||
+else
|
||||
+ ac_cv_lib_selinux_security_get_boolean_active=no
|
||||
+fi
|
||||
+rm -f core conftest.err conftest.$ac_objext \
|
||||
+ conftest$ac_exeext conftest.$ac_ext
|
||||
+LIBS=$ac_check_lib_save_LIBS
|
||||
+fi
|
||||
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5
|
||||
+$as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; }
|
||||
+if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then :
|
||||
+ cat >>confdefs.h <<_ACEOF
|
||||
+#define HAVE_LIBSELINUX 1
|
||||
+_ACEOF
|
||||
+
|
||||
+ LIBS="-lselinux $LIBS"
|
||||
+
|
||||
+fi
|
||||
+
|
||||
+
|
||||
|
||||
# Support for --with-sysroot is a copy of GDB_AC_WITH_DIR,
|
||||
# except that the argument to --with-sysroot is optional.
|
||||
diff --git a/gdb/configure.ac b/gdb/configure.ac
|
||||
--- a/gdb/configure.ac
|
||||
+++ b/gdb/configure.ac
|
||||
@@ -2054,6 +2054,10 @@ case $host_os in
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED(GDBINIT,"$gdbinit",[The .gdbinit filename.])
|
||||
|
||||
+dnl Check security_get_boolean_active availability.
|
||||
+AC_CHECK_HEADERS(selinux/selinux.h)
|
||||
+AC_CHECK_LIB(selinux, security_get_boolean_active)
|
||||
+
|
||||
dnl Handle optional features that can be enabled.
|
||||
|
||||
# Support for --with-sysroot is a copy of GDB_AC_WITH_DIR,
|
||||
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
|
||||
--- a/gdb/gdbserver/config.in
|
||||
+++ b/gdb/gdbserver/config.in
|
||||
@@ -126,6 +126,9 @@
|
||||
/* Define to 1 if you have the `mcheck' library (-lmcheck). */
|
||||
#undef HAVE_LIBMCHECK
|
||||
|
||||
+/* Define to 1 if you have the `selinux' library (-lselinux). */
|
||||
+#undef HAVE_LIBSELINUX
|
||||
+
|
||||
/* Define if the target supports branch tracing. */
|
||||
#undef HAVE_LINUX_BTRACE
|
||||
|
||||
@@ -202,6 +205,9 @@
|
||||
/* Define to 1 if you have the `pwrite' function. */
|
||||
#undef HAVE_PWRITE
|
||||
|
||||
+/* Define to 1 if you have the <selinux/selinux.h> header file. */
|
||||
+#undef HAVE_SELINUX_SELINUX_H
|
||||
+
|
||||
/* Define to 1 if you have the `setns' function. */
|
||||
#undef HAVE_SETNS
|
||||
|
||||
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
|
||||
--- a/gdb/gdbserver/configure
|
||||
+++ b/gdb/gdbserver/configure
|
||||
@@ -8535,6 +8535,64 @@ if $want_ipa ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
+for ac_header in selinux/selinux.h
|
||||
+do :
|
||||
+ ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default"
|
||||
+if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then :
|
||||
+ cat >>confdefs.h <<_ACEOF
|
||||
+#define HAVE_SELINUX_SELINUX_H 1
|
||||
+_ACEOF
|
||||
+
|
||||
+fi
|
||||
+
|
||||
+done
|
||||
+
|
||||
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5
|
||||
+$as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; }
|
||||
+if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then :
|
||||
+ $as_echo_n "(cached) " >&6
|
||||
+else
|
||||
+ ac_check_lib_save_LIBS=$LIBS
|
||||
+LIBS="-lselinux $LIBS"
|
||||
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
+/* end confdefs.h. */
|
||||
+
|
||||
+/* Override any GCC internal prototype to avoid an error.
|
||||
+ Use char because int might match the return type of a GCC
|
||||
+ builtin and then its argument prototype would still apply. */
|
||||
+#ifdef __cplusplus
|
||||
+extern "C"
|
||||
+#endif
|
||||
+char security_get_boolean_active ();
|
||||
+int
|
||||
+main ()
|
||||
+{
|
||||
+return security_get_boolean_active ();
|
||||
+ ;
|
||||
+ return 0;
|
||||
+}
|
||||
+_ACEOF
|
||||
+if ac_fn_c_try_link "$LINENO"; then :
|
||||
+ ac_cv_lib_selinux_security_get_boolean_active=yes
|
||||
+else
|
||||
+ ac_cv_lib_selinux_security_get_boolean_active=no
|
||||
+fi
|
||||
+rm -f core conftest.err conftest.$ac_objext \
|
||||
+ conftest$ac_exeext conftest.$ac_ext
|
||||
+LIBS=$ac_check_lib_save_LIBS
|
||||
+fi
|
||||
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5
|
||||
+$as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; }
|
||||
+if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then :
|
||||
+ cat >>confdefs.h <<_ACEOF
|
||||
+#define HAVE_LIBSELINUX 1
|
||||
+_ACEOF
|
||||
+
|
||||
+ LIBS="-lselinux $LIBS"
|
||||
+
|
||||
+fi
|
||||
+
|
||||
+
|
||||
|
||||
|
||||
|
||||
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
|
||||
--- a/gdb/gdbserver/configure.ac
|
||||
+++ b/gdb/gdbserver/configure.ac
|
||||
@@ -486,6 +486,10 @@ if $want_ipa ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
+dnl Check security_get_boolean_active availability.
|
||||
+AC_CHECK_HEADERS(selinux/selinux.h)
|
||||
+AC_CHECK_LIB(selinux, security_get_boolean_active)
|
||||
+
|
||||
AC_SUBST(GDBSERVER_DEPFILES)
|
||||
AC_SUBST(GDBSERVER_LIBS)
|
||||
AC_SUBST(srv_xmlbuiltin)
|
||||
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
|
||||
--- a/gdb/gdbserver/linux-low.c
|
||||
+++ b/gdb/gdbserver/linux-low.c
|
||||
@@ -967,7 +967,16 @@ linux_ptrace_fun ()
|
||||
{
|
||||
if (ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0,
|
||||
(PTRACE_TYPE_ARG4) 0) < 0)
|
||||
- trace_start_error_with_name ("ptrace");
|
||||
+ {
|
||||
+ int save_errno = errno;
|
||||
+
|
||||
+ std::string msg (linux_ptrace_create_warnings ());
|
||||
+
|
||||
+ msg += _("Cannot trace created process");
|
||||
+
|
||||
+ errno = save_errno;
|
||||
+ trace_start_error_with_name (msg.c_str ());
|
||||
+ }
|
||||
|
||||
if (setpgid (0, 0) < 0)
|
||||
trace_start_error_with_name ("setpgid");
|
||||
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
|
||||
--- a/gdb/linux-nat.c
|
||||
+++ b/gdb/linux-nat.c
|
||||
@@ -1089,7 +1089,17 @@ linux_nat_target::create_inferior (const char *exec_file,
|
||||
/* Make sure we report all signals during startup. */
|
||||
pass_signals (0, NULL);
|
||||
|
||||
- inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty);
|
||||
+ TRY
|
||||
+ {
|
||||
+ inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty);
|
||||
+ }
|
||||
+ CATCH (ex, RETURN_MASK_ERROR)
|
||||
+ {
|
||||
+ std::string result = linux_ptrace_create_warnings ();
|
||||
+
|
||||
+ throw_error (ex.error, "%s%s", result.c_str (), ex.message);
|
||||
+ }
|
||||
+ END_CATCH
|
||||
}
|
||||
|
||||
/* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not
|
||||
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
|
||||
--- a/gdb/nat/linux-ptrace.c
|
||||
+++ b/gdb/nat/linux-ptrace.c
|
||||
@@ -25,6 +25,10 @@
|
||||
#include <sys/procfs.h>
|
||||
#endif
|
||||
|
||||
+#ifdef HAVE_SELINUX_SELINUX_H
|
||||
+# include <selinux/selinux.h>
|
||||
+#endif /* HAVE_SELINUX_SELINUX_H */
|
||||
+
|
||||
/* Stores the ptrace options supported by the running kernel.
|
||||
A value of -1 means we did not check for features yet. A value
|
||||
of 0 means there are no supported features. */
|
||||
@@ -50,6 +54,8 @@ linux_ptrace_attach_fail_reason (pid_t pid)
|
||||
"terminated"),
|
||||
(int) pid);
|
||||
|
||||
+ result += linux_ptrace_create_warnings ();
|
||||
+
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -583,6 +589,25 @@ linux_ptrace_init_warnings (void)
|
||||
linux_ptrace_test_ret_to_nx ();
|
||||
}
|
||||
|
||||
+/* Print all possible reasons we could fail to create a traced process. */
|
||||
+
|
||||
+std::string
|
||||
+linux_ptrace_create_warnings ()
|
||||
+{
|
||||
+ std::string result;
|
||||
+
|
||||
+#ifdef HAVE_LIBSELINUX
|
||||
+ /* -1 is returned for errors, 0 if it has no effect, 1 if PTRACE_ATTACH is
|
||||
+ forbidden. */
|
||||
+ if (security_get_boolean_active ("deny_ptrace") == 1)
|
||||
+ string_appendf (result,
|
||||
+ _("the SELinux boolean 'deny_ptrace' is enabled, "
|
||||
+ "you can disable this process attach protection by: "
|
||||
+ "(gdb) shell sudo setsebool deny_ptrace=0\n"));
|
||||
+#endif /* HAVE_LIBSELINUX */
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
/* Extract extended ptrace event from wait status. */
|
||||
|
||||
int
|
||||
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
|
||||
--- a/gdb/nat/linux-ptrace.h
|
||||
+++ b/gdb/nat/linux-ptrace.h
|
||||
@@ -184,6 +184,7 @@ extern std::string linux_ptrace_attach_fail_reason (pid_t pid);
|
||||
extern std::string linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err);
|
||||
|
||||
extern void linux_ptrace_init_warnings (void);
|
||||
+extern std::string linux_ptrace_create_warnings ();
|
||||
extern void linux_check_ptrace_features (void);
|
||||
extern void linux_enable_event_reporting (pid_t pid, int attached);
|
||||
extern void linux_disable_event_reporting (pid_t pid);
|
@ -0,0 +1,45 @@
|
||||
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-btrobust.patch
|
||||
|
||||
;; Continue backtrace even if a frame filter throws an exception (Phil Muldoon).
|
||||
;;=push
|
||||
|
||||
This should fix the error with glib. An error message will still be
|
||||
printed, but a default backtrace will occur in this case.
|
||||
|
||||
--
|
||||
|
||||
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
|
||||
--- a/gdb/python/py-framefilter.c
|
||||
+++ b/gdb/python/py-framefilter.c
|
||||
@@ -1151,6 +1151,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
|
||||
htab_eq_pointer,
|
||||
NULL));
|
||||
|
||||
+ int count_printed = 0;
|
||||
while (true)
|
||||
{
|
||||
gdbpy_ref<> item (PyIter_Next (iterable.get ()));
|
||||
@@ -1159,8 +1160,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
|
||||
{
|
||||
if (PyErr_Occurred ())
|
||||
{
|
||||
- throw_quit_or_print_exception ();
|
||||
- return EXT_LANG_BT_ERROR;
|
||||
+ gdbpy_print_stack ();
|
||||
+ return count_printed > 0 ? EXT_LANG_BT_ERROR : EXT_LANG_BT_NO_FILTERS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1193,7 +1194,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
|
||||
/* Do not exit on error printing a single frame. Print the
|
||||
error and continue with other frames. */
|
||||
if (success == EXT_LANG_BT_ERROR)
|
||||
- throw_quit_or_print_exception ();
|
||||
+ gdbpy_print_stack ();
|
||||
+ count_printed++;
|
||||
}
|
||||
|
||||
return success;
|
@ -0,0 +1,178 @@
|
||||
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-bz1219747-attach-kills.patch
|
||||
|
||||
;; Never kill PID on: gdb exec PID (Jan Kratochvil, RH BZ 1219747).
|
||||
;;=push+jan
|
||||
|
||||
http://sourceware.org/ml/gdb-patches/2015-10/msg00301.html
|
||||
|
||||
Hi,
|
||||
|
||||
in some cases with deleted main executable GDB will want to kill the inferior.
|
||||
|
||||
$ cp /bin/sleep /tmp/sleep;/tmp/sleep 1h&p=$!
|
||||
$ rm /tmp/sleep
|
||||
$ gdb /tmp/sleep $p
|
||||
GNU gdb (GDB) 7.10.50.20151016-cvs
|
||||
/tmp/sleep: No such file or directory.
|
||||
Attaching to process 9694
|
||||
/tmp/sleep (deleted): No such file or directory.
|
||||
A program is being debugged already. Kill it? (y or n) _
|
||||
|
||||
The first attachment of "/tmp/sleep" commandline argument errors at:
|
||||
|
||||
267 if (scratch_chan < 0)
|
||||
268 perror_with_name (filename);
|
||||
1051 if (catch_command_errors_const (exec_file_attach, execarg,
|
||||
1052 !batch_flag))
|
||||
|
||||
Then GDB tries to attach to the process $p:
|
||||
|
||||
1082 if (catch_command_errors (attach_command, pid_or_core_arg,
|
||||
1083 !batch_flag) == 0)
|
||||
|
||||
This succeeds and since this moment GDB has a valid inferior. But despite that
|
||||
the lines
|
||||
1082 if (catch_command_errors (attach_command, pid_or_core_arg,
|
||||
1083 !batch_flag) == 0)
|
||||
still fail because consequently attach_command() fails to find the associated
|
||||
executable file:
|
||||
|
||||
267 if (scratch_chan < 0)
|
||||
268 perror_with_name (filename);
|
||||
1082 if (catch_command_errors (attach_command, pid_or_core_arg,
|
||||
1083 !batch_flag) == 0)
|
||||
|
||||
and therefore GDB executes the following:
|
||||
|
||||
(gdb) bt
|
||||
2179 if (have_inferiors ())
|
||||
2180 {
|
||||
2181 if (!from_tty
|
||||
2182 || !have_live_inferiors ()
|
||||
2183 || query (_("A program is being debugged already. Kill it? ")))
|
||||
2184 iterate_over_inferiors (dispose_inferior, NULL);
|
||||
2185 else
|
||||
2186 error (_("Program not killed."));
|
||||
2187 }
|
||||
1084 catch_command_errors (core_file_command, pid_or_core_arg,
|
||||
1085 !batch_flag);
|
||||
|
||||
No regressions on {x86_64,x86_64-m32,i686}-fedora24pre-linux-gnu.
|
||||
|
||||
Thanks,
|
||||
Jan
|
||||
|
||||
gdb/ChangeLog
|
||||
2015-10-16 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* main.c (captured_main): Run core_file_command for pid_or_core_arg
|
||||
only if not have_inferiors ().
|
||||
|
||||
gdb/testsuite/ChangeLog
|
||||
2015-10-16 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.base/attach-kills.c: New.
|
||||
* gdb.base/attach-kills.exp: New.
|
||||
|
||||
diff --git a/gdb/main.c b/gdb/main.c
|
||||
--- a/gdb/main.c
|
||||
+++ b/gdb/main.c
|
||||
@@ -1115,7 +1115,10 @@ captured_main_1 (struct captured_main_args *context)
|
||||
if (isdigit (pid_or_core_arg[0]))
|
||||
{
|
||||
if (catch_command_errors (attach_command, pid_or_core_arg,
|
||||
- !batch_flag) == 0)
|
||||
+ !batch_flag) == 0
|
||||
+ /* attach_command could succeed partially and core_file_command
|
||||
+ would try to kill it. */
|
||||
+ && !have_inferiors ())
|
||||
catch_command_errors (core_file_command, pid_or_core_arg,
|
||||
!batch_flag);
|
||||
}
|
||||
diff --git a/gdb/testsuite/gdb.base/attach-kills.c b/gdb/testsuite/gdb.base/attach-kills.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/attach-kills.c
|
||||
@@ -0,0 +1,25 @@
|
||||
+/* 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/>. */
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+ sleep (600);
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.base/attach-kills.exp b/gdb/testsuite/gdb.base/attach-kills.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/attach-kills.exp
|
||||
@@ -0,0 +1,49 @@
|
||||
+# Copyright (C) 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 { ![can_spawn_for_attach] } {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+standard_testfile
|
||||
+
|
||||
+if { [build_executable ${testfile}.exp $testfile] == -1 } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Start the program running and then wait for a bit, to be sure
|
||||
+# that it can be attached to.
|
||||
+
|
||||
+set test_spawn_id [spawn_wait_for_attach $binfile]
|
||||
+set testpid [spawn_id_get_pid $test_spawn_id]
|
||||
+
|
||||
+remote_exec target "cp -pf -- $binfile $binfile-copy"
|
||||
+remote_exec target "rm -f -- $binfile"
|
||||
+
|
||||
+set test "start gdb"
|
||||
+set res [gdb_spawn_with_cmdline_opts \
|
||||
+ "-iex \"set height 0\" -iex \"set width 0\" /DoEsNoTeXySt $testpid"]
|
||||
+if { $res != 0} {
|
||||
+ fail "$test (spawn)"
|
||||
+ kill_wait_spawned_process $test_spawn_id
|
||||
+ return -1
|
||||
+}
|
||||
+gdb_test_multiple "" $test {
|
||||
+ -re "\r\nAttaching to .*\r\n$gdb_prompt $" {
|
||||
+ pass $test
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+kill_wait_spawned_process $test_spawn_id
|
@ -0,0 +1,130 @@
|
||||
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-bz533176-fortran-omp-step.patch
|
||||
|
||||
;; Fix stepping with OMP parallel Fortran sections (BZ 533176).
|
||||
;;=push+jan: It requires some better DWARF annotations.
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=533176#c4
|
||||
|
||||
I find it a bug in DWARF and gdb behaves correctly according to it. From the
|
||||
current DWARF's point of view the is a function call which you skip by "next".
|
||||
|
||||
If you hide any /usr/lib/debug such as using:
|
||||
gdb -nx -ex 'set debug-file-directory /qwe' -ex 'file ./tpcommon_gfortran44'
|
||||
and use "step" command instead of "next" there it will work.
|
||||
(You need to hide debuginfo from libgomp as you would step into libgomp sources
|
||||
to maintain the threads for execution.)
|
||||
|
||||
There should be some DWARF extension for it, currently tried to detect
|
||||
substring ".omp_fn." as this function is called "MAIN__.omp_fn.0" and do not
|
||||
consider such sub-function as a skippable by "next".
|
||||
|
||||
Another problem is that with "set scheduler-locking" being "off" (default
|
||||
upstream) or "step" (default in F/RHEL) the simultaneous execution of the
|
||||
threads is inconvenient. Setting it to "on" will lockup the debugging as the
|
||||
threads need to get synchronized at some point. This is a more general
|
||||
debugging problem of GOMP outside of the scope of this Bug.
|
||||
|
||||
diff --git a/gdb/infrun.c b/gdb/infrun.c
|
||||
--- a/gdb/infrun.c
|
||||
+++ b/gdb/infrun.c
|
||||
@@ -6695,6 +6695,16 @@ process_event_stop_test (struct execution_control_state *ecs)
|
||||
|
||||
if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
|
||||
{
|
||||
+ struct symbol *stop_fn = find_pc_function (stop_pc);
|
||||
+ struct minimal_symbol *stopf = lookup_minimal_symbol_by_pc (stop_pc).minsym;
|
||||
+
|
||||
+ if ((stop_fn == NULL
|
||||
+ || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL)
|
||||
+ /* gcc-4.7.2-9.fc19.x86_64 uses a new format. */
|
||||
+ && (stopf == NULL
|
||||
+ || strstr (MSYMBOL_LINKAGE_NAME (stopf), "._omp_fn.") == NULL))
|
||||
+{ /* ".omp_fn." */
|
||||
+
|
||||
/* We're doing a "next".
|
||||
|
||||
Normal (forward) execution: set a breakpoint at the
|
||||
@@ -6728,6 +6738,7 @@ process_event_stop_test (struct execution_control_state *ecs)
|
||||
|
||||
keep_going (ecs);
|
||||
return;
|
||||
+} /* ".omp_fn." */
|
||||
}
|
||||
|
||||
/* If we are in a function call trampoline (a stub between the
|
||||
diff --git a/gdb/testsuite/gdb.fortran/omp-step.exp b/gdb/testsuite/gdb.fortran/omp-step.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.fortran/omp-step.exp
|
||||
@@ -0,0 +1,31 @@
|
||||
+# 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 "omp-step"
|
||||
+set srcfile ${testfile}.f90
|
||||
+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90 additional_flags=-fopenmp}] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+if ![runto [gdb_get_line_number "start-here"]] {
|
||||
+ perror "Couldn't run to start-here"
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+gdb_test "next" {!\$omp parallel} "step closer"
|
||||
+gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp"
|
||||
+
|
||||
+gdb_breakpoint [gdb_get_line_number "success"]
|
||||
+gdb_continue_to_breakpoint "success" ".*success.*"
|
||||
diff --git a/gdb/testsuite/gdb.fortran/omp-step.f90 b/gdb/testsuite/gdb.fortran/omp-step.f90
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.fortran/omp-step.f90
|
||||
@@ -0,0 +1,32 @@
|
||||
+! 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/>.
|
||||
+
|
||||
+ use omp_lib
|
||||
+ integer nthreads, i, a(1000)
|
||||
+ nthreads = omp_get_num_threads()
|
||||
+ if (nthreads .gt. 1000) call abort
|
||||
+
|
||||
+ do i = 1, nthreads
|
||||
+ a(i) = 0
|
||||
+ end do
|
||||
+ print *, "start-here"
|
||||
+!$omp parallel
|
||||
+ a(omp_get_thread_num() + 1) = 1
|
||||
+!$omp end parallel
|
||||
+ do i = 1, nthreads
|
||||
+ if (a(i) .ne. 1) call abort
|
||||
+ end do
|
||||
+ print *, "success"
|
||||
+ end
|
@ -0,0 +1,175 @@
|
||||
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-bz541866-rwatch-before-run.patch
|
||||
|
||||
;; Fix i386+x86_64 rwatch+awatch before run, regression against 6.8 (BZ 541866).
|
||||
;; Fix i386 rwatch+awatch before run (BZ 688788, on top of BZ 541866).
|
||||
;;=push+jan: It should be fixed properly instead.
|
||||
|
||||
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
|
||||
--- a/gdb/breakpoint.c
|
||||
+++ b/gdb/breakpoint.c
|
||||
@@ -8807,7 +8807,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
|
||||
int enabled, int internal, unsigned flags,
|
||||
int display_canonical)
|
||||
{
|
||||
- int i;
|
||||
+ int i ATTRIBUTE_UNUSED;
|
||||
|
||||
if (type == bp_hardware_breakpoint)
|
||||
{
|
||||
@@ -14356,7 +14356,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
|
||||
|
||||
if (bpt->type == bp_hardware_breakpoint)
|
||||
{
|
||||
- int i;
|
||||
+ int i ATTRIBUTE_UNUSED;
|
||||
i = hw_breakpoint_used_count ();
|
||||
target_resources_ok =
|
||||
target_can_use_hardware_watchpoint (bp_hardware_breakpoint,
|
||||
diff --git a/gdb/config/i386/nm-linux.h b/gdb/config/i386/nm-linux.h
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/config/i386/nm-linux.h
|
||||
@@ -0,0 +1,28 @@
|
||||
+/* Native support for GNU/Linux i386.
|
||||
+
|
||||
+ Copyright 2010 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/>. */
|
||||
+
|
||||
+#ifndef NM_LINUX_H
|
||||
+#define NM_LINUX_H
|
||||
+
|
||||
+#include "config/nm-linux.h"
|
||||
+
|
||||
+/* Red Hat backward compatibility with gdb-6.8. */
|
||||
+#define target_can_use_hardware_watchpoint(type, cnt, ot) 1
|
||||
+
|
||||
+#endif /* NM_LINUX64_H */
|
||||
diff --git a/gdb/config/i386/nm-linux64.h b/gdb/config/i386/nm-linux64.h
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/config/i386/nm-linux64.h
|
||||
@@ -0,0 +1,28 @@
|
||||
+/* Native support for GNU/Linux amd64.
|
||||
+
|
||||
+ Copyright 2010 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/>. */
|
||||
+
|
||||
+#ifndef NM_LINUX64_H
|
||||
+#define NM_LINUX64_H
|
||||
+
|
||||
+#include "config/nm-linux.h"
|
||||
+
|
||||
+/* Red Hat backward compatibility with gdb-6.8. */
|
||||
+#define target_can_use_hardware_watchpoint(type, cnt, ot) 1
|
||||
+
|
||||
+#endif /* NM_LINUX64_H */
|
||||
diff --git a/gdb/configure.nat b/gdb/configure.nat
|
||||
--- a/gdb/configure.nat
|
||||
+++ b/gdb/configure.nat
|
||||
@@ -238,6 +238,7 @@ case ${gdb_host} in
|
||||
;;
|
||||
i386)
|
||||
# Host: Intel 386 running GNU/Linux.
|
||||
+ NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux.h"
|
||||
NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
|
||||
i386-linux-nat.o x86-linux-nat.o linux-btrace.o \
|
||||
x86-linux.o x86-linux-dregs.o"
|
||||
@@ -290,6 +291,7 @@ case ${gdb_host} in
|
||||
case ${gdb_host_cpu} in
|
||||
i386)
|
||||
# Host: GNU/Linux x86-64
|
||||
+ NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux64.h"
|
||||
NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
|
||||
amd64-nat.o amd64-linux-nat.o x86-linux-nat.o linux-btrace.o \
|
||||
x86-linux.o x86-linux-dregs.o amd64-linux-siginfo.o"
|
||||
diff --git a/gdb/target.h b/gdb/target.h
|
||||
--- a/gdb/target.h
|
||||
+++ b/gdb/target.h
|
||||
@@ -1953,9 +1953,11 @@ extern struct thread_info *target_thread_handle_to_thread_info
|
||||
one. OTHERTYPE is the number of watchpoints of other types than
|
||||
this one used so far. */
|
||||
|
||||
+#ifndef target_can_use_hardware_watchpoint
|
||||
#define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \
|
||||
(current_top_target ()->can_use_hw_breakpoint) ( \
|
||||
TYPE, CNT, OTHERTYPE)
|
||||
+#endif
|
||||
|
||||
/* Returns the number of debug registers needed to watch the given
|
||||
memory region, or zero if not supported. */
|
||||
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp b/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp
|
||||
@@ -0,0 +1,40 @@
|
||||
+# Copyright 2009, 2010 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/>.
|
||||
+
|
||||
+# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set.
|
||||
+if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]
|
||||
+ && ![istarget "ia64-*-*"])
|
||||
+ || [target_info exists gdb,no_hardware_watchpoints]} then {
|
||||
+ verbose "Skipping watchpoint-hw-before-run test."
|
||||
+ return
|
||||
+}
|
||||
+
|
||||
+set test watchpoint-hw-before-run
|
||||
+set srcfile watchpoint-hw-hit-once.c
|
||||
+if { [prepare_for_testing ${test}.exp ${test} ${srcfile}] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_test "rwatch watchee" "ardware read watchpoint 1: watchee"
|
||||
+
|
||||
+# `runto_main' or `runto main' would delete the watchpoint created above.
|
||||
+
|
||||
+if { [gdb_start_cmd] < 0 } {
|
||||
+ untested start
|
||||
+ return -1
|
||||
+}
|
||||
+gdb_test "" "main .* at .*" "start"
|
||||
+
|
||||
+gdb_test "continue" "Continuing.\r\n\r\nHardware read watchpoint \[0-9\]+: watchee\r\n\r\nValue = 0\r\n.*"
|
@ -0,0 +1,71 @@
|
||||
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-bz568248-oom-is-error.patch
|
||||
|
||||
;; Out of memory is just an error, not fatal (uninitialized VLS vars, BZ 568248).
|
||||
;;=push+jan: Inferior objects should be read in parts, then this patch gets obsoleted.
|
||||
|
||||
http://sourceware.org/ml/gdb-patches/2010-06/msg00005.html
|
||||
|
||||
Hi,
|
||||
|
||||
unfortunately I see this problem reproducible only with the
|
||||
archer-jankratochvil-vla branch (VLA = Variable Length Arrays - char[var]).
|
||||
OTOH this branch I hopefully submit in some form for FSF GDB later.
|
||||
|
||||
In this case (a general problem but tested for example on Fedora 13 i686):
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char a[argc];
|
||||
return a[0];
|
||||
}
|
||||
|
||||
(gdb) start
|
||||
(gdb) print a
|
||||
../../gdb/utils.c:1251: internal-error: virtual memory exhausted: can't allocate 4294951689 bytes.
|
||||
|
||||
It is apparently because boundary for the variable `a' is not initialized
|
||||
there. Users notice it due to Eclipse-CDT trying to automatically display all
|
||||
the local variables on each step.
|
||||
|
||||
Apparentl no regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
|
||||
But is anone aware of the reasons to use internal_error there?
|
||||
I find simple error as a perfectly reasonable there.
|
||||
(history only tracks it since the initial import)
|
||||
|
||||
IIRC this idea has been discussed with Tom Tromey, not sure of its origin.
|
||||
|
||||
I understand it may be offtopic for FSF GDB but from some GDB crashes I am not
|
||||
sure if it can happen only due to the VLA variables.
|
||||
|
||||
Thanks,
|
||||
Jan
|
||||
|
||||
gdb/
|
||||
2010-06-01 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* utils.c (nomem): Change internal_error to error.
|
||||
|
||||
diff --git a/gdb/utils.c b/gdb/utils.c
|
||||
--- a/gdb/utils.c
|
||||
+++ b/gdb/utils.c
|
||||
@@ -746,13 +746,11 @@ malloc_failure (long size)
|
||||
{
|
||||
if (size > 0)
|
||||
{
|
||||
- internal_error (__FILE__, __LINE__,
|
||||
- _("virtual memory exhausted: can't allocate %ld bytes."),
|
||||
- size);
|
||||
+ error (_("virtual memory exhausted: can't allocate %ld bytes."), size);
|
||||
}
|
||||
else
|
||||
{
|
||||
- internal_error (__FILE__, __LINE__, _("virtual memory exhausted."));
|
||||
+ error (_("virtual memory exhausted."));
|
||||
}
|
||||
}
|
||||
|
@ -1,139 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Tue, 1 Jun 2021 10:14:31 -0700
|
||||
Subject: gdb-dont-overwrite-fsgsbase-m32.patch
|
||||
|
||||
;; Backport "[gdb/server] Don't overwrite fs/gs_base with -m32"
|
||||
;; (Tom de Vries)
|
||||
|
||||
Consider a minimal test-case test.c:
|
||||
...
|
||||
int main (void) { return 0; }
|
||||
...
|
||||
compiled with -m32:
|
||||
...
|
||||
$ gcc test.c -m32
|
||||
...
|
||||
|
||||
When running the exec using gdbserver on openSUSE Factory (currently running a
|
||||
linux kernel version 5.10.5):
|
||||
...
|
||||
$ gdbserver localhost:12345 a.out
|
||||
...
|
||||
to which we connect in a gdb session, we run into a segfault in the inferior:
|
||||
...
|
||||
$ gdb -batch -q -ex "target remote localhost:12345" -ex continue
|
||||
Program received signal SIGSEGV, Segmentation fault.
|
||||
0xf7dd8bd2 in init_cacheinfo () at ../sysdeps/x86/cacheinfo.c:761
|
||||
...
|
||||
|
||||
The segfault is caused by gdbserver overwriting $gs_base with 0 using
|
||||
PTRACE_SETREGS. After it is overwritten, the next use of $gs in the inferior
|
||||
will trigger the segfault.
|
||||
|
||||
Before linux kernel version 5.9, the value used by PTRACE_SETREGS for $gs_base
|
||||
was ignored, but starting version 5.9, the linux kernel has support for
|
||||
intel architecture extension FSGSBASE, which allows users to modify $gs_base,
|
||||
and consequently PTRACE_SETREGS can no longer ignore the $gs_base value.
|
||||
|
||||
The overwrite of $gs_base with 0 is done by a memset in x86_fill_gregset,
|
||||
which was added in commit 9e0aa64f551 "Fix gdbserver qGetTLSAddr for
|
||||
x86_64 -m32". The memset intends to zero-extend 32-bit registers that are
|
||||
tracked in the regcache to 64-bit when writing them into the PTRACE_SETREGS
|
||||
data argument. But in addition, it overwrites other registers that are
|
||||
not tracked in the regcache, such as $gs_base.
|
||||
|
||||
Fix the segfault by redoing the fix from commit 9e0aa64f551 in minimal form.
|
||||
|
||||
Tested on x86_64-linux:
|
||||
- openSUSE Leap 15.2 (using kernel version 5.3.18):
|
||||
- native
|
||||
- gdbserver -m32
|
||||
- -m32
|
||||
- openSUSE Factory (using kernel version 5.10.5):
|
||||
- native
|
||||
- m32
|
||||
|
||||
gdbserver/ChangeLog:
|
||||
|
||||
2021-01-20 Tom de Vries <tdevries@suse.de>
|
||||
|
||||
* linux-x86-low.cc (collect_register_i386): New function.
|
||||
(x86_fill_gregset): Remove memset. Use collect_register_i386.
|
||||
|
||||
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
|
||||
--- a/gdbserver/linux-x86-low.cc
|
||||
+++ b/gdbserver/linux-x86-low.cc
|
||||
@@ -397,6 +397,35 @@ x86_target::low_cannot_fetch_register (int regno)
|
||||
return regno >= I386_NUM_REGS;
|
||||
}
|
||||
|
||||
+static void
|
||||
+collect_register_i386 (struct regcache *regcache, int regno, void *buf)
|
||||
+{
|
||||
+ collect_register (regcache, regno, buf);
|
||||
+
|
||||
+#ifdef __x86_64__
|
||||
+ /* In case of x86_64 -m32, collect_register only writes 4 bytes, but the
|
||||
+ space reserved in buf for the register is 8 bytes. Make sure the entire
|
||||
+ reserved space is initialized. */
|
||||
+
|
||||
+ gdb_assert (register_size (regcache->tdesc, regno) == 4);
|
||||
+
|
||||
+ if (regno == RAX)
|
||||
+ {
|
||||
+ /* Sign extend EAX value to avoid potential syscall restart
|
||||
+ problems.
|
||||
+
|
||||
+ See amd64_linux_collect_native_gregset() in
|
||||
+ gdb/amd64-linux-nat.c for a detailed explanation. */
|
||||
+ *(int64_t *) buf = *(int32_t *) buf;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ /* Zero-extend. */
|
||||
+ *(uint64_t *) buf = *(uint32_t *) buf;
|
||||
+ }
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
static void
|
||||
x86_fill_gregset (struct regcache *regcache, void *buf)
|
||||
{
|
||||
@@ -411,32 +440,14 @@ x86_fill_gregset (struct regcache *regcache, void *buf)
|
||||
|
||||
return;
|
||||
}
|
||||
-
|
||||
- /* 32-bit inferior registers need to be zero-extended.
|
||||
- Callers would read uninitialized memory otherwise. */
|
||||
- memset (buf, 0x00, X86_64_USER_REGS * 8);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < I386_NUM_REGS; i++)
|
||||
- collect_register (regcache, i, ((char *) buf) + i386_regmap[i]);
|
||||
-
|
||||
- collect_register_by_name (regcache, "orig_eax",
|
||||
- ((char *) buf) + ORIG_EAX * REGSIZE);
|
||||
+ collect_register_i386 (regcache, i, ((char *) buf) + i386_regmap[i]);
|
||||
|
||||
-#ifdef __x86_64__
|
||||
- /* Sign extend EAX value to avoid potential syscall restart
|
||||
- problems.
|
||||
-
|
||||
- See amd64_linux_collect_native_gregset() in gdb/amd64-linux-nat.c
|
||||
- for a detailed explanation. */
|
||||
- if (register_size (regcache->tdesc, 0) == 4)
|
||||
- {
|
||||
- void *ptr = ((gdb_byte *) buf
|
||||
- + i386_regmap[find_regno (regcache->tdesc, "eax")]);
|
||||
-
|
||||
- *(int64_t *) ptr = *(int32_t *) ptr;
|
||||
- }
|
||||
-#endif
|
||||
+ /* Handle ORIG_EAX, which is not in i386_regmap. */
|
||||
+ collect_register_i386 (regcache, find_regno (regcache->tdesc, "orig_eax"),
|
||||
+ ((char *) buf) + ORIG_EAX * REGSIZE);
|
||||
}
|
||||
|
||||
static void
|
@ -0,0 +1,315 @@
|
||||
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-dts-rhel6-python-compat.patch
|
||||
|
||||
;; [rhel6] DTS backward Python compatibility API (BZ 1020004, Phil Muldoon).
|
||||
;;=fedora
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1020004
|
||||
|
||||
diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
|
||||
--- a/gdb/data-directory/Makefile.in
|
||||
+++ b/gdb/data-directory/Makefile.in
|
||||
@@ -71,6 +71,8 @@ PYTHON_FILE_LIST = \
|
||||
gdb/__init__.py \
|
||||
gdb/FrameDecorator.py \
|
||||
gdb/FrameIterator.py \
|
||||
+ gdb/FrameWrapper.py \
|
||||
+ gdb/backtrace.py \
|
||||
gdb/frames.py \
|
||||
gdb/printing.py \
|
||||
gdb/prompt.py \
|
||||
@@ -79,6 +81,7 @@ PYTHON_FILE_LIST = \
|
||||
gdb/xmethod.py \
|
||||
gdb/command/__init__.py \
|
||||
gdb/command/explore.py \
|
||||
+ gdb/command/backtrace.py \
|
||||
gdb/command/frame_filters.py \
|
||||
gdb/command/pretty_printers.py \
|
||||
gdb/command/prompt.py \
|
||||
diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/python/lib/gdb/FrameWrapper.py
|
||||
@@ -0,0 +1,122 @@
|
||||
+# Wrapper API for frames.
|
||||
+
|
||||
+# Copyright (C) 2008, 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/>.
|
||||
+
|
||||
+import gdb
|
||||
+
|
||||
+# FIXME: arguably all this should be on Frame somehow.
|
||||
+class FrameWrapper:
|
||||
+ def __init__ (self, frame):
|
||||
+ self.frame = frame;
|
||||
+
|
||||
+ def write_symbol (self, stream, sym, block):
|
||||
+ if len (sym.linkage_name):
|
||||
+ nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block)
|
||||
+ if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER:
|
||||
+ sym = nsym
|
||||
+
|
||||
+ stream.write (sym.print_name + "=")
|
||||
+ try:
|
||||
+ val = self.read_var (sym)
|
||||
+ if val != None:
|
||||
+ val = str (val)
|
||||
+ # FIXME: would be nice to have a more precise exception here.
|
||||
+ except RuntimeError as text:
|
||||
+ val = text
|
||||
+ if val == None:
|
||||
+ stream.write ("???")
|
||||
+ else:
|
||||
+ stream.write (str (val))
|
||||
+
|
||||
+ def print_frame_locals (self, stream, func):
|
||||
+
|
||||
+ try:
|
||||
+ block = self.frame.block()
|
||||
+ except RuntimeError:
|
||||
+ block = None
|
||||
+
|
||||
+ while block != None:
|
||||
+ if block.is_global or block.is_static:
|
||||
+ break
|
||||
+
|
||||
+ for sym in block:
|
||||
+ if sym.is_argument:
|
||||
+ continue;
|
||||
+
|
||||
+ self.write_symbol (stream, sym, block)
|
||||
+ stream.write ('\n')
|
||||
+
|
||||
+ def print_frame_args (self, stream, func):
|
||||
+
|
||||
+ try:
|
||||
+ block = self.frame.block()
|
||||
+ except RuntimeError:
|
||||
+ block = None
|
||||
+
|
||||
+ while block != None:
|
||||
+ if block.function != None:
|
||||
+ break
|
||||
+ block = block.superblock
|
||||
+
|
||||
+ first = True
|
||||
+ for sym in block:
|
||||
+ if not sym.is_argument:
|
||||
+ continue;
|
||||
+
|
||||
+ if not first:
|
||||
+ stream.write (", ")
|
||||
+
|
||||
+ self.write_symbol (stream, sym, block)
|
||||
+ first = False
|
||||
+
|
||||
+ # FIXME: this should probably just be a method on gdb.Frame.
|
||||
+ # But then we need stream wrappers.
|
||||
+ def describe (self, stream, full):
|
||||
+ if self.type () == gdb.DUMMY_FRAME:
|
||||
+ stream.write (" <function called from gdb>\n")
|
||||
+ elif self.type () == gdb.SIGTRAMP_FRAME:
|
||||
+ stream.write (" <signal handler called>\n")
|
||||
+ else:
|
||||
+ sal = self.find_sal ()
|
||||
+ pc = self.pc ()
|
||||
+ name = self.name ()
|
||||
+ if not name:
|
||||
+ name = "??"
|
||||
+ if pc != sal.pc or not sal.symtab:
|
||||
+ stream.write (" 0x%08x in" % pc)
|
||||
+ stream.write (" " + name + " (")
|
||||
+
|
||||
+ func = self.function ()
|
||||
+ self.print_frame_args (stream, func)
|
||||
+
|
||||
+ stream.write (")")
|
||||
+
|
||||
+ if sal.symtab and sal.symtab.filename:
|
||||
+ stream.write (" at " + sal.symtab.filename)
|
||||
+ stream.write (":" + str (sal.line))
|
||||
+
|
||||
+ if not self.name () or (not sal.symtab or not sal.symtab.filename):
|
||||
+ lib = gdb.solib_name (pc)
|
||||
+ if lib:
|
||||
+ stream.write (" from " + lib)
|
||||
+
|
||||
+ stream.write ("\n")
|
||||
+
|
||||
+ if full:
|
||||
+ self.print_frame_locals (stream, func)
|
||||
+
|
||||
+ def __getattr__ (self, name):
|
||||
+ return getattr (self.frame, name)
|
||||
diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/python/lib/gdb/backtrace.py
|
||||
@@ -0,0 +1,42 @@
|
||||
+# Filtering backtrace.
|
||||
+
|
||||
+# Copyright (C) 2008, 2011 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/>.
|
||||
+
|
||||
+import gdb
|
||||
+import itertools
|
||||
+
|
||||
+# Our only exports.
|
||||
+__all__ = ['push_frame_filter', 'create_frame_filter']
|
||||
+
|
||||
+old_frame_filter = None
|
||||
+
|
||||
+def push_frame_filter (constructor):
|
||||
+ """Register a new backtrace filter class with the 'backtrace' command.
|
||||
+The filter will be passed an iterator as an argument. The iterator
|
||||
+will return gdb.Frame-like objects. The filter should in turn act as
|
||||
+an iterator returning such objects."""
|
||||
+ global old_frame_filter
|
||||
+ if old_frame_filter == None:
|
||||
+ old_frame_filter = constructor
|
||||
+ else:
|
||||
+ old_frame_filter = lambda iterator, filter = frame_filter: constructor (filter(iterator))
|
||||
+
|
||||
+def create_frame_filter (iter):
|
||||
+ global old_frame_filter
|
||||
+ if old_frame_filter is None:
|
||||
+ return iter
|
||||
+ return old_frame_filter (iter)
|
||||
+
|
||||
diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/python/lib/gdb/command/backtrace.py
|
||||
@@ -0,0 +1,106 @@
|
||||
+# New backtrace command.
|
||||
+
|
||||
+# Copyright (C) 2008, 2009, 2011 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/>.
|
||||
+
|
||||
+import gdb
|
||||
+import gdb.backtrace
|
||||
+import itertools
|
||||
+from gdb.FrameIterator import FrameIterator
|
||||
+from gdb.FrameWrapper import FrameWrapper
|
||||
+import sys
|
||||
+
|
||||
+class ReverseBacktraceParameter (gdb.Parameter):
|
||||
+ """The new-backtrace command can show backtraces in 'reverse' order.
|
||||
+This means that the innermost frame will be printed last.
|
||||
+Note that reverse backtraces are more expensive to compute."""
|
||||
+
|
||||
+ set_doc = "Enable or disable reverse backtraces."
|
||||
+ show_doc = "Show whether backtraces will be printed in reverse order."
|
||||
+
|
||||
+ def __init__(self):
|
||||
+ gdb.Parameter.__init__ (self, "reverse-backtrace",
|
||||
+ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN)
|
||||
+ # Default to compatibility with gdb.
|
||||
+ self.value = False
|
||||
+
|
||||
+class FilteringBacktrace (gdb.Command):
|
||||
+ """Print backtrace of all stack frames, or innermost COUNT frames.
|
||||
+With a negative argument, print outermost -COUNT frames.
|
||||
+Use of the 'full' qualifier also prints the values of the local variables.
|
||||
+Use of the 'raw' qualifier avoids any filtering by loadable modules.
|
||||
+"""
|
||||
+
|
||||
+ def __init__ (self):
|
||||
+ # FIXME: this is not working quite well enough to replace
|
||||
+ # "backtrace" yet.
|
||||
+ gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK)
|
||||
+ self.reverse = ReverseBacktraceParameter()
|
||||
+
|
||||
+ def reverse_iter (self, iter):
|
||||
+ result = []
|
||||
+ for item in iter:
|
||||
+ result.append (item)
|
||||
+ result.reverse()
|
||||
+ return result
|
||||
+
|
||||
+ def final_n (self, iter, x):
|
||||
+ result = []
|
||||
+ for item in iter:
|
||||
+ result.append (item)
|
||||
+ return result[x:]
|
||||
+
|
||||
+ def invoke (self, arg, from_tty):
|
||||
+ i = 0
|
||||
+ count = 0
|
||||
+ filter = True
|
||||
+ full = False
|
||||
+
|
||||
+ for word in arg.split (" "):
|
||||
+ if word == '':
|
||||
+ continue
|
||||
+ elif word == 'raw':
|
||||
+ filter = False
|
||||
+ elif word == 'full':
|
||||
+ full = True
|
||||
+ else:
|
||||
+ count = int (word)
|
||||
+
|
||||
+ # FIXME: provide option to start at selected frame
|
||||
+ # However, should still number as if starting from newest
|
||||
+ newest_frame = gdb.newest_frame()
|
||||
+ iter = itertools.imap (FrameWrapper,
|
||||
+ FrameIterator (newest_frame))
|
||||
+ if filter:
|
||||
+ iter = gdb.backtrace.create_frame_filter (iter)
|
||||
+
|
||||
+ # Now wrap in an iterator that numbers the frames.
|
||||
+ iter = itertools.izip (itertools.count (0), iter)
|
||||
+
|
||||
+ # Reverse if the user wanted that.
|
||||
+ if self.reverse.value:
|
||||
+ iter = self.reverse_iter (iter)
|
||||
+
|
||||
+ # Extract sub-range user wants.
|
||||
+ if count < 0:
|
||||
+ iter = self.final_n (iter, count)
|
||||
+ elif count > 0:
|
||||
+ iter = itertools.islice (iter, 0, count)
|
||||
+
|
||||
+ for pair in iter:
|
||||
+ sys.stdout.write ("#%-2d" % pair[0])
|
||||
+ pair[1].describe (sys.stdout, full)
|
||||
+
|
||||
+FilteringBacktrace()
|
@ -1,327 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Keith Seitz <keiths@redhat.com>
|
||||
Date: Mon, 4 Dec 2023 11:04:22 -0800
|
||||
Subject: gdb-find_and_open_source-empty-string-ub-1of4.patch
|
||||
|
||||
;; Backport "gdbsupport: make gdb_abspath return an std::string"
|
||||
;; (Simon Marchi)
|
||||
|
||||
I'm trying to switch these functions to use std::string instead of char
|
||||
arrays, as much as possible. Some callers benefit from it (can avoid
|
||||
doing a copy of the result), while others suffer (have to make one more
|
||||
copy).
|
||||
|
||||
Change-Id: Iced49b8ee2f189744c5072a3b217aab5af17a993
|
||||
|
||||
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
|
||||
--- a/gdb/compile/compile.c
|
||||
+++ b/gdb/compile/compile.c
|
||||
@@ -295,8 +295,8 @@ compile_file_command (const char *args, int from_tty)
|
||||
error (_("You must provide a filename for this command."));
|
||||
|
||||
args = skip_spaces (args);
|
||||
- gdb::unique_xmalloc_ptr<char> abspath = gdb_abspath (args);
|
||||
- std::string buffer = string_printf ("#include \"%s\"\n", abspath.get ());
|
||||
+ std::string abspath = gdb_abspath (args);
|
||||
+ std::string buffer = string_printf ("#include \"%s\"\n", abspath.c_str ());
|
||||
eval_compile_command (NULL, buffer.c_str (), scope, NULL);
|
||||
}
|
||||
|
||||
diff --git a/gdb/completer.c b/gdb/completer.c
|
||||
--- a/gdb/completer.c
|
||||
+++ b/gdb/completer.c
|
||||
@@ -2036,7 +2036,7 @@ gdb_completion_word_break_characters_throw ()
|
||||
rl_basic_quote_characters = NULL;
|
||||
}
|
||||
|
||||
- return rl_completer_word_break_characters;
|
||||
+ return (char *) rl_completer_word_break_characters;
|
||||
}
|
||||
|
||||
char *
|
||||
diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
--- a/gdb/corelow.c
|
||||
+++ b/gdb/corelow.c
|
||||
@@ -447,7 +447,7 @@ core_target_open (const char *arg, int from_tty)
|
||||
|
||||
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
|
||||
if (!IS_ABSOLUTE_PATH (filename.get ()))
|
||||
- filename = gdb_abspath (filename.get ());
|
||||
+ filename = make_unique_xstrdup (gdb_abspath (filename.get ()).c_str ());
|
||||
|
||||
flags = O_BINARY | O_LARGEFILE;
|
||||
if (write_files)
|
||||
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
|
||||
@@ -291,7 +291,8 @@ set_index_cache_directory_command (const char *arg, int from_tty,
|
||||
cmd_list_element *element)
|
||||
{
|
||||
/* Make sure the index cache directory is absolute and tilde-expanded. */
|
||||
- gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (index_cache_directory));
|
||||
+ gdb::unique_xmalloc_ptr<char> abs
|
||||
+ = make_unique_xstrdup (gdb_abspath (index_cache_directory).c_str ());
|
||||
xfree (index_cache_directory);
|
||||
index_cache_directory = abs.release ();
|
||||
global_index_cache.set_directory (index_cache_directory);
|
||||
diff --git a/gdb/main.c b/gdb/main.c
|
||||
--- a/gdb/main.c
|
||||
+++ b/gdb/main.c
|
||||
@@ -135,12 +135,7 @@ set_gdb_data_directory (const char *new_datadir)
|
||||
"../foo" and "../foo" doesn't exist then we'll record $(pwd)/../foo which
|
||||
isn't canonical, but that's ok. */
|
||||
if (!IS_ABSOLUTE_PATH (gdb_datadir.c_str ()))
|
||||
- {
|
||||
- gdb::unique_xmalloc_ptr<char> abs_datadir
|
||||
- = gdb_abspath (gdb_datadir.c_str ());
|
||||
-
|
||||
- gdb_datadir = abs_datadir.get ();
|
||||
- }
|
||||
+ gdb_datadir = gdb_abspath (gdb_datadir.c_str ());
|
||||
}
|
||||
|
||||
/* Relocate a file or directory. PROGNAME is the name by which gdb
|
||||
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
|
||||
--- a/gdb/objfiles.c
|
||||
+++ b/gdb/objfiles.c
|
||||
@@ -341,7 +341,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
|
||||
|
||||
objfile_alloc_data (this);
|
||||
|
||||
- gdb::unique_xmalloc_ptr<char> name_holder;
|
||||
+ std::string name_holder;
|
||||
if (name == NULL)
|
||||
{
|
||||
gdb_assert (abfd == NULL);
|
||||
@@ -354,7 +354,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
|
||||
else
|
||||
{
|
||||
name_holder = gdb_abspath (name);
|
||||
- expanded_name = name_holder.get ();
|
||||
+ expanded_name = name_holder.c_str ();
|
||||
}
|
||||
original_name = obstack_strdup (&objfile_obstack, expanded_name);
|
||||
|
||||
diff --git a/gdb/source.c b/gdb/source.c
|
||||
--- a/gdb/source.c
|
||||
+++ b/gdb/source.c
|
||||
@@ -512,15 +512,15 @@ add_path (const char *dirname, char **which_path, int parse_separators)
|
||||
|
||||
for (const gdb::unique_xmalloc_ptr<char> &name_up : dir_vec)
|
||||
{
|
||||
- char *name = name_up.get ();
|
||||
+ const char *name = name_up.get ();
|
||||
char *p;
|
||||
struct stat st;
|
||||
- gdb::unique_xmalloc_ptr<char> new_name_holder;
|
||||
+ std::string new_name_holder;
|
||||
|
||||
/* Spaces and tabs will have been removed by buildargv().
|
||||
NAME is the start of the directory.
|
||||
P is the '\0' following the end. */
|
||||
- p = name + strlen (name);
|
||||
+ p = name_up.get () + strlen (name);
|
||||
|
||||
while (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
|
||||
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
||||
@@ -561,16 +561,18 @@ add_path (const char *dirname, char **which_path, int parse_separators)
|
||||
}
|
||||
|
||||
if (name[0] == '~')
|
||||
- new_name_holder.reset (tilde_expand (name));
|
||||
+ new_name_holder
|
||||
+ = gdb::unique_xmalloc_ptr<char[]> (tilde_expand (name)).get ();
|
||||
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
||||
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
|
||||
- new_name_holder.reset (concat (name, ".", (char *) NULL));
|
||||
+ new_name_holder = std::string (name) + ".";
|
||||
#endif
|
||||
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
|
||||
new_name_holder = gdb_abspath (name);
|
||||
else
|
||||
- new_name_holder.reset (savestring (name, p - name));
|
||||
- name = new_name_holder.get ();
|
||||
+ new_name_holder = std::string (name, p - name);
|
||||
+
|
||||
+ name = new_name_holder.c_str ();
|
||||
|
||||
/* Unless it's a variable, check existence. */
|
||||
if (name[0] != '$')
|
||||
@@ -915,7 +917,8 @@ openp (const char *path, openp_flags opts, const char *string,
|
||||
else if ((opts & OPF_RETURN_REALPATH) != 0)
|
||||
*filename_opened = gdb_realpath (filename);
|
||||
else
|
||||
- *filename_opened = gdb_abspath (filename);
|
||||
+ *filename_opened
|
||||
+ = make_unique_xstrdup (gdb_abspath (filename).c_str ());
|
||||
}
|
||||
|
||||
errno = last_errno;
|
||||
diff --git a/gdb/top.c b/gdb/top.c
|
||||
--- a/gdb/top.c
|
||||
+++ b/gdb/top.c
|
||||
@@ -2065,8 +2065,7 @@ init_history (void)
|
||||
const char *fname = ".gdb_history";
|
||||
#endif
|
||||
|
||||
- gdb::unique_xmalloc_ptr<char> temp (gdb_abspath (fname));
|
||||
- history_filename = temp.release ();
|
||||
+ history_filename = xstrdup (gdb_abspath (fname).c_str ());
|
||||
}
|
||||
|
||||
if (!history_filename_empty ())
|
||||
@@ -2150,10 +2149,10 @@ set_history_filename (const char *args,
|
||||
that was read. */
|
||||
if (!history_filename_empty () && !IS_ABSOLUTE_PATH (history_filename))
|
||||
{
|
||||
- gdb::unique_xmalloc_ptr<char> temp (gdb_abspath (history_filename));
|
||||
+ std::string temp = gdb_abspath (history_filename);
|
||||
|
||||
xfree (history_filename);
|
||||
- history_filename = temp.release ();
|
||||
+ history_filename = xstrdup (temp.c_str ());
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
|
||||
--- a/gdb/tracefile-tfile.c
|
||||
+++ b/gdb/tracefile-tfile.c
|
||||
@@ -471,7 +471,7 @@ tfile_target_open (const char *arg, int from_tty)
|
||||
|
||||
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
|
||||
if (!IS_ABSOLUTE_PATH (filename.get ()))
|
||||
- filename = gdb_abspath (filename.get ());
|
||||
+ filename = make_unique_xstrdup (gdb_abspath (filename.get ()).c_str ());
|
||||
|
||||
flags = O_BINARY | O_LARGEFILE;
|
||||
flags |= O_RDONLY;
|
||||
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
|
||||
--- a/gdbserver/server.cc
|
||||
+++ b/gdbserver/server.cc
|
||||
@@ -93,31 +93,31 @@ bool non_stop;
|
||||
static struct {
|
||||
/* Set the PROGRAM_PATH. Here we adjust the path of the provided
|
||||
binary if needed. */
|
||||
- void set (gdb::unique_xmalloc_ptr<char> &&path)
|
||||
+ void set (const char *path)
|
||||
{
|
||||
- m_path = std::move (path);
|
||||
+ m_path = path;
|
||||
|
||||
/* Make sure we're using the absolute path of the inferior when
|
||||
creating it. */
|
||||
- if (!contains_dir_separator (m_path.get ()))
|
||||
+ if (!contains_dir_separator (m_path.c_str ()))
|
||||
{
|
||||
int reg_file_errno;
|
||||
|
||||
/* Check if the file is in our CWD. If it is, then we prefix
|
||||
its name with CURRENT_DIRECTORY. Otherwise, we leave the
|
||||
name as-is because we'll try searching for it in $PATH. */
|
||||
- if (is_regular_file (m_path.get (), ®_file_errno))
|
||||
- m_path = gdb_abspath (m_path.get ());
|
||||
+ if (is_regular_file (m_path.c_str (), ®_file_errno))
|
||||
+ m_path = gdb_abspath (m_path.c_str ());
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the PROGRAM_PATH. */
|
||||
- char *get ()
|
||||
- { return m_path.get (); }
|
||||
+ const char *get ()
|
||||
+ { return m_path.empty () ? nullptr : m_path.c_str (); }
|
||||
|
||||
private:
|
||||
/* The program name, adjusted if needed. */
|
||||
- gdb::unique_xmalloc_ptr<char> m_path;
|
||||
+ std::string m_path;
|
||||
} program_path;
|
||||
static std::vector<char *> program_args;
|
||||
static std::string wrapper_argv;
|
||||
@@ -3054,7 +3054,7 @@ handle_v_run (char *own_buf)
|
||||
}
|
||||
}
|
||||
else
|
||||
- program_path.set (gdb::unique_xmalloc_ptr<char> (new_program_name));
|
||||
+ program_path.set (new_program_name);
|
||||
|
||||
/* Free the old argv and install the new one. */
|
||||
free_vector_argv (program_args);
|
||||
@@ -3845,7 +3845,7 @@ captured_main (int argc, char *argv[])
|
||||
int i, n;
|
||||
|
||||
n = argc - (next_arg - argv);
|
||||
- program_path.set (make_unique_xstrdup (next_arg[0]));
|
||||
+ program_path.set (next_arg[0]);
|
||||
for (i = 1; i < n; i++)
|
||||
program_args.push_back (xstrdup (next_arg[i]));
|
||||
|
||||
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
|
||||
--- a/gdbsupport/pathstuff.cc
|
||||
+++ b/gdbsupport/pathstuff.cc
|
||||
@@ -126,23 +126,23 @@ gdb_realpath_keepfile (const char *filename)
|
||||
|
||||
/* See gdbsupport/pathstuff.h. */
|
||||
|
||||
-gdb::unique_xmalloc_ptr<char>
|
||||
+std::string
|
||||
gdb_abspath (const char *path)
|
||||
{
|
||||
gdb_assert (path != NULL && path[0] != '\0');
|
||||
|
||||
if (path[0] == '~')
|
||||
- return gdb_tilde_expand_up (path);
|
||||
+ return gdb_tilde_expand (path);
|
||||
|
||||
if (IS_ABSOLUTE_PATH (path) || current_directory == NULL)
|
||||
- return make_unique_xstrdup (path);
|
||||
+ return path;
|
||||
|
||||
/* Beware the // my son, the Emacs barfs, the botch that catch... */
|
||||
- return gdb::unique_xmalloc_ptr<char>
|
||||
- (concat (current_directory,
|
||||
- IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
|
||||
- ? "" : SLASH_STRING,
|
||||
- path, (char *) NULL));
|
||||
+ return string_printf
|
||||
+ ("%s%s%s", current_directory,
|
||||
+ (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
|
||||
+ ? "" : SLASH_STRING),
|
||||
+ path);
|
||||
}
|
||||
|
||||
/* See gdbsupport/pathstuff.h. */
|
||||
@@ -225,8 +225,8 @@ get_standard_cache_dir ()
|
||||
if (xdg_cache_home != NULL)
|
||||
{
|
||||
/* Make sure the path is absolute and tilde-expanded. */
|
||||
- gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_cache_home));
|
||||
- return string_printf ("%s/gdb", abs.get ());
|
||||
+ std::string abs = gdb_abspath (xdg_cache_home);
|
||||
+ return string_printf ("%s/gdb", abs.c_str ());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -234,8 +234,8 @@ get_standard_cache_dir ()
|
||||
if (home != NULL)
|
||||
{
|
||||
/* Make sure the path is absolute and tilde-expanded. */
|
||||
- gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home));
|
||||
- return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ());
|
||||
+ std::string abs = gdb_abspath (home);
|
||||
+ return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.c_str ());
|
||||
}
|
||||
|
||||
return {};
|
||||
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
|
||||
--- a/gdbsupport/pathstuff.h
|
||||
+++ b/gdbsupport/pathstuff.h
|
||||
@@ -49,7 +49,7 @@ extern gdb::unique_xmalloc_ptr<char>
|
||||
If CURRENT_DIRECTORY is NULL, this function returns a copy of
|
||||
PATH. */
|
||||
|
||||
-extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *path);
|
||||
+extern std::string gdb_abspath (const char *path);
|
||||
|
||||
/* If the path in CHILD is a child of the path in PARENT, return a
|
||||
pointer to the first component in the CHILD's pathname below the
|
@ -1,475 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Keith Seitz <keiths@redhat.com>
|
||||
Date: Mon, 4 Dec 2023 11:02:16 -0800
|
||||
Subject: gdb-find_and_open_source-empty-string-ub-2of4.patch
|
||||
|
||||
;; Backport "gdbsupport: add path_join function"
|
||||
;; (Simon Marchi)
|
||||
|
||||
In this review [1], Eli pointed out that we should be careful when
|
||||
concatenating file names to avoid duplicated slashes. On Windows, a
|
||||
double slash at the beginning of a file path has a special meaning. So
|
||||
naively concatenating "/" and "foo/bar" would give "//foo/bar", which
|
||||
would not give the desired results. We already have a few spots doing:
|
||||
|
||||
if (first_path ends with a slash)
|
||||
path = first_path + second_path
|
||||
else
|
||||
path = first_path + slash + second_path
|
||||
|
||||
In general, I think it's nice to avoid superfluous slashes in file
|
||||
paths, since they might end up visible to the user and look a bit
|
||||
unprofessional.
|
||||
|
||||
Introduce the path_join function that can be used to join multiple path
|
||||
components together (along with unit tests).
|
||||
|
||||
I initially wanted to make it possible to join two absolute paths, to
|
||||
support the use case of prepending a sysroot path to a target file path,
|
||||
or the prepending the debug-file-directory to a target file path. But
|
||||
the code in solib_find_1 shows that it is more complex than this anyway
|
||||
(for example, when the right hand side is a Windows path with a drive
|
||||
letter). So I don't think we need to support that case in path_join.
|
||||
That also keeps the implementation simpler.
|
||||
|
||||
Change a few spots to use path_join to show how it can be used. I
|
||||
believe that all the spots I changed are guarded by some checks that
|
||||
ensure the right hand side operand is not an absolute path.
|
||||
|
||||
Regression-tested on Ubuntu 18.04. Built-tested on Windows, and I also
|
||||
ran the new unit-test there.
|
||||
|
||||
[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187559.html
|
||||
|
||||
Change-Id: I0df889f7e3f644e045f42ff429277b732eb6c752
|
||||
|
||||
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
|
||||
--- a/gdb/Makefile.in
|
||||
+++ b/gdb/Makefile.in
|
||||
@@ -446,6 +446,7 @@ SELFTESTS_SRCS = \
|
||||
unittests/observable-selftests.c \
|
||||
unittests/optional-selftests.c \
|
||||
unittests/parse-connection-spec-selftests.c \
|
||||
+ unittests/path-join-selftests.c \
|
||||
unittests/ptid-selftests.c \
|
||||
unittests/main-thread-selftests.c \
|
||||
unittests/mkdir-recursive-selftests.c \
|
||||
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
|
||||
--- a/gdb/buildsym.c
|
||||
+++ b/gdb/buildsym.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "defs.h"
|
||||
#include "buildsym-legacy.h"
|
||||
#include "bfd.h"
|
||||
+#include "gdbsupport/pathstuff.h"
|
||||
#include "gdb_obstack.h"
|
||||
#include "symtab.h"
|
||||
#include "symfile.h"
|
||||
@@ -512,27 +513,22 @@ buildsym_compunit::start_subfile (const char *name)
|
||||
|
||||
for (subfile = m_subfiles; subfile; subfile = subfile->next)
|
||||
{
|
||||
- char *subfile_name;
|
||||
+ std::string subfile_name;
|
||||
|
||||
/* If NAME is an absolute path, and this subfile is not, then
|
||||
attempt to create an absolute path to compare. */
|
||||
if (IS_ABSOLUTE_PATH (name)
|
||||
&& !IS_ABSOLUTE_PATH (subfile->name)
|
||||
&& subfile_dirname != NULL)
|
||||
- subfile_name = concat (subfile_dirname, SLASH_STRING,
|
||||
- subfile->name, (char *) NULL);
|
||||
+ subfile_name = path_join (subfile_dirname, subfile->name);
|
||||
else
|
||||
subfile_name = subfile->name;
|
||||
|
||||
- if (FILENAME_CMP (subfile_name, name) == 0)
|
||||
+ if (FILENAME_CMP (subfile_name.c_str (), name) == 0)
|
||||
{
|
||||
m_current_subfile = subfile;
|
||||
- if (subfile_name != subfile->name)
|
||||
- xfree (subfile_name);
|
||||
return;
|
||||
}
|
||||
- if (subfile_name != subfile->name)
|
||||
- xfree (subfile_name);
|
||||
}
|
||||
|
||||
/* This subfile is not known. Add an entry for it. */
|
||||
diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
|
||||
--- a/gdb/dwarf2/line-header.c
|
||||
+++ b/gdb/dwarf2/line-header.c
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "dwarf2/read.h"
|
||||
#include "complaints.h"
|
||||
#include "filenames.h"
|
||||
+#include "gdbsupport/pathstuff.h"
|
||||
|
||||
void
|
||||
line_header::add_include_dir (const char *include_dir)
|
||||
@@ -73,9 +74,7 @@ line_header::file_file_name (int file) const
|
||||
{
|
||||
const char *dir = fe->include_dir (this);
|
||||
if (dir != NULL)
|
||||
- return gdb::unique_xmalloc_ptr<char> (concat (dir, SLASH_STRING,
|
||||
- fe->name,
|
||||
- (char *) NULL));
|
||||
+ return make_unique_xstrdup (path_join (dir, fe->name).c_str ());
|
||||
}
|
||||
return make_unique_xstrdup (fe->name);
|
||||
}
|
||||
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
||||
--- a/gdb/dwarf2/read.c
|
||||
+++ b/gdb/dwarf2/read.c
|
||||
@@ -12782,14 +12782,13 @@ open_dwo_file (dwarf2_per_objfile *per_objfile,
|
||||
|
||||
if (comp_dir != NULL)
|
||||
{
|
||||
- gdb::unique_xmalloc_ptr<char> path_to_try
|
||||
- (concat (comp_dir, SLASH_STRING, file_name, (char *) NULL));
|
||||
+ std::string path_to_try = path_join (comp_dir, file_name);
|
||||
|
||||
/* NOTE: If comp_dir is a relative path, this will also try the
|
||||
search path, which seems useful. */
|
||||
- gdb_bfd_ref_ptr abfd (try_open_dwop_file (per_objfile, path_to_try.get (),
|
||||
- 0 /*is_dwp*/,
|
||||
- 1 /*search_cwd*/));
|
||||
+ gdb_bfd_ref_ptr abfd (try_open_dwop_file
|
||||
+ (per_objfile, path_to_try.c_str (), 0 /*is_dwp*/, 1 /*search_cwd*/));
|
||||
+
|
||||
if (abfd != NULL)
|
||||
return abfd;
|
||||
}
|
||||
@@ -20537,7 +20536,7 @@ static const char *
|
||||
psymtab_include_file_name (const struct line_header *lh, const file_entry &fe,
|
||||
const dwarf2_psymtab *pst,
|
||||
const char *comp_dir,
|
||||
- gdb::unique_xmalloc_ptr<char> *name_holder)
|
||||
+ std::string &name_holder)
|
||||
{
|
||||
const char *include_name = fe.name;
|
||||
const char *include_name_to_compare = include_name;
|
||||
@@ -20546,7 +20545,7 @@ psymtab_include_file_name (const struct line_header *lh, const file_entry &fe,
|
||||
|
||||
const char *dir_name = fe.include_dir (lh);
|
||||
|
||||
- gdb::unique_xmalloc_ptr<char> hold_compare;
|
||||
+ std::string hold_compare;
|
||||
if (!IS_ABSOLUTE_PATH (include_name)
|
||||
&& (dir_name != NULL || comp_dir != NULL))
|
||||
{
|
||||
@@ -20573,26 +20572,23 @@ psymtab_include_file_name (const struct line_header *lh, const file_entry &fe,
|
||||
|
||||
if (dir_name != NULL)
|
||||
{
|
||||
- name_holder->reset (concat (dir_name, SLASH_STRING,
|
||||
- include_name, (char *) NULL));
|
||||
- include_name = name_holder->get ();
|
||||
+ name_holder = path_join (dir_name, include_name);
|
||||
+ include_name = name_holder.c_str ();
|
||||
include_name_to_compare = include_name;
|
||||
}
|
||||
if (!IS_ABSOLUTE_PATH (include_name) && comp_dir != NULL)
|
||||
{
|
||||
- hold_compare.reset (concat (comp_dir, SLASH_STRING,
|
||||
- include_name, (char *) NULL));
|
||||
- include_name_to_compare = hold_compare.get ();
|
||||
+ hold_compare = path_join (comp_dir, include_name);
|
||||
+ include_name_to_compare = hold_compare.c_str ();
|
||||
}
|
||||
}
|
||||
|
||||
pst_filename = pst->filename;
|
||||
- gdb::unique_xmalloc_ptr<char> copied_name;
|
||||
+ std::string copied_name;
|
||||
if (!IS_ABSOLUTE_PATH (pst_filename) && pst->dirname != NULL)
|
||||
{
|
||||
- copied_name.reset (concat (pst->dirname, SLASH_STRING,
|
||||
- pst_filename, (char *) NULL));
|
||||
- pst_filename = copied_name.get ();
|
||||
+ copied_name = path_join (pst->dirname, pst_filename);
|
||||
+ pst_filename = copied_name.c_str ();
|
||||
}
|
||||
|
||||
file_is_pst = FILENAME_CMP (include_name_to_compare, pst_filename) == 0;
|
||||
@@ -21303,10 +21299,10 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
|
||||
for (auto &file_entry : lh->file_names ())
|
||||
if (file_entry.included_p == 1)
|
||||
{
|
||||
- gdb::unique_xmalloc_ptr<char> name_holder;
|
||||
+ std::string name_holder;
|
||||
const char *include_name =
|
||||
psymtab_include_file_name (lh, file_entry, pst,
|
||||
- comp_dir, &name_holder);
|
||||
+ comp_dir, name_holder);
|
||||
if (include_name != NULL)
|
||||
dwarf2_create_include_psymtab (include_name, pst, objfile);
|
||||
}
|
||||
@@ -21360,7 +21356,7 @@ static void
|
||||
dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
|
||||
const char *dirname)
|
||||
{
|
||||
- gdb::unique_xmalloc_ptr<char> copy;
|
||||
+ std::string copy;
|
||||
|
||||
/* In order not to lose the line information directory,
|
||||
we concatenate it to the filename when it makes sense.
|
||||
@@ -21371,8 +21367,8 @@ dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
|
||||
|
||||
if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
|
||||
{
|
||||
- copy.reset (concat (dirname, SLASH_STRING, filename, (char *) NULL));
|
||||
- filename = copy.get ();
|
||||
+ copy = path_join (dirname, filename);
|
||||
+ filename = copy.c_str ();
|
||||
}
|
||||
|
||||
cu->get_builder ()->start_subfile (filename);
|
||||
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
|
||||
--- a/gdb/macrotab.c
|
||||
+++ b/gdb/macrotab.c
|
||||
@@ -18,6 +18,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "defs.h"
|
||||
+#include "gdbsupport/pathstuff.h"
|
||||
#include "gdb_obstack.h"
|
||||
#include "splay-tree.h"
|
||||
#include "filenames.h"
|
||||
@@ -1071,5 +1072,5 @@ macro_source_fullname (struct macro_source_file *file)
|
||||
if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
|
||||
return file->filename;
|
||||
|
||||
- return std::string (comp_dir) + SLASH_STRING + file->filename;
|
||||
+ return path_join (comp_dir, file->filename);
|
||||
}
|
||||
diff --git a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
|
||||
--- a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
|
||||
+++ b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
|
||||
@@ -36,6 +36,12 @@ if { [regsub {^(/[^/]+)/} $srcfileabs {\1subst/} srcfileabssubst] != 1
|
||||
return -1
|
||||
}
|
||||
|
||||
+# Generate a regular expression which to match $srcfileabs with
|
||||
+# or without the doubled slash. This is used by the substituted
|
||||
+# fullname test.
|
||||
+set srcfileabssubst_regexp [string_to_regexp $srcfileabssubst]
|
||||
+regsub {//} $srcfileabssubst_regexp {\0?} srcfileabssubst_regexp
|
||||
+
|
||||
set f [open $srcfileabs "w"]
|
||||
puts $f "int main (void) { return 0; }"
|
||||
close $f
|
||||
@@ -54,7 +60,7 @@ mi_gdb_test "-interpreter-exec console \"set substitute-path ${initdir} ${initdi
|
||||
|
||||
mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\".*\".*" "fullname present"
|
||||
|
||||
-mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"[string_to_regexp $srcfileabssubst]\".*" "substituted fullname"
|
||||
+mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"$srcfileabssubst_regexp\".*" "substituted fullname"
|
||||
|
||||
# Test compare_filenames_for_search does not falsely use absolute filename as
|
||||
# a relative one.
|
||||
diff --git a/gdb/unittests/path-join-selftests.c b/gdb/unittests/path-join-selftests.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/unittests/path-join-selftests.c
|
||||
@@ -0,0 +1,73 @@
|
||||
+/* Self tests for path_join for GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright (C) 2022 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/>. */
|
||||
+
|
||||
+#include "defs.h"
|
||||
+#include "gdbsupport/pathstuff.h"
|
||||
+#include "gdbsupport/selftest.h"
|
||||
+
|
||||
+namespace selftests {
|
||||
+namespace path_join {
|
||||
+
|
||||
+template <typename ...Args>
|
||||
+static void
|
||||
+test_one (const char *expected, Args... paths)
|
||||
+{
|
||||
+ std::string actual = ::path_join (paths...);
|
||||
+
|
||||
+ SELF_CHECK (actual == expected);
|
||||
+}
|
||||
+
|
||||
+/* Test path_join. */
|
||||
+
|
||||
+static void
|
||||
+test ()
|
||||
+{
|
||||
+ test_one ("/foo/bar", "/foo", "bar");
|
||||
+ test_one ("/bar", "/", "bar");
|
||||
+ test_one ("foo/bar/", "foo", "bar", "");
|
||||
+ test_one ("foo", "", "foo");
|
||||
+ test_one ("foo/bar", "foo", "", "bar");
|
||||
+ test_one ("foo/", "foo", "");
|
||||
+ test_one ("foo/", "foo/", "");
|
||||
+
|
||||
+ test_one ("D:/foo/bar", "D:/foo", "bar");
|
||||
+ test_one ("D:/foo/bar", "D:/foo/", "bar");
|
||||
+
|
||||
+#if defined(_WIN32)
|
||||
+ /* The current implementation doesn't recognize backslashes as directory
|
||||
+ separators on Unix-like systems, so only run these tests on Windows. If
|
||||
+ we ever switch our implementation to use std::filesystem::path, they
|
||||
+ should work anywhere, in theory. */
|
||||
+ test_one ("D:\\foo/bar", "D:\\foo", "bar");
|
||||
+ test_one ("D:\\foo\\bar", "D:\\foo\\", "bar");
|
||||
+ test_one ("\\\\server\\dir\\file", "\\\\server\\dir\\", "file");
|
||||
+ test_one ("\\\\server\\dir/file", "\\\\server\\dir", "file");
|
||||
+#endif /* _WIN32 */
|
||||
+}
|
||||
+
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+void _initialize_path_join_selftests ();
|
||||
+void
|
||||
+_initialize_path_join_selftests ()
|
||||
+{
|
||||
+ selftests::register_test ("path_join",
|
||||
+ selftests::path_join::test);
|
||||
+}
|
||||
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
|
||||
--- a/gdbsupport/pathstuff.cc
|
||||
+++ b/gdbsupport/pathstuff.cc
|
||||
@@ -87,7 +87,6 @@ gdb_realpath_keepfile (const char *filename)
|
||||
{
|
||||
const char *base_name = lbasename (filename);
|
||||
char *dir_name;
|
||||
- char *result;
|
||||
|
||||
/* Extract the basename of filename, and return immediately
|
||||
a copy of filename if it does not contain any directory prefix. */
|
||||
@@ -116,12 +115,7 @@ gdb_realpath_keepfile (const char *filename)
|
||||
directory separator, avoid doubling it. */
|
||||
gdb::unique_xmalloc_ptr<char> path_storage = gdb_realpath (dir_name);
|
||||
const char *real_path = path_storage.get ();
|
||||
- if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
|
||||
- result = concat (real_path, base_name, (char *) NULL);
|
||||
- else
|
||||
- result = concat (real_path, SLASH_STRING, base_name, (char *) NULL);
|
||||
-
|
||||
- return gdb::unique_xmalloc_ptr<char> (result);
|
||||
+ return make_unique_xstrdup (path_join (real_path, base_name).c_str ());
|
||||
}
|
||||
|
||||
/* See gdbsupport/pathstuff.h. */
|
||||
@@ -137,12 +131,7 @@ gdb_abspath (const char *path)
|
||||
if (IS_ABSOLUTE_PATH (path) || current_directory == NULL)
|
||||
return path;
|
||||
|
||||
- /* Beware the // my son, the Emacs barfs, the botch that catch... */
|
||||
- return string_printf
|
||||
- ("%s%s%s", current_directory,
|
||||
- (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
|
||||
- ? "" : SLASH_STRING),
|
||||
- path);
|
||||
+ return path_join (current_directory, path);
|
||||
}
|
||||
|
||||
/* See gdbsupport/pathstuff.h. */
|
||||
@@ -197,6 +186,29 @@ child_path (const char *parent, const char *child)
|
||||
|
||||
/* See gdbsupport/pathstuff.h. */
|
||||
|
||||
+std::string
|
||||
+path_join (gdb::array_view<const gdb::string_view> paths)
|
||||
+{
|
||||
+ std::string ret;
|
||||
+
|
||||
+ for (int i = 0; i < paths.size (); ++i)
|
||||
+ {
|
||||
+ const gdb::string_view path = paths[i];
|
||||
+
|
||||
+ if (i > 0)
|
||||
+ gdb_assert (!IS_ABSOLUTE_PATH (path));
|
||||
+
|
||||
+ if (!ret.empty () && !IS_DIR_SEPARATOR (ret.back ()))
|
||||
+ ret += '/';
|
||||
+
|
||||
+ ret.append (path.begin (), path.end ());
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+/* See gdbsupport/pathstuff.h. */
|
||||
+
|
||||
bool
|
||||
contains_dir_separator (const char *path)
|
||||
{
|
||||
@@ -226,7 +238,7 @@ get_standard_cache_dir ()
|
||||
{
|
||||
/* Make sure the path is absolute and tilde-expanded. */
|
||||
std::string abs = gdb_abspath (xdg_cache_home);
|
||||
- return string_printf ("%s/gdb", abs.c_str ());
|
||||
+ return path_join (abs.c_str (), "gdb");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -235,7 +247,7 @@ get_standard_cache_dir ()
|
||||
{
|
||||
/* Make sure the path is absolute and tilde-expanded. */
|
||||
std::string abs = gdb_abspath (home);
|
||||
- return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.c_str ());
|
||||
+ return path_join (abs.c_str (), HOME_CACHE_DIR, "gdb");
|
||||
}
|
||||
|
||||
return {};
|
||||
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
|
||||
--- a/gdbsupport/pathstuff.h
|
||||
+++ b/gdbsupport/pathstuff.h
|
||||
@@ -21,6 +21,7 @@
|
||||
#define COMMON_PATHSTUFF_H
|
||||
|
||||
#include "gdbsupport/byte-vector.h"
|
||||
+#include "gdbsupport/array-view.h"
|
||||
|
||||
/* Path utilities. */
|
||||
|
||||
@@ -57,6 +58,28 @@ extern std::string gdb_abspath (const char *path);
|
||||
|
||||
extern const char *child_path (const char *parent, const char *child);
|
||||
|
||||
+/* Join elements in PATHS into a single path.
|
||||
+
|
||||
+ The first element can be absolute or relative. All the others must be
|
||||
+ relative. */
|
||||
+
|
||||
+extern std::string path_join (gdb::array_view<const gdb::string_view> paths);
|
||||
+
|
||||
+/* Same as the above, but accept paths as distinct parameters. */
|
||||
+
|
||||
+template<typename ...Args>
|
||||
+std::string
|
||||
+path_join (Args... paths)
|
||||
+{
|
||||
+ /* It doesn't make sense to join less than two paths. */
|
||||
+ gdb_static_assert (sizeof... (Args) >= 2);
|
||||
+
|
||||
+ std::array<gdb::string_view, sizeof... (Args)> views
|
||||
+ { gdb::string_view (paths)... };
|
||||
+
|
||||
+ return path_join (gdb::array_view<const gdb::string_view> (views));
|
||||
+}
|
||||
+
|
||||
/* Return whether PATH contains a directory separator character. */
|
||||
|
||||
extern bool contains_dir_separator (const char *path);
|
@ -1,47 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Keith Seitz <keiths@redhat.com>
|
||||
Date: Tue, 5 Dec 2023 08:47:16 -0800
|
||||
Subject: gdb-find_and_open_source-empty-string-ub-3of4.patch
|
||||
|
||||
;; Backport "Fix undefined behaviour dereferencing empty string"
|
||||
;; (Magne Hov, RHEL-18940)
|
||||
|
||||
When a source file's dirname is solely made up of directory separators
|
||||
we end up trying to dereference the last character of an empty string
|
||||
with std::string::back, which results in undefined behaviour. A typical
|
||||
use case where this can happen is when the root directory "/" is used as
|
||||
a compilation directory.
|
||||
|
||||
With libstdc++.so.6.0.28 we get no out-of-bounds checks and the byte
|
||||
preceding the storage of the empty string is returned. The character
|
||||
value of this byte depends on heap implementation and usage, but when
|
||||
this byte happens to hold the value of the directory separator character
|
||||
we go on to call std::string::pop_back on the empty string which results
|
||||
in an out_of_range exception which terminates GDB.
|
||||
|
||||
Fix this by using path_join. prepare_path_for_appending ensures that the
|
||||
filename component is relative.
|
||||
|
||||
The testsuite has been run before and after the change and no
|
||||
regressions were found.
|
||||
|
||||
diff --git a/gdb/source.c b/gdb/source.c
|
||||
--- a/gdb/source.c
|
||||
+++ b/gdb/source.c
|
||||
@@ -1111,15 +1111,7 @@ find_and_open_source (const char *filename,
|
||||
helpful if part of the compilation directory was removed,
|
||||
e.g. using gcc's -fdebug-prefix-map, and we have added the missing
|
||||
prefix to source_path. */
|
||||
- std::string cdir_filename (dirname);
|
||||
-
|
||||
- /* Remove any trailing directory separators. */
|
||||
- while (IS_DIR_SEPARATOR (cdir_filename.back ()))
|
||||
- cdir_filename.pop_back ();
|
||||
-
|
||||
- /* Add our own directory separator. */
|
||||
- cdir_filename.append (SLASH_STRING);
|
||||
- cdir_filename.append (filename_start);
|
||||
+ std::string cdir_filename = path_join (dirname, filename_start);
|
||||
|
||||
result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,
|
||||
cdir_filename.c_str (), OPEN_MODE, fullname);
|
@ -1,113 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Keith Seitz <keiths@redhat.com>
|
||||
Date: Wed, 6 Dec 2023 07:19:49 -0800
|
||||
Subject: gdb-find_and_open_source-empty-string-ub-4of4.patch
|
||||
|
||||
;; Backport "gdbsupport: change path_join parameter to
|
||||
;; array_view<const char *>"
|
||||
;; (Simon Marchi)
|
||||
|
||||
When a GDB built with -D_GLIBCXX_DEBUG=1 reads a binary with a single
|
||||
character name, we hit this assertion failure:
|
||||
|
||||
$ ./gdb -q --data-directory=data-directory -nx ./x
|
||||
/usr/include/c++/12.1.0/string_view:239: constexpr const std::basic_string_view<_CharT, _Traits>::value_type& std::basic_string_view<_CharT, _Traits>::operator[](size_type) const [with _CharT = char; _Traits = std::char_traits<char>; const_reference = const char&; size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
|
||||
|
||||
The backtrace:
|
||||
|
||||
#3 0x00007ffff6c0f002 in std::__glibcxx_assert_fail (file=<optimized out>, line=<optimized out>, function=<optimized out>, condition=<optimized out>) at /usr/src/debug/gcc/libstdc++-v3/src/c++11/debug.cc:60
|
||||
#4 0x000055555da8a864 in std::basic_string_view<char, std::char_traits<char> >::operator[] (this=0x7fffffffcc30, __pos=1) at /usr/include/c++/12.1.0/string_view:239
|
||||
#5 0x00005555609dcb88 in path_join[abi:cxx11](gdb::array_view<std::basic_string_view<char, std::char_traits<char> > const>) (paths=...) at /home/simark/src/binutils-gdb/gdbsupport/pathstuff.cc:203
|
||||
#6 0x000055555e0443f4 in path_join<char const*, char const*> () at /home/simark/src/binutils-gdb/gdb/../gdbsupport/pathstuff.h:84
|
||||
#7 0x00005555609dc336 in gdb_realpath_keepfile[abi:cxx11](char const*) (filename=0x6060000a8d40 "/home/simark/build/binutils-gdb-one-target/gdb/./x") at /home/simark/src/binutils-gdb/gdbsupport/pathstuff.cc:122
|
||||
#8 0x000055555ebd2794 in exec_file_attach (filename=0x7fffffffe0f9 "./x", from_tty=1) at /home/simark/src/binutils-gdb/gdb/exec.c:471
|
||||
#9 0x000055555f2b3fb0 in catch_command_errors (command=0x55555ebd1ab6 <exec_file_attach(char const*, int)>, arg=0x7fffffffe0f9 "./x", from_tty=1, do_bp_actions=false) at /home/simark/src/binutils-gdb/gdb/main.c:513
|
||||
#10 0x000055555f2b7e11 in captured_main_1 (context=0x7fffffffdb60) at /home/simark/src/binutils-gdb/gdb/main.c:1209
|
||||
#11 0x000055555f2b9144 in captured_main (data=0x7fffffffdb60) at /home/simark/src/binutils-gdb/gdb/main.c:1319
|
||||
#12 0x000055555f2b9226 in gdb_main (args=0x7fffffffdb60) at /home/simark/src/binutils-gdb/gdb/main.c:1344
|
||||
#13 0x000055555d938c5e in main (argc=5, argv=0x7fffffffdcf8) at /home/simark/src/binutils-gdb/gdb/gdb.c:32
|
||||
|
||||
The problem is this line in path_join:
|
||||
|
||||
gdb_assert (strlen (path) == 0 || !IS_ABSOLUTE_PATH (path));
|
||||
|
||||
... where `path` is "x". IS_ABSOLUTE_PATH eventually calls
|
||||
HAS_DRIVE_SPEC_1:
|
||||
|
||||
#define HAS_DRIVE_SPEC_1(dos_based, f) \
|
||||
((f)[0] && ((f)[1] == ':') && (dos_based))
|
||||
|
||||
This macro accesses indices 0 and 1 of the input string. However, `f`
|
||||
is a string_view of length 1, so it's incorrect to try to access index
|
||||
1. We know that the string_view's underlying object is a null-terminated
|
||||
string, so in practice there's no harm. But as far as the string_view
|
||||
is concerned, index 1 is considered out of bounds.
|
||||
|
||||
This patch makes the easy fix, that is to change the path_join parameter
|
||||
from a vector of to a vector of `const char *`. Another solution would
|
||||
be to introduce a non-standard gdb::cstring_view class, which would be a
|
||||
view over a null-terminated string. With that class, it would be
|
||||
correct to access index 1, it would yield the NUL character. If there
|
||||
is interest in having this class (it has been mentioned a few times in
|
||||
the past) I can do it and use it here.
|
||||
|
||||
This was found by running tests such as gdb.ada/arrayidx.exp, which
|
||||
produce 1-char long filenames, so adding a new test is not necessary.
|
||||
|
||||
Change-Id: Ia41a16c7243614636b18754fd98a41860756f7af
|
||||
|
||||
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
|
||||
--- a/gdbsupport/pathstuff.cc
|
||||
+++ b/gdbsupport/pathstuff.cc
|
||||
@@ -187,21 +187,21 @@ child_path (const char *parent, const char *child)
|
||||
/* See gdbsupport/pathstuff.h. */
|
||||
|
||||
std::string
|
||||
-path_join (gdb::array_view<const gdb::string_view> paths)
|
||||
+path_join (gdb::array_view<const char *> paths)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
for (int i = 0; i < paths.size (); ++i)
|
||||
{
|
||||
- const gdb::string_view path = paths[i];
|
||||
+ const char *path = paths[i];
|
||||
|
||||
if (i > 0)
|
||||
- gdb_assert (!IS_ABSOLUTE_PATH (path));
|
||||
+ gdb_assert (strlen (path) == 0 || !IS_ABSOLUTE_PATH (path));
|
||||
|
||||
if (!ret.empty () && !IS_DIR_SEPARATOR (ret.back ()))
|
||||
ret += '/';
|
||||
|
||||
- ret.append (path.begin (), path.end ());
|
||||
+ ret.append (path);
|
||||
}
|
||||
|
||||
return ret;
|
||||
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
|
||||
--- a/gdbsupport/pathstuff.h
|
||||
+++ b/gdbsupport/pathstuff.h
|
||||
@@ -63,7 +63,7 @@ extern const char *child_path (const char *parent, const char *child);
|
||||
The first element can be absolute or relative. All the others must be
|
||||
relative. */
|
||||
|
||||
-extern std::string path_join (gdb::array_view<const gdb::string_view> paths);
|
||||
+extern std::string path_join (gdb::array_view<const char *> paths);
|
||||
|
||||
/* Same as the above, but accept paths as distinct parameters. */
|
||||
|
||||
@@ -74,10 +74,10 @@ path_join (Args... paths)
|
||||
/* It doesn't make sense to join less than two paths. */
|
||||
gdb_static_assert (sizeof... (Args) >= 2);
|
||||
|
||||
- std::array<gdb::string_view, sizeof... (Args)> views
|
||||
- { gdb::string_view (paths)... };
|
||||
+ std::array<const char *, sizeof... (Args)> path_array
|
||||
+ { paths... };
|
||||
|
||||
- return path_join (gdb::array_view<const gdb::string_view> (views));
|
||||
+ return path_join (gdb::array_view<const char *> (path_array));
|
||||
}
|
||||
|
||||
/* Return whether PATH contains a directory separator character. */
|
@ -1,88 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Simon Marchi <simon.marchi@efficios.com>
|
||||
Date: Tue, 4 May 2021 11:20:09 -0400
|
||||
Subject: gdb-flexible-array-member-expected-pattern.patch
|
||||
|
||||
;; Backport "adjust gdb.python/flexible-array-member.exp expected pattern"
|
||||
;; (Simon Marchi)
|
||||
|
||||
The `Type.range ()` tests in gdb.python/flexible-array-member.exp pass
|
||||
when the test is compiled with gcc 9 or later, but not with gcc 8 or
|
||||
earlier:
|
||||
|
||||
$ make check TESTS="gdb.python/flexible-array-member.exp" RUNTESTFLAGS="CC_FOR_TARGET='gcc-8'"
|
||||
|
||||
python print(zs['items'].type.range())^M
|
||||
(0, 0)^M
|
||||
(gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zs['items'].type.range())
|
||||
python print(zso['items'].type.range())^M
|
||||
(0, 0)^M
|
||||
(gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zso['items'].type.range())
|
||||
|
||||
The value that we get for the upper bound of a flexible array member
|
||||
declared with a "0" size is 0 with gcc <= 8 and is -1 for gcc >= 9.
|
||||
This is due to different debug info. For this member, gcc 8 does:
|
||||
|
||||
0x000000d5: DW_TAG_array_type
|
||||
DW_AT_type [DW_FORM_ref4] (0x00000034 "int")
|
||||
DW_AT_sibling [DW_FORM_ref4] (0x000000e4)
|
||||
|
||||
0x000000de: DW_TAG_subrange_type
|
||||
DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int")
|
||||
|
||||
For the same type, gcc 9 does:
|
||||
|
||||
0x000000d5: DW_TAG_array_type
|
||||
DW_AT_type [DW_FORM_ref4] (0x00000034 "int")
|
||||
DW_AT_sibling [DW_FORM_ref4] (0x000000e5)
|
||||
|
||||
0x000000de: DW_TAG_subrange_type
|
||||
DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int")
|
||||
DW_AT_count [DW_FORM_data1] (0x00)
|
||||
|
||||
Ideally, GDB would present a consistent and documented value for an
|
||||
array member declared with size 0, regardless of how the debug info
|
||||
looks like. But for now, just change the test to accept the two
|
||||
values, to get rid of the failure and make the test in sync
|
||||
|
||||
I also realized (by looking at the py-type.exp test) that calling the
|
||||
fields method on an array type yields one field representing the "index"
|
||||
of the array. The type of that field is of type range
|
||||
(gdb.TYPE_CODE_RANGE). When calling `.range()` on that range type, it
|
||||
yields the same range tuple as when calling `.range()` on the array type
|
||||
itself. For completeness, add some tests to access the range tuple
|
||||
through that range type as well.
|
||||
|
||||
gdb/testsuite/ChangeLog:
|
||||
|
||||
* gdb.python/flexible-array-member.exp: Adjust expected range
|
||||
value for member declared with 0 size. Test accessing range
|
||||
tuple through range type.
|
||||
|
||||
Change-Id: Ie4e06d99fe9315527f04577888f48284d649ca4c
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.python/flexible-array-member.exp b/gdb/testsuite/gdb.python/flexible-array-member.exp
|
||||
--- a/gdb/testsuite/gdb.python/flexible-array-member.exp
|
||||
+++ b/gdb/testsuite/gdb.python/flexible-array-member.exp
|
||||
@@ -76,9 +76,17 @@ gdb_test "python print(zso\['items'\] == zso\['items'\]\[0\].address)" "True"
|
||||
gdb_test "python print(zso\['items'\]\[0\].address + 1 == zso\['items'\]\[1\].address)" "True"
|
||||
|
||||
# Verify the range attribute. It looks a bit inconsistent that the high bound
|
||||
-# is sometimes 0, sometimes -1, but that's what GDB produces today, so that's
|
||||
-# what we test.
|
||||
+# is sometimes 0, sometimes -1. It depends on the way the flexible array
|
||||
+# member is specified and on the compiler version (the debug info is
|
||||
+# different). But that's what GDB produces today, so that's what we test.
|
||||
|
||||
gdb_test "python print(ns\['items'\].type.range())" "\\(0, 0\\)"
|
||||
-gdb_test "python print(zs\['items'\].type.range())" "\\(0, -1\\)"
|
||||
-gdb_test "python print(zso\['items'\].type.range())" "\\(0, -1\\)"
|
||||
+gdb_test "python print(zs\['items'\].type.range())" "\\(0, (0|-1)\\)"
|
||||
+gdb_test "python print(zso\['items'\].type.range())" "\\(0, (0|-1)\\)"
|
||||
+
|
||||
+# Test the same thing, but going explicitly through the array index's range
|
||||
+# type.
|
||||
+
|
||||
+gdb_test "python print(ns\['items'\].type.fields()\[0\].type.range())" "\\(0, 0\\)"
|
||||
+gdb_test "python print(zs\['items'\].type.fields()\[0\].type.range())" "\\(0, (0|-1)\\)"
|
||||
+gdb_test "python print(zso\['items'\].type.fields()\[0\].type.range())" "\\(0, (0|-1)\\)"
|
@ -0,0 +1,36 @@
|
||||
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-follow-child-stale-parent.patch
|
||||
|
||||
;; Fix regression by python on ia64 due to stale current frame.
|
||||
;;=push+jan
|
||||
|
||||
Problem occurs with python and its get_current_arch () as it selects
|
||||
selected_frame and current_frame while still inferior_ptid is valid for the
|
||||
original parent. But since this place it is already attached and later
|
||||
unwinders try to access it, breaking:
|
||||
-PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork
|
||||
-PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork
|
||||
-PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork
|
||||
-PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork
|
||||
-PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish
|
||||
+FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork
|
||||
+FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork
|
||||
+FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork
|
||||
+FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork
|
||||
+FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish
|
||||
|
||||
diff --git a/gdb/infrun.c b/gdb/infrun.c
|
||||
--- a/gdb/infrun.c
|
||||
+++ b/gdb/infrun.c
|
||||
@@ -752,6 +752,9 @@ follow_fork (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
+ /* Possibly referenced PARENT is no longer valid. */
|
||||
+ reinit_frame_cache ();
|
||||
+
|
||||
/* This pending follow fork event is now handled, one way
|
||||
or another. The previous selected thread may be gone
|
||||
from the lists by now, but if it is still around, need
|
@ -1,281 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Tom Tromey <tromey@adacore.com>
|
||||
Date: Fri, 23 Apr 2021 11:28:48 -0600
|
||||
Subject: gdb-gdb27743-psymtab-imported-unit.patch
|
||||
|
||||
;; Backport "Fix crash when expanding partial symtabs with DW_TAG_imported_unit"
|
||||
;; (Tom Tromey, gdb/27743)
|
||||
|
||||
From e7d77ce0c408e7019f9885b8be64c9cdb46dd312 Mon Sep 17 00:00:00 2001
|
||||
Subject: [PATCH] Fix crash when expanding partial symtabs with
|
||||
DW_TAG_imported_unit
|
||||
|
||||
PR gdb/27743 points out a gdb crash when expanding partial symtabs,
|
||||
where one of the compilation units uses DW_TAG_imported_unit.
|
||||
|
||||
The bug is that partial_map_expand_apply expects only to be called for
|
||||
the outermost psymtab. However, filename searching doesn't (and
|
||||
probably shouldn't) guarantee this. The fix is to walk upward to find
|
||||
the outermost CU.
|
||||
|
||||
A new test case is included. It is mostly copied from other test
|
||||
cases, which really sped up the effort.
|
||||
|
||||
This bug does not occur on trunk. There,
|
||||
psym_map_symtabs_matching_filename is gone, replaced by
|
||||
psymbol_functions::expand_symtabs_matching. When this find a match,
|
||||
it calls psymtab_to_symtab, which does this same upward walk.
|
||||
|
||||
Tested on x86-64 Fedora 32.
|
||||
|
||||
I propose checking in this patch on the gdb-10 branch, and just the
|
||||
new test case on trunk.
|
||||
|
||||
gdb/ChangeLog
|
||||
2021-04-23 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
PR gdb/27743:
|
||||
* psymtab.c (partial_map_expand_apply): Expand outermost psymtab.
|
||||
|
||||
gdb/testsuite/ChangeLog
|
||||
2021-04-23 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
PR gdb/27743:
|
||||
* gdb.dwarf2/imported-unit-bp.exp: New file.
|
||||
* gdb.dwarf2/imported-unit-bp-main.c: New file.
|
||||
* gdb.dwarf2/imported-unit-bp-alt.c: New file.
|
||||
|
||||
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
|
||||
--- a/gdb/psymtab.c
|
||||
+++ b/gdb/psymtab.c
|
||||
@@ -127,9 +127,10 @@ partial_map_expand_apply (struct objfile *objfile,
|
||||
{
|
||||
struct compunit_symtab *last_made = objfile->compunit_symtabs;
|
||||
|
||||
- /* Shared psymtabs should never be seen here. Instead they should
|
||||
- be handled properly by the caller. */
|
||||
- gdb_assert (pst->user == NULL);
|
||||
+ /* We may see a shared psymtab here, but we want to expand the
|
||||
+ outermost symtab. */
|
||||
+ while (pst->user != nullptr)
|
||||
+ pst = pst->user;
|
||||
|
||||
/* Don't visit already-expanded psymtabs. */
|
||||
if (pst->readin_p (objfile))
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp-alt.c b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-alt.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-alt.c
|
||||
@@ -0,0 +1,50 @@
|
||||
+/* Copyright 2020-2021 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/>. */
|
||||
+
|
||||
+/* Used to insert labels with which we can build a fake line table. */
|
||||
+#define LL(N) asm ("line_label_" #N ": .globl line_label_" #N)
|
||||
+
|
||||
+volatile int var;
|
||||
+volatile int bar;
|
||||
+
|
||||
+/* Generate some code to take up some space. */
|
||||
+#define FILLER do { \
|
||||
+ var = 99; \
|
||||
+} while (0)
|
||||
+
|
||||
+int
|
||||
+func (void)
|
||||
+{ /* func prologue */
|
||||
+ asm ("func_label: .globl func_label");
|
||||
+ LL (1); // F1, Ln 16
|
||||
+ FILLER;
|
||||
+ LL (2); // F1, Ln 17
|
||||
+ FILLER;
|
||||
+ LL (3); // F2, Ln 21
|
||||
+ FILLER;
|
||||
+ LL (4); // F2, Ln 22 // F1, Ln 18, !S
|
||||
+ FILLER;
|
||||
+ LL (5); // F1, Ln 19 !S
|
||||
+ FILLER;
|
||||
+ LL (6); // F1, Ln 20
|
||||
+ FILLER;
|
||||
+ LL (7);
|
||||
+ FILLER;
|
||||
+ return 0; /* func end */
|
||||
+}
|
||||
+
|
||||
+#ifdef WITHMAIN
|
||||
+int main () { return 0; }
|
||||
+#endif
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp-main.c b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-main.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp-main.c
|
||||
@@ -0,0 +1,24 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2004-2021 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/>. */
|
||||
+
|
||||
+extern int func (void);
|
||||
+
|
||||
+int
|
||||
+main()
|
||||
+{
|
||||
+ return func ();
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp
|
||||
@@ -0,0 +1,128 @@
|
||||
+# Copyright 2020-2021 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/>.
|
||||
+
|
||||
+# Test that "break /absolute/file:line" works ok with imported CUs.
|
||||
+
|
||||
+load_lib dwarf.exp
|
||||
+
|
||||
+# This test can only be run on targets which support DWARF-2 and use gas.
|
||||
+if {![dwarf2_support]} {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+# The .c files use __attribute__.
|
||||
+if [get_compiler_info] {
|
||||
+ return -1
|
||||
+}
|
||||
+if !$gcc_compiled {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+standard_testfile imported-unit-bp-alt.c .S imported-unit-bp-main.c
|
||||
+
|
||||
+set build_options {nodebug optimize=-O1}
|
||||
+
|
||||
+set asm_file [standard_output_file $srcfile2]
|
||||
+Dwarf::assemble $asm_file {
|
||||
+ global srcdir subdir srcfile srcfile
|
||||
+ global build_options
|
||||
+ declare_labels lines_label callee_subprog_label cu_label
|
||||
+
|
||||
+ get_func_info func "$build_options additional_flags=-DWITHMAIN"
|
||||
+
|
||||
+ cu {} {
|
||||
+ compile_unit {
|
||||
+ {language @DW_LANG_C}
|
||||
+ {name "<artificial>"}
|
||||
+ } {
|
||||
+ imported_unit {
|
||||
+ {import %$cu_label}
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ cu {} {
|
||||
+ cu_label: compile_unit {
|
||||
+ {producer "gcc"}
|
||||
+ {language @DW_LANG_C}
|
||||
+ {name ${srcfile}}
|
||||
+ {comp_dir "/tmp"}
|
||||
+ {low_pc 0 addr}
|
||||
+ {stmt_list ${lines_label} DW_FORM_sec_offset}
|
||||
+ } {
|
||||
+ callee_subprog_label: subprogram {
|
||||
+ {external 1 flag}
|
||||
+ {name callee}
|
||||
+ {inline 3 data1}
|
||||
+ }
|
||||
+ subprogram {
|
||||
+ {external 1 flag}
|
||||
+ {name func}
|
||||
+ {low_pc $func_start addr}
|
||||
+ {high_pc "$func_start + $func_len" addr}
|
||||
+ } {
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ lines {version 2 default_is_stmt 1} lines_label {
|
||||
+ include_dir "/tmp"
|
||||
+ file_name "$srcfile" 1
|
||||
+
|
||||
+ program {
|
||||
+ {DW_LNE_set_address line_label_1}
|
||||
+ {DW_LNS_advance_line 15}
|
||||
+ {DW_LNS_copy}
|
||||
+
|
||||
+ {DW_LNE_set_address line_label_2}
|
||||
+ {DW_LNS_advance_line 1}
|
||||
+ {DW_LNS_copy}
|
||||
+
|
||||
+ {DW_LNE_set_address line_label_3}
|
||||
+ {DW_LNS_advance_line 4}
|
||||
+ {DW_LNS_copy}
|
||||
+
|
||||
+ {DW_LNE_set_address line_label_4}
|
||||
+ {DW_LNS_advance_line 1}
|
||||
+ {DW_LNS_copy}
|
||||
+
|
||||
+ {DW_LNS_advance_line -4}
|
||||
+ {DW_LNS_negate_stmt}
|
||||
+ {DW_LNS_copy}
|
||||
+
|
||||
+ {DW_LNE_set_address line_label_5}
|
||||
+ {DW_LNS_advance_line 1}
|
||||
+ {DW_LNS_copy}
|
||||
+
|
||||
+ {DW_LNE_set_address line_label_6}
|
||||
+ {DW_LNS_advance_line 1}
|
||||
+ {DW_LNS_negate_stmt}
|
||||
+ {DW_LNS_copy}
|
||||
+
|
||||
+ {DW_LNE_set_address line_label_7}
|
||||
+ {DW_LNE_end_sequence}
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+if { [prepare_for_testing "failed to prepare" ${testfile} \
|
||||
+ [list $srcfile $asm_file $srcfile3] $build_options] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_reinitialize_dir /tmp
|
||||
+
|
||||
+# Using an absolute path is important to see the bug.
|
||||
+gdb_test "break /tmp/${srcfile}:19" "Breakpoint .* file $srcfile, line .*"
|
@ -0,0 +1,236 @@
|
||||
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-gnat-dwarf-crash-3of3.patch
|
||||
|
||||
;; Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211).
|
||||
;;=push+jan
|
||||
|
||||
http://sourceware.org/ml/gdb-patches/2014-02/msg00731.html
|
||||
|
||||
--6TrnltStXW4iwmi0
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
Content-Disposition: inline
|
||||
|
||||
Hi,
|
||||
|
||||
PR 16581:
|
||||
GDB crash on inherit_abstract_dies infinite recursion
|
||||
https://sourceware.org/bugzilla/show_bug.cgi?id=16581
|
||||
|
||||
fixed crash from an infinite recursion. But in rare cases the new code can
|
||||
now gdb_assert() due to weird DWARF file.
|
||||
|
||||
I do not yet fully understand why the DWARF is as it is but just GDB should
|
||||
never crash due to invalid DWARF anyway. The "invalid" DWARF I see only in
|
||||
Fedora GCC build, not in FSF GCC build, more info at:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1069382
|
||||
http://people.redhat.com/jkratoch/gcc-debuginfo-4.8.2-7.fc20.x86_64-gnatbind.debug
|
||||
|
||||
Thanks,
|
||||
Jan
|
||||
|
||||
--6TrnltStXW4iwmi0
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
Content-Disposition: inline; filename="complaint.patch"
|
||||
|
||||
gdb/
|
||||
2014-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* dwarf2read.c (process_die): Change gdb_assert to complaint.
|
||||
|
||||
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
|
||||
--- a/gdb/dwarf2read.c
|
||||
+++ b/gdb/dwarf2read.c
|
||||
@@ -10499,6 +10499,13 @@ private:
|
||||
static void
|
||||
process_die (struct die_info *die, struct dwarf2_cu *cu)
|
||||
{
|
||||
+ if (die->in_process)
|
||||
+ {
|
||||
+ complaint (_("DIE at 0x%s attempted to be processed twice"),
|
||||
+ sect_offset_str (die->sect_off));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
process_die_scope scope (die, cu);
|
||||
|
||||
switch (die->tag)
|
||||
diff --git a/gdb/infrun.c b/gdb/infrun.c
|
||||
--- a/gdb/infrun.c
|
||||
+++ b/gdb/infrun.c
|
||||
@@ -607,6 +607,13 @@ holding the child stopped. Try \"set detach-on-fork\" or \
|
||||
target_pid_to_str (process_ptid));
|
||||
}
|
||||
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+ /* We should check PID_WAS_STOPPED and detach it stopped accordingly.
|
||||
+ In this point of code it cannot be 1 as we would not get FORK
|
||||
+ executed without CONTINUE first which resets PID_WAS_STOPPED.
|
||||
+ We would have to first TARGET_STOP and WAITPID it as with running
|
||||
+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */
|
||||
+#endif
|
||||
target_detach (parent_inf, 0);
|
||||
}
|
||||
|
||||
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
|
||||
--- a/gdb/linux-nat.c
|
||||
+++ b/gdb/linux-nat.c
|
||||
@@ -191,6 +191,12 @@ struct linux_nat_target *linux_target;
|
||||
/* Does the current host support PTRACE_GETREGSET? */
|
||||
enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN;
|
||||
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */
|
||||
+static pid_t pid_was_stopped;
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
/* The saved to_close method, inherited from inf-ptrace.c.
|
||||
Called by our to_close. */
|
||||
static void (*super_close) (struct target_ops *);
|
||||
@@ -1027,6 +1033,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled)
|
||||
if (debug_linux_nat)
|
||||
fprintf_unfiltered (gdb_stdlog,
|
||||
"LNPAW: Attaching to a stopped process\n");
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+ pid_was_stopped = ptid.pid ();
|
||||
+#endif
|
||||
|
||||
/* The process is definitely stopped. It is in a job control
|
||||
stop, unless the kernel predates the TASK_STOPPED /
|
||||
@@ -1359,6 +1368,25 @@ get_detach_signal (struct lwp_info *lp)
|
||||
return gdb_signal_to_host (signo);
|
||||
}
|
||||
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that
|
||||
+ many TIDs are left unstopped). See RH Bug 496732. */
|
||||
+ if (lp->ptid.pid () == pid_was_stopped)
|
||||
+ {
|
||||
+ int err;
|
||||
+
|
||||
+ errno = 0;
|
||||
+ err = kill_lwp (lp->ptid.lwp (), SIGSTOP);
|
||||
+ if (debug_linux_nat)
|
||||
+ {
|
||||
+ fprintf_unfiltered (gdb_stdlog,
|
||||
+ "SC: lwp kill %d %s\n",
|
||||
+ err,
|
||||
+ errno ? safe_strerror (errno) : "ERRNO-OK");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1507,6 +1535,10 @@ linux_nat_target::detach (inferior *inf, int from_tty)
|
||||
detach_one_lwp (main_lwp, &signo);
|
||||
|
||||
detach_success (inf);
|
||||
+
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+ pid_was_stopped = 0;
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1765,6 +1797,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
|
||||
return;
|
||||
}
|
||||
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+ /* At this point, we are going to resume the inferior and if we
|
||||
+ have attached to a stopped process, we no longer should leave
|
||||
+ it as stopped if the user detaches. PTID variable has PID set to LWP
|
||||
+ while we need to check the real PID here. */
|
||||
+
|
||||
+ if (!step && lp && pid_was_stopped == lp->ptid.pid ())
|
||||
+ pid_was_stopped = 0;
|
||||
+
|
||||
+#endif
|
||||
if (resume_many)
|
||||
iterate_over_lwps (ptid, linux_nat_resume_callback, lp);
|
||||
|
||||
@@ -3761,6 +3803,10 @@ linux_nat_target::mourn_inferior ()
|
||||
|
||||
/* Let the arch-specific native code know this process is gone. */
|
||||
linux_target->low_forget_process (pid);
|
||||
+#ifdef NEED_DETACH_SIGSTOP
|
||||
+
|
||||
+ pid_was_stopped = 0;
|
||||
+#endif
|
||||
}
|
||||
|
||||
/* Convert a native/host siginfo object, into/from the siginfo in the
|
||||
diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp
|
||||
--- a/gdb/testsuite/gdb.threads/attach-stopped.exp
|
||||
+++ b/gdb/testsuite/gdb.threads/attach-stopped.exp
|
||||
@@ -56,7 +56,65 @@ proc corefunc { threadtype } {
|
||||
gdb_reinitialize_dir $srcdir/$subdir
|
||||
gdb_load ${binfile}
|
||||
|
||||
- # Verify that we can attach to the stopped process.
|
||||
+ # Verify that we can attach to the process by first giving its
|
||||
+ # executable name via the file command, and using attach with the
|
||||
+ # process ID.
|
||||
+
|
||||
+ set test "$threadtype: set file, before attach1 to stopped process"
|
||||
+ gdb_test_multiple "file $binfile" "$test" {
|
||||
+ -re "Load new symbol table from.*y or n. $" {
|
||||
+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \
|
||||
+ "$test (re-read)"
|
||||
+ }
|
||||
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach1 to stopped, after setting file"
|
||||
+ gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there.
|
||||
+ if {[string equal $threadtype threaded]} {
|
||||
+ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach1 to stopped bt"
|
||||
+ } else {
|
||||
+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt"
|
||||
+ }
|
||||
+
|
||||
+ # Exit and detach the process.
|
||||
+
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Avoid some race:
|
||||
+ sleep 2
|
||||
+
|
||||
+ if [catch {open /proc/${testpid}/status r} fileid] {
|
||||
+ set line2 "NOTFOUND"
|
||||
+ } else {
|
||||
+ gets $fileid line1;
|
||||
+ gets $fileid line2;
|
||||
+ close $fileid;
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach1, exit leaves process stopped"
|
||||
+ if {[string match "*(stopped)*" $line2]} {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+
|
||||
+ # At this point, the process should still be stopped
|
||||
+
|
||||
+ gdb_start
|
||||
+ gdb_reinitialize_dir $srcdir/$subdir
|
||||
+ gdb_load ${binfile}
|
||||
+
|
||||
+ # Verify that we can attach to the process just by giving the
|
||||
+ # process ID.
|
||||
|
||||
set test "$threadtype: attach2 to stopped, after setting file"
|
||||
gdb_test_multiple "attach $testpid" "$test" {
|
@ -0,0 +1,46 @@
|
||||
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-jit-reader-multilib.patch
|
||||
|
||||
;; Fix jit-reader.h for multi-lib.
|
||||
;;=push+jan
|
||||
|
||||
diff --git a/gdb/configure b/gdb/configure
|
||||
--- a/gdb/configure
|
||||
+++ b/gdb/configure
|
||||
@@ -9680,10 +9680,12 @@ _ACEOF
|
||||
|
||||
|
||||
|
||||
-if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then
|
||||
- TARGET_PTR="unsigned long"
|
||||
-elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then
|
||||
+# Try to keep TARGET_PTR the same across archs so that jit-reader.h file
|
||||
+# content is the same for multilib distributions.
|
||||
+if test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then
|
||||
TARGET_PTR="unsigned long long"
|
||||
+elif test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then
|
||||
+ TARGET_PTR="unsigned long"
|
||||
elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then
|
||||
TARGET_PTR="unsigned __int128"
|
||||
else
|
||||
diff --git a/gdb/configure.ac b/gdb/configure.ac
|
||||
--- a/gdb/configure.ac
|
||||
+++ b/gdb/configure.ac
|
||||
@@ -843,10 +843,12 @@ AC_CHECK_SIZEOF(unsigned long long)
|
||||
AC_CHECK_SIZEOF(unsigned long)
|
||||
AC_CHECK_SIZEOF(unsigned __int128)
|
||||
|
||||
-if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then
|
||||
- TARGET_PTR="unsigned long"
|
||||
-elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then
|
||||
+# Try to keep TARGET_PTR the same across archs so that jit-reader.h file
|
||||
+# content is the same for multilib distributions.
|
||||
+if test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then
|
||||
TARGET_PTR="unsigned long long"
|
||||
+elif test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then
|
||||
+ TARGET_PTR="unsigned long"
|
||||
elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then
|
||||
TARGET_PTR="unsigned __int128"
|
||||
else
|
@ -0,0 +1,25 @@
|
||||
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-moribund-utrace-workaround.patch
|
||||
|
||||
;; Workaround non-stop moribund locations exploited by kernel utrace (BZ 590623).
|
||||
;;=push+jan: Currently it is still not fully safe.
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=590623
|
||||
http://sources.redhat.com/bugzilla/show_bug.cgi?id=11593
|
||||
|
||||
Bug in FSF GDB exploited by the ptrace-on-utrace interaction.
|
||||
|
||||
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
|
||||
--- a/gdb/breakpoint.c
|
||||
+++ b/gdb/breakpoint.c
|
||||
@@ -12016,6 +12016,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
|
||||
traps we can no longer explain. */
|
||||
|
||||
old_loc->events_till_retirement = 3 * (thread_count () + 1);
|
||||
+ /* Red Hat Bug 590623. */
|
||||
+ old_loc->events_till_retirement *= 10;
|
||||
old_loc->owner = NULL;
|
||||
|
||||
VEC_safe_push (bp_location_p, moribund_locations, old_loc);
|
@ -0,0 +1,241 @@
|
||||
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-python-gil.patch
|
||||
|
||||
;; Fix Python GIL with gdb.execute("continue") (Phil Muldoon, BZ 1116957).
|
||||
;;=push
|
||||
|
||||
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
|
||||
--- a/gdb/doc/python.texi
|
||||
+++ b/gdb/doc/python.texi
|
||||
@@ -232,6 +232,14 @@ returned as a string. The default is @code{False}, in which case the
|
||||
return value is @code{None}. If @var{to_string} is @code{True}, the
|
||||
@value{GDBN} virtual terminal will be temporarily set to unlimited width
|
||||
and height, and its pagination will be disabled; @pxref{Screen Size}.
|
||||
+
|
||||
+The @var{release_gil} flag specifies whether @value{GDBN} ought to
|
||||
+release the Python GIL before executing the command. This is useful
|
||||
+in multi-threaded Python programs where by default the Python
|
||||
+interpreter will acquire the GIL and lock other threads from
|
||||
+executing. After the command has completed executing in @value{GDBN}
|
||||
+the Python GIL is reacquired. This flag must be a boolean value. If
|
||||
+omitted, it defaults to @code{False}.
|
||||
@end defun
|
||||
|
||||
@findex gdb.breakpoints
|
||||
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
|
||||
@@ -148,6 +148,8 @@ typedef int Py_ssize_t;
|
||||
#define PyGILState_Release(ARG) ((void)(ARG))
|
||||
#define PyEval_InitThreads()
|
||||
#define PyThreadState_Swap(ARG) ((void)(ARG))
|
||||
+#define PyEval_SaveThread() ((void)(ARG))
|
||||
+#define PyEval_RestoreThread(ARG) ((void)(ARG))
|
||||
#define PyEval_ReleaseLock()
|
||||
#endif
|
||||
|
||||
diff --git a/gdb/python/python.c b/gdb/python/python.c
|
||||
--- a/gdb/python/python.c
|
||||
+++ b/gdb/python/python.c
|
||||
@@ -556,12 +556,16 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
const char *arg;
|
||||
PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
|
||||
- int from_tty, to_string;
|
||||
- static const char *keywords[] = { "command", "from_tty", "to_string", NULL };
|
||||
+ int from_tty, to_string, release_gil;
|
||||
+ static const char *keywords[] = {"command", "from_tty", "to_string", "release_gil", NULL };
|
||||
+ PyObject *release_gil_obj = NULL;
|
||||
+ /* Initialize it just to avoid a GCC false warning. */
|
||||
+ PyThreadState *state = NULL;
|
||||
|
||||
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg,
|
||||
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!O!", keywords, &arg,
|
||||
&PyBool_Type, &from_tty_obj,
|
||||
- &PyBool_Type, &to_string_obj))
|
||||
+ &PyBool_Type, &to_string_obj,
|
||||
+ &PyBool_Type, &release_gil_obj))
|
||||
return NULL;
|
||||
|
||||
from_tty = 0;
|
||||
@@ -582,6 +586,15 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
|
||||
to_string = cmp;
|
||||
}
|
||||
|
||||
+ release_gil = 0;
|
||||
+ if (release_gil_obj)
|
||||
+ {
|
||||
+ int cmp = PyObject_IsTrue (release_gil_obj);
|
||||
+ if (cmp < 0)
|
||||
+ return NULL;
|
||||
+ release_gil = cmp;
|
||||
+ }
|
||||
+
|
||||
std::string to_string_res;
|
||||
|
||||
TRY
|
||||
@@ -602,6 +615,13 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
counted_command_line lines = read_command_lines_1 (reader, 1, nullptr);
|
||||
|
||||
+ /* In the case of long running GDB commands, allow the user to
|
||||
+ release the Python GIL acquired by Python. Restore the GIL
|
||||
+ after the command has completed before handing back to
|
||||
+ Python. */
|
||||
+ if (release_gil)
|
||||
+ state = PyEval_SaveThread();
|
||||
+
|
||||
scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
|
||||
|
||||
scoped_restore save_uiout = make_scoped_restore (¤t_uiout);
|
||||
@@ -617,10 +637,22 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
|
||||
from_tty);
|
||||
else
|
||||
execute_control_commands (lines.get (), from_tty);
|
||||
+
|
||||
+ /* Reacquire the GIL if it was released earlier. */
|
||||
+ if (release_gil)
|
||||
+ PyEval_RestoreThread (state);
|
||||
}
|
||||
CATCH (except, RETURN_MASK_ALL)
|
||||
{
|
||||
- GDB_PY_HANDLE_EXCEPTION (except);
|
||||
+ if (except.reason < 0)
|
||||
+ {
|
||||
+ /* Reacquire the GIL if it was released earlier. */
|
||||
+ if (release_gil)
|
||||
+ PyEval_RestoreThread (state);
|
||||
+
|
||||
+ gdbpy_convert_exception (except);
|
||||
+ return NULL;
|
||||
+ }
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.c b/gdb/testsuite/gdb.python/py-gil-mthread.c
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.python/py-gil-mthread.c
|
||||
@@ -0,0 +1,13 @@
|
||||
+#include <stdio.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+ int i;
|
||||
+ for (i = 0; i < 10; i++)
|
||||
+ {
|
||||
+ sleep (1); /* break-here */
|
||||
+ printf ("Sleeping %d\n", i);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.exp b/gdb/testsuite/gdb.python/py-gil-mthread.exp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.python/py-gil-mthread.exp
|
||||
@@ -0,0 +1,69 @@
|
||||
+# Copyright (C) 2014 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/>.
|
||||
+
|
||||
+standard_testfile .c .py
|
||||
+set executable $testfile
|
||||
+
|
||||
+if { [prepare_for_testing $testfile.exp $executable $srcfile] } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Skip all tests if Python scripting is not enabled.
|
||||
+if { [skip_python_tests] } { continue }
|
||||
+
|
||||
+if ![runto_main] {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"] temporary
|
||||
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
|
||||
+
|
||||
+set test "response"
|
||||
+set timeout 60
|
||||
+set sleeping_last -1
|
||||
+set hello_last 0
|
||||
+set minimal 5
|
||||
+gdb_test_multiple "python exec (open ('$srcdir/$subdir/$srcfile2').read ())" $test {
|
||||
+ -re "Error: unable to start thread\r\n" {
|
||||
+ fail $test
|
||||
+ # Not $gdb_prompt-synced!
|
||||
+ }
|
||||
+ -re "Sleeping (\[0-9\]+)\r\n" {
|
||||
+ set n $expect_out(1,string)
|
||||
+ if { $sleeping_last + 1 != $n } {
|
||||
+ fail $test
|
||||
+ } else {
|
||||
+ set sleeping_last $n
|
||||
+ if { $sleeping_last >= $minimal && $hello_last >= $minimal } {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ exp_continue
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ -re "Hello \\( (\[0-9\]+) \\)\r\n" {
|
||||
+ set n $expect_out(1,string)
|
||||
+ if { $hello_last + 1 != $n } {
|
||||
+ fail $test
|
||||
+ } else {
|
||||
+ set hello_last $n
|
||||
+ if { $sleeping_last >= $minimal && $hello_last >= $minimal } {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ exp_continue
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.py b/gdb/testsuite/gdb.python/py-gil-mthread.py
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.python/py-gil-mthread.py
|
||||
@@ -0,0 +1,28 @@
|
||||
+try:
|
||||
+ import thread
|
||||
+except:
|
||||
+ import _thread
|
||||
+import time
|
||||
+import gdb
|
||||
+
|
||||
+# Define a function for the thread
|
||||
+def print_thread_hello():
|
||||
+ count = 0
|
||||
+ while count < 10:
|
||||
+ time.sleep(1)
|
||||
+ count += 1
|
||||
+ print ("Hello ( %d )" % count)
|
||||
+
|
||||
+# Create a threads a continue
|
||||
+try:
|
||||
+ thread.start_new_thread (print_thread_hello, ())
|
||||
+ gdb.execute ("continue", release_gil=True)
|
||||
+except:
|
||||
+ try:
|
||||
+ _thread.start_new_thread (print_thread_hello, ())
|
||||
+ gdb.execute ("continue", release_gil=True)
|
||||
+ except:
|
||||
+ print ("Error: unable to start thread")
|
||||
+
|
||||
+while 1:
|
||||
+ pass
|
@ -0,0 +1,25 @@
|
||||
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-readline62-ask-more-rh.patch
|
||||
|
||||
;; Work around readline-6.2 incompatibility not asking for --more-- (BZ 701131).
|
||||
;;=fedora
|
||||
|
||||
diff --git a/gdb/event-top.c b/gdb/event-top.c
|
||||
--- a/gdb/event-top.c
|
||||
+++ b/gdb/event-top.c
|
||||
@@ -1183,6 +1183,13 @@ gdb_setup_readline (int editing)
|
||||
{
|
||||
struct ui *ui = current_ui;
|
||||
|
||||
+#ifdef NEED_RL_STATE_FEDORA_GDB
|
||||
+ /* 6.2 regression: no longed asks for --more--
|
||||
+ gdb.base/readline-ask.exp
|
||||
+ https://bugzilla.redhat.com/show_bug.cgi?id=701131 */
|
||||
+ RL_SETSTATE (RL_STATE_FEDORA_GDB);
|
||||
+#endif
|
||||
+
|
||||
/* This function is a noop for the sync case. The assumption is
|
||||
that the sync setup is ALL done in gdb_init, and we would only
|
||||
mess it up here. The sync stuff should really go away over
|
@ -1,115 +0,0 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Tom de Vries <tdevries@suse.de>
|
||||
Date: Fri, 21 May 2021 15:09:14 +0200
|
||||
Subject: gdb-rhbz-2130624-assert_in_jit_event_handler.patch
|
||||
|
||||
;; Backport "[gdb/breakpoint] Fix assert in jit_event_handler"
|
||||
;; (Tom de Vries, RHBZ2130624)
|
||||
|
||||
Consider a minimal test-case test.c:
|
||||
...
|
||||
int main (void) { return 0; }
|
||||
...
|
||||
which we can compile into llvm byte code using clang:
|
||||
...
|
||||
$ clang -g -S -emit-llvm --target=x86_64-unknown-unknown-elf test.c
|
||||
...
|
||||
and then run using lli, which uses the llvm jit:
|
||||
...
|
||||
$ lli test.ll
|
||||
...
|
||||
|
||||
If we run this under gdb, we run into an assert:
|
||||
...
|
||||
$ gdb -q -batch -ex run --args /usr/bin/lli test.ll
|
||||
Dwarf Error: Cannot not find DIE at 0x18a936e7 \
|
||||
[from module libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug]
|
||||
|
||||
[Thread debugging using libthread_db enabled]
|
||||
Using host libthread_db library "/lib64/libthread_db.so.1".
|
||||
src/gdb/jit.c:1178: internal-error: \
|
||||
void jit_event_handler(gdbarch*, objfile*): \
|
||||
Assertion `jiter->jiter_data != nullptr' failed.
|
||||
...
|
||||
|
||||
This is caused by the following.
|
||||
|
||||
When running jit_breakpoint_re_set_internal, we first handle
|
||||
libLLVM.so.10.debug, and set a jit breakpoint.
|
||||
|
||||
Next we handle libLLVM.so.10:
|
||||
...
|
||||
(gdb) p the_objfile.original_name
|
||||
$42 = 0x2494170 "libLLVM.so.10"
|
||||
...
|
||||
but the minimal symbols we find are from libLLVM.so.10.debug:
|
||||
...
|
||||
(gdb) p reg_symbol.objfile.original_name
|
||||
$43 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug"
|
||||
(gdb) p desc_symbol.objfile.original_name
|
||||
$44 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug"
|
||||
...
|
||||
and consequently, the objf_data is the one from libLLVM.so.10.debug:
|
||||
...
|
||||
jiter_objfile_data *objf_data
|
||||
= get_jiter_objfile_data (reg_symbol.objfile);
|
||||
...
|
||||
and so we hit this:
|
||||
...
|
||||
if (objf_data->cached_code_address == addr)
|
||||
continue;
|
||||
...
|
||||
and no second jit breakpoint is inserted.
|
||||
|
||||
Subsequently, the jit breakpoint is triggered and handled, but when finding
|
||||
the symbol for the breakpoint address we get:
|
||||
...
|
||||
(gdb) p jit_bp_sym.objfile.original_name
|
||||
$52 = 0x2494170 "libLLVM.so.10"
|
||||
...
|
||||
|
||||
The assert 'jiter->jiter_data != nullptr' triggers because it checks
|
||||
libLLVM.so.10 while the one with jiter_data setup is libLLVM.so.10.debug.
|
||||
|
||||
This fixes the assert:
|
||||
...
|
||||
jiter_objfile_data *objf_data
|
||||
- = get_jiter_objfile_data (reg_symbol.objfile);
|
||||
- = get_jiter_objfile_data (the_objfile);
|
||||
...
|
||||
but consequently we'll have two jit breakpoints, so we also make sure we don't
|
||||
set a jit breakpoint on separate debug objects like libLLVM.so.10.debug.
|
||||
|
||||
Tested on x86_64-linux.
|
||||
|
||||
gdb/ChangeLog:
|
||||
|
||||
2021-05-21 Tom de Vries <tdevries@suse.de>
|
||||
|
||||
PR breakpoint/27889
|
||||
* jit.c (jit_breakpoint_re_set_internal): Skip separate debug
|
||||
objects. Call get_jiter_objfile_data with the_objfile.
|
||||
|
||||
diff --git a/gdb/jit.c b/gdb/jit.c
|
||||
--- a/gdb/jit.c
|
||||
+++ b/gdb/jit.c
|
||||
@@ -893,6 +893,10 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
|
||||
{
|
||||
for (objfile *the_objfile : pspace->objfiles ())
|
||||
{
|
||||
+ /* Skip separate debug objects. */
|
||||
+ if (the_objfile->separate_debug_objfile_backlink != nullptr)
|
||||
+ continue;
|
||||
+
|
||||
if (the_objfile->skip_jit_symbol_lookup)
|
||||
continue;
|
||||
|
||||
@@ -919,7 +923,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
|
||||
}
|
||||
|
||||
jiter_objfile_data *objf_data
|
||||
- = get_jiter_objfile_data (reg_symbol.objfile);
|
||||
+ = get_jiter_objfile_data (the_objfile);
|
||||
objf_data->register_code = reg_symbol.minsym;
|
||||
objf_data->descriptor = desc_symbol.minsym;
|
||||
|
@ -0,0 +1,65 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Thu, 9 Aug 2018 17:09:48 +0200
|
||||
Subject: gdb-rhbz1187581-power8-regs-1of7.patch
|
||||
|
||||
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
|
||||
|
||||
commit 05abfc39c719e740530000059bb963ad33462479
|
||||
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
Date: Mon Aug 6 16:24:55 2018 -0300
|
||||
|
||||
Fix indentation in remote_target::download_tracepoint
|
||||
|
||||
gdb/ChangeLog:
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* remote.c (remote_target::download_tracepoint): Fix indentation
|
||||
in for block.
|
||||
|
||||
diff --git a/gdb/remote.c b/gdb/remote.c
|
||||
--- a/gdb/remote.c
|
||||
+++ b/gdb/remote.c
|
||||
@@ -12912,24 +12912,24 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
error (_("Error on target while setting tracepoints."));
|
||||
}
|
||||
|
||||
- for (auto action_it = stepping_actions.begin ();
|
||||
- action_it != stepping_actions.end (); action_it++)
|
||||
- {
|
||||
- QUIT; /* Allow user to bail out with ^C. */
|
||||
-
|
||||
- bool is_first = action_it == stepping_actions.begin ();
|
||||
- bool has_more = action_it != stepping_actions.end ();
|
||||
-
|
||||
- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
|
||||
- b->number, addrbuf, /* address */
|
||||
- is_first ? "S" : "",
|
||||
- action_it->c_str (),
|
||||
- has_more ? "-" : "");
|
||||
- putpkt (buf);
|
||||
- remote_get_noisy_reply ();
|
||||
- if (strcmp (rs->buf, "OK"))
|
||||
- error (_("Error on target while setting tracepoints."));
|
||||
- }
|
||||
+ for (auto action_it = stepping_actions.begin ();
|
||||
+ action_it != stepping_actions.end (); action_it++)
|
||||
+ {
|
||||
+ QUIT; /* Allow user to bail out with ^C. */
|
||||
+
|
||||
+ bool is_first = action_it == stepping_actions.begin ();
|
||||
+ bool has_more = action_it != stepping_actions.end ();
|
||||
+
|
||||
+ xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
|
||||
+ b->number, addrbuf, /* address */
|
||||
+ is_first ? "S" : "",
|
||||
+ action_it->c_str (),
|
||||
+ has_more ? "-" : "");
|
||||
+ putpkt (buf);
|
||||
+ remote_get_noisy_reply ();
|
||||
+ if (strcmp (rs->buf, "OK"))
|
||||
+ error (_("Error on target while setting tracepoints."));
|
||||
+ }
|
||||
|
||||
if (packet_support (PACKET_TracepointSource) == PACKET_ENABLE)
|
||||
{
|
@ -0,0 +1,45 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Thu, 9 Aug 2018 17:10:46 +0200
|
||||
Subject: gdb-rhbz1187581-power8-regs-2of7.patch
|
||||
|
||||
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
|
||||
|
||||
commit aa6f3694ce867884e43d1c0406c64df08ea24bd3
|
||||
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
Date: Mon Aug 6 16:24:55 2018 -0300
|
||||
|
||||
Remove trailing '-' from the last QTDP action packet
|
||||
|
||||
The has_more predicate in remote_target::download_tracepoint always
|
||||
evaluates to true, so the last action packet will be sent with a
|
||||
trailing '-'. This patch changes the predicate to remove the last
|
||||
trailing '-'.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* remote.c (remote_target::download_tracepoint): Fix the has_more
|
||||
predicate in the QTDP action list iteration.
|
||||
|
||||
diff --git a/gdb/remote.c b/gdb/remote.c
|
||||
--- a/gdb/remote.c
|
||||
+++ b/gdb/remote.c
|
||||
@@ -12899,7 +12899,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
{
|
||||
QUIT; /* Allow user to bail out with ^C. */
|
||||
|
||||
- bool has_more = (action_it != tdp_actions.end ()
|
||||
+ bool has_more = ((action_it + 1) != tdp_actions.end ()
|
||||
|| !stepping_actions.empty ());
|
||||
|
||||
xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%c",
|
||||
@@ -12918,7 +12918,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
QUIT; /* Allow user to bail out with ^C. */
|
||||
|
||||
bool is_first = action_it == stepping_actions.begin ();
|
||||
- bool has_more = action_it != stepping_actions.end ();
|
||||
+ bool has_more = (action_it + 1) != stepping_actions.end ();
|
||||
|
||||
xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
|
||||
b->number, addrbuf, /* address */
|
@ -0,0 +1,258 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Thu, 9 Aug 2018 17:11:09 +0200
|
||||
Subject: gdb-rhbz1187581-power8-regs-3of7.patch
|
||||
|
||||
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
|
||||
|
||||
commit 3df3a985a475db004706d64f83d9085f99053611
|
||||
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
Date: Mon Aug 6 16:24:55 2018 -0300
|
||||
|
||||
Use get_remote_packet_size in download_tracepoint
|
||||
|
||||
This patch changes the remote target to use the remote packet size to
|
||||
build QTDP packets, and to check if there is enough room for the
|
||||
packet.
|
||||
|
||||
I changed the function to raise an error if the packet is too small,
|
||||
instead of aborting gdb (through xsnprintf). It isn't clear if gdb
|
||||
will be in a consistent state with respect to the stub after this,
|
||||
since it's possible that some packets will be sent but not others, and
|
||||
there could be an incomplete tracepoint on the stub.
|
||||
|
||||
The char array used to build the packets is changed to a
|
||||
gdb::char_vector and sized with the result from
|
||||
get_remote_packet_size.
|
||||
|
||||
When checking if the buffer is large enough to hold the tracepoint
|
||||
condition agent expression, the length of the expression is multiplied
|
||||
by two, since it is encoded with two hex digits per expression
|
||||
byte. For simplicity, I assume that the result won't overflow, which
|
||||
can happen for very long condition expressions.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* remote.c (remote_target::download_tracepoint): Remove BUF_SIZE.
|
||||
Replace array buf with gdb::char_vector buf, of size
|
||||
get_remote_packet_size (). Replace references to buf and
|
||||
BUF_SIZE to buf.data () and buf.size (). Replace strcpy, strcat
|
||||
and xsnprintf with snprintf. Raise errors if the buffer is too
|
||||
small.
|
||||
|
||||
diff --git a/gdb/remote.c b/gdb/remote.c
|
||||
--- a/gdb/remote.c
|
||||
+++ b/gdb/remote.c
|
||||
@@ -12799,26 +12799,35 @@ remote_target::remote_download_command_source (int num, ULONGEST addr,
|
||||
void
|
||||
remote_target::download_tracepoint (struct bp_location *loc)
|
||||
{
|
||||
-#define BUF_SIZE 2048
|
||||
-
|
||||
CORE_ADDR tpaddr;
|
||||
char addrbuf[40];
|
||||
- char buf[BUF_SIZE];
|
||||
std::vector<std::string> tdp_actions;
|
||||
std::vector<std::string> stepping_actions;
|
||||
char *pkt;
|
||||
struct breakpoint *b = loc->owner;
|
||||
struct tracepoint *t = (struct tracepoint *) b;
|
||||
struct remote_state *rs = get_remote_state ();
|
||||
+ int ret;
|
||||
+ char *err_msg = _("Tracepoint packet too large for target.");
|
||||
+ size_t size_left;
|
||||
+
|
||||
+ /* We use a buffer other than rs->buf because we'll build strings
|
||||
+ across multiple statements, and other statements in between could
|
||||
+ modify rs->buf. */
|
||||
+ gdb::char_vector buf (get_remote_packet_size ());
|
||||
|
||||
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
|
||||
|
||||
tpaddr = loc->address;
|
||||
sprintf_vma (addrbuf, tpaddr);
|
||||
- xsnprintf (buf, BUF_SIZE, "QTDP:%x:%s:%c:%lx:%x", b->number,
|
||||
- addrbuf, /* address */
|
||||
- (b->enable_state == bp_enabled ? 'E' : 'D'),
|
||||
- t->step_count, t->pass_count);
|
||||
+ ret = snprintf (buf.data (), buf.size (), "QTDP:%x:%s:%c:%lx:%x",
|
||||
+ b->number, addrbuf, /* address */
|
||||
+ (b->enable_state == bp_enabled ? 'E' : 'D'),
|
||||
+ t->step_count, t->pass_count);
|
||||
+
|
||||
+ if (ret < 0 || ret >= buf.size ())
|
||||
+ error (err_msg);
|
||||
+
|
||||
/* Fast tracepoints are mostly handled by the target, but we can
|
||||
tell the target how big of an instruction block should be moved
|
||||
around. */
|
||||
@@ -12830,8 +12839,15 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
{
|
||||
if (gdbarch_fast_tracepoint_valid_at (loc->gdbarch, tpaddr,
|
||||
NULL))
|
||||
- xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x",
|
||||
- gdb_insn_length (loc->gdbarch, tpaddr));
|
||||
+ {
|
||||
+ size_left = buf.size () - strlen (buf.data ());
|
||||
+ ret = snprintf (buf.data () + strlen (buf.data ()),
|
||||
+ size_left, ":F%x",
|
||||
+ gdb_insn_length (loc->gdbarch, tpaddr));
|
||||
+
|
||||
+ if (ret < 0 || ret >= size_left)
|
||||
+ error (err_msg);
|
||||
+ }
|
||||
else
|
||||
/* If it passed validation at definition but fails now,
|
||||
something is very wrong. */
|
||||
@@ -12855,7 +12871,14 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
struct static_tracepoint_marker marker;
|
||||
|
||||
if (target_static_tracepoint_marker_at (tpaddr, &marker))
|
||||
- strcat (buf, ":S");
|
||||
+ {
|
||||
+ size_left = buf.size () - strlen (buf.data ());
|
||||
+ ret = snprintf (buf.data () + strlen (buf.data ()),
|
||||
+ size_left, ":S");
|
||||
+
|
||||
+ if (ret < 0 || ret >= size_left)
|
||||
+ error (err_msg);
|
||||
+ }
|
||||
else
|
||||
error (_("Static tracepoint not valid during download"));
|
||||
}
|
||||
@@ -12873,10 +12896,26 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
capabilities at definition time. */
|
||||
if (remote_supports_cond_tracepoints ())
|
||||
{
|
||||
- agent_expr_up aexpr = gen_eval_for_expr (tpaddr, loc->cond.get ());
|
||||
- xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":X%x,",
|
||||
- aexpr->len);
|
||||
- pkt = buf + strlen (buf);
|
||||
+ agent_expr_up aexpr = gen_eval_for_expr (tpaddr,
|
||||
+ loc->cond.get ());
|
||||
+
|
||||
+ size_left = buf.size () - strlen (buf.data ());
|
||||
+
|
||||
+ ret = snprintf (buf.data () + strlen (buf.data ()),
|
||||
+ size_left, ":X%x,", aexpr->len);
|
||||
+
|
||||
+ if (ret < 0 || ret >= size_left)
|
||||
+ error (err_msg);
|
||||
+
|
||||
+ size_left = buf.size () - strlen (buf.data ());
|
||||
+
|
||||
+ /* Two bytes to encode each aexpr byte, plus the terminating
|
||||
+ null byte. */
|
||||
+ if (aexpr->len * 2 + 1 > size_left)
|
||||
+ error (err_msg);
|
||||
+
|
||||
+ pkt = buf.data () + strlen (buf.data ());
|
||||
+
|
||||
for (int ndx = 0; ndx < aexpr->len; ++ndx)
|
||||
pkt = pack_hex_byte (pkt, aexpr->buf[ndx]);
|
||||
*pkt = '\0';
|
||||
@@ -12887,8 +12926,17 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
}
|
||||
|
||||
if (b->commands || *default_collect)
|
||||
- strcat (buf, "-");
|
||||
- putpkt (buf);
|
||||
+ {
|
||||
+ size_left = buf.size () - strlen (buf.data ());
|
||||
+
|
||||
+ ret = snprintf (buf.data () + strlen (buf.data ()),
|
||||
+ size_left, "-");
|
||||
+
|
||||
+ if (ret < 0 || ret >= size_left)
|
||||
+ error (err_msg);
|
||||
+ }
|
||||
+
|
||||
+ putpkt (buf.data ());
|
||||
remote_get_noisy_reply ();
|
||||
if (strcmp (rs->buf, "OK"))
|
||||
error (_("Target does not support tracepoints."));
|
||||
@@ -12902,11 +12950,15 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
bool has_more = ((action_it + 1) != tdp_actions.end ()
|
||||
|| !stepping_actions.empty ());
|
||||
|
||||
- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%c",
|
||||
- b->number, addrbuf, /* address */
|
||||
- action_it->c_str (),
|
||||
- has_more ? '-' : 0);
|
||||
- putpkt (buf);
|
||||
+ ret = snprintf (buf.data (), buf.size (), "QTDP:-%x:%s:%s%c",
|
||||
+ b->number, addrbuf, /* address */
|
||||
+ action_it->c_str (),
|
||||
+ has_more ? '-' : 0);
|
||||
+
|
||||
+ if (ret < 0 || ret >= buf.size ())
|
||||
+ error (err_msg);
|
||||
+
|
||||
+ putpkt (buf.data ());
|
||||
remote_get_noisy_reply ();
|
||||
if (strcmp (rs->buf, "OK"))
|
||||
error (_("Error on target while setting tracepoints."));
|
||||
@@ -12920,12 +12972,16 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
bool is_first = action_it == stepping_actions.begin ();
|
||||
bool has_more = (action_it + 1) != stepping_actions.end ();
|
||||
|
||||
- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
|
||||
- b->number, addrbuf, /* address */
|
||||
- is_first ? "S" : "",
|
||||
- action_it->c_str (),
|
||||
- has_more ? "-" : "");
|
||||
- putpkt (buf);
|
||||
+ ret = snprintf (buf.data (), buf.size (), "QTDP:-%x:%s:%s%s%s",
|
||||
+ b->number, addrbuf, /* address */
|
||||
+ is_first ? "S" : "",
|
||||
+ action_it->c_str (),
|
||||
+ has_more ? "-" : "");
|
||||
+
|
||||
+ if (ret < 0 || ret >= buf.size ())
|
||||
+ error (err_msg);
|
||||
+
|
||||
+ putpkt (buf.data ());
|
||||
remote_get_noisy_reply ();
|
||||
if (strcmp (rs->buf, "OK"))
|
||||
error (_("Error on target while setting tracepoints."));
|
||||
@@ -12935,22 +12991,32 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||
{
|
||||
if (b->location != NULL)
|
||||
{
|
||||
- strcpy (buf, "QTDPsrc:");
|
||||
+ ret = snprintf (buf.data (), buf.size (), "QTDPsrc:");
|
||||
+
|
||||
+ if (ret < 0 || ret >= buf.size ())
|
||||
+ error (err_msg);
|
||||
+
|
||||
encode_source_string (b->number, loc->address, "at",
|
||||
event_location_to_string (b->location.get ()),
|
||||
- buf + strlen (buf), 2048 - strlen (buf));
|
||||
- putpkt (buf);
|
||||
+ buf.data () + strlen (buf.data ()),
|
||||
+ buf.size () - strlen (buf.data ()));
|
||||
+ putpkt (buf.data ());
|
||||
remote_get_noisy_reply ();
|
||||
if (strcmp (rs->buf, "OK"))
|
||||
warning (_("Target does not support source download."));
|
||||
}
|
||||
if (b->cond_string)
|
||||
{
|
||||
- strcpy (buf, "QTDPsrc:");
|
||||
+ ret = snprintf (buf.data (), buf.size (), "QTDPsrc:");
|
||||
+
|
||||
+ if (ret < 0 || ret >= buf.size ())
|
||||
+ error (err_msg);
|
||||
+
|
||||
encode_source_string (b->number, loc->address,
|
||||
- "cond", b->cond_string, buf + strlen (buf),
|
||||
- 2048 - strlen (buf));
|
||||
- putpkt (buf);
|
||||
+ "cond", b->cond_string,
|
||||
+ buf.data () + strlen (buf.data ()),
|
||||
+ buf.size () - strlen (buf.data ()));
|
||||
+ putpkt (buf.data ());
|
||||
remote_get_noisy_reply ();
|
||||
if (strcmp (rs->buf, "OK"))
|
||||
warning (_("Target does not support source download."));
|
@ -0,0 +1,449 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Thu, 9 Aug 2018 17:17:16 +0200
|
||||
Subject: gdb-rhbz1187581-power8-regs-4of7.patch
|
||||
|
||||
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
|
||||
|
||||
commit 4277c4b87addb5354cc47b98d7a73e44cfaf22c2
|
||||
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
Date: Mon Aug 6 16:24:55 2018 -0300
|
||||
|
||||
Use remote register numbers in tracepoint mask
|
||||
|
||||
Currently, tracepoint register masks in the QTDP packets include both
|
||||
internal and remote register numbers, as well as pseudo-register
|
||||
numbers.
|
||||
|
||||
This patch changes this so that the mask only includes remote register
|
||||
numbers.
|
||||
|
||||
Register numbers from agent expressions are already set in the mask
|
||||
using remote numbers. Other tracepoint actions used internal numbers,
|
||||
e.g. "collect $regs" or "collect $<pseudoreg>". To handle pseudoreg
|
||||
numbers, an empty agent expression is created and ax_reg_mask is
|
||||
called for this expression and the pseudoreg. This will cause the ax
|
||||
to set its mask with the corresponding remote raw register
|
||||
numbers (using ax_regs_mask, which calls
|
||||
gdbarch_ax_pseudo_register_collect).
|
||||
|
||||
If ax_regs_mask and gdbarch_ax_pseudo_register_collect also generate
|
||||
more ax bytecode, the ax is also appended to the collection list. It
|
||||
isn't clear that this was the original intent for
|
||||
gdbarch_ax_pseudo_register_collect, and none of the arches seem to do
|
||||
this, but if this changes in the future, it should work.
|
||||
|
||||
The patch also refactors the code used by validate_action line to
|
||||
validate axs into a function that is now called from every place that
|
||||
generates axs. Previously, some parts of tracepoint.c that generated
|
||||
axs didn't check if the ax length was greater than MAX_AGENT_EXPR_LEN.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* tracepoint.h (class collection_list) <add_register>: Remove.
|
||||
<add_remote_register, add_ax_registers, add_local_register>:
|
||||
Declare.
|
||||
<add_memrange>: Add scope parameter.
|
||||
* tracepoint.c (encode_actions_1): Likewise.
|
||||
(collection_list::add_register): Rename to ...
|
||||
(collection_list::add_remote_register): ... this. Update
|
||||
comment.
|
||||
(collection_list::add_ax_registers, add_local_register): New
|
||||
methods.
|
||||
(collection_list::add_memrange): Add scope parameter. Call
|
||||
add_local_register instead of add_register.
|
||||
(finalize_tracepoint_aexpr): New function.
|
||||
(collection_list::collect_symbol): Update calls to add_memrange.
|
||||
Call add_local_register instead of add_register. Call
|
||||
add_ax_registers. Call finalize_tracepoint_aexpr.
|
||||
(encode_actions_1): Get remote regnos for $reg action. Call
|
||||
add_remote_register, add_ax_registers, and add_local_register.
|
||||
Update call to add_memrange. Call finalize_tracepoint_aexpr.
|
||||
(validate_actionline): Call finalize_tracepoint_aexpr.
|
||||
|
||||
+2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
+
|
||||
+ * tracepoint.h (class collection_list) <add_register>: Remove.
|
||||
+ <add_remote_register, add_ax_registers, add_local_register>:
|
||||
+ Declare.
|
||||
+ <add_memrange>: Add scope parameter.
|
||||
+ * tracepoint.c (encode_actions_1): Likewise.
|
||||
+ (collection_list::add_register): Rename to ...
|
||||
+ (collection_list::add_remote_register): ... this. Update
|
||||
+ comment.
|
||||
+ (collection_list::add_ax_registers, add_local_register): New
|
||||
+ methods.
|
||||
+ (collection_list::add_memrange): Add scope parameter. Call
|
||||
+ add_local_register instead of add_register.
|
||||
+ (finalize_tracepoint_aexpr): New function.
|
||||
+ (collection_list::collect_symbol): Update calls to add_memrange.
|
||||
+ Call add_local_register instead of add_register. Call
|
||||
+ add_ax_registers. Call finalize_tracepoint_aexpr.
|
||||
+ (encode_actions_1): Get remote regnos for $reg action. Call
|
||||
+ add_remote_register, add_ax_registers, and add_local_register.
|
||||
+ Update call to add_memrange. Call finalize_tracepoint_aexpr.
|
||||
+ (validate_actionline): Call finalize_tracepoint_aexpr.
|
||||
+
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* remote.c (remote_target::download_tracepoint): Remove BUF_SIZE.
|
||||
|
||||
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
|
||||
--- a/gdb/tracepoint.c
|
||||
+++ b/gdb/tracepoint.c
|
||||
@@ -615,6 +615,19 @@ report_agent_reqs_errors (struct agent_expr *aexpr)
|
||||
error (_("Expression is too complicated."));
|
||||
}
|
||||
|
||||
+/* Call ax_reqs on AEXPR and raise an error if something is wrong. */
|
||||
+
|
||||
+static void
|
||||
+finalize_tracepoint_aexpr (struct agent_expr *aexpr)
|
||||
+{
|
||||
+ ax_reqs (aexpr);
|
||||
+
|
||||
+ if (aexpr->len > MAX_AGENT_EXPR_LEN)
|
||||
+ error (_("Expression is too complicated."));
|
||||
+
|
||||
+ report_agent_reqs_errors (aexpr);
|
||||
+}
|
||||
+
|
||||
/* worker function */
|
||||
void
|
||||
validate_actionline (const char *line, struct breakpoint *b)
|
||||
@@ -699,12 +712,7 @@ validate_actionline (const char *line, struct breakpoint *b)
|
||||
exp.get (),
|
||||
trace_string);
|
||||
|
||||
- if (aexpr->len > MAX_AGENT_EXPR_LEN)
|
||||
- error (_("Expression is too complicated."));
|
||||
-
|
||||
- ax_reqs (aexpr.get ());
|
||||
-
|
||||
- report_agent_reqs_errors (aexpr.get ());
|
||||
+ finalize_tracepoint_aexpr (aexpr.get ());
|
||||
}
|
||||
}
|
||||
while (p && *p++ == ',');
|
||||
@@ -731,11 +739,7 @@ validate_actionline (const char *line, struct breakpoint *b)
|
||||
long. */
|
||||
agent_expr_up aexpr = gen_eval_for_expr (loc->address, exp.get ());
|
||||
|
||||
- if (aexpr->len > MAX_AGENT_EXPR_LEN)
|
||||
- error (_("Expression is too complicated."));
|
||||
-
|
||||
- ax_reqs (aexpr.get ());
|
||||
- report_agent_reqs_errors (aexpr.get ());
|
||||
+ finalize_tracepoint_aexpr (aexpr.get ());
|
||||
}
|
||||
}
|
||||
while (p && *p++ == ',');
|
||||
@@ -811,10 +815,10 @@ memrange_sortmerge (std::vector<memrange> &memranges)
|
||||
}
|
||||
}
|
||||
|
||||
-/* Add a register to a collection list. */
|
||||
+/* Add remote register number REGNO to the collection list mask. */
|
||||
|
||||
void
|
||||
-collection_list::add_register (unsigned int regno)
|
||||
+collection_list::add_remote_register (unsigned int regno)
|
||||
{
|
||||
if (info_verbose)
|
||||
printf_filtered ("collect register %d\n", regno);
|
||||
@@ -824,12 +828,74 @@ collection_list::add_register (unsigned int regno)
|
||||
m_regs_mask[regno / 8] |= 1 << (regno % 8);
|
||||
}
|
||||
|
||||
+/* Add all the registers from the mask in AEXPR to the mask in the
|
||||
+ collection list. Registers in the AEXPR mask are already remote
|
||||
+ register numbers. */
|
||||
+
|
||||
+void
|
||||
+collection_list::add_ax_registers (struct agent_expr *aexpr)
|
||||
+{
|
||||
+ if (aexpr->reg_mask_len > 0)
|
||||
+ {
|
||||
+ for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
|
||||
+ {
|
||||
+ QUIT; /* Allow user to bail out with ^C. */
|
||||
+ if (aexpr->reg_mask[ndx1] != 0)
|
||||
+ {
|
||||
+ /* Assume chars have 8 bits. */
|
||||
+ for (int ndx2 = 0; ndx2 < 8; ndx2++)
|
||||
+ if (aexpr->reg_mask[ndx1] & (1 << ndx2))
|
||||
+ /* It's used -- record it. */
|
||||
+ add_remote_register (ndx1 * 8 + ndx2);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* If REGNO is raw, add its corresponding remote register number to
|
||||
+ the mask. If REGNO is a pseudo-register, figure out the necessary
|
||||
+ registers using a temporary agent expression, and add it to the
|
||||
+ list if it needs more than just a mask. */
|
||||
+
|
||||
+void
|
||||
+collection_list::add_local_register (struct gdbarch *gdbarch,
|
||||
+ unsigned int regno,
|
||||
+ CORE_ADDR scope)
|
||||
+{
|
||||
+ if (regno < gdbarch_num_regs (gdbarch))
|
||||
+ {
|
||||
+ int remote_regno = gdbarch_remote_register_number (gdbarch, regno);
|
||||
+
|
||||
+ if (remote_regno < 0)
|
||||
+ error (_("Can't collect register %d"), regno);
|
||||
+
|
||||
+ add_remote_register (remote_regno);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ agent_expr_up aexpr (new agent_expr (gdbarch, scope));
|
||||
+
|
||||
+ ax_reg_mask (aexpr.get (), regno);
|
||||
+
|
||||
+ finalize_tracepoint_aexpr (aexpr.get ());
|
||||
+
|
||||
+ add_ax_registers (aexpr.get ());
|
||||
+
|
||||
+ /* Usually ax_reg_mask for a pseudo-regiser only sets the
|
||||
+ corresponding raw registers in the ax mask, but if this isn't
|
||||
+ the case add the expression that is generated to the
|
||||
+ collection list. */
|
||||
+ if (aexpr->len > 0)
|
||||
+ add_aexpr (std::move (aexpr));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* Add a memrange to a collection list. */
|
||||
|
||||
void
|
||||
collection_list::add_memrange (struct gdbarch *gdbarch,
|
||||
int type, bfd_signed_vma base,
|
||||
- ULONGEST len)
|
||||
+ ULONGEST len, CORE_ADDR scope)
|
||||
{
|
||||
if (info_verbose)
|
||||
printf_filtered ("(%d,%s,%s)\n", type, paddress (gdbarch, base), pulongest (len));
|
||||
@@ -840,7 +906,7 @@ collection_list::add_memrange (struct gdbarch *gdbarch,
|
||||
m_memranges.emplace_back (type, base, base + len);
|
||||
|
||||
if (type != memrange_absolute) /* Better collect the base register! */
|
||||
- add_register (type);
|
||||
+ add_local_register (gdbarch, type, scope);
|
||||
}
|
||||
|
||||
/* Add a symbol to a collection list. */
|
||||
@@ -882,19 +948,19 @@ collection_list::collect_symbol (struct symbol *sym,
|
||||
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
|
||||
treat_as_expr = 1;
|
||||
else
|
||||
- add_memrange (gdbarch, memrange_absolute, offset, len);
|
||||
+ add_memrange (gdbarch, memrange_absolute, offset, len, scope);
|
||||
break;
|
||||
case LOC_REGISTER:
|
||||
reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
|
||||
if (info_verbose)
|
||||
printf_filtered ("LOC_REG[parm] %s: ",
|
||||
SYMBOL_PRINT_NAME (sym));
|
||||
- add_register (reg);
|
||||
+ add_local_register (gdbarch, reg, scope);
|
||||
/* Check for doubles stored in two registers. */
|
||||
/* FIXME: how about larger types stored in 3 or more regs? */
|
||||
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT &&
|
||||
len > register_size (gdbarch, reg))
|
||||
- add_register (reg + 1);
|
||||
+ add_local_register (gdbarch, reg + 1, scope);
|
||||
break;
|
||||
case LOC_REF_ARG:
|
||||
printf_filtered ("Sorry, don't know how to do LOC_REF_ARG yet.\n");
|
||||
@@ -911,7 +977,7 @@ collection_list::collect_symbol (struct symbol *sym,
|
||||
SYMBOL_PRINT_NAME (sym), pulongest (len),
|
||||
paddress (gdbarch, offset), reg);
|
||||
}
|
||||
- add_memrange (gdbarch, reg, offset, len);
|
||||
+ add_memrange (gdbarch, reg, offset, len, scope);
|
||||
break;
|
||||
case LOC_REGPARM_ADDR:
|
||||
reg = SYMBOL_VALUE (sym);
|
||||
@@ -923,7 +989,7 @@ collection_list::collect_symbol (struct symbol *sym,
|
||||
SYMBOL_PRINT_NAME (sym), pulongest (len),
|
||||
paddress (gdbarch, offset), reg);
|
||||
}
|
||||
- add_memrange (gdbarch, reg, offset, len);
|
||||
+ add_memrange (gdbarch, reg, offset, len, scope);
|
||||
break;
|
||||
case LOC_LOCAL:
|
||||
reg = frame_regno;
|
||||
@@ -935,7 +1001,7 @@ collection_list::collect_symbol (struct symbol *sym,
|
||||
SYMBOL_PRINT_NAME (sym), pulongest (len),
|
||||
paddress (gdbarch, offset), reg);
|
||||
}
|
||||
- add_memrange (gdbarch, reg, offset, len);
|
||||
+ add_memrange (gdbarch, reg, offset, len, scope);
|
||||
break;
|
||||
|
||||
case LOC_UNRESOLVED:
|
||||
@@ -968,26 +1034,10 @@ collection_list::collect_symbol (struct symbol *sym,
|
||||
return;
|
||||
}
|
||||
|
||||
- ax_reqs (aexpr.get ());
|
||||
-
|
||||
- report_agent_reqs_errors (aexpr.get ());
|
||||
+ finalize_tracepoint_aexpr (aexpr.get ());
|
||||
|
||||
/* Take care of the registers. */
|
||||
- if (aexpr->reg_mask_len > 0)
|
||||
- {
|
||||
- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
|
||||
- {
|
||||
- QUIT; /* Allow user to bail out with ^C. */
|
||||
- if (aexpr->reg_mask[ndx1] != 0)
|
||||
- {
|
||||
- /* Assume chars have 8 bits. */
|
||||
- for (int ndx2 = 0; ndx2 < 8; ndx2++)
|
||||
- if (aexpr->reg_mask[ndx1] & (1 << ndx2))
|
||||
- /* It's used -- record it. */
|
||||
- add_register (ndx1 * 8 + ndx2);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ add_ax_registers (aexpr.get ());
|
||||
|
||||
add_aexpr (std::move (aexpr));
|
||||
}
|
||||
@@ -1257,8 +1307,18 @@ encode_actions_1 (struct command_line *action,
|
||||
|
||||
if (0 == strncasecmp ("$reg", action_exp, 4))
|
||||
{
|
||||
- for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
|
||||
- collect->add_register (i);
|
||||
+ for (i = 0; i < gdbarch_num_regs (target_gdbarch ());
|
||||
+ i++)
|
||||
+ {
|
||||
+ int remote_regno = (gdbarch_remote_register_number
|
||||
+ (target_gdbarch (), i));
|
||||
+
|
||||
+ /* Ignore arch regnos without a corresponding
|
||||
+ remote regno. This can happen for regnos not
|
||||
+ in the tdesc. */
|
||||
+ if (remote_regno >= 0)
|
||||
+ collect->add_remote_register (remote_regno);
|
||||
+ }
|
||||
action_exp = strchr (action_exp, ','); /* more? */
|
||||
}
|
||||
else if (0 == strncasecmp ("$arg", action_exp, 4))
|
||||
@@ -1288,27 +1348,10 @@ encode_actions_1 (struct command_line *action,
|
||||
target_gdbarch (),
|
||||
trace_string);
|
||||
|
||||
- ax_reqs (aexpr.get ());
|
||||
- report_agent_reqs_errors (aexpr.get ());
|
||||
+ finalize_tracepoint_aexpr (aexpr.get ());
|
||||
|
||||
/* take care of the registers */
|
||||
- if (aexpr->reg_mask_len > 0)
|
||||
- {
|
||||
- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
|
||||
- {
|
||||
- QUIT; /* allow user to bail out with ^C */
|
||||
- if (aexpr->reg_mask[ndx1] != 0)
|
||||
- {
|
||||
- /* assume chars have 8 bits */
|
||||
- for (int ndx2 = 0; ndx2 < 8; ndx2++)
|
||||
- if (aexpr->reg_mask[ndx1] & (1 << ndx2))
|
||||
- {
|
||||
- /* It's used -- record it. */
|
||||
- collect->add_register (ndx1 * 8 + ndx2);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ collect->add_ax_registers (aexpr.get ());
|
||||
|
||||
collect->add_aexpr (std::move (aexpr));
|
||||
action_exp = strchr (action_exp, ','); /* more? */
|
||||
@@ -1340,7 +1383,8 @@ encode_actions_1 (struct command_line *action,
|
||||
name);
|
||||
if (info_verbose)
|
||||
printf_filtered ("OP_REGISTER: ");
|
||||
- collect->add_register (i);
|
||||
+ collect->add_local_register (target_gdbarch (),
|
||||
+ i, tloc->address);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1352,7 +1396,8 @@ encode_actions_1 (struct command_line *action,
|
||||
check_typedef (exp->elts[1].type);
|
||||
collect->add_memrange (target_gdbarch (),
|
||||
memrange_absolute, addr,
|
||||
- TYPE_LENGTH (exp->elts[1].type));
|
||||
+ TYPE_LENGTH (exp->elts[1].type),
|
||||
+ tloc->address);
|
||||
collect->append_exp (exp.get ());
|
||||
break;
|
||||
|
||||
@@ -1376,28 +1421,10 @@ encode_actions_1 (struct command_line *action,
|
||||
exp.get (),
|
||||
trace_string);
|
||||
|
||||
- ax_reqs (aexpr.get ());
|
||||
-
|
||||
- report_agent_reqs_errors (aexpr.get ());
|
||||
+ finalize_tracepoint_aexpr (aexpr.get ());
|
||||
|
||||
/* Take care of the registers. */
|
||||
- if (aexpr->reg_mask_len > 0)
|
||||
- {
|
||||
- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
|
||||
- {
|
||||
- QUIT; /* Allow user to bail out with ^C. */
|
||||
- if (aexpr->reg_mask[ndx1] != 0)
|
||||
- {
|
||||
- /* Assume chars have 8 bits. */
|
||||
- for (int ndx2 = 0; ndx2 < 8; ndx2++)
|
||||
- if (aexpr->reg_mask[ndx1] & (1 << ndx2))
|
||||
- {
|
||||
- /* It's used -- record it. */
|
||||
- collect->add_register (ndx1 * 8 + ndx2);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ collect->add_ax_registers (aexpr.get ());
|
||||
|
||||
collect->add_aexpr (std::move (aexpr));
|
||||
collect->append_exp (exp.get ());
|
||||
@@ -1422,8 +1449,7 @@ encode_actions_1 (struct command_line *action,
|
||||
agent_expr_up aexpr = gen_eval_for_expr (tloc->address,
|
||||
exp.get ());
|
||||
|
||||
- ax_reqs (aexpr.get ());
|
||||
- report_agent_reqs_errors (aexpr.get ());
|
||||
+ finalize_tracepoint_aexpr (aexpr.get ());
|
||||
|
||||
/* Even though we're not officially collecting, add
|
||||
to the collect list anyway. */
|
||||
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
|
||||
--- a/gdb/tracepoint.h
|
||||
+++ b/gdb/tracepoint.h
|
||||
@@ -263,9 +263,14 @@ public:
|
||||
void add_aexpr (agent_expr_up aexpr);
|
||||
|
||||
void add_register (unsigned int regno);
|
||||
+ void add_remote_register (unsigned int regno);
|
||||
+ void add_ax_registers (struct agent_expr *aexpr);
|
||||
+ void add_local_register (struct gdbarch *gdbarch,
|
||||
+ unsigned int regno,
|
||||
+ CORE_ADDR scope);
|
||||
void add_memrange (struct gdbarch *gdbarch,
|
||||
int type, bfd_signed_vma base,
|
||||
- ULONGEST len);
|
||||
+ ULONGEST len, CORE_ADDR scope);
|
||||
void collect_symbol (struct symbol *sym,
|
||||
struct gdbarch *gdbarch,
|
||||
long frame_regno, long frame_offset,
|
@ -0,0 +1,215 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Thu, 9 Aug 2018 17:17:46 +0200
|
||||
Subject: gdb-rhbz1187581-power8-regs-5of7.patch
|
||||
|
||||
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
|
||||
|
||||
commit a04b9d62a234923826e431a209d396a628661548
|
||||
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
Date: Mon Aug 6 16:24:55 2018 -0300
|
||||
|
||||
Variable size for regs mask in collection list
|
||||
|
||||
This patch changes collection_list to allow larger register masks.
|
||||
|
||||
The mask is changed from an array to a vector and is initialized to
|
||||
hold the maximum possible remote register number. The stringify
|
||||
method is updated to resize temp_buf if needed.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* tracepoint.h (collection_list) <m_regs_mask>: Change type to
|
||||
std::vector<unsigned char>.
|
||||
* tracepoint.c (collection_list::collection_list): Remove
|
||||
m_regs_mask initializer from initializer list. Resize
|
||||
m_regs_mask using the largest remote register number.
|
||||
(collection_list::add_remote_register): Remove size check on
|
||||
m_regs_mask. Use at to access element.
|
||||
(collection_list::stringify): Change type of temp_buf to
|
||||
gdb::char_vector. Update uses of temp_buf. Resize if needed to
|
||||
stringify the register mask. Use pack_hex_byte for the register
|
||||
mask.
|
||||
|
||||
+2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
+
|
||||
+ * tracepoint.h (collection_list) <m_regs_mask>: Change type to
|
||||
+ std::vector<unsigned char>.
|
||||
+ * tracepoint.c (collection_list::collection_list): Remove
|
||||
+ m_regs_mask initializer from initializer list. Resize
|
||||
+ m_regs_mask using the largest remote register number.
|
||||
+ (collection_list::add_remote_register): Remove size check on
|
||||
+ m_regs_mask. Use at to access element.
|
||||
+ (collection_list::stringify): Change type of temp_buf to
|
||||
+ gdb::char_vector. Update uses of temp_buf. Resize if needed to
|
||||
+ stringify the register mask. Use pack_hex_byte for the register
|
||||
+ mask.
|
||||
+
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* tracepoint.h (class collection_list) <add_register>: Remove.
|
||||
|
||||
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
|
||||
--- a/gdb/tracepoint.c
|
||||
+++ b/gdb/tracepoint.c
|
||||
@@ -822,10 +822,8 @@ collection_list::add_remote_register (unsigned int regno)
|
||||
{
|
||||
if (info_verbose)
|
||||
printf_filtered ("collect register %d\n", regno);
|
||||
- if (regno >= (8 * sizeof (m_regs_mask)))
|
||||
- error (_("Internal: register number %d too large for tracepoint"),
|
||||
- regno);
|
||||
- m_regs_mask[regno / 8] |= 1 << (regno % 8);
|
||||
+
|
||||
+ m_regs_mask.at (regno / 8) |= 1 << (regno % 8);
|
||||
}
|
||||
|
||||
/* Add all the registers from the mask in AEXPR to the mask in the
|
||||
@@ -1136,9 +1134,20 @@ collection_list::add_static_trace_data ()
|
||||
}
|
||||
|
||||
collection_list::collection_list ()
|
||||
- : m_regs_mask (),
|
||||
- m_strace_data (false)
|
||||
+ : m_strace_data (false)
|
||||
{
|
||||
+ int max_remote_regno = 0;
|
||||
+ for (int i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
|
||||
+ {
|
||||
+ int remote_regno = (gdbarch_remote_register_number
|
||||
+ (target_gdbarch (), i));
|
||||
+
|
||||
+ if (remote_regno >= 0 && remote_regno > max_remote_regno)
|
||||
+ max_remote_regno = remote_regno;
|
||||
+ }
|
||||
+
|
||||
+ m_regs_mask.resize ((max_remote_regno / 8) + 1);
|
||||
+
|
||||
m_memranges.reserve (128);
|
||||
m_aexprs.reserve (128);
|
||||
}
|
||||
@@ -1148,7 +1157,8 @@ collection_list::collection_list ()
|
||||
std::vector<std::string>
|
||||
collection_list::stringify ()
|
||||
{
|
||||
- char temp_buf[2048];
|
||||
+ gdb::char_vector temp_buf (2048);
|
||||
+
|
||||
int count;
|
||||
char *end;
|
||||
long i;
|
||||
@@ -1158,35 +1168,45 @@ collection_list::stringify ()
|
||||
{
|
||||
if (info_verbose)
|
||||
printf_filtered ("\nCollecting static trace data\n");
|
||||
- end = temp_buf;
|
||||
+ end = temp_buf.data ();
|
||||
*end++ = 'L';
|
||||
- str_list.emplace_back (temp_buf, end - temp_buf);
|
||||
+ str_list.emplace_back (temp_buf.data (), end - temp_buf.data ());
|
||||
}
|
||||
|
||||
- for (i = sizeof (m_regs_mask) - 1; i > 0; i--)
|
||||
+ for (i = m_regs_mask.size () - 1; i > 0; i--)
|
||||
if (m_regs_mask[i] != 0) /* Skip leading zeroes in regs_mask. */
|
||||
break;
|
||||
if (m_regs_mask[i] != 0) /* Prepare to send regs_mask to the stub. */
|
||||
{
|
||||
if (info_verbose)
|
||||
printf_filtered ("\nCollecting registers (mask): 0x");
|
||||
- end = temp_buf;
|
||||
+
|
||||
+ /* One char for 'R', one for the null terminator and two per
|
||||
+ mask byte. */
|
||||
+ std::size_t new_size = (i + 1) * 2 + 2;
|
||||
+ if (new_size > temp_buf.size ())
|
||||
+ temp_buf.resize (new_size);
|
||||
+
|
||||
+ end = temp_buf.data ();
|
||||
*end++ = 'R';
|
||||
for (; i >= 0; i--)
|
||||
{
|
||||
QUIT; /* Allow user to bail out with ^C. */
|
||||
if (info_verbose)
|
||||
printf_filtered ("%02X", m_regs_mask[i]);
|
||||
- sprintf (end, "%02X", m_regs_mask[i]);
|
||||
- end += 2;
|
||||
+
|
||||
+ end = pack_hex_byte (end, m_regs_mask[i]);
|
||||
}
|
||||
- str_list.emplace_back (temp_buf);
|
||||
+ *end = '\0';
|
||||
+
|
||||
+ str_list.emplace_back (temp_buf.data ());
|
||||
}
|
||||
if (info_verbose)
|
||||
printf_filtered ("\n");
|
||||
if (!m_memranges.empty () && info_verbose)
|
||||
printf_filtered ("Collecting memranges: \n");
|
||||
- for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++)
|
||||
+ for (i = 0, count = 0, end = temp_buf.data ();
|
||||
+ i < m_memranges.size (); i++)
|
||||
{
|
||||
QUIT; /* Allow user to bail out with ^C. */
|
||||
if (info_verbose)
|
||||
@@ -1200,9 +1220,9 @@ collection_list::stringify ()
|
||||
}
|
||||
if (count + 27 > MAX_AGENT_EXPR_LEN)
|
||||
{
|
||||
- str_list.emplace_back (temp_buf, count);
|
||||
+ str_list.emplace_back (temp_buf.data (), count);
|
||||
count = 0;
|
||||
- end = temp_buf;
|
||||
+ end = temp_buf.data ();
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1222,7 +1242,7 @@ collection_list::stringify ()
|
||||
}
|
||||
|
||||
count += strlen (end);
|
||||
- end = temp_buf + count;
|
||||
+ end = temp_buf.data () + count;
|
||||
}
|
||||
|
||||
for (i = 0; i < m_aexprs.size (); i++)
|
||||
@@ -1230,9 +1250,9 @@ collection_list::stringify ()
|
||||
QUIT; /* Allow user to bail out with ^C. */
|
||||
if ((count + 10 + 2 * m_aexprs[i]->len) > MAX_AGENT_EXPR_LEN)
|
||||
{
|
||||
- str_list.emplace_back (temp_buf, count);
|
||||
+ str_list.emplace_back (temp_buf.data (), count);
|
||||
count = 0;
|
||||
- end = temp_buf;
|
||||
+ end = temp_buf.data ();
|
||||
}
|
||||
sprintf (end, "X%08X,", m_aexprs[i]->len);
|
||||
end += 10; /* 'X' + 8 hex digits + ',' */
|
||||
@@ -1244,9 +1264,9 @@ collection_list::stringify ()
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
- str_list.emplace_back (temp_buf, count);
|
||||
+ str_list.emplace_back (temp_buf.data (), count);
|
||||
count = 0;
|
||||
- end = temp_buf;
|
||||
+ end = temp_buf.data ();
|
||||
}
|
||||
|
||||
return str_list;
|
||||
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
|
||||
--- a/gdb/tracepoint.h
|
||||
+++ b/gdb/tracepoint.h
|
||||
@@ -293,8 +293,9 @@ public:
|
||||
{ return m_computed; }
|
||||
|
||||
private:
|
||||
- /* room for up to 256 regs */
|
||||
- unsigned char m_regs_mask[32];
|
||||
+ /* We need the allocator zero-initialize the mask, so we don't use
|
||||
+ gdb::byte_vector. */
|
||||
+ std::vector<unsigned char> m_regs_mask;
|
||||
|
||||
std::vector<memrange> m_memranges;
|
||||
|
@ -0,0 +1,187 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Thu, 9 Aug 2018 17:18:15 +0200
|
||||
Subject: gdb-rhbz1187581-power8-regs-6of7.patch
|
||||
|
||||
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
|
||||
|
||||
commit 296956befef3711ed458c7cba8041fde0dab9c50
|
||||
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
Date: Mon Aug 6 16:24:55 2018 -0300
|
||||
|
||||
Allow larger regblock sizes when saving tracefiles
|
||||
|
||||
The tracefile.c:trace_save function assumes trace_regblock_size won't
|
||||
be larger than the MAX_TRACE_UPLOAD constant, used to size the buffer
|
||||
which holds trace data. This can cause buffer overruns when this is
|
||||
not the case. This patch changes this function so that the larger
|
||||
size is used to size the buffer.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* tracefile.c: Include common/byte-vector.h.
|
||||
(trace_save): Change type of buf to gdb::byte_vector. Initialize
|
||||
with trace_regblock_size if needed. Update uses of buf.
|
||||
|
||||
+2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
+
|
||||
+ * tracefile.c: Include common/byte-vector.h.
|
||||
+ (trace_save): Change type of buf to gdb::byte_vector. Initialize
|
||||
+ with trace_regblock_size if needed. Update uses of buf.
|
||||
+
|
||||
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
||||
|
||||
* tracepoint.h (collection_list) <m_regs_mask>: Change type to
|
||||
|
||||
diff --git a/gdb/tracefile.c b/gdb/tracefile.c
|
||||
--- a/gdb/tracefile.c
|
||||
+++ b/gdb/tracefile.c
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ctf.h"
|
||||
#include "exec.h"
|
||||
#include "regcache.h"
|
||||
+#include "common/byte-vector.h"
|
||||
|
||||
/* Helper macros. */
|
||||
|
||||
@@ -67,7 +68,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
|
||||
ULONGEST offset = 0;
|
||||
#define MAX_TRACE_UPLOAD 2000
|
||||
- gdb_byte buf[MAX_TRACE_UPLOAD];
|
||||
+ gdb::byte_vector buf (std::max (MAX_TRACE_UPLOAD, trace_regblock_size));
|
||||
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
|
||||
|
||||
/* If the target is to save the data to a file on its own, then just
|
||||
@@ -144,7 +145,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
/* We ask for big blocks, in the hopes of efficiency, but
|
||||
will take less if the target has packet size limitations
|
||||
or some such. */
|
||||
- gotten = target_get_raw_trace_data (buf, offset,
|
||||
+ gotten = target_get_raw_trace_data (buf.data (), offset,
|
||||
MAX_TRACE_UPLOAD);
|
||||
if (gotten < 0)
|
||||
error (_("Failure to get requested trace buffer data"));
|
||||
@@ -152,7 +153,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
if (gotten == 0)
|
||||
break;
|
||||
|
||||
- writer->ops->write_trace_buffer (writer, buf, gotten);
|
||||
+ writer->ops->write_trace_buffer (writer, buf.data (), gotten);
|
||||
|
||||
offset += gotten;
|
||||
}
|
||||
@@ -163,7 +164,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
/* Parse the trace buffers according to how data are stored
|
||||
in trace buffer in GDBserver. */
|
||||
|
||||
- gotten = target_get_raw_trace_data (buf, offset, 6);
|
||||
+ gotten = target_get_raw_trace_data (buf.data (), offset, 6);
|
||||
|
||||
if (gotten == 0)
|
||||
break;
|
||||
@@ -171,10 +172,10 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
/* Read the first six bytes in, which is the tracepoint
|
||||
number and trace frame size. */
|
||||
tp_num = (uint16_t)
|
||||
- extract_unsigned_integer (&buf[0], 2, byte_order);
|
||||
+ extract_unsigned_integer (&((buf.data ())[0]), 2, byte_order);
|
||||
|
||||
tf_size = (uint32_t)
|
||||
- extract_unsigned_integer (&buf[2], 4, byte_order);
|
||||
+ extract_unsigned_integer (&((buf.data ())[2]), 4, byte_order);
|
||||
|
||||
writer->ops->frame_ops->start (writer, tp_num);
|
||||
gotten = 6;
|
||||
@@ -192,7 +193,8 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
/* We'll fetch one block each time, in order to
|
||||
handle the extremely large 'M' block. We first
|
||||
fetch one byte to get the type of the block. */
|
||||
- gotten = target_get_raw_trace_data (buf, offset, 1);
|
||||
+ gotten = target_get_raw_trace_data (buf.data (),
|
||||
+ offset, 1);
|
||||
if (gotten < 1)
|
||||
error (_("Failure to get requested trace buffer data"));
|
||||
|
||||
@@ -205,13 +207,13 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
{
|
||||
case 'R':
|
||||
gotten
|
||||
- = target_get_raw_trace_data (buf, offset,
|
||||
+ = target_get_raw_trace_data (buf.data (), offset,
|
||||
trace_regblock_size);
|
||||
if (gotten < trace_regblock_size)
|
||||
error (_("Failure to get requested trace"
|
||||
" buffer data"));
|
||||
|
||||
- TRACE_WRITE_R_BLOCK (writer, buf,
|
||||
+ TRACE_WRITE_R_BLOCK (writer, buf.data (),
|
||||
trace_regblock_size);
|
||||
break;
|
||||
case 'M':
|
||||
@@ -221,7 +223,8 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
LONGEST t;
|
||||
int j;
|
||||
|
||||
- t = target_get_raw_trace_data (buf,offset, 10);
|
||||
+ t = target_get_raw_trace_data (buf.data (),
|
||||
+ offset, 10);
|
||||
if (t < 10)
|
||||
error (_("Failure to get requested trace"
|
||||
" buffer data"));
|
||||
@@ -231,10 +234,10 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
|
||||
gotten = 0;
|
||||
addr = (ULONGEST)
|
||||
- extract_unsigned_integer (buf, 8,
|
||||
+ extract_unsigned_integer (buf.data (), 8,
|
||||
byte_order);
|
||||
mlen = (unsigned short)
|
||||
- extract_unsigned_integer (&buf[8], 2,
|
||||
+ extract_unsigned_integer (&((buf.data ())[8]), 2,
|
||||
byte_order);
|
||||
|
||||
TRACE_WRITE_M_BLOCK_HEADER (writer, addr,
|
||||
@@ -252,14 +255,15 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
else
|
||||
read_length = mlen - j;
|
||||
|
||||
- t = target_get_raw_trace_data (buf,
|
||||
+ t = target_get_raw_trace_data (buf.data (),
|
||||
offset + j,
|
||||
read_length);
|
||||
if (t < read_length)
|
||||
error (_("Failure to get requested"
|
||||
" trace buffer data"));
|
||||
|
||||
- TRACE_WRITE_M_BLOCK_MEMORY (writer, buf,
|
||||
+ TRACE_WRITE_M_BLOCK_MEMORY (writer,
|
||||
+ buf.data (),
|
||||
read_length);
|
||||
|
||||
j += read_length;
|
||||
@@ -274,18 +278,18 @@ trace_save (const char *filename, struct trace_file_writer *writer,
|
||||
LONGEST val;
|
||||
|
||||
gotten
|
||||
- = target_get_raw_trace_data (buf, offset,
|
||||
- 12);
|
||||
+ = target_get_raw_trace_data (buf.data (),
|
||||
+ offset, 12);
|
||||
if (gotten < 12)
|
||||
error (_("Failure to get requested"
|
||||
" trace buffer data"));
|
||||
|
||||
- vnum = (int) extract_signed_integer (buf,
|
||||
+ vnum = (int) extract_signed_integer (buf.data (),
|
||||
4,
|
||||
byte_order);
|
||||
val
|
||||
- = extract_signed_integer (&buf[4], 8,
|
||||
- byte_order);
|
||||
+ = extract_signed_integer (&((buf.data ())[4]),
|
||||
+ 8, byte_order);
|
||||
|
||||
TRACE_WRITE_V_BLOCK (writer, vnum, val);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue