X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fprintcmd.c;h=10d3c230ee6d680f9e17a6e72ec8668bccf1f65e;hb=9f1b45b0da430a7a7abf9e54acbe6f2ef9d3a763;hp=3e1d0265356bba584faeeaf275225fbd35d09577;hpb=6f937416b997de1c0fb4664df3b7a69910b66b76;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 3e1d026535..10d3c230ee 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1,6 +1,6 @@ /* Print values for GNU debugger GDB. - Copyright (C) 1986-2013 Free Software Foundation, Inc. + Copyright (C) 1986-2014 Free Software Foundation, Inc. This file is part of GDB. @@ -18,7 +18,7 @@ along with this program. If not, see . */ #include "defs.h" -#include "gdb_string.h" +#include #include "frame.h" #include "symtab.h" #include "gdbtypes.h" @@ -41,7 +41,6 @@ #include "block.h" #include "disasm.h" #include "dfp.h" -#include "valprint.h" #include "exceptions.h" #include "observer.h" #include "solist.h" @@ -533,6 +532,10 @@ print_scalar_formatted (const void *valaddr, struct type *type, } break; + case 'z': + print_hex_chars (stream, valaddr, len, byte_order); + break; + default: error (_("Undefined output format \"%c\"."), options->format); } @@ -658,7 +661,7 @@ build_address_symbolic (struct gdbarch *gdbarch, save some memory, but for many debug format--ELF/DWARF or anything/stabs--it would be inconvenient to eliminate those minimal symbols anyway). */ - msymbol = lookup_minimal_symbol_by_pc_section (addr, section); + msymbol = lookup_minimal_symbol_by_pc_section (addr, section).minsym; symbol = find_pc_sect_function (addr, section); if (symbol) @@ -689,6 +692,17 @@ build_address_symbolic (struct gdbarch *gdbarch, { if (SYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL) { + /* If this is a function (i.e. a code address), strip out any + non-address bits. For instance, display a pointer to the + first instruction of a Thumb function as ; the + second instruction will be , even though the + pointer is . This matches the ISA behavior. */ + if (MSYMBOL_TYPE (msymbol) == mst_text + || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc + || MSYMBOL_TYPE (msymbol) == mst_file_text + || MSYMBOL_TYPE (msymbol) == 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; @@ -936,11 +950,10 @@ static void print_command_1 (const char *exp, int voidprint) { struct expression *expr; - struct cleanup *old_chain = 0; + struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); char format = 0; struct value *val; struct format_data fmt; - int cleanup = 0; if (exp && *exp == '/') { @@ -960,8 +973,7 @@ print_command_1 (const char *exp, int voidprint) if (exp && *exp) { expr = parse_expression (exp); - old_chain = make_cleanup (free_current_contents, &expr); - cleanup = 1; + make_cleanup (free_current_contents, &expr); val = evaluate_expression (expr); } else @@ -996,8 +1008,7 @@ print_command_1 (const char *exp, int voidprint) annotate_value_end (); } - if (cleanup) - do_cleanups (old_chain); + do_cleanups (old_chain); } static void @@ -1115,7 +1126,8 @@ sym_info (char *arg, int from_tty) if (obj_section_addr (osect) <= sect_addr && sect_addr < obj_section_endaddr (osect) - && (msymbol = lookup_minimal_symbol_by_pc_section (sect_addr, osect))) + && (msymbol + = lookup_minimal_symbol_by_pc_section (sect_addr, osect).minsym)) { const char *obj_name, *mapped, *sec_name, *msym_name; char *loc_string; @@ -1138,8 +1150,8 @@ sym_info (char *arg, int from_tty) a pagination request inside printf_filtered. */ old_chain = make_cleanup (xfree, loc_string); - gdb_assert (osect->objfile && osect->objfile->name); - obj_name = osect->objfile->name; + gdb_assert (osect->objfile && objfile_name (osect->objfile)); + obj_name = objfile_name (osect->objfile); if (MULTI_OBJFILE_P ()) if (pc_in_unmapped_range (addr, osect)) @@ -1188,7 +1200,7 @@ address_info (char *exp, int from_tty) struct gdbarch *gdbarch; int regno; struct symbol *sym; - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; long val; struct obj_section *section; CORE_ADDR load_addr, context_pc = 0; @@ -1214,12 +1226,14 @@ address_info (char *exp, int from_tty) return; } - msymbol = lookup_minimal_symbol (exp, NULL, NULL); + msymbol = lookup_bound_minimal_symbol (exp); - if (msymbol != NULL) + if (msymbol.minsym != NULL) { - gdbarch = get_objfile_arch (msymbol_objfile (msymbol)); - load_addr = SYMBOL_VALUE_ADDRESS (msymbol); + struct objfile *objfile = msymbol.objfile; + + gdbarch = get_objfile_arch (objfile); + load_addr = SYMBOL_VALUE_ADDRESS (msymbol.minsym); printf_filtered ("Symbol \""); fprintf_symbol_filtered (gdb_stdout, exp, @@ -1227,7 +1241,7 @@ address_info (char *exp, int from_tty) printf_filtered ("\" is at "); fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); printf_filtered (" in a file compiled without debugging"); - section = SYMBOL_OBJ_SECTION (msymbol); + section = SYMBOL_OBJ_SECTION (objfile, msymbol.minsym); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); @@ -1248,9 +1262,17 @@ address_info (char *exp, int from_tty) current_language->la_language, DMGL_ANSI); printf_filtered ("\" is "); val = SYMBOL_VALUE (sym); - section = SYMBOL_OBJ_SECTION (sym); + section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym); gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile); + if (SYMBOL_COMPUTED_OPS (sym) != NULL) + { + SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, context_pc, + gdb_stdout); + printf_filtered (".\n"); + return; + } + switch (SYMBOL_CLASS (sym)) { case LOC_CONST: @@ -1273,14 +1295,7 @@ address_info (char *exp, int from_tty) break; case LOC_COMPUTED: - /* FIXME: cagney/2004-01-26: It should be possible to - unconditionally call the SYMBOL_COMPUTED_OPS method when available. - Unfortunately DWARF 2 stores the frame-base (instead of the - function) location in a function's symbol. Oops! For the - moment enable this when/where applicable. */ - SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, context_pc, - gdb_stdout); - break; + gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method")); case LOC_REGISTER: /* GDBARCH is the architecture associated with the objfile the symbol @@ -1352,22 +1367,22 @@ address_info (char *exp, int from_tty) case LOC_UNRESOLVED: { - struct minimal_symbol *msym; + struct bound_minimal_symbol msym; - msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, NULL); - if (msym == NULL) + msym = lookup_minimal_symbol_and_objfile (SYMBOL_LINKAGE_NAME (sym)); + if (msym.minsym == NULL) printf_filtered ("unresolved"); else { - section = SYMBOL_OBJ_SECTION (msym); - load_addr = SYMBOL_VALUE_ADDRESS (msym); + section = SYMBOL_OBJ_SECTION (msym.objfile, msym.minsym); + load_addr = SYMBOL_VALUE_ADDRESS (msym.minsym); if (section && (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) printf_filtered (_("a thread-local variable at offset %s " "in the thread-local storage for `%s'"), paddress (gdbarch, load_addr), - section->objfile->name); + objfile_name (section->objfile)); else { printf_filtered (_("static storage at address ")); @@ -1924,21 +1939,24 @@ disable_display_command (char *args, int from_tty) an item by re-parsing .exp_string field in the new execution context. */ static void -clear_dangling_display_expressions (struct so_list *solib) +clear_dangling_display_expressions (struct objfile *objfile) { - struct objfile *objfile = solib->objfile; struct display *d; + struct program_space *pspace; /* With no symbol file we cannot have a block or expression from it. */ if (objfile == NULL) return; + pspace = objfile->pspace; if (objfile->separate_debug_objfile_backlink) - objfile = objfile->separate_debug_objfile_backlink; - gdb_assert (objfile->pspace == solib->pspace); + { + objfile = objfile->separate_debug_objfile_backlink; + gdb_assert (objfile->pspace == pspace); + } for (d = display_chain; d != NULL; d = d->next) { - if (d->pspace != solib->pspace) + if (d->pspace != pspace) continue; if (lookup_objfile_from_block (d->block) == objfile @@ -2442,6 +2460,7 @@ static void printf_command (char *arg, int from_tty) { ui_printf (arg, gdb_stdout); + gdb_flush (gdb_stdout); } /* Implement the "eval" command. */ @@ -2470,7 +2489,7 @@ _initialize_printcmd (void) current_display_number = -1; - observer_attach_solib_unloaded (clear_dangling_display_expressions); + observer_attach_free_objfile (clear_dangling_display_expressions); add_info ("address", address_info, _("Describe where symbol SYM is stored.")); @@ -2484,7 +2503,8 @@ Examine memory: x/FMT ADDRESS.\n\ ADDRESS is an expression for the memory address to examine.\n\ FMT is a repeat count followed by a format letter and a size letter.\n\ Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\ - t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\ + t(binary), f(float), a(address), i(instruction), c(char), s(string)\n\ + and z(hex, zero padded on the left).\n\ Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\ The specified number of objects of the specified size are printed\n\ according to the format.\n\n\ @@ -2611,7 +2631,12 @@ but no count or size letter (see \"x\" command).")); add_setshow_uinteger_cmd ("max-symbolic-offset", no_class, &max_symbolic_offset, _("\ Set the largest offset that will be printed in form."), _("\ -Show the largest offset that will be printed in form."), NULL, +Show the largest offset that will be printed in form."), _("\ +Tell GDB to only display the symbolic form of an address if the\n\ +offset between the closest earlier symbol and the address is less than\n\ +the specified maximum offset. The default is \"unlimited\", which tells GDB\n\ +to always print the symbolic form of an address if any symbol precedes\n\ +it. Zero is equivalent to \"unlimited\"."), NULL, show_max_symbolic_offset, &setprintlist, &showprintlist);