* Patch for new i386 `info float' command
@ 1999-11-13 10:18 Mark Kettenis
0 siblings, 0 replies; only message in thread
From: Mark Kettenis @ 1999-11-13 10:18 UTC (permalink / raw)
To: gdb-patches
Here is a patch that implements the new generic i386 `info float'
command. The new i387-tdep.c is a bit of a mess since it still
contains code that used by some of the old target specific `info
float' implementation and the Linux `long double' kludges. These bits
of code should be removed eventually and I added some comments saying
so.
The new `info float' command uses the *_filtered functions as
suggested by Andrew Cagney. The way the floating point values are
printed means that on some hosts there is a partial precision loss. I
think this is OK since full information is still available (as
hexadecimal output) and even partial information can be useful.
Mark
1999-11-13 Mark Kettenis <kettenis@gnu.org>
* config/i386/tm-i386.h (FLOAT_INFO): New define.
* i387-tdep.c (print_i387_value, print_i387_ext,
print_i387_status_word, print_i387_control_word, i387_float_info):
New functions, used to implement generic `info float' command.
Index: config/i386/tm-i386.h
===================================================================
RCS file: /var/cvsroot/gdb/gdb/config/i386/tm-i386.h,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 tm-i386.h
--- config/i386/tm-i386.h 1999/11/13 14:31:07 1.1.1.8
+++ config/i386/tm-i386.h 1999/11/13 17:30:39
@@ -259,6 +259,13 @@
double_to_i387((char *)&val, (TO)); \
}
+/* Print out the i387 floating point state. */
+#ifdef HAVE_I387_REGS
+extern void i387_float_info (void);
+#define FLOAT_INFO { i387_float_info (); }
+#endif
+
+\f
/* Store the address of the place in which to copy the structure the
subroutine will return. This is called from call_function. */
Index: i387-tdep.c
===================================================================
RCS file: /var/cvsroot/gdb/gdb/i387-tdep.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 i387-tdep.c
--- i387-tdep.c 1999/10/02 19:51:09 1.1.1.4
+++ i387-tdep.c 1999/11/13 17:27:21
@@ -1,5 +1,5 @@
/* Intel 387 floating point stuff.
- Copyright (C) 1988, 1989, 1991, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1988, 1989, 1991, 1998, 1999 Free Software Foundation, Inc.
This file is part of GDB.
@@ -26,14 +26,12 @@
#include "gdbcore.h"
#include "floatformat.h"
-void i387_to_double PARAMS ((char *, char *));
-void double_to_i387 PARAMS ((char *, char *));
-static void print_387_control_bits PARAMS ((unsigned int control));
-static void print_387_status_bits PARAMS ((unsigned int status));
+/* FIXME: Eliminate the next two functions when we have the time to
+ change all the callers. */
-/* FIXME: Eliminate these routines when we have the time to change all
- the callers. */
+void i387_to_double PARAMS ((char *from, char *to));
+void double_to_i387 PARAMS ((char *from, char *to));
void
i387_to_double (from, to)
@@ -51,6 +49,16 @@
floatformat_from_double (&floatformat_i387_ext, (double *) from, to);
}
+\f
+/* FIXME: The functions on this page are used by the old `info float'
+ implementations that a few of the i386 targets provide. These
+ functions should be removed if all of these have been converted to
+ use the generic implementation based on the new register file
+ layout. */
+
+static void print_387_control_bits PARAMS ((unsigned int control));
+static void print_387_status_bits PARAMS ((unsigned int status));
+
static void
print_387_control_bits (control)
unsigned int control;
@@ -149,6 +157,243 @@
puts_unfiltered ("\n");
}
+\f
+/* Implement the `info float' layout based on the register definitions
+ in `tm-i386.h'. */
+
+/* Print the floating point number specified by RAW. */
+static void
+print_i387_value (char *raw)
+{
+ DOUBLEST value;
+
+ floatformat_to_doublest (&floatformat_i387_ext, raw, &value);
+
+ /* We try to print 19 digits. The last digit may or may not contain
+ garbage, but we'd better print one too many. We need enough room
+ to print the value, 1 position for the sign, 1 for the decimal
+ point, 19 for the digits and 6 for the exponent adds up to 27. */
+#ifdef PRINTF_HAS_LONG_DOUBLE
+ printf_filtered (" %-+27.19Lg", (long double) value);
+#else
+ printf_filtered (" %-+27.19g", (double) value);
+#endif
+}
+
+/* Print the classification for the register contents RAW. */
+static void
+print_i387_ext (unsigned char *raw)
+{
+ int sign;
+ int integer;
+ unsigned int exponent;
+ unsigned long fraction[2];
+
+ sign = raw[9] & 0x80;
+ integer = raw[7] & 0x80;
+ exponent = (((raw[9] & 0x7f) << 8) | raw[8]);
+ fraction[0] = ((raw[3] << 24) | (raw[2] << 16) | (raw[1] << 8) | raw[0]);
+ fraction[1] = (((raw[7] & 0x7f) << 24) | (raw[6] << 16)
+ | (raw[5] << 8) | raw[4]);
+
+ if (exponent == 0x7fff && integer)
+ {
+ if (fraction[0] == 0x00000000 && fraction[1] == 0x00000000)
+ /* Infinity. */
+ printf_filtered (" %cInf", (sign ? '-' : '+'));
+ else if (sign && fraction[0] == 0x00000000 && fraction[1] == 0x40000000)
+ /* Real Indefinite (QNaN). */
+ puts_unfiltered (" Real Indefinite (QNaN)");
+ else if (fraction[1] & 0x40000000)
+ /* QNaN. */
+ puts_filtered (" QNaN");
+ else
+ /* SNaN. */
+ puts_filtered (" SNaN");
+ }
+ else if (exponent < 0x7fff && exponent > 0x0000 && integer)
+ /* Normal. */
+ print_i387_value (raw);
+ else if (exponent == 0x0000)
+ {
+ /* Denormal or zero. */
+ print_i387_value (raw);
+
+ if (integer)
+ /* Pseudo-denormal. */
+ puts_filtered (" Pseudo-denormal");
+ else if (fraction[0] || fraction[1])
+ /* Denormal. */
+ puts_filtered (" Denormal");
+ }
+ else
+ /* Unsupported. */
+ puts_filtered (" Unsupported");
+}
+
+/* Print the status word STATUS. */
+static void
+print_i387_status_word (unsigned int status)
+{
+ printf_filtered ("Status Word: %s",
+ local_hex_string_custom (status, "04"));
+ puts_filtered (" ");
+ printf_filtered (" %s", (status & 0x0001) ? "IE" : " ");
+ printf_filtered (" %s", (status & 0x0002) ? "DE" : " ");
+ printf_filtered (" %s", (status & 0x0004) ? "ZE" : " ");
+ printf_filtered (" %s", (status & 0x0008) ? "OE" : " ");
+ printf_filtered (" %s", (status & 0x0010) ? "UE" : " ");
+ printf_filtered (" %s", (status & 0x0020) ? "PE" : " ");
+ puts_filtered (" ");
+ printf_filtered (" %s", (status & 0x0080) ? "ES" : " ");
+ puts_filtered (" ");
+ printf_filtered (" %s", (status & 0x0080) ? "SF" : " ");
+ puts_filtered (" ");
+ printf_filtered (" %s", (status & 0x0100) ? "C0" : " ");
+ printf_filtered (" %s", (status & 0x0200) ? "C1" : " ");
+ printf_filtered (" %s", (status & 0x0400) ? "C2" : " ");
+ printf_filtered (" %s", (status & 0x4000) ? "C3" : " ");
+
+ puts_filtered ("\n");
+
+ printf_filtered (" TOP: %d\n", ((status >> 11) & 7));
+}
+
+/* Print the control word CONTROL. */
+static void
+print_i387_control_word (unsigned int control)
+{
+ printf_filtered ("Control Word: %s",
+ local_hex_string_custom (control, "04"));
+ puts_filtered (" ");
+ printf_filtered (" %s", (control & 0x0001) ? "IM" : " ");
+ printf_filtered (" %s", (control & 0x0002) ? "DM" : " ");
+ printf_filtered (" %s", (control & 0x0004) ? "ZM" : " ");
+ printf_filtered (" %s", (control & 0x0008) ? "OM" : " ");
+ printf_filtered (" %s", (control & 0x0010) ? "UM" : " ");
+ printf_filtered (" %s", (control & 0x0020) ? "PM" : " ");
+
+ puts_filtered ("\n");
+
+ puts_filtered (" PC: ");
+ switch ((control >> 8) & 3)
+ {
+ case 0:
+ puts_filtered ("Single Precision (24-bits)\n");
+ break;
+ case 1:
+ puts_filtered ("Reserved\n");
+ break;
+ case 2:
+ puts_filtered ("Double Precision (53-bits)\n");
+ break;
+ case 3:
+ puts_filtered ("Extended Precision (64-bits)\n");
+ break;
+ }
+
+ puts_filtered (" RC: ");
+ switch ((control >> 10) & 3)
+ {
+ case 0:
+ puts_filtered ("Round to nearest\n");
+ break;
+ case 1:
+ puts_filtered ("Round down\n");
+ break;
+ case 2:
+ puts_filtered ("Round up\n");
+ break;
+ case 3:
+ puts_filtered ("Round toward zero\n");
+ break;
+ }
+}
+
+/* Print out the i387 floating poin state. */
+void
+i387_float_info (void)
+{
+ unsigned int fctrl;
+ unsigned int fstat;
+ unsigned int ftag;
+ unsigned int fiseg;
+ unsigned int fioff;
+ unsigned int foseg;
+ unsigned int fooff;
+ unsigned int fop;
+ int fpreg;
+ int top;
+
+ fctrl = read_register (FCTRL_REGNUM);
+ fstat = read_register (FSTAT_REGNUM);
+ ftag = read_register (FTAG_REGNUM);
+ fiseg = read_register (FCS_REGNUM);
+ fioff = read_register (FCOFF_REGNUM);
+ foseg = read_register (FDS_REGNUM);
+ fooff = read_register (FDOFF_REGNUM);
+ fop = read_register (FOP_REGNUM);
+
+ top = ((fstat >> 11) & 7);
+
+ for (fpreg = 7; fpreg >= 0; fpreg--)
+ {
+ unsigned char raw[FPU_REG_RAW_SIZE];
+ int tag = (ftag >> (fpreg * 2)) & 3;
+ int i;
+
+ printf_filtered ("%sR%d: ", fpreg == top ? "=>" : " ", fpreg);
+
+ switch (tag)
+ {
+ case 0:
+ puts_filtered ("Valid ");
+ break;
+ case 1:
+ puts_filtered ("Zero ");
+ break;
+ case 2:
+ puts_filtered ("Special ");
+ break;
+ case 3:
+ puts_filtered ("Empty ");
+ break;
+ }
+
+ read_register_gen ((fpreg + 8 - top) % 8 + FP0_REGNUM, raw);
+
+ puts_filtered ("0x");
+ for (i = 9; i >= 0; i--)
+ printf_filtered ("%02x", raw[i]);
+
+ if (tag != 3)
+ print_i387_ext (raw);
+
+ puts_filtered ("\n");
+ }
+
+ puts_filtered ("\n");
+
+ print_i387_status_word (fstat);
+ print_i387_control_word (fctrl);
+ printf_filtered ("Tag Word: %s\n",
+ local_hex_string_custom (ftag, "04"));
+ printf_filtered ("Instruction Pointer: %s:",
+ local_hex_string_custom (fiseg, "02"));
+ printf_filtered ("%s\n", local_hex_string_custom (fioff, "08"));
+ printf_filtered ("Operand Pointer: %s:",
+ local_hex_string_custom (foseg, "02"));
+ printf_filtered ("%s\n", local_hex_string_custom (fooff, "08"));
+ printf_filtered ("Opcode: %s\n",
+ local_hex_string_custom (fop ? (fop | 0xd800) : 0, "04"));
+}
+
+\f
+/* FIXME: The functions on this page are used to provide `long double'
+ support for Linux. However, the approach does not seem to be the
+ right one, and we are planning to solve this in a way that should
+ work for all i386 targets. These functions will disappear in the
+ near future, so please don't use them. */
#ifdef LD_I387
int
i387_extract_floating (PTR addr, int len, DOUBLEST *dretptr)
From ac131313@cygnus.com Mon Nov 15 14:54:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Kevin Buettner <kevinb@cygnus.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: RFA: PACKET_OVERHEAD constant added to remote.c
Date: Mon, 15 Nov 1999 14:54:00 -0000
Message-id: <38308EDB.A02AF873@cygnus.com>
References: <991112184146.ZM22052@ocotillo.lan>
X-SW-Source: 1999-q4/msg00252.html
Content-length: 1253
Kevin Buettner wrote:
>
> Hi Andrew,
>
> Jesper Skov alerted me to the fact that we were getting some "Remote
> packet too long" messages when attempting to debug using a gdbserver
> for i386 linux. The problem was that the memory packet size
> computations were not taking into account the packet overhead. This
> would've been a one line fix, but I decided to define PACKET_OVERHEAD
> instead of adding another hard-coded instance of the constant 32.
Keven,
I'm puzzled. (I guess you mean one of the M or X packets?).
I thought the function remote_write_bytes () was already taking care of
the packet overhead. Can you expand a little on what exactly Jesper is
seeing?
perhaphs this is an old problem?
confused,
Andrew
FYI, the pre change code is below, the new code was ment to be
functionally equivalent.
#define MAXBUFBYTES(N) (((N)-32)/2)
#define PBUFSIZ ((REGISTER_BYTES > MAXBUFBYTES (400)) \
? (REGISTER_BYTES * 2 + 32) \
: 400)
...
remote_write_size = PBUFSIZ;
...
/* Determine the max packet size. */
max_buf_size = min (remote_write_size, PBUFSIZ);
if (remote_register_buf_size != 0)
max_buf_size = min (max_buf_size, remote_register_buf_size);
buf = alloca (max_buf_size + 1);
From kevinb@cygnus.com Mon Nov 15 15:35:00 1999
From: Kevin Buettner <kevinb@cygnus.com>
To: Andrew Cagney <ac131313@cygnus.com>, Kevin Buettner <kevinb@cygnus.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: RFA: PACKET_OVERHEAD constant added to remote.c
Date: Mon, 15 Nov 1999 15:35:00 -0000
Message-id: <991115233403.ZM17177@ocotillo.lan>
References: <991112184146.ZM22052@ocotillo.lan> <38308EDB.A02AF873@cygnus.com> <ac131313@cygnus.com>
X-SW-Source: 1999-q4/msg00253.html
Content-length: 1945
On Nov 16, 9:53am, Andrew Cagney wrote:
> Kevin Buettner wrote:
> >
> > Hi Andrew,
> >
> > Jesper Skov alerted me to the fact that we were getting some "Remote
> > packet too long" messages when attempting to debug using a gdbserver
> > for i386 linux. The problem was that the memory packet size
> > computations were not taking into account the packet overhead. This
> > would've been a one line fix, but I decided to define PACKET_OVERHEAD
> > instead of adding another hard-coded instance of the constant 32.
>
> Keven,
>
> I'm puzzled. (I guess you mean one of the M or X packets?).
> I thought the function remote_write_bytes () was already taking care of
> the packet overhead. Can you expand a little on what exactly Jesper is
> seeing?
I was able to reproduce the problem as well. Here's what I was seeing
Sending packet: $m40013368,c8#cd...Ack
()Remote packet too long: 00000000870101401c990408883601400000000090...
In other words, gdb was asking gdbserver to send a packet that was
too large for gdb to deal with.
As far as remote_write_bytes() or remote_read_bytes() are concerned,
they get their packet sizes by calling get_memory_write_packet_size()
or get_memory_read_packet_size() which in turn determine the size by
calling get_memory_packet_size(). It is the latter function which
was returning too large a value. It is also in this function where
I chose to make an adjustment:
@@ -358,7 +363,7 @@
}
else
{
- what_they_get = remote_packet_size;
+ what_they_get = remote_packet_size - PACKET_OVERHEAD;
/* Limit the packet to the size specified by the user. */
if (config->size > 0
&& what_they_get > config->size)
Looking at it again, it occurs to me that it might be better to
subtract out PACKET_OVERHEAD on the expression in the return statement.
I.e, instead of
return what_they_get;
perhaps we want
return what_they_get - PACKET_OVERHEAD;
??
Kevin
From jimb@cygnus.com Mon Nov 15 16:05:00 1999
From: Jim Blandy <jimb@cygnus.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dj@delorie.com, gdb-patches@sourceware.cygnus.com
Subject: Re: i386: Are we settled?
Date: Mon, 15 Nov 1999 16:05:00 -0000
Message-id: <npr9hr712j.fsf@zwingli.cygnus.com>
References: <199911090018.TAA12933@zwingli.cygnus.com> <199911102234.RAA01359@mescaline.gnu.org>
X-SW-Source: 1999-q4/msg00254.html
Content-length: 10784
I've applied these. They only affect DJGPP files, so I've applied
them without testing them. Please let me know if you find any problems.
Thanks, Eli!
> These are the patches for go32-specific config files following the new
> tm-i386.h.
>
> --- gdb/config/i386/tm-go32.h~1 Wed Jul 7 20:13:00 1999
> +++ gdb/config/i386/tm-go32.h Wed Nov 10 18:08:46 1999
> @@ -18,108 +18,10 @@
> Foundation, Inc., 59 Temple Place - Suite 330,
> Boston, MA 02111-1307, USA. */
>
> -#include "i386/tm-i386v.h"
> +#undef HAVE_SSE_REGS /* FIXME! go32-nat.c needs to support XMMi registers */
> +#define HAVE_I387_REGS
>
> -/* Number of machine registers. */
> -
> -#undef NUM_FREGS
> -#define NUM_FREGS 15
> -#undef NUM_REGS
> -#define NUM_REGS (16+NUM_FREGS)
> -
> -/* Initializer for an array of names of registers. There should be
> - NUM_REGS strings in this initializer. */
> -
> -/* The order of the first 8 registers must match the compiler's
> - numbering scheme (which is the same as the 386 scheme). */
> -
> -#undef REGISTER_NAMES
> -#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \
> - "esp", "ebp", "esi", "edi", \
> - "eip", "eflags","cs", "ss", \
> - "ds", "es", "fs", "gs", \
> - "st0", "st1", "st2", "st3", \
> - "st4", "st5", "st6", "st7", \
> - "fctrl","fstat", "ftag", "fcs", \
> - "fopsel","fip", "fopoff" }
> -
> -#undef FP_REGNUM
> -#define FP_REGNUM 5 /* (ebp) Contains addr of stack frame */
> -#undef SP_REGNUM
> -#define SP_REGNUM 4 /* (usp) Contains address of top of stack */
> -#undef PS_REGNUM
> -#define PS_REGNUM 9 /* (ps) Contains processor status */
> -#undef PC_REGNUM
> -#define PC_REGNUM 8 /* (eip) Contains program counter */
> -#undef FP0_REGNUM
> -#define FP0_REGNUM 16 /* Floating point register 0 */
> -#undef FPC_REGNUM
> -#define FPC_REGNUM 24 /* 80387 control register */
> -#undef FPCWD_REGNUM
> -#define FPCWD_REGNUM FPC_REGNUM
> -#undef FPSWD_REGNUM
> -#define FPSWD_REGNUM 25 /* 80387 status register */
> -#undef FPTWD_REGNUM
> -#define FPTWD_REGNUM 26 /* 80387 tag register */
> -#undef FPIPO_REGNUM
> -#define FPIPO_REGNUM 29 /* 80387 instruction pointer offset reg */
> -#undef FPIPS_REGNUM
> -#define FPIPS_REGNUM 27 /* 80387 instruction pointer selector reg */
> -#undef FPOOS_REGNUM
> -#define FPOOS_REGNUM 30 /* 80387 operand pointer offset reg */
> -#undef FPOPS_REGNUM
> -#define FPOPS_REGNUM 28 /* 80387 operand pointer selector reg */
> -
> -/* Total amount of space needed to store our copies of the machine's
> - register state, the array `registers'. */
> -
> -#undef REGISTER_BYTES
> -#define REGISTER_BYTES (10*4 + 6*2 + 8*10 + 5*2 + 2*4)
> -
> -/* Index within `registers' of the first byte of the space for
> - register N. */
> -
> -#undef REGISTER_BYTE
> -#define REGBYTE_0 0
> -#define REGBYTE_10 (REGBYTE_0+10*4)
> -#define REGBYTE_16 (REGBYTE_10+6*2)
> -#define REGBYTE_24 (REGBYTE_16+8*10)
> -#define REGBYTE_29 (REGBYTE_24+5*2)
> -#define REGISTER_BYTE(N) (((N) < 10) ? (N) * 4 : \
> - (N) < 16 ? REGBYTE_10 +((N) - 10) * 2 : \
> - (N) < 24 ? REGBYTE_16 +((N) - 16) * 10 : \
> - (N) < 29 ? REGBYTE_24 +((N) - 24) * 2 : \
> - REGBYTE_29 + ((N) - 29) * 4)
> -
> -/* Number of bytes of storage in the actual machine representation
> - for register N. */
> -
> -#undef REGISTER_RAW_SIZE
> -#define REGISTER_RAW_SIZE(N) ((N) < 10 ? 4 : (N) < 16 ? 2 : (N) < 24 ? 10 : \
> - (N) < 29 ? 2 : 4)
> -
> -/* Number of bytes of storage in the program's representation
> - for register N. */
> -
> -#undef REGISTER_VIRTUAL_SIZE
> -#define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
> -
> -/* Largest value REGISTER_RAW_SIZE can have. */
> -
> -#undef MAX_REGISTER_RAW_SIZE
> -#define MAX_REGISTER_RAW_SIZE 10
> -
> -/* Largest value REGISTER_VIRTUAL_SIZE can have. */
> -
> -#undef MAX_REGISTER_VIRTUAL_SIZE
> -#define MAX_REGISTER_VIRTUAL_SIZE 10
> -
> -/* Nonzero if register N requires conversion
> - from raw format to virtual format. */
> -
> -#undef REGISTER_CONVERTIBLE
> -#define REGISTER_CONVERTIBLE(N) ((N) < FP0_REGNUM ? 0 :\
> - (N) < FPC_REGNUM ? 1 : 0)
> +#include "i386/tm-i386.h"
>
> /* The host and target are i386 machines and the compiler supports
> long doubles. Long doubles on the host therefore have the same
> @@ -142,70 +44,34 @@
>
> extern int i387_hex_long_double_input (char *p, long double *putithere);
>
> +#ifdef LD_I387 /* otherwise, definitions from tm-i386.h are good enough */
> +
> #undef REGISTER_CONVERT_TO_VIRTUAL
> -#ifdef LD_I387
> -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
> -{ \
> - if (TYPE == REGISTER_VIRTUAL_TYPE (REGNUM)) \
> - { \
> - memcpy (TO, FROM, TYPE_LENGTH (TYPE)); \
> - } \
> - else \
> - { \
> - long double val = *((long double *)FROM); \
> - store_floating ((TO), TYPE_LENGTH (TYPE), val); \
> - } \
> +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
> +{ \
> + long double val = *((long double *)(FROM)); \
> + store_floating ((TO), TYPE_LENGTH (TYPE), val); \
> }
> -#else
> -/* Convert data from raw format for register REGNUM in buffer FROM to
> - virtual format with type TYPE in buffer TO. */
> -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
> -{ \
> - double val; \
> - i387_to_double ((FROM), (char *)&val); \
> - store_floating ((TO), TYPE_LENGTH (TYPE), val); \
> -}
> -#endif
> -
> -extern void i387_to_double PARAMS ((char *, char *));
>
> #undef REGISTER_CONVERT_TO_RAW
> -#ifdef LD_I387
> -#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
> -{ \
> - if (TYPE == REGISTER_VIRTUAL_TYPE (REGNUM)) \
> - { \
> - memcpy (TO, FROM, TYPE_LENGTH (TYPE)); \
> - } \
> - else \
> - { \
> - long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
> - *((long double *)TO) = val; \
> - } \
> -}
> -#else
> -#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
> -{ \
> - double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
> - double_to_i387((char *)&val, (TO)); \
> +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
> +{ \
> + long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
> + *((long double *)(TO)) = val; \
> }
> -#endif
>
> -extern void double_to_i387 PARAMS ((char *, char *));
> +/* Return the GDB type object for the "standard" data type of data in
> + register N. Perhaps si and di should go here, but potentially they
> + could be used for things other than address. */
> +
> +#define REGISTER_VIRTUAL_TYPE(N) \
> + (((N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM) \
> + ? lookup_pointer_type (builtin_type_void) \
> + : IS_FP_REGNUM(N) ? builtin_type_long_double \
> + : IS_SSE_REGNUM(N) ? builtin_type_v4sf \
> + : builtin_type_int)
>
> -/* Return the GDB type object for the "standard" data type of data in
> - register N. */
> -
> -#undef REGISTER_VIRTUAL_TYPE
> -#ifdef LD_I387
> -#define REGISTER_VIRTUAL_TYPE(N) \
> - ((N < FP0_REGNUM) ? builtin_type_int : \
> - (N < FPC_REGNUM) ? builtin_type_long_double : builtin_type_int)
> -#else
> -#define REGISTER_VIRTUAL_TYPE(N) \
> - ((N < FP0_REGNUM) ? builtin_type_int : \
> - (N < FPC_REGNUM) ? builtin_type_double : builtin_type_int)
> -#endif
> +#endif /* LD_I387 */
>
> #undef TARGET_LONG_DOUBLE_BIT
> #define TARGET_LONG_DOUBLE_BIT 96
> --- gdb/config/i386/xm-go32.h~1 Mon Apr 26 18:26:22 1999
> +++ gdb/config/i386/xm-go32.h Wed Aug 18 08:30:52 1999
> @@ -25,7 +25,7 @@
>
> #define SLASH_P(X) ((X)=='\\' || (X) == '/')
>
> -#define ROOTED_P(X) ((SLASH_P((X)[0]))|| ((X)[1] ==':'))
> +#define ROOTED_P(X) ((SLASH_P((X)[0])) || ((X)[0] && (X)[1] ==':'))
>
> #define SLASH_CHAR '/'
> #define SLASH_STRING "/"
> --- gdb/config/i386/nm-go32.h~1 Sun Aug 8 12:41:38 1999
> +++ gdb/config/i386/nm-go32.h Sat Aug 14 14:59:08 1999
> @@ -24,8 +23,31 @@
>
> #define TARGET_HAS_HARDWARE_WATCHPOINTS
>
> +/* Returns the number of hardware watchpoints of type TYPE that we can
> + set. Value is positive if we can set CNT watchpoints, zero if
> + setting watchpoints of type TYPE is not supported, and negative if
> + CNT is more than the maximum number of watchpoints of type TYPE
> + that we can support. TYPE is one of bp_hardware_watchpoint,
> + bp_read_watchpoint, bp_write_watchpoint, or bp_hardware_breakpoint.
> + CNT is the number of such watchpoints used so far (including this
> + one). OTHERTYPE is non-zero if other types of watchpoints are
> + currently enabled.
> +
> + We always return 1 here because we don't have enough information
> + about possible overlap of addresses that they want to watch. As
> + an extreme example, consider the case where all the watchpoints
> + watch the same address and the same region length: then we can
> + handle a virtually unlimited number of watchpoints, due to debug
> + register sharing implemented via reference counts in go32-nat.c. */
> +
> #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) 1
>
> +/* Returns non-zero if we can use hardware watchpoints to watch a region
> + whose address is ADDR and whose length is LEN. */
> +
> +#define TARGET_REGION_OK_FOR_HW_WATCHPOINT(addr,len) \
> + go32_region_ok_for_watchpoint(addr,len)
> +
> /* After a watchpoint trap, the PC points to the instruction after the
> one that caused the trap. Therefore we don't need to step over it.
> But we do need to reset the status register to avoid another trap. */
> @@ -33,19 +55,22 @@
> #define HAVE_CONTINUABLE_WATCHPOINT
>
> #define STOPPED_BY_WATCHPOINT(W) \
> - go32_stopped_by_watchpoint (inferior_pid)
> + go32_stopped_by_watchpoint (inferior_pid, 0)
> +
> +#define target_stopped_data_address() \
> + go32_stopped_by_watchpoint (inferior_pid, 1)
>
> /* Use these macros for watchpoint insertion/removal. */
>
> #define target_insert_watchpoint(addr, len, type) \
> - go32_insert_watchpoint (inferior_pid, addr, len, 2)
> + go32_insert_watchpoint (inferior_pid, addr, len, type)
>
> #define target_remove_watchpoint(addr, len, type) \
> - go32_remove_watchpoint (inferior_pid, addr, len)
> + go32_remove_watchpoint (inferior_pid, addr, len, type)
>
> #define target_insert_hw_breakpoint(addr, shadow) \
> go32_insert_hw_breakpoint(addr, shadow)
> -
> +
> #define target_remove_hw_breakpoint(addr, shadow) \
> go32_remove_hw_breakpoint(addr, shadow)
>
> @@ -55,3 +80,4 @@
> #define FLOAT_INFO { i386_go32_float_info (); }
>
> extern void i386_go32_float_info (void);
> +
>
From jimb@cygnus.com Mon Nov 15 16:06:00 1999
From: Jim Blandy <jimb@cygnus.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: ezannoni@cygnus.com, dj@delorie.com, muller@cerbere.u-strasbg.fr, shebs@cygnus.com, gdb-patches@sourceware.cygnus.com
Subject: Re: go32-nat.c compilation problem
Date: Mon, 15 Nov 1999 16:06:00 -0000
Message-id: <nppuxb711c.fsf@zwingli.cygnus.com>
References: <199911081709.SAA23904@cerbere.u-strasbg.fr> <14375.536.118347.328812@kwikemart.cygnus.com> <199911081742.MAA20623@mescaline.gnu.org> <14375.5038.377535.816858@kwikemart.cygnus.com> <199911102250.RAA01938@mescaline.gnu.org>
X-SW-Source: 1999-q4/msg00255.html
Content-length: 2948
I've applied this patch. Since it only affects DJGPP files, I didn't
test them. Thanks again!
> > Fatal() was deleted, and then changes to go32-nat.c were made that
> > reintroduced calls to fatal(). I believe the changes were part of a patch
> > you submitted, *before* the function fatal was replaced by internal_error().
>
> Here are the diffs for go32-nat.c that should fix this.
>
> 1999-11-10 Eli Zaretskii <eliz@is.elta.co.il>
>
> * go32-nat.c (go32_fetch_registers, store_register)
> (go32_create_inferior, init_go32_ops): Replace fatal with
> internal_error.
> (sig_map): Map exception 7 to TARGET_SIGNAL_EMT.
>
>
> --- gdb/go32-nat.c~1 Wed Oct 13 13:39:00 1999
> +++ gdb/go32-nat.c Wed Nov 10 16:49:06 1999
> @@ -345,7 +345,7 @@ sig_map[] =
> 4, TARGET_SIGNAL_FPE,
> 5, TARGET_SIGNAL_SEGV,
> 6, TARGET_SIGNAL_ILL,
> - 7, TARGET_SIGNAL_FPE,
> + 7, TARGET_SIGNAL_EMT, /* no-coprocessor exception */
> 8, TARGET_SIGNAL_SEGV,
> 9, TARGET_SIGNAL_SEGV,
> 10, TARGET_SIGNAL_BUS,
> @@ -570,7 +570,8 @@ go32_fetch_registers (int regno)
> supply_register (regno,
> (char *) &npx + regno_mapping[regno].tss_ofs);
> else
> - fatal ("Invalid register no. %d in go32_fetch_register.", regno);
> + internal_error ("Invalid register no. %d in go32_fetch_register.",
> + regno);
> }
> }
>
> @@ -587,7 +588,7 @@ store_register (int regno)
> else if (regno < 31)
> rp = (char *) &npx + regno_mapping[regno].tss_ofs;
> else
> - fatal ("Invalid register no. %d in store_register.", regno);
> + internal_error ("Invalid register no. %d in store_register.", regno);
> memcpy (rp, v, regno_mapping[regno].size);
> }
>
> @@ -680,7 +681,7 @@ go32_create_inferior (char *exec_file, c
> resume_is_step = 0;
> /* Init command line storage. */
> if (redir_debug_init (&child_cmd) == -1)
> - fatal ("Cannot allocate redirection storage: not enough memory.\n");
> + internal_error ("Cannot allocate redirection storage: not enough memory.\n");
>
> /* Parse the command line and create redirections. */
> if (strpbrk (args, "<>"))
> @@ -1311,7 +1312,7 @@ init_go32_ops (void)
>
> /* Initialize child's command line storage. */
> if (redir_debug_init (&child_cmd) == -1)
> - fatal ("Cannot allocate redirection storage: not enough memory.\n");
> + internal_error ("Cannot allocate redirection storage: not enough memory.\n");
> }
>
> void
> --- gdb/utils.c~1 Wed Nov 10 12:58:14 1999
> +++ gdb/utils.c Wed Nov 10 16:51:24 1999
> @@ -787,7 +787,7 @@ notice_quit ()
> immediate_quit = 1;
> }
>
> -#else /* !defined(__GO32__) && !defined(_MSC_VER) */
> +#else /* !defined(_MSC_VER) */
>
> void
> notice_quit ()
> @@ -795,7 +795,7 @@ notice_quit ()
> /* Done by signals */
> }
>
> -#endif /* !defined(__GO32__) && !defined(_MSC_VER) */
> +#endif /* !defined(_MSC_VER) */
>
> /* Control C comes here */
> void
>
From ac131313@cygnus.com Mon Nov 15 17:40:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Jimmy Guo <guo@cup.hp.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: (patch) hpjyg23: gdbtypes.[ch] & values.c
Date: Mon, 15 Nov 1999 17:40:00 -0000
Message-id: <3830B4FA.95EB76A4@cygnus.com>
References: <Pine.LNX.4.10.9911121213280.2889-100000@hpcll168.cup.hp.com>
X-SW-Source: 1999-q4/msg00256.html
Content-length: 3291
Jimmy Guo wrote:
>
> ***
> Patch dependency: hpjyg11 (gdbtypes.h)
> ***
>
> This patch covers misc. fixes to gdbtypes.c and values.c, and introduces
> builtin_type_CORE_ADDR (for 32x64 fix) as well as is_float_type.
>
> ChangeLog:
>
> 1999-11-12 Jimmy Guo <guo@cup.hp.com>
>
> * gdbtypes.c: Misc. fixes and builtin_type_CORE_ADDR support.
> (rank_one_type): return INTEGER_PROMOTION_BADNESS if parm is of
> TYPE_CODE_ENUM, arg is of a compatible type, but TYPE_LENGTH
> (arg) <= TYPE_LENGTH (parm); when both parm and arg are of
> TYPE_CODE_STRUCT, return 0 if the tag names are the same (for
> same type in different shared libraries), same for
> TYPE_CODE_UNION.
> (build_gdbtypes): init builtin_type_CORE_ADDR to
> builtin_type_unsigned_long_long (64bit) or
> builtin_type_unsigned_long (32bit).
> (is_float_type): New function.
>
> * gdbtypes.h: Misc. fixes and builtin_type_CORE_ADDR support.
> (TYPE_IS_OPAQUE): include TYPE_CODE_TEMPLATE too.
> (builtin_type_CORE_ADDR): Declare.
> (builtin_type_f_integer_s2,builtin_type_f_integer_s8,
> builtin_type_f_logical_s8): Declare, for Fortran support.
> (is_float_type): Declare.
>
> * values.c: Misc. 32x64 fixes.
> +
> + #ifdef BFD64
> + builtin_type_CORE_ADDR = builtin_type_unsigned_long_long;
> + #else
> + builtin_type_CORE_ADDR = builtin_type_unsigned_long;
> + #endif
Can you expand a little - looks like there isn't a builtin_type_* for
pointer :-( That makes makes the introduction of a builtin_type for
target pointers a pretty good idea.
BFD64: I'm not sure this is the right test. Should some characteristic
of the ABFD be tested instead?
I suspect that builtin_type_uint{32,64} would be safer. There are
machines with 64 bit longs :-)
***************
*** 955,964 ****
* the beginning of the vtable; but first we have to adjust
* by HP_ACC_VFUNC_START to account for other entries */
! /* pai: FIXME: 32x64 problem here, a word may be 8 bytes in
! * which case the multiplier should be 8 and values should be
long */
! vp = value_at (builtin_type_int,
! coreptr + 4 * (TYPE_FN_FIELD_VOFFSET (f, j) +
HP_ACC_VFUNC_START), NULL);
coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
/* coreptr now contains the address of the virtual function */
--- 954,965 ----
* the beginning of the vtable; but first we have to adjust
* by HP_ACC_VFUNC_START to account for other entries */
! vp = value_at (builtin_type_CORE_ADDR,
! coreptr +
! sizeof (CORE_ADDR) *
! (TYPE_FN_FIELD_VOFFSET (f, j) +
! HP_ACC_VFUNC_START),
! NULL);
coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
/* coreptr now contains the address of the virtual function */
FYI, you can't trust sizeof (CORE_ADDR). CORE_ADDR is a type that is
large enough to fit a target pointer. Often it is larger. Generally
code uses TARGET_PTR_BIT (?), with builtin_type_CORE_ADDR perhaphs an
attribute of that can be used.
enjoy,
Andrew
From ac131313@cygnus.com Mon Nov 15 17:52:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Jimmy Guo <guo@cup.hp.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: (patch) hpjyg22: misc. 32x64 and minor changes
Date: Mon, 15 Nov 1999 17:52:00 -0000
Message-id: <3830B817.25E7D7D9@cygnus.com>
References: <Pine.LNX.4.10.9911111411150.6005-100000@hpcll168.cup.hp.com>
X-SW-Source: 1999-q4/msg00257.html
Content-length: 2135
Jimmy Guo wrote:
>
> This patch contains some 32x64 fixes and minor changes. See ChangeLog:
>
> 1999-11-11 Jimmy Guo <guo@cup.hp.com>
>
> * solib.c,osfsolib.c,irix5-nat.c: Change error string from
> 'No exec file' to 'No executable file'.
>
> * solib.c (info_sharedlibrary_command): 32x64 fix.
>
> * m2-exp.y (lex): add default case statement to capture
> unhandled token and call error().
> ***************
> *** 1301,1312 ****
> header_done++;
> }
>
> ! printf_unfiltered ("%-*s", addr_width,
> ! local_hex_string_custom ((unsigned long) LM_ADDR (so),
> ! addr_fmt));
> ! printf_unfiltered ("%-*s", addr_width,
> ! local_hex_string_custom ((unsigned long) so->lmend,
> ! addr_fmt));
> printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
> printf_unfiltered ("%s\n", so->so_name);
> }
> --- 1301,1312 ----
> header_done++;
> }
>
> ! printf_unfiltered ("%-12s",
> ! longest_local_hex_string_custom ((LONGEST) LM_ADDR (so),
> ! "08l"));
> ! printf_unfiltered ("%-12s",
> ! longest_local_hex_string_custom ((LONGEST) so->lmend,
> ! "08l"));
> printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
> printf_unfiltered ("%s\n", so->so_name);
> }
FYI, I'm not sure about this. Hardwiring ``08l'' looks dangerous.
Perhaps paddr() should be used - that returns a string based on
TARGET_PTR_BIT. Hmm, here thougy, you're manipulating values from the
ELF object file format )??). Perhaphs something object-file related is
needed? Also, there are at least systems with elf32 object files but
TARGET_PTR_BIT=64.
Hmm, to step back, I'm not sure what the problem that has occured is.
Could you please expand a little.
best regards,
Andrew
From ac131313@cygnus.com Mon Nov 15 18:21:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Kevin Buettner <kevinb@cygnus.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: RFA: PACKET_OVERHEAD constant added to remote.c
Date: Mon, 15 Nov 1999 18:21:00 -0000
Message-id: <3830BF79.F43EEE0A@cygnus.com>
References: <991112184146.ZM22052@ocotillo.lan> <38308EDB.A02AF873@cygnus.com> <991115233403.ZM17177@ocotillo.lan>
X-SW-Source: 1999-q4/msg00258.html
Content-length: 2546
Kevin Buettner wrote:
> > I'm puzzled. (I guess you mean one of the M or X packets?).
> > I thought the function remote_write_bytes () was already taking care of
> > the packet overhead. Can you expand a little on what exactly Jesper is
> > seeing?
>
> I was able to reproduce the problem as well. Here's what I was seeing
>
> Sending packet: $m40013368,c8#cd...Ack
>
> ()Remote packet too long: 00000000870101401c990408883601400000000090...
> In other words, gdb was asking gdbserver to send a packet that was
> too large for gdb to deal with.
>
> As far as remote_write_bytes() or remote_read_bytes() are concerned,
> they get their packet sizes by calling get_memory_write_packet_size()
> or get_memory_read_packet_size() which in turn determine the size by
> calling get_memory_packet_size(). It is the latter function which
> was returning too large a value. It is also in this function where
> I chose to make an adjustment:
Yes. I'm just trying to understand if this is a recently introduced bug
(by me) or has always been in there. (In particular prior to the change
to remote.c below).
For what it's worth, there is a nasty overflow bug to do with
remote_read_bytes() - it stuffs up the buffer allocation. Ulgh. Better
fix that one.
Andrew
Thu Nov 4 11:59:24 1999 Andrew Cagney <cagney@b1.cygnus.com>
* remote.c (get_memory_packet_size, set_memory_packet_size,
build_memory_packet_size): New functions. Set / compute / update
the size of a memory read / write packet.
(set_memory_read_packet_size, set_memory_write_packet_size): New
functions. Verify changes to the memory read / write packet
size.
(prefered_memory_write_packet_size,
current_memory_write_packet_size,
prefered_memory_read_packet_size,
current_memory_read_packet_size): New variables.
(get_memory_read_packet_size, get_memory_write_packet_size): New
functions. Determine the current memory read/write packet size.
A
function is needed as ``current_register_packet_size'', a
variable
is used in the calculation.
(register_remote_packet_sizes, build_remote_packet_sizes):
Initialize packet sizes according the current architecture.
(remote_fetch_registers, remote_write_bytes, remote_read_bytes,
build_remote_gdbarch_data): Update.
(_initialize_remote): Add the commands ``set remote
memory-read-packet-size'' and ``set remote
memory-write-packet-size''. Deprecate ``set remotepacketsize''.
From kevinb@cygnus.com Mon Nov 15 20:13:00 1999
From: Kevin Buettner <kevinb@cygnus.com>
To: Andrew Cagney <ac131313@cygnus.com>, Kevin Buettner <kevinb@cygnus.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: RFA: PACKET_OVERHEAD constant added to remote.c
Date: Mon, 15 Nov 1999 20:13:00 -0000
Message-id: <991116041240.ZM24569@ocotillo.lan>
References: <991112184146.ZM22052@ocotillo.lan> <38308EDB.A02AF873@cygnus.com> <991115233403.ZM17177@ocotillo.lan> <3830BF79.F43EEE0A@cygnus.com> <ac131313@cygnus.com>
X-SW-Source: 1999-q4/msg00259.html
Content-length: 2505
On Nov 16, 1:20pm, Andrew Cagney wrote:
> > As far as remote_write_bytes() or remote_read_bytes() are concerned,
> > they get their packet sizes by calling get_memory_write_packet_size()
> > or get_memory_read_packet_size() which in turn determine the size by
> > calling get_memory_packet_size(). It is the latter function which
> > was returning too large a value. It is also in this function where
> > I chose to make an adjustment:
>
> Yes. I'm just trying to understand if this is a recently introduced bug
> (by me) or has always been in there. (In particular prior to the change
> to remote.c below).
Unclear. I was able to use an x86 linux gdbserver with gdb prior to
your change below (without seeing the buffer overflow problem). I
don't whether it was your change which caused the breakage or something
else.
Let me know if you'd like me to pursue this; I could do an update
to Nov 3 and see if the problem still exists...
> For what it's worth, there is a nasty overflow bug to do with
> remote_read_bytes() - it stuffs up the buffer allocation. Ulgh. Better
> fix that one.
Yes. I saw your comment in get_memory_read_packet_size().
> Andrew
>
>
> Thu Nov 4 11:59:24 1999 Andrew Cagney <cagney@b1.cygnus.com>
>
> * remote.c (get_memory_packet_size, set_memory_packet_size,
> build_memory_packet_size): New functions. Set / compute / update
> the size of a memory read / write packet.
> (set_memory_read_packet_size, set_memory_write_packet_size): New
> functions. Verify changes to the memory read / write packet
> size.
> (prefered_memory_write_packet_size,
> current_memory_write_packet_size,
> prefered_memory_read_packet_size,
> current_memory_read_packet_size): New variables.
> (get_memory_read_packet_size, get_memory_write_packet_size): New
> functions. Determine the current memory read/write packet size.
> A
> function is needed as ``current_register_packet_size'', a
> variable
> is used in the calculation.
> (register_remote_packet_sizes, build_remote_packet_sizes):
> Initialize packet sizes according the current architecture.
> (remote_fetch_registers, remote_write_bytes, remote_read_bytes,
> build_remote_gdbarch_data): Update.
> (_initialize_remote): Add the commands ``set remote
> memory-read-packet-size'' and ``set remote
> memory-write-packet-size''. Deprecate ``set remotepacketsize''.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-11-13 10:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-13 10:18 Patch for new i386 `info float' command Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox