aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-fork.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-02-28 09:09:55 -0700
committerTom Tromey <tromey@adacore.com>2019-03-13 13:50:13 -0600
commita068643d69ce0f25d5f7cbdaa1d0a3211d72c081 (patch)
tree4b0da08750a1d8fb4db7889fd2f42ea49580cbae /gdb/linux-fork.c
parentb4be1b0648608a2578bbed39841c8ee411773edd (diff)
downloadgdb-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.
Diffstat (limited to 'gdb/linux-fork.c')
-rw-r--r--gdb/linux-fork.c24
1 files changed, 13 insertions, 11 deletions
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);
}