Change pid_to_str to return std::string

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.
This commit is contained in:
Tom Tromey 2019-02-28 09:09:55 -07:00
parent b4be1b0648
commit a068643d69
53 changed files with 499 additions and 408 deletions

View 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> 2019-03-13 Simon Marchi <simon.marchi@ericsson.com>
* NEWS: Mention that the new default MI version is 3. Mention * NEWS: Mention that the new default MI version is 3. Mention

View file

@ -140,7 +140,7 @@ public:
bool thread_alive (ptid_t ptid) override; 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; 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 /* Return a printable representation of composite PID for use in
"info threads" output. */ "info threads" output. */
const char * std::string
aix_thread_target::pid_to_str (ptid_t ptid) aix_thread_target::pid_to_str (ptid_t ptid)
{ {
static char *ret = NULL;
if (!PD_TID (ptid)) if (!PD_TID (ptid))
return beneath ()->pid_to_str (ptid); return beneath ()->pid_to_str (ptid);
/* Free previous return value; a new one will be allocated by return string_printf (_("Thread %ld"), ptid.tid ());
xstrprintf(). */
xfree (ret);
ret = xstrprintf (_("Thread %ld"), ptid.tid ());
return ret;
} }
/* Return a printable representation of extra information about /* Return a printable representation of extra information about

View file

@ -92,7 +92,7 @@ public:
void files_info () override; void files_info () override;
bool thread_alive (ptid_t ptid) 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_memory () override { return true; }
bool has_stack () override { return true; } bool has_stack () override { return true; }
@ -368,12 +368,10 @@ bsd_kvm_target::thread_alive (ptid_t ptid)
return true; return true;
} }
const char * std::string
bsd_kvm_target::pid_to_str (ptid_t ptid) bsd_kvm_target::pid_to_str (ptid_t ptid)
{ {
static char buf[64]; return "<kvm>";
xsnprintf (buf, sizeof buf, "<kvm>");
return buf;
} }
/* Add the libkvm interface to the list of all possible targets and /* Add the libkvm interface to the list of all possible targets and

View file

@ -62,7 +62,7 @@ struct bsd_uthread_target final : public target_ops
const char *extra_thread_info (struct thread_info *) override; 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; static bsd_uthread_target bsd_uthread_ops;
@ -530,17 +530,12 @@ bsd_uthread_target::extra_thread_info (thread_info *info)
return NULL; return NULL;
} }
const char * std::string
bsd_uthread_target::pid_to_str (ptid_t ptid) bsd_uthread_target::pid_to_str (ptid_t ptid)
{ {
if (ptid.tid () != 0) if (ptid.tid () != 0)
{ return string_printf ("process %d, thread 0x%lx",
static char buf[64]; ptid.pid (), ptid.tid ());
xsnprintf (buf, sizeof buf, "process %d, thread 0x%lx",
ptid.pid (), ptid.tid ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }

View file

@ -1608,7 +1608,7 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf)
#endif /* !defined (HAVE_LIBIPT) */ #endif /* !defined (HAVE_LIBIPT) */
DEBUG ("enable thread %s (%s)", print_thread_id (tp), 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); tp->btrace.target = target_enable_btrace (tp->ptid, conf);
@ -1663,7 +1663,7 @@ btrace_disable (struct thread_info *tp)
return; return;
DEBUG ("disable thread %s (%s)", print_thread_id (tp), 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); target_disable_btrace (btp->target);
btp->target = NULL; btp->target = NULL;
@ -1682,7 +1682,7 @@ btrace_teardown (struct thread_info *tp)
return; return;
DEBUG ("teardown thread %s (%s)", print_thread_id (tp), 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); target_teardown_btrace (btp->target);
btp->target = NULL; btp->target = NULL;
@ -1905,7 +1905,7 @@ btrace_fetch (struct thread_info *tp, const struct btrace_cpu *cpu)
int errcode; int errcode;
DEBUG ("fetch thread %s (%s)", print_thread_id (tp), 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; btinfo = &tp->btrace;
tinfo = btinfo->target; tinfo = btinfo->target;
@ -1981,7 +1981,7 @@ btrace_clear (struct thread_info *tp)
struct btrace_thread_info *btinfo; struct btrace_thread_info *btinfo;
DEBUG ("clear thread %s (%s)", print_thread_id (tp), 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 /* Make sure btrace frames that may hold a pointer into the branch
trace data are destroyed. */ trace data are destroyed. */

View file

@ -83,7 +83,7 @@ public:
bool thread_alive (ptid_t ptid) override; bool thread_alive (ptid_t ptid) override;
const struct target_desc *read_description () 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; const char *thread_name (struct thread_info *) override;
@ -985,10 +985,9 @@ core_target::read_description ()
return this->beneath ()->read_description (); return this->beneath ()->read_description ();
} }
const char * std::string
core_target::pid_to_str (ptid_t ptid) core_target::pid_to_str (ptid_t ptid)
{ {
static char buf[64];
struct inferior *inf; struct inferior *inf;
int pid; int pid;
@ -1013,8 +1012,7 @@ core_target::pid_to_str (ptid_t ptid)
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
/* No luck. We simply don't have a valid PID to print. */ /* No luck. We simply don't have a valid PID to print. */
xsnprintf (buf, sizeof buf, "<main task>"); return "<main task>";
return buf;
} }
const char * const char *

View file

@ -2052,10 +2052,10 @@ darwin_nat_target::attach (const char *args, int from_tty)
if (exec_file) if (exec_file)
printf_unfiltered (_("Attaching to program: %s, %s\n"), 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 else
printf_unfiltered (_("Attaching to %s\n"), 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) if (pid == 0 || ::kill (pid, 0) < 0)
@ -2126,18 +2126,14 @@ darwin_nat_target::detach (inferior *inf, int from_tty)
mourn_inferior (); mourn_inferior ();
} }
const char * std::string
darwin_nat_target::pid_to_str (ptid_t ptid) darwin_nat_target::pid_to_str (ptid_t ptid)
{ {
static char buf[80];
long tid = ptid.tid (); long tid = ptid.tid ();
if (tid != 0) if (tid != 0)
{ return string_printf (_("Thread 0x%lx of process %u"),
snprintf (buf, sizeof (buf), _("Thread 0x%lx of process %u"), tid, ptid.pid ());
tid, ptid.pid ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }

View file

@ -45,7 +45,7 @@ class darwin_nat_target : public inf_child_target
bool thread_alive (ptid_t ptid) override; 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; char *pid_to_exec_file (int pid) override;

View file

@ -615,7 +615,7 @@ dcache_info_1 (DCACHE *dcache, const char *exp)
} }
printf_filtered (_("Contains data for %s\n"), printf_filtered (_("Contains data for %s\n"),
target_pid_to_str (dcache->ptid)); target_pid_to_str (dcache->ptid).c_str ());
refcount = 0; refcount = 0;

View file

@ -409,7 +409,7 @@ fprint_dummy_frames (struct ui_file *file)
fprintf_unfiltered (file, " id="); fprintf_unfiltered (file, " id=");
fprint_frame_id (file, s->id.id); fprint_frame_id (file, s->id.id);
fprintf_unfiltered (file, ", ptid=%s", 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"); fprintf_unfiltered (file, "\n");
} }
} }

View file

@ -897,10 +897,9 @@ fbsd_nat_target::thread_alive (ptid_t ptid)
return true; return true;
} }
/* Convert PTID to a string. Returns the string in a static /* Convert PTID to a string. */
buffer. */
const char * std::string
fbsd_nat_target::pid_to_str (ptid_t ptid) fbsd_nat_target::pid_to_str (ptid_t ptid)
{ {
lwpid_t lwp; lwpid_t lwp;
@ -908,11 +907,9 @@ fbsd_nat_target::pid_to_str (ptid_t ptid)
lwp = ptid.lwp (); lwp = ptid.lwp ();
if (lwp != 0) if (lwp != 0)
{ {
static char buf[64];
int pid = ptid.pid (); int pid = ptid.pid ();
xsnprintf (buf, sizeof buf, "LWP %d of process %d", lwp, pid); return string_printf ("LWP %d of process %d", lwp, pid);
return buf;
} }
return normal_pid_to_str (ptid); 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", "FLWP: deleting thread for LWP %u\n",
pl.pl_lwpid); pl.pl_lwpid);
if (print_thread_events) if (print_thread_events)
printf_unfiltered (_("[%s exited]\n"), target_pid_to_str printf_unfiltered (_("[%s exited]\n"),
(wptid)); target_pid_to_str (wptid).c_str ());
delete_thread (thr); delete_thread (thr);
} }
if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1) if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1)

View file

@ -51,7 +51,7 @@ public:
#ifdef PT_LWPINFO #ifdef PT_LWPINFO
bool thread_alive (ptid_t ptid) override; 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 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
const char *thread_name (struct thread_info *) override; const char *thread_name (struct thread_info *) override;

View 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. */ /* 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) fbsd_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
{ {
static char buf[80];
if (ptid.lwp () != 0) if (ptid.lwp () != 0)
{ return string_printf ("LWP %ld", ptid.lwp ());
xsnprintf (buf, sizeof buf, "LWP %ld", ptid.lwp ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }

View file

@ -3766,7 +3766,7 @@ gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch)
return gdbarch->core_pid_to_str != NULL; return gdbarch->core_pid_to_str != NULL;
} }
const char * std::string
gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
{ {
gdb_assert (gdbarch != NULL); gdb_assert (gdbarch != NULL);

View 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); 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); typedef std::string (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); 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); 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. */ /* How the core target extracts the name of a thread from a core file. */

View file

@ -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 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. # 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. # 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 M;const char *;core_thread_name;struct thread_info *thr;thr

View file

