|
|
a8767b3 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
f524ac5 |
From: Fedora GDB patches <invalid@email.com>
|
|
|
f524ac5 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
fd7e5d7 |
Subject: gdb-gnat-dwarf-crash-3of3.patch
|
|
|
f524ac5 |
|
|
|
f637971 |
;; Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211).
|
|
|
f637971 |
;;=push+jan
|
|
|
f524ac5 |
|
|
|
f637971 |
http://sourceware.org/ml/gdb-patches/2014-02/msg00731.html
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
--6TrnltStXW4iwmi0
|
|
Jan Kratochvil |
3e56442 |
Content-Type: text/plain; charset=us-ascii
|
|
Jan Kratochvil |
3e56442 |
Content-Disposition: inline
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
Hi,
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
PR 16581:
|
|
Jan Kratochvil |
3e56442 |
GDB crash on inherit_abstract_dies infinite recursion
|
|
Jan Kratochvil |
3e56442 |
https://sourceware.org/bugzilla/show_bug.cgi?id=16581
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
fixed crash from an infinite recursion. But in rare cases the new code can
|
|
Jan Kratochvil |
3e56442 |
now gdb_assert() due to weird DWARF file.
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
I do not yet fully understand why the DWARF is as it is but just GDB should
|
|
Jan Kratochvil |
3e56442 |
never crash due to invalid DWARF anyway. The "invalid" DWARF I see only in
|
|
Jan Kratochvil |
3e56442 |
Fedora GCC build, not in FSF GCC build, more info at:
|
|
Jan Kratochvil |
3e56442 |
https://bugzilla.redhat.com/show_bug.cgi?id=1069382
|
|
Jan Kratochvil |
3e56442 |
http://people.redhat.com/jkratoch/gcc-debuginfo-4.8.2-7.fc20.x86_64-gnatbind.debug
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
Thanks,
|
|
Jan Kratochvil |
3e56442 |
Jan
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
--6TrnltStXW4iwmi0
|
|
Jan Kratochvil |
3e56442 |
Content-Type: text/plain; charset=us-ascii
|
|
Jan Kratochvil |
3e56442 |
Content-Disposition: inline; filename="complaint.patch"
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
gdb/
|
|
Jan Kratochvil |
3e56442 |
2014-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
Jan Kratochvil |
3e56442 |
|
|
Jan Kratochvil |
3e56442 |
* dwarf2read.c (process_die): Change gdb_assert to complaint.
|
|
Jan Kratochvil |
3e56442 |
|
|
|
ed8730b |
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
|
|
ed8730b |
--- a/gdb/dwarf2/read.c
|
|
|
ed8730b |
+++ b/gdb/dwarf2/read.c
|
|
Jan Kratochvil |
6c6f63f |
@@ -10159,6 +10159,13 @@ class process_die_scope
|
|
|
f637971 |
static void
|
|
|
f637971 |
process_die (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
f637971 |
{
|
|
Jan Kratochvil |
3e56442 |
+ if (die->in_process)
|
|
Jan Kratochvil |
3e56442 |
+ {
|
|
|
9e41188 |
+ complaint (_("DIE at 0x%s attempted to be processed twice"),
|
|
|
2bcd68d |
+ sect_offset_str (die->sect_off));
|
|
Jan Kratochvil |
3e56442 |
+ return;
|
|
Jan Kratochvil |
3e56442 |
+ }
|
|
|
f637971 |
+
|
|
|
f637971 |
process_die_scope scope (die, cu);
|
|
Jan Kratochvil |
3e56442 |
|
|
|
f637971 |
switch (die->tag)
|
|
|
2bcd68d |
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
|
|
|
2bcd68d |
--- a/gdb/linux-nat.c
|
|
|
2bcd68d |
+++ b/gdb/linux-nat.c
|
|
|
ed8730b |
@@ -190,6 +190,12 @@ struct linux_nat_target *linux_target;
|
|
|
2bcd68d |
/* Does the current host support PTRACE_GETREGSET? */
|
|
|
2bcd68d |
enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN;
|
|
|
2bcd68d |
|
|
|
2bcd68d |
+#ifdef NEED_DETACH_SIGSTOP
|
|
|
2bcd68d |
+/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */
|
|
|
2bcd68d |
+static pid_t pid_was_stopped;
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+#endif
|
|
|
2bcd68d |
+
|
|
|
0702d0d |
static unsigned int debug_linux_nat;
|
|
|
0702d0d |
static void
|
|
|
0702d0d |
show_debug_linux_nat (struct ui_file *file, int from_tty,
|
|
|
ed8730b |
@@ -1044,6 +1050,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled)
|
|
|
ed8730b |
if (linux_proc_pid_is_stopped (pid))
|
|
|
ed8730b |
{
|
|
|
ed8730b |
linux_nat_debug_printf ("Attaching to a stopped process");
|
|
|
2bcd68d |
+#ifdef NEED_DETACH_SIGSTOP
|
|
Jan Kratochvil |
f21bb23 |
+ pid_was_stopped = ptid.pid ();
|
|
|
2bcd68d |
+#endif
|
|
|
2bcd68d |
|
|
|
2bcd68d |
/* The process is definitely stopped. It is in a job control
|
|
|
2bcd68d |
stop, unless the kernel predates the TASK_STOPPED /
|
|
|
ed8730b |
@@ -1359,6 +1368,25 @@ get_detach_signal (struct lwp_info *lp)
|
|
|
2bcd68d |
return gdb_signal_to_host (signo);
|
|
|
2bcd68d |
}
|
|
|
2bcd68d |
|
|
|
2bcd68d |
+#ifdef NEED_DETACH_SIGSTOP
|
|
|
2bcd68d |
+ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that
|
|
|
2bcd68d |
+ many TIDs are left unstopped). See RH Bug 496732. */
|
|
Jan Kratochvil |
f21bb23 |
+ if (lp->ptid.pid () == pid_was_stopped)
|
|
|
2bcd68d |
+ {
|
|
|
2bcd68d |
+ int err;
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ errno = 0;
|
|
Jan Kratochvil |
f21bb23 |
+ err = kill_lwp (lp->ptid.lwp (), SIGSTOP);
|
|
|
2bcd68d |
+ if (debug_linux_nat)
|
|
|
2bcd68d |
+ {
|
|
|
2bcd68d |
+ fprintf_unfiltered (gdb_stdlog,
|
|
|
2bcd68d |
+ "SC: lwp kill %d %s\n",
|
|
|
2bcd68d |
+ err,
|
|
|
2bcd68d |
+ errno ? safe_strerror (errno) : "ERRNO-OK");
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+#endif
|
|
|
2bcd68d |
return 0;
|
|
|
2bcd68d |
}
|
|
|
2bcd68d |
|
|
|
ed8730b |
@@ -1502,6 +1530,10 @@ linux_nat_target::detach (inferior *inf, int from_tty)
|
|
|
2bcd68d |
detach_one_lwp (main_lwp, &signo);
|
|
|
2bcd68d |
|
|
|
2bcd68d |
detach_success (inf);
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+#ifdef NEED_DETACH_SIGSTOP
|
|
|
2bcd68d |
+ pid_was_stopped = 0;
|
|
|
2bcd68d |
+#endif
|
|
|
2bcd68d |
}
|
|
|
2bcd68d |
}
|
|
|
2bcd68d |
|
|
|
ed8730b |
@@ -1744,6 +1776,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
|
|
|
2bcd68d |
return;
|
|
|
2bcd68d |
}
|
|
|
2bcd68d |
|
|
|
2bcd68d |
+#ifdef NEED_DETACH_SIGSTOP
|
|
|
2bcd68d |
+ /* At this point, we are going to resume the inferior and if we
|
|
|
2bcd68d |
+ have attached to a stopped process, we no longer should leave
|
|
|
2bcd68d |
+ it as stopped if the user detaches. PTID variable has PID set to LWP
|
|
|
2bcd68d |
+ while we need to check the real PID here. */
|
|
|
2bcd68d |
+
|
|
Jan Kratochvil |
f21bb23 |
+ if (!step && lp && pid_was_stopped == lp->ptid.pid ())
|
|
|
2bcd68d |
+ pid_was_stopped = 0;
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+#endif
|
|
|
2bcd68d |
if (resume_many)
|
|
|
96770ac |
iterate_over_lwps (ptid, [=] (struct lwp_info *info)
|
|
|
96770ac |
{
|
|
|
ed8730b |
@@ -3617,6 +3659,10 @@ linux_nat_target::mourn_inferior ()
|
|
|
2bcd68d |
|
|
|
2bcd68d |
/* Let the arch-specific native code know this process is gone. */
|
|
|
2bcd68d |
linux_target->low_forget_process (pid);
|
|
|
2bcd68d |
+#ifdef NEED_DETACH_SIGSTOP
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ pid_was_stopped = 0;
|
|
|
2bcd68d |
+#endif
|
|
|
2bcd68d |
}
|
|
|
2bcd68d |
|
|
|
2bcd68d |
/* Convert a native/host siginfo object, into/from the siginfo in the
|
|
|
2bcd68d |
diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp
|
|
|
2bcd68d |
--- a/gdb/testsuite/gdb.threads/attach-stopped.exp
|
|
|
2bcd68d |
+++ b/gdb/testsuite/gdb.threads/attach-stopped.exp
|
|
|
2f55d67 |
@@ -56,7 +56,73 @@ proc corefunc { threadtype } {
|
|
|
2bcd68d |
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
2bcd68d |
gdb_load ${binfile}
|
|
|
2bcd68d |
|
|
|
2bcd68d |
- # Verify that we can attach to the stopped process.
|
|
|
2bcd68d |
+ # Verify that we can attach to the process by first giving its
|
|
|
2bcd68d |
+ # executable name via the file command, and using attach with the
|
|
|
2bcd68d |
+ # process ID.
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ set test "$threadtype: set file, before attach1 to stopped process"
|
|
|
2bcd68d |
+ gdb_test_multiple "file $binfile" "$test" {
|
|
|
2bcd68d |
+ -re "Load new symbol table from.*y or n. $" {
|
|
|
2f55d67 |
+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*" \
|
|
|
2bcd68d |
+ "$test (re-read)"
|
|
|
2bcd68d |
+ }
|
|
|
2f55d67 |
+ -re "Reading symbols from $escapedbinfile\.\.\.*$gdb_prompt $" {
|
|
|
2bcd68d |
+ pass "$test"
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ set test "$threadtype: attach1 to stopped, after setting file"
|
|
|
2bcd68d |
+ gdb_test_multiple "attach $testpid" "$test" {
|
|
|
2bcd68d |
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
|
|
2bcd68d |
+ pass "$test"
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there.
|
|
|
2bcd68d |
+ if {[string equal $threadtype threaded]} {
|
|
|
2bcd68d |
+ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach1 to stopped bt"
|
|
|
2bcd68d |
+ } else {
|
|
|
2bcd68d |
+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt"
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ # Exit and detach the process.
|
|
|
2f55d67 |
+
|
|
|
2bcd68d |
+ gdb_exit
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ # Avoid some race:
|
|
|
2bcd68d |
+ sleep 2
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ if [catch {open /proc/${testpid}/status r} fileid] {
|
|
|
2f55d67 |
+ set line "NOTFOUND"
|
|
|
2bcd68d |
+ } else {
|
|
|
2f55d67 |
+ while { 1 } {
|
|
|
2f55d67 |
+ if { [gets $fileid line] < 0 } {
|
|
|
2f55d67 |
+ set line "EOF"
|
|
|
2f55d67 |
+ break
|
|
|
2f55d67 |
+ }
|
|
|
2f55d67 |
+ if {[string match "State:*" $line]} {
|
|
|
2f55d67 |
+ break
|
|
|
2f55d67 |
+ }
|
|
|
2f55d67 |
+ }
|
|
|
2bcd68d |
+ close $fileid;
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ set test "$threadtype: attach1, exit leaves process stopped"
|
|
|
2f55d67 |
+ verbose -log "line: $line"
|
|
|
2f55d67 |
+ if {[string match "*(stopped)*" $line]} {
|
|
|
2bcd68d |
+ pass $test
|
|
|
2bcd68d |
+ } else {
|
|
|
2bcd68d |
+ fail $test
|
|
|
2bcd68d |
+ }
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ # At this point, the process should still be stopped
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ gdb_start
|
|
|
2bcd68d |
+ gdb_reinitialize_dir $srcdir/$subdir
|
|
|
2bcd68d |
+ gdb_load ${binfile}
|
|
|
2bcd68d |
+
|
|
|
2bcd68d |
+ # Verify that we can attach to the process just by giving the
|
|
|
2bcd68d |
+ # process ID.
|
|
|
2bcd68d |
|
|
|
2bcd68d |
set test "$threadtype: attach2 to stopped, after setting file"
|
|
|
2bcd68d |
gdb_test_multiple "attach $testpid" "$test" {
|