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]

[rfc] Use trad_frame_alloc_saved_regs everywhere


Hi,

there were still 3 places (1 in unused source in score-tdep.c) where frame_obstack_zalloc was used
instead of trad_frame_alloc_saved_regs. SIZEOF_FRAME_SAVED_REGS was only used with this 3 functions and thus is removed by this patch also.


I tried to port alpha target to use trad_frame_alloc_saved_regs correctly but I'm not sure I covered everything. I'd appreciate it very much if someone with access to an alpha machine could run the testsuite.

What about that unused source part in score-tdep.c? Is it ok to delete it?

Tested by building score and alpha target. Is this ok ?

ChangeLog:

	* score-tdep.c: Remove unused source parts.
	* frame.h (SIZEOF_FRAME_SAVED_REGS): Remove.

	* alpha-tdep.c (trad-frame.h): Add new include.
	(alpha_heuristic_frame_unwind_cache): Use trad_frame_alloc_saved_regs
	instead of frame_obstack_zalloc.
	* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.

	(alpha_heuristic_unwind_cache): Use trad_frame_saved_reg as
	saved_regs.
	(alpha_heuristic_frame_prev_register): Likewise.

* Makefile.in (alpha-tdep.o): Add dependency to trad_frame_h.


Regards, Markus

--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com


diff -urpN src/gdb/alpha-mdebug-tdep.c dev/gdb/alpha-mdebug-tdep.c
--- src/gdb/alpha-mdebug-tdep.c	2007-10-17 15:36:43.000000000 +0200
+++ dev/gdb/alpha-mdebug-tdep.c	2007-11-15 08:54:54.000000000 +0100
@@ -201,7 +201,7 @@ alpha_mdebug_frame_unwind_cache (struct 
   info->proc_desc = proc_desc;
   gdb_assert (proc_desc != NULL);
 
-  info->saved_regs = frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS);
+  info->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
   /* The VFP of the frame is at FRAME_REG+FRAME_OFFSET.  */
   vfp = frame_unwind_register_unsigned (next_frame, PROC_FRAME_REG (proc_desc));
diff -urpN src/gdb/alpha-tdep.c dev/gdb/alpha-tdep.c
--- src/gdb/alpha-tdep.c	2007-11-09 06:32:19.000000000 +0100
+++ dev/gdb/alpha-tdep.c	2007-11-15 09:44:20.000000000 +0100
@@ -40,6 +40,7 @@
 #include "osabi.h"
 #include "block.h"
 #include "infcall.h"
+#include "trad-frame.h"
 
 #include "elf-bfd.h"
 
@@ -903,10 +904,10 @@ alpha_sigtramp_frame_sniffer (struct fra
 
 struct alpha_heuristic_unwind_cache
 {
-  CORE_ADDR *saved_regs;
   CORE_ADDR vfp;
   CORE_ADDR start_pc;
   int return_reg;
+  struct trad_frame_saved_reg *saved_regs;
 };
 
 /* Heuristic_proc_start may hunt through the text section for a long
@@ -1009,7 +1010,7 @@ alpha_heuristic_frame_unwind_cache (stru
 
   info = FRAME_OBSTACK_ZALLOC (struct alpha_heuristic_unwind_cache);
   *this_prologue_cache = info;
-  info->saved_regs = frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS);
+  info->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
   limit_pc = frame_pc_unwind (next_frame);
   if (start_pc == 0)
@@ -1059,7 +1060,7 @@ alpha_heuristic_frame_unwind_cache (stru
                  All it says is that the function we are scanning reused
                  that register for some computation of its own, and is now
                  saving its result.  */
-              if (info->saved_regs[reg])
+              if (info->saved_regs[reg].addr)
                 continue;
 
 	      if (reg == 31)
@@ -1075,7 +1076,7 @@ alpha_heuristic_frame_unwind_cache (stru
 		 pointer or not.  */
 	      /* Hack: temporarily add one, so that the offset is non-zero
 		 and we can tell which registers have save offsets below.  */
-	      info->saved_regs[reg] = (word & 0xffff) + 1;
+	      info->saved_regs[reg].addr = (word & 0xffff) + 1;
 
 	      /* Starting with OSF/1-3.2C, the system libraries are shipped
 		 without local symbols, but they still contain procedure
@@ -1144,7 +1145,7 @@ alpha_heuristic_frame_unwind_cache (stru
   /* Failing that, do default to the customary RA.  */
   if (return_reg == -1)
     return_reg = ALPHA_RA_REGNUM;
-  info->return_reg = return_reg;
+  info->saved_regs[ALPHA_PC_REGNUM].realreg = return_reg;
 
   val = frame_unwind_register_unsigned (next_frame, frame_reg);
   info->vfp = val + frame_size;
@@ -1152,8 +1153,8 @@ alpha_heuristic_frame_unwind_cache (stru
   /* Convert offsets to absolute addresses.  See above about adding
      one to the offsets to make all detected offsets non-zero.  */
   for (reg = 0; reg < ALPHA_NUM_REGS; ++reg)
-    if (info->saved_regs[reg])
-      info->saved_regs[reg] += val - 1;
+    if (info->saved_regs[reg].addr)
+      info->saved_regs[reg].addr += val - 1;
 
   return info;
 }
@@ -1188,15 +1189,15 @@ alpha_heuristic_frame_prev_register (str
      the current frame.  Frob regnum so that we pull the value from
      the correct place.  */
   if (regnum == ALPHA_PC_REGNUM)
-    regnum = info->return_reg;
+    regnum = info->saved_regs[ALPHA_PC_REGNUM].realreg;
   
-  /* For all registers known to be saved in the current frame, 
+  /* For all registers known to be saved in the current frame,  
      do the obvious and pull the value out.  */
-  if (info->saved_regs[regnum])
+  if (info->saved_regs[regnum].addr)
     {
       *optimizedp = 0;
       *lvalp = lval_memory;
-      *addrp = info->saved_regs[regnum];
+      *addrp = info->saved_regs[regnum].addr;
       *realnump = -1;
       if (bufferp != NULL)
 	get_frame_memory (next_frame, *addrp, bufferp, ALPHA_REGISTER_SIZE);
diff -urpN src/gdb/frame.h dev/gdb/frame.h
--- src/gdb/frame.h	2007-11-02 15:47:27.000000000 +0100
+++ dev/gdb/frame.h	2007-11-15 08:55:21.000000000 +0100
@@ -569,18 +569,6 @@ enum print_what
     LOC_AND_ADDRESS 
   };
 
-/* Allocate additional space for appendices to a struct frame_info.
-   NOTE: Much of GDB's code works on the assumption that the allocated
-   saved_regs[] array is the size specified below.  If you try to make
-   that array smaller, GDB will happily walk off its end.  */
-
-#ifdef SIZEOF_FRAME_SAVED_REGS
-#error "SIZEOF_FRAME_SAVED_REGS can not be re-defined"
-#endif
-#define SIZEOF_FRAME_SAVED_REGS \
-        (sizeof (CORE_ADDR) * (gdbarch_num_regs (current_gdbarch)\
-			       + gdbarch_num_pseudo_regs (current_gdbarch)))
-
 /* Allocate zero initialized memory from the frame cache obstack.
    Appendices to the frame info (such as the unwind cache) should
    allocate memory using this method.  */
diff -urpN src/gdb/Makefile.in dev/gdb/Makefile.in
--- src/gdb/Makefile.in	2007-11-15 07:58:49.000000000 +0100
+++ dev/gdb/Makefile.in	2007-11-15 09:22:00.000000000 +0100
@@ -1786,7 +1786,7 @@ alpha-tdep.o: alpha-tdep.c $(defs_h) $(d
 	$(symtab_h) $(value_h) $(gdbcmd_h) $(gdbcore_h) $(dis_asm_h) \
 	$(symfile_h) $(objfiles_h) $(gdb_string_h) $(linespec_h) \
 	$(regcache_h) $(reggroups_h) $(arch_utils_h) $(osabi_h) $(block_h) \
-	$(infcall_h) $(elf_bfd_h) $(alpha_tdep_h)
+	$(infcall_h) $(elf_bfd_h) $(alpha_tdep_h) $(trad_frame_h)
 amd64bsd-nat.o: amd64bsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
 	$(target_h) $(gdb_assert_h) $(amd64_tdep_h) $(amd64_nat_h) \
 	$(inf_ptrace_h)
diff -urpN src/gdb/score-tdep.c dev/gdb/score-tdep.c
--- src/gdb/score-tdep.c	2007-11-07 07:33:01.000000000 +0100
+++ dev/gdb/score-tdep.c	2007-11-15 08:50:03.000000000 +0100
@@ -54,135 +54,6 @@ struct score_frame_cache
 };
 
 #if 0
-/* If S+core GCC will generate these instructions in the prologue:
-
-   lw   rx, imm1
-   addi rx, -imm2
-   mv!  r2, rx
-
-   then .pdr section is used.  */
-
-#define P_SIZE          8
-#define PI_SYM          0
-#define PI_R_MSK        1
-#define PI_R_OFF        2
-#define PI_R_LEF        4
-#define PI_F_OFF        5
-#define PI_F_REG        6
-#define PI_RAREG        7
-
-typedef struct frame_extra_info
-{
-  CORE_ADDR p_frame;
-  unsigned int pdr[P_SIZE];
-} extra_info_t;
-
-struct obj_priv
-{
-  bfd_size_type size;
-  char *contents;
-};
-
-static bfd *the_bfd;
-
-static int
-score_compare_pdr_entries (const void *a, const void *b)
-{
-  CORE_ADDR lhs = bfd_get_32 (the_bfd, (bfd_byte *) a);
-  CORE_ADDR rhs = bfd_get_32 (the_bfd, (bfd_byte *) b);
-  if (lhs < rhs)
-    return -1;
-  else if (lhs == rhs)
-    return 0;
-  else
-    return 1;
-}
-
-static void
-score_analyze_pdr_section (CORE_ADDR startaddr, CORE_ADDR pc,
-                           struct frame_info *next_frame,
-                           struct score_frame_cache *this_cache)
-{
-  struct symbol *sym;
-  struct obj_section *sec;
-  extra_info_t *fci_ext;
-  CORE_ADDR leaf_ra_stack_addr = -1;
-
-  gdb_assert (startaddr <= pc);
-  gdb_assert (this_cache != NULL);
-
-  fci_ext = frame_obstack_zalloc (sizeof (extra_info_t));
-  if ((sec = find_pc_section (pc)) == NULL)
-    {
-      error ("Error: Can't find section in file:%s, line:%d!",
-             __FILE__, __LINE__);
-      return;
-    }
-
-  /* Anylyze .pdr section and get coresponding fields.  */
-  {
-    static struct obj_priv *priv = NULL;
-
-    if (priv == NULL)
-      {
-        asection *bfdsec;
-        priv = obstack_alloc (&sec->objfile->objfile_obstack,
-                              sizeof (struct obj_priv));
-        if ((bfdsec = bfd_get_section_by_name (sec->objfile->obfd, ".pdr")))
-          {
-            priv->size = bfd_section_size (sec->objfile->obfd, bfdsec);
-            priv->contents = obstack_alloc (&sec->objfile->objfile_obstack,
-                                            priv->size);
-            bfd_get_section_contents (sec->objfile->obfd, bfdsec,
-                                      priv->contents, 0, priv->size);
-            the_bfd = sec->objfile->obfd;
-            qsort (priv->contents, priv->size / 32, 32,
-                   score_compare_pdr_entries);
-            the_bfd = NULL;
-          }
-        else
-          priv->size = 0;
-      }
-    if (priv->size != 0)
-      {
-        int low = 0, mid, high = priv->size / 32;
-        char *ptr;
-        do
-          {
-            CORE_ADDR pdr_pc;
-            mid = (low + high) / 2;
-            ptr = priv->contents + mid * 32;
-            pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr);
-            pdr_pc += ANOFFSET (sec->objfile->section_offsets,
-                                SECT_OFF_TEXT (sec->objfile));
-            if (pdr_pc == startaddr)
-              break;
-            if (pdr_pc > startaddr)
-              high = mid;
-            else
-              low = mid + 1;
-          }
-        while (low != high);
-
-        if (low != high)
-          {
-            gdb_assert (bfd_get_32 (sec->objfile->obfd, ptr) == startaddr);
-#define EXT_PDR(_pi)    bfd_get_32(sec->objfile->obfd, ptr+((_pi)<<2))
-            fci_ext->pdr[PI_SYM] = EXT_PDR (PI_SYM);
-            fci_ext->pdr[PI_R_MSK] = EXT_PDR (PI_R_MSK);
-            fci_ext->pdr[PI_R_OFF] = EXT_PDR (PI_R_OFF);
-            fci_ext->pdr[PI_R_LEF] = EXT_PDR (PI_R_LEF);
-            fci_ext->pdr[PI_F_OFF] = EXT_PDR (PI_F_OFF);
-            fci_ext->pdr[PI_F_REG] = EXT_PDR (PI_F_REG);
-            fci_ext->pdr[PI_RAREG] = EXT_PDR (PI_RAREG);
-#undef EXT_PDR
-          }
-      }
-  }
-}
-#endif
-
-#if 0
 /* Open these functions if build with simulator.  */
 
 int

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