@ -1493,7 +1493,7 @@ gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
waiting_inf = inf; 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: rewait:
if (proc_wait_pid != inf->pid && !inf->no_wait) if (proc_wait_pid != inf->pid && !inf->no_wait)
@ -1648,7 +1648,7 @@ rewait:
} }
inf_debug (inf, "returning ptid = %s, status = %s (%d)", 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_EXITED ? "EXITED"
: status->kind == TARGET_WAITKIND_STOPPED ? "STOPPED" : status->kind == TARGET_WAITKIND_STOPPED ? "STOPPED"
: status->kind == TARGET_WAITKIND_SIGNALLED ? "SIGNALLED" : 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; struct inf *inf = gnu_current_inf;
inf_debug (inf, "ptid = %s, step = %d, sig = %d", 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); inf_validate_procinfo (inf);
@ -2058,8 +2058,9 @@ gnu_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
if (!thread) if (!thread)
error (_("Can't run single thread id %s: no such thread!"), error (_("Can't run single thread id %s: no such thread!"),
target_pid_to_str (ptid)); target_pid_to_str (ptid).c_str ());
inf_debug (inf, "running one thread: %s", target_pid_to_str (ptid)); inf_debug (inf, "running one thread: %s",
target_pid_to_str (ptid).c_str ());
inf_set_threads_resume_sc (inf, thread, 0); 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 ()); step_thread = inf_tid_to_thread (inf, ptid.lwp ());
if (!step_thread) if (!step_thread)
warning (_("Can't step thread id %s: no such thread."), warning (_("Can't step thread id %s: no such thread."),
target_pid_to_str (ptid)); target_pid_to_str (ptid).c_str ());
else 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) if (step_thread != inf->step_thread)
inf_set_step_thread (inf, step_thread); inf_set_step_thread (inf, step_thread);
@ -2714,7 +2716,7 @@ proc_string (struct proc *proc)
return tid_str; return tid_str;
} }
const char * std::string
gnu_nat_target::pid_to_str (ptid_t ptid) gnu_nat_target::pid_to_str (ptid_t ptid)
{ {
struct inf *inf = gnu_current_inf; struct inf *inf = gnu_current_inf;
@ -2724,12 +2726,7 @@ gnu_nat_target::pid_to_str (ptid_t ptid)
if (thread) if (thread)
return proc_string (thread); return proc_string (thread);
else else
{ return string_printf ("bogus thread id %d", tid);
static char tid_str[80];
xsnprintf (tid_str, sizeof (tid_str), "bogus thread id %d", tid);
return tid_str;
}
} }

View file

@ -146,7 +146,7 @@ struct gnu_nat_target : public inf_child_target
char **, int) override; char **, int) override;
void mourn_inferior () override; void mourn_inferior () override;
bool thread_alive (ptid_t ptid) 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; void stop (ptid_t) override;
}; };

View file

