* [rfc v2][1/6] Distinguish target and "fake" PID values
@ 2012-01-13 18:14 Ulrich Weigand
2012-01-16 15:38 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2012-01-13 18:14 UTC (permalink / raw)
To: gdb-patches
Hello,
this is basically Pedro's patch 03-process_id.diff from:
http://sourceware.org/ml/gdb-patches/2012-01/msg00353.html
to record in `struct inferior' whether the target process id
we have has been faked by GDB or not.
The only difference is that this patch contains no uses of
fake_pid_p yet, those will be introduced later in the series.
Bye,
Ulrich
From: Pedro Alves <palves@redhat.com>
ChangeLog:
* inferior.h (struct inferior): Add fake_pid_p.
* inferior.c (exit_inferior_1): Clear fake_pid_p.
* remote.c (remote_start_remote): Set fake_pid_p if we have to use
magic_null_ptid since the remote side doesn't provide a real PID.
Index: gdb-head/gdb/inferior.c
===================================================================
--- gdb-head.orig/gdb/inferior.c 2012-01-13 18:44:36.000000000 +0100
+++ gdb-head/gdb/inferior.c 2012-01-13 18:45:55.000000000 +0100
@@ -276,6 +276,7 @@ exit_inferior_1 (struct inferior *inftoe
observer_notify_inferior_exit (inf);
inf->pid = 0;
+ inf->fake_pid_p = 0;
if (inf->vfork_parent != NULL)
{
inf->vfork_parent->vfork_child = NULL;
Index: gdb-head/gdb/inferior.h
===================================================================
--- gdb-head.orig/gdb/inferior.h 2012-01-13 18:44:36.000000000 +0100
+++ gdb-head/gdb/inferior.h 2012-01-13 18:45:55.000000000 +0100
@@ -421,6 +421,8 @@ struct inferior
/* Actual target inferior id, usually, a process id. This matches
the ptid_t.pid member of threads of this inferior. */
int pid;
+ /* True if the PID was actually faked by GDB. */
+ int fake_pid_p;
/* State of GDB control of inferior process execution.
See `struct inferior_control_state'. */
Index: gdb-head/gdb/remote.c
===================================================================
--- gdb-head.orig/gdb/remote.c 2012-01-13 18:44:36.000000000 +0100
+++ gdb-head/gdb/remote.c 2012-01-13 18:45:55.000000000 +0100
@@ -3253,6 +3253,10 @@ remote_start_remote (int from_tty, struc
if (!non_stop)
{
+ ptid_t ptid;
+ int fake_pid_p = 0;
+ struct inferior *inf;
+
if (rs->buf[0] == 'W' || rs->buf[0] == 'X')
{
if (!extended_p)
@@ -3272,19 +3276,37 @@ remote_start_remote (int from_tty, struc
/* Let the stub know that we want it to return the thread. */
set_continue_thread (minus_one_ptid);
- /* Without this, some commands which require an active target
- (such as kill) won't work. This variable serves (at least)
- double duty as both the pid of the target process (if it has
- such), and as a flag indicating that a target is active.
- These functions should be split out into seperate variables,
- especially since GDB will someday have a notion of debugging
- several processes. */
- inferior_ptid = magic_null_ptid;
+ inferior_ptid = minus_one_ptid;
/* Now, if we have thread information, update inferior_ptid. */
- inferior_ptid = remote_current_thread (inferior_ptid);
+ ptid = remote_current_thread (inferior_ptid);
+ if (!ptid_equal (ptid, minus_one_ptid))
+ {
+ if (ptid_get_pid (ptid) == -1)
+ {
+ ptid = ptid_build (ptid_get_pid (magic_null_ptid),
+ ptid_get_lwp (ptid),
+ ptid_get_tid (ptid));
+ fake_pid_p = 1;
+ }
+
+ inferior_ptid = ptid;
+ }
+ else
+ {
+ /* Without this, some commands which require an active
+ target (such as kill) won't work. This variable serves
+ (at least) double duty as both the pid of the target
+ process (if it has such), and as a flag indicating that a
+ target is active. These functions should be split out
+ into seperate variables, especially since GDB will
+ someday have a notion of debugging several processes. */
+ inferior_ptid = magic_null_ptid;
+ fake_pid_p = 1;
+ }
- remote_add_inferior (ptid_get_pid (inferior_ptid), -1);
+ inf = remote_add_inferior (ptid_get_pid (inferior_ptid), -1);
+ inf->fake_pid_p = fake_pid_p;
/* Always add the main thread. */
add_thread_silent (inferior_ptid);
--
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: [rfc v2][1/6] Distinguish target and "fake" PID values
2012-01-13 18:14 [rfc v2][1/6] Distinguish target and "fake" PID values Ulrich Weigand
@ 2012-01-16 15:38 ` Pedro Alves
2012-01-16 17:27 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2012-01-16 15:38 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On 01/13/2012 06:13 PM, Ulrich Weigand wrote:
> Hello,
>
> this is basically Pedro's patch 03-process_id.diff from:
> http://sourceware.org/ml/gdb-patches/2012-01/msg00353.html
> to record in `struct inferior' whether the target process id
> we have has been faked by GDB or not.
>
> The only difference is that this patch contains no uses of
> fake_pid_p yet, those will be introduced later in the series.
I remembered that extended_remote_create_inferior_1 (for "run")
will need the same treatment. It's no biggie, since we'll be using
multiprocess extensions in gdbserver. I'll fix it, but don't let
this block you (unless you want to fix it yourself).
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfc v2][1/6] Distinguish target and "fake" PID values
2012-01-16 15:38 ` Pedro Alves
@ 2012-01-16 17:27 ` Ulrich Weigand
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2012-01-16 17:27 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Pedro Alves wrote:
> On 01/13/2012 06:13 PM, Ulrich Weigand wrote:
> > Hello,
> >
> > this is basically Pedro's patch 03-process_id.diff from:
> > http://sourceware.org/ml/gdb-patches/2012-01/msg00353.html
> > to record in `struct inferior' whether the target process id
> > we have has been faked by GDB or not.
> >
> > The only difference is that this patch contains no uses of
> > fake_pid_p yet, those will be introduced later in the series.
>
> I remembered that extended_remote_create_inferior_1 (for "run")
> will need the same treatment. It's no biggie, since we'll be using
> multiprocess extensions in gdbserver. I'll fix it, but don't let
> this block you (unless you want to fix it yourself).
OK, thanks!
Bye,
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:[~2012-01-16 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-13 18:14 [rfc v2][1/6] Distinguish target and "fake" PID values Ulrich Weigand
2012-01-16 15:38 ` Pedro Alves
2012-01-16 17:27 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).