public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/multi-target: add target stack id and change corelow to use it
@ 2013-08-14 14:41 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2013-08-14 14:41 UTC (permalink / raw)
  To: archer-commits

The branch, tromey/multi-target has been updated
       via  9d360a89784516aab9fa674e22ff7f1507bad64b (commit)
       via  0782c7536958252af14d087e4c5f45287acb062b (commit)
      from  4601a97a1aadb2af73071b6efe18b5475a988e30 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 9d360a89784516aab9fa674e22ff7f1507bad64b
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Aug 14 08:41:44 2013 -0600

    add target stack id and change corelow to use it

commit 0782c7536958252af14d087e4c5f45287acb062b
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Aug 14 07:45:02 2013 -0600

    add new ptid target field

-----------------------------------------------------------------------

Summary of changes:
 gdb/common/ptid.c |   14 ++++++++------
 gdb/common/ptid.h |   23 +++++++++++++++++------
 gdb/corelow.c     |    6 ++++--
 gdb/inferior.h    |    4 ++++
 gdb/target.c      |   15 +++++++++++++++
 gdb/target.h      |    2 ++
 6 files changed, 50 insertions(+), 14 deletions(-)

First 500 lines of diff:
diff --git a/gdb/common/ptid.c b/gdb/common/ptid.c
index 506b5c2..b02e3b8 100644
--- a/gdb/common/ptid.c
+++ b/gdb/common/ptid.c
@@ -20,28 +20,29 @@
 #include "ptid.h"
 
 /* Oft used ptids */
-ptid_t null_ptid = { 0, 0, 0 };
-ptid_t minus_one_ptid = { -1, 0, 0 };
+ptid_t null_ptid = { 0, 0, 0, 0 };
+ptid_t minus_one_ptid = { -1, 0, 0, 0 };
 
 /* Create a ptid given the necessary PID, LWP, and TID components.  */
 
 ptid_t
-ptid_build (int pid, long lwp, long tid)
+ptid_build_target (int pid, long lwp, long tid, int target)
 {
   ptid_t ptid;
 
   ptid.pid = pid;
   ptid.lwp = lwp;
   ptid.tid = tid;
+  ptid.target = target;
   return ptid;
 }
 
 /* Create a ptid from just a pid.  */
 
 ptid_t
-pid_to_ptid (int pid)
+pid_to_ptid_target (int pid, int target)
 {
-  return ptid_build (pid, 0, 0);
+  return ptid_build_target (pid, 0, 0, target);
 }
 
 /* Fetch the pid (process id) component from a ptid.  */
@@ -75,7 +76,8 @@ ptid_equal (ptid_t ptid1, ptid_t ptid2)
 {
   return (ptid1.pid == ptid2.pid
 	  && ptid1.lwp == ptid2.lwp
-	  && ptid1.tid == ptid2.tid);
+	  && ptid1.tid == ptid2.tid
+	  && ptid1.target == ptid2.target);
 }
 
 /* Returns true if PTID represents a process.  */
diff --git a/gdb/common/ptid.h b/gdb/common/ptid.h
index fefe8b6..89c020e 100644
--- a/gdb/common/ptid.h
+++ b/gdb/common/ptid.h
@@ -48,6 +48,11 @@ struct ptid
 
     /* Thread id */
     long tid;
+
+    /* Target id.  This is often 0, but it can be set if the ptid user
+       allows multiple targets.  It is just an arbitrary target
+       identifier.  */
+    int target;
   };
 
 typedef struct ptid ptid_t;
@@ -59,13 +64,19 @@ extern ptid_t null_ptid;
    or a "don't care" condition, i.e, "run all threads."  */
 extern ptid_t minus_one_ptid;
 
