aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-01-07 10:50:48 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2018-01-07 10:50:48 -0500
commit2cc050302cd365fd28fac65d49b6c817eed74faf (patch)
treed83d6b14675bdbbb207c125e37e051d2bc9ae8e4 /gdb
parentb01ba14d4d5391e59fd0e1a3608fd47287edc008 (diff)
downloadgdb-2cc050302cd365fd28fac65d49b6c817eed74faf.zip
gdb-2cc050302cd365fd28fac65d49b6c817eed74faf.tar.gz
gdb-2cc050302cd365fd28fac65d49b6c817eed74faf.tar.bz2
Make parse_debug_format_options return an std::string
This avoid having to manually free the return value. gdb/gdbserver/ChangeLog: * server.c (parse_debug_format_options): Return std::string. (handle_monitor_command, captured_main): Adjust.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbserver/ChangeLog5
-rw-r--r--gdb/gdbserver/server.c21
2 files changed, 15 insertions, 11 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 2299c8e..b9757c3 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 1a72123..665d9aa 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -1295,7 +1295,7 @@ handle_detach (char *own_buf)
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;
@@ -1338,8 +1338,8 @@ parse_debug_format_options (const char *arg, int is_monitor)
}
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;
@@ -1347,7 +1347,7 @@ parse_debug_format_options (const char *arg, int is_monitor)
}
free_char_ptr_vec (options);
- return NULL;
+ return std::string ();
}
/* Handle monitor commands not handled by target-specific handlers. */
@@ -1387,16 +1387,15 @@ handle_monitor_command (char *mon, char *own_buf)
}
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)
@@ -3611,13 +3610,13 @@ captured_main (int argc, char *argv[])
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);
}
}