public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: use ptid_t::to_string instead of target_pid_to_str in debug statements
@ 2022-01-16  4:45 Simon Marchi
  2022-01-18 10:44 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2022-01-16  4:45 UTC (permalink / raw)
  To: gdb-patches

Same idea as 0fab79556484 ("gdb: use ptid_t::to_string in infrun debug
messages"), but throughout GDB.

Change-Id: I62ba36eaef29935316d7187b9b13d7b88491acc1
---
 gdb/btrace.c             | 10 ++---
 gdb/displaced-stepping.c |  4 +-
 gdb/dummy-frame.c        |  2 +-
 gdb/gnu-nat.c            | 10 ++---
 gdb/linux-nat.c          | 92 ++++++++++++++++++++--------------------
 gdb/record-btrace.c      | 16 +++----
 gdb/remote.c             |  4 +-
 gdb/thread.c             |  4 +-
 8 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/gdb/btrace.c b/gdb/btrace.c
index ba10f78e7bf5..dc4d686ac4bc 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1616,7 +1616,7 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf)
 #endif /* !defined (HAVE_LIBIPT) */
 
   DEBUG ("enable thread %s (%s)", print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str ());
+	 tp->ptid.to_string ().c_str ());
 
   tp->btrace.target = target_enable_btrace (tp->ptid, conf);
 
@@ -1671,7 +1671,7 @@ btrace_disable (struct thread_info *tp)
 	   print_thread_id (tp), target_pid_to_str (tp->ptid).c_str ());
 
   DEBUG ("disable thread %s (%s)", print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str ());
+	 tp->ptid.to_string ().c_str ());
 
   target_disable_btrace (btp->target);
   btp->target = NULL;
@@ -1690,7 +1690,7 @@ btrace_teardown (struct thread_info *tp)
     return;
 
   DEBUG ("teardown thread %s (%s)", print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str ());
+	 tp->ptid.to_string ().c_str ());
 
   target_teardown_btrace (btp->target);
   btp->target = NULL;
@@ -1912,7 +1912,7 @@ btrace_fetch (struct thread_info *tp, const struct btrace_cpu *cpu)
   int errcode;
 
   DEBUG ("fetch thread %s (%s)", print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str ());
+	 tp->ptid.to_string ().c_str ());
 
   btinfo = &tp->btrace;
   tinfo = btinfo->target;
@@ -1989,7 +1989,7 @@ btrace_clear (struct thread_info *tp)
   struct btrace_thread_info *btinfo;
 
   DEBUG ("clear thread %s (%s)", print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str ());
+	 tp->ptid.to_string ().c_str ());
 
   /* Make sure btrace frames that may hold a pointer into the branch
      trace data are destroyed.  */
diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c
index 43fc435305ea..e2afbe42f582 100644
--- a/gdb/displaced-stepping.c
+++ b/gdb/displaced-stepping.c
@@ -232,7 +232,7 @@ displaced_step_buffers::finish (gdbarch *arch, thread_info *thread,
 		     buffer->saved_copy.data (), len);
 
   displaced_debug_printf ("restored %s %s",
-			  target_pid_to_str (thread->ptid).c_str (),
+			  thread->ptid.to_string ().c_str (),
 			  paddress (arch, buffer->addr));
 
   regcache *rc = get_thread_regcache (thread);
@@ -285,7 +285,7 @@ displaced_step_buffers::restore_in_ptid (ptid_t ptid)
       write_memory_ptid (ptid, buffer.addr, buffer.saved_copy.data (), len);
 
       displaced_debug_printf ("restored in ptid %s %s",
-			      target_pid_to_str (ptid).c_str (),
+			      ptid.to_string ().c_str (),
 			      paddress (arch, buffer.addr));
     }
 }
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index 41c0bdeb9455..db7aaacdc5ae 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -408,7 +408,7 @@ fprint_dummy_frames (struct ui_file *file)
     fprintf_filtered (file, "%s: id=%s, ptid=%s\n",
 		      host_address_to_string (s),
 		      s->id.id.to_string ().c_str (),
-		      target_pid_to_str (s->id.thread->ptid).c_str ());
+		      s->id.thread->ptid.to_string ().c_str ());
 }
 
 static void
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 9c53e3c0c2f4..1586a738dee2 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -1463,7 +1463,7 @@ gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
 
   waiting_inf = inf;
 
-  inf_debug (inf, "waiting for: %s", target_pid_to_str (ptid).c_str ());
+  inf_debug (inf, "waiting for: %s", ptid.to_string ().c_str ());
 
 rewait:
   if (proc_wait_pid != inf->pid && !inf->no_wait)
@@ -1621,7 +1621,7 @@ gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
     }
 
   inf_debug (inf, "returning ptid = %s, %s",
-	     target_pid_to_str (ptid).c_str (),
+	     ptid.to_string ().c_str (),
 	     status->to_string ().c_str ());
 
   return ptid;
@@ -1973,7 +1973,7 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
   struct inf *inf = gnu_current_inf;
 
   inf_debug (inf, "ptid = %s, step = %d, sig = %d",
-	     target_pid_to_str (ptid).c_str (), step, sig);
+	     ptid.to_string ().c_str (), step, sig);
 
   inf_validate_procinfo (inf);
 
@@ -2021,7 +2021,7 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 	error (_("Can't run single thread id %s: no such thread!"),
 	       target_pid_to_str (ptid).c_str ());
       inf_debug (inf, "running one thread: %s",
-		 target_pid_to_str (ptid).c_str ());
+		 ptid.to_string ().c_str ());
       inf_set_threads_resume_sc (inf, thread, 0);
     }
 
@@ -2033,7 +2033,7 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 		 target_pid_to_str (ptid).c_str ());
       else
 	inf_debug (inf, "stepping thread: %s",
-		   target_pid_to_str (ptid).c_str ());
+		   ptid.to_string ().c_str ());
     }
   if (step_thread != inf->step_thread)
     inf_set_step_thread (inf, step_thread);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index b926fb5eba9e..0cc6923ad023 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1123,7 +1123,7 @@ attach_proc_task_lwp_callback (ptid_t ptid)
       else
 	{
 	  linux_nat_debug_printf ("PTRACE_ATTACH %s, 0, 0 (OK)",
-				  target_pid_to_str (ptid).c_str ());
+				  ptid.to_string ().c_str ());
 
 	  lp = add_lwp (ptid);
 
