]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change pid_to_str to return std::string
authorTom Tromey <tromey@adacore.com>
Thu, 28 Feb 2019 16:09:55 +0000 (09:09 -0700)
committerTom Tromey <tromey@adacore.com>
Wed, 13 Mar 2019 19:50:13 +0000 (13:50 -0600)
Currently the target pid_to_str method returns a const char *, so many
implementations have a static buffer that they update.  This patch
changes these methods to return a std::string instead.  I think this
is cleaner and avoids possible gotchas when calling pid_to_str on
different ptids in a single statement.  (Though no such calls exist
currently.)

This also updates various helper functions, and the gdbarch pid_to_str
methods.

I also made a best effort to fix all the callers, but I can't build
some of the *-nat.c files.

Tested by the buildbot.

gdb/ChangeLog
2019-03-13  Tom Tromey  <tromey@adacore.com>

* i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers)
(i386_gnu_nat_target::store_registers): Update.
* target-debug.h (target_debug_print_std_string): New macro.
* x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update.
* windows-tdep.c (display_one_tib): Update.
* tui/tui-stack.c (tui_make_status_line): Update.
* top.c (print_inferior_quit_action): Update.
* thread.c (thr_try_catch_cmd): Update.
(add_thread_with_info): Update.
(thread_target_id_str): Update.
(thr_try_catch_cmd): Update.
(thread_command): Update.
(thread_find_command): Update.
* record-btrace.c (record_btrace_target::info_record)
(record_btrace_resume_thread, record_btrace_target::resume)
(record_btrace_cancel_resume, record_btrace_step_thread)
(record_btrace_target::wait, record_btrace_target::wait)
(record_btrace_target::wait, record_btrace_target::stop): Update.
* progspace.c (print_program_space): Update.
* process-stratum-target.c
(process_stratum_target::thread_address_space): Update.
* linux-fork.c (linux_fork_mourn_inferior)
(detach_checkpoint_command, info_checkpoints_command)
(linux_fork_context): Update.
(linux_fork_detach): Update.
(class scoped_switch_fork_info): Update.
(delete_checkpoint_command): Update.
* infrun.c (follow_fork_inferior): Update.
(follow_fork_inferior): Update.
(proceed_after_vfork_done): Update.
(handle_vfork_child_exec_or_exit): Update.
(follow_exec): Update.
(displaced_step_prepare_throw): Update.
(displaced_step_restore): Update.
(start_step_over): Update.
(resume_1): Update.
(clear_proceed_status_thread): Update.
(proceed): Update.
(print_target_wait_results): Update.
(do_target_wait): Update.
(context_switch): Update.
(stop_all_threads): Update.
(restart_threads): Update.
(finish_step_over): Update.
(handle_signal_stop): Update.
(switch_back_to_stepped_thread): Update.
(keep_going_pass_signal): Update.
(print_exited_reason): Update.
(normal_stop): Update.
* inferior.c (inferior_pid_to_str): Change return type.
(print_selected_inferior): Update.
(add_inferior): Update.
(detach_inferior): Update.
* dummy-frame.c (fprint_dummy_frames): Update.
* dcache.c (dcache_info_1): Update.
* btrace.c (btrace_enable, btrace_disable, btrace_teardown)
(btrace_fetch, btrace_clear): Update.
* linux-tdep.c (linux_core_pid_to_str): Change return type.
* i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return
type.
* fbsd-tdep.c (fbsd_core_pid_to_str): Change return type.
* sol2-tdep.h (sol2_core_pid_to_str): Change return type.
* sol2-tdep.c (sol2_core_pid_to_str): Change return type.
* gdbarch.c, gdbarch.h: Rebuild.
* gdbarch.sh (core_pid_to_str): Change return type.
* windows-nat.c (struct windows_nat_target) <pid_to_str>: Change
return type.
(windows_nat_target::pid_to_str): Change return type.
(windows_delete_thread): Update.
(windows_nat_target::attach): Update.
(windows_nat_target::files_info): Update.
* target-delegates.c: Rebuild.
* sol-thread.c (class sol_thread_target) <pid_to_str>: Change
return type.
(sol_thread_target::pid_to_str): Change return type.
* remote.c (class remote_target) <pid_to_str>: Change return
type.
(remote_target::pid_to_str): Change return type.
(extended_remote_target::attach, remote_target::remote_stop_ns)
(remote_target::remote_notif_remove_queued_reply)
(remote_target::push_stop_reply, remote_target::disable_btrace):
Update.
(extended_remote_target::attach): Update.
* remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return
type.
(gdbsim_target::pid_to_str): Change return type.
* ravenscar-thread.c (struct ravenscar_thread_target)
<pid_to_str>: Change return type.
(ravenscar_thread_target::pid_to_str): Change return type.
* procfs.c (class procfs_target) <pid_to_str>: Change return
type.
(procfs_target::pid_to_str): Change return type.
(procfs_target::attach): Update.
(procfs_target::detach): Update.
(procfs_target::fetch_registers): Update.
(procfs_target::store_registers): Update.
(procfs_target::wait): Update.
(procfs_target::files_info): Update.
* obsd-nat.c (obsd_nat_target::pid_to_str): Change return type.
* nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change
return type.
(nto_procfs_target::pid_to_str): Change return type.
(nto_procfs_target::files_info, nto_procfs_target::attach): Update.
* linux-thread-db.c (class thread_db_target) <pid_to_str>: Change
return type.
* linux-nat.c (linux_nat_target::pid_to_str): Change return type.
(exit_lwp): Update.
(attach_proc_task_lwp_callback, get_detach_signal)
(detach_one_lwp, resume_lwp, linux_nat_target::resume)
(linux_nat_target::resume, wait_lwp, stop_callback)
(maybe_clear_ignore_sigint, stop_wait_callback, status_callback)
(save_stop_reason, select_event_lwp, linux_nat_filter_event)
(linux_nat_wait_1, resume_stopped_resumed_lwps)
(linux_nat_target::wait, linux_nat_stop_lwp): Update.
* inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return
type.
(inf_ptrace_target::attach): Update.
(inf_ptrace_target::files_info): Update.
* go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return
type.
(go32_nat_target::pid_to_str): Change return type.
* gnu-nat.c (gnu_nat_target::pid_to_str): Change return type.
(gnu_nat_target::wait): Update.
(gnu_nat_target::wait): Update.
(gnu_nat_target::resume): Update.
* fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type.
(fbsd_nat_target::wait): Update.
* darwin-nat.c (darwin_nat_target::pid_to_str): Change return
type.
(darwin_nat_target::attach): Update.
* corelow.c (class core_target) <pid_to_str>: Change return type.
(core_target::pid_to_str): Change return type.
* target.c (normal_pid_to_str): Change return type.
(default_pid_to_str): Likewise.
(target_pid_to_str): Change return type.
(target_translate_tls_address): Update.
(target_announce_detach): Update.
* bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change
return type.
(bsd_uthread_target::pid_to_str): Change return type.
* bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return
type.
(bsd_kvm_target::pid_to_str): Change return type.
* aix-thread.c (class aix_thread_target) <pid_to_str>: Change
return type.
(aix_thread_target::pid_to_str): Change return type.
* target.h (struct target_ops) <pid_to_str>: Change return type.
(target_pid_to_str, normal_pid_to_str): Likewise.
* obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return
type.
* linux-nat.h (class linux_nat_target) <pid_to_str>: Change return
type.
* inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change
return type.
* gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return
type.
* fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return
type.
* darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change
return type.

53 files changed:
gdb/ChangeLog
gdb/aix-thread.c
gdb/bsd-kvm.c
gdb/bsd-uthread.c
gdb/btrace.c
gdb/corelow.c
gdb/darwin-nat.c
gdb/darwin-nat.h
gdb/dcache.c
gdb/dummy-frame.c
gdb/fbsd-nat.c
gdb/fbsd-nat.h
gdb/fbsd-tdep.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/gnu-nat.c
gdb/gnu-nat.h
gdb/go32-nat.c
gdb/i386-cygwin-tdep.c
gdb/i386-gnu-nat.c
gdb/inf-ptrace.c
gdb/inf-ptrace.h
gdb/inferior.c
gdb/infrun.c
gdb/linux-fork.c
gdb/linux-nat.c
gdb/linux-nat.h
gdb/linux-tdep.c
gdb/linux-thread-db.c
gdb/nto-procfs.c
gdb/obsd-nat.c
gdb/obsd-nat.h
gdb/process-stratum-target.c
gdb/procfs.c
gdb/progspace.c
gdb/ravenscar-thread.c
gdb/record-btrace.c
gdb/remote-sim.c
gdb/remote.c
gdb/sol-thread.c
gdb/sol2-tdep.c
gdb/sol2-tdep.h
gdb/target-debug.h
gdb/target-delegates.c
gdb/target.c
gdb/target.h
gdb/thread.c
gdb/top.c
gdb/tui/tui-stack.c
gdb/windows-nat.c
gdb/windows-tdep.c
gdb/x86-linux-nat.c

index 85bf5a96bab238d9973b65dcabb16ca8b2fadfd3..24de651bf92838b7a0f3fb10286f2a10f99cbc92 100644 (file)
@@ -1,3 +1,166 @@
+2019-03-13  Tom Tromey  <tromey@adacore.com>
+
+       * i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers)
+       (i386_gnu_nat_target::store_registers): Update.
+       * target-debug.h (target_debug_print_std_string): New macro.
+       * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update.
+       * windows-tdep.c (display_one_tib): Update.
+       * tui/tui-stack.c (tui_make_status_line): Update.
+       * top.c (print_inferior_quit_action): Update.
+       * thread.c (thr_try_catch_cmd): Update.
+       (add_thread_with_info): Update.
+       (thread_target_id_str): Update.
+       (thr_try_catch_cmd): Update.
+       (thread_command): Update.
+       (thread_find_command): Update.
+       * record-btrace.c (record_btrace_target::info_record)
+       (record_btrace_resume_thread, record_btrace_target::resume)
+       (record_btrace_cancel_resume, record_btrace_step_thread)
+       (record_btrace_target::wait, record_btrace_target::wait)
+       (record_btrace_target::wait, record_btrace_target::stop): Update.
+       * progspace.c (print_program_space): Update.
+       * process-stratum-target.c
+       (process_stratum_target::thread_address_space): Update.
+       * linux-fork.c (linux_fork_mourn_inferior)
+       (detach_checkpoint_command, info_checkpoints_command)
+       (linux_fork_context): Update.
+       (linux_fork_detach): Update.
+       (class scoped_switch_fork_info): Update.
+       (delete_checkpoint_command): Update.
+       * infrun.c (follow_fork_inferior): Update.
+       (follow_fork_inferior): Update.
+       (proceed_after_vfork_done): Update.
+       (handle_vfork_child_exec_or_exit): Update.
+       (follow_exec): Update.
+       (displaced_step_prepare_throw): Update.
+       (displaced_step_restore): Update.
+       (start_step_over): Update.
+       (resume_1): Update.
+       (clear_proceed_status_thread): Update.
+       (proceed): Update.
+       (print_target_wait_results): Update.
+       (do_target_wait): Update.
+       (context_switch): Update.
+       (stop_all_threads): Update.
+       (restart_threads): Update.
+       (finish_step_over): Update.
+       (handle_signal_stop): Update.
+       (switch_back_to_stepped_thread): Update.
+       (keep_going_pass_signal): Update.
+       (print_exited_reason): Update.
+       (normal_stop): Update.
+       * inferior.c (inferior_pid_to_str): Change return type.
+       (print_selected_inferior): Update.
+       (add_inferior): Update.
+       (detach_inferior): Update.
+       * dummy-frame.c (fprint_dummy_frames): Update.
+       * dcache.c (dcache_info_1): Update.
+       * btrace.c (btrace_enable, btrace_disable, btrace_teardown)
+       (btrace_fetch, btrace_clear): Update.
+       * linux-tdep.c (linux_core_pid_to_str): Change return type.
+       * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return
+       type.
+       * fbsd-tdep.c (fbsd_core_pid_to_str): Change return type.
+       * sol2-tdep.h (sol2_core_pid_to_str): Change return type.
+       * sol2-tdep.c (sol2_core_pid_to_str): Change return type.
+       * gdbarch.c, gdbarch.h: Rebuild.
+       * gdbarch.sh (core_pid_to_str): Change return type.
+       * windows-nat.c (struct windows_nat_target) <pid_to_str>: Change
+       return type.
+       (windows_nat_target::pid_to_str): Change return type.
+       (windows_delete_thread): Update.
+       (windows_nat_target::attach): Update.
+       (windows_nat_target::files_info): Update.
+       * target-delegates.c: Rebuild.
+       * sol-thread.c (class sol_thread_target) <pid_to_str>: Change
+       return type.
+       (sol_thread_target::pid_to_str): Change return type.
+       * remote.c (class remote_target) <pid_to_str>: Change return
+       type.
+       (remote_target::pid_to_str): Change return type.
+       (extended_remote_target::attach, remote_target::remote_stop_ns)
+       (remote_target::remote_notif_remove_queued_reply)
+       (remote_target::push_stop_reply, remote_target::disable_btrace):
+       Update.
+       (extended_remote_target::attach): Update.
+       * remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return
+       type.
+       (gdbsim_target::pid_to_str): Change return type.
+       * ravenscar-thread.c (struct ravenscar_thread_target)
+       <pid_to_str>: Change return type.
+       (ravenscar_thread_target::pid_to_str): Change return type.
+       * procfs.c (class procfs_target) <pid_to_str>: Change return
+       type.
+       (procfs_target::pid_to_str): Change return type.
+       (procfs_target::attach): Update.
+       (procfs_target::detach): Update.
+       (procfs_target::fetch_registers): Update.
+       (procfs_target::store_registers): Update.
+       (procfs_target::wait): Update.
+       (procfs_target::files_info): Update.
+       * obsd-nat.c (obsd_nat_target::pid_to_str): Change return type.
+       * nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change
+       return type.
+       (nto_procfs_target::pid_to_str): Change return type.
+       (nto_procfs_target::files_info, nto_procfs_target::attach): Update.
+       * linux-thread-db.c (class thread_db_target) <pid_to_str>: Change
+       return type.
+       * linux-nat.c (linux_nat_target::pid_to_str): Change return type.
+       (exit_lwp): Update.
+       (attach_proc_task_lwp_callback, get_detach_signal)
+       (detach_one_lwp, resume_lwp, linux_nat_target::resume)
+       (linux_nat_target::resume, wait_lwp, stop_callback)
+       (maybe_clear_ignore_sigint, stop_wait_callback, status_callback)
+       (save_stop_reason, select_event_lwp, linux_nat_filter_event)
+       (linux_nat_wait_1, resume_stopped_resumed_lwps)
+       (linux_nat_target::wait, linux_nat_stop_lwp): Update.
+       * inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return
+       type.
+       (inf_ptrace_target::attach): Update.
+       (inf_ptrace_target::files_info): Update.
+       * go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return
+       type.
+       (go32_nat_target::pid_to_str): Change return type.
+       * gnu-nat.c (gnu_nat_target::pid_to_str): Change return type.
+       (gnu_nat_target::wait): Update.
+       (gnu_nat_target::wait): Update.
+       (gnu_nat_target::resume): Update.
+       * fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type.
+       (fbsd_nat_target::wait): Update.
+       * darwin-nat.c (darwin_nat_target::pid_to_str): Change return
+       type.
+       (darwin_nat_target::attach): Update.
+       * corelow.c (class core_target) <pid_to_str>: Change return type.
+       (core_target::pid_to_str): Change return type.
+       * target.c (normal_pid_to_str): Change return type.
+       (default_pid_to_str): Likewise.
+       (target_pid_to_str): Change return type.
+       (target_translate_tls_address): Update.
+       (target_announce_detach): Update.
+       * bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change
+       return type.
+       (bsd_uthread_target::pid_to_str): Change return type.
+       * bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return
+       type.
+       (bsd_kvm_target::pid_to_str): Change return type.
+       * aix-thread.c (class aix_thread_target) <pid_to_str>: Change
+       return type.
+       (aix_thread_target::pid_to_str): Change return type.
+       * target.h (struct target_ops) <pid_to_str>: Change return type.
+       (target_pid_to_str, normal_pid_to_str): Likewise.
+       * obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return
+       type.
+       * linux-nat.h (class linux_nat_target) <pid_to_str>: Change return
+       type.
+       * inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change
+       return type.
+       * gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return
+       type.
+       * fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return
+       type.
+       * darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change
+       return type.
+
 2019-03-13  Simon Marchi  <simon.marchi@ericsson.com>
 
        * NEWS: Mention that the new default MI version is 3.  Mention
index 655c085734c1326b83081774d36784b88fdb77b6..ffa3352d03992338614c3883d8ac2f268e597ed8 100644 (file)
@@ -140,7 +140,7 @@ public:
 
   bool thread_alive (ptid_t ptid) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   const char *extra_thread_info (struct thread_info *) override;
 
@@ -1746,20 +1746,13 @@ aix_thread_target::thread_alive (ptid_t ptid)
 /* Return a printable representation of composite PID for use in
    "info threads" output.  */
 
-const char *
+std::string
 aix_thread_target::pid_to_str (ptid_t ptid)
 {
-  static char *ret = NULL;
-
   if (!PD_TID (ptid))
     return beneath ()->pid_to_str (ptid);
 
-  /* Free previous return value; a new one will be allocated by
-     xstrprintf().  */
-  xfree (ret);
-
-  ret = xstrprintf (_("Thread %ld"), ptid.tid ());
-  return ret;
+  return string_printf (_("Thread %ld"), ptid.tid ());
 }
 
 /* Return a printable representation of extra information about
index 46f222558f3a7047474f8def833c593a0968c7c0..21f978728da629ef3569f996af9cfe7aa12fe8f6 100644 (file)
@@ -92,7 +92,7 @@ public:
 
   void files_info () override;
   bool thread_alive (ptid_t ptid) override;
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   bool has_memory () override { return true; }
   bool has_stack () override { return true; }
@@ -368,12 +368,10 @@ bsd_kvm_target::thread_alive (ptid_t ptid)
   return true;
 }
 
-const char *
+std::string
 bsd_kvm_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[64];
-  xsnprintf (buf, sizeof buf, "<kvm>");
-  return buf;
+  return "<kvm>";
 }
 
 /* Add the libkvm interface to the list of all possible targets and
index 3b3a420f2a468ebb1451416b5454a69345e1eb6d..af048f7a18f940c02633c228a864f8f68d46d5cd 100644 (file)
@@ -62,7 +62,7 @@ struct bsd_uthread_target final : public target_ops
 
   const char *extra_thread_info (struct thread_info *) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 };
 
 static bsd_uthread_target bsd_uthread_ops;
@@ -530,17 +530,12 @@ bsd_uthread_target::extra_thread_info (thread_info *info)
   return NULL;
 }
 
-const char *
+std::string
 bsd_uthread_target::pid_to_str (ptid_t ptid)
 {
   if (ptid.tid () != 0)
-    {
-      static char buf[64];
-
-      xsnprintf (buf, sizeof buf, "process %d, thread 0x%lx",
-                ptid.pid (), ptid.tid ());
-      return buf;
-    }
+    return string_printf ("process %d, thread 0x%lx",
+                         ptid.pid (), ptid.tid ());
 
   return normal_pid_to_str (ptid);
 }
index 000db4260e2078f13d04369d5cb60c1c701262d7..12af46814a9db0586d8e1109574528f6cf610576 100644 (file)
@@ -1608,7 +1608,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));
+        target_pid_to_str (tp->ptid).c_str ());
 
   tp->btrace.target = target_enable_btrace (tp->ptid, conf);
 
@@ -1663,7 +1663,7 @@ btrace_disable (struct thread_info *tp)
     return;
 
   DEBUG ("disable thread %s (%s)", print_thread_id (tp),
-        target_pid_to_str (tp->ptid));
+        target_pid_to_str (tp->ptid).c_str ());
 
   target_disable_btrace (btp->target);
   btp->target = NULL;
@@ -1682,7 +1682,7 @@ btrace_teardown (struct thread_info *tp)
     return;
 
   DEBUG ("teardown thread %s (%s)", print_thread_id (tp),
-        target_pid_to_str (tp->ptid));
+        target_pid_to_str (tp->ptid).c_str ());
 
   target_teardown_btrace (btp->target);
   btp->target = NULL;
@@ -1905,7 +1905,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));
+        target_pid_to_str (tp->ptid).c_str ());
 
   btinfo = &tp->btrace;
   tinfo = btinfo->target;
@@ -1981,7 +1981,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));
+        target_pid_to_str (tp->ptid).c_str ());
 
   /* Make sure btrace frames that may hold a pointer into the branch
      trace data are destroyed.  */
index 6a29d6a232864add7b835dcd10cc0c73efec07fa..7fb42970de4f87ba08c9416ac3065f4186a8de38 100644 (file)
@@ -83,7 +83,7 @@ public:
   bool thread_alive (ptid_t ptid) override;
   const struct target_desc *read_description () override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   const char *thread_name (struct thread_info *) override;
 
@@ -985,10 +985,9 @@ core_target::read_description ()
   return this->beneath ()->read_description ();
 }
 
-const char *
+std::string
 core_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[64];
   struct inferior *inf;
   int pid;
 
@@ -1013,8 +1012,7 @@ core_target::pid_to_str (ptid_t ptid)
     return normal_pid_to_str (ptid);
 
   /* No luck.  We simply don't have a valid PID to print.  */
-  xsnprintf (buf, sizeof buf, "<main task>");
-  return buf;
+  return "<main task>";
 }
 
 const char *
index 0b7cfb69dc805d3e6b565e2a67a5ac1d7d3d6498..6247b0656c9507de3a8f89e1b74a42b8b4dc30a5 100644 (file)
@@ -2052,10 +2052,10 @@ darwin_nat_target::attach (const char *args, int from_tty)
 
       if (exec_file)
        printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
       else
        printf_unfiltered (_("Attaching to %s\n"),
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
     }
 
   if (pid == 0 || ::kill (pid, 0) < 0)
@@ -2126,18 +2126,14 @@ darwin_nat_target::detach (inferior *inf, int from_tty)
   mourn_inferior ();
 }
 
-const char *
+std::string
 darwin_nat_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[80];
   long tid = ptid.tid ();
 
   if (tid != 0)
-    {
-      snprintf (buf, sizeof (buf), _("Thread 0x%lx of process %u"),
-               tid, ptid.pid ());
-      return buf;
-    }
+    return string_printf (_("Thread 0x%lx of process %u"),
+                         tid, ptid.pid ());
 
   return normal_pid_to_str (ptid);
 }
index f33e25316f5ac1e46f0eaa3edaaabfcf5649a725..9091efd88f14b866fb98729e829e77d726986430 100644 (file)
@@ -45,7 +45,7 @@ class darwin_nat_target : public inf_child_target
 
   bool thread_alive (ptid_t ptid) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   char *pid_to_exec_file (int pid) override;
 
index 82cb34b08ad67f56062fbb6f23deffea3381085b..5a2e8f8000b7c7de9f0fbac640611043b2187b02 100644 (file)
@@ -615,7 +615,7 @@ dcache_info_1 (DCACHE *dcache, const char *exp)
     }
 
   printf_filtered (_("Contains data for %s\n"),
-                  target_pid_to_str (dcache->ptid));
+                  target_pid_to_str (dcache->ptid).c_str ());
 
   refcount = 0;
 
index a36cdff459e879c61af12491b298ecfea17aaa1f..aebdd233d74074fb1f723c7bd0bd9e03147e24db 100644 (file)
@@ -409,7 +409,7 @@ fprint_dummy_frames (struct ui_file *file)
       fprintf_unfiltered (file, " id=");
       fprint_frame_id (file, s->id.id);
       fprintf_unfiltered (file, ", ptid=%s",
-                         target_pid_to_str (s->id.thread->ptid));
+                         target_pid_to_str (s->id.thread->ptid).c_str ());
       fprintf_unfiltered (file, "\n");
     }
 }
index 184d63939f475c8bf6c01a90dca225eae3f11e91..d4f4c8cf3592b5eaf61ccdd7b3514287feef9d54 100644 (file)
@@ -897,10 +897,9 @@ fbsd_nat_target::thread_alive (ptid_t ptid)
   return true;
 }
 
-/* Convert PTID to a string.  Returns the string in a static
-   buffer.  */
+/* Convert PTID to a string.  */
 
-const char *
+std::string
 fbsd_nat_target::pid_to_str (ptid_t ptid)
 {
   lwpid_t lwp;
@@ -908,11 +907,9 @@ fbsd_nat_target::pid_to_str (ptid_t ptid)
   lwp = ptid.lwp ();
   if (lwp != 0)
     {
-      static char buf[64];
       int pid = ptid.pid ();
 
-      xsnprintf (buf, sizeof buf, "LWP %d of process %d", lwp, pid);
-      return buf;
+      return string_printf ("LWP %d of process %d", lwp, pid);
     }
 
   return normal_pid_to_str (ptid);
@@ -1350,8 +1347,8 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
                                        "FLWP: deleting thread for LWP %u\n",
                                        pl.pl_lwpid);
                  if (print_thread_events)
-                   printf_unfiltered (_("[%s exited]\n"), target_pid_to_str
-                                      (wptid));
+                   printf_unfiltered (_("[%s exited]\n"),
+                                      target_pid_to_str (wptid).c_str ());
                  delete_thread (thr);
                }
              if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1)
index 45861d0257a4a0289ca64b63a3c5daf6551352cf..b0c9eb16c7754f6b2353838b837d4a9671dfc373 100644 (file)
@@ -51,7 +51,7 @@ public:
 
 #ifdef PT_LWPINFO
   bool thread_alive (ptid_t ptid) override;
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
   const char *thread_name (struct thread_info *) override;
index f06836216d9ed865668834c753579fd6d1961f1e..cd207d88bc384f097fa42f72402537783d8b9248 100644 (file)
@@ -482,16 +482,11 @@ fbsd_pspace_data_cleanup (struct program_space *pspace, void *data)
 
 /* This is how we want PTIDs from core files to be printed.  */
 
-static const char *
+static std::string
 fbsd_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
 {
-  static char buf[80];
-
   if (ptid.lwp () != 0)
-    {
-      xsnprintf (buf, sizeof buf, "LWP %ld", ptid.lwp ());
-      return buf;
-    }
+    return string_printf ("LWP %ld", ptid.lwp ());
 
   return normal_pid_to_str (ptid);
 }
index 2b3fcef004febe84097dc65e13eb69017728ff90..210defffea39a12b40354aa92d79d3ceb7e75be2 100644 (file)
@@ -3766,7 +3766,7 @@ gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch)
   return gdbarch->core_pid_to_str != NULL;
 }
 
-const char *
+std::string
 gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
 {
   gdb_assert (gdbarch != NULL);
index abb72e752b1f290b297376e2e3297d3513eb760e..7e185241872d350c7bcf46d496b36d8153a11fd0 100644 (file)
@@ -959,8 +959,8 @@ extern void set_gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
 
 extern int gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch);
 
-typedef const char * (gdbarch_core_pid_to_str_ftype) (struct gdbarch *gdbarch, ptid_t ptid);
-extern const char * gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid);
+typedef std::string (gdbarch_core_pid_to_str_ftype) (struct gdbarch *gdbarch, ptid_t ptid);
+extern std::string gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid);
 extern void set_gdbarch_core_pid_to_str (struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype *core_pid_to_str);
 
 /* How the core target extracts the name of a thread from a core file. */
index 63bfbad7d9e7dc2f019100e95040c909ff5b0d18..5e3e4346a4ea6f5a361884a719a566cf5c660bdb 100755 (executable)
@@ -767,7 +767,7 @@ M;ULONGEST;core_xfer_shared_libraries;gdb_byte *readbuf, ULONGEST offset, ULONGE
 M;ULONGEST;core_xfer_shared_libraries_aix;gdb_byte *readbuf, ULONGEST offset, ULONGEST len;readbuf, offset, len
 
 # How the core target converts a PTID from a core file to a string.
-M;const char *;core_pid_to_str;ptid_t ptid;ptid
+M;std::string;core_pid_to_str;ptid_t ptid;ptid
 
 # How the core target extracts the name of a thread from a core file.
 M;const char *;core_thread_name;struct thread_info *thr;thr
