Index: gdb/procfs.c =================================================================== RCS file: /cvs/src/src/gdb/procfs.c,v retrieving revision 1.119 diff -u -p -r1.119 procfs.c --- gdb/procfs.c 21 Oct 2009 08:27:25 -0000 1.119 +++ gdb/procfs.c 6 Nov 2009 22:30:54 -0000 @@ -6060,9 +6060,19 @@ procfs_do_thread_registers (bfd *obfd, p gdb_gregset_t gregs; gdb_fpregset_t fpregs; unsigned long merged_pid; + struct cleanup *old_chain; merged_pid = TIDGET (ptid) << 16 | PIDGET (ptid); + /* This part is the old method for fetching registers. + It should be replaced by the newer one using regsets + once it is implemented in this platform: + gdbarch_regset_from_core_section() and regset->collect_regset(). */ + + old_chain = save_inferior_ptid (); + inferior_ptid = ptid; + target_fetch_registers (regcache, -1); + fill_gregset (regcache, &gregs, -1); #if defined (UNIXWARE) note_data = (char *) elfcore_write_lwpstatus (obfd, @@ -6085,6 +6095,9 @@ procfs_do_thread_registers (bfd *obfd, p note_size, &fpregs, sizeof (fpregs)); + + do_cleanups (old_chain); + return note_data; } @@ -6102,13 +6115,11 @@ procfs_corefile_thread_callback (procinf if (pi != NULL) { - ptid_t saved_ptid = inferior_ptid; - inferior_ptid = MERGEPID (pi->pid, thread->tid); - args->note_data = procfs_do_thread_registers (args->obfd, inferior_ptid, + ptid_t ptid = MERGEPID (pi->pid, thread->tid); + args->note_data = procfs_do_thread_registers (args->obfd, ptid, args->note_data, args->note_size, args->stop_signal); - inferior_ptid = saved_ptid; } return 0; } Index: gdb/testsuite/gdb.threads/gcore-thread.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/gcore-thread.exp,v retrieving revision 1.13 diff -u -p -r1.13 gcore-thread.exp --- gdb/testsuite/gdb.threads/gcore-thread.exp 3 Jan 2009 05:58:07 -0000 1.13 +++ gdb/testsuite/gdb.threads/gcore-thread.exp 6 Nov 2009 22:30:54 -0000 @@ -154,11 +154,7 @@ gdb_expect { } } -# FIXME: now what can we test about the thread state? -# We do not know for certain that there should be at least -# three threads, because who knows what kind of many-to-one -# mapping various OS's may do? Let's assume that there must -# be at least two threads: +# There must be at least two threads. gdb_test "info threads" ".*${nl} 2 ${horiz}${nl}\\* 1 .*" \ "corefile contains at least two threads" @@ -173,3 +169,16 @@ gdb_test "info threads" ".* thread2 .*" gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \ "thread2 is current thread in corefile" +# The threads should be standing at a known function, rather than ??. + +gdb_test_multiple "info threads" \ + "corefile contains good register values and enables symbols lookup" \ +{ + -re ".* in \\?\\? .*" { + fail "corefile contains good register values and enables symbols lookup" + } + -re ".* in \[_a-zA-Z0-9]+ \\(.*" { + pass "corefile contains good register values and enables symbols lookup" + } +} +