This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] mn10300-prolog.c, saving pc and sp
- From: Michael Snyder <msnyder at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 21 Mar 2005 15:25:00 -0800
- Subject: [commit] mn10300-prolog.c, saving pc and sp
- Organization: Red Hat, Inc.
2005-03-21 Michael Snyder <msnyder@redhat.com>
* mn10300-prologue.c (fix_frame_pointer): Delete.
(set_movm_offsets) Don't return just because movm_args is
zero -- still need to save pc and sp in saved_regs.
(mn10300_analyze_prologue): Don't return prematurely without
calling set_movm_offsets (for pc and sp at minimum).
Index: mn10300-prologue.c
===================================================================
RCS file: /cvs/src/src/gdb/mn10300-prologue.c,v
retrieving revision 1.1
diff -p -r1.1 mn10300-prologue.c
*** mn10300-prologue.c 5 Mar 2005 02:01:40 -0000 1.1
--- mn10300-prologue.c 21 Mar 2005 23:20:36 -0000
*************** set_my_stack_size (struct frame_info *fi
*** 107,134 ****
}
- /* Fix fi->frame if it's bogus at this point. This is a helper
- function for mn10300_analyze_prologue.
-
- MVS: This later became frame_base_hack, and probably now
- could just be trad_frame_set_this_base.
- */
-
- static void
- fix_frame_pointer (struct frame_info *fi, int stack_size)
- {
- #if 0
- if (fi && get_next_frame (fi) == NULL)
- {
- if (is_my_frame_in_sp (fi))
- deprecated_update_frame_base_hack (fi, read_sp () - stack_size);
- else if (is_my_frame_in_fp (fi))
- deprecated_update_frame_base_hack (fi, read_register (E_A3_REGNUM));
- }
- #endif
- }
-
-
/* Set offsets of registers saved by movm instruction.
This is a helper function for mn10300_analyze_prologue. */
--- 107,112 ----
*************** set_movm_offsets (struct frame_info *fi,
*** 141,147 ****
int offset = 0;
CORE_ADDR base;
! if (cache == NULL || fi == NULL || movm_args == 0)
return;
cache = mn10300_frame_unwind_cache (fi, this_cache);
--- 119,125 ----
int offset = 0;
CORE_ADDR base;
! if (cache == NULL || fi == NULL)
return;
cache = mn10300_frame_unwind_cache (fi, this_cache);
*************** mn10300_analyze_prologue (struct frame_i
*** 329,341 ****
pc = (fi ? get_frame_pc (fi) : pc);
But this is (now) badly broken when called from analyze_dummy_frame().
*/
! pc = (pc ? pc : get_frame_pc (fi));
/* Find the start of this function. */
status = find_pc_partial_function (pc, &name, &func_addr, &func_end);
! /* Do nothing if we couldn't find the start of this function or if we're
! stopped at the first instruction in the prologue. */
if (status == 0)
{
return pc;
--- 307,327 ----
pc = (fi ? get_frame_pc (fi) : pc);
But this is (now) badly broken when called from analyze_dummy_frame().
*/
! if (fi)
! {
! pc = (pc ? pc : get_frame_pc (fi));
! /* At the start of a function our frame is in the stack pointer. */
! my_frame_is_in_sp (fi, this_cache);
! }
/* Find the start of this function. */
status = find_pc_partial_function (pc, &name, &func_addr, &func_end);
! /* Do nothing if we couldn't find the start of this function
!
! MVS: comment went on to say "or if we're stopped at the first
! instruction in the prologue" -- but code doesn't reflect that,
! and I don't want to do that anyway. */
if (status == 0)
{
return pc;
*************** mn10300_analyze_prologue (struct frame_i
*** 349,358 ****
return pc;
}
- /* At the start of a function our frame is in the stack pointer. */
- if (fi)
- my_frame_is_in_sp (fi, this_cache);
-
#if 0
/* Get the next two bytes into buf, we need two because rets is a two
byte insn and the first isn't enough to uniquely identify it. */
--- 335,340 ----
*************** mn10300_analyze_prologue (struct frame_i
*** 384,389 ****
--- 366,375 ----
}
#endif
+ /* NOTE: from here on, we don't want to return without jumping to
+ finish_prologue. */
+
+
/* Figure out where to stop scanning. */
stop = fi ? pc : func_end;
*************** mn10300_analyze_prologue (struct frame_i
*** 396,405 ****
/* Suck in two bytes. */
if (addr + 2 >= stop
|| (status = deprecated_read_memory_nobpt (addr, buf, 2)) != 0)
! {
! fix_frame_pointer (fi, 0);
! return addr;
! }
/* First see if this insn sets the stack pointer from a register; if
so, it's probably the initialization of the stack pointer in _start,
--- 382,388 ----
/* Suck in two bytes. */
if (addr + 2 >= stop
|| (status = deprecated_read_memory_nobpt (addr, buf, 2)) != 0)
! goto finish_prologue;
/* First see if this insn sets the stack pointer from a register; if
so, it's probably the initialization of the stack pointer in _start,
*************** mn10300_analyze_prologue (struct frame_i
*** 408,414 ****
{
if (fi)
my_frame_is_last (fi);
! return addr;
}
/* Now look for movm [regs],sp, which saves the callee saved registers.
--- 391,397 ----
{
if (fi)
my_frame_is_last (fi);
! goto finish_prologue;
}
/* Now look for movm [regs],sp, which saves the callee saved registers.
*************** mn10300_analyze_prologue (struct frame_i
*** 425,452 ****
/* Quit now if we're beyond the stop point. */
if (addr >= stop)
! {
! /* Fix fi->frame since it's bogus at this point. */
! if (fi && get_next_frame (fi) == NULL)
! deprecated_update_frame_base_hack (fi, read_sp ());
!
! /* Note if/where callee saved registers were saved. */
! set_movm_offsets (fi, this_cache, movm_args);
! return addr;
! }
/* Get the next two bytes so the prologue scan can continue. */
status = deprecated_read_memory_nobpt (addr, buf, 2);
if (status != 0)
! {
! /* Fix fi->frame since it's bogus at this point. */
! if (fi && get_next_frame (fi) == NULL)
! deprecated_update_frame_base_hack (fi, read_sp ());
!
! /* Note if/where callee saved registers were saved. */
! set_movm_offsets (fi, this_cache, movm_args);
! return addr;
! }
}
/* Now see if we set up a frame pointer via "mov sp,a3" */
--- 408,419 ----
/* Quit now if we're beyond the stop point. */
if (addr >= stop)
! goto finish_prologue;
/* Get the next two bytes so the prologue scan can continue. */
status = deprecated_read_memory_nobpt (addr, buf, 2);
if (status != 0)
! goto finish_prologue;
}
/* Now see if we set up a frame pointer via "mov sp,a3" */
*************** mn10300_analyze_prologue (struct frame_i
*** 462,487 ****
/* Quit now if we're beyond the stop point. */
if (addr >= stop)
! {
! /* Fix fi->frame if it's bogus at this point. */
! fix_frame_pointer (fi, 0);
!
! /* Note if/where callee saved registers were saved. */
! set_movm_offsets (fi, this_cache, movm_args);
! return addr;
! }
/* Get two more bytes so scanning can continue. */
status = deprecated_read_memory_nobpt (addr, buf, 2);
if (status != 0)
! {
! /* Fix fi->frame if it's bogus at this point. */
! fix_frame_pointer (fi, 0);
!
! /* Note if/where callee saved registers were saved. */
! set_movm_offsets (fi, this_cache, movm_args);
! return addr;
! }
}
/* Next we should allocate the local frame. No more prologue insns
--- 429,440 ----
/* Quit now if we're beyond the stop point. */
if (addr >= stop)
! goto finish_prologue;
/* Get two more bytes so scanning can continue. */
status = deprecated_read_memory_nobpt (addr, buf, 2);
if (status != 0)
! goto finish_prologue;
}
/* Next we should allocate the local frame. No more prologue insns
*************** mn10300_analyze_prologue (struct frame_i
*** 508,521 ****
current frame. */
status = deprecated_read_memory_nobpt (addr + 2, buf, imm_size);
if (status != 0)
! {
! /* Fix fi->frame if it's bogus at this point. */
! fix_frame_pointer (fi, 0);
!
! /* Note if/where callee saved registers were saved. */
! set_movm_offsets (fi, this_cache, movm_args);
! return addr;
! }
/* Note the size of the stack in the frame info structure. */
stack_size = extract_signed_integer (buf, imm_size);
--- 461,467 ----
current frame. */
status = deprecated_read_memory_nobpt (addr + 2, buf, imm_size);
if (status != 0)
! goto finish_prologue;
/* Note the size of the stack in the frame info structure. */
stack_size = extract_signed_integer (buf, imm_size);
*************** mn10300_analyze_prologue (struct frame_i
*** 526,546 ****
addr += 2 + imm_size;
/* No more prologue insns follow, so begin preparation to return. */
! /* Fix fi->frame if it's bogus at this point. */
! fix_frame_pointer (fi, stack_size);
!
! /* Note if/where callee saved registers were saved. */
! set_movm_offsets (fi, this_cache, movm_args);
! return addr;
}
!
! /* We never found an insn which allocates local stack space, regardless
! this is the end of the prologue. */
! /* Fix fi->frame if it's bogus at this point. */
! fix_frame_pointer (fi, 0);
!
/* Note if/where callee saved registers were saved. */
! set_movm_offsets (fi, this_cache, movm_args);
return addr;
}
--- 472,484 ----
addr += 2 + imm_size;
/* No more prologue insns follow, so begin preparation to return. */
! goto finish_prologue;
}
! /* Do the essentials and get out of here. */
! finish_prologue:
/* Note if/where callee saved registers were saved. */
! if (fi)
! set_movm_offsets (fi, this_cache, movm_args);
return addr;
}