Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ulrich Weigand <weigand@i1.informatik.uni-erlangen.de>
To: cagney@gnu.org (Andrew Cagney)
Cc: weigand@i1.informatik.uni-erlangen.de (Ulrich Weigand),
	drow@false.org (Daniel Jacobowitz),
	gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Fix frame ID comparison problem on s390
Date: Wed, 16 Jun 2004 13:48:00 -0000	[thread overview]
Message-ID: <200406161348.PAA04636@faui1m.informatik.uni-erlangen.de> (raw)
In-Reply-To: <40C724DC.1040306@gnu.org> from "Andrew Cagney" at Jun 09, 2004 10:55:24 AM

Andrew Cagney wrote:

> with something like:
> 
>  > extern struct frame_id frame_id_build_wild (CORE_ADDR stack_addr);
> 
> That way clients would explicitly build a wild-card frame ID, and the 
> frame code was free to implement that mechanism anyway it saw fit.

The following patch adds bits to the struct frame_id that explicitly
state whether each of the stack, code, or special addresses is valid.
This removes the need to choose one particular address value to 
signify the 'invalid/wildcard/...' state.

It also adds the frame_id_build_wild function you suggested.

However, it changes the behaviour in that nobody actually calls _wild
at the moment, since I wasn't sure at what places the code address
actually can be unknown right now.  Those places would need to be
adapted later, if required.

Tested on s390-ibm-linux and s390x-ibm-linux, fixes the signull
test case failure.

OK?

Bye,
Ulrich


ChangeLog:

	* frame.h (struct frame_id): New fields stack_addr_valid,
	code_addr_valid, and special_addr_valid.
	(frame_id_build, frame_id_build_special): Update comments.
	(frame_id_build_wild): New prototype.
	* frame.c (frame_id_build, frame_id_build_special): Fill in new
	struct frame_id fields.
	(frame_id_build_wild): New function.
	(frame_id_eq, frame_id_inner): Use new struct frame_id fields.

