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.
This commit is contained in:
parent
2a9b2c1abe
commit
c7110220be
@ -1,3 +1,13 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2018-06-07 Alan Hayward <alan.hayward@arm.com>
|
2018-06-07 Alan Hayward <alan.hayward@arm.com>
|
||||||
|
|
||||||
* aarch64-tdep.c (AARCH64_SVE_V0_REGNUM): Add define.
|
* aarch64-tdep.c (AARCH64_SVE_V0_REGNUM): Add define.
|
||||||
|
@ -327,15 +327,6 @@ extern int print_address_symbolic (struct gdbarch *, CORE_ADDR,
|
|||||||
struct ui_file *, int,
|
struct ui_file *, int,
|
||||||
const char *);
|
const char *);
|
||||||
|
|
||||||
extern int build_address_symbolic (struct gdbarch *,
|
|
||||||
CORE_ADDR addr,
|
|
||||||
int do_demangle,
|
|
||||||
char **name,
|
|
||||||
int *offset,
|
|
||||||
char **filename,
|
|
||||||
int *line,
|
|
||||||
int *unmapped);
|
|
||||||
|
|
||||||
extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *);
|
extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *);
|
||||||
extern const char *pc_prefix (CORE_ADDR);
|
extern const char *pc_prefix (CORE_ADDR);
|
||||||
|
|
||||||
|
11
gdb/disasm.c
11
gdb/disasm.c
@ -30,6 +30,7 @@
|
|||||||
#include "safe-ctype.h"
|
#include "safe-ctype.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "common/gdb_optional.h"
|
#include "common/gdb_optional.h"
|
||||||
|
#include "valprint.h"
|
||||||
|
|
||||||
/* Disassemble functions.
|
/* Disassemble functions.
|
||||||
FIXME: We should get rid of all the duplicate code in gdb that does
|
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 offset;
|
||||||
int line;
|
int line;
|
||||||
int size;
|
int size;
|
||||||
char *filename = NULL;
|
|
||||||
char *name = NULL;
|
|
||||||
CORE_ADDR pc;
|
CORE_ADDR pc;
|
||||||
struct gdbarch *gdbarch = arch ();
|
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->text (pc_prefix (pc));
|
||||||
uiout->field_core_addr ("address", gdbarch, pc);
|
uiout->field_core_addr ("address", gdbarch, pc);
|
||||||
|
|
||||||
|
std::string name, filename;
|
||||||
if (!build_address_symbolic (gdbarch, pc, 0, &name, &offset, &filename,
|
if (!build_address_symbolic (gdbarch, pc, 0, &name, &offset, &filename,
|
||||||
&line, &unmapped))
|
&line, &unmapped))
|
||||||
{
|
{
|
||||||
@ -244,7 +244,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout,
|
|||||||
the future. */
|
the future. */
|
||||||
uiout->text (" <");
|
uiout->text (" <");
|
||||||
if ((flags & DISASSEMBLY_OMIT_FNAME) == 0)
|
if ((flags & DISASSEMBLY_OMIT_FNAME) == 0)
|
||||||
uiout->field_string ("func-name", name);
|
uiout->field_string ("func-name", name.c_str ());
|
||||||
uiout->text ("+");
|
uiout->text ("+");
|
||||||
uiout->field_int ("offset", offset);
|
uiout->field_int ("offset", offset);
|
||||||
uiout->text (">:\t");
|
uiout->text (">:\t");
|
||||||
@ -252,11 +252,6 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout,
|
|||||||
else
|
else
|
||||||
uiout->text (":\t");
|
uiout->text (":\t");
|
||||||
|
|
||||||
if (filename != NULL)
|
|
||||||
xfree (filename);
|
|
||||||
if (name != NULL)
|
|
||||||
xfree (name);
|
|
||||||
|
|
||||||
m_insn_stb.clear ();
|
m_insn_stb.clear ();
|
||||||
|
|
||||||
if (flags & DISASSEMBLY_RAW_INSN)
|
if (flags & DISASSEMBLY_RAW_INSN)
|
||||||
|
@ -520,63 +520,50 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
|
|||||||
struct ui_file *stream,
|
struct ui_file *stream,
|
||||||
int do_demangle, const char *leadin)
|
int do_demangle, const char *leadin)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
std::string name, filename;
|
||||||
char *filename = NULL;
|
|
||||||
int unmapped = 0;
|
int unmapped = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int line = 0;
|
int line = 0;
|
||||||
|
|
||||||
/* Throw away both name and filename. */
|
|
||||||
struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &name);
|
|
||||||
make_cleanup (free_current_contents, &filename);
|
|
||||||
|
|
||||||
if (build_address_symbolic (gdbarch, addr, do_demangle, &name, &offset,
|
if (build_address_symbolic (gdbarch, addr, do_demangle, &name, &offset,
|
||||||
&filename, &line, &unmapped))
|
&filename, &line, &unmapped))
|
||||||
{
|
return 0;
|
||||||
do_cleanups (cleanup_chain);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fputs_filtered (leadin, stream);
|
fputs_filtered (leadin, stream);
|
||||||
if (unmapped)
|
if (unmapped)
|
||||||
fputs_filtered ("<*", stream);
|
fputs_filtered ("<*", stream);
|
||||||
else
|
else
|
||||||
fputs_filtered ("<", stream);
|
fputs_filtered ("<", stream);
|
||||||
fputs_filtered (name, stream);
|
fputs_filtered (name.c_str (), stream);
|
||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
fprintf_filtered (stream, "+%u", (unsigned int) offset);
|
fprintf_filtered (stream, "+%u", (unsigned int) offset);
|
||||||
|
|
||||||
/* Append source filename and line number if desired. Give specific
|
/* Append source filename and line number if desired. Give specific
|
||||||
line # of this addr, if we have it; else line # of the nearest symbol. */
|
line # of this addr, if we have it; else line # of the nearest symbol. */
|
||||||
if (print_symbol_filename && filename != NULL)
|
if (print_symbol_filename && !filename.empty ())
|
||||||
{
|
{
|
||||||
if (line != -1)
|
if (line != -1)
|
||||||
fprintf_filtered (stream, " at %s:%d", filename, line);
|
fprintf_filtered (stream, " at %s:%d", filename.c_str (), line);
|
||||||
else
|
else
|
||||||
fprintf_filtered (stream, " in %s", filename);
|
fprintf_filtered (stream, " in %s", filename.c_str ());
|
||||||
}
|
}
|
||||||
if (unmapped)
|
if (unmapped)
|
||||||
fputs_filtered ("*>", stream);
|
fputs_filtered ("*>", stream);
|
||||||
else
|
else
|
||||||
fputs_filtered (">", stream);
|
fputs_filtered (">", stream);
|
||||||
|
|
||||||
do_cleanups (cleanup_chain);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Given an address ADDR return all the elements needed to print the
|
/* See valprint.h. */
|
||||||
address in a symbolic form. NAME can be mangled or not depending
|
|
||||||
on DO_DEMANGLE (and also on the asm_demangle global variable,
|
|
||||||
manipulated via ''set print asm-demangle''). Return 0 in case of
|
|
||||||
success, when all the info in the OUT paramters is valid. Return 1
|
|
||||||
otherwise. */
|
|
||||||
int
|
int
|
||||||
build_address_symbolic (struct gdbarch *gdbarch,
|
build_address_symbolic (struct gdbarch *gdbarch,
|
||||||
CORE_ADDR addr, /* IN */
|
CORE_ADDR addr, /* IN */
|
||||||
int do_demangle, /* IN */
|
int do_demangle, /* IN */
|
||||||
char **name, /* OUT */
|
std::string *name, /* OUT */
|
||||||
int *offset, /* OUT */
|
int *offset, /* OUT */
|
||||||
char **filename, /* OUT */
|
std::string *filename, /* OUT */
|
||||||
int *line, /* OUT */
|
int *line, /* OUT */
|
||||||
int *unmapped) /* OUT */
|
int *unmapped) /* OUT */
|
||||||
{
|
{
|
||||||
@ -678,7 +665,7 @@ build_address_symbolic (struct gdbarch *gdbarch,
|
|||||||
|
|
||||||
*offset = addr - name_location;
|
*offset = addr - name_location;
|
||||||
|
|
||||||
*name = xstrdup (name_temp);
|
*name = name_temp;
|
||||||
|
|
||||||
if (print_symbol_filename)
|
if (print_symbol_filename)
|
||||||
{
|
{
|
||||||
@ -688,7 +675,7 @@ build_address_symbolic (struct gdbarch *gdbarch,
|
|||||||
|
|
||||||
if (sal.symtab)
|
if (sal.symtab)
|
||||||
{
|
{
|
||||||
*filename = xstrdup (symtab_to_filename_for_display (sal.symtab));
|
*filename = symtab_to_filename_for_display (sal.symtab);
|
||||||
*line = sal.line;
|
*line = sal.line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,4 +229,20 @@ extern void print_command_parse_format (const char **expp, const char *cmdname,
|
|||||||
struct format_data *fmtp);
|
struct format_data *fmtp);
|
||||||
extern void print_value (struct value *val, const struct format_data *fmtp);
|
extern void print_value (struct value *val, const struct format_data *fmtp);
|
||||||
|
|
||||||
|
/* Given an address ADDR return all the elements needed to print the
|
||||||
|
address in a symbolic form. NAME can be mangled or not depending
|
||||||
|
on DO_DEMANGLE (and also on the asm_demangle global variable,
|
||||||
|
manipulated via ''set print asm-demangle''). Return 0 in case of
|
||||||
|
success, when all the info in the OUT paramters is valid. Return 1
|
||||||
|
otherwise. */
|
||||||
|
|
||||||
|
extern int build_address_symbolic (struct gdbarch *,
|
||||||
|
CORE_ADDR addr,
|
||||||
|
int do_demangle,
|
||||||
|
std::string *name,
|
||||||
|
int *offset,
|
||||||
|
std::string *filename,
|
||||||
|
int *line,
|
||||||
|
int *unmapped);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user