Handle EM_L1OM.
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index c2468d01353833b18c1808d18f1bd124d56874aa..d202330ab08160d2d3113f6eebeb679b192ceac6 100644 (file)
@@ -46,7 +46,6 @@
 #include "exceptions.h"
 #include "observer.h"
 #include "solist.h"
-#include "solib.h"
 #include "parser-defs.h"
 #include "charset.h"
 #include "arch-utils.h"
@@ -260,6 +259,11 @@ decode_format (char **string_ptr, int oformat, int osize)
        /* Characters default to one byte.  */
        val.size = osize ? 'b' : osize;
        break;
+      case 's':
+       /* Display strings with byte size chars unless explicitly specified.  */
+       val.size = '\0';
+       break;
+
       default:
        /* The default is the size most recently specified.  */
        val.size = osize;
@@ -295,7 +299,7 @@ print_formatted (struct value *val, int size,
            next_address = (value_address (val)
                            + val_print_string (elttype,
                                                value_address (val), -1,
-                                               stream, options));
+                                               stream, options) * len);
          }
          return;
 
@@ -802,9 +806,11 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
   next_gdbarch = gdbarch;
   next_address = addr;
 
-  /* String or instruction format implies fetch single bytes
-     regardless of the specified size.  */
-  if (format == 's' || format == 'i')
+  /* Instruction format implies fetch single bytes
+     regardless of the specified size.
+     The case of strings is handled in decode_format, only explicit
+     size operator are not changed to 'b'.  */
+  if (format == 'i')
     size = 'b';
 
   if (size == 'a')
@@ -831,6 +837,27 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
   else if (size == 'g')
     val_type = builtin_type (next_gdbarch)->builtin_int64;
 
+  if (format == 's')
+    {
+      struct type *char_type = NULL;
+      /* Search for "char16_t"  or "char32_t" types or fall back to 8-bit char
+        if type is not found.  */
+      if (size == 'h')
+       char_type = builtin_type (next_gdbarch)->builtin_char16;
+      else if (size == 'w')
+       char_type = builtin_type (next_gdbarch)->builtin_char32;
+      if (char_type)
+        val_type = char_type;
+      else
+        {
+         if (size != '\0' && size != 'b')
+           warning (_("Unable to display strings with size '%c', using 'b' \
+instead."), size);
+         size = 'b';
+         val_type = builtin_type (next_gdbarch)->builtin_int8;
+        }
+    }
+
   maxelts = 8;
   if (size == 'w')
     maxelts = 4;
@@ -932,7 +959,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
 
   if (exp && *exp)
     {
-      struct type *type;
       expr = parse_expression (exp);
       old_chain = make_cleanup (free_current_contents, &expr);
       cleanup = 1;
@@ -1148,7 +1174,6 @@ sym_info (char *arg, int from_tty)
 static void
 address_info (char *exp, int from_tty)
 {
-  struct block *block;
   struct gdbarch *gdbarch;
   int regno;
   struct symbol *sym;
@@ -1393,7 +1418,7 @@ x_command (char *exp, int from_tty)
       old_chain = make_cleanup (free_current_contents, &expr);
       val = evaluate_expression (expr);
       if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF)
-       val = value_ind (val);
+       val = coerce_ref (val);
       /* In rvalue contexts, such as this, functions are coerced into
          pointers to functions.  This makes "x/i main" work.  */
       if (/* last_format == 'i'  && */ 
@@ -1413,8 +1438,11 @@ x_command (char *exp, int from_tty)
   do_examine (fmt, next_gdbarch, next_address);
 
   /* If the examine succeeds, we remember its size and format for next
-     time.  */
-  last_size = fmt.size;
+     time.  Set last_size to 'b' for strings.  */
+  if (fmt.format == 's')
+    last_size = 'b';
+  else
+    last_size = fmt.size;
   last_format = fmt.format;
 
   /* Set a couple of internal variables if appropriate. */
@@ -1860,51 +1888,6 @@ disable_display_command (char *args, int from_tty)
       }
 }
 
-/* Return 1 if D uses SOLIB (and will become dangling when SOLIB
-   is unloaded), otherwise return 0.  */
-
-static int
-display_uses_solib_p (const struct display *d,
-                     const struct so_list *solib)
-{
-  int endpos;
-  struct expression *const exp = d->exp;
-  const union exp_element *const elts = exp->elts;
-
-  if (d->block != NULL
-      && d->pspace == solib->pspace
-      && solib_contains_address_p (solib, d->block->startaddr))
-    return 1;
-
-  for (endpos = exp->nelts; endpos > 0; )
-    {
-      int i, args, oplen = 0;
-
-      exp->language_defn->la_exp_desc->operator_length (exp, endpos,
-                                                       &oplen, &args);
-      gdb_assert (oplen > 0);
-
-      i = endpos - oplen;
-      if (elts[i].opcode == OP_VAR_VALUE)
-       {
-         const struct block *const block = elts[i + 1].block;
-         const struct symbol *const symbol = elts[i + 2].symbol;
-
-         if (block != NULL
-             && solib_contains_address_p (solib,
-                                          block->startaddr))
-           return 1;
-
-         /* SYMBOL_OBJ_SECTION (symbol) may be NULL.  */
-         if (SYMBOL_SYMTAB (symbol)->objfile == solib->objfile)
-           return 1;
-       }
-      endpos -= oplen;
-    }
-
-  return 0;
-}
-
 /* display_chain items point to blocks and expressions.  Some expressions in
    turn may point to symbols.
    Both symbols and blocks are obstack_alloc'd on objfile_stack, and are
@@ -1916,17 +1899,28 @@ display_uses_solib_p (const struct display *d,
 static void
 clear_dangling_display_expressions (struct so_list *solib)
 {
+  struct objfile *objfile = solib->objfile;
   struct display *d;
-  struct objfile *objfile = NULL;
 
-  for (d = display_chain; d; d = d->next)
+  /* With no symbol file we cannot have a block or expression from it.  */
+  if (objfile == NULL)
+    return;
+  if (objfile->separate_debug_objfile_backlink)
+    objfile = objfile->separate_debug_objfile_backlink;
+  gdb_assert (objfile->pspace == solib->pspace);
+
+  for (d = display_chain; d != NULL; d = d->next)
     {
-      if (d->exp && display_uses_solib_p (d, solib))
-       {
-         xfree (d->exp);
-         d->exp = NULL;
-         d->block = NULL;
-       }
+      if (d->pspace != solib->pspace)
+       continue;
+
+      if (lookup_objfile_from_block (d->block) == objfile
+         || (d->exp && exp_uses_objfile (d->exp, objfile)))
+      {
+       xfree (d->exp);
+       d->exp = NULL;
+       d->block = NULL;
+      }
     }
 }
 \f
@@ -2387,7 +2381,6 @@ printf_command (char *arg, int from_tty)
            {
              struct gdbarch *gdbarch
                = get_type_arch (value_type (val_args[i]));
-             enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
              struct type *wctype = lookup_typename (current_language, gdbarch,
                                                     "wchar_t", NULL, 0);
              struct type *valtype;
This page took 0.045799 seconds and 4 git commands to generate.