X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fprocfs.c;h=50e3e928425e47895ba7ae32b132c297c7d81474;hb=268a13a5a3f7c6b9b6ffc5ac2d1b24eb41f3fbdc;hp=384ca9bc0b27076ecd24cb76e62cb29a7daafad9;hpb=c119e04082b5b3ee907a8d02b42fae2aee0c4fbb;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/procfs.c b/gdb/procfs.c index 384ca9bc0b..50e3e92842 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -31,14 +31,14 @@ #include "regcache.h" #include "inf-child.h" #include "nat/fork-inferior.h" -#include "common/filestuff.h" +#include "gdbsupport/filestuff.h" #define _STRUCTURED_PROC 1 /* Should be done by configure script. */ #include #include #include -#include "common/gdb_wait.h" +#include "gdbsupport/gdb_wait.h" #include #include #include "gdb_bfd.h" @@ -46,8 +46,8 @@ #include "auxv.h" #include "procfs.h" #include "observable.h" -#include "common/scoped_fd.h" -#include "common/pathstuff.h" +#include "gdbsupport/scoped_fd.h" +#include "gdbsupport/pathstuff.h" /* This module provides the interface between GDB and the /proc file system, which is used on many versions of Unix @@ -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