@ -377,7 +377,7 @@ struct go32_nat_target final : public x86_nat_target<inf_child_target>
bool thread_alive (ptid_t ptid) override; 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; static go32_nat_target the_go32_nat_target;
@ -992,7 +992,7 @@ go32_nat_target::thread_alive (ptid_t ptid)
return ptid != null_ptid; return ptid != null_ptid;
} }
const char * std::string
go32_nat_target::pid_to_str (ptid_t ptid) go32_nat_target::pid_to_str (ptid_t ptid)
{ {
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);

View 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. */ /* 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) i386_windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
{ {
static char buf[80];
if (ptid.lwp () != 0) if (ptid.lwp () != 0)
{ return string_printf ("Thread 0x%lx", ptid.lwp ());
snprintf (buf, sizeof (buf), "Thread 0x%lx", ptid.lwp ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }

View 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 ()); thread = inf_tid_to_thread (gnu_current_inf, ptid.lwp ());
if (!thread) if (!thread)
error (_("Can't fetch registers from thread %s: No such 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) 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 ()); thread = inf_tid_to_thread (gnu_current_inf, ptid.lwp ());
if (!thread) if (!thread)
error (_("Couldn't store registers into thread %s: No such 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) if (regno < I386_NUM_GREGS || regno == -1)
{ {

View file

@ -213,10 +213,10 @@ inf_ptrace_target::attach (const char *args, int from_tty)
if (exec_file) if (exec_file)
printf_unfiltered (_("Attaching to program: %s, %s\n"), 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 else
printf_unfiltered (_("Attaching to %s\n"), 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 #ifdef PT_ATTACH
@ -624,10 +624,10 @@ inf_ptrace_target::files_info ()
printf_filtered (_("\tUsing the running image of %s %s.\n"), printf_filtered (_("\tUsing the running image of %s %s.\n"),
inf->attach_flag ? "attached" : "child", 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) inf_ptrace_target::pid_to_str (ptid_t ptid)
{ {
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);

View file

@ -59,7 +59,7 @@ struct inf_ptrace_target : public inf_child_target
bool thread_alive (ptid_t ptid) override; 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, enum target_xfer_status xfer_partial (enum target_object object,
const char *annex, const char *annex,

View file

@ -126,7 +126,7 @@ add_inferior (int pid)
if (pid != 0) if (pid != 0)
printf_unfiltered (_("[New inferior %d (%s)]\n"), printf_unfiltered (_("[New inferior %d (%s)]\n"),
inf->num, inf->num,
target_pid_to_str (ptid_t (pid))); target_pid_to_str (ptid_t (pid)).c_str ());
else else
printf_unfiltered (_("[New inferior %d]\n"), inf->num); printf_unfiltered (_("[New inferior %d]\n"), inf->num);
} }
@ -243,7 +243,7 @@ detach_inferior (inferior *inf)
if (print_inferior_events) if (print_inferior_events)
printf_unfiltered (_("[Inferior %d (%s) detached]\n"), printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
inf->num, inf->num,
target_pid_to_str (ptid_t (pid))); target_pid_to_str (ptid_t (pid)).c_str ());
} }
void void
@ -407,7 +407,7 @@ number_of_inferiors (void)
/* Converts an inferior process id to a string. Like /* Converts an inferior process id to a string. Like
target_pid_to_str, but special cases the null process. */ target_pid_to_str, but special cases the null process. */
static const char * static std::string
inferior_pid_to_str (int pid) inferior_pid_to_str (int pid)
{ {
if (pid != 0) if (pid != 0)
@ -428,7 +428,7 @@ print_selected_inferior (struct ui_out *uiout)
filename = _("<noexec>"); filename = _("<noexec>");
uiout->message (_("[Switching to inferior %d [%s] (%s)]\n"), 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 /* Prints the list of inferiors and their details on UIOUT. This is a

View file

@ -471,7 +471,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \
fprintf_filtered (gdb_stdlog, fprintf_filtered (gdb_stdlog,
_("[Detaching after %s from child %s]\n"), _("[Detaching after %s from child %s]\n"),
has_vforked ? "vfork" : "fork", has_vforked ? "vfork" : "fork",
target_pid_to_str (process_ptid)); target_pid_to_str (process_ptid).c_str ());
} }
} }
else else
@ -607,7 +607,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \
fprintf_filtered (gdb_stdlog, fprintf_filtered (gdb_stdlog,
_("[Detaching after fork from " _("[Detaching after fork from "
"parent %s]\n"), "parent %s]\n"),
target_pid_to_str (process_ptid)); target_pid_to_str (process_ptid).c_str ());
} }
target_detach (parent_inf, 0); target_detach (parent_inf, 0);
@ -876,7 +876,7 @@ proceed_after_vfork_done (struct thread_info *thread,
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: resuming vfork parent thread %s\n", "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); switch_to_thread (thread);
clear_proceed_status (0); clear_proceed_status (0);
@ -963,7 +963,7 @@ handle_vfork_child_exec_or_exit (int exec)
if (print_inferior_events) if (print_inferior_events)
{ {
const char *pidstr std::string pidstr
= target_pid_to_str (ptid_t (inf->vfork_parent->pid)); = target_pid_to_str (ptid_t (inf->vfork_parent->pid));
target_terminal::ours_for_output (); target_terminal::ours_for_output ();
@ -972,13 +972,13 @@ handle_vfork_child_exec_or_exit (int exec)
{ {
fprintf_filtered (gdb_stdlog, fprintf_filtered (gdb_stdlog,
_("[Detaching vfork parent %s " _("[Detaching vfork parent %s "
"after child exec]\n"), pidstr); "after child exec]\n"), pidstr.c_str ());
} }
else else
{ {
fprintf_filtered (gdb_stdlog, fprintf_filtered (gdb_stdlog,
_("[Detaching vfork parent %s " _("[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? */ /* What is this a.out's name? */
process_ptid = ptid_t (pid); process_ptid = ptid_t (pid);
printf_unfiltered (_("%s is executing new program: %s\n"), 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); exec_file_target);
/* We've followed the inferior through an exec. Therefore, the /* We've followed the inferior through an exec. Therefore, the
@ -1668,7 +1668,7 @@ displaced_step_prepare_throw (thread_info *tp)
if (debug_displaced) if (debug_displaced)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"displaced: deferring step of %s\n", "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); thread_step_over_chain_enqueue (tp);
return 0; return 0;
@ -1678,7 +1678,7 @@ displaced_step_prepare_throw (thread_info *tp)
if (debug_displaced) if (debug_displaced)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"displaced: stepping %s now\n", "displaced: stepping %s now\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
} }
displaced_step_clear (displaced); displaced_step_clear (displaced);
@ -1831,7 +1831,7 @@ displaced_step_restore (struct displaced_step_inferior_state *displaced,
displaced->step_saved_copy.data (), len); displaced->step_saved_copy.data (), len);
if (debug_displaced) if (debug_displaced)
fprintf_unfiltered (gdb_stdlog, "displaced: restored %s %s\n", 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, paddress (displaced->step_gdbarch,
displaced->step_copy)); displaced->step_copy));
} }
@ -1985,7 +1985,7 @@ start_step_over (void)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
"[%s] has inconsistent state: " "[%s] has inconsistent state: "
"trap_expected=%d, resumed=%d, executing=%d\n", "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->control.trap_expected,
tp->resumed, tp->resumed,
tp->executing); tp->executing);
@ -1994,7 +1994,7 @@ start_step_over (void)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: resuming [%s] for step-over\n", "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 /* keep_going_pass_signal skips the step-over if the breakpoint
is no longer inserted. In all-stop, we want to keep looking 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, fprintf_unfiltered (gdb_stdlog,
"infrun: resume: thread %s has pending wait " "infrun: resume: thread %s has pending wait "
"status %s (currently_stepping=%d).\n", "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)); currently_stepping (tp));
} }
@ -2265,7 +2266,8 @@ resume_1 (enum gdb_signal sig)
if (sig != GDB_SIGNAL_0) if (sig != GDB_SIGNAL_0)
{ {
warning (_("Couldn't deliver signal %s to %s."), 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; 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", "trap_expected=%d, current thread [%s] at %s\n",
step, gdb_signal_to_symbol_string (sig), step, gdb_signal_to_symbol_string (sig),
tp->control.trap_expected, tp->control.trap_expected,
target_pid_to_str (inferior_ptid), target_pid_to_str (inferior_ptid).c_str (),
paddress (gdbarch, pc)); paddress (gdbarch, pc));
/* Normally, by the time we reach `resume', the breakpoints are either /* Normally, by the time we reach `resume', the breakpoints are either
@ -2558,7 +2560,7 @@ resume_1 (enum gdb_signal sig)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: resume: [%s] stepped breakpoint\n", "infrun: resume: [%s] stepped breakpoint\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
tp->stepped_breakpoint = 1; tp->stepped_breakpoint = 1;
@ -2663,7 +2665,7 @@ clear_proceed_status_thread (struct thread_info *tp)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: clear_proceed_status_thread (%s)\n", "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 /* If we're starting a new sequence, then the previous finished
single-step is no longer relevant. */ single-step is no longer relevant. */
@ -2676,7 +2678,7 @@ clear_proceed_status_thread (struct thread_info *tp)
"infrun: clear_proceed_status: pending " "infrun: clear_proceed_status: pending "
"event of %s was a finished step. " "event of %s was a finished step. "
"Discarding.\n", "Discarding.\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
tp->suspend.waitstatus_pending_p = 0; tp->suspend.waitstatus_pending_p = 0;
tp->suspend.stop_reason = TARGET_STOPPED_BY_NO_REASON; 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 " "infrun: clear_proceed_status_thread: thread %s "
"has pending wait status %s " "has pending wait status %s "
"(currently_stepping=%d).\n", "(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)); currently_stepping (tp));
} }
} }
@ -2960,7 +2963,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: need to step-over [%s] first\n", "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); thread_step_over_chain_enqueue (tp);
} }
@ -3005,7 +3008,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: proceed: [%s] resumed\n", "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); gdb_assert (tp->executing || tp->suspend.waitstatus_pending_p);
continue; continue;
} }
@ -3015,14 +3018,14 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: proceed: [%s] needs step-over\n", "infrun: proceed: [%s] needs step-over\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
continue; continue;
} }
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: proceed: resuming %s\n", "infrun: proceed: resuming %s\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
reset_ecs (ecs, tp); reset_ecs (ecs, tp);
switch_to_thread (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.lwp (),
waiton_ptid.tid ()); waiton_ptid.tid ());
if (waiton_ptid.pid () != -1) 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 (", status) =\n");
stb.printf ("infrun: %d.%ld.%ld [%s],\n", stb.printf ("infrun: %d.%ld.%ld [%s],\n",
result_ptid.pid (), result_ptid.pid (),
result_ptid.lwp (), result_ptid.lwp (),
result_ptid.tid (), 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 ()); stb.printf ("infrun: %s\n", status_string.c_str ());
/* This uses %s in part to handle %'s in the text, but also to avoid /* 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) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: Waiting for specific thread %s.\n", "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. */ /* We have a specific thread to check. */
tp = find_thread_ptid (ptid); tp = find_thread_ptid (ptid);
@ -3357,7 +3360,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: PC of %s changed. was=%s, now=%s\n", "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, tp->suspend.stop_pc),
paddress (gdbarch, pc)); paddress (gdbarch, pc));
discard = 1; discard = 1;
@ -3367,7 +3370,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: previous breakpoint of %s, at %s gone\n", "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)); paddress (gdbarch, pc));
discard = 1; discard = 1;
@ -3378,7 +3381,7 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: pending event of %s cancelled.\n", "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.waitstatus.kind = TARGET_WAITKIND_SPURIOUS;
tp->suspend.stop_reason = TARGET_STOPPED_BY_NO_REASON; 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, fprintf_unfiltered (gdb_stdlog,
"infrun: Using pending wait status %s for %s.\n", "infrun: Using pending wait status %s for %s.\n",
statstr.c_str (), 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 /* 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 ()) && ecs->event_thread != inferior_thread ())
{ {
fprintf_unfiltered (gdb_stdlog, "infrun: Switching context from %s ", 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", 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); switch_to_thread (ecs->event_thread);
@ -4312,7 +4315,7 @@ stop_all_threads (void)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: %s executing, " "infrun: %s executing, "
"need stop\n", "need stop\n",
target_pid_to_str (t->ptid)); target_pid_to_str (t->ptid).c_str ());
target_stop (t->ptid); target_stop (t->ptid);
t->stop_requested = 1; t->stop_requested = 1;
} }
@ -4322,7 +4325,7 @@ stop_all_threads (void)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: %s executing, " "infrun: %s executing, "
"already stopping\n", "already stopping\n",
target_pid_to_str (t->ptid)); target_pid_to_str (t->ptid).c_str ());
} }
if (t->stop_requested) if (t->stop_requested)
@ -4333,7 +4336,7 @@ stop_all_threads (void)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: %s not executing\n", "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 /* The thread may be not executing, but still be
resumed with a pending status to process. */ resumed with a pending status to process. */
@ -4367,7 +4370,7 @@ stop_all_threads (void)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: %s exited while " "infrun: %s exited while "
"stopping threads\n", "stopping threads\n",
target_pid_to_str (ptid)); target_pid_to_str (ptid).c_str ());
} }
} }
else else
@ -4407,7 +4410,7 @@ stop_all_threads (void)
"infrun: displaced-step of %s " "infrun: displaced-step of %s "
"canceled: adding back to the " "canceled: adding back to the "
"step-over queue\n", "step-over queue\n",
target_pid_to_str (t->ptid)); target_pid_to_str (t->ptid).c_str ());
} }
t->control.trap_expected = 0; t->control.trap_expected = 0;
thread_step_over_chain_enqueue (t); thread_step_over_chain_enqueue (t);
@ -4454,7 +4457,7 @@ stop_all_threads (void)
"(currently_stepping=%d)\n", "(currently_stepping=%d)\n",
paddress (target_gdbarch (), paddress (target_gdbarch (),
t->suspend.stop_pc), t->suspend.stop_pc),
target_pid_to_str (t->ptid), target_pid_to_str (t->ptid).c_str (),
currently_stepping (t)); currently_stepping (t));
} }
} }
@ -5220,7 +5223,7 @@ restart_threads (struct thread_info *event_thread)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: restart threads: " "infrun: restart threads: "
"[%s] is event thread\n", "[%s] is event thread\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
continue; continue;
} }
@ -5230,7 +5233,7 @@ restart_threads (struct thread_info *event_thread)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: restart threads: " "infrun: restart threads: "
"[%s] not meant to be running\n", "[%s] not meant to be running\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
continue; continue;
} }
@ -5239,7 +5242,7 @@ restart_threads (struct thread_info *event_thread)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: restart threads: [%s] resumed\n", "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); gdb_assert (tp->executing || tp->suspend.waitstatus_pending_p);
continue; continue;
} }
@ -5250,7 +5253,7 @@ restart_threads (struct thread_info *event_thread)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: restart threads: " "infrun: restart threads: "
"[%s] needs step-over\n", "[%s] needs step-over\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
gdb_assert (!tp->resumed); gdb_assert (!tp->resumed);
continue; continue;
} }
@ -5262,7 +5265,7 @@ restart_threads (struct thread_info *event_thread)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: restart threads: " "infrun: restart threads: "
"[%s] has pending status\n", "[%s] has pending status\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
tp->resumed = 1; tp->resumed = 1;
continue; continue;
} }
@ -5277,7 +5280,7 @@ restart_threads (struct thread_info *event_thread)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
"thread [%s] needs a step-over, but not in " "thread [%s] needs a step-over, but not in "
"step-over queue\n", "step-over queue\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
} }
if (currently_stepping (tp)) if (currently_stepping (tp))
@ -5285,7 +5288,7 @@ restart_threads (struct thread_info *event_thread)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: restart threads: [%s] was stepping\n", "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); keep_going_stepped_thread (tp);
} }
else else
@ -5296,7 +5299,7 @@ restart_threads (struct thread_info *event_thread)
if (debug_infrun) if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: restart threads: [%s] continuing\n", "infrun: restart threads: [%s] continuing\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
reset_ecs (ecs, tp); reset_ecs (ecs, tp);
switch_to_thread (tp); switch_to_thread (tp);
keep_going_pass_signal (ecs); keep_going_pass_signal (ecs);
@ -5417,7 +5420,7 @@ finish_step_over (struct execution_control_state *ecs)
"(currently_stepping=%d)\n", "(currently_stepping=%d)\n",
paddress (target_gdbarch (), paddress (target_gdbarch (),
tp->suspend.stop_pc), tp->suspend.stop_pc),
target_pid_to_str (tp->ptid), target_pid_to_str (tp->ptid).c_str (),
currently_stepping (tp)); currently_stepping (tp));
} }
@ -5580,7 +5583,7 @@ handle_signal_stop (struct execution_control_state *ecs)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: [%s] hit another thread's " "infrun: [%s] hit another thread's "
"single-step breakpoint\n", "single-step breakpoint\n",
target_pid_to_str (ecs->ptid)); target_pid_to_str (ecs->ptid).c_str ());
} }
ecs->hit_singlestep_breakpoint = 1; ecs->hit_singlestep_breakpoint = 1;
} }
@ -5592,7 +5595,7 @@ handle_signal_stop (struct execution_control_state *ecs)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: [%s] hit its " "infrun: [%s] hit its "
"single-step breakpoint\n", "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, fprintf_unfiltered (gdb_stdlog,
"infrun: need to finish step-over of [%s]\n", "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); keep_going (ecs);
return 1; return 1;
@ -6857,7 +6860,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: need to step [%s] over single-step " "infrun: need to step [%s] over single-step "
"breakpoint\n", "breakpoint\n",
target_pid_to_str (ecs->ptid)); target_pid_to_str (ecs->ptid).c_str ());
} }
keep_going (ecs); keep_going (ecs);
return 1; return 1;
@ -6872,7 +6875,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs)
{ {
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: thread [%s] still needs step-over\n", "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); keep_going (ecs);
return 1; return 1;
@ -6923,7 +6926,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
"[%s] has inconsistent state: " "[%s] has inconsistent state: "
"trap_expected=%d\n", "trap_expected=%d\n",
target_pid_to_str (tp->ptid), target_pid_to_str (tp->ptid).c_str (),
tp->control.trap_expected); tp->control.trap_expected);
} }
@ -7493,7 +7496,7 @@ keep_going_pass_signal (struct execution_control_state *ecs)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: %s has trap_expected set, " "infrun: %s has trap_expected set, "
"resuming to collect trap\n", "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 /* We haven't yet gotten our trap, and either: intercepted a
non-signal event (e.g., a fork); or took a signal which we 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, fprintf_unfiltered (gdb_stdlog,
"infrun: step-over already in progress: " "infrun: step-over already in progress: "
"step-over for %s deferred\n", "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); thread_step_over_chain_enqueue (tp);
} }
else else
@ -7524,7 +7527,7 @@ keep_going_pass_signal (struct execution_control_state *ecs)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"infrun: step-over in progress: " "infrun: step-over in progress: "
"resume of %s deferred\n", "resume of %s deferred\n",
target_pid_to_str (tp->ptid)); target_pid_to_str (tp->ptid).c_str ());
} }
} }
else else
@ -7692,7 +7695,7 @@ void
print_exited_reason (struct ui_out *uiout, int exitstatus) print_exited_reason (struct ui_out *uiout, int exitstatus)
{ {
struct inferior *inf = current_inferior (); 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); annotate_exited (exitstatus);
if (exitstatus) if (exitstatus)
@ -7702,7 +7705,7 @@ print_exited_reason (struct ui_out *uiout, int exitstatus)
uiout->text ("[Inferior "); uiout->text ("[Inferior ");
uiout->text (plongest (inf->num)); uiout->text (plongest (inf->num));
uiout->text (" ("); uiout->text (" (");
uiout->text (pidstr); uiout->text (pidstr.c_str ());
uiout->text (") exited with code "); uiout->text (") exited with code ");
uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus); uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus);
uiout->text ("]\n"); uiout->text ("]\n");
@ -7715,7 +7718,7 @@ print_exited_reason (struct ui_out *uiout, int exitstatus)
uiout->text ("[Inferior "); uiout->text ("[Inferior ");
uiout->text (plongest (inf->num)); uiout->text (plongest (inf->num));
uiout->text (" ("); uiout->text (" (");
uiout->text (pidstr); uiout->text (pidstr.c_str ());
uiout->text (") exited normally]\n"); uiout->text (") exited normally]\n");
} }
} }
@ -8046,7 +8049,7 @@ normal_stop (void)
{ {
target_terminal::ours_for_output (); target_terminal::ours_for_output ();
printf_filtered (_("[Switching to %s]\n"), printf_filtered (_("[Switching to %s]\n"),
target_pid_to_str (inferior_ptid)); target_pid_to_str (inferior_ptid).c_str ());
annotate_thread_changed (); annotate_thread_changed ();
} }
previous_inferior_ptid = inferior_ptid; previous_inferior_ptid = inferior_ptid;

