Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/8] nto-procfs.c: Add "target native".
Date: Mon, 17 Mar 2014 15:23:00 -0000	[thread overview]
Message-ID: <1395069784-7406-6-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1395069784-7406-1-git-send-email-palves@redhat.com>

This makes QNX/NTO end up with two targets.  It preserves "target
procfs <node>", and adds a "native" target to be like other native
ports.

Not tested.

gdb/
2014-03-17  Pedro Alves  <palves@redhat.com>

	* nto-procfs.c (procfs_can_run): New function.
	(nto_procfs_ops): New global.
	(init_procfs_targets): New, based on procfs_target.  Install
	"target native" in addition to "target procfs".
	(_initialize_procfs): Call init_procfs_targets instead of adding
	the target here.
---
 gdb/nto-procfs.c | 44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index c552a8e..b328dfa 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -1370,18 +1370,31 @@ procfs_pid_to_str (struct target_ops *ops, ptid_t ptid)
   return buf;
 }
 
-/* Create a nto-procfs target.  */
+/* to_can_run implementation for "target procfs".  Note this really
+  means "can this target be the default run target", which there can
+  be only one, and we make it be "target native" like other ports.
+  "target procfs <node>" wouldn't make sense as default run target, as
+  it needs <node>.  */
 
-static struct target_ops *
-procfs_target (void)
+static int
+procfs_can_run (struct target_ops *self)
+{
+  return 0;
+}
+
+/* "target procfs".  */
+static struct target_ops nto_procfs_ops;
+
+/* Create the "native" and "procfs" targets.  */
+
+static void
+init_procfs_targets (void)
 {
   struct target_ops *t = inf_child_target ();
 
-  t->to_shortname = "procfs";
-  t->to_longname = "QNX Neutrino procfs child process";
-  t->to_doc
-    = "QNX Neutrino procfs child process (started by the \"run\" command).\n\
-	target procfs <node>";
+  /* Leave to_shortname as "native".  */
+  t->to_longname = "QNX Neutrino local process";
+  t->to_doc = "QNX Neutrino local process (started by the \"run\" command).";
   t->to_open = procfs_open;
   t->to_attach = procfs_attach;
   t->to_post_attach = procfs_post_attach;
@@ -1411,7 +1424,16 @@ procfs_target (void)
   t->to_have_continuable_watchpoint = 1;
   t->to_extra_thread_info = nto_extra_thread_info;
 
-  return t;
+  /* Register "target native".  This is the default run target.  */
+  add_target (t);
+
+  /* Register "target procfs <node>".  */
+  nto_procfs_ops = *t;
+  nto_procfs_ops.to_shortname = "procfs";
+  nto_procfs_ops.to_can_run = procfs_can_run;
+  t->to_longname = "QNX Neutrino local or remote process";
+  t->to_doc = "QNX Neutrino process.  target procfs <node>";
+  add_target (&nto_procfs_ops);
 }
 
 #define OSTYPE_NTO 1
@@ -1420,10 +1442,8 @@ void
 _initialize_procfs (void)
 {
   sigset_t set;
-  struct target_ops *t;
 
-  t = procfs_target ();
-  add_target (t);
+  init_procfs_targets ();
 
   /* We use SIGUSR1 to gain control after we block waiting for a process.
      We use sigwaitevent to wait.  */
-- 
1.7.11.7


  parent reply	other threads:[~2014-03-17 15:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17 15:23 [PATCH 0/8] Allow making GDB not automatically connect to the native target (and add "target native") Pedro Alves
2014-03-17 15:23 ` [PATCH 4/8] Windows: Rename "target child" -> "target native" Pedro Alves
2014-03-17 15:23 ` [PATCH 1/8] Rename "target djgpp" " Pedro Alves
2014-03-17 16:44   ` Eli Zaretskii
2014-03-17 15:23 ` [PATCH 6/8] go32-nat.c: Don't override to_open Pedro Alves
2014-03-17 16:44   ` Eli Zaretskii
2014-03-17 15:23 ` [PATCH 7/8] NEWS: Mention native target renames Pedro Alves
2014-03-17 16:45   ` Eli Zaretskii
2014-03-17 15:23 ` Pedro Alves [this message]
2014-03-17 15:23 ` [PATCH 2/8] Rename "target darwin-child" -> "target native" Pedro Alves
2014-03-17 15:23 ` [PATCH 3/8] Rename "target GNU" " Pedro Alves
2014-03-17 15:23 ` [PATCH 8/8] Allow making GDB not automatically connect to the native target Pedro Alves
2014-03-17 16:47   ` Eli Zaretskii
2014-03-18 21:55   ` Stan Shebs
2014-03-25 20:06   ` Doug Evans
2014-05-21 17:53     ` Pedro Alves
2014-06-03  5:35   ` [PATCH OBV] Fix a regexp pattern in gdb.base/auto-connect-native-target.exp (Re: [PATCH 8/8] Allow making GDB not automatically connect to the native target.) Yao Qi
2014-03-17 17:01 ` [PATCH 0.5/8] Rename "target child" to "target native" Pedro Alves
2014-03-17 17:02 ` Pedro Alves
2014-06-03  5:29   ` [PATCH OBV] Fix regexp pattern in gdb.base/default.exp (Re: [PATCH 0.5/8] Rename "target child" to "target native".) Yao Qi
2014-05-21 17:57 ` [pushed] Re: [PATCH 0/8] Allow making GDB not automatically connect to the native target (and add "target native") Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395069784-7406-6-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox