Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch, rfc] frame attribute - FRAME_IS_CALLER
@ 2003-07-09 20:04 Andrew Cagney
  2003-07-09 21:29 ` Daniel Jacobowitz
  2003-07-15 17:39 ` Andrew Cagney
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cagney @ 2003-07-09 20:04 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

Hello,

Ref: Add frame_is_callee_p(), use in dwarf2-frame.c?,
http://sources.redhat.com/ml/gdb-patches/2003-07/msg00046.html

This patch adds a new `frame attribute' methods and defines one 
attribute `FRAME_IS_CALLER' (described in comment) (again better name?).

It then uses it in a couple random places so that i know it is working.

thoughts,

The attached would be committed to the mainline, and just the new 
methods to the branch.

Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 5296 bytes --]

2003-07-09  Andrew Cagney  <cagney@redhat.com>

	* frame.c (frame_unwind_attrib, get_frame_attrib): New functions.
	(pc_notcurrent): Delete function.
	(find_frame_sal): Use get_frame_attrib instead of pc_notcurrent.
	* frame.h (frame_attrib): Define.
	(get_frame_attrib): Declare.
	(frame_unwind_attrib): Declare.
	* blockframe.c (frame_address_in_block): Use get_frame_attrib
	instead of get_frame_type.

Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.72
diff -u -r1.72 blockframe.c
--- blockframe.c	23 May 2003 17:05:19 -0000	1.72
+++ blockframe.c	9 Jul 2003 19:56:01 -0000
@@ -179,15 +179,11 @@
 
   /* If we are not in the innermost frame, and we are not interrupted
      by a signal, frame->pc points to the instruction following the
-     call. As a consequence, we need to get the address of the previous
-     instruction. Unfortunately, this is not straightforward to do, so
-     we just use the address minus one, which is a good enough
-     approximation.  */
-  /* FIXME: cagney/2002-11-10: Should this instead test for
-     NORMAL_FRAME?  A dummy frame (in fact all the abnormal frames)
-     save the PC value in the block.  */
-  if (get_next_frame (frame) != 0
-      && get_frame_type (get_next_frame (frame)) != SIGTRAMP_FRAME)
+     call.  As a consequence, we need to get the address of the
+     previous instruction.  Unfortunately, this is not straightforward
+     to do, so we just use the address minus one, which is a good
+     enough approximation.  */
+  if (get_frame_attrib (frame, FRAME_IS_CALLER))
     --pc;
 
   return pc;
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.130
diff -u -r1.130 frame.c
--- frame.c	7 Jul 2003 20:07:12 -0000	1.130
+++ frame.c	9 Jul 2003 19:56:01 -0000
@@ -2006,8 +2006,8 @@
   return frame_pc_unwind (frame->next);
 }
 
-static int
-pc_notcurrent (struct frame_info *frame)
+void
+find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal)
 {
   /* If FRAME is not the innermost frame, that normally means that
      FRAME->pc points at the return instruction (which is *after* the
@@ -2018,15 +2018,8 @@
      PC and such a PC indicates the current (rather than next)
      instruction/line, consequently, for such cases, want to get the
      line containing fi->pc.  */
-  struct frame_info *next = get_next_frame (frame);
-  int notcurrent = (next != NULL && get_frame_type (next) == NORMAL_FRAME);
-  return notcurrent;
-}
-
-void
-find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal)
-{
-  (*sal) = find_pc_line (get_frame_pc (frame), pc_notcurrent (frame));
+  int pc_notcurrent = get_frame_attrib (frame, FRAME_IS_CALLER);
+  (*sal) = find_pc_line (get_frame_pc (frame), pc_notcurrent);
 }
 
 /* Per "frame.h", return the ``address'' of the frame.  Code should
@@ -2139,6 +2132,33 @@
 {
   /* Arrrg!  See comment in "frame.h".  */
   frame->type = type;
+}
+
+int
+get_frame_attrib (struct frame_info *this_frame, enum frame_attrib attrib)
+{
+  return frame_unwind_attrib (this_frame->next, attrib);
+}
+
+int
+frame_unwind_attrib (struct frame_info *next_frame, enum frame_attrib attrib)
+{
+  switch (attrib)
+    {
+    case FRAME_IS_CALLER:
+      /* If the next frame is a sentinel, this frame can't be a
+         caller.  */
+      if (next_frame->level < 0)
+	return 0;
+      /* If the next frame isn't normal, this frame can't be a caller.
+         Use get_frame_type because that hides NORMAL_FRAME.  */
+      if (get_frame_type (next_frame) != NORMAL_FRAME)
+	return 0;
+      /* Hope its a call frame.  */
+      return 1;
+    default:
+      internal_error (__FILE__, __LINE__, "bad switch");
+    }
 }
 
 struct frame_extra_info *
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.104
diff -u -r1.104 frame.h
--- frame.h	7 Jul 2003 14:36:58 -0000	1.104
+++ frame.h	9 Jul 2003 19:56:03 -0000
@@ -322,6 +322,27 @@
 };
 extern enum frame_type get_frame_type (struct frame_info *);
 