index 7a0c726c8e943c9072b81b498f3f262984f4d254..c1fafed156efc81f0971e8e8c6b6fa4cab200aef 100644 (file)
@@ -1493,7 +1493,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));
+  inf_debug (inf, "waiting for: %s", target_pid_to_str (ptid).c_str ());
 
 rewait:
   if (proc_wait_pid != inf->pid && !inf->no_wait)
@@ -1648,7 +1648,7 @@ rewait:
     }
 
   inf_debug (inf, "returning ptid = %s, status = %s (%d)",
-            target_pid_to_str (ptid),
+            target_pid_to_str (ptid).c_str (),
             status->kind == TARGET_WAITKIND_EXITED ? "EXITED"
             : status->kind == TARGET_WAITKIND_STOPPED ? "STOPPED"
             : status->kind == TARGET_WAITKIND_SIGNALLED ? "SIGNALLED"
@@ -2012,7 +2012,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), step, sig);
+            target_pid_to_str (ptid).c_str (), step, sig);
 
   inf_validate_procinfo (inf);
 
@@ -2058,8 +2058,9 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 
       if (!thread)
        error (_("Can't run single thread id %s: no such thread!"),
-              target_pid_to_str (ptid));
-      inf_debug (inf, "running one thread: %s", target_pid_to_str (ptid));
+              target_pid_to_str (ptid).c_str ());
+      inf_debug (inf, "running one thread: %s",
+                target_pid_to_str (ptid).c_str ());
       inf_set_threads_resume_sc (inf, thread, 0);
     }
 
@@ -2068,9 +2069,10 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
       step_thread = inf_tid_to_thread (inf, ptid.lwp ());
       if (!step_thread)
        warning (_("Can't step thread id %s: no such thread."),
-                target_pid_to_str (ptid));
+                target_pid_to_str (ptid).c_str ());
       else
-       inf_debug (inf, "stepping thread: %s", target_pid_to_str (ptid));
+       inf_debug (inf, "stepping thread: %s",
+                  target_pid_to_str (ptid).c_str ());
     }
   if (step_thread != inf->step_thread)
     inf_set_step_thread (inf, step_thread);
@@ -2714,7 +2716,7 @@ proc_string (struct proc *proc)
   return tid_str;
 }
 
-const char *
+std::string
 gnu_nat_target::pid_to_str (ptid_t ptid)
 {
   struct inf *inf = gnu_current_inf;
@@ -2724,12 +2726,7 @@ gnu_nat_target::pid_to_str (ptid_t ptid)
   if (thread)
     return proc_string (thread);
   else
-    {
-      static char tid_str[80];
-
-      xsnprintf (tid_str, sizeof (tid_str), "bogus thread id %d", tid);
-      return tid_str;
-    }
+    return string_printf ("bogus thread id %d", tid);
 }
 
 \f
index 4bd4176ead8882afad0192fc686321860e7caacb..a22df89fe2de549649efeb2c415ac2aac29f2d9a 100644 (file)
@@ -146,7 +146,7 @@ struct gnu_nat_target : public inf_child_target
                        char **, int) override;
   void mourn_inferior () override;
   bool thread_alive (ptid_t ptid) override;
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
   void stop (ptid_t) override;
 };
 
index 27e236918f06c2772f7ab281227229d984e32221..ea0872363d3c4b3c424181cf0d80cb2287358e7c 100644 (file)
@@ -377,7 +377,7 @@ struct go32_nat_target final : public x86_nat_target<inf_child_target>
 
   bool thread_alive (ptid_t ptid) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 };
 
 static go32_nat_target the_go32_nat_target;
@@ -992,7 +992,7 @@ go32_nat_target::thread_alive (ptid_t ptid)
   return ptid != null_ptid;
 }
 
-const char *
+std::string
 go32_nat_target::pid_to_str (ptid_t ptid)
 {
   return normal_pid_to_str (ptid);
index e6a9f8289294c41e1be3db07dc01c4220ab66721..1acd37975ee8c26dfe2873ab76e1909d21394691 100644 (file)
@@ -178,16 +178,11 @@ windows_core_xfer_shared_libraries (struct gdbarch *gdbarch,
 
 /* This is how we want PTIDs from core files to be printed.  */
 
-static const char *
+static std::string
 i386_windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
 {
-  static char buf[80];
-
   if (ptid.lwp () != 0)
-    {
-      snprintf (buf, sizeof (buf), "Thread 0x%lx", ptid.lwp ());
-      return buf;
-    }
+    return string_printf ("Thread 0x%lx", ptid.lwp ());
 
   return normal_pid_to_str (ptid);
 }
index 75ae641f8e06ca6c289c6eaa7a44629b893899ae..087445bc6269b53d3499191d07d90f53c0b949eb 100644 (file)
@@ -117,7 +117,7 @@ i386_gnu_nat_target::fetch_registers (struct regcache *regcache, int regno)
   thread = inf_tid_to_thread (gnu_current_inf, ptid.lwp ());
   if (!thread)
     error (_("Can't fetch registers from thread %s: No such thread"),
-          target_pid_to_str (ptid));
+          target_pid_to_str (ptid).c_str ());
 
   if (regno < I386_NUM_GREGS || regno == -1)
     {
@@ -208,7 +208,7 @@ i386_gnu_nat_target::store_registers (struct regcache *regcache, int regno)
   thread = inf_tid_to_thread (gnu_current_inf, ptid.lwp ());
   if (!thread)
     error (_("Couldn't store registers into thread %s: No such thread"),
-          target_pid_to_str (ptid));
+          target_pid_to_str (ptid).c_str ());
 
   if (regno < I386_NUM_GREGS || regno == -1)
     {
index d4b9a3a646957f0ad66f0057fb947f1dc48e7ee5..e1acd8dc9df7cb1faf00a346b0cf8685bff6b0c3 100644 (file)
@@ -213,10 +213,10 @@ inf_ptrace_target::attach (const char *args, int from_tty)
 
       if (exec_file)
        printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
       else
        printf_unfiltered (_("Attaching to %s\n"),
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
     }
 
 #ifdef PT_ATTACH
@@ -624,10 +624,10 @@ inf_ptrace_target::files_info ()
 
   printf_filtered (_("\tUsing the running image of %s %s.\n"),
                   inf->attach_flag ? "attached" : "child",
-                  target_pid_to_str (inferior_ptid));
+                  target_pid_to_str (inferior_ptid).c_str ());
 }
 
-const char *
+std::string
 inf_ptrace_target::pid_to_str (ptid_t ptid)
 {
   return normal_pid_to_str (ptid);
index 2165578083db557e4cda8359b5bf7382b331192f..98b5d2e09e686b0c4490f1fd442e4be61bab6a61 100644 (file)
@@ -59,7 +59,7 @@ struct inf_ptrace_target : public inf_child_target
 
   bool thread_alive (ptid_t ptid) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   enum target_xfer_status xfer_partial (enum target_object object,
                                        const char *annex,
index cb8063ba03241586790bceab199ed21310be1c00..e995af816c13105123915bcdcd8890d064e0c774 100644 (file)
@@ -126,7 +126,7 @@ add_inferior (int pid)
       if (pid != 0)
        printf_unfiltered (_("[New inferior %d (%s)]\n"),
                           inf->num,
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
       else
        printf_unfiltered (_("[New inferior %d]\n"), inf->num);
     }
@@ -243,7 +243,7 @@ detach_inferior (inferior *inf)
   if (print_inferior_events)
     printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
                       inf->num,
-                      target_pid_to_str (ptid_t (pid)));
+                      target_pid_to_str (ptid_t (pid)).c_str ());
 }
 
 void
@@ -407,7 +407,7 @@ number_of_inferiors (void)
 /* Converts an inferior process id to a string.  Like
    target_pid_to_str, but special cases the null process.  */
 
-static const char *
+static std::string
 inferior_pid_to_str (int pid)
 {
   if (pid != 0)
@@ -428,7 +428,7 @@ print_selected_inferior (struct ui_out *uiout)
     filename = _("<noexec>");
 
   uiout->message (_("[Switching to inferior %d [%s] (%s)]\n"),
-                 inf->num, inferior_pid_to_str (inf->pid), filename);
+                 inf->num, inferior_pid_to_str (inf->pid).c_str (), filename);
 }
 
 /* Prints the list of inferiors and their details on UIOUT.  This is a
index 33e5d434b3582cdf189887fb985331ab64f0b6a4..3d7f36b447490482e77d9328f4bf32fd9666b86c 100644 (file)
@@ -471,7 +471,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
              fprintf_filtered (gdb_stdlog,
                                _("[Detaching after %s from child %s]\n"),
                                has_vforked ? "vfork" : "fork",
-                               target_pid_to_str (process_ptid));
+                               target_pid_to_str (process_ptid).c_str ());
            }
        }
       else
@@ -607,7 +607,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
              fprintf_filtered (gdb_stdlog,
                                _("[Detaching after fork from "
                                  "parent %s]\n"),
-                               target_pid_to_str (process_ptid));
+                               target_pid_to_str (process_ptid).c_str ());
            }
 
          target_detach (parent_inf, 0);
@@ -876,7 +876,7 @@ proceed_after_vfork_done (struct thread_info *thread,
       if (debug_infrun)
        fprintf_unfiltered (gdb_stdlog,
                            "infrun: resuming vfork parent thread %s\n",
-                           target_pid_to_str (thread->ptid));
+                           target_pid_to_str (thread->ptid).c_str ());
 
       switch_to_thread (thread);
       clear_proceed_status (0);
@@ -963,7 +963,7 @@ handle_vfork_child_exec_or_exit (int exec)
 
          if (print_inferior_events)
            {
-             const char *pidstr
+             std::string pidstr
                = target_pid_to_str (ptid_t (inf->vfork_parent->pid));
 
              target_terminal::ours_for_output ();
@@ -972,13 +972,13 @@ handle_vfork_child_exec_or_exit (int exec)
                {
                  fprintf_filtered (gdb_stdlog,
                                    _("[Detaching vfork parent %s "
-                                     "after child exec]\n"), pidstr);
+                                     "after child exec]\n"), pidstr.c_str ());
                }
              else
                {
                  fprintf_filtered (gdb_stdlog,
                                    _("[Detaching vfork parent %s "
-                                     "after child exit]\n"), pidstr);
+                                     "after child exit]\n"), pidstr.c_str ());
                }
            }
 
@@ -1154,7 +1154,7 @@ follow_exec (ptid_t ptid, char *exec_file_target)
   /* What is this a.out's name?  */
   process_ptid = ptid_t (pid);
   printf_unfiltered (_("%s is executing new program: %s\n"),
-                    target_pid_to_str (process_ptid),
+                    target_pid_to_str (process_ptid).c_str (),
                     exec_file_target);
 
   /* We've followed the inferior through an exec.  Therefore, the
@@ -1668,7 +1668,7 @@ displaced_step_prepare_throw (thread_info *tp)
       if (debug_displaced)
        fprintf_unfiltered (gdb_stdlog,
                            "displaced: deferring step of %s\n",
-                           target_pid_to_str (tp->ptid));
+                           target_pid_to_str (tp->ptid).c_str ());
 
       thread_step_over_chain_enqueue (tp);
       return 0;
@@ -1678,7 +1678,7 @@ displaced_step_prepare_throw (thread_info *tp)
       if (debug_displaced)
        fprintf_unfiltered (gdb_stdlog,
                            "displaced: stepping %s now\n",
-                           target_pid_to_str (tp->ptid));
+                           target_pid_to_str (tp->ptid).c_str ());
     }
 
   displaced_step_clear (displaced);
@@ -1831,7 +1831,7 @@ displaced_step_restore (struct displaced_step_inferior_state *displaced,
                     displaced->step_saved_copy.data (), len);
   if (debug_displaced)
     fprintf_unfiltered (gdb_stdlog, "displaced: restored %s %s\n",
-                       target_pid_to_str (ptid),
+                       target_pid_to_str (ptid).c_str (),
                        paddress (displaced->step_gdbarch,
                                  displaced->step_copy));
 }
@@ -1985,7 +1985,7 @@ start_step_over (void)
          internal_error (__FILE__, __LINE__,
                          "[%s] has inconsistent state: "
                          "trap_expected=%d, resumed=%d, executing=%d\n",
-                         target_pid_to_str (tp->ptid),
+                         target_pid_to_str (tp->ptid).c_str (),
                          tp->control.trap_expected,
                          tp->resumed,
                          tp->executing);
@@ -1994,7 +1994,7 @@ start_step_over (void)
       if (debug_infrun)
        fprintf_unfiltered (gdb_stdlog,
                            "infrun: resuming [%s] for step-over\n",
-                           target_pid_to_str (tp->ptid));
+                           target_pid_to_str (tp->ptid).c_str ());
 
       /* keep_going_pass_signal skips the step-over if the breakpoint
         is no longer inserted.  In all-stop, we want to keep looking
@@ -2253,7 +2253,8 @@ resume_1 (enum gdb_signal sig)
          fprintf_unfiltered (gdb_stdlog,
                              "infrun: resume: thread %s has pending wait "
                              "status %s (currently_stepping=%d).\n",
-                             target_pid_to_str (tp->ptid), statstr.c_str (),
+                             target_pid_to_str (tp->ptid).c_str (),
+                             statstr.c_str (),
                              currently_stepping (tp));
        }
 
@@ -2265,7 +2266,8 @@ resume_1 (enum gdb_signal sig)
       if (sig != GDB_SIGNAL_0)
        {
          warning (_("Couldn't deliver signal %s to %s."),
-                  gdb_signal_to_name (sig), target_pid_to_str (tp->ptid));
+                  gdb_signal_to_name (sig),
+                  target_pid_to_str (tp->ptid).c_str ());
        }
 
       tp->suspend.stop_signal = GDB_SIGNAL_0;
@@ -2309,7 +2311,7 @@ resume_1 (enum gdb_signal sig)
                        "trap_expected=%d, current thread [%s] at %s\n",
                        step, gdb_signal_to_symbol_string (sig),
                        tp->control.trap_expected,
-                       target_pid_to_str (inferior_ptid),
+                       target_pid_to_str (inferior_ptid).c_str (),
                        paddress (gdbarch, pc));
 
   /* Normally, by the time we reach `resume', the breakpoints are either
@@ -2558,7 +2560,7 @@ resume_1 (enum gdb_signal sig)
       if (debug_infrun)
        fprintf_unfiltered (gdb_stdlog,
                            "infrun: resume: [%s] stepped breakpoint\n",
-                           target_pid_to_str (tp->ptid));
+                           target_pid_to_str (tp->ptid).c_str ());
 
       tp->stepped_breakpoint = 1;
 
@@ -2663,7 +2665,7 @@ clear_proceed_status_thread (struct thread_info *tp)
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
                        "infrun: clear_proceed_status_thread (%s)\n",
-                       target_pid_to_str (tp->ptid));
+                       target_pid_to_str (tp->ptid).c_str ());
 
   /* If we're starting a new sequence, then the previous finished
      single-step is no longer relevant.  */
