diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-01-17 12:33:57 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-01-17 12:34:50 -0500 |
commit | 4d9b86e17505063c96a01d40cdf5b4fc2080a798 (patch) | |
tree | e345594b4540d2b6a7cfa773eb972d17507731cd /gdb/gdbserver | |
parent | a7b2d0fbeb4ca22ffbf56d19d06b7d1cb774e383 (diff) | |
download | binutils-gdb-4d9b86e17505063c96a01d40cdf5b4fc2080a798.tar.gz |
Make linux_ptrace_attach_fail_reason return an std::string
This patch makes linux_ptrace_attach_fail_reason and
linux_ptrace_attach_fail_reason_string return std::string. It also
replaces usages of struct buffer with std::string. This allows getting
rid of a cleanup in in linux_ptrace_attach_fail_reason_string and
simplifies the code in general.
Something that looks odd to me is that in
linux_ptrace_attach_fail_reason, if the two messages are appended, there
is no separating space or \n, so the result won't be very nice. I left
it as-is for now though.
gdb/ChangeLog:
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason): Return
std::string.
(linux_ptrace_attach_fail_reason_string): Likewise.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason):
Likewise.
(linux_ptrace_attach_fail_reason_string): Likewise.
* linux-nat.c (attach_proc_task_lwp_callback): Adjust.
gdb/gdbserver/ChangeLog:
* linux-low.c (attach_proc_task_lwp_callback): Adjust to
linux_ptrace_attach_fail_reason_string now returning an
std::string.
(linux_attach): Likewise.
* thread-db.c (attach_thread): Likewise.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 14 | ||||
-rw-r--r-- | gdb/gdbserver/thread-db.c | 6 |
3 files changed, 21 insertions, 7 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index d91e004a69d..f1836559539 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,11 @@ +2018-01-17 Simon Marchi <simon.marchi@ericsson.com> + + * linux-low.c (attach_proc_task_lwp_callback): Adjust to + linux_ptrace_attach_fail_reason_string now returning an + std::string. + (linux_attach): Likewise. + * thread-db.c (attach_thread): Likewise. + 2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com> PR gdb/21559 diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index d8e122603cb..8117fc6ca8b 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -1159,9 +1159,10 @@ attach_proc_task_lwp_callback (ptid_t ptid) } else if (err != 0) { - warning (_("Cannot attach to lwp %d: %s"), - lwpid, - linux_ptrace_attach_fail_reason_string (ptid, err)); + std::string reason + = linux_ptrace_attach_fail_reason_string (ptid, err); + + warning (_("Cannot attach to lwp %d: %s"), lwpid, reason.c_str ()); } return 1; @@ -1186,8 +1187,11 @@ linux_attach (unsigned long pid) soon. */ err = linux_attach_lwp (ptid); if (err != 0) - error ("Cannot attach to process %ld: %s", - pid, linux_ptrace_attach_fail_reason_string (ptid, err)); + { + std::string reason = linux_ptrace_attach_fail_reason_string (ptid, err); + + error ("Cannot attach to process %ld: %s", pid, reason.c_str ()); + } proc = linux_add_process (pid, 1); diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c index 6829fcca42c..812aa0f61f1 100644 --- a/gdb/gdbserver/thread-db.c +++ b/gdb/gdbserver/thread-db.c @@ -225,9 +225,11 @@ attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p) err = linux_attach_lwp (ptid); if (err != 0) { + std::string reason = linux_ptrace_attach_fail_reason_string (ptid, err); + warning ("Could not attach to thread %ld (LWP %d): %s\n", - (unsigned long) ti_p->ti_tid, ti_p->ti_lid, - linux_ptrace_attach_fail_reason_string (ptid, err)); + (unsigned long) ti_p->ti_tid, ti_p->ti_lid, reason.c_str ()); + return 0; } |