-/* Attempt to find and return an existing ptid with the given PID, LWP,
-   and TID components.  If none exists, create a new one and return
-   that.  */
-ptid_t ptid_build (int pid, long lwp, long tid);
+/* Attempt to find and return an existing ptid with the given PID,
+   LWP, TID, and TARGET components.  If none exists, create a new one
+   and return that.  */
+ptid_t ptid_build_target (int pid, long lwp, long tid, int target);
+
+/* Like ptid_build_target, but use 0 for TARGET.  */
+#define ptid_build(PID, LWP, TID) ptid_build_target ((PID), (LWP), (TID), 0)
+
+/* Find/Create a ptid from just a pid and target. */
+ptid_t pid_to_ptid_target (int pid, int target);
 
-/* Find/Create a ptid from just a pid. */
-ptid_t pid_to_ptid (int pid);
+/* Like pid_to_ptid_target, but supply 0 for TARGET.  */
+#define pid_to_ptid(PID) pid_to_ptid_target ((PID), 0)
 
 /* Fetch the pid (process id) component from a ptid. */
 int ptid_get_pid (ptid_t ptid);
diff --git a/gdb/corelow.c b/gdb/corelow.c
index accb54f..11e355a 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -283,7 +283,8 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
       inf->fake_pid_p = fake_pid_p;
     }
 
-  ptid = ptid_build (pid, lwpid, 0);
+  ptid = ptid_build_target (pid, lwpid, 0,
+			    inferior_target_stack_id (current_inferior ()));
 
   add_thread (ptid);
 
@@ -427,7 +428,8 @@ core_open (char *filename, int from_tty)
       if (thread == NULL)
 	{
 	  inferior_appeared (current_inferior (), CORELOW_PID);
-	  inferior_ptid = pid_to_ptid (CORELOW_PID);
+	  inferior_ptid = pid_to_ptid_target (CORELOW_PID,
+					      inferior_target_stack_id (current_inferior ()));
 	  add_thread_silent (inferior_ptid);
 	}
       else
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 6a198c9..07a04db 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -584,6 +584,10 @@ extern struct inferior *find_inferior_id (int num);
 extern struct inferior *
   find_inferior_for_program_space (struct program_space *pspace);
 
+/* Inferior's target stack id.  */
+#define inferior_target_stack_id(INF) \
+  (target_stack_id ((INF)->pspace->target_stack))
+
 /* Inferior iterator function.
 
    Calls a callback function once for each inferior, so long as the
diff --git a/gdb/target.c b/gdb/target.c
index 9381908..102ea32 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -151,6 +151,10 @@ static VEC (target_ops_ptr) *target_structs;
 
 static struct target_ops dummy_target;
 
+/* The last assigned target id.  */
+
+static int last_assigned_target_id;
+
 /* The type of the target stack.  */
 
 struct target_stack
@@ -165,6 +169,10 @@ struct target_stack
 
   int refc;
 
+  /* Target id.  */
+
+  int id;
+
   /* The debug target_ops for this target.  */
 
   struct target_ops debug_target;
@@ -5235,6 +5243,7 @@ new_target_stack (void)
   /* Overwrite the globals so that push_target can work.  */
   target_stack = XCNEW (struct target_stack);
   target_stack->refc = 1;
+  target_stack->id = last_assigned_target_id++;
   target_stack->smashed.ops = XCNEW (struct target_ops);
   current_target = &target_stack->smashed;
 
@@ -5254,6 +5263,12 @@ new_target_stack (void)
   return result;
 }
 
+int
+target_stack_id (const struct target_stack *ts)
+{
+  return ts->id;
+}
+
 /* Print a single target stack.  */
 
 static int
diff --git a/gdb/target.h b/gdb/target.h
index ea5d324..c0d999a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -901,6 +901,8 @@ extern void target_stack_set_current (struct target_stack *tstack);
 
 extern struct target_stack *new_target_stack (void);
 
+extern int target_stack_id (const struct target_stack *);
+
 /* Return true if gdb is currently in multi-target mode.  */
 
 extern int currently_multi_target (void);


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-08-14 14:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-14 14:41 [SCM] tromey/multi-target: add target stack id and change corelow to use it tromey

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).