@@ -2676,7 +2678,7 @@ clear_proceed_status_thread (struct thread_info *tp)
                                "infrun: clear_proceed_status: pending "
                                "event of %s was a finished step. "
                                "Discarding.\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
 
          tp->suspend.waitstatus_pending_p = 0;
          tp->suspend.stop_reason = TARGET_STOPPED_BY_NO_REASON;
@@ -2690,7 +2692,8 @@ clear_proceed_status_thread (struct thread_info *tp)
                              "infrun: clear_proceed_status_thread: thread %s "
                              "has pending wait status %s "
                              "(currently_stepping=%d).\n",
-                             target_pid_to_str (tp->ptid), statstr.c_str (),
+                             target_pid_to_str (tp->ptid).c_str (),
+                             statstr.c_str (),
                              currently_stepping (tp));
        }
     }
@@ -2960,7 +2963,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: need to step-over [%s] first\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
 
          thread_step_over_chain_enqueue (tp);
        }
@@ -3005,7 +3008,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
              if (debug_infrun)
                fprintf_unfiltered (gdb_stdlog,
                                    "infrun: proceed: [%s] resumed\n",
-                                   target_pid_to_str (tp->ptid));
+                                   target_pid_to_str (tp->ptid).c_str ());
              gdb_assert (tp->executing || tp->suspend.waitstatus_pending_p);
              continue;
            }
@@ -3015,14 +3018,14 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
              if (debug_infrun)
                fprintf_unfiltered (gdb_stdlog,
                                    "infrun: proceed: [%s] needs step-over\n",
-                                   target_pid_to_str (tp->ptid));
+                                   target_pid_to_str (tp->ptid).c_str ());
              continue;
            }
 
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: proceed: resuming %s\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
 
          reset_ecs (ecs, tp);
          switch_to_thread (tp);
@@ -3256,13 +3259,13 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
              waiton_ptid.lwp (),
              waiton_ptid.tid ());
   if (waiton_ptid.pid () != -1)
-    stb.printf (" [%s]", target_pid_to_str (waiton_ptid));
+    stb.printf (" [%s]", target_pid_to_str (waiton_ptid).c_str ());
   stb.printf (", status) =\n");
   stb.printf ("infrun:   %d.%ld.%ld [%s],\n",
              result_ptid.pid (),
              result_ptid.lwp (),
              result_ptid.tid (),
-             target_pid_to_str (result_ptid));
+             target_pid_to_str (result_ptid).c_str ());
   stb.printf ("infrun:   %s\n", status_string.c_str ());
 
   /* This uses %s in part to handle %'s in the text, but also to avoid
@@ -3332,7 +3335,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
       if (debug_infrun)
        fprintf_unfiltered (gdb_stdlog,
                            "infrun: Waiting for specific thread %s.\n",
-                           target_pid_to_str (ptid));
+                           target_pid_to_str (ptid).c_str ());
 
       /* We have a specific thread to check.  */
       tp = find_thread_ptid (ptid);
@@ -3357,7 +3360,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: PC of %s changed.  was=%s, now=%s\n",
-                               target_pid_to_str (tp->ptid),
+                               target_pid_to_str (tp->ptid).c_str (),
                                paddress (gdbarch, tp->suspend.stop_pc),
                                paddress (gdbarch, pc));
          discard = 1;
@@ -3367,7 +3370,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: previous breakpoint of %s, at %s gone\n",
-                               target_pid_to_str (tp->ptid),
+                               target_pid_to_str (tp->ptid).c_str (),
                                paddress (gdbarch, pc));
 
          discard = 1;
@@ -3378,7 +3381,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: pending event of %s cancelled.\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
 
          tp->suspend.waitstatus.kind = TARGET_WAITKIND_SPURIOUS;
          tp->suspend.stop_reason = TARGET_STOPPED_BY_NO_REASON;
@@ -3395,7 +3398,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
          fprintf_unfiltered (gdb_stdlog,
                              "infrun: Using pending wait status %s for %s.\n",
                              statstr.c_str (),
-                             target_pid_to_str (tp->ptid));
+                             target_pid_to_str (tp->ptid).c_str ());
        }
 
       /* Now that we've selected our final event LWP, un-adjust its PC
@@ -3870,9 +3873,9 @@ context_switch (execution_control_state *ecs)
       && ecs->event_thread != inferior_thread ())
     {
       fprintf_unfiltered (gdb_stdlog, "infrun: Switching context from %s ",
-                         target_pid_to_str (inferior_ptid));
+                         target_pid_to_str (inferior_ptid).c_str ());
       fprintf_unfiltered (gdb_stdlog, "to %s\n",
-                         target_pid_to_str (ecs->ptid));
+                         target_pid_to_str (ecs->ptid).c_str ());
     }
 
   switch_to_thread (ecs->event_thread);
@@ -4312,7 +4315,7 @@ stop_all_threads (void)
                        fprintf_unfiltered (gdb_stdlog,
                                            "infrun:   %s executing, "
                                            "need stop\n",
-                                           target_pid_to_str (t->ptid));
+                                           target_pid_to_str (t->ptid).c_str ());
                      target_stop (t->ptid);
                      t->stop_requested = 1;
                    }
@@ -4322,7 +4325,7 @@ stop_all_threads (void)
                        fprintf_unfiltered (gdb_stdlog,
                                            "infrun:   %s executing, "
                                            "already stopping\n",
-                                           target_pid_to_str (t->ptid));
+                                           target_pid_to_str (t->ptid).c_str ());
                    }
 
                  if (t->stop_requested)
@@ -4333,7 +4336,7 @@ stop_all_threads (void)
                  if (debug_infrun)
                    fprintf_unfiltered (gdb_stdlog,
                                        "infrun:   %s not executing\n",
-                                       target_pid_to_str (t->ptid));
+                                       target_pid_to_str (t->ptid).c_str ());
 
                  /* The thread may be not executing, but still be
                     resumed with a pending status to process.  */
@@ -4367,7 +4370,7 @@ stop_all_threads (void)
                  fprintf_unfiltered (gdb_stdlog,
                                      "infrun: %s exited while "
                                      "stopping threads\n",
-                                     target_pid_to_str (ptid));
+                                     target_pid_to_str (ptid).c_str ());
                }
            }
          else
@@ -4407,7 +4410,7 @@ stop_all_threads (void)
                                              "infrun: displaced-step of %s "
                                              "canceled: adding back to the "
                                              "step-over queue\n",
-                                             target_pid_to_str (t->ptid));
+                                             target_pid_to_str (t->ptid).c_str ());
                        }
                      t->control.trap_expected = 0;
                      thread_step_over_chain_enqueue (t);
@@ -4454,7 +4457,7 @@ stop_all_threads (void)
                                          "(currently_stepping=%d)\n",
                                          paddress (target_gdbarch (),
                                                    t->suspend.stop_pc),
-                                         target_pid_to_str (t->ptid),
+                                         target_pid_to_str (t->ptid).c_str (),
                                          currently_stepping (t));
                    }
                }
@@ -5220,7 +5223,7 @@ restart_threads (struct thread_info *event_thread)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: restart threads: "
                                "[%s] is event thread\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          continue;
        }
 
@@ -5230,7 +5233,7 @@ restart_threads (struct thread_info *event_thread)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: restart threads: "
                                "[%s] not meant to be running\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          continue;
        }
 
@@ -5239,7 +5242,7 @@ restart_threads (struct thread_info *event_thread)
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: restart threads: [%s] resumed\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          gdb_assert (tp->executing || tp->suspend.waitstatus_pending_p);
          continue;
        }
@@ -5250,7 +5253,7 @@ restart_threads (struct thread_info *event_thread)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: restart threads: "
                                "[%s] needs step-over\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          gdb_assert (!tp->resumed);
          continue;
        }
@@ -5262,7 +5265,7 @@ restart_threads (struct thread_info *event_thread)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: restart threads: "
                                "[%s] has pending status\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          tp->resumed = 1;
          continue;
        }
@@ -5277,7 +5280,7 @@ restart_threads (struct thread_info *event_thread)
          internal_error (__FILE__, __LINE__,
                          "thread [%s] needs a step-over, but not in "
                          "step-over queue\n",
-                         target_pid_to_str (tp->ptid));
+                         target_pid_to_str (tp->ptid).c_str ());
        }
 
       if (currently_stepping (tp))
@@ -5285,7 +5288,7 @@ restart_threads (struct thread_info *event_thread)
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: restart threads: [%s] was stepping\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          keep_going_stepped_thread (tp);
        }
       else
@@ -5296,7 +5299,7 @@ restart_threads (struct thread_info *event_thread)
          if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: restart threads: [%s] continuing\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          reset_ecs (ecs, tp);
          switch_to_thread (tp);
          keep_going_pass_signal (ecs);
@@ -5417,7 +5420,7 @@ finish_step_over (struct execution_control_state *ecs)
                                  "(currently_stepping=%d)\n",
                                  paddress (target_gdbarch (),
                                            tp->suspend.stop_pc),
-                                 target_pid_to_str (tp->ptid),
+                                 target_pid_to_str (tp->ptid).c_str (),
                                  currently_stepping (tp));
            }
 
@@ -5580,7 +5583,7 @@ handle_signal_stop (struct execution_control_state *ecs)
                  fprintf_unfiltered (gdb_stdlog,
                                      "infrun: [%s] hit another thread's "
                                      "single-step breakpoint\n",
-                                     target_pid_to_str (ecs->ptid));
+                                     target_pid_to_str (ecs->ptid).c_str ());
                }
              ecs->hit_singlestep_breakpoint = 1;
            }
@@ -5592,7 +5595,7 @@ handle_signal_stop (struct execution_control_state *ecs)
              fprintf_unfiltered (gdb_stdlog,
                                  "infrun: [%s] hit its "
                                  "single-step breakpoint\n",
-                                 target_pid_to_str (ecs->ptid));
+                                 target_pid_to_str (ecs->ptid).c_str ());
            }
        }
     }
@@ -6842,7 +6845,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs)
            {
              fprintf_unfiltered (gdb_stdlog,
                                  "infrun: need to finish step-over of [%s]\n",
-                                 target_pid_to_str (ecs->event_thread->ptid));
+                                 target_pid_to_str (ecs->event_thread->ptid).c_str ());
            }
          keep_going (ecs);
          return 1;
@@ -6857,7 +6860,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs)
             fprintf_unfiltered (gdb_stdlog,
                                 "infrun: need to step [%s] over single-step "
                                 "breakpoint\n",
-                                target_pid_to_str (ecs->ptid));
+                                target_pid_to_str (ecs->ptid).c_str ());
           }
         keep_going (ecs);
         return 1;
@@ -6872,7 +6875,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs)
            {
              fprintf_unfiltered (gdb_stdlog,
                                  "infrun: thread [%s] still needs step-over\n",
-                                 target_pid_to_str (ecs->event_thread->ptid));
+                                 target_pid_to_str (ecs->event_thread->ptid).c_str ());
            }
          keep_going (ecs);
          return 1;
@@ -6923,7 +6926,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs)
              internal_error (__FILE__, __LINE__,
                              "[%s] has inconsistent state: "
                              "trap_expected=%d\n",
-                             target_pid_to_str (tp->ptid),
+                             target_pid_to_str (tp->ptid).c_str (),
                              tp->control.trap_expected);
            }
 
@@ -7493,7 +7496,7 @@ keep_going_pass_signal (struct execution_control_state *ecs)
        fprintf_unfiltered (gdb_stdlog,
                            "infrun: %s has trap_expected set, "
                            "resuming to collect trap\n",
-                           target_pid_to_str (tp->ptid));
+                           target_pid_to_str (tp->ptid).c_str ());
 
       /* We haven't yet gotten our trap, and either: intercepted a
         non-signal event (e.g., a fork); or took a signal which we
@@ -7515,7 +7518,7 @@ keep_going_pass_signal (struct execution_control_state *ecs)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: step-over already in progress: "
                                "step-over for %s deferred\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
          thread_step_over_chain_enqueue (tp);
        }
       else
@@ -7524,7 +7527,7 @@ keep_going_pass_signal (struct execution_control_state *ecs)
            fprintf_unfiltered (gdb_stdlog,
                                "infrun: step-over in progress: "
                                "resume of %s deferred\n",
-                               target_pid_to_str (tp->ptid));
+                               target_pid_to_str (tp->ptid).c_str ());
        }
     }
   else
@@ -7692,7 +7695,7 @@ void
 print_exited_reason (struct ui_out *uiout, int exitstatus)
 {
   struct inferior *inf = current_inferior ();
-  const char *pidstr = target_pid_to_str (ptid_t (inf->pid));
+  std::string pidstr = target_pid_to_str (ptid_t (inf->pid));
 
   annotate_exited (exitstatus);
   if (exitstatus)
@@ -7702,7 +7705,7 @@ print_exited_reason (struct ui_out *uiout, int exitstatus)
       uiout->text ("[Inferior ");
       uiout->text (plongest (inf->num));
       uiout->text (" (");
-      uiout->text (pidstr);
+      uiout->text (pidstr.c_str ());
       uiout->text (") exited with code ");
       uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus);
       uiout->text ("]\n");
@@ -7715,7 +7718,7 @@ print_exited_reason (struct ui_out *uiout, int exitstatus)
       uiout->text ("[Inferior ");
       uiout->text (plongest (inf->num));
       uiout->text (" (");
-      uiout->text (pidstr);
+      uiout->text (pidstr.c_str ());
       uiout->text (") exited normally]\n");
     }
 }
@@ -8046,7 +8049,7 @@ normal_stop (void)
        {
          target_terminal::ours_for_output ();
          printf_filtered (_("[Switching to %s]\n"),
-                          target_pid_to_str (inferior_ptid));
+                          target_pid_to_str (inferior_ptid).c_str ());
          annotate_thread_changed ();
        }
       previous_inferior_ptid = inferior_ptid;
index 51e8fddbc2351cde5ca879a1df3882f10f6f44c0..dde63d5572f0b4f1664fb1b6ea85d219eb46cf6d 100644 (file)
@@ -352,7 +352,7 @@ linux_fork_mourn_inferior (void)
   last = find_last_fork ();
   fork_load_infrun_state (last);
   printf_filtered (_("[Switching to %s]\n"),
-                  target_pid_to_str (inferior_ptid));
+                  target_pid_to_str (inferior_ptid).c_str ());
 
   /* If there's only one fork, switch back to non-fork mode.  */
   if (one_fork_p ())
