Article View: gnu.gdb.bug
Article #10070Patches for gdb-3.90.11.
From: bothner
Date: Mon, 09 Jul 1990 23:40
Date: Mon, 09 Jul 1990 23:40
527 lines
17584 bytes
17584 bytes
Below are a number of patches relative to gdb-3.90.11. Some were
needed to make 3.90.11 work at all, but most are attempts to
improve the c++ support, including slightly better support
for multiple inheritance. (These might be useful for gdb-3.5 as well.)
--Per Bothner
bothner@cs.wisc.edu Computer Sciences Dept, U. of Wisconsin-Madison
dbxread.c:
Calling make_cleanup (free, *stringtab) loses when stringtab
is the global stringtab. It gets freed when it shouldn't.
And add_file seems to free it when it should be.
Try to allow non-zero basetype offset. (However, g++ currently
emits wrong value. Bug report has been sent to bug-g++.)
symtab.c:
Remove error message.
Don't look for methods in baseclasses if a match has been found.
This avoids most of the annoying menues that ask the user
to disambiguate forms like "class::method" that aren't
ambiguous in the first place.
Made decode_line_2 skip function prologues correctly.
valprint.c:
Print base class fields properly, and less verbosely.
Don't print static members.
Made some while loops (e.g. while (*name != ' ') name++;) more robust.
These incorrectly assumed that class type were of the form "struct T".
In type_print_derivation_info, merged some duplicate code.
value.h:
Added declaration of new routine value_primitive_field.
values.c:
Added value_primitive_field which is generalized version of
value_field that can handle multiple inheritance (non-zero offsets etc).
Re-implemented value_field to call value_primitive_field.
xm-news.h:
REGISTER_U_ADDR was wrong for the PC register, which meant that nothing
worked. Re-wrote it to use a table lookup.
*** dbxread.c.orig Thu May 24 15:37:14 1990
--- dbxread.c Mon Jul 9 18:15:35 1990
***************
*** 1598,1607 ****
perror_with_name (name);
READ_STRING_TABLE_SIZE (*stringtab_size);
if (*stringtab_size >= 0 && *stringtab_size < statbuf.st_size)
! {
! *stringtab = (char *) xmalloc (*stringtab_size);
! make_cleanup (free, *stringtab);
! }
else
*stringtab = NULL;
if (*stringtab == NULL)
--- 1598,1604 ----
perror_with_name (name);
READ_STRING_TABLE_SIZE (*stringtab_size);
if (*stringtab_size >= 0 && *stringtab_size < statbuf.st_size)
! *stringtab = (char *) xmalloc (*stringtab_size);
else
*stringtab = NULL;
if (*stringtab == NULL)
***************
*** 4492,4498 ****
"\nWarning: GDB has limited understanding of multiple inheritance...");
error_printed = 1;
}
! offset = 0;
}
baseclass_vec[i] = lookup_basetype_type (baseclass, offset, via_virtual, via_public);
--- 4489,4499 ----
"\nWarning: GDB has limited understanding of multiple inheritance...");
error_printed = 1;
}
! /* The following statement should be removed as soon as g++ has
! * been fixed. It is a hack to allow testing of the case
! * for two baseclasses, the first of which is abstract,
! * and therefore is 4 bytes long (for the vtable). */
! offset = 4*8; /* hack! */
}
baseclass_vec[i] = lookup_basetype_type (baseclass, offset, via_virtual, via_public);
*** symtab.c.orig Fri Apr 6 01:19:56 1990
--- symtab.c Mon Jul 9 18:25:29 1990
***************
*** 566,572 ****
if (offset != 0)
{
! printf ("Internal error: type offset non-zero in lookup_basetype_type");
offset = 0;
}
--- 566,572 ----
if (offset != 0)
{
! /* printf ("Internal error: type offset non-zero in lookup_basetype_type");*/
offset = 0;
}
***************
*** 1693,1699 ****
}
}
}
! if (TYPE_N_BASECLASSES (t))
t = TYPE_BASECLASS(t, 1);
else
break;
--- 1693,1707 ----
}
}
}
! /* Methods that have been shadowed should not be
! * presented to the user. An approximation of this
! * behavior is to stop searching in baseclass
! * if a match has been found (i.e. when i1 > 0).
! * This isn't quite right, but the user will
! * seldom ask for methods in baseclasses anyway
! * (since naming the specific class containing a method
! * is most natural). */
! if (i1 == 0 && TYPE_N_BASECLASSES (t))
t = TYPE_BASECLASS(t, 1);
else
break;
***************
*** 1955,1960 ****
--- 1963,1969 ----
if (funfirstline)
SKIP_PROLOGUE (pc);
values.sals[i] = find_pc_line (pc, 0);
+ values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ? values.sals[i].end : pc;
printf("[%d] file:%s; line number:%d\n",
(i+2), values.sals[i].symtab->filename, values.sals[i].line);
}
*** valprint.c.orig Wed May 2 00:30:19 1990
--- valprint.c Mon Jul 9 15:30:38 1990
***************
*** 710,741 ****
fprintf_filtered (stream, "{");
len = TYPE_NFIELDS (type);
n_baseclasses = TYPE_N_BASECLASSES (type);
! for (i = 1; i <= n_baseclasses; i++)
{
fprintf_filtered (stream, "\n");
if (pretty)
print_spaces_filtered (2 + 2 * recurse, stream);
fputs_filtered ("<", stream);
! fputs_filtered (TYPE_NAME (TYPE_BASECLASS (type, i)), stream);
fputs_filtered ("> = ", stream);
! val_print (TYPE_FIELD_TYPE (type, 0),
! valaddr + TYPE_FIELD_BITPOS (type, i-1) / 8,
0, stream, 0, 0, recurse + 1, pretty);
}
! if (i > 1) {
! fprintf_filtered (stream, "\n");
! print_spaces_filtered (2 + 2 * recurse, stream);
! fputs_filtered ("members of ", stream);
! fputs_filtered (TYPE_NAME (type), stream);
! fputs_filtered (": ", stream);
! }
! if (!len && i == 1)
fprintf_filtered (stream, "<No data fields>");
else
{
! for (i -= 1; i < len; i++)
{
! if (i > n_baseclasses) fprintf_filtered (stream, ", ");
if (pretty)
{
fprintf_filtered (stream, "\n");
--- 710,746 ----
fprintf_filtered (stream, "{");
len = TYPE_NFIELDS (type);
n_baseclasses = TYPE_N_BASECLASSES (type);
! for (i = 0; i < n_baseclasses; i++)
{
fprintf_filtered (stream, "\n");
if (pretty)
print_spaces_filtered (2 + 2 * recurse, stream);
fputs_filtered ("<", stream);
! fputs_filtered (TYPE_NAME (TYPE_BASECLASS (type, i+1)), stream);
fputs_filtered ("> = ", stream);
! val_print (TYPE_FIELD_TYPE (type, i),
! valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
0, stream, 0, 0, recurse + 1, pretty);
}
! if (!len && i == 0)
fprintf_filtered (stream, "<No data fields>");
else
{
! int fields_seen = 0;
! for (; i < len; i++)
{
! /* check if static field */
! if (TYPE_FIELD_STATIC (type, i))
! continue;
! if (fields_seen) fprintf_filtered (stream, ", ");
! else if (n_baseclasses > 0) {
! fprintf_filtered (stream, "\n");
! print_spaces_filtered (2 + 2 * recurse, stream);
! fputs_filtered ("members of ", stream);
! fputs_filtered (TYPE_NAME (type), stream);
! fputs_filtered (": ", stream);
! }
! fields_seen = 1;
if (pretty)
{
fprintf_filtered (stream, "\n");
***************
*** 743,760 ****
}
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
fputs_filtered (" = ", stream);
! /* check if static field */
! if (TYPE_FIELD_STATIC (type, i))
{
- value v;
-
- v = value_static_field (type, TYPE_FIELD_NAME (type, i), i);
- val_print (TYPE_FIELD_TYPE (type, i),
- VALUE_CONTENTS (v), 0, stream, format,
- deref_ref, recurse + 1, pretty);
- }
- else if (TYPE_FIELD_PACKED (type, i))
- {
char *valp = (char *) & val;
union {int i; char c;} test;
test.i = 1;
--- 748,755 ----
}
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
fputs_filtered (" = ", stream);
! if (TYPE_FIELD_PACKED (type, i))
{
char *valp = (char *) & val;
union {int i; char c;} test;
test.i = 1;
***************
*** 1024,1067 ****
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
struct type *basetype = 0;
! while (type && n_baseclasses == 1)
{
/* Not actually sure about this one -- Bryan. */
check_stub_type (type);
! basetype = TYPE_BASECLASS (type, 1);
! if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype)))
! {
! while (*name != ' ') name++;
! fprintf_filtered (stream, ": %s%s ",
! TYPE_VIA_PUBLIC (basetype) ? "public" : "private",
! TYPE_VIA_VIRTUAL (basetype) ? " virtual" : "");
! fputs_filtered (name + 1, stream);
! fputs_filtered (" ", stream);
! }
! n_baseclasses = TYPE_N_BASECLASSES (basetype);
! type = basetype;
! }
!
! if (type)
! {
! if (n_baseclasses != 0)
! fprintf_filtered (stream, ": ");
for (i = 1; i <= n_baseclasses; i++)
{
basetype = TYPE_BASECLASS (type, i);
if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype)))
{
! while (*name != ' ') name++;
fprintf_filtered (stream, "%s%s ",
TYPE_VIA_PUBLIC (basetype) ? "public" : "private",
TYPE_VIA_VIRTUAL (basetype) ? " virtual" : "");
! fputs_filtered (name + 1, stream);
}
if (i < n_baseclasses)
fprintf_filtered (stream, ", ");
}
fprintf_filtered (stream, " ");
}
}
--- 1019,1051 ----
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
struct type *basetype = 0;
! while (type && n_baseclasses > 0)
{
/* Not actually sure about this one -- Bryan. */
check_stub_type (type);
! fprintf_filtered (stream, ": ");
for (i = 1; i <= n_baseclasses; i++)
{
basetype = TYPE_BASECLASS (type, i);
if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype)))
{
! for ( ; ; name++)
! if (*name == '\0') { name = TYPE_NAME (basetype); break; }
! else if (*name == ' ') { name++; break; }
fprintf_filtered (stream, "%s%s ",
TYPE_VIA_PUBLIC (basetype) ? "public" : "private",
TYPE_VIA_VIRTUAL (basetype) ? " virtual" : "");
! fputs_filtered (name, stream);
}
if (i < n_baseclasses)
fprintf_filtered (stream, ", ");
}
+
fprintf_filtered (stream, " ");
+ if (n_baseclasses != 1) break;
+ n_baseclasses = TYPE_N_BASECLASSES (basetype);
+ type = basetype;
}
}
***************
*** 1276,1285 ****
case TYPE_CODE_UNION:
fprintf_filtered (stream, "union ");
struct_union:
! if (TYPE_NAME (type) && (name = TYPE_NAME (type)))
{
! while (*name != ' ') name++;
! fputs_filtered (name + 1, stream);
fputs_filtered (" ", stream);
}
if (show < 0)
--- 1260,1271 ----
case TYPE_CODE_UNION:
fprintf_filtered (stream, "union ");
struct_union:
! if ((name = TYPE_NAME (type)) != NULL)
{
! for (;; name++)
! if (*name == ' ') { name++; break; }
! else if (*name == '\0') { name = TYPE_NAME (type); break; }
! fputs_filtered (name, stream);
fputs_filtered (" ", stream);
}
if (show < 0)
***************
*** 1366,1372 ****
fprintf_filtered (stream, ";\n");
}
- if (len2) fprintf_filtered (stream, "\n");
}
print_spaces_filtered (level, stream);
--- 1352,1357 ----
*** value.h.orig Wed May 2 00:27:10 1990
--- value.h Mon Jul 9 14:58:03 1990
***************
*** 193,199 ****
value value_neg ();
value value_lognot ();
value value_struct_elt (), value_struct_elt_for_address ();
! value value_field ();
value value_cast ();
value value_zero ();
value value_repeat ();
--- 193,199 ----
value value_neg ();
value value_lognot ();
value value_struct_elt (), value_struct_elt_for_address ();
! value value_field (), value_primitive_field();
value value_cast ();
value value_zero ();
value value_repeat ();
*** values.c.orig Mon May 21 19:31:56 1990
--- values.c Mon Jul 9 14:23:01 1990
***************
*** 723,729 ****
return (double) 0; /* To silence compiler warning. */
}
! /* Given a value ARG1 of a struct or union type,
extract and return the value of one of its fields.
FIELDNO says which field.
--- 723,730 ----
return (double) 0; /* To silence compiler warning. */
}
! /* Given a value ARG1 (offset by OFFSET bytes)
! of a struct or union type ARG_TYPE,
extract and return the value of one of its fields.
FIELDNO says which field.
***************
*** 730,754 ****
For C++, must also be able to return values from static fields */
value
! value_field (arg1, fieldno)
register value arg1;
register int fieldno;
{
register value v;
! register struct type *type = TYPE_FIELD_TYPE (VALUE_TYPE (arg1), fieldno);
! register int offset;
/* Handle packed fields */
! offset = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) / 8;
if (TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno))
{
v = value_from_long (type,
! unpack_field_as_long (VALUE_TYPE (arg1),
VALUE_CONTENTS (arg1),
fieldno));
! VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) % 8;
! VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno);
}
else
{
--- 731,755 ----
For C++, must also be able to return values from static fields */
value
! value_primitive_field (arg1, offset, fieldno, arg_type)
register value arg1;
register int fieldno;
+ register struct type *arg_type;
{
register value v;
! register struct type *type = TYPE_FIELD_TYPE (arg_type, fieldno);
/* Handle packed fields */
! offset += TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
if (TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno))
{
v = value_from_long (type,
! unpack_field_as_long (arg_type,
VALUE_CONTENTS (arg1),
fieldno));
! VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (arg_type, fieldno) % 8;
! VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (arg_type, fieldno);
}
else
{
***************
*** 766,771 ****
--- 767,786 ----
VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1);
VALUE_OFFSET (v) = offset + VALUE_OFFSET (arg1);
return v;
+ }
+
+ /* Given a value ARG1 of a struct or union type,
+ extract and return the value of one of its fields.
+ FIELDNO says which field.
+
+ For C++, must also be able to return values from static fields */
+
+ value
+ value_field (arg1, fieldno)
+ register value arg1;
+ register int fieldno;
+ {
+ return value_primitive_field (arg1, 0, VALUE_TYPE (arg1), fieldno);
}
value
*** xm-news.h.orig Wed Apr 4 15:09:56 1990
--- xm-news.h Mon Jul 9 18:12:31 1990
***************
*** 34,68 ****
#define KERNEL_U_ADDR UADDR
! #ifdef USE_PCB
#define REGISTER_U_ADDR(addr, blockend, regno) \
! { blockend += 4; /* why? */ \
! if (regno <= FP_REGNUM) \
! addr = blockend + regno * 4; \
! else if (regno == SP_REGNUM) \
! addr = blockend - 4 - 4 * 4; \
! else if (regno <= PS_REGNUM) \
! addr = blockend - 4 + (regno - PS_REGNUM) * 4; \
! else if (regno < FPC_REGNUM) \
! addr = blockend + (14 + 1 + 3) * 4 + (regno - FP0_REGNUM) * 12; \
! else \
! addr = blockend + 15 * 4 + (regno - FPC_REGNUM) * 4; \
}
- #else
- #define REGISTER_U_ADDR(addr, blockend, regno) \
- { blockend += 4; /* why? */ \
- if (regno <= FP_REGNUM) \
- addr = blockend + regno * 4; \
- else if (regno == SP_REGNUM) \
- addr = blockend -4 - 4 * 4; \
- else if (regno <= PS_REGNUM) \
- addr = blockend - 4 + (regno - PS_REGNUM) * 4; \
- else if (regno < FPC_REGNUM) \
- addr = blockend + (14 + 1 + 3) * 4 + (regno - FP0_REGNUM) * 12; \
- else \
- addr = blockend + 15 * 4 + (regno - FPC_REGNUM) * 4; \
- }
- #endif
/* Compensate for lack of `vprintf' function. */
#ifndef HAVE_VPRINTF
--- 34,48 ----
#define KERNEL_U_ADDR UADDR
! /* The offsets in this macro are from /usr/include/machine/reg.h */
!
#define REGISTER_U_ADDR(addr, blockend, regno) \
! { static char offsets[] = { \
! /*d0-d7:*/1,2,3,4,5,6,7,8, \
! /*a0-a6:*/9,10,11,12,13,14,15, /*sp:*/-4, /*ps:*/0, /*pc:*/-1, \
! /*fp0-fp7:*/19,22,25,28,31,34,37,40, /*fpc:*/16,17,18 }; \
! addr = blockend + 4 * offsets[regno]; \
}
/* Compensate for lack of `vprintf' function. */
#ifndef HAVE_VPRINTF
Technical Details
Message-ID:
<9007092340.AA12156@sevenlayer.cs.wisc.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!CS.WISC.EDU!bothnerShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,6cce3776e0c419e3,start X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 1990-07-09 16:40:07 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!CS.WISC.EDU!bothner From: bothner@CS.WISC.EDU Newsgroups: gnu.gdb.bug Subject: Patches for gdb-3.90.11. Message-ID: <9007092340.AA12156@sevenlayer.cs.wisc.edu> Date: 9 Jul 90 23:40:07 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 527 Posted: Tue Jul 10 00:40:07 1990