2007-02-09 Gabriel Dos Reis <gdr@integrable-solutions.net>
[deliverable/binutils-gdb.git] / gdb / ada-lang.c
index 706806efac427851018cfef61d554bc84646fb53..afee231811ca46f44f2f52faf87ae0684c6e8db8 100644 (file)
@@ -55,6 +55,7 @@ Boston, MA 02110-1301, USA.  */
 #include "exceptions.h"
 #include "annotate.h"
 #include "valprint.h"
+#include "source.h"
 
 #ifndef ADA_RETAIN_DOTS
 #define ADA_RETAIN_DOTS 0
@@ -4119,7 +4120,7 @@ symtab_for_sym (struct symbol *sym)
   struct dict_iterator iter;
   int j;
 
-  ALL_SYMTABS (objfile, s)
+  ALL_PRIMARY_SYMTABS (objfile, s)
   {
     switch (SYMBOL_CLASS (sym))
       {
@@ -4418,7 +4419,7 @@ renaming_is_visible (const struct symbol *sym, char *function_name)
 
 static int
 remove_out_of_scope_renamings (struct ada_symbol_info *syms,
-                               int nsyms, struct block *current_block)
+                               int nsyms, const struct block *current_block)
 {
   struct symbol *current_function;
   char *current_function_name;
@@ -4548,11 +4549,9 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
   /* Now add symbols from all global blocks: symbol tables, minimal symbol
      tables, and psymtab's.  */
 
-  ALL_SYMTABS (objfile, s)
+  ALL_PRIMARY_SYMTABS (objfile, s)
   {
     QUIT;
-    if (!s->primary)
-      continue;
     bv = BLOCKVECTOR (s);
     block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
     ada_add_block_symbols (&symbol_list_obstack, block, name, namespace,
@@ -4618,11 +4617,9 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
   if (num_defns_collected (&symbol_list_obstack) == 0)
     {
 
-      ALL_SYMTABS (objfile, s)
+      ALL_PRIMARY_SYMTABS (objfile, s)
       {
         QUIT;
-        if (!s->primary)
-          continue;
         bv = BLOCKVECTOR (s);
         block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
         ada_add_block_symbols (&symbol_list_obstack, block, name, namespace,
@@ -4659,8 +4656,7 @@ done:
     cache_symbol (name0, namespace, (*results)[0].sym, (*results)[0].block,
                   (*results)[0].symtab);
 
-  ndefns = remove_out_of_scope_renamings (*results, ndefns,
-                                          (struct block *) block0);
+  ndefns = remove_out_of_scope_renamings (*results, ndefns, block0);
 
   return ndefns;
 }
@@ -4702,7 +4698,7 @@ ada_lookup_symbol (const char *name, const struct block *block0,
 
           /* Search the list of symtabs for one which contains the
              address of the start of this block.  */
-          ALL_SYMTABS (objfile, s)
+          ALL_PRIMARY_SYMTABS (objfile, s)
           {
             bv = BLOCKVECTOR (s);
             b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
@@ -9041,66 +9037,44 @@ function_name_from_pc (CORE_ADDR pc)
 static int
 is_known_support_routine (struct frame_info *frame)
 {
-  struct frame_info *next_frame = get_next_frame (frame);
-  /* If frame is not innermost, that normally means that frame->pc
-     points to *after* the call instruction, and we want to get the line
-     containing the call, never the next line.  But if the next frame is
-     a signal_handler_caller or a dummy frame, then the next frame was
-     not entered as the result of a call, and we want to get the line
-     containing frame->pc.  */
-  const int pc_is_after_call =
-    next_frame != NULL
-    && get_frame_type (next_frame) != SIGTRAMP_FRAME
-    && get_frame_type (next_frame) != DUMMY_FRAME;
-  struct symtab_and_line sal
-    = find_pc_line (get_frame_pc (frame), pc_is_after_call);
+  struct symtab_and_line sal;
   char *func_name;
   int i;
-  struct stat st;
 
-  /* The heuristic:
-     1. The symtab is null (indicating no debugging symbols)
-     2. The symtab's filename does not exist.
-     3. The object file's name is one of the standard libraries.
-     4. The symtab's file name has the form of an Ada library source file.
-     5. The function at frame's PC has a GNAT-compiler-generated name.  */
+  /* If this code does not have any debugging information (no symtab),
+     This cannot be any user code.  */
 
+  find_frame_sal (frame, &sal);
   if (sal.symtab == NULL)
     return 1;
 
-  /* On some systems (e.g. VxWorks), the kernel contains debugging
-     symbols; in this case, the filename referenced by these symbols
-     does not exists.  */
+  /* If there is a symtab, but the associated source file cannot be
+     located, then assume this is not user code:  Selecting a frame
+     for which we cannot display the code would not be very helpful
+     for the user.  This should also take care of case such as VxWorks
+     where the kernel has some debugging info provided for a few units.  */
 
-  if (stat (sal.symtab->filename, &st))
+  if (symtab_to_fullname (sal.symtab) == NULL)
     return 1;
 
+  /* Check the unit filename againt the Ada runtime file naming.
+     We also check the name of the objfile against the name of some
+     known system libraries that sometimes come with debugging info
+     too.  */
+
   for (i = 0; known_runtime_file_name_patterns[i] != NULL; i += 1)
     {
       re_comp (known_runtime_file_name_patterns[i]);
       if (re_exec (sal.symtab->filename))
         return 1;
-    }
-  if (sal.symtab->objfile != NULL)
-    {
-      for (i = 0; known_runtime_file_name_patterns[i] != NULL; i += 1)
-        {
-          re_comp (known_runtime_file_name_patterns[i]);
-          if (re_exec (sal.symtab->objfile->name))
-            return 1;
-        }
+      if (sal.symtab->objfile != NULL
+          && re_exec (sal.symtab->objfile->name))
+        return 1;
     }
 
-  /* If the frame PC points after the call instruction, then we need to
-     decrement it in order to search for the function associated to this
-     PC.  Otherwise, if the associated call was the last instruction of
-     the function, we might either find the wrong function or even fail
-     during the function name lookup.  */
-  if (pc_is_after_call)
-    func_name = function_name_from_pc (get_frame_pc (frame) - 1);
-  else
-    func_name = function_name_from_pc (get_frame_pc (frame));
+  /* Check whether the function is a GNAT-generated entity.  */
 
+  func_name = function_name_from_pc (get_frame_address_in_block (frame));
   if (func_name == NULL)
     return 1;
 
@@ -9584,7 +9558,7 @@ ada_exception_sym_name (enum exception_catchpoint_kind ex)
    of the EX kind.  */
 
 static struct breakpoint_ops *
-ada_exception_breakption_ops (enum exception_catchpoint_kind ex)
+ada_exception_breakpoint_ops (enum exception_catchpoint_kind ex)
 {
   switch (ex)
     {
@@ -9710,7 +9684,7 @@ ada_exception_sal (enum exception_catchpoint_kind ex, char *exp_string,
     }
 
   /* Set OPS.  */
-  *ops = ada_exception_breakption_ops (ex);
+  *ops = ada_exception_breakpoint_ops (ex);
 
   return sal;
 }
This page took 0.030752 seconds and 4 git commands to generate.