From patchwork Fri Jan 20 18:12:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 6324 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2F55E23F8D for ; Fri, 20 Jan 2012 18:13:03 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id DCE75A18167 for ; Fri, 20 Jan 2012 18:13:02 +0000 (UTC) Received: by bkar19 with SMTP id r19so766493bka.11 for ; Fri, 20 Jan 2012 10:13:02 -0800 (PST) Received: by 10.205.139.66 with SMTP id iv2mr12398088bkc.27.1327083181058; Fri, 20 Jan 2012 10:13:01 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs13027bkc; Fri, 20 Jan 2012 10:13:00 -0800 (PST) Received: by 10.213.11.13 with SMTP id r13mr588770ebr.119.1327083178665; Fri, 20 Jan 2012 10:12:58 -0800 (PST) Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com. [195.75.94.110]) by mx.google.com with ESMTPS id n42si2351322eef.92.2012.01.20.10.12.58 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 Jan 2012 10:12:58 -0800 (PST) Received-SPF: pass (google.com: domain of uweigand@de.ibm.com designates 195.75.94.110 as permitted sender) client-ip=195.75.94.110; Authentication-Results: mx.google.com; spf=pass (google.com: domain of uweigand@de.ibm.com designates 195.75.94.110 as permitted sender) smtp.mail=uweigand@de.ibm.com Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Jan 2012 18:12:58 -0000 Received: from d06nrmr1507.portsmouth.uk.ibm.com (9.149.38.233) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Jan 2012 18:12:56 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0KICu3F2551850 for ; Fri, 20 Jan 2012 18:12:56 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0KICtfE030666 for ; Fri, 20 Jan 2012 11:12:56 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q0KICsvo030654 for ; Fri, 20 Jan 2012 11:12:54 -0700 Message-Id: <201201201812.q0KICsvo030654@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 20 Jan 2012 19:12:54 +0100 Subject: [rfc v4][1/6] Distinguish target and "fake" PID values To: patches@linaro.org Date: Fri, 20 Jan 2012 19:12:54 +0100 (CET) From: "Ulrich Weigand" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 x-cbid: 12012018-1948-0000-0000-000000B4642E http://sourceware.org/ml/gdb-patches/2012-01/msg00686.html From: Pedro Alves 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-19 10:35:59.000000000 +0100 +++ gdb-head/gdb/inferior.c 2012-01-19 10:39:29.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-19 10:35:59.000000000 +0100 +++ gdb-head/gdb/inferior.h 2012-01-19 10:39:29.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-19 10:37:07.000000000 +0100 +++ gdb-head/gdb/remote.c 2012-01-19 10:39:29.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);