@@ -371,7 +371,8 @@ linux_fork_detach (int from_tty)
      fork.  */
 
   if (ptrace (PTRACE_DETACH, inferior_ptid.pid (), 0, 0))
-    error (_("Unable to detach %s"), target_pid_to_str (inferior_ptid));
+    error (_("Unable to detach %s"),
+          target_pid_to_str (inferior_ptid).c_str ());
 
   delete_fork (inferior_ptid);
 
@@ -384,7 +385,7 @@ linux_fork_detach (int from_tty)
 
   if (from_tty)
     printf_filtered (_("[Switching to %s]\n"),
-                    target_pid_to_str (inferior_ptid));
+                    target_pid_to_str (inferior_ptid).c_str ());
 
   /* If there's only one fork, switch back to non-fork mode.  */
   if (one_fork_p ())
@@ -435,7 +436,7 @@ public:
        CATCH (ex, RETURN_MASK_ALL)
          {
            warning (_("Couldn't restore checkpoint state in %s: %s"),
-                    target_pid_to_str (m_oldfp->ptid), ex.message);
+                    target_pid_to_str (m_oldfp->ptid).c_str (), ex.message);
          }
        END_CATCH
       }
@@ -504,14 +505,14 @@ delete_checkpoint_command (const char *args, int from_tty)
 Please switch to another checkpoint before deleting the current one"));
 
   if (ptrace (PTRACE_KILL, ptid.pid (), 0, 0))
-    error (_("Unable to kill pid %s"), target_pid_to_str (ptid));
+    error (_("Unable to kill pid %s"), target_pid_to_str (ptid).c_str ());
 
   fi = find_fork_ptid (ptid);
   gdb_assert (fi);
   pptid = fi->parent_ptid;
 
   if (from_tty)
-    printf_filtered (_("Killed %s\n"), target_pid_to_str (ptid));
+    printf_filtered (_("Killed %s\n"), target_pid_to_str (ptid).c_str ());
 
   delete_fork (ptid);
 
@@ -524,7 +525,8 @@ Please switch to another checkpoint before deleting the current one"));
       || (parent != NULL && parent->state == THREAD_STOPPED))
     {
       if (inferior_call_waitpid (pptid, ptid.pid ()))
-        warning (_("Unable to wait pid %s"), target_pid_to_str (ptid));
+        warning (_("Unable to wait pid %s"),
+                target_pid_to_str (ptid).c_str ());
     }
 }
 
@@ -545,10 +547,10 @@ detach_checkpoint_command (const char *args, int from_tty)
 Please switch to another checkpoint before detaching the current one"));
 
   if (ptrace (PTRACE_DETACH, ptid.pid (), 0, 0))
-    error (_("Unable to detach %s"), target_pid_to_str (ptid));
+    error (_("Unable to detach %s"), target_pid_to_str (ptid).c_str ());
 
   if (from_tty)
-    printf_filtered (_("Detached %s\n"), target_pid_to_str (ptid));
+    printf_filtered (_("Detached %s\n"), target_pid_to_str (ptid).c_str ());
 
   delete_fork (ptid);
 }
@@ -577,7 +579,7 @@ info_checkpoints_command (const char *arg, int from_tty)
        printf_filtered ("  ");
 
       ULONGEST pc = fi.pc;
-      printf_filtered ("%d %s", fi.num, target_pid_to_str (fi.ptid));
+      printf_filtered ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
       if (fi.num == 0)
        printf_filtered (_(" (main process)"));
       printf_filtered (_(" at "));
@@ -730,7 +732,7 @@ linux_fork_context (struct fork_info *newfp, int from_tty)
   insert_breakpoints ();
 
   printf_filtered (_("Switching to %s\n"),
-                  target_pid_to_str (inferior_ptid));
+                  target_pid_to_str (inferior_ptid).c_str ());
 
   print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
 }
index ad5ec3d0b570bffd8be895321108dcec36f1c5fb..58da62a79640b5d5784779bc4344408a572d1a73 100644 (file)
@@ -1013,7 +1013,8 @@ exit_lwp (struct lwp_info *lp)
   if (th)
     {
       if (print_thread_events)
-       printf_unfiltered (_("[%s exited]\n"), target_pid_to_str (lp->ptid));
+       printf_unfiltered (_("[%s exited]\n"),
+                          target_pid_to_str (lp->ptid).c_str ());
 
       delete_thread (th);
     }
@@ -1149,7 +1150,7 @@ attach_proc_task_lwp_callback (ptid_t ptid)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "PTRACE_ATTACH %s, 0, 0 (OK)\n",
-                               target_pid_to_str (ptid));
+                               target_pid_to_str (ptid).c_str ());
 
          lp = add_lwp (ptid);
 
@@ -1335,7 +1336,7 @@ get_detach_signal (struct lwp_info *lp)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "GPT: lwp %s has no pending signal\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
   else if (!signal_pass_state (signo))
     {
@@ -1343,7 +1344,7 @@ get_detach_signal (struct lwp_info *lp)
        fprintf_unfiltered (gdb_stdlog,
                            "GPT: lwp %s had signal %s, "
                            "but it is in no pass state\n",
-                           target_pid_to_str (lp->ptid),
+                           target_pid_to_str (lp->ptid).c_str (),
                            gdb_signal_to_string (signo));
     }
   else
@@ -1351,7 +1352,7 @@ get_detach_signal (struct lwp_info *lp)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "GPT: lwp %s has pending signal %s\n",
-                           target_pid_to_str (lp->ptid),
+                           target_pid_to_str (lp->ptid).c_str (),
                            gdb_signal_to_string (signo));
 
       return gdb_signal_to_host (signo);
@@ -1375,7 +1376,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
   if (debug_linux_nat && lp->status)
     fprintf_unfiltered (gdb_stdlog, "DC:  Pending %s for %s on detach.\n",
                        strsignal (WSTOPSIG (lp->status)),
-                       target_pid_to_str (lp->ptid));
+                       target_pid_to_str (lp->ptid).c_str ());
 
   /* If there is a pending SIGSTOP, get rid of it.  */
   if (lp->signalled)
@@ -1383,7 +1384,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "DC: Sending SIGCONT to %s\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
 
       kill_lwp (lwpid, SIGCONT);
       lp->signalled = 0;
@@ -1438,7 +1439,8 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
        }
       else
        {
-         error (_("Can't detach %s: %s"), target_pid_to_str (lp->ptid),
+         error (_("Can't detach %s: %s"),
+                target_pid_to_str (lp->ptid).c_str (),
                 safe_strerror (save_errno));
        }
     }
@@ -1446,7 +1448,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
     {
       fprintf_unfiltered (gdb_stdlog,
                          "PTRACE_DETACH (%s, %s, 0) (OK)\n",
-                         target_pid_to_str (lp->ptid),
+                         target_pid_to_str (lp->ptid).c_str (),
                          strsignal (signo));
     }
 
@@ -1608,14 +1610,14 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "RC: Not resuming %s (vfork parent)\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
        }
       else if (!lwp_status_pending_p (lp))
        {
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "RC: Resuming sibling %s, %s, %s\n",
-                               target_pid_to_str (lp->ptid),
+                               target_pid_to_str (lp->ptid).c_str (),
                                (signo != GDB_SIGNAL_0
                                 ? strsignal (gdb_signal_to_host (signo))
                                 : "0"),
@@ -1628,7 +1630,7 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "RC: Not resuming sibling %s (has pending)\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
        }
     }
   else
@@ -1636,7 +1638,7 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "RC: Not resuming sibling %s (not stopped)\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
 }
 
@@ -1693,10 +1695,10 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
     fprintf_unfiltered (gdb_stdlog,
                        "LLR: Preparing to %s %s, %s, inferior_ptid %s\n",
                        step ? "step" : "resume",
-                       target_pid_to_str (ptid),
+                       target_pid_to_str (ptid).c_str (),
                        (signo != GDB_SIGNAL_0
                         ? strsignal (gdb_signal_to_host (signo)) : "0"),
-                       target_pid_to_str (inferior_ptid));
+                       target_pid_to_str (inferior_ptid).c_str ());
 
   /* A specific PTID means `step only this process id'.  */
   resume_many = (minus_one_ptid == ptid
@@ -1773,7 +1775,7 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
     fprintf_unfiltered (gdb_stdlog,
                        "LLR: %s %s, %s (resume event thread)\n",
                        step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-                       target_pid_to_str (lp->ptid),
+                       target_pid_to_str (lp->ptid).c_str (),
                        (signo != GDB_SIGNAL_0
                         ? strsignal (gdb_signal_to_host (signo)) : "0"));
 
@@ -2174,7 +2176,7 @@ wait_lwp (struct lwp_info *lp)
          thread_dead = 1;
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog, "WL: %s vanished.\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
        }
       if (pid != 0)
        break;
@@ -2200,7 +2202,7 @@ wait_lwp (struct lwp_info *lp)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "WL: Thread group leader %s vanished.\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
          break;
        }
 
@@ -2223,7 +2225,7 @@ wait_lwp (struct lwp_info *lp)
        {
          fprintf_unfiltered (gdb_stdlog,
                              "WL: waitpid %s received %s\n",
-                             target_pid_to_str (lp->ptid),
+                             target_pid_to_str (lp->ptid).c_str (),
                              status_to_str (status));
        }
 
@@ -2248,7 +2250,7 @@ wait_lwp (struct lwp_info *lp)
          thread_dead = 1;
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog, "WL: %s exited.\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
        }
     }
 
@@ -2316,7 +2318,7 @@ stop_callback (struct lwp_info *lp)
        {
          fprintf_unfiltered (gdb_stdlog,
                              "SC:  kill %s **<SIGSTOP>**\n",
-                             target_pid_to_str (lp->ptid));
+                             target_pid_to_str (lp->ptid).c_str ());
        }
       errno = 0;
       ret = kill_lwp (lp->ptid.lwp (), SIGSTOP);
@@ -2417,7 +2419,7 @@ maybe_clear_ignore_sigint (struct lwp_info *lp)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "MCIS: Clearing bogus flag for %s\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
       lp->ignore_sigint = 0;
     }
 }
@@ -2517,7 +2519,7 @@ stop_wait_callback (struct lwp_info *lp)
            fprintf_unfiltered (gdb_stdlog,
                                "PTRACE_CONT %s, 0, 0 (%s) "
                                "(discarding SIGINT)\n",
-                               target_pid_to_str (lp->ptid),
+                               target_pid_to_str (lp->ptid).c_str (),
                                errno ? safe_strerror (errno) : "OK");
 
          return stop_wait_callback (lp);
@@ -2533,7 +2535,7 @@ stop_wait_callback (struct lwp_info *lp)
            fprintf_unfiltered (gdb_stdlog,
                                "SWC: Pending event %s in %s\n",
                                status_to_str ((int) status),
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
 
          /* Save the sigtrap event.  */
          lp->status = status;
@@ -2547,7 +2549,7 @@ stop_wait_callback (struct lwp_info *lp)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "SWC: Expected SIGSTOP caught for %s.\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
 
          lp->signalled = 0;
 
@@ -2594,7 +2596,7 @@ status_callback (struct lwp_info *lp)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "SC: PC of %s changed.  was=%s, now=%s\n",
-                               target_pid_to_str (lp->ptid),
+                               target_pid_to_str (lp->ptid).c_str (),
                                paddress (target_gdbarch (), lp->stop_pc),
                                paddress (target_gdbarch (), pc));
          discard = 1;
@@ -2606,7 +2608,7 @@ status_callback (struct lwp_info *lp)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "SC: previous breakpoint of %s, at %s gone\n",
-                               target_pid_to_str (lp->ptid),
+                               target_pid_to_str (lp->ptid).c_str (),
                                paddress (target_gdbarch (), lp->stop_pc));
 
          discard = 1;
@@ -2618,7 +2620,7 @@ status_callback (struct lwp_info *lp)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "SC: pending event of %s cancelled.\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
 
          lp->status = 0;
          linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
@@ -2744,7 +2746,7 @@ save_stop_reason (struct lwp_info *lp)
              if (debug_linux_nat)
                fprintf_unfiltered (gdb_stdlog,
                                    "CSBB: %s stopped by trace\n",
-                                   target_pid_to_str (lp->ptid));
+                                   target_pid_to_str (lp->ptid).c_str ());
 
              /* We may have single stepped an instruction that
                 triggered a watchpoint.  In that case, on some
@@ -2777,7 +2779,7 @@ save_stop_reason (struct lwp_info *lp)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "CSBB: %s stopped by software breakpoint\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
 
       /* Back up the PC if necessary.  */
       if (pc != sw_bp_pc)
@@ -2791,14 +2793,14 @@ save_stop_reason (struct lwp_info *lp)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "CSBB: %s stopped by hardware breakpoint\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
   else if (lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
     {
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "CSBB: %s stopped by hardware watchpoint\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
 
   lp->stop_pc = pc;
@@ -2875,7 +2877,7 @@ select_event_lwp (ptid_t filter, struct lwp_info **orig_lp, int *status)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "SEL: Select single-step %s\n",
-                               target_pid_to_str (event_lp->ptid));
+                               target_pid_to_str (event_lp->ptid).c_str ());
        }
     }
 
