[RFA] Fixup long_long.exp for 4-byte short

Michael Snyder
2001-05-21T11:41:00Z

Along the same lines as one of Stephane Carrez's recent submissions:
2001-05-21 Michael Snyder <msnyder@redhat.com>

* gdb.base/long_long.exp: Allow for targets with 4-byte short.

Index: long_long.exp
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/long_long.exp,v
retrieving revision 1.10
diff -c -3 -p -r1.10 long_long.exp
*** long_long.exp 2001/03/26 19:55:25 1.10
--- long_long.exp 2001/05/21 18:37:45
*************** gdb_expect {
*** 85,90 ****
--- 85,100 ----
default { }
}

+ # Detect targets with 4-byte shorts. Assume all others use 2-bytes.
+
+ set sizeof_short 2
+ send_gdb "print sizeof(short)\n"
+ gdb_expect {
+ -re ".* = 4.*$gdb_prompt $" { set sizeof_short 4 }
+ -re ".*$gdb_prompt $" { }
+ default { }
+ }
+
# Detect targets with 4-byte doubles.

set sizeof_double 8
*************** if { $target_bigendian_p } {
*** 172,185 ****

}

! gdb_test "p/d *(short *)&oct" ".*-22738.*"
! gdb_test "p/u *(short *)&oct" ".*42798.*"
! gdb_test "p/o *(short *)&oct" ".*0123456.*"
! gdb_test "p/t *(short *)&oct" ".*1010011100101110.*"
! gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
! gdb_test "p/c *(short *)&oct" ".* 46 '.'.*"
! gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
! gdb_test "p/f *(short *)&oct" ".*-22738.*"

gdb_test "x/x &oct" ".*0xa72ee539.*"
gdb_test "x/d &oct" ".*.-1490098887*"
--- 182,204 ----

}

! if { $sizeof_short == 2 } {
! gdb_test "p/d *(short *)&oct" ".*-22738.*"
! gdb_test "p/u *(short *)&oct" ".*42798.*"
! gdb_test "p/o *(short *)&oct" ".*0123456.*"
! gdb_test "p/t *(short *)&oct" ".*1010011100101110.*"
! gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
! gdb_test "p/c *(short *)&oct" ".* 46 '.'.*"
! gdb_test "p/f *(short *)&oct" ".*-22738.*"
! } else {
! gdb_test "p/d *(short *)&oct" ".*-1490098887.*"
! gdb_test "p/u *(short *)&oct" ".*2804868409.*"
! gdb_test "p/o *(short *)&oct" ".*024713562471.*"
! gdb_test "p/t *(short *)&oct" ".*10100111001011101110010100111001.*"
! gdb_test "p/a *(short *)&oct" ".*0xf*a72ee539.*"
! gdb_test "p/c *(short *)&oct" ".* 57 '9'.*"
! gdb_test "p/f *(short *)&oct" ".*-2.42716126e-15.*"
! }

gdb_test "x/x &oct" ".*0xa72ee539.*"
gdb_test "x/d &oct" ".*.-1490098887*"
From msnyder@cygnus.com Mon May 21 11:49:00 2001
From: Michael Snyder <msnyder@cygnus.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH]: remote.c, catch return value of hex2bin
Date: Mon, 21 May 2001 11:49:00 -0000
Message-id: <3B096334.58242CB@cygnus.com>
X-SW-Source: 2001-05/msg00398.html
Content-length: 1369

As suggested by John Kallal, remote_async_wait also requires this fix:
2001-05-21 Michael Snyder <msnyder@redhat.com>

* remote.c (remote_async_wait): Added new variable fieldsize.
Add fieldsize (return value of hex2bin) to string pointer p.

Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.53
diff -c -3 -p -r1.53 remote.c
*** remote.c 2001/05/16 20:10:52 1.53
--- remote.c 2001/05/21 18:47:28
*************** remote_async_wait (ptid_t ptid, struct t
*** 3060,3065 ****
--- 3060,3066 ----
{
unsigned char *p1;
char *p_temp;
+ int fieldsize;

/* Read the register number */
regno = strtol ((const char *) p, &p_temp, 16);
*************** Packet: '%s'\n",
*** 3093,3100 ****
Packet: '%s'\n",
regno, p, buf);

! if (hex2bin (p, regs, REGISTER_RAW_SIZE (regno))
! < REGISTER_RAW_SIZE (regno))
warning ("Remote reply is too short: %s", buf);
supply_register (regno, regs);
}
--- 3094,3102 ----
Packet: '%s'\n",
regno, p, buf);

! fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
! p += 2 * fieldsize;
! if (fieldsize < REGISTER_RAW_SIZE (regno))
warning ("Remote reply is too short: %s", buf);
supply_register (regno, regs);
}
From kettenis@wins.uva.nl Mon May 21 12:33:00 2001
From: Mark Kettenis <kettenis@wins.uva.nl>
To: kallal@home.com
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH RFC] Make lin-lwp.c functions use target vectors
Date: Mon, 21 May 2001 12:33:00 -0000
Message-id: <200105211933.f4LJXTZ00243@delius.kettenis.local>
References: <Pine.LNX.4.21.0105172127080.1203@CyberMax.local>
X-SW-Source: 2001-05/msg00399.html
Content-length: 1345

Date: Thu, 17 May 2001 21:27:18 -0400 (EDT)
From: "John S. Kallal" <kallal@home.com>

Hi John,

As you've noticed, the code in lin-lwp.c does some very low-level
things. In fact it is so closely tied to the "child_ops" layer, that
I don't feel comfortable applying your patch, even though in the long
run a patch similar to yours may be the way to go. I think it is
essential to envision how gdb and gdbserver should interact when
debugging multi-threaded code first, before starting to do any
coding. I'm not terribly well familiar with the GDB remote protocol,
but I do think that changes to the remote protocol and/or gdbserver
are necessary (probably both). Unfortunately I won't have time in the
near future to work on this myself. Volunteers to work on this stuff
are welcome!

That said, there are two obstacles when contributing code to GDB. The
first is a copyright assignment: copyrights for any significant
changes need to be assigned to the FSF before we can include them in
the GDB sources. This can take a bit of time, so if you're serious in
contributing to GDB, make sure the paperwork gets done.

The second point is that code has to conform to the GNU/GDB coding
standards. Your code currently doesn't, so I'd suggest you look at
the GNU coding standards and the suggestions on the GDB web pages.

Thanks,

Mark