diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-05 10:24:54 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-06-07 06:38:18 -0600 |
commit | c7110220be62590222e35525dda499902ee49a89 (patch) | |
tree | 34756b1adffc595768d9c9d9e3c8197aefed0af5 /gdb/disasm.c | |
parent | 2a9b2c1abe29e1063240604d2464b8de9a46011f (diff) | |
download | gdb-c7110220be62590222e35525dda499902ee49a89.zip gdb-c7110220be62590222e35525dda499902ee49a89.tar.gz gdb-c7110220be62590222e35525dda499902ee49a89.tar.bz2 |
Change build_address_symbolic to return std::string
This changes two out parameters of build_address_symbolic to be
std::string, and updates the callers. This allows removing some
cleanups.
This patch also moves the declaration of build_address_symbolic out of
defs.h. I think that many things in defs.h should be elsewhere
instead. In this case, I moved the declaration to valprint.h, becuase
there is no "printcmd.h" -- but perhaps it would be better to
introduce that instead.
Tested by the buildbot.
gdb/ChangeLog
2018-06-07 Tom Tromey <tom@tromey.com>
* valprint.h (build_address_symbolic): Declare.
* printcmd.c (print_address_symbolic): Update.
(build_address_symbolic): Change "name" and "filename" to
std::string.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
Update.
* defs.h (build_address_symbolic): Remove declaration.
Diffstat (limited to 'gdb/disasm.c')
-rw-r--r-- | gdb/disasm.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/gdb/disasm.c b/gdb/disasm.c index e465388..6983903 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -30,6 +30,7 @@ #include "safe-ctype.h" #include <algorithm> #include "common/gdb_optional.h" +#include "valprint.h" /* Disassemble functions. FIXME: We should get rid of all the duplicate code in gdb that does @@ -199,8 +200,6 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout, int offset; int line; int size; - char *filename = NULL; - char *name = NULL; CORE_ADDR pc; struct gdbarch *gdbarch = arch (); @@ -237,6 +236,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout, uiout->text (pc_prefix (pc)); uiout->field_core_addr ("address", gdbarch, pc); + std::string name, filename; if (!build_address_symbolic (gdbarch, pc, 0, &name, &offset, &filename, &line, &unmapped)) { @@ -244,7 +244,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout, the future. */ uiout->text (" <"); if ((flags & DISASSEMBLY_OMIT_FNAME) == 0) - uiout->field_string ("func-name", name); + uiout->field_string ("func-name", name.c_str ()); uiout->text ("+"); uiout->field_int ("offset", offset); uiout->text (">:\t"); @@ -252,11 +252,6 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout, else uiout->text (":\t"); - if (filename != NULL) - xfree (filename); - if (name != NULL) - xfree (name); - m_insn_stb.clear (); if (flags & DISASSEMBLY_RAW_INSN) |