+2018-01-07 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * server.c (parse_debug_format_options): Return std::string.
+ (handle_monitor_command, captured_main): Adjust.
+
2018-01-05 Pedro Alves <palves@redhat.com>
PR gdb/18653
to gdb's "set debug foo on|off" because we also use this function to
parse "--debug-format=foo,bar". */
-static char *
+static std::string
parse_debug_format_options (const char *arg, int is_monitor)
{
VEC (char_ptr) *options;
}
else
{
- char *msg = xstrprintf ("Unknown debug-format argument: \"%s\"\n",
- option);
+ std::string msg
+ = string_printf ("Unknown debug-format argument: \"%s\"\n", option);
free_char_ptr_vec (options);
return msg;
}
free_char_ptr_vec (options);
- return NULL;
+ return std::string ();
}
/* Handle monitor commands not handled by target-specific handlers. */
}
else if (startswith (mon, "set debug-format "))
{
- char *error_msg
+ std::string error_msg
= parse_debug_format_options (mon + sizeof ("set debug-format ") - 1,
1);
- if (error_msg != NULL)
+ if (!error_msg.empty ())
{
- monitor_output (error_msg);
+ monitor_output (error_msg.c_str ());
monitor_show_help ();
write_enn (own_buf);
- xfree (error_msg);
}
}
else if (strcmp (mon, "help") == 0)
debug_threads = 1;
else if (startswith (*next_arg, "--debug-format="))
{
- char *error_msg
+ std::string error_msg
= parse_debug_format_options ((*next_arg)
+ sizeof ("--debug-format=") - 1, 0);
- if (error_msg != NULL)
+ if (!error_msg.empty ())
{
- fprintf (stderr, "%s", error_msg);
+ fprintf (stderr, "%s", error_msg.c_str ());
exit (1);
}
}