This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] Frame ID cleanups
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 12 Apr 2003 00:26:36 -0400
- Subject: [commit] Frame ID cleanups
Hello,
The attached cleans up the following aspects of the frame ID's when a
legacy target:
- legacy_get_prev_reg() sets the frame ID's code-addr to the function
address
- get_frame_id() returns the real ID (no longer replaces the code-addr
with the current PC)
- deprecated_frame_xmalloc() initializes the frame ID (ensuring that
legacy_saved_regs_id() is never called)
- legacy_saved_regs_id() is emptied - it is never called
Since frame_id_eq() doesn't yet compare the ID code-addrs, this doesn't
(or shouldn't) have any effect.
committed,
Andrew
2003-04-11 Andrew Cagney <cagney at redhat dot com>
* frame.c (get_frame_id): Return this frame's "id".
(legacy_get_prev_frame): Set prev's frame ID code_addr to the
function start.
(legacy_saved_regs_this_id): Replace function body with
internal-error.
(deprecated_frame_xmalloc): Mark the frame ID as valid, use
FRAME_OBSTACK_ZALLOC.
(create_new_frame): Mark the frame ID as valid.
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.105
diff -u -r1.105 frame.c
--- frame.c 10 Apr 2003 15:32:27 -0000 1.105
+++ frame.c 12 Apr 2003 03:50:07 -0000
@@ -145,7 +145,7 @@
fprintf_unfiltered (gdb_stdlog, " }\n");
}
}
- return frame_id_build (fi->this_id.value.stack_addr, get_frame_pc (fi));
+ return fi->this_id.value;
}
const struct frame_id null_frame_id; /* All zeros. */
@@ -921,70 +921,9 @@
void **this_prologue_cache,
struct frame_id *id)
{
- int fromleaf;
- CORE_ADDR base;
- CORE_ADDR pc;
-
- if (frame_relative_level (next_frame) < 0)
- {
- /* FIXME: cagney/2003-03-14: We've got the extra special case of
- unwinding a sentinel frame, the PC of which is pointing at a
- stack dummy. Fake up the dummy frame's ID using the same
- sequence as is found a traditional unwinder. */
- (*id) = frame_id_build (read_fp (), read_pc ());
- return;
- }
-
- /* Start out by assuming it's NULL. */
- (*id) = null_frame_id;
-
- if (frame_relative_level (next_frame) <= 0)
- /* FIXME: 2002-11-09: Frameless functions can occure anywhere in
- the frame chain, not just the inner most frame! The generic,
- per-architecture, frame code should handle this and the below
- should simply be removed. */
- fromleaf = FRAMELESS_FUNCTION_INVOCATION (next_frame);
- else
- fromleaf = 0;
-
- if (fromleaf)
- /* A frameless inner-most frame. The `FP' (which isn't an
- architecture frame-pointer register!) of the caller is the same
- as the callee. */
- /* FIXME: 2002-11-09: There isn't any reason to special case this
- edge condition. Instead the per-architecture code should hande
- it locally. */
- base = get_frame_base (next_frame);
- else
- {
- /* Two macros defined in tm.h specify the machine-dependent
- actions to be performed here.
-
- First, get the frame's chain-pointer.
-
- If that is zero, the frame is the outermost frame or a leaf
- called by the outermost frame. This means that if start
- calls main without a frame, we'll return 0 (which is fine
- anyway).
-
- Nope; there's a problem. This also returns when the current
- routine is a leaf of main. This is unacceptable. We move
- this to after the ffi test; I'd rather have backtraces from
- start go curfluy than have an abort called from main not show
- main. */
- gdb_assert (DEPRECATED_FRAME_CHAIN_P ());
- base = DEPRECATED_FRAME_CHAIN (next_frame);
-
- if (!legacy_frame_chain_valid (base, next_frame))
- return;
- }
- if (base == 0)
- return;
-
- /* FIXME: cagney/2002-06-08: This should probably return the frame's
- function and not the PC (a.k.a. resume address). */
- pc = frame_pc_unwind (next_frame);
- (*id) = frame_id_build (base, pc);
+ /* legacy_get_prev_frame() always sets ->this_id.p, hence this is
+ never needed. */
+ internal_error (__FILE__, __LINE__, "legacy_saved_regs_this_id() called");
}
const struct frame_unwind legacy_saved_regs_unwinder = {
@@ -1147,6 +1086,7 @@
else
fi->type = frame_type_from_pc (pc);
+ fi->this_id.p = 1;
deprecated_update_frame_base_hack (fi, addr);
deprecated_update_frame_pc_hack (fi, pc);
@@ -1370,6 +1310,11 @@
{
DEPRECATED_INIT_EXTRA_FRAME_INFO (0, prev);
}
+
+ if (prev->type == NORMAL_FRAME)
+ prev->this_id.value.code_addr
+ = get_pc_function_start (prev->this_id.value.code_addr);
+
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "-> ");
@@ -1578,6 +1523,9 @@
if (prev->unwind->type != UNKNOWN_FRAME)
{
prev->type = prev->unwind->type;
+ if (prev->type == NORMAL_FRAME)
+ prev->this_id.value.code_addr
+ = get_pc_function_start (prev->this_id.value.code_addr);
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "-> ");
@@ -1620,6 +1568,10 @@
go away. */
}
+ if (prev->type == NORMAL_FRAME)
+ prev->this_id.value.code_addr
+ = get_pc_function_start (prev->this_id.value.code_addr);
+
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "-> ");
@@ -2111,8 +2063,8 @@
struct frame_info *
deprecated_frame_xmalloc (void)
{
- struct frame_info *frame = XMALLOC (struct frame_info);
- memset (frame, 0, sizeof (struct frame_info));
+ struct frame_info *frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
+ frame->this_id.p = 1;
return frame;
}