@@ -3038,7 +3040,7 @@ linux_nat_filter_event (int lwpid, int status)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "LLW: %s exited.\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).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
@@ -3077,7 +3079,7 @@ linux_nat_filter_event (int lwpid, int status)
          if (debug_linux_nat)
            fprintf_unfiltered (gdb_stdlog,
                                "LLW: resume_stop SIGSTOP caught for %s.\n",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
        }
       else
        {
@@ -3088,7 +3090,7 @@ linux_nat_filter_event (int lwpid, int status)
                                "LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n",
                                lp->step ?
                                "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-                               target_pid_to_str (lp->ptid));
+                               target_pid_to_str (lp->ptid).c_str ());
 
          linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
          gdb_assert (lp->resumed);
@@ -3104,7 +3106,7 @@ linux_nat_filter_event (int lwpid, int status)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "LLW: Delayed SIGINT caught for %s.\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
 
       /* This is a delayed SIGINT.  */
       lp->ignore_sigint = 0;
@@ -3115,7 +3117,7 @@ linux_nat_filter_event (int lwpid, int status)
                            "LLW: %s %s, 0, 0 (discard SIGINT)\n",
                            lp->step ?
                            "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
       gdb_assert (lp->resumed);
 
       /* Discard the event.  */
@@ -3164,7 +3166,7 @@ linux_nat_filter_event (int lwpid, int status)
                                "LLW: %s %s, %s (preempt 'handle')\n",
                                lp->step ?
                                "PTRACE_SINGLESTEP" : "PTRACE_CONT",
-                               target_pid_to_str (lp->ptid),
+                               target_pid_to_str (lp->ptid).c_str (),
                                (signo != GDB_SIGNAL_0
                                 ? strsignal (gdb_signal_to_host (signo))
                                 : "0"));
@@ -3293,7 +3295,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
        fprintf_unfiltered (gdb_stdlog,
                            "LLW: Using pending wait status %s for %s.\n",
                            status_to_str (lp->status),
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
 
   /* But if we don't find a pending event, we'll have to wait.  Always
@@ -3453,7 +3455,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "LLW: trap ptid is %s.\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
 
   if (lp->waitstatus.kind != TARGET_WAITKIND_IGNORE)
@@ -3502,21 +3504,21 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "RSRL: NOT resuming LWP %s, not stopped\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
   else if (!lp->resumed)
     {
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "RSRL: NOT resuming LWP %s, not resumed\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
   else if (lwp_status_pending_p (lp))
     {
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "RSRL: NOT resuming LWP %s, has pending status\n",
-                           target_pid_to_str (lp->ptid));
+                           target_pid_to_str (lp->ptid).c_str ());
     }
   else
     {
@@ -3542,7 +3544,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
                fprintf_unfiltered (gdb_stdlog,
                                    "RSRL: resuming stopped-resumed LWP %s at "
                                    "%s: step=%d\n",
-                                   target_pid_to_str (lp->ptid),
+                                   target_pid_to_str (lp->ptid).c_str (),
                                    paddress (gdbarch, pc),
                                    lp->step);
 
@@ -3571,7 +3573,7 @@ linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
       std::string options_string = target_options_to_string (target_options);
       fprintf_unfiltered (gdb_stdlog,
                          "linux_nat_wait: [%s], [%s]\n",
-                         target_pid_to_str (ptid),
+                         target_pid_to_str (ptid).c_str (),
                          options_string.c_str ());
     }
 
@@ -3943,18 +3945,13 @@ linux_nat_target::update_thread_list ()
     }
 }
 
-const char *
+std::string
 linux_nat_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[64];
-
   if (ptid.lwp_p ()
       && (ptid.pid () != ptid.lwp ()
          || num_lwps (ptid.pid ()) > 1))
-    {
-      snprintf (buf, sizeof (buf), "LWP %ld", ptid.lwp ());
-      return buf;
-    }
+    return string_printf ("LWP %ld", ptid.lwp ());
 
   return normal_pid_to_str (ptid);
 }
@@ -4434,7 +4431,7 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
                            "LNSL: running -> suspending %s\n",
-                           target_pid_to_str (lwp->ptid));
+                           target_pid_to_str (lwp->ptid).c_str ());
 
 
       if (lwp->last_resume_kind == resume_stop)
@@ -4459,12 +4456,12 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
          if (find_thread_ptid (lwp->ptid)->stop_requested)
            fprintf_unfiltered (gdb_stdlog,
                                "LNSL: already stopped/stop_requested %s\n",
-                               target_pid_to_str (lwp->ptid));
+                               target_pid_to_str (lwp->ptid).c_str ());
          else
            fprintf_unfiltered (gdb_stdlog,
                                "LNSL: already stopped/no "
                                "stop_requested yet %s\n",
-                               target_pid_to_str (lwp->ptid));
+                               target_pid_to_str (lwp->ptid).c_str ());
        }
     }
   return 0;
index 40e0f2cb29b4c97e60c031ed1c8a0b42a1478161..0c1695ad1020aa176752e6bb8e877bf815e63077 100644 (file)
@@ -64,7 +64,7 @@ public:
 
   void update_thread_list () override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   const char *thread_name (struct thread_info *) override;
 
index 8d594138e5586a33bf4e0131b8126b905dbdc288..77bc7142865ea196a4d96c7ac3c2036e38deca6e 100644 (file)
@@ -414,16 +414,11 @@ linux_has_shared_address_space (struct gdbarch *gdbarch)
 
 /* This is how we want PTIDs from core files to be printed.  */
 
-static const char *
+static std::string
 linux_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
 {
-  static char buf[80];
-
   if (ptid.lwp () != 0)
-    {
-      snprintf (buf, sizeof (buf), "LWP %ld", ptid.lwp ());
-      return buf;
-    }
+    return string_printf ("LWP %ld", ptid.lwp ());
 
   return normal_pid_to_str (ptid);
 }
index fd67dcb17b2b6e9ec2e26bc3f3aad216e34a2f4c..186525a1e5844f7927737eeb3560bb1aa12610ac 100644 (file)
@@ -95,7 +95,7 @@ public:
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
   void update_thread_list () override;
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
   CORE_ADDR get_thread_local_address (ptid_t ptid,
                                      CORE_ADDR load_module_addr,
                                      CORE_ADDR offset) override;
@@ -1631,20 +1631,17 @@ thread_db_target::update_thread_list ()
   this->beneath ()->update_thread_list ();
 }
 
-const char *
+std::string
 thread_db_target::pid_to_str (ptid_t ptid)
 {
   struct thread_info *thread_info = find_thread_ptid (ptid);
 
   if (thread_info != NULL && thread_info->priv != NULL)
     {
-      static char buf[64];
       thread_db_thread_info *priv = get_thread_db_thread_info (thread_info);
 
-      snprintf (buf, sizeof (buf), "Thread 0x%lx (LWP %ld)",
-               (unsigned long) priv->tid, ptid.lwp ());
-
-      return buf;
+      return string_printf ("Thread 0x%lx (LWP %ld)",
+                           (unsigned long) priv->tid, ptid.lwp ());
     }
 
   return beneath ()->pid_to_str (ptid);
index 8108c0e3888eab79596187d40527ab77e1a94a54..9dd35a4c8aafcce2e9c7bec459941dcb7831c47c 100644 (file)
@@ -115,7 +115,7 @@ struct nto_procfs_target : public inf_child_target
 
   void update_thread_list () override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   void interrupt () override;
 
@@ -658,7 +658,7 @@ nto_procfs_target::files_info ()
 
   printf_unfiltered ("\tUsing the running image of %s %s via %s.\n",
                     inf->attach_flag ? "attached" : "child",
-                    target_pid_to_str (inferior_ptid),
+                    target_pid_to_str (inferior_ptid).c_str (),
                     (nodestr != NULL) ? nodestr : "local node");
 }
 
@@ -708,10 +708,10 @@ nto_procfs_target::attach (const char *args, int from_tty)
 
       if (exec_file)
        printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
       else
        printf_unfiltered ("Attaching to %s\n",
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
     }
   inferior_ptid = do_attach (ptid_t (pid));
   inf = current_inferior ();
@@ -1455,25 +1455,22 @@ nto_procfs_target::pass_signals
     }
 }
 
-char *
+std::string
 nto_procfs_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[1024];
-  int pid, tid, n;
+  int pid, tid;
   struct tidinfo *tip;
 
   pid = ptid.pid ();
   tid = ptid.tid ();
 
-  n = snprintf (buf, 1023, "process %d", pid);
-
 #if 0                          /* NYI */
   tip = procfs_thread_info (pid, tid);
   if (tip != NULL)
     snprintf (&buf[n], 1023, " (state = 0x%02x)", tip->state);
 #endif
 
-  return buf;
+  return string_printf ("process %d", pid);
 }
 
 /* to_can_run implementation for "target procfs".  Note this really
index 2c8b2d47817462fd05b6280e48fdb319a58d4ea0..0a99bd021df6b2edfa8fe4bded96c1da6e0c3528 100644 (file)
 
 #ifdef PT_GET_THREAD_FIRST
 
-const char *
+std::sring
 obsd_nat_target::pid_to_str (ptid_t ptid)
 {
   if (ptid.lwp () != 0)
-    {
-      static char buf[64];
-
-      xsnprintf (buf, sizeof buf, "thread %ld", ptid.lwp ());
-      return buf;
-    }
+    return string_printf ("thread %ld", ptid.lwp ());
 
   return normal_pid_to_str (ptid);
 }
index 7c35307c075e79d1344bedf46388520be133375f..c8016ed91218f0c6c4cdf603c29278b0833d5e7a 100644 (file)
@@ -25,7 +25,7 @@
 class obsd_nat_target : public inf_ptrace_target
 {
   /* Override some methods to support threads.  */
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
   void update_thread_list () override;
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
 };
index e2e8d6c4ff73a44ae6cd2007c5391dce8339d6a5..2c4b812f86379f4f32bdcf0358d5e18e1897189a 100644 (file)
@@ -35,7 +35,7 @@ process_stratum_target::thread_address_space (ptid_t ptid)
     internal_error (__FILE__, __LINE__,
                    _("Can't determine the current "
                      "address space of thread %s\n"),
-                   target_pid_to_str (ptid));
+                   target_pid_to_str (ptid).c_str ());
 
   return inf->aspace;
 }
index 384ca9bc0b27076ecd24cb76e62cb29a7daafad9..020336e5ba4b3bcf320e59a6a3192dcdeb9f7ad3 100644 (file)
@@ -127,7 +127,7 @@ public:
 
   bool thread_alive (ptid_t ptid) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   char *pid_to_exec_file (int pid) override;
 
@@ -1884,10 +1884,10 @@ procfs_target::attach (const char *args, int from_tty)
 
       if (exec_file)
        printf_filtered (_("Attaching to program `%s', %s\n"),
-                        exec_file, target_pid_to_str (ptid_t (pid)));
+                        exec_file, target_pid_to_str (ptid_t (pid)).c_str ());
       else
        printf_filtered (_("Attaching to %s\n"),
-                        target_pid_to_str (ptid_t (pid)));
+                        target_pid_to_str (ptid_t (pid)).c_str ());
 
       fflush (stdout);
     }
@@ -1910,7 +1910,7 @@ procfs_target::detach (inferior *inf, int from_tty)
        exec_file = "";
 
       printf_filtered (_("Detaching from program: %s, %s\n"), exec_file,
-                      target_pid_to_str (ptid_t (pid)));
+                      target_pid_to_str (ptid_t (pid)).c_str ());
     }
 
   do_detach ();
@@ -2063,7 +2063,7 @@ procfs_target::fetch_registers (struct regcache *regcache, int regnum)
 
   if (pi == NULL)
     error (_("procfs: fetch_registers failed to find procinfo for %s"),
-          target_pid_to_str (ptid));
+          target_pid_to_str (ptid).c_str ());
 
   gregs = proc_get_gregs (pi);
   if (gregs == NULL)
@@ -2112,7 +2112,7 @@ procfs_target::store_registers (struct regcache *regcache, int regnum)
 
   if (pi == NULL)
     error (_("procfs: store_registers: failed to find procinfo for %s"),
-          target_pid_to_str (ptid));
+          target_pid_to_str (ptid).c_str ());
 
   gregs = proc_get_gregs (pi);
   if (gregs == NULL)
@@ -2285,7 +2285,7 @@ wait_again:
                  {
                    if (print_thread_events)
                      printf_unfiltered (_("[%s exited]\n"),
-                                        target_pid_to_str (retval));
+                                        target_pid_to_str (retval).c_str ());
                    delete_thread (find_thread_ptid (retval));
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return retval;
@@ -2406,7 +2406,7 @@ wait_again:
                  {
                    if (print_thread_events)
                      printf_unfiltered (_("[%s exited]\n"),
-                                        target_pid_to_str (retval));
+                                        target_pid_to_str (retval).c_str ());
                    delete_thread (find_thread_ptid (retval));
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return retval;
@@ -2804,7 +2804,7 @@ procfs_target::files_info ()
 
   printf_filtered (_("\tUsing the running image of %s %s via /proc.\n"),
                   inf->attach_flag? "attached": "child",
-                  target_pid_to_str (inferior_ptid));
+                  target_pid_to_str (inferior_ptid).c_str ());
 }
 
 /* Make it die.  Wait for it to die.  Clean up after it.  Note: this
@@ -3189,20 +3189,15 @@ procfs_target::thread_alive (ptid_t ptid)
   return true;
 }
 
-/* Convert PTID to a string.  Returns the string in a static
-   buffer.  */
+/* Convert PTID to a string.  */
 
-const char *
+std::string
 procfs_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[80];
-
   if (ptid.lwp () == 0)
-    xsnprintf (buf, sizeof (buf), "process %d", ptid.pid ());
+    return string_printf ("process %d", ptid.pid ());
   else
