* [rfa] gdbserver multiple register set issue: target description in remote_attach
@ 2008-05-08 20:02 Ulrich Weigand
2008-05-08 21:19 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2008-05-08 20:02 UTC (permalink / raw)
To: drow, gdb-patches
Hello,
another (potential) problem in gdbserver --multi mode. A second process that
is being attached to might have a different register set, and thus a different
XML target description. Now, the common attach code will re-query the target
description in any case. However, in the interval after the vAttach command
returns and before the description is read, GDB and gdbserver may be out of
sync about register sizes etc. In remote_open_1, the remote.c -for a similar
reason- calls target_find_description early.
While I was only able to see an actual bug due to this in a modified version of
GDB (that installs an extra target on the stack above the remote target), I think
it would be safer in any case for extended_remote_attach_1 to do the same as
remote_open_1 does and call target_find_description early.
What do you think? Would this be OK for mainline?
Tested on powerpc-linux and powerpc64-linux in local gdbserver mode.
Bye,
Ulrich
ChangeLog:
* remote.c (extended_remote_attach_1): Call target_find_description.
diff -urNp src-orig/gdb/remote.c src/gdb/remote.c
--- src-orig/gdb/remote.c 2008-04-20 17:22:14.000000000 +0200
+++ src/gdb/remote.c 2008-04-20 17:22:23.000000000 +0200
@@ -2840,6 +2840,7 @@ extended_remote_attach_1 (struct target_
struct remote_state *rs = get_remote_state ();
int pid;
char *dummy;
+ char *wait_status = NULL;
if (!args)
error_no_arg (_("process-id to attach"));
@@ -2863,8 +2864,9 @@ extended_remote_attach_1 (struct target_
printf_unfiltered (_("Attached to %s\n"),
target_pid_to_str (pid_to_ptid (pid)));
- /* We have a wait response; reuse it. */
- rs->cached_wait_status = 1;
+ /* Save the reply for later. */
+ wait_status = alloca (strlen (rs->buf) + 1);
+ strcpy (wait_status, rs->buf);
}
else if (remote_protocol_packets[PACKET_vAttach].support == PACKET_DISABLE)
error (_("This target does not support attaching to a process"));
@@ -2875,6 +2877,15 @@ extended_remote_attach_1 (struct target_
target_mark_running (target);
inferior_ptid = pid_to_ptid (pid);
attach_flag = 1;
+
+ /* Next, if the target can specify a description, read it. We do
+ this before anything involving memory or registers. */
+ target_find_description ();
+
+ /* Use the previously fetched status. */
+ gdb_assert (wait_status != NULL);
+ strcpy (rs->buf, wait_status);
+ rs->cached_wait_status = 1;
}
static void
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [rfa] gdbserver multiple register set issue: target description in remote_attach
2008-05-08 20:02 [rfa] gdbserver multiple register set issue: target description in remote_attach Ulrich Weigand
@ 2008-05-08 21:19 ` Daniel Jacobowitz
2008-05-09 1:29 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-05-08 21:19 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On Thu, May 08, 2008 at 08:29:46PM +0200, Ulrich Weigand wrote:
> What do you think? Would this be OK for mainline?
Agreed, this looks correct to me. Thanks!
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfa] gdbserver multiple register set issue: target description in remote_attach
2008-05-08 21:19 ` Daniel Jacobowitz
@ 2008-05-09 1:29 ` Ulrich Weigand
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2008-05-09 1:29 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Thu, May 08, 2008 at 08:29:46PM +0200, Ulrich Weigand wrote:
> > What do you think? Would this be OK for mainline?
>
> Agreed, this looks correct to me. Thanks!
I've committed this as well.
Thanks,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-05-08 19:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-08 20:02 [rfa] gdbserver multiple register set issue: target description in remote_attach Ulrich Weigand
2008-05-08 21:19 ` Daniel Jacobowitz
2008-05-09 1:29 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox