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