This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Use std::string in info_symbol_command
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 3 Oct 2017 11:46:52 -0000
- Subject: [binutils-gdb] Use std::string in info_symbol_command
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5178ed487f813639e660fba23215fa7ba69a769e
commit 5178ed487f813639e660fba23215fa7ba69a769e
Author: Tom Tromey <tom@tromey.com>
Date: Fri Sep 29 22:49:36 2017 -0600
Use std::string in info_symbol_command
This removes a cleanup by using std::string in info_symbol_command.
2017-10-03 Tom Tromey <tom@tromey.com>
* printcmd.c (info_symbol_command): Use std::string.
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/printcmd.c | 16 +++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6c55cf..439df4a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2017-10-03 Tom Tromey <tom@tromey.com>
+ * printcmd.c (info_symbol_command): Use std::string.
+
+2017-10-03 Tom Tromey <tom@tromey.com>
+
* top.c (gdb_safe_append_history): Use std::string.
2017-10-03 Tom Tromey <tom@tromey.com>
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index a254e3a..994259d 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1314,7 +1314,7 @@ info_symbol_command (char *arg, int from_tty)
= lookup_minimal_symbol_by_pc_section (sect_addr, osect).minsym))
{
const char *obj_name, *mapped, *sec_name, *msym_name;
- char *loc_string;
+ const char *loc_string;
struct cleanup *old_chain;
matches = 1;
@@ -1325,14 +1325,14 @@ info_symbol_command (char *arg, int from_tty)
/* Don't print the offset if it is zero.
We assume there's no need to handle i18n of "sym + offset". */
+ std::string string_holder;
if (offset)
- loc_string = xstrprintf ("%s + %u", msym_name, offset);
+ {
+ string_holder = string_printf ("%s + %u", msym_name, offset);
+ loc_string = string_holder.c_str ();
+ }
else
- loc_string = xstrprintf ("%s", msym_name);
-
- /* Use a cleanup to free loc_string in case the user quits
- a pagination request inside printf_filtered. */
- old_chain = make_cleanup (xfree, loc_string);
+ loc_string = msym_name;
gdb_assert (osect->objfile && objfile_name (osect->objfile));
obj_name = objfile_name (osect->objfile);
@@ -1370,8 +1370,6 @@ info_symbol_command (char *arg, int from_tty)
else
printf_filtered (_("%s in section %s\n"),
loc_string, sec_name);
-
- do_cleanups (old_chain);
}
}
if (matches == 0)