public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: gdb-patches@sourceware.org
Cc: Thomas Schwinge <thomas@codesourcery.com>,
	thomas@schwinge.name, bug-hurd@gnu.org
Subject: [PATCH 4/5] hurd: add gnu_target pointer to fix thread API calls
Date: Fri, 29 May 2020 22:07:52 +0200	[thread overview]
Message-ID: <20200529200752.qsjsbamgjekdqsp2@function> (raw)
In-Reply-To: <20200529200444.3mc4bw2nqep3d4oh@function>

gdb/ChangeLog: 

2020-05-29  Samuel Thibault  <samuel.thibault@ens-lyon.org>

	* gnu-nat.h (gnu_target): New variable declaration.
	* i386-gnu-nat.c (_initialize_i386gnu_nat): Initialize
	gnu_target.
	* gnu-nat.c (gnu_target): New variable.
	(inf_validate_procs): Pass gnu_target to thread_change_ptid,
	add_thread_silent, and add_thread calls.
	(gnu_nat_target::create_inferior): Pass gnu_target to
	add_thread_silent, thread_change_ptid call.
	(gnu_nat_target::detach): Pass gnu_target to detach_inferior
	call.

diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index 77c57817b2..7c36778394 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -150,4 +150,7 @@ struct gnu_nat_target : public inf_child_target
   void stop (ptid_t) override;
 };
 
+/* The final/concrete instance.  */
+extern gnu_nat_target *gnu_target;
+
 #endif /* GNU_NAT_H */
diff --git a/gdb/i386-gnu-nat.c b/gdb/i386-gnu-nat.c
index afbe8eff49..6382ca8acb 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/i386-gnu-nat.c
@@ -439,6 +439,8 @@ _initialize_i386gnu_nat ()
   x86_set_debug_register_length (4);
 #endif /* i386_DEBUG_STATE */
 
+  gnu_target = &the_i386_gnu_nat_target;
+
   /* Register the target.  */
   add_inf_child_target (&the_i386_gnu_nat_target);
 }
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 3b438a9a43..78e9ab7f71 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -84,6 +85,8 @@ extern "C"
 #include "msg_U.h"
 }
 
+struct gnu_nat_target *gnu_target;
+
 static process_t proc_server = MACH_PORT_NULL;
 
 /* If we've sent a proc_wait_request to the proc server, the pid of the
@@ -1106,12 +1109,12 @@ inf_validate_procs (struct inf *inf)
 	    if (inferior_ptid == ptid_t (inf->pid))
 	      /* This is the first time we're hearing about thread
 		 ids, after a fork-child.  */
-	      thread_change_ptid (inferior_ptid, ptid);
+	      thread_change_ptid (gnu_target, inferior_ptid, ptid);
 	    else if (inf->pending_execs != 0)
 	      /* This is a shell thread.  */
-	      add_thread_silent (ptid);
+	      add_thread_silent (gnu_target, ptid);
 	    else
-	      add_thread (ptid);
+	      add_thread (gnu_target, ptid);
 	  }
       }
 
@@ -2149,7 +2152,7 @@ gnu_nat_target::create_inferior (const char *exec_file,
   /* We have something that executes now.  We'll be running through
      the shell at this point (if startup-with-shell is true), but the
      pid shouldn't change.  */
-  add_thread_silent (ptid_t (pid));
+  add_thread_silent (gnu_target, ptid_t (pid));
 
   /* Attach to the now stopped child, which is actually a shell...  */
   inf_debug (inf, "attaching to child: %d", pid);
@@ -2167,7 +2170,7 @@ gnu_nat_target::create_inferior (const char *exec_file,
   inf_resume (inf);
 
   /* We now have thread info.  */
-  thread_change_ptid (inferior_ptid,
+  thread_change_ptid (gnu_target, inferior_ptid,
 		      ptid_t (inf->pid, inf_pick_first_thread (), 0));
 
   gdb_startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED);
@@ -2273,7 +2276,7 @@ gnu_nat_target::detach (inferior *inf, int from_tty)
   inf_detach (gnu_current_inf);
 
   inferior_ptid = null_ptid;
-  detach_inferior (find_inferior_pid (pid));
+  detach_inferior (find_inferior_pid (gnu_target, pid));
 
   maybe_unpush_target ();
 }

  reply	other threads:[~2020-05-29 20:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 20:01 [PATCH 1/5] hurd: fix gnu_debug_flag type Samuel Thibault
2020-05-29 20:02 ` [PATCH 2/5] hurd: add missing awk script dependency Samuel Thibault
2020-05-29 20:04   ` [PATCH 3/5] hurd: make function cast stronger Samuel Thibault
2020-05-29 20:07     ` Samuel Thibault [this message]
2020-05-29 20:09       ` [PATCH 5/5] hurd: remove unused variables Samuel Thibault
2020-05-29 20:44 ` [PATCH 1/5] hurd: fix gnu_debug_flag type Simon Marchi

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=20200529200752.qsjsbamgjekdqsp2@function \
    --to=samuel.thibault@gnu.org \
    --cc=bug-hurd@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=thomas@codesourcery.com \
    --cc=thomas@schwinge.name \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).