daily update
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index 7decc397a7a6790633343a659391dcd8188ab5d0..1cc248d70f60091eb2f1be4f7a1297ff7cfaec32 100644 (file)
@@ -533,6 +533,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 +662,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 +693,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 <function>; the
+            second instruction will be <function+2>, even though the
+            pointer is <function+3>.  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 +951,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 +974,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 +1009,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 +1127,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;
@@ -1218,7 +1231,9 @@ address_info (char *exp, int from_tty)
 
       if (msymbol != NULL)
        {
-         gdbarch = get_objfile_arch (msymbol_objfile (msymbol));
+         struct objfile *objfile = msymbol_objfile (msymbol);
+
+         gdbarch = get_objfile_arch (objfile);
          load_addr = SYMBOL_VALUE_ADDRESS (msymbol);
 
          printf_filtered ("Symbol \"");
@@ -1227,7 +1242,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);
          if (section_is_overlay (section))
            {
              load_addr = overlay_unmapped_address (load_addr, section);
@@ -1248,7 +1263,7 @@ 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)
@@ -1353,15 +1368,15 @@ 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)
@@ -2485,7 +2500,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\
@@ -2612,7 +2628,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 <symbol+1234> form."), _("\
-Show the largest offset that will be printed in <symbol+1234> form."), NULL,
+Show the largest offset that will be printed in <symbol+1234> 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);
This page took 0.025414 seconds and 4 git commands to generate.