-    xsnprintf (buf, sizeof (buf), "LWP %ld", ptid.lwp ());
-
-  return buf;
+    return string_printf ("LWP %ld", ptid.lwp ());
 }
 
 /* Accepts an integer PID; Returns a string representing a file that
index 9027087d734bf70107a50b4a7d885e41a0267e4a..1c749621ad6a615c257066e21b4a9545579e1a85 100644 (file)
@@ -293,12 +293,12 @@ print_program_space (struct ui_out *uiout, int requested)
                printed_header = 1;
                printf_filtered ("\n\tBound inferiors: ID %d (%s)",
                                 inf->num,
-                                target_pid_to_str (ptid_t (inf->pid)));
+                                target_pid_to_str (ptid_t (inf->pid)).c_str ());
              }
            else
              printf_filtered (", ID %d (%s)",
                               inf->num,
-                              target_pid_to_str (ptid_t (inf->pid)));
+                              target_pid_to_str (ptid_t (inf->pid)).c_str ());
          }
 
       uiout->text ("\n");
index cb4f26a3472457e04ec1e39989213d02f9ac36a4..6636a89554b29ed488182a9a99afe9b59f2927bb 100644 (file)
@@ -110,7 +110,7 @@ struct ravenscar_thread_target final : public target_ops
 
   const char *extra_thread_info (struct thread_info *) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   ptid_t get_ada_task_ptid (long lwp, long thread) override;
 
@@ -406,13 +406,10 @@ ravenscar_thread_target::thread_alive (ptid_t ptid)
   return true;
 }
 
-const char *
+std::string
 ravenscar_thread_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[30];
-
-  snprintf (buf, sizeof (buf), "Thread %#x", (int) ptid.tid ());
-  return buf;
+  return string_printf ("Thread %#x", (int) ptid.tid ());
 }
 
 void
index dc26938f0b9a66e9ce8a7b06f6389d1442c22209..4c896944d7a8830a66777c51bfff7e25bd798291 100644 (file)
@@ -596,7 +596,8 @@ record_btrace_target::info_record ()
 
   printf_unfiltered (_("Recorded %u instructions in %u functions (%u gaps) "
                       "for thread %s (%s).\n"), insns, calls, gaps,
-                    print_thread_id (tp), target_pid_to_str (tp->ptid));
+                    print_thread_id (tp),
+                    target_pid_to_str (tp->ptid).c_str ());
 
   if (btrace_is_replaying (tp))
     printf_unfiltered (_("Replay in progress.  At instruction %u.\n"),
@@ -1949,7 +1950,8 @@ 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), flag, btrace_thread_flag_to_str (flag));
+        target_pid_to_str (tp->ptid).c_str (), flag,
+        btrace_thread_flag_to_str (flag));
 
   btinfo = &tp->btrace;
 
@@ -2127,7 +2129,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),
+  DEBUG ("resume %s: %s%s", target_pid_to_str (ptid).c_str (),
         ::execution_direction == EXEC_REVERSE ? "reverse-" : "",
         step ? "step" : "cont");
 
@@ -2214,7 +2216,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), flags,
+        target_pid_to_str (tp->ptid).c_str (), flags,
         btrace_thread_flag_to_str (flags));
 
   tp->btrace.flags &= ~(BTHR_MOVE | BTHR_STOP);
@@ -2442,7 +2444,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), flags,
+        target_pid_to_str (tp->ptid).c_str (), flags,
         btrace_thread_flag_to_str (flags));
 
   /* We can't step without an execution history.  */
@@ -2527,7 +2529,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
   std::vector<thread_info *> moving;
   std::vector<thread_info *> no_history;
 
-  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid), options);
+  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (), options);
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
@@ -2545,7 +2547,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),
+      DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid).c_str (),
             target_waitstatus_to_string (status).c_str ());
 
       return null_ptid;
@@ -2636,7 +2638,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),
+        target_pid_to_str (eventing->ptid).c_str (),
         target_waitstatus_to_string (status).c_str ());
 
   return eventing->ptid;
@@ -2647,7 +2649,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));
+  DEBUG ("stop %s", target_pid_to_str (ptid).c_str ());
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
index bef04e6bf7cb4a39b374047150c3552438c59d4c..8a6cb6b18e3fe0cb7e2c9e9a83e5da4408f1dc8b 100644 (file)
@@ -124,7 +124,7 @@ struct gdbsim_target final
 
   bool thread_alive (ptid_t ptid) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   bool has_all_memory ()  override;
   bool has_memory ()  override;
@@ -1280,10 +1280,9 @@ gdbsim_target::thread_alive (ptid_t ptid)
   return false;
 }
 
-/* Convert a thread ID to a string.  Returns the string in a static
-   buffer.  */
+/* Convert a thread ID to a string.  */
 
-const char *
+std::string
 gdbsim_target::pid_to_str (ptid_t ptid)
 {
   return normal_pid_to_str (ptid);
index d113f99e48cb0a7940149af09991f1a540ad8bf1..657a4a25cac5609b4a7d3386d5be1fa0bd86421c 100644 (file)
@@ -475,7 +475,7 @@ public:
 
   void update_thread_list () override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   const char *extra_thread_info (struct thread_info *) override;
 
@@ -5814,10 +5814,10 @@ extended_remote_target::attach (const char *args, int from_tty)
 
       if (exec_file)
        printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
       else
        printf_unfiltered (_("Attaching to %s\n"),
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
     }
 
   xsnprintf (rs->buf.data (), get_remote_packet_size (), "vAttach;%x", pid);
@@ -5836,14 +5836,14 @@ extended_remote_target::attach (const char *args, int from_tty)
        }
       else if (strcmp (rs->buf.data (), "OK") != 0)
        error (_("Attaching to %s failed with: %s"),
-              target_pid_to_str (ptid_t (pid)),
+              target_pid_to_str (ptid_t (pid)).c_str (),
               rs->buf.data ());
       break;
     case PACKET_UNKNOWN:
       error (_("This target does not support attaching to a process"));
     default:
       error (_("Attaching to %s failed"),
-            target_pid_to_str (ptid_t (pid)));
+            target_pid_to_str (ptid_t (pid)).c_str ());
     }
 
   set_current_inferior (remote_add_inferior (0, pid, 1, 0));
@@ -6638,7 +6638,7 @@ remote_target::remote_stop_ns (ptid_t ptid)
   putpkt (rs->buf);
   getpkt (&rs->buf, 0);
   if (strcmp (rs->buf.data (), "OK") != 0)
-    error (_("Stopping %s failed: %s"), target_pid_to_str (ptid),
+    error (_("Stopping %s failed: %s"), target_pid_to_str (ptid).c_str (),
           rs->buf.data ());
 }
 
@@ -7096,7 +7096,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));
+                       target_pid_to_str (ptid).c_str ());
 
   return result;
 }
@@ -7134,7 +7134,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),
+                       target_pid_to_str (new_event->ptid).c_str (),
                        int (rs->stop_reply_queue.size ()));
 
   mark_async_event_handler (rs->remote_async_inferior_event_token);
@@ -11397,13 +11397,11 @@ init_remote_threadtests (void)
 
 #endif /* 0 */
 
-/* Convert a thread ID to a string.  Returns the string in a static
-   buffer.  */
+/* Convert a thread ID to a string.  */
 
-const char *
+std::string
 remote_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[64];
   struct remote_state *rs = get_remote_state ();
 
   if (ptid == null_ptid)
@@ -11422,27 +11420,22 @@ remote_target::pid_to_str (ptid_t ptid)
         attached to a process, and reporting yes to qAttached, hence
         no smart special casing here.  */
       if (!remote_multi_process_p (rs))
-       {
-         xsnprintf (buf, sizeof buf, "Remote target");
-         return buf;
-       }
+       return "Remote target";
 
       return normal_pid_to_str (ptid);
     }
   else
     {
       if (magic_null_ptid == ptid)
-       xsnprintf (buf, sizeof buf, "Thread <main>");
+       return "Thread <main>";
       else if (remote_multi_process_p (rs))
        if (ptid.lwp () == 0)
          return normal_pid_to_str (ptid);
        else
-         xsnprintf (buf, sizeof buf, "Thread %d.%ld",
-                    ptid.pid (), ptid.lwp ());
+         return string_printf ("Thread %d.%ld",
+                               ptid.pid (), ptid.lwp ());
       else
-       xsnprintf (buf, sizeof buf, "Thread %ld",
-                  ptid.lwp ());
-      return buf;
+       return string_printf ("Thread %ld", ptid.lwp ());
     }
 }
 
@@ -13786,10 +13779,10 @@ remote_target::enable_btrace (ptid_t ptid, const struct btrace_config *conf)
     {
       if (rs->buf[0] == 'E' && rs->buf[1] == '.')
        error (_("Could not enable branch tracing for %s: %s"),
-              target_pid_to_str (ptid), &rs->buf[2]);
+              target_pid_to_str (ptid).c_str (), &rs->buf[2]);
       else
        error (_("Could not enable branch tracing for %s."),
-              target_pid_to_str (ptid));
+              target_pid_to_str (ptid).c_str ());
     }
 
   tinfo = XCNEW (struct btrace_target_info);
@@ -13834,10 +13827,10 @@ remote_target::disable_btrace (struct btrace_target_info *tinfo)
     {
       if (rs->buf[0] == 'E' && rs->buf[1] == '.')
        error (_("Could not disable branch tracing for %s: %s"),
-              target_pid_to_str (tinfo->ptid), &rs->buf[2]);
+              target_pid_to_str (tinfo->ptid).c_str (), &rs->buf[2]);
       else
        error (_("Could not disable branch tracing for %s."),
-              target_pid_to_str (tinfo->ptid));
+              target_pid_to_str (tinfo->ptid).c_str ());
     }
 
   xfree (tinfo);
index f8e8df532145079f9b7c604075d8fc50333e0681..68fa85130a1d917ad4992424958ef5b70dec69e0 100644 (file)
@@ -87,7 +87,7 @@ public:
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
   ptid_t get_ada_task_ptid (long lwp, long thread) override;
 
   void fetch_registers (struct regcache *, int) override;
@@ -997,11 +997,9 @@ ps_lgetLDT (struct ps_prochandle *ph, lwpid_t lwpid, struct ssd *pldt)     /* ARI: e
 
 /* Convert PTID to printable form.  */
 
-const char *
+std::string
 sol_thread_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[100];
-
   if (ptid.tid_p ())
     {
       ptid_t lwp;
@@ -1009,21 +1007,19 @@ sol_thread_target::pid_to_str (ptid_t ptid)
       lwp = thread_to_lwp (ptid, -2);
 
       if (lwp.pid () == -1)
-       xsnprintf (buf, sizeof (buf), "Thread %ld (defunct)",
-                  ptid.tid ());
+       return string_printf ("Thread %ld (defunct)",
+                             ptid.tid ());
       else if (lwp.pid () != -2)
-       xsnprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)",
-                ptid.tid (), lwp.lwp ());
+       return string_printf ("Thread %ld (LWP %ld)",
+                             ptid.tid (), lwp.lwp ());
       else
-       xsnprintf (buf, sizeof (buf), "Thread %ld        ",
-                  ptid.tid ());
+       return string_printf ("Thread %ld        ",
+                             ptid.tid ());
     }
   else if (ptid.lwp () != 0)
-    xsnprintf (buf, sizeof (buf), "LWP    %ld        ", ptid.lwp ());
+    return string_printf ("LWP    %ld        ", ptid.lwp ());
   else
-    xsnprintf (buf, sizeof (buf), "process %d    ", ptid.pid ());
-
-  return buf;
+    return string_printf ("process %d    ", ptid.pid ());
 }
 \f
 
index 8bab8e268e258d9f2527e51c5f76cdffd63107aa..014b7d79a735dea42f4d638f962050163990f006 100644 (file)
@@ -40,10 +40,9 @@ sol2_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
 /* This is how we want PTIDs from Solaris core files to be
    printed.  */
 
-const char *
+std::string
 sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
 {
-  static char buf[80];
   struct inferior *inf;
   int pid;
 
@@ -53,8 +52,7 @@ sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
   if (pid != 0)
     {
       /* A thread.  */
-      xsnprintf (buf, sizeof buf, "LWP %ld", ptid.lwp ());
-      return buf;
+      return string_printf ("LWP %ld", ptid.lwp ());
     }
 
   /* GDB didn't use to put a NT_PSTATUS note in Solaris cores.  If
@@ -62,10 +60,7 @@ sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
      up.  */
   inf = find_inferior_ptid (ptid);
   if (inf == NULL || inf->fake_pid_p)
-    {
-      xsnprintf (buf, sizeof buf, "<core>");
-      return buf;
-    }
+    return "<core>";
 
   /* Not fake; print as usual.  */
   return normal_pid_to_str (ptid);
index 381e62fb3cc1d60ed43fc47834eeba64d8308b0b..cdc4bbfbe88c4e538313149fe9efbe9ceacdb874 100644 (file)
@@ -24,6 +24,6 @@ struct gdbarch;
 
 CORE_ADDR sol2_skip_solib_resolver (struct gdbarch *, CORE_ADDR);
 
-const char *sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid);
+std::string sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid);
 
 #endif /* sol2-tdep.h */
index d9f7d46dd92e74cd2dcd290a94f03e94b395f33f..bef8a7f330d9744a167c2453da6448301c424f9f 100644 (file)
   target_debug_do_print (host_address_to_string (X))
 #define target_debug_print_thread_info_pp(X)           \
   target_debug_do_print (host_address_to_string (X))
+#define target_debug_print_std_string(X) \
+  target_debug_do_print ((X).c_str ())
 
 static void
 target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
index a25851e9cf7b8402bf9e18f3864f39186a86c7a9..3654f02e63ba1af7a6d866ef10fd9253ce2cbcf4 100644 (file)
@@ -66,7 +66,7 @@ struct dummy_target : public target_ops
   void program_signals (gdb::array_view<const unsigned char> arg0) override;
   bool thread_alive (ptid_t arg0) override;
   void update_thread_list () override;
-  const char *pid_to_str (ptid_t arg0) override;
+  std::string pid_to_str (ptid_t arg0) override;
   const char *extra_thread_info (thread_info *arg0) override;
   const char *thread_name (thread_info *arg0) override;
   thread_info *thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, inferior *arg2) override;
@@ -233,7 +233,7 @@ struct debug_target : public target_ops
   void program_signals (gdb::array_view<const unsigned char> arg0) override;
   bool thread_alive (ptid_t arg0) override;
   void update_thread_list () override;
-  const char *pid_to_str (ptid_t arg0) override;
+  std::string pid_to_str (ptid_t arg0) override;
   const char *extra_thread_info (thread_info *arg0) override;
   const char *thread_name (thread_info *arg0) override;
   thread_info *thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, inferior *arg2) override;
@@ -1746,28 +1746,28 @@ debug_target::update_thread_list ()
   fputs_unfiltered (")\n", gdb_stdlog);
 }
 
-const char *
+std::string
 target_ops::pid_to_str (ptid_t arg0)
 {
   return this->beneath ()->pid_to_str (arg0);
 }
 
-const char *
+std::string
 dummy_target::pid_to_str (ptid_t arg0)
 {
   return default_pid_to_str (this, arg0);
 }
 
-const char *
+std::string
 debug_target::pid_to_str (ptid_t arg0)
 {
-  const char * result;
+  std::string result;
   fprintf_unfiltered (gdb_stdlog, "-> %s->pid_to_str (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->pid_to_str (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->pid_to_str (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
   fputs_unfiltered (") = ", gdb_stdlog);
-  target_debug_print_const_char_p (result);
+  target_debug_print_std_string (result);
   fputs_unfiltered ("\n", gdb_stdlog);
   return result;
 }
index c27157d209f9bd75c1fe3bad919f6bd7209a8d25..5f596b6a3c93c0b9fa0dc76a86d271fe9d5fa761 100644 (file)
@@ -92,7 +92,7 @@ static int dummy_find_memory_regions (struct target_ops *self,
 static char *dummy_make_corefile_notes (struct target_ops *self,
                                        bfd *ignore1, int *ignore2);
 
-static const char *default_pid_to_str (struct target_ops *ops, ptid_t ptid);
+static std::string default_pid_to_str (struct target_ops *ops, ptid_t ptid);
 
 static enum exec_direction_kind default_execution_direction
     (struct target_ops *self);
@@ -744,24 +744,26 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
                         " thread-local variables in\n"
                         "the shared library `%s'\n"
                         "for %s"),
-                      objfile_name (objfile), target_pid_to_str (ptid));
+                      objfile_name (objfile),
+                      target_pid_to_str (ptid).c_str ());
              else
                error (_("The inferior has not yet allocated storage for"
                         " thread-local variables in\n"
                         "the executable `%s'\n"
                         "for %s"),
-                      objfile_name (objfile), target_pid_to_str (ptid));
+                      objfile_name (objfile),
+                      target_pid_to_str (ptid).c_str ());
              break;
            case TLS_GENERIC_ERROR:
              if (objfile_is_library)
                error (_("Cannot find thread-local storage for %s, "
                         "shared library %s:\n%s"),
-                      target_pid_to_str (ptid),
+                      target_pid_to_str (ptid).c_str (),
                       objfile_name (objfile), ex.message);
              else
                error (_("Cannot find thread-local storage for %s, "
                         "executable file %s:\n%s"),
-                      target_pid_to_str (ptid),
+                      target_pid_to_str (ptid).c_str (),
                       objfile_name (objfile), ex.message);
              break;
            default:
@@ -2073,7 +2075,7 @@ default_target_wait (struct target_ops *ops,
   return minus_one_ptid;
 }
 
-const char *
+std::string
 target_pid_to_str (ptid_t ptid)
 {
   return current_top_target ()->pid_to_str (ptid);
@@ -3168,7 +3170,7 @@ target_announce_detach (int from_tty)
 
   pid = inferior_ptid.pid ();
   printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
-                    target_pid_to_str (ptid_t (pid)));
+                    target_pid_to_str (ptid_t (pid)).c_str ());
 }
 
 /* The inferior process has died.  Long live the inferior!  */
@@ -3205,16 +3207,13 @@ generic_mourn_inferior (void)
 /* Convert a normal process ID to a string.  Returns the string in a
    static buffer.  */
 
-const char *
+std::string
 normal_pid_to_str (ptid_t ptid)
 {
-  static char buf[32];
-
-  xsnprintf (buf, sizeof buf, "process %d", ptid.pid ());
-  return buf;
+  return string_printf ("process %d", ptid.pid ());
 }
 
-static const char *
+static std::string
 default_pid_to_str (struct target_ops *ops, ptid_t ptid)
 {
   return normal_pid_to_str (ptid);
index 5fe6aa74b0c48f819de960921843ddf9dc34e15d..4f7a43e1a8b30a986e062d109540b156f498cb54 100644 (file)
@@ -649,7 +649,7 @@ struct target_ops
       TARGET_DEFAULT_RETURN (false);
     virtual void update_thread_list ()
       TARGET_DEFAULT_IGNORE ();
-    virtual const char *pid_to_str (ptid_t)
+    virtual std::string pid_to_str (ptid_t)
       TARGET_DEFAULT_FUNC (default_pid_to_str);
     virtual const char *extra_thread_info (thread_info *)
       TARGET_DEFAULT_RETURN (NULL);
@@ -1829,9 +1829,9 @@ extern int target_is_non_stop_p (void);
    `process xyz', but on some systems it may contain
    `process xyz thread abc'.  */
 
-extern const char *target_pid_to_str (ptid_t ptid);
+extern std::string target_pid_to_str (ptid_t ptid);
 
-extern const char *normal_pid_to_str (ptid_t ptid);
+extern std::string normal_pid_to_str (ptid_t ptid);
 
 /* Return a short string describing extra information about PID,
    e.g. "sleeping", "runnable", "running on LWP 3".  Null return value
index 6c232529646d7a287e14a76f03bc68bae4c5e2e3..91741c76f0d322b57aee824b4c6c60aaea1425e6 100644 (file)
@@ -319,7 +319,7 @@ add_thread_with_info (ptid_t ptid, private_thread_info *priv)
   result->priv.reset (priv);
 
   if (print_thread_events)
-    printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
+    printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid).c_str ());
 
   annotate_new_thread ();
   return result;
@@ -992,16 +992,17 @@ should_print_thread (const char *requested_threads, int default_inf_num,
 static std::string
 thread_target_id_str (thread_info *tp)
 {
-  const char *target_id = target_pid_to_str (tp->ptid);
+  std::string target_id = target_pid_to_str (tp->ptid);
   const char *extra_info = target_extra_thread_info (tp);
   const char *name = tp->name != nullptr ? tp->name : target_thread_name (tp);
 
   if (extra_info != nullptr && name != nullptr)
-    return string_printf ("%s \"%s\" (%s)", target_id, name, extra_info);
+    return string_printf ("%s \"%s\" (%s)", target_id.c_str (), name,
+                         extra_info);
   else if (extra_info != nullptr)
-    return string_printf ("%s (%s)", target_id, extra_info);
+    return string_printf ("%s (%s)", target_id.c_str (), extra_info);
   else if (name != nullptr)
-    return string_printf ("%s \"%s\"", target_id, name);
+    return string_printf ("%s \"%s\"", target_id.c_str (), name);
   else
     return target_id;
 }
@@ -1466,7 +1467,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
          if (!flags.quiet)
            printf_filtered (_("\nThread %s (%s):\n"),
                             print_thread_id (thr),
-                            target_pid_to_str (inferior_ptid));
+                            target_pid_to_str (inferior_ptid).c_str ());
          printf_filtered ("%s", cmd_result.c_str ());
        }
     }
@@ -1477,7 +1478,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
          if (!flags.quiet)
            printf_filtered (_("\nThread %s (%s):\n"),
                             print_thread_id (thr),
-                            target_pid_to_str (inferior_ptid));
+                            target_pid_to_str (inferior_ptid).c_str ());
          if (flags.cont)
            printf_filtered ("%s\n", ex.message);
          else
@@ -1675,11 +1676,11 @@ thread_command (const char *tidstr, int from_tty)
          if (tp->state == THREAD_EXITED)
            printf_filtered (_("[Current thread is %s (%s) (exited)]\n"),
                             print_thread_id (tp),
-                            target_pid_to_str (inferior_ptid));
+                            target_pid_to_str (inferior_ptid).c_str ());
          else
            printf_filtered (_("[Current thread is %s (%s)]\n"),
                             print_thread_id (tp),
-                            target_pid_to_str (inferior_ptid));
+                            target_pid_to_str (inferior_ptid).c_str ());
        }
       else
        error (_("No stack."));
@@ -1756,11 +1757,11 @@ thread_find_command (const char *arg, int from_tty)
          match++;
        }
 
-      tmp = target_pid_to_str (tp->ptid);
-      if (tmp != NULL && re_exec (tmp))
+      std::string name = target_pid_to_str (tp->ptid);
+      if (!name.empty () && re_exec (name.c_str ()))
        {
          printf_filtered (_("Thread %s has target id '%s'\n"),
-                          print_thread_id (tp), tmp);
+                          print_thread_id (tp), name.c_str ());
          match++;
        }
 
@@ -1824,7 +1825,7 @@ print_selected_thread_frame (struct ui_out *uiout,
          uiout->text ("[Switching to thread ");
          uiout->field_string ("new-thread-id", print_thread_id (tp));
          uiout->text (" (");
-         uiout->text (target_pid_to_str (inferior_ptid));
+         uiout->text (target_pid_to_str (inferior_ptid).c_str ());
          uiout->text (")]");
        }
     }
index 4065df708154499be33a849d9d02c5e4946f5e0c..b10b0649e9c571c241a7eb4bb49a66fd585b2921 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1548,11 +1548,11 @@ print_inferior_quit_action (struct inferior *inf, void *arg)
   if (inf->attach_flag)
     fprintf_filtered (stb,
                      _("\tInferior %d [%s] will be detached.\n"), inf->num,
-                     target_pid_to_str (ptid_t (inf->pid)));
+                     target_pid_to_str (ptid_t (inf->pid)).c_str ());
   else
     fprintf_filtered (stb,
                      _("\tInferior %d [%s] will be killed.\n"), inf->num,
-                     target_pid_to_str (ptid_t (inf->pid)));
+                     target_pid_to_str (ptid_t (inf->pid)).c_str ());
 
   return 0;
 }
index bd58fde1de30bf71987a3f065cd0ed0f07b9224a..b85b7a5d43771bd4635dbd3755a58a15d2c5bba0 100644 (file)
@@ -72,10 +72,14 @@ tui_make_status_line (struct tui_locator_element *loc)
   int pid_width;
   int line_width;
 
+  std::string pid_name_holder;
   if (inferior_ptid == null_ptid)
     pid_name = "No process";
   else
-    pid_name = target_pid_to_str (inferior_ptid);
+    {
+      pid_name_holder = target_pid_to_str (inferior_ptid);
+      pid_name = pid_name_holder.c_str ();
+    }
 
   target_width = strlen (target_shortname);
   if (target_width > MAX_TARGET_WIDTH)
index 99bcedcc2cf9f16188cc767c79b66787ef97cd9a..5caaa3b56508aff544db9ceb25aaa68dc6d0178b 100644 (file)
@@ -341,7 +341,7 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
 
   bool thread_alive (ptid_t ptid) override;
 
-  const char *pid_to_str (ptid_t) override;
+  std::string pid_to_str (ptid_t) override;
 
   void interrupt () override;
 
@@ -525,10 +525,11 @@ windows_delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p)
      here as well.  */
 
   if (info_verbose)
-    printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (ptid));
+    printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (ptid).c_str ());
   else if (print_thread_events && !main_thread_p)
     printf_unfiltered (_("[%s exited with code %u]\n"),
-                      target_pid_to_str (ptid), (unsigned) exit_code);
+                      target_pid_to_str (ptid).c_str (),
+                      (unsigned) exit_code);
 
   delete_thread (find_thread_ptid (ptid));
 
@@ -2011,10 +2012,10 @@ windows_nat_target::attach (const char *args, int from_tty)
 
       if (exec_file)
        printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
       else
        printf_unfiltered ("Attaching to %s\n",
-                          target_pid_to_str (ptid_t (pid)));
+                          target_pid_to_str (ptid_t (pid)).c_str ());
     }
 
   do_initial_windows_stuff (this, pid, 1);
@@ -2142,7 +2143,7 @@ windows_nat_target::files_info ()
 
   printf_unfiltered ("\tUsing the running image of %s %s.\n",
                     inf->attach_flag ? "attached" : "child",
-                    target_pid_to_str (inferior_ptid));
+                    target_pid_to_str (inferior_ptid).c_str ());
 }
 
 /* Modify CreateProcess parameters for use of a new separate console.
@@ -2934,17 +2935,11 @@ windows_nat_target::close ()
 }
 
 /* Convert pid to printable format.  */
-const char *
+std::string
 windows_nat_target::pid_to_str (ptid_t ptid)
 {
-  static char buf[80];
-
   if (ptid.tid () != 0)
-    {
-      snprintf (buf, sizeof (buf), "Thread %d.0x%lx",
-               ptid.pid (), ptid.tid ());
-      return buf;
-    }
+    return string_printf ("Thread %d.0x%lx", ptid.pid (), ptid.tid ());
 
   return normal_pid_to_str (ptid);
 }
index 2f223b3dfe93956ba00c3dce483ec09330d3990a..42083e789a580811070645ddbaaae267b9608470 100644 (file)
@@ -327,7 +327,7 @@ display_one_tib (ptid_t ptid)
   if (target_get_tib_address (ptid, &thread_local_base) == 0)
     {
       printf_filtered (_("Unable to get thread local base for %s\n"),
-       target_pid_to_str (ptid));
+                      target_pid_to_str (ptid).c_str ());
       return -1;
     }
 
@@ -336,13 +336,13 @@ display_one_tib (ptid_t ptid)
     {
       printf_filtered (_("Unable to read thread information "
                         "block for %s at address %s\n"),
-       target_pid_to_str (ptid), 
-       paddress (target_gdbarch (), thread_local_base));
+                      target_pid_to_str (ptid).c_str (), 
+                      paddress (target_gdbarch (), thread_local_base));
       return -1;
     }
 
   printf_filtered (_("Thread Information Block %s at %s\n"),
-                  target_pid_to_str (ptid),
+                  target_pid_to_str (ptid).c_str (),
                   paddress (target_gdbarch (), thread_local_base));
 
   index = (gdb_byte *) tib;
index fd15dc9b87209de27f267ab37c62e69dca70fb63..9a451e0e1aa0a41d49273c34231d6ef0ad95ae0f 100644 (file)
@@ -224,7 +224,7 @@ x86_linux_nat_target::enable_btrace (ptid_t ptid,
   CATCH (exception, RETURN_MASK_ERROR)
     {
       error (_("Could not enable branch tracing for %s: %s"),
-            target_pid_to_str (ptid), exception.message);
+            target_pid_to_str (ptid).c_str (), exception.message);
     }
   END_CATCH