This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for DejaGnu test case "pointers"


Hi,

I'm working at Axis Communications in Lund, Sweden, and I'm updating our
port of gdb for cross-debugging. An assign.future has been submitted
previously that covers all employees. This is my first patch submission
(more patches are on the way), so I'd appreciate feedback if any changes
are needed.

I'd like to submit a patch for the DejaGnu test case called pointers. In
pointers.c, the following variables are declared:

float F, *pF;
double D, *pD;

and later the following statements:

F = 1.25E10;
pF = &F;
D = -1.375E-123;
pD = &D;

-1.375E-123 will only fit if a double is (at least) 8 bytes. For a
4-byte double, an underflow occurs. In pointers.exp, there is a test
that prints *pD which fails. However, assigning D something that fits is
not enough since the pattern matching with respect to the decimals for
doubles and floats differ, which also seems to stem from an assumption
about their respective sizes. print *pD is required to match *exactly*,
whereas print *pF is checked only until the first decimal.

I'm not an expert on various sizes of floats and doubles, so maybe I'm
also making assumptions about sizes. From K&R, The C Programming
Language, Appendix B11, "acceptable minimum" for FLT_MIN is 1E-37. I
suggest using D = -1.25E-37, and checking only the first decimal. The
patches below to that.

*************** int more_code()
*** 194,200 ****
      L = -234;
      UL = 234;
      F = 1.25E10;
!     D = -1.375E-123;
      pC = &C;
      ppC = &pC;
      pppC = &ppC;
--- 194,200 ----
      L = -234;
      UL = 234;
      F = 1.25E10;
!     D = -1.25E-37;
      pC = &C;
      ppC = &pC;
      pppC = &ppC;


*************** gdb_expect {
*** 522,528 ****
  
  send_gdb "print *pD\n"
  gdb_expect {
!     -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
          pass "print value of *pD"
        }
      -re ".*$gdb_prompt $" { fail "print value of *pD" }
--- 522,528 ----
  
  send_gdb "print *pD\n"
  gdb_expect {
!     -re ".\[0-9\]* = -1.2\[0-9\]*e\\-37.*$gdb_prompt $" {
          pass "print value of *pD"
        }
      -re ".*$gdb_prompt $" { fail "print value of *pD" }



Orjan Friberg
Axis Communications AB
E-mail: orjan.friberg@axis.com 
Phone:  +46 46 272 17 68

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]