This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfa] Mips heuristic_proc_desc vs. the stack pointer.
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 16 Nov 2001 16:24:23 -0500
- Subject: [rfa] Mips heuristic_proc_desc vs. the stack pointer.
As HJ noticed, we try to read the stack pointer in heuristic_proc_desc. I'm
not sure why this normally works and fails with linuxthread support, but I'm
convinced it's sometimes wrong. If we are called from after_prologue(), the
stack pointer has nothing to do with the function we're trying to generate a
desc for. We shouldn't try to read it in this case. The uses of it in
*_heuristic_proc_desc are harmless.
Is this OK, Andrew?
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2001-11-16 Daniel Jacobowitz <drow@mvista.com>
* mips-tdep.c (find_proc_desc): Add read_sp argument. Update all
callers.
(heuristic_proc_desc): Likewise. Do not read SP if read_sp == 0.
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.60
diff -u -p -r1.60 mips-tdep.c
--- mips-tdep.c 2001/10/15 18:18:29 1.60
+++ mips-tdep.c 2001/11/16 21:18:23
@@ -239,7 +240,7 @@ int gdb_print_insn_mips (bfd_vma, disass
static void mips_print_register (int, int);
static mips_extra_func_info_t
-heuristic_proc_desc (CORE_ADDR, CORE_ADDR, struct frame_info *);
+heuristic_proc_desc (CORE_ADDR, CORE_ADDR, struct frame_info *, int);
static CORE_ADDR heuristic_proc_start (CORE_ADDR);
@@ -252,7 +253,7 @@ static void mips_show_processor_type_com
static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element *);
static mips_extra_func_info_t
-find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame);
+find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame, int read_sp);
static CORE_ADDR after_prologue (CORE_ADDR pc,
mips_extra_func_info_t proc_desc);
@@ -562,7 +563,7 @@ after_prologue (CORE_ADDR pc,
CORE_ADDR func_addr, func_end;
if (!proc_desc)
- proc_desc = find_proc_desc (pc, NULL);
+ proc_desc = find_proc_desc (pc, NULL, 0);
if (proc_desc)
{
@@ -1858,10 +1859,15 @@ restart:
static mips_extra_func_info_t
heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
- struct frame_info *next_frame)
+ struct frame_info *next_frame, int read_sp)
{
- CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM);
+ CORE_ADDR sp;
+ if (read_sp)
+ sp = read_next_frame_reg (next_frame, SP_REGNUM);
+ else
+ sp = 0;
+
if (start_pc == 0)
return NULL;
memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc));
@@ -1919,7 +1925,7 @@ non_heuristic_proc_desc (CORE_ADDR pc, C
static mips_extra_func_info_t
-find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame)
+find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame, int read_sp)
{
mips_extra_func_info_t proc_desc;
CORE_ADDR startaddr;
@@ -1951,7 +1957,7 @@ find_proc_desc (CORE_ADDR pc, struct fra
{
mips_extra_func_info_t found_heuristic =
heuristic_proc_desc (PROC_LOW_ADDR (proc_desc),
- pc, next_frame);
+ pc, next_frame, read_sp);
if (found_heuristic)
proc_desc = found_heuristic;
}
@@ -1975,7 +1981,7 @@ find_proc_desc (CORE_ADDR pc, struct fra
startaddr = heuristic_proc_start (pc);
proc_desc =
- heuristic_proc_desc (startaddr, pc, next_frame);
+ heuristic_proc_desc (startaddr, pc, next_frame, read_sp);
}
return proc_desc;
}
@@ -2007,7 +2013,7 @@ mips_frame_chain (struct frame_info *fra
saved_pc = tmp;
/* Look up the procedure descriptor for this PC. */
- proc_desc = find_proc_desc (saved_pc, frame);
+ proc_desc = find_proc_desc (saved_pc, frame, 1);
if (!proc_desc)
return 0;
@@ -2033,7 +2039,7 @@ mips_init_extra_frame_info (int fromleaf
/* Use proc_desc calculated in frame_chain */
mips_extra_func_info_t proc_desc =
- fci->next ? cached_proc_desc : find_proc_desc (fci->pc, fci->next);
+ fci->next ? cached_proc_desc : find_proc_desc (fci->pc, fci->next, 1);
fci->extra_info = (struct frame_extra_info *)
frame_obstack_alloc (sizeof (struct frame_extra_info));