keiths / rpms / gdb

Forked from rpms/gdb 4 months ago
Clone
43873a6
2004-10-26  Andrew Cagney  <cagney@gnu.org>
43873a6
43873a6
	* blockframe.c (find_pc_function): Use find_pc_section to find the
43873a6
	pc's section.
43873a6
	* block.c, symfile.c: Ditto.
43873a6
43873a6
*** ./gdb/blockframe.c.1	2004-10-26 21:21:46.517866240 -0400
43873a6
--- ./gdb/blockframe.c	2004-10-26 21:24:16.345089040 -0400
43873a6
***************
43873a6
*** 288,294 ****
43873a6
  struct symbol *
43873a6
  find_pc_function (CORE_ADDR pc)
43873a6
  {
43873a6
!   return find_pc_sect_function (pc, find_pc_mapped_section (pc));
43873a6
  }
43873a6
  
43873a6
  /* These variables are used to cache the most recent result
43873a6
--- 288,311 ----
43873a6
  struct symbol *
43873a6
  find_pc_function (CORE_ADDR pc)
43873a6
  {
43873a6
!   struct bfd_section *section;
43873a6
!   struct symbol *symbol;
43873a6
!   /* To ensure that the symbol returned belongs to the correct setion
43873a6
!      (and that the last [random] symbol from the previous section
43873a6
!      isn't returned) try to find the section containing PC.  First try
43873a6
!      the overlay code (which by default returns NULL); and second try
43873a6
!      the normal section code (which almost always succeeds).  */
43873a6
!   section = find_pc_overlay (pc);
43873a6
!   if (section == NULL)
43873a6
!     {
43873a6
!       struct obj_section *obj_section = find_pc_section (pc);
43873a6
!       if (obj_section == NULL)
43873a6
! 	section = NULL;
43873a6
!       else
43873a6
! 	section = obj_section->the_bfd_section;
43873a6
!     }
43873a6
!   symbol = find_pc_sect_function (pc, section);
43873a6
!   return symbol;
43873a6
  }
43873a6
  
43873a6
  /* These variables are used to cache the most recent result
43873a6
--- ./gdb/symtab.c.1	2004-10-26 22:47:13.650423616 -0400
43873a6
+++ ./gdb/symtab.c	2004-10-26 22:50:10.239577984 -0400
43873a6
@@ -2176,7 +2176,20 @@
43873a6
 {
43873a6
   asection *section;
43873a6
 
43873a6
+  /* To ensure that the symbol returned belongs to the correct setion
43873a6
+     (and that the last [random] symbol from the previous section
43873a6
+     isn't returned) try to find the section containing PC.  First try
43873a6
+     the overlay code (which by default returns NULL); and second try
43873a6
+     the normal section code (which almost always succeeds).  */
43873a6
   section = find_pc_overlay (pc);
43873a6
+  if (section == NULL)
43873a6
+    {
43873a6
+      struct obj_section *obj_section = find_pc_section (pc);
43873a6
+      if (obj_section == NULL)
43873a6
+	section = NULL;
43873a6
+      else
43873a6
+	section = obj_section->the_bfd_section;
43873a6
+    }
43873a6
   if (pc_in_unmapped_range (pc, section))
43873a6
     pc = overlay_mapped_address (pc, section);
43873a6
   return find_pc_sect_line (pc, section, notcurrent);
43873a6
--- ./gdb/block.c.1	2004-10-27 00:22:56.881319808 -0400
43873a6
+++ ./gdb/block.c	2004-10-27 00:24:17.364084568 -0400
43873a6
@@ -25,6 +25,7 @@
43873a6
 #include "symfile.h"
43873a6
 #include "gdb_obstack.h"
43873a6
 #include "cp-support.h"
43873a6
+#include "objfiles.h"
43873a6
 
43873a6
 /* This is used by struct block to store namespace-related info for
43873a6
    C++ files, namely using declarations and the current namespace in
43873a6
@@ -153,7 +154,22 @@
43873a6
 struct block *
43873a6
 block_for_pc (CORE_ADDR pc)
43873a6
 {
43873a6
-  return block_for_pc_sect (pc, find_pc_mapped_section (pc));
43873a6
+  struct bfd_section *section;
43873a6
+  /* To ensure that the symbol returned belongs to the correct setion
43873a6
+     (and that the last [random] symbol from the previous section
43873a6
+     isn't returned) try to find the section containing PC.  First try
43873a6
+     the overlay code (which by default returns NULL); and second try
43873a6
+     the normal section code (which almost always succeeds).  */
43873a6
+  section = find_pc_overlay (pc);
43873a6
+  if (section == NULL)
43873a6
+    {
43873a6
+      struct obj_section *obj_section = find_pc_section (pc);
43873a6
+      if (obj_section == NULL)
43873a6
+	section = NULL;
43873a6
+      else
43873a6
+	section = obj_section->the_bfd_section;
43873a6
+    }
43873a6
+  return block_for_pc_sect (pc, section);
43873a6
 }
43873a6
 
43873a6
 /* Now come some functions designed to deal with C++ namespace issues.