+2017-09-03 Simon Marchi <simon.marchi@ericsson.com>
+
+ * 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.
+
2017-09-01 Jan Kratochvil <jan.kratochvil@redhat.com>
PR gdb/22046
+2017-09-03 Simon Marchi <simon.marchi@ericsson.com>
+
+ * linux-low.c (linux_wait_1): Adjust.
+ * server.c (queue_stop_reply_callback): Adjust.
+
2017-08-31 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (handle_general_set): Handle QEnvironmentHexEncoded,
{
if (event_child->waitstatus.kind != TARGET_WAITKIND_IGNORE)
{
- char *str;
+ std::string str
+ = target_waitstatus_to_string (&event_child->waitstatus);
- str = target_waitstatus_to_string (&event_child->waitstatus);
debug_printf ("LWP %ld: extended event with waitstatus %s\n",
- lwpid_of (get_lwp_thread (event_child)), str);
- xfree (str);
+ lwpid_of (get_lwp_thread (event_child)), str.c_str ());
}
if (current_thread->last_resume_kind == resume_step)
{
{
if (debug_threads)
{
- char *status_string
+ std::string status_string
= target_waitstatus_to_string (&thread->last_status);
debug_printf ("Reporting thread %s as already stopped with %s\n",
target_pid_to_str (entry->id),
- status_string);
-
- xfree (status_string);
+ status_string.c_str ());
}
gdb_assert (thread->last_status.kind != TARGET_WAITKIND_IGNORE);
{
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;
}
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);
}
}
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.
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
{
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
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. */
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. */
*status = btrace_step_no_resumed ();
DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid),
- target_waitstatus_to_string (status));
+ target_waitstatus_to_string (status).c_str ());
do_cleanups (cleanups);
return null_ptid;
DEBUG ("wait ended by thread %s (%s): %s",
print_thread_id (eventing),
target_pid_to_str (eventing->ptid),
- target_waitstatus_to_string (status));
+ target_waitstatus_to_string (status).c_str ());
do_cleanups (cleanups);
return eventing->ptid;
static void
target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
{
- char *str = target_waitstatus_to_string (status);
+ std::string str = target_waitstatus_to_string (status);
- fputs_unfiltered (str, gdb_stdlog);
- xfree (str);
+ fputs_unfiltered (str.c_str (), gdb_stdlog);
}
\f
const char *name;
};
-/* Return a pretty printed form of target_waitstatus.
- Space for the result is malloc'd, caller must free. */
-extern char *target_waitstatus_to_string (const struct target_waitstatus *);
-
/* Return a pretty printed form of TARGET_OPTIONS.
Space for the result is malloc'd, caller must free. */
extern char *target_options_to_string (int target_options);
/* Return a pretty printed form of target_waitstatus.
Space for the result is malloc'd, caller must free. */
-char *
+std::string
target_waitstatus_to_string (const struct target_waitstatus *ws)
{
const char *kind_str = "status->kind = ";
switch (ws->kind)
{
case TARGET_WAITKIND_EXITED:
- return xstrprintf ("%sexited, status = %d",
- kind_str, ws->value.integer);
+ return string_printf ("%sexited, status = %d",
+ kind_str, ws->value.integer);
case TARGET_WAITKIND_STOPPED:
- return xstrprintf ("%sstopped, signal = %s",
- kind_str,
- gdb_signal_to_symbol_string (ws->value.sig));
+ return string_printf ("%sstopped, signal = %s",
+ kind_str,
+ gdb_signal_to_symbol_string (ws->value.sig));
case TARGET_WAITKIND_SIGNALLED:
- return xstrprintf ("%ssignalled, signal = %s",
- kind_str,
- gdb_signal_to_symbol_string (ws->value.sig));
+ return string_printf ("%ssignalled, signal = %s",
+ kind_str,
+ gdb_signal_to_symbol_string (ws->value.sig));
case TARGET_WAITKIND_LOADED:
- return xstrprintf ("%sloaded", kind_str);
+ return string_printf ("%sloaded", kind_str);
case TARGET_WAITKIND_FORKED:
- return xstrprintf ("%sforked", kind_str);
+ return string_printf ("%sforked", kind_str);
case TARGET_WAITKIND_VFORKED:
- return xstrprintf ("%svforked", kind_str);
+ return string_printf ("%svforked", kind_str);
case TARGET_WAITKIND_EXECD:
- return xstrprintf ("%sexecd", kind_str);
+ return string_printf ("%sexecd", kind_str);
case TARGET_WAITKIND_VFORK_DONE:
- return xstrprintf ("%svfork-done", kind_str);
+ return string_printf ("%svfork-done", kind_str);
case TARGET_WAITKIND_SYSCALL_ENTRY:
- return xstrprintf ("%sentered syscall", kind_str);
+ return string_printf ("%sentered syscall", kind_str);
case TARGET_WAITKIND_SYSCALL_RETURN:
- return xstrprintf ("%sexited syscall", kind_str);
+ return string_printf ("%sexited syscall", kind_str);
case TARGET_WAITKIND_SPURIOUS:
- return xstrprintf ("%sspurious", kind_str);
+ return string_printf ("%sspurious", kind_str);
case TARGET_WAITKIND_IGNORE:
- return xstrprintf ("%signore", kind_str);
+ return string_printf ("%signore", kind_str);
case TARGET_WAITKIND_NO_HISTORY:
- return xstrprintf ("%sno-history", kind_str);
+ return string_printf ("%sno-history", kind_str);
case TARGET_WAITKIND_NO_RESUMED:
- return xstrprintf ("%sno-resumed", kind_str);
+ return string_printf ("%sno-resumed", kind_str);
case TARGET_WAITKIND_THREAD_CREATED:
- return xstrprintf ("%sthread created", kind_str);
+ return string_printf ("%sthread created", kind_str);
case TARGET_WAITKIND_THREAD_EXITED:
- return xstrprintf ("%sthread exited, status = %d",
- kind_str, ws->value.integer);
+ return string_printf ("%sthread exited, status = %d",
+ kind_str, ws->value.integer);
default:
- return xstrprintf ("%sunknown???", kind_str);
+ return string_printf ("%sunknown???", kind_str);
}
}
/* Prototypes */
-/* Return a pretty printed form of target_waitstatus.
- Space for the result is malloc'd, caller must free. */
-extern char *target_waitstatus_to_string (const struct target_waitstatus *);
+/* Return a pretty printed form of target_waitstatus. */
+std::string target_waitstatus_to_string (const struct target_waitstatus *);
#endif /* WAITSTATUS_H */