[PATCH] Fix frame ID comparison problem on s390

Ulrich Weigand weigand@i1.informatik.uni-erlangen.de
Sun Jun 27 20:48:00 GMT 2004


Andrew Cagney wrote:

> with those changes its ok,

Thanks; here's the version I finally committed.

(Sorry it took so long, I got sidetracked by a kernel bug triggered
by running the gdb test suite that caused random kernel memory 
corruption :-/)

Bye,
Ulrich


ChangeLog:

        * frame.h (struct frame_id): New fields stack_addr_p, code_addr_p
	and special_addr_p.
        (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	16 Jun 2004 18:53:20 -0000
*************** struct frame_id
*** 268,292 ****
  frame_id_build_special (CORE_ADDR stack_addr, CORE_ADDR code_addr,
                          CORE_ADDR special_addr)
  {
!   struct frame_id id;
    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=");
--- 268,309 ----
  frame_id_build_special (CORE_ADDR stack_addr, CORE_ADDR code_addr,
                          CORE_ADDR special_addr)
  {
!   struct frame_id id = null_frame_id;
    id.stack_addr = stack_addr;
+   id.stack_addr_p = 1;
    id.code_addr = code_addr;
+   id.code_addr_p = 1;
    id.special_addr = special_addr;
+   id.special_addr_p = 1;
    return id;
  }
  
  struct frame_id
  frame_id_build (CORE_ADDR stack_addr, CORE_ADDR code_addr)
  {
!   struct frame_id id = null_frame_id;
!   id.stack_addr = stack_addr;
!   id.stack_addr_p = 1;
!   id.code_addr = code_addr;
!   id.code_addr_p = 1;
!   return id;
! }
! 
! struct frame_id
! frame_id_build_wild (CORE_ADDR stack_addr)
! {
!   struct frame_id id = null_frame_id;
!   id.stack_addr = stack_addr;
!   id.stack_addr_p = 1;
!   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_p;
    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.  */
--- 317,337 ----
  frame_id_eq (struct frame_id l, struct frame_id r)
  {
    int eq;
!   if (!l.stack_addr_p || !r.stack_addr_p)
!     /* Like a NaN, if either ID is invalid, the result is false.
!        Note that a frame ID is invalid iff it is the null frame ID.  */
      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_p || !r.code_addr_p)
!     /* 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_p || !r.special_addr_p)
!     /* 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
--- 354,360 ----
  frame_id_inner (struct frame_id l, struct frame_id r)
  {
    int inner;
!   if (!l.stack_addr_p || !r.stack_addr_p)
      /* 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	16 Jun 2004 18:53:20 -0000
*************** struct frame_id
*** 94,116 ****
       outer-most address (the inner-most address of the previous frame)
       is used.  Watch out for all the legacy targets that still use the
       function pointer register or stack pointer register.  They are
!      wrong.  */
    CORE_ADDR stack_addr;
    /* The frame's code address.  This shall be constant through out the
       lifetime of the frame.  While the PC (a.k.a. resume address)
       changes as the function is executed, this code address cannot.
       Typically, it is set to the address of the entry point of the
!      frame's function (as returned by frame_func_unwind().  */
    CORE_ADDR code_addr;
    /* The frame's special address.  This shall be constant through out the
       lifetime of the frame.  This is used for architectures that may have
       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.
--- 94,132 ----
       outer-most address (the inner-most address of the previous frame)
       is used.  Watch out for all the legacy targets that still use the
       function pointer register or stack pointer register.  They are
!      wrong.
! 
!      This field is valid only if stack_addr_p is true.  Otherwise, this
!      frame represents the null frame.  */
    CORE_ADDR stack_addr;
+ 
    /* The frame's code address.  This shall be constant through out the
       lifetime of the frame.  While the PC (a.k.a. resume address)
       changes as the function is executed, this code address cannot.
       Typically, it is set to the address of the entry point of the
!      frame's function (as returned by frame_func_unwind().  
! 
!      This field is valid only if code_addr_p is true.  Otherwise, this
!      frame is considered to have a wildcard code address, i.e. one that
!      matches every address value in frame comparisons.  */
    CORE_ADDR code_addr;
+ 
    /* The frame's special address.  This shall be constant through out the
       lifetime of the frame.  This is used for architectures that may have
       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().
! 
!      This field is valid only if special_addr_p is true.  Otherwise, this
!      frame is considered to have a wildcard special address, i.e. one that
!      matches every address value in frame comparisons.  */
    CORE_ADDR special_addr;
+ 
+   /* Flags to indicate the above fields have valid contents.  */
+   int stack_addr_p : 1;
+   int code_addr_p : 1;
+   int special_addr_p : 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);
--- 151,174 ----
  
  /* 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



More information about the Gdb-patches mailing list