aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-tdep.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2014-08-21 20:36:20 +0200
committerJan Kratochvil <jan.kratochvil@redhat.com>2014-08-21 20:36:20 +0200
commit22fd09ae995556cc1b898afe3d5901eb161d1102 (patch)
tree5ff6539a93ea414391cf51270809fc75ee807b04 /gdb/linux-tdep.c
parent656e8868f333de49bf22e10112392ca404e5eb67 (diff)
Fix 'gcore' with exited threads
Program received signal SIGABRT, Aborted. [...] (gdb) gcore foobar Couldn't get registers: No such process. (gdb) info threads [...] (gdb) gcore foobar Saved corefile foobar (gdb) gcore tries to access the exited thread: [Thread 0x7ffff7fce700 (LWP 6895) exited] ptrace(PTRACE_GETREGS, 6895, 0, 0x7fff18167dd0) = -1 ESRCH (No such process) Without the TRY_CATCH protection testsuite FAILs for: gcore .../gdb/testsuite/gdb.threads/gcore-thread0.test Cannot find new threads: debugger service failed (gdb) FAIL: gdb.threads/gcore-thread.exp: save a zeroed-threads corefile + core .../gdb/testsuite/gdb.threads/gcore-thread0.test ".../gdb/testsuite/gdb.threads/gcore-thread0.test" is not a core dump: File format not recognized (gdb) FAIL: gdb.threads/gcore-thread.exp: core0file: re-load generated corefile (bad file format) Maybe the TRY_CATCH could be more inside update_thread_list(). Similar update_thread_list() call is IMO missing in procfs_make_note_section() but I do not have where to verify that change. gdb/ChangeLog 2014-08-21 Jan Kratochvil <jan.kratochvil@redhat.com> * linux-tdep.c (linux_corefile_thread_callback): Ignore THREAD_EXITED. (linux_make_corefile_notes): call update_thread_list, protected against exceptions. gdb/testsuite/ChangeLog 2014-08-21 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.threads/gcore-stale-thread.c: New file. * gdb.threads/gcore-stale-thread.exp: New file.
Diffstat (limited to 'gdb/linux-tdep.c')
-rw-r--r--gdb/linux-tdep.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index d0f1106ce8..dae59c50f1 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1194,6 +1194,11 @@ linux_corefile_thread_callback (struct thread_info *info, void *data)
{
struct linux_corefile_thread_data *args = data;
+ /* It can be current thread
+ which cannot be removed by update_thread_list. */
+ if (info->state == THREAD_EXITED)
+ return 0;
+
if (ptid_get_pid (info->ptid) == args->pid)
{
struct cleanup *old_chain;
@@ -1445,6 +1450,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size,
char *note_data = NULL;
gdb_byte *auxv;
int auxv_len;
+ volatile struct gdb_exception e;
if (linux_fill_prpsinfo (&prpsinfo))
{
@@ -1468,6 +1474,12 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size,
}
/* Thread register information. */
+ TRY_CATCH (e, RETURN_MASK_ERROR)
+ {
+ update_thread_list ();
+ }
+ if (e.reason < 0)
+ exception_print (gdb_stderr, e);
thread_args.gdbarch = gdbarch;
thread_args.pid = ptid_get_pid (inferior_ptid);
thread_args.obfd = obfd;