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]

[committed] Fix MIPS32 heuristic procedure start finder


Hi,

 There's code to check for the MIPS16 ASE in mips_about_to_return, however 
this function is never called for MIPS16 code; presumably this is a 
left-over from before current elaborate MIPS16 support was added to 
heuristic_proc_start.  Also the new (in the context of GDB that is, it's 
been a few years now since it was defined) JR.HB $ra instruction is not 
handled.

 The change below addresses these problems.  For future compatibility any 
hint values for JR class instructions are actually accepted, not only 
plain JR and JR.HB -- any new values defined by the architecture are not 
supposed to change the basic semantics of the instruction being a jump.

 No regressions for mips-sde-elf or mips-linux-gnu (o32, n64 or MIPS16/o32 
ABIs).  Committed.

2011-04-24  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/
	* mips-tdep.c (mips_about_to_return): Remove dead MIPS16 support
	code.  Handle JR.HB correctly.

  Maciej

gdb-mips-about-to-return.diff
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c	2012-04-23 23:11:02.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c	2012-04-24 00:16:57.855563807 +0100
@@ -2821,16 +3938,16 @@ mips_software_single_step (struct frame_
 static int
 mips_about_to_return (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  if (mips_pc_is_mips16 (pc))
-    /* This mips16 case isn't necessarily reliable.  Sometimes the compiler
-       generates a "jr $ra"; other times it generates code to load
-       the return address from the stack to an accessible register (such
-       as $a3), then a "jr" using that register.  This second case
-       is almost impossible to distinguish from an indirect jump
-       used for switch statements, so we don't even try.  */
-    return mips_fetch_instruction (gdbarch, pc) == 0xe820;	/* jr $ra */
-  else
-    return mips_fetch_instruction (gdbarch, pc) == 0x3e00008;	/* jr $ra */
+  ULONGEST insn;
+  ULONGEST hint;
+
+  /* This used to check for MIPS16, but this piece of code is never
+     called for MIPS16 functions.  */
+  gdb_assert (!mips_pc_is_mips16 (pc));
+
+  insn = mips_fetch_instruction (gdbarch, pc);
+  hint = 0x7c0;
+  return (insn & ~hint) == 0x3e00008;			/* jr(.hb) $ra */
 }
 
 


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