* syms.c (_bfd_stab_section_find_nearest_line): Look at the
authorNick Clifton <nickc@redhat.com>
Fri, 21 Sep 2007 07:58:03 +0000 (07:58 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 21 Sep 2007 07:58:03 +0000 (07:58 +0000)
  specific SOM sections for stabs if the regular ones are not found.
* som.h (struct somdata): Add a line_info field, to be used by som_find_nearest_line.
* som.c (som_find_nearest_line): Implement using the bfd stabs function above.

bfd/ChangeLog
bfd/som.c
bfd/som.h
bfd/syms.c

index 38eef5406452520beba2df3a35c138cc99456f9e..22461e9987d64057870ad011562147e7f476e127 100644 (file)
@@ -1,3 +1,13 @@
+2007-09-21  Olivier Hainque  <hainque@adacore.com>
+           Tristan Gingold  <gingold@adacore.com>
+       
+       * syms.c (_bfd_stab_section_find_nearest_line): Look at the 
+        specific SOM sections for stabs if the regular ones are not found.
+       * som.h (struct somdata): Add a line_info field, to be used by
+        som_find_nearest_line.
+       * som.c (som_find_nearest_line): Implement using the bfd stabs
+       function above.
+
 2007-09-19  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Make sure .got
index e267658ca17109deca0af68a949b7b905eceba96..f36e3bc29285abf5b6061c54be5fac564f53780e 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -5331,15 +5331,57 @@ som_set_arch_mach (bfd *abfd,
 }
 
 static bfd_boolean
-som_find_nearest_line (bfd *abfd ATTRIBUTE_UNUSED,
-                      asection *section ATTRIBUTE_UNUSED,
-                      asymbol **symbols ATTRIBUTE_UNUSED,
-                      bfd_vma offset ATTRIBUTE_UNUSED,
-                      const char **filename_ptr ATTRIBUTE_UNUSED,
-                      const char **functionname_ptr ATTRIBUTE_UNUSED,
-                      unsigned int *line_ptr ATTRIBUTE_UNUSED)
+som_find_nearest_line (bfd *abfd,
+                      asection *section,
+                      asymbol **symbols,
+                      bfd_vma offset,
+                      const char **filename_ptr,
+                      const char **functionname_ptr,
+                      unsigned int *line_ptr)
 {
-  return FALSE;
+  bfd_boolean found;
+  asymbol *func;
+  bfd_vma low_func;
+  asymbol **p;
+
+  if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+                                             & found, filename_ptr,
+                                             functionname_ptr, line_ptr,
+                                             & somdata (abfd).line_info))
+    return FALSE;
+
+  if (found)
+    return TRUE;
+
+  if (symbols == NULL)
+    return FALSE;
+
+  /* Fallback: find function name from symbols table.  */
+  func = NULL;
+  low_func = 0;
+
+  for (p = symbols; *p != NULL; p++)
+    { 
+      som_symbol_type *q = (som_symbol_type *) *p;
+  
+      if (q->som_type == SYMBOL_TYPE_ENTRY
+         && q->symbol.section == section
+         && q->symbol.value >= low_func
+         && q->symbol.value <= offset)
+       {
+         func = (asymbol *) q;
+         low_func = q->symbol.value;
+       }
+    }
+
+  if (func == NULL)
+    return FALSE;
+
+  *filename_ptr = NULL;
+  *functionname_ptr = bfd_asymbol_name (func);
+  *line_ptr = 0;
+
+  return TRUE;
 }
 
 static int
index 708f0aea38682685a7ea5cef47371f6dfe0780bf..59b4c19910021cbfeade095862464159426b8c3f 100644 (file)
--- a/bfd/som.h
+++ b/bfd/som.h
@@ -136,6 +136,7 @@ struct somdata
   file_ptr str_filepos;
   file_ptr reloc_filepos;
   unsigned stringtab_size;
+  void * line_info;
 };
 
 struct som_data_struct
index 9d425684d9039e6997185f3948c8b526459ab205..8831b9257c2609972dbfee496000d39b6a2a2ad1 100644 (file)
@@ -989,10 +989,17 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
 
       if (info->stabsec == NULL || info->strsec == NULL)
        {
-         /* No stabs debugging information.  Set *pinfo so that we
-             can return quickly in the info != NULL case above.  */
-         *pinfo = info;
-         return TRUE;
+         /* Try SOM section names.  */
+         info->stabsec = bfd_get_section_by_name (abfd, "$GDB_SYMBOLS$");
+         info->strsec  = bfd_get_section_by_name (abfd, "$GDB_STRINGS$");
+  
+         if (info->stabsec == NULL || info->strsec == NULL)
+           {
+             /* No stabs debugging information.  Set *pinfo so that we
+                can return quickly in the info != NULL case above.  */
+             *pinfo = info;
+             return TRUE;
+           }
        }
 
       stabsize = (info->stabsec->rawsize