Index: gdb/frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.182
diff -c -p -r1.182 frame.c
*** gdb/frame.c	10 Jun 2004 13:22:05 -0000	1.182
--- gdb/frame.c	11 Jun 2004 16:10:13 -0000
*************** frame_id_build_special (CORE_ADDR stack_
*** 272,292 ****
    id.stack_addr = stack_addr;
    id.code_addr = code_addr;
    id.special_addr = special_addr;
    return id;
  }
  
  struct frame_id
  frame_id_build (CORE_ADDR stack_addr, CORE_ADDR code_addr)
  {
!   return frame_id_build_special (stack_addr, code_addr, 0);
  }
  
  int
  frame_id_p (struct frame_id l)
  {
    int p;
!   /* The .code can be NULL but the .stack cannot.  */
!   p = (l.stack_addr != 0);
    if (frame_debug)
      {
        fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=");
--- 272,315 ----
    id.stack_addr = stack_addr;
    id.code_addr = code_addr;
    id.special_addr = special_addr;
+   id.stack_addr_valid = 1;
+   id.code_addr_valid = 1;
+   id.special_addr_valid = 1;
    return id;
  }
  
  struct frame_id
  frame_id_build (CORE_ADDR stack_addr, CORE_ADDR code_addr)
  {
!   struct frame_id id;
!   id.stack_addr = stack_addr;
!   id.code_addr = code_addr;
!   id.special_addr = 0;
!   id.stack_addr_valid = 1;
!   id.code_addr_valid = 1;
!   id.special_addr_valid = 0;
!   return id;
! }
! 
! struct frame_id
! frame_id_build_wild (CORE_ADDR stack_addr)
! {
!   struct frame_id id;
!   id.stack_addr = stack_addr;
!   id.code_addr = 0;
!   id.special_addr = 0;
!   id.stack_addr_valid = 1;
!   id.code_addr_valid = 0;
!   id.special_addr_valid = 0;
!   return id;
  }
  
  int
  frame_id_p (struct frame_id l)
  {
    int p;
!   /* The frame is valid iff it has a valid stack address.  */
!   p = l.stack_addr_valid;
    if (frame_debug)
      {
        fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=");
*************** int
*** 300,319 ****
  frame_id_eq (struct frame_id l, struct frame_id r)
  {
    int eq;
!   if (l.stack_addr == 0 || r.stack_addr == 0)
      /* Like a NaN, if either ID is invalid, the result is false.  */
      eq = 0;
    else if (l.stack_addr != r.stack_addr)
      /* If .stack addresses are different, the frames are different.  */
      eq = 0;
!   else if (l.code_addr == 0 || r.code_addr == 0)
!     /* A zero code addr is a wild card, always succeed.  */
      eq = 1;
    else if (l.code_addr != r.code_addr)
      /* If .code addresses are different, the frames are different.  */
      eq = 0;
!   else if (l.special_addr == 0 || r.special_addr == 0)
!     /* A zero special addr is a wild card (or unused), always succeed.  */
      eq = 1;
    else if (l.special_addr == r.special_addr)
      /* Frames are equal.  */
--- 323,342 ----
  frame_id_eq (struct frame_id l, struct frame_id r)
  {
    int eq;
!   if (!l.stack_addr_valid || !r.stack_addr_valid)
      /* Like a NaN, if either ID is invalid, the result is false.  */
      eq = 0;
    else if (l.stack_addr != r.stack_addr)
      /* If .stack addresses are different, the frames are different.  */
      eq = 0;
!   else if (!l.code_addr_valid || !r.code_addr_valid)
!     /* An invalid code addr is a wild card, always succeed.  */
      eq = 1;
    else if (l.code_addr != r.code_addr)
      /* If .code addresses are different, the frames are different.  */
      eq = 0;
!   else if (!l.special_addr_valid || !r.special_addr_valid)
!     /* An invalid special addr is a wild card (or unused), always succeed.  */
      eq = 1;
    else if (l.special_addr == r.special_addr)
      /* Frames are equal.  */
*************** int
*** 336,342 ****
  frame_id_inner (struct frame_id l, struct frame_id r)
  {
    int inner;
!   if (l.stack_addr == 0 || r.stack_addr == 0)
      /* Like NaN, any operation involving an invalid ID always fails.  */
      inner = 0;
    else
--- 359,365 ----
  frame_id_inner (struct frame_id l, struct frame_id r)
  {
    int inner;
!   if (!l.stack_addr_valid || !r.stack_addr_valid)
      /* Like NaN, any operation involving an invalid ID always fails.  */
      inner = 0;
    else
Index: gdb/frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.134
diff -c -p -r1.134 frame.h
*** gdb/frame.h	10 Jun 2004 13:22:05 -0000	1.134
--- gdb/frame.h	11 Jun 2004 16:10:13 -0000
*************** struct frame_id
*** 107,116 ****
       frames that do not change the stack but are still distinct and have 
       some form of distinct identifier (e.g. the ia64 which uses a 2nd 
       stack for registers).  This field is treated as unordered - i.e. will
!      not be used in frame ordering comparisons such as frame_id_inner().
!      A zero in this field will be treated as a wild-card when comparing
!      frames for equality.  */
    CORE_ADDR special_addr;
  };
  
  /* Methods for constructing and comparing Frame IDs.
--- 107,122 ----
       frames that do not change the stack but are still distinct and have 
       some form of distinct identifier (e.g. the ia64 which uses a 2nd 
       stack for registers).  This field is treated as unordered - i.e. will
!      not be used in frame ordering comparisons such as frame_id_inner().  */
    CORE_ADDR special_addr;
+ 
+   /* Flags to indicate the above fields have valid contents.  An invalid
+      stack address indicates a null frame, while invalid code and special
+      addresses are treated as wild cards that compare equal with every
+      address.  */
+   int stack_addr_valid : 1;
+   int code_addr_valid : 1;
+   int special_addr_valid : 1;
  };
  
  /* Methods for constructing and comparing Frame IDs.
*************** extern const struct frame_id null_frame_
*** 135,156 ****
  
  /* Construct a frame ID.  The first parameter is the frame's constant
     stack address (typically the outer-bound), and the second the
!    frame's constant code address (typically the entry point) (or zero,
!    to indicate a wild card).  The special identifier address is
!    defaulted to zero.  */
  extern struct frame_id frame_id_build (CORE_ADDR stack_addr,
  				       CORE_ADDR code_addr);
  
  /* Construct a special frame ID.  The first parameter is the frame's constant
     stack address (typically the outer-bound), the second is the
!    frame's constant code address (typically the entry point) (or zero,
!    to indicate a wild card), and the third parameter is the frame's
!    special identifier address (or zero to indicate a wild card or 
!    unused default).  */
  extern struct frame_id frame_id_build_special (CORE_ADDR stack_addr,
  					       CORE_ADDR code_addr,
  					       CORE_ADDR special_addr);
  
  /* Returns non-zero when L is a valid frame (a valid frame has a
     non-zero .base).  */
  extern int frame_id_p (struct frame_id l);
--- 141,164 ----
  
  /* Construct a frame ID.  The first parameter is the frame's constant
     stack address (typically the outer-bound), and the second the
!    frame's constant code address (typically the entry point).
!    The special identifier address is set to indicate a wild card.  */
  extern struct frame_id frame_id_build (CORE_ADDR stack_addr,
  				       CORE_ADDR code_addr);
  
  /* Construct a special frame ID.  The first parameter is the frame's constant
     stack address (typically the outer-bound), the second is the
!    frame's constant code address (typically the entry point),
!    and the third parameter is the frame's special identifier address. */
  extern struct frame_id frame_id_build_special (CORE_ADDR stack_addr,
  					       CORE_ADDR code_addr,
  					       CORE_ADDR special_addr);
  
+ /* Construct a wild card frame ID.  The parameter is the frame's constant
+    stack address (typically the outer-bound).  The code address as well
+    as the special identifier address are set to indicate wild cards.  */
+ extern struct frame_id frame_id_build_wild (CORE_ADDR stack_addr);
+ 
  /* Returns non-zero when L is a valid frame (a valid frame has a
     non-zero .base).  */
  extern int frame_id_p (struct frame_id l);

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


  reply	other threads:[~2004-06-16 13:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-20 13:31 Ulrich Weigand
2004-05-20 14:17 ` Daniel Jacobowitz
2004-05-24 13:45   ` Ulrich Weigand
2004-05-24 18:52     ` Andrew Cagney
2004-06-09 14:12       ` Ulrich Weigand
2004-06-09 14:55         ` Andrew Cagney
2004-06-16 13:48           ` Ulrich Weigand [this message]
2004-06-16 17:33             ` Andrew Cagney
2004-06-27 20:48               ` Ulrich Weigand
2004-06-27 21:48                 ` Daniel Jacobowitz
2004-06-27 22:35                   ` Ulrich Weigand
2004-06-27 22:59                   ` Andreas Schwab
2004-06-27 23:11                     ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200406161348.PAA04636@faui1m.informatik.uni-erlangen.de \
    --to=weigand@i1.informatik.uni-erlangen.de \
    --cc=cagney@gnu.org \
    --cc=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox