[patch/mips] small cleanup (unused variables, comments, etc)

Joel Brobecker brobecker@gnat.com
Mon Oct 11 02:02:00 GMT 2004


Still in my quest to eliminate the proc_desc from the heuristic cases,
here is a small cleanup patch that helps in that direction. A couple
of changes are worth mentioning (the same change, but both in mips16
and mips32):

+    /* We can't analyze the prologue if we couldn't find the begining
+       of the function.  */
+    if (start_addr == 0)
+      return cache;

This is the only case when heuristic_proc_desc would abort early
and return a NULL proc_desc address. So I added this check in the
caller so that we no longer need to check whether the returned
proc desc was null or not. This allows me to get rid of proc_desc
in mips_insn32_frame_cache() as well as mips_insn16_frame_cache.

The rest is just obvious stuff (unused variables, out of date
comments).

2004-10-10  Joel Brobecker  <brobecker@gnat.com>

        * mips-tdep.c (mips_insn16_frame_cache): Remove unused variables.
        Update comments. Also immediately return empty cache when the start
        address of our function could not be found.
        (mips_insn32_frame_cache): Likewise.

It seems simple enough that I didn't run the testuite, just checked
that it builds. I will run the testsuite tonight, after I have done
all the changes I can squeeze in this evening (I just don't want to
have to run the testuite for each of the numerous little steps I am
making).

Committing now,
-- 
Joel
-------------- next part --------------
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.328
diff -u -p -r1.328 mips-tdep.c
--- mips-tdep.c	11 Oct 2004 01:00:57 -0000	1.328
+++ mips-tdep.c	11 Oct 2004 01:47:09 -0000
@@ -1717,14 +1717,7 @@ mips_mdebug_frame_base_sniffer (struct f
 static struct mips_frame_cache *
 mips_insn16_frame_cache (struct frame_info *next_frame, void **this_cache)
 {
-  mips_extra_func_info_t proc_desc;
   struct mips_frame_cache *cache;
-  struct gdbarch *gdbarch = get_frame_arch (next_frame);
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  /* r0 bit means kernel trap */
-  int kernel_trap;
-  /* What registers have been saved?  Bitmasks.  */
-  unsigned long gen_mask, float_mask;
 
   if ((*this_cache) != NULL)
     return (*this_cache);
@@ -1732,7 +1725,7 @@ mips_insn16_frame_cache (struct frame_in
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
-  /* Synthesize a proc descriptor.  */
+  /* Analyze the function prologue.  */
   {
     const CORE_ADDR pc = frame_pc_unwind (next_frame);
     CORE_ADDR start_addr;
@@ -1740,8 +1733,12 @@ mips_insn16_frame_cache (struct frame_in
     find_pc_partial_function (pc, NULL, &start_addr, NULL);
     if (start_addr == 0)
       start_addr = heuristic_proc_start (pc);
+    /* We can't analyze the prologue if we couldn't find the begining
+       of the function.  */
+    if (start_addr == 0)
+      return cache;
 
-    proc_desc = heuristic_proc_desc (start_addr, pc, next_frame, *this_cache);
+    heuristic_proc_desc (start_addr, pc, next_frame, *this_cache);
   }
   
   /* SP_REGNUM, contains the value and not the address.  */
@@ -1822,14 +1819,7 @@ mips_insn16_frame_base_sniffer (struct f
 static struct mips_frame_cache *
 mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache)
 {
-  mips_extra_func_info_t proc_desc;
   struct mips_frame_cache *cache;
-  struct gdbarch *gdbarch = get_frame_arch (next_frame);
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  /* r0 bit means kernel trap */
-  int kernel_trap;
-  /* What registers have been saved?  Bitmasks.  */
-  unsigned long gen_mask, float_mask;
 
   if ((*this_cache) != NULL)
     return (*this_cache);
@@ -1838,7 +1828,7 @@ mips_insn32_frame_cache (struct frame_in
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
-  /* Synthesize a proc descriptor.  */
+  /* Analyze the function prologue.  */
   {
     const CORE_ADDR pc = frame_pc_unwind (next_frame);
     CORE_ADDR start_addr;
@@ -1846,16 +1836,14 @@ mips_insn32_frame_cache (struct frame_in
     find_pc_partial_function (pc, NULL, &start_addr, NULL);
     if (start_addr == 0)
       start_addr = heuristic_proc_start (pc);
+    /* We can't analyze the prologue if we couldn't find the begining
+       of the function.  */
+    if (start_addr == 0)
+      return cache;
 
-    proc_desc = heuristic_proc_desc (start_addr, pc, next_frame, *this_cache);
+    heuristic_proc_desc (start_addr, pc, next_frame, *this_cache);
   }
   
-  if (proc_desc == NULL)
-    /* I'm not sure how/whether this can happen.  Normally when we
-       can't find a proc_desc, we "synthesize" one using
-       heuristic_proc_desc and set the saved_regs right away.  */
-    return cache;
-
   /* SP_REGNUM, contains the value and not the address.  */
   trad_frame_set_value (cache->saved_regs, NUM_REGS + MIPS_SP_REGNUM, cache->base);
 


More information about the Gdb-patches mailing list