aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-09-27 20:46:18 -0600
committerTom Tromey <tom@tromey.com>2017-09-29 20:46:44 -0600
commit6ad94bc76615933a234a219368f1b9af2a64d746 (patch)
tree0d1482ca6e142e1d5b3c1af591bbe2ab88aafa41
parent2003f3d839fa887811ff65380191e0beaeff719e (diff)
downloadgdb-6ad94bc76615933a234a219368f1b9af2a64d746.zip
gdb-6ad94bc76615933a234a219368f1b9af2a64d746.tar.gz
gdb-6ad94bc76615933a234a219368f1b9af2a64d746.tar.bz2
Remove cleanups from cp-support.c
This removes some cleanups from cp-support.c, using std::string. gdb/ChangeLog 2017-09-29 Tom Tromey <tom@tromey.com> * cp-support.c (gdb_demangle): Use std::string.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/cp-support.c25
2 files changed, 14 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 896c9fe..1fadba2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2017-09-29 Tom Tromey <tom@tromey.com>
+ * cp-support.c (gdb_demangle): Use std::string.
+
+2017-09-29 Tom Tromey <tom@tromey.com>
+
* stack.c (parse_frame_specification): Use std::string
(info_frame_command): Use gdb::unique_xmalloc_ptr.
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 6b5f2a3..d88bdaa 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1546,17 +1546,14 @@ gdb_demangle (const char *name, int options)
if (!error_reported)
{
- char *short_msg, *long_msg;
- struct cleanup *back_to;
+ std::string short_msg
+ = string_printf (_("unable to demangle '%s' "
+ "(demangler failed with signal %d)"),
+ name, crash_signal);
- short_msg = xstrprintf (_("unable to demangle '%s' "
- "(demangler failed with signal %d)"),
- name, crash_signal);
- back_to = make_cleanup (xfree, short_msg);
-
- long_msg = xstrprintf ("%s:%d: %s: %s", __FILE__, __LINE__,
- "demangler-warning", short_msg);
- make_cleanup (xfree, long_msg);
+ std::string long_msg
+ = string_printf ("%s:%d: %s: %s", __FILE__, __LINE__,
+ "demangler-warning", short_msg.c_str ());
target_terminal::scoped_restore_terminal_state term_state;
target_terminal::ours_for_output ();
@@ -1565,13 +1562,11 @@ gdb_demangle (const char *name, int options)
if (core_dump_allowed)
fprintf_unfiltered (gdb_stderr,
_("%s\nAttempting to dump core.\n"),
- long_msg);
+ long_msg.c_str ());
else
- warn_cant_dump_core (long_msg);
-
- demangler_warning (__FILE__, __LINE__, "%s", short_msg);
+ warn_cant_dump_core (long_msg.c_str ());
- do_cleanups (back_to);
+ demangler_warning (__FILE__, __LINE__, "%s", short_msg.c_str ());
error_reported = 1;
}