This is the mail archive of the gdb-patches@sources.redhat.com 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/mips] Proposal for inlining heuristic_proc_desc a bit...


Hello Andrew,

what would you think of something like this. It's just a concept,
it hasn't been compiled nor tested, but the idea is to remove the
call to heuristic_proc_desc() in mips_insn32_frame_cache() by a
a direct call to mips32_scan_prologue(). The same would be applied
to mips16.

The two things that are not obvious are:

  . Where should the SP be computed: in the caller ofo scan_prologue,
    or inside scan_prologue. I chose the latter.

  . Should the scanning limit (200 bytes) be checked in the caller,
    or inside scan_prologue. Again, I chose the latter.

This is mostly to avoid duplicating this code. What do you think?

You know, heuristic_proc_desc() is in grave danger of dying :-).
I have have a couple of things I'd like to work on first, but then
it should be ripe for removal.


Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.331
diff -u -p -r1.331 mips-tdep.c
--- mips-tdep.c	11 Oct 2004 02:27:13 -0000	1.331
+++ mips-tdep.c	11 Oct 2004 02:59:40 -0000
@@ -1841,7 +1841,7 @@ mips_insn32_frame_cache (struct frame_in
     if (start_addr == 0)
       return cache;
 
-    heuristic_proc_desc (start_addr, pc, next_frame, *this_cache);
+    mips32_scan_prologue (start_addr, pc, next_frame, *this_cache);
   }
   
   /* SP_REGNUM, contains the value and not the address.  */
@@ -2422,15 +2422,26 @@ reset_saved_regs (struct mips_frame_cach
    the associated FRAME_CACHE if not null.  */
 
 static void
-mips32_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc, CORE_ADDR sp,
+mips32_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
                       struct frame_info *next_frame,
                       struct mips_frame_cache *this_cache)
 {
   CORE_ADDR cur_pc;
   CORE_ADDR frame_addr = 0; /* Value of $r30. Used by gcc for frame-pointer */
+  CORE_ADDR sp;
   long frame_offset;
   int  frame_reg = MIPS_SP_REGNUM;
 
+  /* Can be called when there's no process, and hence when there's no
+     NEXT_FRAME.  */
+  if (next_frame != NULL)
+    sp = read_next_frame_reg (next_frame, NUM_REGS + MIPS_SP_REGNUM);
+  else
+    sp = 0;
+
+  if (limit_pc > start_pc + 200)
+    limit_pc = start_pc + 200;
+
 restart:
 
   frame_offset = 0;
@@ -2569,7 +2580,7 @@ heuristic_proc_desc (CORE_ADDR start_pc,
   if (pc_is_mips16 (start_pc))
     mips16_scan_prologue (start_pc, limit_pc, sp, next_frame, this_cache);
   else
-    mips32_scan_prologue (start_pc, limit_pc, sp, next_frame, this_cache);
+    mips32_scan_prologue (start_pc, limit_pc, next_frame, this_cache);
   return &temp_proc_desc;
 }
 

-- 
Joel


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