[testsuite] Unbuffer the output in gdb.base/multi-forks.c
[deliverable/binutils-gdb.git] / gdb / findvar.c
index fd1b9d7a5f4b7f5ea1e7ac2ee795fbc53691b489..a39d89788e8c16dd128887913c3ac8d8d998cb95 100644 (file)
@@ -1,6 +1,6 @@
 /* Find a variable's value in memory, for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2015 Free Software Foundation, Inc.
+   Copyright (C) 1986-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -737,8 +737,20 @@ default_read_var_value (struct symbol *var, const struct block *var_block,
           symbol_objfile (var));
        msym = lookup_data.result.minsym;
 
+       /* If we can't find the minsym there's a problem in the symbol info.
+          The symbol exists in the debug info, but it's missing in the minsym
+          table.  */
        if (msym == NULL)
-         error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var));
+         {
+           const char *flavour_name
+             = objfile_flavour_name (symbol_objfile (var));
+
+           /* We can't get here unless we've opened the file, so flavour_name
+              can't be NULL.  */
+           gdb_assert (flavour_name != NULL);
+           error (_("Missing %s symbol \"%s\"."),
+                  flavour_name, SYMBOL_LINKAGE_NAME (var));
+         }
        obj_section = MSYMBOL_OBJ_SECTION (lookup_data.result.objfile, msym);
        /* Relocate address, unless there is no section or the variable is
           a TLS variable. */
@@ -915,6 +927,12 @@ address_from_register (int regnum, struct frame_info *frame)
   struct type *type = builtin_type (gdbarch)->builtin_data_ptr;
   struct value *value;
   CORE_ADDR result;
+  int regnum_max_excl = (gdbarch_num_regs (gdbarch)
+                        + gdbarch_num_pseudo_regs (gdbarch));
+
+  if (regnum < 0 || regnum >= regnum_max_excl)
+    error (_("Invalid register #%d, expecting 0 <= # < %d"), regnum,
+          regnum_max_excl);
 
   /* This routine may be called during early unwinding, at a time
      where the ID of FRAME is not yet known.  Calling value_from_register
@@ -927,7 +945,7 @@ address_from_register (int regnum, struct frame_info *frame)
      pointer types.  Avoid constructing a value object in those cases.  */
   if (gdbarch_convert_register_p (gdbarch, regnum, type))
     {
-      gdb_byte *buf = alloca (TYPE_LENGTH (type));
+      gdb_byte *buf = (gdb_byte *) alloca (TYPE_LENGTH (type));
       int optim, unavail, ok;
 
       ok = gdbarch_register_to_value (gdbarch, frame, regnum, type,
This page took 0.024815 seconds and 4 git commands to generate.