aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-09-03 10:23:31 +0200
committerSimon Marchi <simon.marchi@ericsson.com>2017-09-03 10:23:31 +0200
commit23fdd69e42180578b3e15ba8f053fadde965bfe8 (patch)
tree5f8dc1441127578fe91dde474ec94ccde1413e94 /gdb/infrun.c
parentf04bdfa7b261402bfa9dbdde58b2feb14becd8a3 (diff)
downloadgdb-23fdd69e42180578b3e15ba8f053fadde965bfe8.zip
gdb-23fdd69e42180578b3e15ba8f053fadde965bfe8.tar.gz
gdb-23fdd69e42180578b3e15ba8f053fadde965bfe8.tar.bz2
Make target_waitstatus_to_string return an std::string
A quite straightforward change. It does "fix" leaks in record-btrace.c, although since this is only used in debug printing code, it has no real world impact. gdb/ChangeLog: * target/waitstatus.h (target_waitstatus_to_string): Change return type to std::string. * target/waitstatus.c (target_waitstatus_to_string): Return std::string. * target.h (target_waitstatus_to_string): Remove declaration. * infrun.c (resume, clear_proceed_status_thread, print_target_wait_results, do_target_wait, save_waitstatus, stop_all_threads): Adjust. * record-btrace.c (record_btrace_wait): Adjust. * target-debug.h (target_debug_print_struct_target_waitstatus_p): Adjust. gdb/gdbserver/ChangeLog: * linux-low.c (linux_wait_1): Adjust. * server.c (queue_stop_reply_callback): Adjust.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index d0e4105..06b45b4 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2409,15 +2409,14 @@ resume (enum gdb_signal sig)
{
if (debug_infrun)
{
- char *statstr;
+ std::string statstr
+ = target_waitstatus_to_string (&tp->suspend.waitstatus);
- statstr = target_waitstatus_to_string (&tp->suspend.waitstatus);
fprintf_unfiltered (gdb_stdlog,
- "infrun: resume: thread %s has pending wait status %s "
- "(currently_stepping=%d).\n",
- target_pid_to_str (tp->ptid), statstr,
+ "infrun: resume: thread %s has pending wait "
+ "status %s (currently_stepping=%d).\n",
+ target_pid_to_str (tp->ptid), statstr.c_str (),
currently_stepping (tp));
- xfree (statstr);
}
tp->resumed = 1;
@@ -2820,16 +2819,15 @@ clear_proceed_status_thread (struct thread_info *tp)
}
else if (debug_infrun)
{
- char *statstr;
+ std::string statstr
+ = target_waitstatus_to_string (&tp->suspend.waitstatus);
- statstr = target_waitstatus_to_string (&tp->suspend.waitstatus);
fprintf_unfiltered (gdb_stdlog,
"infrun: clear_proceed_status_thread: thread %s "
"has pending wait status %s "
"(currently_stepping=%d).\n",
- target_pid_to_str (tp->ptid), statstr,
+ target_pid_to_str (tp->ptid), statstr.c_str (),
currently_stepping (tp));
- xfree (statstr);
}
}
@@ -3418,7 +3416,7 @@ void
print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
const struct target_waitstatus *ws)
{
- char *status_string = target_waitstatus_to_string (ws);
+ std::string status_string = target_waitstatus_to_string (ws);
string_file stb;
/* The text is split over several lines because it was getting too long.
@@ -3438,13 +3436,11 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid,
ptid_get_lwp (result_ptid),
ptid_get_tid (result_ptid),
target_pid_to_str (result_ptid));
- stb.printf ("infrun: %s\n", status_string);
+ stb.printf ("infrun: %s\n", status_string.c_str ());
/* This uses %s in part to handle %'s in the text, but also to avoid
a gcc error: the format attribute requires a string literal. */
fprintf_unfiltered (gdb_stdlog, "%s", stb.c_str ());
-
- xfree (status_string);
}
/* Select a thread at random, out of those which are resumed and have
@@ -3566,14 +3562,13 @@ do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
{
if (debug_infrun)
{
- char *statstr;
+ std::string statstr
+ = target_waitstatus_to_string (&tp->suspend.waitstatus);
- statstr = target_waitstatus_to_string (&tp->suspend.waitstatus);
fprintf_unfiltered (gdb_stdlog,
"infrun: Using pending wait status %s for %s.\n",
- statstr,
+ statstr.c_str (),
target_pid_to_str (tp->ptid));
- xfree (statstr);
}
/* Now that we've selected our final event LWP, un-adjust its PC
@@ -4395,16 +4390,14 @@ save_waitstatus (struct thread_info *tp, struct target_waitstatus *ws)
if (debug_infrun)
{
- char *statstr;
+ std::string statstr = target_waitstatus_to_string (ws);
- statstr = target_waitstatus_to_string (ws);
fprintf_unfiltered (gdb_stdlog,
"infrun: saving status %s for %d.%ld.%ld\n",
- statstr,
+ statstr.c_str (),
ptid_get_pid (tp->ptid),
ptid_get_lwp (tp->ptid),
ptid_get_tid (tp->ptid));
- xfree (statstr);
}
/* Record for later. */
@@ -4634,17 +4627,15 @@ stop_all_threads (void)
if (debug_infrun)
{
- char *statstr;
+ std::string statstr = target_waitstatus_to_string (&ws);
- statstr = target_waitstatus_to_string (&ws);
fprintf_unfiltered (gdb_stdlog,
"infrun: target_wait %s, saving "
"status for %d.%ld.%ld\n",
- statstr,
+ statstr.c_str (),
ptid_get_pid (t->ptid),
ptid_get_lwp (t->ptid),
ptid_get_tid (t->ptid));
- xfree (statstr);
}
/* Record for later. */