This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Updating pc from wrong inferior
- From: Simo Melenius <simo dot melenius at iki dot fi>
- To: gdb-patches <gdb-patches at sourceware dot org>
- Date: Thu, 4 Mar 2010 15:43:59 +0200
- Subject: Updating pc from wrong inferior
[ Disclaimer: I've quite new to gdb so I might have missed something
obvious, invalidating my patch. ]
I noticed that in gdbserver's linux_wait_for_lwp() the program counter
is sometimes updated from the wrong inferior. After a breakpoint was
hit in another thread, get_thread_regcache() was called before
current_inferior was updated, causing ptrace() getregs to fail on a
non-stopped thread.
This in turn caused gdbserver to mess up its communication or
something, and thus clientside gdb received a bad packet and entered
into a loop waiting for good data.
I fixed my test case with this patch. If it's OK, I'd like to see it
included in upstream. Thank you.
kind regards,
Simo
--- /tmp/CVS/src/gdb/gdbserver/linux-low.c 2010-02-13
03:13:54.000000000 +0200
+++ gdb/gdbserver/linux-low.c 2010-03-04 14:21:20.000000000 +0200
@@ -1067,11 +1067,12 @@
&& the_low_target.get_pc != NULL)
{
struct thread_info *saved_inferior = current_inferior;
- struct regcache *regcache = get_thread_regcache (current_inferior, 1);
+ struct regcache *regcache;
CORE_ADDR pc;
current_inferior = (struct thread_info *)
find_inferior_id (&all_threads, child->head.id);
+ regcache = get_thread_regcache (current_inferior, 1);
pc = (*the_low_target.get_pc) (regcache);
fprintf (stderr, "linux_wait_for_lwp: pc is 0x%lx\n", (long) pc);
current_inferior = saved_inferior;
--
() Today is the car of the cdr of your life.
/\ http://arc.pasp.de/