+/* Frame attributes.  These can be tested individually.  Please use
+   this in preference to the frame type.  */
+
+enum frame_attrib
+{
+  /* THIS is a "caller frame".  It executed a "call" instruction as
+     part of creating the NEXT frame (which is the "callee").  Unlike
+     other categories of frames, this frame's PC value does not need
+     to point at valid code.  For instance, if the callee is no-return
+     and the caller (this frame) is at the end of the function, any
+     code after the function call instruction may have been eliminated
+     by the compiler leaving this frame's PC pointing outside of the
+     current function or even into the next function.  */
+  FRAME_IS_CALLER
+};
+
+extern int get_frame_attrib (struct frame_info *this_frame,
+			     enum frame_attrib attrib);
+extern int frame_unwind_attrib (struct frame_info *next_frame,
+				enum frame_attrib attrib);
+
 /* FIXME: cagney/2002-11-10: Some targets want to directly mark a
    frame as being of a specific type.  This shouldn't be necessary.
    PC_IN_SIGTRAMP() indicates a SIGTRAMP_FRAME and

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, rfc] frame attribute - FRAME_IS_CALLER
  2003-07-09 20:04 [patch, rfc] frame attribute - FRAME_IS_CALLER Andrew Cagney
@ 2003-07-09 21:29 ` Daniel Jacobowitz
  2003-07-10 19:03   ` Andrew Cagney
  2003-07-15 17:39 ` Andrew Cagney
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-07-09 21:29 UTC (permalink / raw)
  To: gdb-patches

On Wed, Jul 09, 2003 at 04:04:03PM -0400, Andrew Cagney wrote:
> Hello,
> 
> Ref: Add frame_is_callee_p(), use in dwarf2-frame.c?,
> http://sources.redhat.com/ml/gdb-patches/2003-07/msg00046.html
> 
> This patch adds a new `frame attribute' methods and defines one 
> attribute `FRAME_IS_CALLER' (described in comment) (again better name?).
> 
> It then uses it in a couple random places so that i know it is working.
> 
> thoughts,
> 
> The attached would be committed to the mainline, and just the new 
> methods to the branch.
> 
> Andrew

Shouldn't FRAME_IS_CALLER only be true if THIS->type == NORMAL_FRAME &&
NEXT->type == NORMAL_FRAME?  If NEXT->type == NORMAL_FRAME but
THIS->type == DUMMY_FRAME, then NEXT's return PC shouldn't be
decremented, et cetera.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, rfc] frame attribute - FRAME_IS_CALLER
  2003-07-09 21:29 ` Daniel Jacobowitz
@ 2003-07-10 19:03   ` Andrew Cagney
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2003-07-10 19:03 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

> On Wed, Jul 09, 2003 at 04:04:03PM -0400, Andrew Cagney wrote:
> 
>> Hello,
>> 
>> Ref: Add frame_is_callee_p(), use in dwarf2-frame.c?,
>> http://sources.redhat.com/ml/gdb-patches/2003-07/msg00046.html
>> 
>> This patch adds a new `frame attribute' methods and defines one 
>> attribute `FRAME_IS_CALLER' (described in comment) (again better name?).
>> 
>> It then uses it in a couple random places so that i know it is working.
>> 
>> thoughts,
>> 
>> The attached would be committed to the mainline, and just the new 
>> methods to the branch.
>> 
>> Andrew
> 
> 
> Shouldn't FRAME_IS_CALLER only be true if THIS->type == NORMAL_FRAME &&
> NEXT->type == NORMAL_FRAME?  If NEXT->type == NORMAL_FRAME but
> THIS->type == DUMMY_FRAME, then NEXT's return PC shouldn't be
> decremented, et cetera.

You mean, does a dummy frame `call' a normal frame?  As far as the 
callee (the normal frame) is concerned, yes.  It can't detect any thing 
different.  It was called by the dummy frame.

The assert this->type != DUMMY_FRAME probably wouldn't hurt 
frame_address_in_block though - the function is meaningless for dummy 
frames.

Andrew



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, rfc] frame attribute - FRAME_IS_CALLER
  2003-07-09 20:04 [patch, rfc] frame attribute - FRAME_IS_CALLER Andrew Cagney
  2003-07-09 21:29 ` Daniel Jacobowitz
@ 2003-07-15 17:39 ` Andrew Cagney
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2003-07-15 17:39 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

> Hello,
> 
> Ref: Add frame_is_callee_p(), use in dwarf2-frame.c?,
> http://sources.redhat.com/ml/gdb-patches/2003-07/msg00046.html
> 
> This patch adds a new `frame attribute' methods and defines one attribute `FRAME_IS_CALLER' (described in comment) (again better name?).
> 
> It then uses it in a couple random places so that i know it is working.
> 
> thoughts,
> 
> The attached would be committed to the mainline, and just the new methods to the branch.

Patch withdrawn.  Turn out I didn't need it.  Leave this for the day 
that there is evidence that it is really needed.

Andrew



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-15 17:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-09 20:04 [patch, rfc] frame attribute - FRAME_IS_CALLER Andrew Cagney
2003-07-09 21:29 ` Daniel Jacobowitz
2003-07-10 19:03   ` Andrew Cagney
2003-07-15 17:39 ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox