int offset = 0;
int line = 0;
- if (build_address_symbolic (gdbarch, addr, do_demangle, &name, &offset,
- &filename, &line, &unmapped))
+ if (build_address_symbolic (gdbarch, addr, do_demangle, false, &name,
+ &offset, &filename, &line, &unmapped))
return 0;
fputs_filtered (leadin, stream);
fputs_filtered ("<", stream);
fputs_styled (name.c_str (), function_name_style.style (), stream);
if (offset != 0)
- fprintf_filtered (stream, "+%u", (unsigned int) offset);
+ fprintf_filtered (stream, "%+d", offset);
/* Append source filename and line number if desired. Give specific
line # of this addr, if we have it; else line # of the nearest symbol. */
int
build_address_symbolic (struct gdbarch *gdbarch,
CORE_ADDR addr, /* IN */
- int do_demangle, /* IN */
+ bool do_demangle, /* IN */
+ bool prefer_sym_over_minsym, /* IN */
std::string *name, /* OUT */
int *offset, /* OUT */
std::string *filename, /* OUT */
}
}
- /* First try to find the address in the symbol table, then
- in the minsyms. Take the closest one. */
+ /* Try to find the address in both the symbol table and the minsyms.
+ In most cases, we'll prefer to use the symbol instead of the
+ minsym. However, there are cases (see below) where we'll choose
+ to use the minsym instead. */
/* This is defective in the sense that it only finds text symbols. So
really this is kind of pointless--we should make sure that the
if (msymbol.minsym != NULL)
{
- if (BMSYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL)
+ /* Use the minsym if no symbol is found.
+
+ Additionally, use the minsym instead of a (found) symbol if
+ the following conditions all hold:
+ 1) The prefer_sym_over_minsym flag is false.
+ 2) The minsym address is identical to that of the address under
+ consideration.
+ 3) The symbol address is not identical to that of the address
+ under consideration. */
+ if (symbol == NULL ||
+ (!prefer_sym_over_minsym
+ && BMSYMBOL_VALUE_ADDRESS (msymbol) == addr
+ && name_location != addr))
{
/* If this is a function (i.e. a code address), strip out any
non-address bits. For instance, display a pointer to the
|| MSYMBOL_TYPE (msymbol.minsym) == mst_solib_trampoline)
addr = gdbarch_addr_bits_remove (gdbarch, addr);
- /* The msymbol is closer to the address than the symbol;
- use the msymbol instead. */
symbol = 0;
name_location = BMSYMBOL_VALUE_ADDRESS (msymbol);
if (do_demangle || asm_demangle)
&& name_location + max_symbolic_offset > name_location)
return 1;
- *offset = addr - name_location;
+ *offset = (LONGEST) addr - name_location;
*name = name_temp;
This is useful in user-defined commands."));
add_prefix_cmd ("set", class_vars, set_command, _("\
-Evaluate expression EXP and assign result to variable VAR\n\
+Evaluate expression EXP and assign result to variable VAR.\n\
Usage: set VAR = EXP\n\
This uses assignment syntax appropriate for the current language\n\
(VAR = EXP or VAR := EXP for example).\n\
&setlist, "set ", 1, &cmdlist);
if (dbx_commands)
add_com ("assign", class_vars, set_command, _("\
-Evaluate expression EXP and assign result to variable VAR\n\
+Evaluate expression EXP and assign result to variable VAR.\n\
Usage: assign VAR = EXP\n\
This uses assignment syntax appropriate for the current language\n\
(VAR = EXP or VAR := EXP for example).\n\
set_cmd_completer_handle_brkchars (c, print_command_completer);
add_cmd ("variable", class_vars, set_command, _("\
-Evaluate expression EXP and assign result to variable VAR\n\
+Evaluate expression EXP and assign result to variable VAR.\n\
Usage: set variable VAR = EXP\n\
This uses assignment syntax appropriate for the current language\n\
(VAR = EXP or VAR := EXP for example).\n\
const auto print_opts = make_value_print_options_def_group (nullptr);
- static const std::string print_help = gdb::option::build_help (N_("\
+ static const std::string print_help = gdb::option::build_help (_("\
Print value of expression EXP.\n\
Usage: print [[OPTION]... --] [/FMT] [EXP]\n\
\n\
Options:\n\
-%OPTIONS%\
+%OPTIONS%\n\
+\n\
Note: because this command accepts arbitrary expressions, if you\n\
specify any command option, you must use a double dash (\"--\")\n\
to mark the end of option processing. E.g.: \"print -o -- myobj\".\n\