@@ -1356,18 +1356,18 @@ get_detach_signal (struct lwp_info *lp)
   if (signo == GDB_SIGNAL_0)
     {
       linux_nat_debug_printf ("lwp %s has no pending signal",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
   else if (!signal_pass_state (signo))
     {
       linux_nat_debug_printf
 	("lwp %s had signal %s but it is in no pass state",
-	 target_pid_to_str (lp->ptid).c_str (), gdb_signal_to_string (signo));
+	 lp->ptid.to_string ().c_str (), gdb_signal_to_string (signo));
     }
   else
     {
       linux_nat_debug_printf ("lwp %s has pending signal %s",
-			      target_pid_to_str (lp->ptid).c_str (),
+			      lp->ptid.to_string ().c_str (),
 			      gdb_signal_to_string (signo));
 
       return gdb_signal_to_host (signo);
@@ -1433,13 +1433,13 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
   if (lp->status != 0)
     linux_nat_debug_printf ("Pending %s for %s on detach.",
 			    strsignal (WSTOPSIG (lp->status)),
-			    target_pid_to_str (lp->ptid).c_str ());
+			    lp->ptid.to_string ().c_str ());
 
   /* If there is a pending SIGSTOP, get rid of it.  */
   if (lp->signalled)
     {
       linux_nat_debug_printf ("Sending SIGCONT to %s",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
 
       kill_lwp (lwpid, SIGCONT);
       lp->signalled = 0;
@@ -1630,12 +1630,12 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
       if (inf->vfork_child != NULL)
 	{
 	  linux_nat_debug_printf ("Not resuming %s (vfork parent)",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 	}
       else if (!lwp_status_pending_p (lp))
 	{
 	  linux_nat_debug_printf ("Resuming sibling %s, %s, %s",
-				  target_pid_to_str (lp->ptid).c_str (),
+				  lp->ptid.to_string ().c_str (),
 				  (signo != GDB_SIGNAL_0
 				   ? strsignal (gdb_signal_to_host (signo))
 				   : "0"),
@@ -1646,12 +1646,12 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
       else
 	{
 	  linux_nat_debug_printf ("Not resuming sibling %s (has pending)",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 	}
     }
   else
     linux_nat_debug_printf ("Not resuming sibling %s (not stopped)",
-			    target_pid_to_str (lp->ptid).c_str ());
+			    lp->ptid.to_string ().c_str ());
 }
 
 /* Callback for iterate_over_lwps.  If LWP is EXCEPT, do nothing.
@@ -1705,10 +1705,10 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
 
   linux_nat_debug_printf ("Preparing to %s %s, %s, inferior_ptid %s",
 			  step ? "step" : "resume",
-			  target_pid_to_str (ptid).c_str (),
+			  ptid.to_string ().c_str (),
 			  (signo != GDB_SIGNAL_0
 			   ? strsignal (gdb_signal_to_host (signo)) : "0"),
-			  target_pid_to_str (inferior_ptid).c_str ());
+			  inferior_ptid.to_string ().c_str ());
 
   /* A specific PTID means `step only this process id'.  */
   resume_many = (minus_one_ptid == ptid
@@ -1780,7 +1780,7 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
 
   linux_nat_debug_printf ("%s %s, %s (resume event thread)",
 			  step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-			  target_pid_to_str (lp->ptid).c_str (),
+			  lp->ptid.to_string ().c_str (),
 			  (signo != GDB_SIGNAL_0
 			   ? strsignal (gdb_signal_to_host (signo)) : "0"));
 
@@ -2167,7 +2167,7 @@ wait_lwp (struct lwp_info *lp)
 	     the top of the file.  */
 	  thread_dead = 1;
 	  linux_nat_debug_printf ("%s vanished.",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 	}
       if (pid != 0)
 	break;
@@ -2191,7 +2191,7 @@ wait_lwp (struct lwp_info *lp)
 	{
 	  thread_dead = 1;
 	  linux_nat_debug_printf ("Thread group leader %s vanished.",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 	  break;
 	}
 
@@ -2211,7 +2211,7 @@ wait_lwp (struct lwp_info *lp)
       gdb_assert (pid == lp->ptid.lwp ());
 
       linux_nat_debug_printf ("waitpid %s received %s",
-			      target_pid_to_str (lp->ptid).c_str (),
+			      lp->ptid.to_string ().c_str (),
 			      status_to_str (status).c_str ());
 
       /* Check if the thread has exited.  */
@@ -2232,7 +2232,7 @@ wait_lwp (struct lwp_info *lp)
 
 	  thread_dead = 1;
 	  linux_nat_debug_printf ("%s exited.",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 	}
     }
 
@@ -2294,7 +2294,7 @@ stop_callback (struct lwp_info *lp)
       int ret;
 
       linux_nat_debug_printf ("kill %s **<SIGSTOP>**",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
 
       errno = 0;
       ret = kill_lwp (lp->ptid.lwp (), SIGSTOP);
@@ -2388,7 +2388,7 @@ maybe_clear_ignore_sigint (struct lwp_info *lp)
   if (!linux_nat_has_pending_sigint (lp->ptid.lwp ()))
     {
       linux_nat_debug_printf ("Clearing bogus flag for %s",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
       lp->ignore_sigint = 0;
     }
 }
@@ -2486,7 +2486,7 @@ stop_wait_callback (struct lwp_info *lp)
 	  lp->stopped = 0;
 	  linux_nat_debug_printf
 	    ("PTRACE_CONT %s, 0, 0 (%s) (discarding SIGINT)",
-	     target_pid_to_str (lp->ptid).c_str (),
+	     lp->ptid.to_string ().c_str (),
 	     errno ? safe_strerror (errno) : "OK");
 
 	  return stop_wait_callback (lp);
@@ -2500,7 +2500,7 @@ stop_wait_callback (struct lwp_info *lp)
 
 	  linux_nat_debug_printf ("Pending event %s in %s",
 				  status_to_str ((int) status).c_str (),
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 
 	  /* Save the sigtrap event.  */
 	  lp->status = status;
@@ -2512,7 +2512,7 @@ stop_wait_callback (struct lwp_info *lp)
 	  /* We caught the SIGSTOP that we intended to catch.  */
 
 	  linux_nat_debug_printf ("Expected SIGSTOP caught for %s.",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 
 	  lp->signalled = 0;
 
@@ -2557,7 +2557,7 @@ status_callback (struct lwp_info *lp)
       if (pc != lp->stop_pc)
 	{
 	  linux_nat_debug_printf ("PC of %s changed.  was=%s, now=%s",
-				  target_pid_to_str (lp->ptid).c_str (),
+				  lp->ptid.to_string ().c_str (),
 				  paddress (target_gdbarch (), lp->stop_pc),
 				  paddress (target_gdbarch (), pc));
 	  discard = 1;
@@ -2567,7 +2567,7 @@ status_callback (struct lwp_info *lp)
       else if (!breakpoint_inserted_here_p (regcache->aspace (), pc))
 	{
 	  linux_nat_debug_printf ("previous breakpoint of %s, at %s gone",
-				  target_pid_to_str (lp->ptid).c_str (),
+				  lp->ptid.to_string ().c_str (),
 				  paddress (target_gdbarch (), lp->stop_pc));
 
 	  discard = 1;
@@ -2577,7 +2577,7 @@ status_callback (struct lwp_info *lp)
       if (discard)
 	{
 	  linux_nat_debug_printf ("pending event of %s cancelled.",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 
 	  lp->status = 0;
 	  linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
@@ -2701,7 +2701,7 @@ save_stop_reason (struct lwp_info *lp)
 	  else if (siginfo.si_code == TRAP_TRACE)
 	    {
 	      linux_nat_debug_printf ("%s stopped by trace",
-				      target_pid_to_str (lp->ptid).c_str ());
+				      lp->ptid.to_string ().c_str ());
 
 	      /* We may have single stepped an instruction that
 		 triggered a watchpoint.  In that case, on some
@@ -2732,7 +2732,7 @@ save_stop_reason (struct lwp_info *lp)
   if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
     {
       linux_nat_debug_printf ("%s stopped by software breakpoint",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
 
       /* Back up the PC if necessary.  */
       if (pc != sw_bp_pc)
@@ -2744,12 +2744,12 @@ save_stop_reason (struct lwp_info *lp)
   else if (lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)
     {
       linux_nat_debug_printf ("%s stopped by hardware breakpoint",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
   else if (lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
     {
       linux_nat_debug_printf ("%s stopped by hardware watchpoint",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
 
   lp->stop_pc = pc;
@@ -2824,7 +2824,7 @@ select_event_lwp (ptid_t filter, struct lwp_info **orig_lp, int *status)
       if (event_lp != NULL)
 	{
 	  linux_nat_debug_printf ("Select single-step %s",
-				  target_pid_to_str (event_lp->ptid).c_str ());
+				  event_lp->ptid.to_string ().c_str ());
 	}
     }
 
@@ -2978,7 +2978,7 @@ linux_nat_filter_event (int lwpid, int status)
 	  && num_lwps (lp->ptid.pid ()) > 1)
 	{
 	  linux_nat_debug_printf ("%s exited.",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 
 	  /* If there is at least one more LWP, then the exit signal
 	     was not the end of the debugged application and should be
@@ -3013,7 +3013,7 @@ linux_nat_filter_event (int lwpid, int status)
       if (lp->last_resume_kind == resume_stop)
 	{
 	  linux_nat_debug_printf ("resume_stop SIGSTOP caught for %s.",
-				  target_pid_to_str (lp->ptid).c_str ());
+				  lp->ptid.to_string ().c_str ());
 	}
       else
 	{
@@ -3022,7 +3022,7 @@ linux_nat_filter_event (int lwpid, int status)
 	  linux_nat_debug_printf
 	    ("%s %s, 0, 0 (discard delayed SIGSTOP)",
 	     lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-	     target_pid_to_str (lp->ptid).c_str ());
+	     lp->ptid.to_string ().c_str ());
 
 	  linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
 	  gdb_assert (lp->resumed);
@@ -3036,7 +3036,7 @@ linux_nat_filter_event (int lwpid, int status)
       && WIFSTOPPED (status) && WSTOPSIG (status) == SIGINT)
     {
       linux_nat_debug_printf ("Delayed SIGINT caught for %s.",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
 
       /* This is a delayed SIGINT.  */
       lp->ignore_sigint = 0;
@@ -3044,7 +3044,7 @@ linux_nat_filter_event (int lwpid, int status)
       linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
       linux_nat_debug_printf ("%s %s, 0, 0 (discard SIGINT)",
 			      lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
       gdb_assert (lp->resumed);
 
       /* Discard the event.  */
@@ -3094,7 +3094,7 @@ linux_nat_filter_event (int lwpid, int status)
 	  linux_nat_debug_printf
 	    ("%s %s, %s (preempt 'handle')",
 	     lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-	     target_pid_to_str (lp->ptid).c_str (),
+	     lp->ptid.to_string ().c_str (),
 	     (signo != GDB_SIGNAL_0
 	      ? strsignal (gdb_signal_to_host (signo)) : "0"));
 	  return;
@@ -3212,7 +3212,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
     {
       linux_nat_debug_printf ("Using pending wait status %s for %s.",
 			      status_to_str (lp->status).c_str (),
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
 
   /* But if we don't find a pending event, we'll have to wait.  Always
@@ -3364,7 +3364,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
   if (linux_target->low_status_is_event (status))
     {
       linux_nat_debug_printf ("trap ptid is %s.",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
 
   if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE)
@@ -3410,17 +3410,17 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
   if (!lp->stopped)
     {
       linux_nat_debug_printf ("NOT resuming LWP %s, not stopped",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
   else if (!lp->resumed)
     {
       linux_nat_debug_printf ("NOT resuming LWP %s, not resumed",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
   else if (lwp_status_pending_p (lp))
     {
       linux_nat_debug_printf ("NOT resuming LWP %s, has pending status",
-			      target_pid_to_str (lp->ptid).c_str ());
+			      lp->ptid.to_string ().c_str ());
     }
   else
     {
@@ -3444,7 +3444,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
 	    {
 	      linux_nat_debug_printf
 		("resuming stopped-resumed LWP %s at %s: step=%d",
-		 target_pid_to_str (lp->ptid).c_str (), paddress (gdbarch, pc),
+		 lp->ptid.to_string ().c_str (), paddress (gdbarch, pc),
 		 lp->step);
 
 	      linux_resume_one_lwp_throw (lp, lp->step, GDB_SIGNAL_0);
@@ -3466,7 +3466,7 @@ linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 {
   ptid_t event_ptid;
 
-  linux_nat_debug_printf ("[%s], [%s]", target_pid_to_str (ptid).c_str (),
+  linux_nat_debug_printf ("[%s], [%s]", ptid.to_string ().c_str (),
 			  target_options_to_string (target_options).c_str ());
 
   /* Flush the async file first.  */
@@ -4295,7 +4295,7 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
   if (!lwp->stopped)
     {
       linux_nat_debug_printf ("running -> suspending %s",
-			      target_pid_to_str (lwp->ptid).c_str ());
+			      lwp->ptid.to_string ().c_str ());
 
 
       if (lwp->last_resume_kind == resume_stop)
@@ -4316,10 +4316,10 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
 	{
 	  if (find_thread_ptid (linux_target, lwp->ptid)->stop_requested)
 	    linux_nat_debug_printf ("already stopped/stop_requested %s",
-				    target_pid_to_str (lwp->ptid).c_str ());
+				    lwp->ptid.to_string ().c_str ());
 	  else
 	    linux_nat_debug_printf ("already stopped/no stop_requested yet %s",
-				    target_pid_to_str (lwp->ptid).c_str ());
+				    lwp->ptid.to_string ().c_str ());
 	}
     }
   return 0;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index c659d68e4441..c594372e6626 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1962,7 +1962,7 @@ record_btrace_resume_thread (struct thread_info *tp,
   struct btrace_thread_info *btinfo;
 
   DEBUG ("resuming thread %s (%s): %x (%s)", print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str (), flag,
+	 tp->ptid.to_string ().c_str (), flag,
 	 btrace_thread_flag_to_str (flag));
 
   btinfo = &tp->btrace;
@@ -2125,7 +2125,7 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 {
   enum btrace_thread_flag flag, cflag;
 
-  DEBUG ("resume %s: %s%s", target_pid_to_str (ptid).c_str (),
+  DEBUG ("resume %s: %s%s", ptid.to_string ().c_str (),
 	 ::execution_direction == EXEC_REVERSE ? "reverse-" : "",
 	 step ? "step" : "cont");
 
@@ -2205,7 +2205,7 @@ record_btrace_cancel_resume (struct thread_info *tp)
 
   DEBUG ("cancel resume thread %s (%s): %x (%s)",
 	 print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str (), flags.raw (),
+	 tp->ptid.to_string ().c_str (), flags.raw (),
 	 btrace_thread_flag_to_str (flags));
 
   tp->btrace.flags &= ~(BTHR_MOVE | BTHR_STOP);
@@ -2431,7 +2431,7 @@ record_btrace_step_thread (struct thread_info *tp)
   btinfo->flags &= ~(BTHR_MOVE | BTHR_STOP);
 
   DEBUG ("stepping thread %s (%s): %x (%s)", print_thread_id (tp),
-	 target_pid_to_str (tp->ptid).c_str (), flags.raw (),
+	 tp->ptid.to_string ().c_str (), flags.raw (),
 	 btrace_thread_flag_to_str (flags));
 
   /* We can't step without an execution history.  */
@@ -2519,7 +2519,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
   /* Clear this, if needed we'll re-mark it below.  */
   clear_async_event_handler (record_btrace_async_inferior_event_handler);
 
-  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (),
+  DEBUG ("wait %s (0x%x)", ptid.to_string ().c_str (),
 	 (unsigned) options);
 
   /* As long as we're not replaying, just forward the request.  */
@@ -2539,7 +2539,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
     {
       *status = btrace_step_no_resumed ();
 
-      DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid).c_str (),
+      DEBUG ("wait ended by %s: %s", null_ptid.to_string ().c_str (),
 	     status->to_string ().c_str ());
 
       return null_ptid;
@@ -2630,7 +2630,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
 
   DEBUG ("wait ended by thread %s (%s): %s",
 	 print_thread_id (eventing),
-	 target_pid_to_str (eventing->ptid).c_str (),
+	 eventing->ptid.to_string ().c_str (),
 	 status->to_string ().c_str ());
 
   return eventing->ptid;
@@ -2641,7 +2641,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
 void
 record_btrace_target::stop (ptid_t ptid)
 {
-  DEBUG ("stop %s", target_pid_to_str (ptid).c_str ());
+  DEBUG ("stop %s", ptid.to_string ().c_str ());
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
diff --git a/gdb/remote.c b/gdb/remote.c
index b126532af45d..b093ad866750 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7436,7 +7436,7 @@ remote_target::remote_notif_remove_queued_reply (ptid_t ptid)
   if (notif_debug)
     fprintf_unfiltered (gdb_stdlog,
 			"notif: discard queued event: 'Stop' in %s\n",
-			target_pid_to_str (ptid).c_str ());
+			ptid.to_string ().c_str ());
 
   return result;
 }
@@ -7474,7 +7474,7 @@ remote_target::push_stop_reply (struct stop_reply *new_event)
   if (notif_debug)
     fprintf_unfiltered (gdb_stdlog,
 			"notif: push 'Stop' %s to queue %d\n",
-			target_pid_to_str (new_event->ptid).c_str (),
+			new_event->ptid.to_string ().c_str (),
 			int (rs->stop_reply_queue.size ()));
 
   /* Mark the pending event queue only if async mode is currently enabled.
diff --git a/gdb/thread.c b/gdb/thread.c
index c43f66131453..0f9fbe325bc7 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -424,7 +424,7 @@ void
 global_thread_step_over_chain_enqueue (struct thread_info *tp)
 {
   infrun_debug_printf ("enqueueing thread %s in global step over chain",
-		       target_pid_to_str (tp->ptid).c_str ());
+		       tp->ptid.to_string ().c_str ());
 
   gdb_assert (!thread_is_in_step_over_chain (tp));
   global_thread_step_over_list.push_back (*tp);
@@ -444,7 +444,7 @@ void
 global_thread_step_over_chain_remove (struct thread_info *tp)
 {
   infrun_debug_printf ("removing thread %s from global step over chain",
-		       target_pid_to_str (tp->ptid).c_str ());
+		       tp->ptid.to_string ().c_str ());
 
   gdb_assert (thread_is_in_step_over_chain (tp));
   auto it = global_thread_step_over_list.iterator_to (*tp);

base-commit: f61defbc986e4ed6da99a3cc061e4134552f4a21
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: use ptid_t::to_string instead of target_pid_to_str in debug statements
  2022-01-16  4:45 [PATCH] gdb: use ptid_t::to_string instead of target_pid_to_str in debug statements Simon Marchi
@ 2022-01-18 10:44 ` Andrew Burgess
  2022-01-18 16:29   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2022-01-18 10:44 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

* Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> [2022-01-15 23:45:06 -0500]:

> Same idea as 0fab79556484 ("gdb: use ptid_t::to_string in infrun debug
> messages"), but throughout GDB.

LGTM.

Thanks,
Andrew

> 
> Change-Id: I62ba36eaef29935316d7187b9b13d7b88491acc1
> ---
>  gdb/btrace.c             | 10 ++---
>  gdb/displaced-stepping.c |  4 +-
>  gdb/dummy-frame.c        |  2 +-
>  gdb/gnu-nat.c            | 10 ++---
>  gdb/linux-nat.c          | 92 ++++++++++++++++++++--------------------
>  gdb/record-btrace.c      | 16 +++----
>  gdb/remote.c             |  4 +-
>  gdb/thread.c             |  4 +-
>  8 files changed, 71 insertions(+), 71 deletions(-)
> 
> diff --git a/gdb/btrace.c b/gdb/btrace.c
> index ba10f78e7bf5..dc4d686ac4bc 100644
> --- a/gdb/btrace.c
> +++ b/gdb/btrace.c
> @@ -1616,7 +1616,7 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf)
>  #endif /* !defined (HAVE_LIBIPT) */
>  
>    DEBUG ("enable thread %s (%s)", print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str ());
> +	 tp->ptid.to_string ().c_str ());
>  
>    tp->btrace.target = target_enable_btrace (tp->ptid, conf);
>  
> @@ -1671,7 +1671,7 @@ btrace_disable (struct thread_info *tp)
>  	   print_thread_id (tp), target_pid_to_str (tp->ptid).c_str ());
>  
>    DEBUG ("disable thread %s (%s)", print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str ());
> +	 tp->ptid.to_string ().c_str ());
>  
>    target_disable_btrace (btp->target);
>    btp->target = NULL;
> @@ -1690,7 +1690,7 @@ btrace_teardown (struct thread_info *tp)
>      return;
>  
>    DEBUG ("teardown thread %s (%s)", print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str ());
> +	 tp->ptid.to_string ().c_str ());
>  
>    target_teardown_btrace (btp->target);
>    btp->target = NULL;
> @@ -1912,7 +1912,7 @@ btrace_fetch (struct thread_info *tp, const struct btrace_cpu *cpu)
>    int errcode;
>  
>    DEBUG ("fetch thread %s (%s)", print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str ());
> +	 tp->ptid.to_string ().c_str ());
>  
>    btinfo = &tp->btrace;
>    tinfo = btinfo->target;
> @@ -1989,7 +1989,7 @@ btrace_clear (struct thread_info *tp)
>    struct btrace_thread_info *btinfo;
>  
>    DEBUG ("clear thread %s (%s)", print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str ());
> +	 tp->ptid.to_string ().c_str ());
>  
>    /* Make sure btrace frames that may hold a pointer into the branch
>       trace data are destroyed.  */
> diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c
> index 43fc435305ea..e2afbe42f582 100644
> --- a/gdb/displaced-stepping.c
> +++ b/gdb/displaced-stepping.c
> @@ -232,7 +232,7 @@ displaced_step_buffers::finish (gdbarch *arch, thread_info *thread,
>  		     buffer->saved_copy.data (), len);
>  
>    displaced_debug_printf ("restored %s %s",
> -			  target_pid_to_str (thread->ptid).c_str (),
> +			  thread->ptid.to_string ().c_str (),
>  			  paddress (arch, buffer->addr));
>  
>    regcache *rc = get_thread_regcache (thread);
> @@ -285,7 +285,7 @@ displaced_step_buffers::restore_in_ptid (ptid_t ptid)
>        write_memory_ptid (ptid, buffer.addr, buffer.saved_copy.data (), len);
>  
>        displaced_debug_printf ("restored in ptid %s %s",
> -			      target_pid_to_str (ptid).c_str (),
> +			      ptid.to_string ().c_str (),
>  			      paddress (arch, buffer.addr));
>      }
>  }
> diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
> index 41c0bdeb9455..db7aaacdc5ae 100644
> --- a/gdb/dummy-frame.c
> +++ b/gdb/dummy-frame.c
> @@ -408,7 +408,7 @@ fprint_dummy_frames (struct ui_file *file)
>      fprintf_filtered (file, "%s: id=%s, ptid=%s\n",
>  		      host_address_to_string (s),
>  		      s->id.id.to_string ().c_str (),
> -		      target_pid_to_str (s->id.thread->ptid).c_str ());
> +		      s->id.thread->ptid.to_string ().c_str ());
>  }
>  
>  static void
> diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
> index 9c53e3c0c2f4..1586a738dee2 100644
> --- a/gdb/gnu-nat.c
> +++ b/gdb/gnu-nat.c
> @@ -1463,7 +1463,7 @@ gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
>  
>    waiting_inf = inf;
>  
> -  inf_debug (inf, "waiting for: %s", target_pid_to_str (ptid).c_str ());
> +  inf_debug (inf, "waiting for: %s", ptid.to_string ().c_str ());
>  
>  rewait:
>    if (proc_wait_pid != inf->pid && !inf->no_wait)
> @@ -1621,7 +1621,7 @@ gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
>      }
>  
>    inf_debug (inf, "returning ptid = %s, %s",
> -	     target_pid_to_str (ptid).c_str (),
> +	     ptid.to_string ().c_str (),
>  	     status->to_string ().c_str ());
>  
>    return ptid;
> @@ -1973,7 +1973,7 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
>    struct inf *inf = gnu_current_inf;
>  
>    inf_debug (inf, "ptid = %s, step = %d, sig = %d",
> -	     target_pid_to_str (ptid).c_str (), step, sig);
> +	     ptid.to_string ().c_str (), step, sig);
>  
>    inf_validate_procinfo (inf);
>  
> @@ -2021,7 +2021,7 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
>  	error (_("Can't run single thread id %s: no such thread!"),
>  	       target_pid_to_str (ptid).c_str ());
>        inf_debug (inf, "running one thread: %s",
> -		 target_pid_to_str (ptid).c_str ());
> +		 ptid.to_string ().c_str ());
>        inf_set_threads_resume_sc (inf, thread, 0);
>      }
>  
> @@ -2033,7 +2033,7 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
>  		 target_pid_to_str (ptid).c_str ());
>        else
>  	inf_debug (inf, "stepping thread: %s",
> -		   target_pid_to_str (ptid).c_str ());
> +		   ptid.to_string ().c_str ());
>      }
>    if (step_thread != inf->step_thread)
>      inf_set_step_thread (inf, step_thread);
> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
> index b926fb5eba9e..0cc6923ad023 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -1123,7 +1123,7 @@ attach_proc_task_lwp_callback (ptid_t ptid)
>        else
>  	{
>  	  linux_nat_debug_printf ("PTRACE_ATTACH %s, 0, 0 (OK)",
> -				  target_pid_to_str (ptid).c_str ());
> +				  ptid.to_string ().c_str ());
>  
>  	  lp = add_lwp (ptid);
>  
> @@ -1356,18 +1356,18 @@ get_detach_signal (struct lwp_info *lp)
>    if (signo == GDB_SIGNAL_0)
>      {
>        linux_nat_debug_printf ("lwp %s has no pending signal",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>    else if (!signal_pass_state (signo))
>      {
>        linux_nat_debug_printf
>  	("lwp %s had signal %s but it is in no pass state",
> -	 target_pid_to_str (lp->ptid).c_str (), gdb_signal_to_string (signo));
> +	 lp->ptid.to_string ().c_str (), gdb_signal_to_string (signo));
>      }
>    else
>      {
>        linux_nat_debug_printf ("lwp %s has pending signal %s",
> -			      target_pid_to_str (lp->ptid).c_str (),
> +			      lp->ptid.to_string ().c_str (),
>  			      gdb_signal_to_string (signo));
>  
>        return gdb_signal_to_host (signo);
> @@ -1433,13 +1433,13 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
>    if (lp->status != 0)
>      linux_nat_debug_printf ("Pending %s for %s on detach.",
>  			    strsignal (WSTOPSIG (lp->status)),
> -			    target_pid_to_str (lp->ptid).c_str ());
> +			    lp->ptid.to_string ().c_str ());
>  
>    /* If there is a pending SIGSTOP, get rid of it.  */
>    if (lp->signalled)
>      {
>        linux_nat_debug_printf ("Sending SIGCONT to %s",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>  
>        kill_lwp (lwpid, SIGCONT);
>        lp->signalled = 0;
> @@ -1630,12 +1630,12 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
>        if (inf->vfork_child != NULL)
>  	{
>  	  linux_nat_debug_printf ("Not resuming %s (vfork parent)",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  	}
>        else if (!lwp_status_pending_p (lp))
>  	{
>  	  linux_nat_debug_printf ("Resuming sibling %s, %s, %s",
> -				  target_pid_to_str (lp->ptid).c_str (),
> +				  lp->ptid.to_string ().c_str (),
>  				  (signo != GDB_SIGNAL_0
>  				   ? strsignal (gdb_signal_to_host (signo))
>  				   : "0"),
> @@ -1646,12 +1646,12 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
>        else
>  	{
>  	  linux_nat_debug_printf ("Not resuming sibling %s (has pending)",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  	}
>      }
>    else
>      linux_nat_debug_printf ("Not resuming sibling %s (not stopped)",
> -			    target_pid_to_str (lp->ptid).c_str ());
> +			    lp->ptid.to_string ().c_str ());
>  }
>  
>  /* Callback for iterate_over_lwps.  If LWP is EXCEPT, do nothing.
> @@ -1705,10 +1705,10 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
>  
>    linux_nat_debug_printf ("Preparing to %s %s, %s, inferior_ptid %s",
>  			  step ? "step" : "resume",
> -			  target_pid_to_str (ptid).c_str (),
> +			  ptid.to_string ().c_str (),
>  			  (signo != GDB_SIGNAL_0
>  			   ? strsignal (gdb_signal_to_host (signo)) : "0"),
> -			  target_pid_to_str (inferior_ptid).c_str ());
> +			  inferior_ptid.to_string ().c_str ());
>  
>    /* A specific PTID means `step only this process id'.  */
>    resume_many = (minus_one_ptid == ptid
> @@ -1780,7 +1780,7 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
>  
>    linux_nat_debug_printf ("%s %s, %s (resume event thread)",
>  			  step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
> -			  target_pid_to_str (lp->ptid).c_str (),
> +			  lp->ptid.to_string ().c_str (),
>  			  (signo != GDB_SIGNAL_0
>  			   ? strsignal (gdb_signal_to_host (signo)) : "0"));
>  
> @@ -2167,7 +2167,7 @@ wait_lwp (struct lwp_info *lp)
>  	     the top of the file.  */
>  	  thread_dead = 1;
>  	  linux_nat_debug_printf ("%s vanished.",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  	}
>        if (pid != 0)
>  	break;
> @@ -2191,7 +2191,7 @@ wait_lwp (struct lwp_info *lp)
>  	{
>  	  thread_dead = 1;
>  	  linux_nat_debug_printf ("Thread group leader %s vanished.",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  	  break;
>  	}
>  
> @@ -2211,7 +2211,7 @@ wait_lwp (struct lwp_info *lp)
>        gdb_assert (pid == lp->ptid.lwp ());
>  
>        linux_nat_debug_printf ("waitpid %s received %s",
> -			      target_pid_to_str (lp->ptid).c_str (),
> +			      lp->ptid.to_string ().c_str (),
>  			      status_to_str (status).c_str ());
>  
>        /* Check if the thread has exited.  */
> @@ -2232,7 +2232,7 @@ wait_lwp (struct lwp_info *lp)
>  
>  	  thread_dead = 1;
>  	  linux_nat_debug_printf ("%s exited.",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  	}
>      }
>  
> @@ -2294,7 +2294,7 @@ stop_callback (struct lwp_info *lp)
>        int ret;
>  
>        linux_nat_debug_printf ("kill %s **<SIGSTOP>**",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>  
>        errno = 0;
>        ret = kill_lwp (lp->ptid.lwp (), SIGSTOP);
> @@ -2388,7 +2388,7 @@ maybe_clear_ignore_sigint (struct lwp_info *lp)
>    if (!linux_nat_has_pending_sigint (lp->ptid.lwp ()))
>      {
>        linux_nat_debug_printf ("Clearing bogus flag for %s",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>        lp->ignore_sigint = 0;
>      }
>  }
> @@ -2486,7 +2486,7 @@ stop_wait_callback (struct lwp_info *lp)
>  	  lp->stopped = 0;
>  	  linux_nat_debug_printf
>  	    ("PTRACE_CONT %s, 0, 0 (%s) (discarding SIGINT)",
> -	     target_pid_to_str (lp->ptid).c_str (),
> +	     lp->ptid.to_string ().c_str (),
>  	     errno ? safe_strerror (errno) : "OK");
>  
>  	  return stop_wait_callback (lp);
> @@ -2500,7 +2500,7 @@ stop_wait_callback (struct lwp_info *lp)
>  
>  	  linux_nat_debug_printf ("Pending event %s in %s",
>  				  status_to_str ((int) status).c_str (),
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  
>  	  /* Save the sigtrap event.  */
>  	  lp->status = status;
> @@ -2512,7 +2512,7 @@ stop_wait_callback (struct lwp_info *lp)
>  	  /* We caught the SIGSTOP that we intended to catch.  */
>  
>  	  linux_nat_debug_printf ("Expected SIGSTOP caught for %s.",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  
>  	  lp->signalled = 0;
>  
> @@ -2557,7 +2557,7 @@ status_callback (struct lwp_info *lp)
>        if (pc != lp->stop_pc)
>  	{
>  	  linux_nat_debug_printf ("PC of %s changed.  was=%s, now=%s",
> -				  target_pid_to_str (lp->ptid).c_str (),
> +				  lp->ptid.to_string ().c_str (),
>  				  paddress (target_gdbarch (), lp->stop_pc),
>  				  paddress (target_gdbarch (), pc));
>  	  discard = 1;
> @@ -2567,7 +2567,7 @@ status_callback (struct lwp_info *lp)
>        else if (!breakpoint_inserted_here_p (regcache->aspace (), pc))
>  	{
>  	  linux_nat_debug_printf ("previous breakpoint of %s, at %s gone",
> -				  target_pid_to_str (lp->ptid).c_str (),
> +				  lp->ptid.to_string ().c_str (),
>  				  paddress (target_gdbarch (), lp->stop_pc));
>  
>  	  discard = 1;
> @@ -2577,7 +2577,7 @@ status_callback (struct lwp_info *lp)
>        if (discard)
>  	{
>  	  linux_nat_debug_printf ("pending event of %s cancelled.",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  
>  	  lp->status = 0;
>  	  linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
> @@ -2701,7 +2701,7 @@ save_stop_reason (struct lwp_info *lp)
>  	  else if (siginfo.si_code == TRAP_TRACE)
>  	    {
>  	      linux_nat_debug_printf ("%s stopped by trace",
> -				      target_pid_to_str (lp->ptid).c_str ());
> +				      lp->ptid.to_string ().c_str ());
>  
>  	      /* We may have single stepped an instruction that
>  		 triggered a watchpoint.  In that case, on some
> @@ -2732,7 +2732,7 @@ save_stop_reason (struct lwp_info *lp)
>    if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
>      {
>        linux_nat_debug_printf ("%s stopped by software breakpoint",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>  
>        /* Back up the PC if necessary.  */
>        if (pc != sw_bp_pc)
> @@ -2744,12 +2744,12 @@ save_stop_reason (struct lwp_info *lp)
>    else if (lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)
>      {
>        linux_nat_debug_printf ("%s stopped by hardware breakpoint",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>    else if (lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
>      {
>        linux_nat_debug_printf ("%s stopped by hardware watchpoint",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>  
>    lp->stop_pc = pc;
> @@ -2824,7 +2824,7 @@ select_event_lwp (ptid_t filter, struct lwp_info **orig_lp, int *status)
>        if (event_lp != NULL)
>  	{
>  	  linux_nat_debug_printf ("Select single-step %s",
> -				  target_pid_to_str (event_lp->ptid).c_str ());
> +				  event_lp->ptid.to_string ().c_str ());
>  	}
>      }
>  
> @@ -2978,7 +2978,7 @@ linux_nat_filter_event (int lwpid, int status)
>  	  && num_lwps (lp->ptid.pid ()) > 1)
>  	{
>  	  linux_nat_debug_printf ("%s exited.",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  
>  	  /* If there is at least one more LWP, then the exit signal
>  	     was not the end of the debugged application and should be
> @@ -3013,7 +3013,7 @@ linux_nat_filter_event (int lwpid, int status)
>        if (lp->last_resume_kind == resume_stop)
>  	{
>  	  linux_nat_debug_printf ("resume_stop SIGSTOP caught for %s.",
> -				  target_pid_to_str (lp->ptid).c_str ());
> +				  lp->ptid.to_string ().c_str ());
>  	}
>        else
>  	{
> @@ -3022,7 +3022,7 @@ linux_nat_filter_event (int lwpid, int status)
>  	  linux_nat_debug_printf
>  	    ("%s %s, 0, 0 (discard delayed SIGSTOP)",
>  	     lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
> -	     target_pid_to_str (lp->ptid).c_str ());
> +	     lp->ptid.to_string ().c_str ());
>  
>  	  linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
>  	  gdb_assert (lp->resumed);
> @@ -3036,7 +3036,7 @@ linux_nat_filter_event (int lwpid, int status)
>        && WIFSTOPPED (status) && WSTOPSIG (status) == SIGINT)
>      {
>        linux_nat_debug_printf ("Delayed SIGINT caught for %s.",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>  
>        /* This is a delayed SIGINT.  */
>        lp->ignore_sigint = 0;
> @@ -3044,7 +3044,7 @@ linux_nat_filter_event (int lwpid, int status)
>        linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
>        linux_nat_debug_printf ("%s %s, 0, 0 (discard SIGINT)",
>  			      lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>        gdb_assert (lp->resumed);
>  
>        /* Discard the event.  */
> @@ -3094,7 +3094,7 @@ linux_nat_filter_event (int lwpid, int status)
>  	  linux_nat_debug_printf
>  	    ("%s %s, %s (preempt 'handle')",
>  	     lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
> -	     target_pid_to_str (lp->ptid).c_str (),
> +	     lp->ptid.to_string ().c_str (),
>  	     (signo != GDB_SIGNAL_0
>  	      ? strsignal (gdb_signal_to_host (signo)) : "0"));
>  	  return;
> @@ -3212,7 +3212,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
>      {
>        linux_nat_debug_printf ("Using pending wait status %s for %s.",
>  			      status_to_str (lp->status).c_str (),
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>  
>    /* But if we don't find a pending event, we'll have to wait.  Always
> @@ -3364,7 +3364,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
>    if (linux_target->low_status_is_event (status))
>      {
>        linux_nat_debug_printf ("trap ptid is %s.",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>  
>    if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE)
> @@ -3410,17 +3410,17 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
>    if (!lp->stopped)
>      {
>        linux_nat_debug_printf ("NOT resuming LWP %s, not stopped",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>    else if (!lp->resumed)
>      {
>        linux_nat_debug_printf ("NOT resuming LWP %s, not resumed",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>    else if (lwp_status_pending_p (lp))
>      {
>        linux_nat_debug_printf ("NOT resuming LWP %s, has pending status",
> -			      target_pid_to_str (lp->ptid).c_str ());
> +			      lp->ptid.to_string ().c_str ());
>      }
>    else
>      {
> @@ -3444,7 +3444,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
>  	    {
>  	      linux_nat_debug_printf
>  		("resuming stopped-resumed LWP %s at %s: step=%d",
> -		 target_pid_to_str (lp->ptid).c_str (), paddress (gdbarch, pc),
> +		 lp->ptid.to_string ().c_str (), paddress (gdbarch, pc),
>  		 lp->step);
>  
>  	      linux_resume_one_lwp_throw (lp, lp->step, GDB_SIGNAL_0);
> @@ -3466,7 +3466,7 @@ linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
>  {
>    ptid_t event_ptid;
>  
> -  linux_nat_debug_printf ("[%s], [%s]", target_pid_to_str (ptid).c_str (),
> +  linux_nat_debug_printf ("[%s], [%s]", ptid.to_string ().c_str (),
>  			  target_options_to_string (target_options).c_str ());
>  
>    /* Flush the async file first.  */
> @@ -4295,7 +4295,7 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
>    if (!lwp->stopped)
>      {
>        linux_nat_debug_printf ("running -> suspending %s",
> -			      target_pid_to_str (lwp->ptid).c_str ());
> +			      lwp->ptid.to_string ().c_str ());
>  
>  
>        if (lwp->last_resume_kind == resume_stop)
> @@ -4316,10 +4316,10 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
>  	{
>  	  if (find_thread_ptid (linux_target, lwp->ptid)->stop_requested)
>  	    linux_nat_debug_printf ("already stopped/stop_requested %s",
> -				    target_pid_to_str (lwp->ptid).c_str ());
> +				    lwp->ptid.to_string ().c_str ());
>  	  else
>  	    linux_nat_debug_printf ("already stopped/no stop_requested yet %s",
> -				    target_pid_to_str (lwp->ptid).c_str ());
> +				    lwp->ptid.to_string ().c_str ());
>  	}
>      }
>    return 0;
> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
> index c659d68e4441..c594372e6626 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -1962,7 +1962,7 @@ record_btrace_resume_thread (struct thread_info *tp,
>    struct btrace_thread_info *btinfo;
>  
>    DEBUG ("resuming thread %s (%s): %x (%s)", print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str (), flag,
> +	 tp->ptid.to_string ().c_str (), flag,
>  	 btrace_thread_flag_to_str (flag));
>  
>    btinfo = &tp->btrace;
> @@ -2125,7 +2125,7 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
>  {
>    enum btrace_thread_flag flag, cflag;
>  
> -  DEBUG ("resume %s: %s%s", target_pid_to_str (ptid).c_str (),
> +  DEBUG ("resume %s: %s%s", ptid.to_string ().c_str (),
>  	 ::execution_direction == EXEC_REVERSE ? "reverse-" : "",
>  	 step ? "step" : "cont");
>  
> @@ -2205,7 +2205,7 @@ record_btrace_cancel_resume (struct thread_info *tp)
>  
>    DEBUG ("cancel resume thread %s (%s): %x (%s)",
>  	 print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str (), flags.raw (),
> +	 tp->ptid.to_string ().c_str (), flags.raw (),
>  	 btrace_thread_flag_to_str (flags));
>  
>    tp->btrace.flags &= ~(BTHR_MOVE | BTHR_STOP);
> @@ -2431,7 +2431,7 @@ record_btrace_step_thread (struct thread_info *tp)
>    btinfo->flags &= ~(BTHR_MOVE | BTHR_STOP);
>  
>    DEBUG ("stepping thread %s (%s): %x (%s)", print_thread_id (tp),
> -	 target_pid_to_str (tp->ptid).c_str (), flags.raw (),
> +	 tp->ptid.to_string ().c_str (), flags.raw (),
>  	 btrace_thread_flag_to_str (flags));
>  
>    /* We can't step without an execution history.  */
> @@ -2519,7 +2519,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
>    /* Clear this, if needed we'll re-mark it below.  */
>    clear_async_event_handler (record_btrace_async_inferior_event_handler);
>  
> -  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (),
> +  DEBUG ("wait %s (0x%x)", ptid.to_string ().c_str (),
>  	 (unsigned) options);
>  
>    /* As long as we're not replaying, just forward the request.  */
> @@ -2539,7 +2539,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
>      {
>        *status = btrace_step_no_resumed ();
>  
> -      DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid).c_str (),
> +      DEBUG ("wait ended by %s: %s", null_ptid.to_string ().c_str (),
>  	     status->to_string ().c_str ());
>  
>        return null_ptid;
> @@ -2630,7 +2630,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
>  
>    DEBUG ("wait ended by thread %s (%s): %s",
>  	 print_thread_id (eventing),
> -	 target_pid_to_str (eventing->ptid).c_str (),
> +	 eventing->ptid.to_string ().c_str (),
>  	 status->to_string ().c_str ());
>  
>    return eventing->ptid;
> @@ -2641,7 +2641,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
>  void
>  record_btrace_target::stop (ptid_t ptid)
>  {
> -  DEBUG ("stop %s", target_pid_to_str (ptid).c_str ());
> +  DEBUG ("stop %s", ptid.to_string ().c_str ());
>  
>    /* As long as we're not replaying, just forward the request.  */
>    if ((::execution_direction != EXEC_REVERSE)
> diff --git a/gdb/remote.c b/gdb/remote.c
> index b126532af45d..b093ad866750 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -7436,7 +7436,7 @@ remote_target::remote_notif_remove_queued_reply (ptid_t ptid)
>    if (notif_debug)
>      fprintf_unfiltered (gdb_stdlog,
>  			"notif: discard queued event: 'Stop' in %s\n",
> -			target_pid_to_str (ptid).c_str ());
> +			ptid.to_string ().c_str ());
>  
>    return result;
>  }
> @@ -7474,7 +7474,7 @@ remote_target::push_stop_reply (struct stop_reply *new_event)
>    if (notif_debug)
>      fprintf_unfiltered (gdb_stdlog,
>  			"notif: push 'Stop' %s to queue %d\n",
> -			target_pid_to_str (new_event->ptid).c_str (),
> +			new_event->ptid.to_string ().c_str (),
>  			int (rs->stop_reply_queue.size ()));
>  
>    /* Mark the pending event queue only if async mode is currently enabled.
> diff --git a/gdb/thread.c b/gdb/thread.c
> index c43f66131453..0f9fbe325bc7 100644
> --- a/gdb/thread.c
> +++ b/gdb/thread.c
> @@ -424,7 +424,7 @@ void
>  global_thread_step_over_chain_enqueue (struct thread_info *tp)
>  {
>    infrun_debug_printf ("enqueueing thread %s in global step over chain",
> -		       target_pid_to_str (tp->ptid).c_str ());
> +		       tp->ptid.to_string ().c_str ());
>  
>    gdb_assert (!thread_is_in_step_over_chain (tp));
>    global_thread_step_over_list.push_back (*tp);
> @@ -444,7 +444,7 @@ void
>  global_thread_step_over_chain_remove (struct thread_info *tp)
>  {
>    infrun_debug_printf ("removing thread %s from global step over chain",
> -		       target_pid_to_str (tp->ptid).c_str ());
> +		       tp->ptid.to_string ().c_str ());
>  
>    gdb_assert (thread_is_in_step_over_chain (tp));
>    auto it = global_thread_step_over_list.iterator_to (*tp);
> 
> base-commit: f61defbc986e4ed6da99a3cc061e4134552f4a21
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: use ptid_t::to_string instead of target_pid_to_str in debug statements
  2022-01-18 10:44 ` Andrew Burgess
@ 2022-01-18 16:29   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2022-01-18 16:29 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches



On 2022-01-18 05:44, Andrew Burgess wrote:
> * Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> [2022-01-15 23:45:06 -0500]:
> 
>> Same idea as 0fab79556484 ("gdb: use ptid_t::to_string in infrun debug
>> messages"), but throughout GDB.
> 
> LGTM.
> 
> Thanks,
> Andrew

Pushed, thanks.

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-18 16:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-16  4:45 [PATCH] gdb: use ptid_t::to_string instead of target_pid_to_str in debug statements Simon Marchi
2022-01-18 10:44 ` Andrew Burgess
2022-01-18 16:29   ` Simon Marchi

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