View file

@ -352,7 +352,7 @@ linux_fork_mourn_inferior (void)
last = find_last_fork (); last = find_last_fork ();
fork_load_infrun_state (last); fork_load_infrun_state (last);
printf_filtered (_("[Switching to %s]\n"), 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 there's only one fork, switch back to non-fork mode. */
if (one_fork_p ()) if (one_fork_p ())
@ -371,7 +371,8 @@ linux_fork_detach (int from_tty)
fork. */ fork. */
if (ptrace (PTRACE_DETACH, inferior_ptid.pid (), 0, 0)) 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); delete_fork (inferior_ptid);
@ -384,7 +385,7 @@ linux_fork_detach (int from_tty)
if (from_tty) if (from_tty)
printf_filtered (_("[Switching to %s]\n"), 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 there's only one fork, switch back to non-fork mode. */
if (one_fork_p ()) if (one_fork_p ())
@ -435,7 +436,7 @@ public:
CATCH (ex, RETURN_MASK_ALL) CATCH (ex, RETURN_MASK_ALL)
{ {
warning (_("Couldn't restore checkpoint state in %s: %s"), 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 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")); Please switch to another checkpoint before deleting the current one"));
if (ptrace (PTRACE_KILL, ptid.pid (), 0, 0)) 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); fi = find_fork_ptid (ptid);
gdb_assert (fi); gdb_assert (fi);
pptid = fi->parent_ptid; pptid = fi->parent_ptid;
if (from_tty) 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); delete_fork (ptid);
@ -524,7 +525,8 @@ Please switch to another checkpoint before deleting the current one"));
|| (parent != NULL && parent->state == THREAD_STOPPED)) || (parent != NULL && parent->state == THREAD_STOPPED))
{ {
if (inferior_call_waitpid (pptid, ptid.pid ())) 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")); Please switch to another checkpoint before detaching the current one"));
if (ptrace (PTRACE_DETACH, ptid.pid (), 0, 0)) 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) 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); delete_fork (ptid);
} }
@ -577,7 +579,7 @@ info_checkpoints_command (const char *arg, int from_tty)
printf_filtered (" "); printf_filtered (" ");
ULONGEST pc = fi.pc; 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) if (fi.num == 0)
printf_filtered (_(" (main process)")); printf_filtered (_(" (main process)"));
printf_filtered (_(" at ")); printf_filtered (_(" at "));
@ -730,7 +732,7 @@ linux_fork_context (struct fork_info *newfp, int from_tty)
insert_breakpoints (); insert_breakpoints ();
printf_filtered (_("Switching to %s\n"), 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); print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
} }

View file

