This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/Ada] Fix crash when printing 'first/'last of type


This patch fixes a debugger crash when trying to print the 'first or
'last value of type Short_Integer when this type is not used in the
program (or debug info for this type is not available).

2009-03-12  Joel Brobecker  <brobecker@adacore.com>

        Fix segfault when printing short_integer'last.

        * ada-lang.c (ada_find_any_type): Search in the primitive types
        if a symbol could not be found.

A testcase is also provided.

2009-03-12  Joel Brobecker  <brobecker@adacore.com>

        * gdb.ada/tick_last_segv: New testcase.

Tested on amd64-linux. Checked in.

-- 
Joel
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index fbcc32a..12ee5cf 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -6535,11 +6535,16 @@ struct type *
 ada_find_any_type (const char *name)
 {
   struct symbol *sym = ada_find_any_symbol (name);
+  struct type *type = NULL;
 
   if (sym != NULL)
-    return SYMBOL_TYPE (sym);
+    type = SYMBOL_TYPE (sym);
 
-  return NULL;
+  if (type == NULL)
+    type = language_lookup_primitive_type_by_name
+      (language_def (language_ada), current_gdbarch, name);
+
+  return type;
 }
 
 /* Given NAME and an associated BLOCK, search all symbols for

Attachment: foo.adb
Description: foo.adb

Attachment: tick_last_segv.exp
Description: tick_last_segv.exp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]