@ -1013,7 +1013,8 @@ exit_lwp (struct lwp_info *lp)
if (th) if (th)
{ {
if (print_thread_events) 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); delete_thread (th);
} }
@ -1149,7 +1150,7 @@ attach_proc_task_lwp_callback (ptid_t ptid)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"PTRACE_ATTACH %s, 0, 0 (OK)\n", "PTRACE_ATTACH %s, 0, 0 (OK)\n",
target_pid_to_str (ptid)); target_pid_to_str (ptid).c_str ());
lp = add_lwp (ptid); lp = add_lwp (ptid);
@ -1335,7 +1336,7 @@ get_detach_signal (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"GPT: lwp %s has no pending signal\n", "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)) else if (!signal_pass_state (signo))
{ {
@ -1343,7 +1344,7 @@ get_detach_signal (struct lwp_info *lp)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"GPT: lwp %s had signal %s, " "GPT: lwp %s had signal %s, "
"but it is in no pass state\n", "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)); gdb_signal_to_string (signo));
} }
else else
@ -1351,7 +1352,7 @@ get_detach_signal (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"GPT: lwp %s has pending signal %s\n", "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)); gdb_signal_to_string (signo));
return gdb_signal_to_host (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) if (debug_linux_nat && lp->status)
fprintf_unfiltered (gdb_stdlog, "DC: Pending %s for %s on detach.\n", fprintf_unfiltered (gdb_stdlog, "DC: Pending %s for %s on detach.\n",
strsignal (WSTOPSIG (lp->status)), 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 there is a pending SIGSTOP, get rid of it. */
if (lp->signalled) if (lp->signalled)
@ -1383,7 +1384,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"DC: Sending SIGCONT to %s\n", "DC: Sending SIGCONT to %s\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
kill_lwp (lwpid, SIGCONT); kill_lwp (lwpid, SIGCONT);
lp->signalled = 0; lp->signalled = 0;
@ -1438,7 +1439,8 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
} }
else 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)); safe_strerror (save_errno));
} }
} }
@ -1446,7 +1448,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
{ {
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"PTRACE_DETACH (%s, %s, 0) (OK)\n", "PTRACE_DETACH (%s, %s, 0) (OK)\n",
target_pid_to_str (lp->ptid), target_pid_to_str (lp->ptid).c_str (),
strsignal (signo)); strsignal (signo));
} }
@ -1608,14 +1610,14 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RC: Not resuming %s (vfork parent)\n", "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)) else if (!lwp_status_pending_p (lp))
{ {
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RC: Resuming sibling %s, %s, %s\n", "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 (signo != GDB_SIGNAL_0
? strsignal (gdb_signal_to_host (signo)) ? strsignal (gdb_signal_to_host (signo))
: "0"), : "0"),
@ -1628,7 +1630,7 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RC: Not resuming sibling %s (has pending)\n", "RC: Not resuming sibling %s (has pending)\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
} }
} }
else else
@ -1636,7 +1638,7 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RC: Not resuming sibling %s (not stopped)\n", "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, fprintf_unfiltered (gdb_stdlog,
"LLR: Preparing to %s %s, %s, inferior_ptid %s\n", "LLR: Preparing to %s %s, %s, inferior_ptid %s\n",
step ? "step" : "resume", step ? "step" : "resume",
target_pid_to_str (ptid), target_pid_to_str (ptid).c_str (),
(signo != GDB_SIGNAL_0 (signo != GDB_SIGNAL_0
? strsignal (gdb_signal_to_host (signo)) : "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'. */ /* A specific PTID means `step only this process id'. */
resume_many = (minus_one_ptid == ptid 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, fprintf_unfiltered (gdb_stdlog,
"LLR: %s %s, %s (resume event thread)\n", "LLR: %s %s, %s (resume event thread)\n",
step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT", step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
target_pid_to_str (lp->ptid), target_pid_to_str (lp->ptid).c_str (),
(signo != GDB_SIGNAL_0 (signo != GDB_SIGNAL_0
? strsignal (gdb_signal_to_host (signo)) : "0")); ? strsignal (gdb_signal_to_host (signo)) : "0"));
@ -2174,7 +2176,7 @@ wait_lwp (struct lwp_info *lp)
thread_dead = 1; thread_dead = 1;
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, "WL: %s vanished.\n", 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) if (pid != 0)
break; break;
@ -2200,7 +2202,7 @@ wait_lwp (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"WL: Thread group leader %s vanished.\n", "WL: Thread group leader %s vanished.\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
break; break;
} }
@ -2223,7 +2225,7 @@ wait_lwp (struct lwp_info *lp)
{ {
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"WL: waitpid %s received %s\n", "WL: waitpid %s received %s\n",
target_pid_to_str (lp->ptid), target_pid_to_str (lp->ptid).c_str (),
status_to_str (status)); status_to_str (status));
} }
@ -2248,7 +2250,7 @@ wait_lwp (struct lwp_info *lp)
thread_dead = 1; thread_dead = 1;
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, "WL: %s exited.\n", 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, fprintf_unfiltered (gdb_stdlog,
"SC: kill %s **<SIGSTOP>**\n", "SC: kill %s **<SIGSTOP>**\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
} }
errno = 0; errno = 0;
ret = kill_lwp (lp->ptid.lwp (), SIGSTOP); ret = kill_lwp (lp->ptid.lwp (), SIGSTOP);
@ -2417,7 +2419,7 @@ maybe_clear_ignore_sigint (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"MCIS: Clearing bogus flag for %s\n", "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; lp->ignore_sigint = 0;
} }
} }
@ -2517,7 +2519,7 @@ stop_wait_callback (struct lwp_info *lp)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"PTRACE_CONT %s, 0, 0 (%s) " "PTRACE_CONT %s, 0, 0 (%s) "
"(discarding SIGINT)\n", "(discarding SIGINT)\n",
target_pid_to_str (lp->ptid), target_pid_to_str (lp->ptid).c_str (),
errno ? safe_strerror (errno) : "OK"); errno ? safe_strerror (errno) : "OK");
return stop_wait_callback (lp); return stop_wait_callback (lp);
@ -2533,7 +2535,7 @@ stop_wait_callback (struct lwp_info *lp)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"SWC: Pending event %s in %s\n", "SWC: Pending event %s in %s\n",
status_to_str ((int) status), status_to_str ((int) status),
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
/* Save the sigtrap event. */ /* Save the sigtrap event. */
lp->status = status; lp->status = status;
@ -2547,7 +2549,7 @@ stop_wait_callback (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"SWC: Expected SIGSTOP caught for %s.\n", "SWC: Expected SIGSTOP caught for %s.\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
lp->signalled = 0; lp->signalled = 0;
@ -2594,7 +2596,7 @@ status_callback (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"SC: PC of %s changed. was=%s, now=%s\n", "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 (), lp->stop_pc),
paddress (target_gdbarch (), pc)); paddress (target_gdbarch (), pc));
discard = 1; discard = 1;
@ -2606,7 +2608,7 @@ status_callback (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"SC: previous breakpoint of %s, at %s gone\n", "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)); paddress (target_gdbarch (), lp->stop_pc));
discard = 1; discard = 1;
@ -2618,7 +2620,7 @@ status_callback (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"SC: pending event of %s cancelled.\n", "SC: pending event of %s cancelled.\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
lp->status = 0; lp->status = 0;
linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_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) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"CSBB: %s stopped by trace\n", "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 /* We may have single stepped an instruction that
triggered a watchpoint. In that case, on some triggered a watchpoint. In that case, on some
@ -2777,7 +2779,7 @@ save_stop_reason (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"CSBB: %s stopped by software breakpoint\n", "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. */ /* Back up the PC if necessary. */
if (pc != sw_bp_pc) if (pc != sw_bp_pc)
@ -2791,14 +2793,14 @@ save_stop_reason (struct lwp_info *lp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"CSBB: %s stopped by hardware breakpoint\n", "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) else if (lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
{ {
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"CSBB: %s stopped by hardware watchpoint\n", "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; 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) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"SEL: Select single-step %s\n", "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) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LLW: %s exited.\n", "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 /* If there is at least one more LWP, then the exit signal
was not the end of the debugged application and should be 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) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LLW: resume_stop SIGSTOP caught for %s.\n", "LLW: resume_stop SIGSTOP caught for %s.\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
} }
else else
{ {
@ -3088,7 +3090,7 @@ linux_nat_filter_event (int lwpid, int status)
"LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n", "LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n",
lp->step ? lp->step ?
"PTRACE_SINGLESTEP" : "PTRACE_CONT", "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); linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
gdb_assert (lp->resumed); gdb_assert (lp->resumed);
@ -3104,7 +3106,7 @@ linux_nat_filter_event (int lwpid, int status)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LLW: Delayed SIGINT caught for %s.\n", "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. */ /* This is a delayed SIGINT. */
lp->ignore_sigint = 0; lp->ignore_sigint = 0;
@ -3115,7 +3117,7 @@ linux_nat_filter_event (int lwpid, int status)
"LLW: %s %s, 0, 0 (discard SIGINT)\n", "LLW: %s %s, 0, 0 (discard SIGINT)\n",
lp->step ? lp->step ?
"PTRACE_SINGLESTEP" : "PTRACE_CONT", "PTRACE_SINGLESTEP" : "PTRACE_CONT",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
gdb_assert (lp->resumed); gdb_assert (lp->resumed);
/* Discard the event. */ /* Discard the event. */
@ -3164,7 +3166,7 @@ linux_nat_filter_event (int lwpid, int status)
"LLW: %s %s, %s (preempt 'handle')\n", "LLW: %s %s, %s (preempt 'handle')\n",
lp->step ? lp->step ?
"PTRACE_SINGLESTEP" : "PTRACE_CONT", "PTRACE_SINGLESTEP" : "PTRACE_CONT",
target_pid_to_str (lp->ptid), target_pid_to_str (lp->ptid).c_str (),
(signo != GDB_SIGNAL_0 (signo != GDB_SIGNAL_0
? strsignal (gdb_signal_to_host (signo)) ? strsignal (gdb_signal_to_host (signo))
: "0")); : "0"));
@ -3293,7 +3295,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LLW: Using pending wait status %s for %s.\n", "LLW: Using pending wait status %s for %s.\n",
status_to_str (lp->status), 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 /* 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) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LLW: trap ptid is %s.\n", "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) 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) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RSRL: NOT resuming LWP %s, not stopped\n", "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) else if (!lp->resumed)
{ {
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RSRL: NOT resuming LWP %s, not resumed\n", "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)) else if (lwp_status_pending_p (lp))
{ {
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RSRL: NOT resuming LWP %s, has pending status\n", "RSRL: NOT resuming LWP %s, has pending status\n",
target_pid_to_str (lp->ptid)); target_pid_to_str (lp->ptid).c_str ());
} }
else else
{ {
@ -3542,7 +3544,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"RSRL: resuming stopped-resumed LWP %s at " "RSRL: resuming stopped-resumed LWP %s at "
"%s: step=%d\n", "%s: step=%d\n",
target_pid_to_str (lp->ptid), target_pid_to_str (lp->ptid).c_str (),
paddress (gdbarch, pc), paddress (gdbarch, pc),
lp->step); 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); std::string options_string = target_options_to_string (target_options);
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"linux_nat_wait: [%s], [%s]\n", "linux_nat_wait: [%s], [%s]\n",
target_pid_to_str (ptid), target_pid_to_str (ptid).c_str (),
options_string.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) linux_nat_target::pid_to_str (ptid_t ptid)
{ {
static char buf[64];
if (ptid.lwp_p () if (ptid.lwp_p ()
&& (ptid.pid () != ptid.lwp () && (ptid.pid () != ptid.lwp ()
|| num_lwps (ptid.pid ()) > 1)) || num_lwps (ptid.pid ()) > 1))
{ return string_printf ("LWP %ld", ptid.lwp ());
snprintf (buf, sizeof (buf), "LWP %ld", ptid.lwp ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }
@ -4434,7 +4431,7 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
if (debug_linux_nat) if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LNSL: running -> suspending %s\n", "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) 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) if (find_thread_ptid (lwp->ptid)->stop_requested)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LNSL: already stopped/stop_requested %s\n", "LNSL: already stopped/stop_requested %s\n",
target_pid_to_str (lwp->ptid)); target_pid_to_str (lwp->ptid).c_str ());
else else
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"LNSL: already stopped/no " "LNSL: already stopped/no "
"stop_requested yet %s\n", "stop_requested yet %s\n",
target_pid_to_str (lwp->ptid)); target_pid_to_str (lwp->ptid).c_str ());
} }
} }
return 0; return 0;

View file

@ -64,7 +64,7 @@ public:
void update_thread_list () override; 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; const char *thread_name (struct thread_info *) override;

View 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. */ /* 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) linux_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
{ {
static char buf[80];
if (ptid.lwp () != 0) if (ptid.lwp () != 0)
{ return string_printf ("LWP %ld", ptid.lwp ());
snprintf (buf, sizeof (buf), "LWP %ld", ptid.lwp ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }

View file

@ -95,7 +95,7 @@ public:
void resume (ptid_t, int, enum gdb_signal) override; void resume (ptid_t, int, enum gdb_signal) override;
void mourn_inferior () override; void mourn_inferior () override;
void update_thread_list () 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 get_thread_local_address (ptid_t ptid,
CORE_ADDR load_module_addr, CORE_ADDR load_module_addr,
CORE_ADDR offset) override; CORE_ADDR offset) override;
@ -1631,20 +1631,17 @@ thread_db_target::update_thread_list ()
this->beneath ()->update_thread_list (); this->beneath ()->update_thread_list ();
} }
const char * std::string
thread_db_target::pid_to_str (ptid_t ptid) thread_db_target::pid_to_str (ptid_t ptid)
{ {
struct thread_info *thread_info = find_thread_ptid (ptid); struct thread_info *thread_info = find_thread_ptid (ptid);
if (thread_info != NULL && thread_info->priv != NULL) if (thread_info != NULL && thread_info->priv != NULL)
{ {
static char buf[64];
thread_db_thread_info *priv = get_thread_db_thread_info (thread_info); thread_db_thread_info *priv = get_thread_db_thread_info (thread_info);
snprintf (buf, sizeof (buf), "Thread 0x%lx (LWP %ld)", return string_printf ("Thread 0x%lx (LWP %ld)",
(unsigned long) priv->tid, ptid.lwp ()); (unsigned long) priv->tid, ptid.lwp ());
return buf;
} }
return beneath ()->pid_to_str (ptid); return beneath ()->pid_to_str (ptid);

View file

@ -115,7 +115,7 @@ struct nto_procfs_target : public inf_child_target
void update_thread_list () override; void update_thread_list () override;
const char *pid_to_str (ptid_t) override; std::string pid_to_str (ptid_t) override;
void interrupt () 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", printf_unfiltered ("\tUsing the running image of %s %s via %s.\n",
inf->attach_flag ? "attached" : "child", inf->attach_flag ? "attached" : "child",
target_pid_to_str (inferior_ptid), target_pid_to_str (inferior_ptid).c_str (),
(nodestr != NULL) ? nodestr : "local node"); (nodestr != NULL) ? nodestr : "local node");
} }
@ -708,10 +708,10 @@ nto_procfs_target::attach (const char *args, int from_tty)
if (exec_file) if (exec_file)
printf_unfiltered ("Attaching to program `%s', %s\n", 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 else
printf_unfiltered ("Attaching to %s\n", 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)); inferior_ptid = do_attach (ptid_t (pid));
inf = current_inferior (); inf = current_inferior ();
@ -1455,25 +1455,22 @@ nto_procfs_target::pass_signals
} }
} }
char * std::string
nto_procfs_target::pid_to_str (ptid_t ptid) nto_procfs_target::pid_to_str (ptid_t ptid)
{ {
static char buf[1024]; int pid, tid;
int pid, tid, n;
struct tidinfo *tip; struct tidinfo *tip;
pid = ptid.pid (); pid = ptid.pid ();
tid = ptid.tid (); tid = ptid.tid ();
n = snprintf (buf, 1023, "process %d", pid);
#if 0 /* NYI */ #if 0 /* NYI */
tip = procfs_thread_info (pid, tid); tip = procfs_thread_info (pid, tid);
if (tip != NULL) if (tip != NULL)
snprintf (&buf[n], 1023, " (state = 0x%02x)", tip->state); snprintf (&buf[n], 1023, " (state = 0x%02x)", tip->state);
#endif #endif
return buf; return string_printf ("process %d", pid);
} }
/* to_can_run implementation for "target procfs". Note this really /* to_can_run implementation for "target procfs". Note this really

View file

@ -35,16 +35,11 @@
#ifdef PT_GET_THREAD_FIRST #ifdef PT_GET_THREAD_FIRST
const char * std::sring
obsd_nat_target::pid_to_str (ptid_t ptid) obsd_nat_target::pid_to_str (ptid_t ptid)
{ {
if (ptid.lwp () != 0) if (ptid.lwp () != 0)
{ return string_printf ("thread %ld", ptid.lwp ());
static char buf[64];
xsnprintf (buf, sizeof buf, "thread %ld", ptid.lwp ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }

View file

@ -25,7 +25,7 @@
class obsd_nat_target : public inf_ptrace_target class obsd_nat_target : public inf_ptrace_target
{ {
/* Override some methods to support threads. */ /* 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; void update_thread_list () override;
ptid_t wait (ptid_t, struct target_waitstatus *, int) override; ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
}; };

View file

@ -35,7 +35,7 @@ process_stratum_target::thread_address_space (ptid_t ptid)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
_("Can't determine the current " _("Can't determine the current "
"address space of thread %s\n"), "address space of thread %s\n"),
target_pid_to_str (ptid)); target_pid_to_str (ptid).c_str ());
return inf->aspace; return inf->aspace;
} }

View file

@ -127,7 +127,7 @@ public:
bool thread_alive (ptid_t ptid) override; 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; char *pid_to_exec_file (int pid) override;
@ -1884,10 +1884,10 @@ procfs_target::attach (const char *args, int from_tty)
if (exec_file) if (exec_file)
printf_filtered (_("Attaching to program `%s', %s\n"), 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 else
printf_filtered (_("Attaching to %s\n"), printf_filtered (_("Attaching to %s\n"),
target_pid_to_str (ptid_t (pid))); target_pid_to_str (ptid_t (pid)).c_str ());
fflush (stdout); fflush (stdout);
} }
@ -1910,7 +1910,7 @@ procfs_target::detach (inferior *inf, int from_tty)
exec_file = ""; exec_file = "";
printf_filtered (_("Detaching from program: %s, %s\n"), 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 (); do_detach ();
@ -2063,7 +2063,7 @@ procfs_target::fetch_registers (struct regcache *regcache, int regnum)
if (pi == NULL) if (pi == NULL)
error (_("procfs: fetch_registers failed to find procinfo for %s"), 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); gregs = proc_get_gregs (pi);
if (gregs == NULL) if (gregs == NULL)
@ -2112,7 +2112,7 @@ procfs_target::store_registers (struct regcache *regcache, int regnum)
if (pi == NULL) if (pi == NULL)
error (_("procfs: store_registers: failed to find procinfo for %s"), 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); gregs = proc_get_gregs (pi);
if (gregs == NULL) if (gregs == NULL)
@ -2285,7 +2285,7 @@ wait_again:
{ {
if (print_thread_events) if (print_thread_events)
printf_unfiltered (_("[%s exited]\n"), printf_unfiltered (_("[%s exited]\n"),
target_pid_to_str (retval)); target_pid_to_str (retval).c_str ());
delete_thread (find_thread_ptid (retval)); delete_thread (find_thread_ptid (retval));
status->kind = TARGET_WAITKIND_SPURIOUS; status->kind = TARGET_WAITKIND_SPURIOUS;
return retval; return retval;
@ -2406,7 +2406,7 @@ wait_again:
{ {
if (print_thread_events) if (print_thread_events)
printf_unfiltered (_("[%s exited]\n"), printf_unfiltered (_("[%s exited]\n"),
target_pid_to_str (retval)); target_pid_to_str (retval).c_str ());
delete_thread (find_thread_ptid (retval)); delete_thread (find_thread_ptid (retval));
status->kind = TARGET_WAITKIND_SPURIOUS; status->kind = TARGET_WAITKIND_SPURIOUS;
return retval; return retval;
@ -2804,7 +2804,7 @@ procfs_target::files_info ()
printf_filtered (_("\tUsing the running image of %s %s via /proc.\n"), printf_filtered (_("\tUsing the running image of %s %s via /proc.\n"),
inf->attach_flag? "attached": "child", 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 /* 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; return true;
} }
/* Convert PTID to a string. Returns the string in a static /* Convert PTID to a string. */
buffer. */
const char * std::string
procfs_target::pid_to_str (ptid_t ptid) procfs_target::pid_to_str (ptid_t ptid)
{ {
static char buf[80];
if (ptid.lwp () == 0) if (ptid.lwp () == 0)
xsnprintf (buf, sizeof (buf), "process %d", ptid.pid ()); return string_printf ("process %d", ptid.pid ());
else else
xsnprintf (buf, sizeof (buf), "LWP %ld", ptid.lwp ()); return string_printf ("LWP %ld", ptid.lwp ());
return buf;
} }
/* Accepts an integer PID; Returns a string representing a file that /* Accepts an integer PID; Returns a string representing a file that

View file

@ -293,12 +293,12 @@ print_program_space (struct ui_out *uiout, int requested)
printed_header = 1; printed_header = 1;
printf_filtered ("\n\tBound inferiors: ID %d (%s)", printf_filtered ("\n\tBound inferiors: ID %d (%s)",
inf->num, inf->num,
target_pid_to_str (ptid_t (inf->pid))); target_pid_to_str (ptid_t (inf->pid)).c_str ());
} }
else else
printf_filtered (", ID %d (%s)", printf_filtered (", ID %d (%s)",
inf->num, inf->num,
target_pid_to_str (ptid_t (inf->pid))); target_pid_to_str (ptid_t (inf->pid)).c_str ());
} }
uiout->text ("\n"); uiout->text ("\n");

View file

@ -110,7 +110,7 @@ struct ravenscar_thread_target final : public target_ops
const char *extra_thread_info (struct thread_info *) override; 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; 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; return true;
} }
const char * std::string
ravenscar_thread_target::pid_to_str (ptid_t ptid) ravenscar_thread_target::pid_to_str (ptid_t ptid)
{ {
static char buf[30]; return string_printf ("Thread %#x", (int) ptid.tid ());
snprintf (buf, sizeof (buf), "Thread %#x", (int) ptid.tid ());
return buf;
} }
void void

View file

@ -596,7 +596,8 @@ record_btrace_target::info_record ()
printf_unfiltered (_("Recorded %u instructions in %u functions (%u gaps) " printf_unfiltered (_("Recorded %u instructions in %u functions (%u gaps) "
"for thread %s (%s).\n"), insns, calls, 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)) if (btrace_is_replaying (tp))
printf_unfiltered (_("Replay in progress. At instruction %u.\n"), 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; struct btrace_thread_info *btinfo;
DEBUG ("resuming thread %s (%s): %x (%s)", print_thread_id (tp), 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; 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; 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-" : "", ::execution_direction == EXEC_REVERSE ? "reverse-" : "",
step ? "step" : "cont"); step ? "step" : "cont");
@ -2214,7 +2216,7 @@ record_btrace_cancel_resume (struct thread_info *tp)
DEBUG ("cancel resume thread %s (%s): %x (%s)", DEBUG ("cancel resume thread %s (%s): %x (%s)",
print_thread_id (tp), 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)); btrace_thread_flag_to_str (flags));
tp->btrace.flags &= ~(BTHR_MOVE | BTHR_STOP); 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); btinfo->flags &= ~(BTHR_MOVE | BTHR_STOP);
DEBUG ("stepping thread %s (%s): %x (%s)", print_thread_id (tp), 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)); btrace_thread_flag_to_str (flags));
/* We can't step without an execution history. */ /* 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 *> moving;
std::vector<thread_info *> no_history; 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. */ /* As long as we're not replaying, just forward the request. */
if ((::execution_direction != EXEC_REVERSE) 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 (); *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 ()); target_waitstatus_to_string (status).c_str ());
return null_ptid; 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", DEBUG ("wait ended by thread %s (%s): %s",
print_thread_id (eventing), 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 ()); target_waitstatus_to_string (status).c_str ());
return eventing->ptid; return eventing->ptid;
@ -2647,7 +2649,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
void void
record_btrace_target::stop (ptid_t ptid) 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. */ /* As long as we're not replaying, just forward the request. */
if ((::execution_direction != EXEC_REVERSE) if ((::execution_direction != EXEC_REVERSE)

View file

@ -124,7 +124,7 @@ struct gdbsim_target final
bool thread_alive (ptid_t ptid) 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_all_memory () override; bool has_all_memory () override;
bool has_memory () override; bool has_memory () override;
@ -1280,10 +1280,9 @@ gdbsim_target::thread_alive (ptid_t ptid)
return false; return false;
} }
/* Convert a thread ID to a string. Returns the string in a static /* Convert a thread ID to a string. */
buffer. */
const char * std::string
gdbsim_target::pid_to_str (ptid_t ptid) gdbsim_target::pid_to_str (ptid_t ptid)
{ {
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);

View file

@ -475,7 +475,7 @@ public:
void update_thread_list () override; 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; 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) if (exec_file)
printf_unfiltered (_("Attaching to program: %s, %s\n"), 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 else
printf_unfiltered (_("Attaching to %s\n"), 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); 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) else if (strcmp (rs->buf.data (), "OK") != 0)
error (_("Attaching to %s failed with: %s"), 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 ()); rs->buf.data ());
break; break;
case PACKET_UNKNOWN: case PACKET_UNKNOWN:
error (_("This target does not support attaching to a process")); error (_("This target does not support attaching to a process"));
default: default:
error (_("Attaching to %s failed"), 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)); 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); putpkt (rs->buf);
getpkt (&rs->buf, 0); getpkt (&rs->buf, 0);
if (strcmp (rs->buf.data (), "OK") != 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 ()); rs->buf.data ());
} }
@ -7096,7 +7096,7 @@ remote_target::remote_notif_remove_queued_reply (ptid_t ptid)
if (notif_debug) if (notif_debug)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"notif: discard queued event: 'Stop' in %s\n", "notif: discard queued event: 'Stop' in %s\n",
target_pid_to_str (ptid)); target_pid_to_str (ptid).c_str ());
return result; return result;
} }
@ -7134,7 +7134,7 @@ remote_target::push_stop_reply (struct stop_reply *new_event)
if (notif_debug) if (notif_debug)
fprintf_unfiltered (gdb_stdlog, fprintf_unfiltered (gdb_stdlog,
"notif: push 'Stop' %s to queue %d\n", "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 ())); int (rs->stop_reply_queue.size ()));
mark_async_event_handler (rs->remote_async_inferior_event_token); mark_async_event_handler (rs->remote_async_inferior_event_token);
@ -11397,13 +11397,11 @@ init_remote_threadtests (void)
#endif /* 0 */ #endif /* 0 */
/* Convert a thread ID to a string. Returns the string in a static /* Convert a thread ID to a string. */
buffer. */
const char * std::string
remote_target::pid_to_str (ptid_t ptid) remote_target::pid_to_str (ptid_t ptid)
{ {
static char buf[64];
struct remote_state *rs = get_remote_state (); struct remote_state *rs = get_remote_state ();
if (ptid == null_ptid) 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 attached to a process, and reporting yes to qAttached, hence
no smart special casing here. */ no smart special casing here. */
if (!remote_multi_process_p (rs)) if (!remote_multi_process_p (rs))
{ return "Remote target";
xsnprintf (buf, sizeof buf, "Remote target");
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }
else else
{ {
if (magic_null_ptid == ptid) if (magic_null_ptid == ptid)
xsnprintf (buf, sizeof buf, "Thread <main>"); return "Thread <main>";
else if (remote_multi_process_p (rs)) else if (remote_multi_process_p (rs))
if (ptid.lwp () == 0) if (ptid.lwp () == 0)
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
else else
xsnprintf (buf, sizeof buf, "Thread %d.%ld", return string_printf ("Thread %d.%ld",
ptid.pid (), ptid.lwp ()); ptid.pid (), ptid.lwp ());
else else
xsnprintf (buf, sizeof buf, "Thread %ld", return string_printf ("Thread %ld", ptid.lwp ());
ptid.lwp ());
return buf;
} }
} }
@ -13786,10 +13779,10 @@ remote_target::enable_btrace (ptid_t ptid, const struct btrace_config *conf)
{ {
if (rs->buf[0] == 'E' && rs->buf[1] == '.') if (rs->buf[0] == 'E' && rs->buf[1] == '.')
error (_("Could not enable branch tracing for %s: %s"), 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 else
error (_("Could not enable branch tracing for %s."), 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); 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] == '.') if (rs->buf[0] == 'E' && rs->buf[1] == '.')
error (_("Could not disable branch tracing for %s: %s"), 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 else
error (_("Could not disable branch tracing for %s."), error (_("Could not disable branch tracing for %s."),
target_pid_to_str (tinfo->ptid)); target_pid_to_str (tinfo->ptid).c_str ());
} }
xfree (tinfo); xfree (tinfo);

View file

@ -87,7 +87,7 @@ public:
ptid_t wait (ptid_t, struct target_waitstatus *, int) override; ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
void resume (ptid_t, int, enum gdb_signal) override; void resume (ptid_t, int, enum gdb_signal) override;
void mourn_inferior () 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; ptid_t get_ada_task_ptid (long lwp, long thread) override;
void fetch_registers (struct regcache *, int) 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. */ /* Convert PTID to printable form. */
const char * std::string
sol_thread_target::pid_to_str (ptid_t ptid) sol_thread_target::pid_to_str (ptid_t ptid)
{ {
static char buf[100];
if (ptid.tid_p ()) if (ptid.tid_p ())
{ {
ptid_t lwp; ptid_t lwp;
@ -1009,21 +1007,19 @@ sol_thread_target::pid_to_str (ptid_t ptid)
lwp = thread_to_lwp (ptid, -2); lwp = thread_to_lwp (ptid, -2);
if (lwp.pid () == -1) if (lwp.pid () == -1)
xsnprintf (buf, sizeof (buf), "Thread %ld (defunct)", return string_printf ("Thread %ld (defunct)",
ptid.tid ()); ptid.tid ());
else if (lwp.pid () != -2) else if (lwp.pid () != -2)
xsnprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)", return string_printf ("Thread %ld (LWP %ld)",
ptid.tid (), lwp.lwp ()); ptid.tid (), lwp.lwp ());
else else
xsnprintf (buf, sizeof (buf), "Thread %ld ", return string_printf ("Thread %ld ",
ptid.tid ()); ptid.tid ());
} }
else if (ptid.lwp () != 0) else if (ptid.lwp () != 0)
xsnprintf (buf, sizeof (buf), "LWP %ld ", ptid.lwp ()); return string_printf ("LWP %ld ", ptid.lwp ());
else else
xsnprintf (buf, sizeof (buf), "process %d ", ptid.pid ()); return string_printf ("process %d ", ptid.pid ());
return buf;
} }

View 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 /* This is how we want PTIDs from Solaris core files to be
printed. */ printed. */
const char * std::string
sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
{ {
static char buf[80];
struct inferior *inf; struct inferior *inf;
int pid; int pid;
@ -53,8 +52,7 @@ sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
if (pid != 0) if (pid != 0)
{ {
/* A thread. */ /* A thread. */
xsnprintf (buf, sizeof buf, "LWP %ld", ptid.lwp ()); return string_printf ("LWP %ld", ptid.lwp ());
return buf;
} }
/* GDB didn't use to put a NT_PSTATUS note in Solaris cores. If /* 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. */ up. */
inf = find_inferior_ptid (ptid); inf = find_inferior_ptid (ptid);
if (inf == NULL || inf->fake_pid_p) if (inf == NULL || inf->fake_pid_p)
{ return "<core>";
xsnprintf (buf, sizeof buf, "<core>");
return buf;
}
/* Not fake; print as usual. */ /* Not fake; print as usual. */
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);

View file

@ -24,6 +24,6 @@ struct gdbarch;
CORE_ADDR sol2_skip_solib_resolver (struct gdbarch *, CORE_ADDR); 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 */ #endif /* sol2-tdep.h */

View file

@ -184,6 +184,8 @@
target_debug_do_print (host_address_to_string (X)) target_debug_do_print (host_address_to_string (X))
#define target_debug_print_thread_info_pp(X) \ #define target_debug_print_thread_info_pp(X) \
target_debug_do_print (host_address_to_string (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 static void
target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status) target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)

View file

@ -66,7 +66,7 @@ struct dummy_target : public target_ops
void program_signals (gdb::array_view<const unsigned char> arg0) override; void program_signals (gdb::array_view<const unsigned char> arg0) override;
bool thread_alive (ptid_t arg0) override; bool thread_alive (ptid_t arg0) override;
void update_thread_list () 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 *extra_thread_info (thread_info *arg0) override;
const char *thread_name (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; 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; void program_signals (gdb::array_view<const unsigned char> arg0) override;
bool thread_alive (ptid_t arg0) override; bool thread_alive (ptid_t arg0) override;
void update_thread_list () 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 *extra_thread_info (thread_info *arg0) override;
const char *thread_name (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; 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); fputs_unfiltered (")\n", gdb_stdlog);
} }
const char * std::string
target_ops::pid_to_str (ptid_t arg0) target_ops::pid_to_str (ptid_t arg0)
{ {
return this->beneath ()->pid_to_str (arg0); return this->beneath ()->pid_to_str (arg0);
} }
const char * std::string
dummy_target::pid_to_str (ptid_t arg0) dummy_target::pid_to_str (ptid_t arg0)
{ {
return default_pid_to_str (this, arg0); return default_pid_to_str (this, arg0);
} }
const char * std::string
debug_target::pid_to_str (ptid_t arg0) 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 ()); fprintf_unfiltered (gdb_stdlog, "-> %s->pid_to_str (...)\n", this->beneath ()->shortname ());
result = this->beneath ()->pid_to_str (arg0); result = this->beneath ()->pid_to_str (arg0);
fprintf_unfiltered (gdb_stdlog, "<- %s->pid_to_str (", this->beneath ()->shortname ()); fprintf_unfiltered (gdb_stdlog, "<- %s->pid_to_str (", this->beneath ()->shortname ());
target_debug_print_ptid_t (arg0); target_debug_print_ptid_t (arg0);
fputs_unfiltered (") = ", gdb_stdlog); fputs_unfiltered (") = ", gdb_stdlog);
target_debug_print_const_char_p (result); target_debug_print_std_string (result);
fputs_unfiltered ("\n", gdb_stdlog); fputs_unfiltered ("\n", gdb_stdlog);
return result; return result;
} }

View 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, static char *dummy_make_corefile_notes (struct target_ops *self,
bfd *ignore1, int *ignore2); 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 static enum exec_direction_kind default_execution_direction
(struct target_ops *self); (struct target_ops *self);
@ -744,24 +744,26 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
" thread-local variables in\n" " thread-local variables in\n"
"the shared library `%s'\n" "the shared library `%s'\n"
"for %s"), "for %s"),
objfile_name (objfile), target_pid_to_str (ptid)); objfile_name (objfile),
target_pid_to_str (ptid).c_str ());
else else
error (_("The inferior has not yet allocated storage for" error (_("The inferior has not yet allocated storage for"
" thread-local variables in\n" " thread-local variables in\n"
"the executable `%s'\n" "the executable `%s'\n"
"for %s"), "for %s"),
objfile_name (objfile), target_pid_to_str (ptid)); objfile_name (objfile),
target_pid_to_str (ptid).c_str ());
break; break;
case TLS_GENERIC_ERROR: case TLS_GENERIC_ERROR:
if (objfile_is_library) if (objfile_is_library)
error (_("Cannot find thread-local storage for %s, " error (_("Cannot find thread-local storage for %s, "
"shared library %s:\n%s"), "shared library %s:\n%s"),
target_pid_to_str (ptid), target_pid_to_str (ptid).c_str (),
objfile_name (objfile), ex.message); objfile_name (objfile), ex.message);
else else
error (_("Cannot find thread-local storage for %s, " error (_("Cannot find thread-local storage for %s, "
"executable file %s:\n%s"), "executable file %s:\n%s"),
target_pid_to_str (ptid), target_pid_to_str (ptid).c_str (),
objfile_name (objfile), ex.message); objfile_name (objfile), ex.message);
break; break;
default: default:
@ -2073,7 +2075,7 @@ default_target_wait (struct target_ops *ops,
return minus_one_ptid; return minus_one_ptid;
} }
const char * std::string
target_pid_to_str (ptid_t ptid) target_pid_to_str (ptid_t ptid)
{ {
return current_top_target ()->pid_to_str (ptid); return current_top_target ()->pid_to_str (ptid);
@ -3168,7 +3170,7 @@ target_announce_detach (int from_tty)
pid = inferior_ptid.pid (); pid = inferior_ptid.pid ();
printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file, 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! */ /* 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 /* Convert a normal process ID to a string. Returns the string in a
static buffer. */ static buffer. */
const char * std::string
normal_pid_to_str (ptid_t ptid) normal_pid_to_str (ptid_t ptid)
{ {
static char buf[32]; return string_printf ("process %d", ptid.pid ());
xsnprintf (buf, sizeof buf, "process %d", ptid.pid ());
return buf;
} }
static const char * static std::string
default_pid_to_str (struct target_ops *ops, ptid_t ptid) default_pid_to_str (struct target_ops *ops, ptid_t ptid)
{ {
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);

View file

@ -649,7 +649,7 @@ struct target_ops
TARGET_DEFAULT_RETURN (false); TARGET_DEFAULT_RETURN (false);
virtual void update_thread_list () virtual void update_thread_list ()
TARGET_DEFAULT_IGNORE (); 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); TARGET_DEFAULT_FUNC (default_pid_to_str);
virtual const char *extra_thread_info (thread_info *) virtual const char *extra_thread_info (thread_info *)
TARGET_DEFAULT_RETURN (NULL); 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', but on some systems it may contain
`process xyz thread abc'. */ `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, /* Return a short string describing extra information about PID,
e.g. "sleeping", "runnable", "running on LWP 3". Null return value e.g. "sleeping", "runnable", "running on LWP 3". Null return value

View file

@ -319,7 +319,7 @@ add_thread_with_info (ptid_t ptid, private_thread_info *priv)
result->priv.reset (priv); result->priv.reset (priv);
if (print_thread_events) 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 (); annotate_new_thread ();
return result; return result;
@ -992,16 +992,17 @@ should_print_thread (const char *requested_threads, int default_inf_num,
static std::string static std::string
thread_target_id_str (thread_info *tp) 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 *extra_info = target_extra_thread_info (tp);
const char *name = tp->name != nullptr ? tp->name : target_thread_name (tp); const char *name = tp->name != nullptr ? tp->name : target_thread_name (tp);
if (extra_info != nullptr && name != nullptr) 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) 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) else if (name != nullptr)
return string_printf ("%s \"%s\"", target_id, name); return string_printf ("%s \"%s\"", target_id.c_str (), name);
else else
return target_id; return target_id;
} }
@ -1466,7 +1467,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
if (!flags.quiet) if (!flags.quiet)
printf_filtered (_("\nThread %s (%s):\n"), printf_filtered (_("\nThread %s (%s):\n"),
print_thread_id (thr), 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 ()); 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) if (!flags.quiet)
printf_filtered (_("\nThread %s (%s):\n"), printf_filtered (_("\nThread %s (%s):\n"),
print_thread_id (thr), print_thread_id (thr),
target_pid_to_str (inferior_ptid)); target_pid_to_str (inferior_ptid).c_str ());
if (flags.cont) if (flags.cont)
printf_filtered ("%s\n", ex.message); printf_filtered ("%s\n", ex.message);
else else
@ -1675,11 +1676,11 @@ thread_command (const char *tidstr, int from_tty)
if (tp->state == THREAD_EXITED) if (tp->state == THREAD_EXITED)
printf_filtered (_("[Current thread is %s (%s) (exited)]\n"), printf_filtered (_("[Current thread is %s (%s) (exited)]\n"),
print_thread_id (tp), print_thread_id (tp),
target_pid_to_str (inferior_ptid)); target_pid_to_str (inferior_ptid).c_str ());
else else
printf_filtered (_("[Current thread is %s (%s)]\n"), printf_filtered (_("[Current thread is %s (%s)]\n"),
print_thread_id (tp), print_thread_id (tp),
target_pid_to_str (inferior_ptid)); target_pid_to_str (inferior_ptid).c_str ());
} }
else else
error (_("No stack.")); error (_("No stack."));
@ -1756,11 +1757,11 @@ thread_find_command (const char *arg, int from_tty)
match++; match++;
} }
tmp = target_pid_to_str (tp->ptid); std::string name = target_pid_to_str (tp->ptid);
if (tmp != NULL && re_exec (tmp)) if (!name.empty () && re_exec (name.c_str ()))
{ {
printf_filtered (_("Thread %s has target id '%s'\n"), printf_filtered (_("Thread %s has target id '%s'\n"),
print_thread_id (tp), tmp); print_thread_id (tp), name.c_str ());
match++; match++;
} }
@ -1824,7 +1825,7 @@ print_selected_thread_frame (struct ui_out *uiout,
uiout->text ("[Switching to thread "); uiout->text ("[Switching to thread ");
uiout->field_string ("new-thread-id", print_thread_id (tp)); uiout->field_string ("new-thread-id", print_thread_id (tp));
uiout->text (" ("); uiout->text (" (");
uiout->text (target_pid_to_str (inferior_ptid)); uiout->text (target_pid_to_str (inferior_ptid).c_str ());
uiout->text (")]"); uiout->text (")]");
} }
} }

View file

@ -1548,11 +1548,11 @@ print_inferior_quit_action (struct inferior *inf, void *arg)
if (inf->attach_flag) if (inf->attach_flag)
fprintf_filtered (stb, fprintf_filtered (stb,
_("\tInferior %d [%s] will be detached.\n"), inf->num, _("\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 else
fprintf_filtered (stb, fprintf_filtered (stb,
_("\tInferior %d [%s] will be killed.\n"), inf->num, _("\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; return 0;
} }

View file

@ -72,10 +72,14 @@ tui_make_status_line (struct tui_locator_element *loc)
int pid_width; int pid_width;
int line_width; int line_width;
std::string pid_name_holder;
if (inferior_ptid == null_ptid) if (inferior_ptid == null_ptid)
pid_name = "No process"; pid_name = "No process";
else 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); target_width = strlen (target_shortname);
if (target_width > MAX_TARGET_WIDTH) if (target_width > MAX_TARGET_WIDTH)

View file

@ -341,7 +341,7 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
bool thread_alive (ptid_t ptid) 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 interrupt () override; void interrupt () override;
@ -525,10 +525,11 @@ windows_delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p)
here as well. */ here as well. */
if (info_verbose) 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) else if (print_thread_events && !main_thread_p)
printf_unfiltered (_("[%s exited with code %u]\n"), 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)); delete_thread (find_thread_ptid (ptid));
@ -2011,10 +2012,10 @@ windows_nat_target::attach (const char *args, int from_tty)
if (exec_file) if (exec_file)
printf_unfiltered ("Attaching to program `%s', %s\n", 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 else
printf_unfiltered ("Attaching to %s\n", 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); 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", printf_unfiltered ("\tUsing the running image of %s %s.\n",
inf->attach_flag ? "attached" : "child", 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. /* Modify CreateProcess parameters for use of a new separate console.
@ -2934,17 +2935,11 @@ windows_nat_target::close ()
} }
/* Convert pid to printable format. */ /* Convert pid to printable format. */
const char * std::string
windows_nat_target::pid_to_str (ptid_t ptid) windows_nat_target::pid_to_str (ptid_t ptid)
{ {
static char buf[80];
if (ptid.tid () != 0) if (ptid.tid () != 0)
{ return string_printf ("Thread %d.0x%lx", ptid.pid (), ptid.tid ());
snprintf (buf, sizeof (buf), "Thread %d.0x%lx",
ptid.pid (), ptid.tid ());
return buf;
}
return normal_pid_to_str (ptid); return normal_pid_to_str (ptid);
} }

View file

@ -327,7 +327,7 @@ display_one_tib (ptid_t ptid)
if (target_get_tib_address (ptid, &thread_local_base) == 0) if (target_get_tib_address (ptid, &thread_local_base) == 0)
{ {
printf_filtered (_("Unable to get thread local base for %s\n"), 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; return -1;
} }
@ -336,13 +336,13 @@ display_one_tib (ptid_t ptid)
{ {
printf_filtered (_("Unable to read thread information " printf_filtered (_("Unable to read thread information "
"block for %s at address %s\n"), "block for %s at address %s\n"),
target_pid_to_str (ptid), target_pid_to_str (ptid).c_str (),
paddress (target_gdbarch (), thread_local_base)); paddress (target_gdbarch (), thread_local_base));
return -1; return -1;
} }
printf_filtered (_("Thread Information Block %s at %s\n"), 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)); paddress (target_gdbarch (), thread_local_base));
index = (gdb_byte *) tib; index = (gdb_byte *) tib;

View file

@ -224,7 +224,7 @@ x86_linux_nat_target::enable_btrace (ptid_t ptid,
CATCH (exception, RETURN_MASK_ERROR) CATCH (exception, RETURN_MASK_ERROR)
{ {
error (_("Could not enable branch tracing for %s: %s"), 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 END_CATCH