aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/ch-exp.y75
-rw-r--r--gdb/ch-typeprint.c77
-rw-r--r--gdb/ch-valprint.c55
-rw-r--r--gdb/stabsread.c32
5 files changed, 152 insertions, 104 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 07d2d34..0040362 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,20 @@
+Tue Apr 6 00:24:32 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * ch-exp.y: Remove ambiguities. Fix or add support for
+ UNOP_IND, UNOP_CAST, UNOP_ADDR, STRUCOP_STRUCT, OP_TYPE.
+ * ch-typeprint.c (chill_print_type): Move support
+ for TYPE_CODE_ARRAY and TYPE_CODE_STRING from here ...
+ * ch-typeprint.c (chill_type_print_base): ... here.
+ * ch-typeprint.c (chill_type_print_base): Improve
+ support for PTR, REF, and FUNC types.
+ * ch-valprint.c: Prefer H'%x format to 0x%s.
+ * ch-valprint.c (chill_val_print): Add support for printing
+ TYPE_CODE_REF (return for LOC parameters and variables).
+ Use c_val_print to print random types (including ENUM).
+ * ch-valprint,c (chill_print_value_fields): Make
+ output look more like Chill tuples.
+ * stabsread.c (read_struct_type): Factor common code.
+
Wed Apr 7 11:22:43 1993 Fred Fish (fnf@cygnus.com)
* sparclite/Makefile.in: Add dummy mostlyclean, clean,
diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y
index 0a2efd1..6788b55 100644
--- a/gdb/ch-exp.y
+++ b/gdb/ch-exp.y
@@ -181,6 +181,8 @@ yyerror PARAMS ((char *));
%token <voidval> EMPTINESS_LITERAL
%token <sval> CHARACTER_STRING_LITERAL
%token <sval> BIT_STRING_LITERAL
+%token <tsym> TYPENAME
+%token <sval> FIELD_NAME
%token <voidval> '.'
%token <voidval> ';'
@@ -291,11 +293,9 @@ yyerror PARAMS ((char *));
%type <voidval> upper_element
%type <voidval> first_element
%type <voidval> structure_primitive_value
-%type <voidval> field_name
%type <voidval> mode_argument
%type <voidval> upper_lower_argument
%type <voidval> length_argument
-%type <voidval> mode_name
%type <voidval> array_mode_name
%type <voidval> string_mode_name
%type <voidval> variant_structure_mode_name
@@ -304,13 +304,20 @@ yyerror PARAMS ((char *));
%type <voidval> subexpression
%type <voidval> case_label_specification
%type <voidval> buffer_location
-
%type <voidval> single_assignment_action
+%type <tsym> mode_name
%%
/* Z.200, 5.3.1 */
+start : value
+ | mode_name
+ { write_exp_elt_opcode(OP_TYPE);
+ write_exp_elt_type($1.type);
+ write_exp_elt_opcode(OP_TYPE);}
+ ;
+
value : expression
{
$$ = 0; /* FIXME */
@@ -333,9 +340,9 @@ location : access_name
{
$$ = 0; /* FIXME */
}
- | FIXME_02
+ | primitive_value POINTER
{
- $$ = 0; /* FIXME */
+ write_exp_elt_opcode (UNOP_IND);
}
;
@@ -588,9 +595,10 @@ value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')'
/* Z.200, 5.2.10 */
-value_structure_field: structure_primitive_value '.' field_name
- {
- $$ = 0; /* FIXME */
+value_structure_field: primitive_value FIELD_NAME
+ { write_exp_elt_opcode (STRUCTOP_STRUCT);
+ write_exp_string ($2);
+ write_exp_elt_opcode (STRUCTOP_STRUCT);
}
;
@@ -598,7 +606,9 @@ value_structure_field: structure_primitive_value '.' field_name
expression_conversion: mode_name parenthesised_expression
{
- $$ = 0; /* FIXME */
+ write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_type ($1.type);
+ write_exp_elt_opcode (UNOP_CAST);
}
;
@@ -648,6 +658,10 @@ expression : operand_0
{
$$ = 0; /* FIXME */
}
+ | single_assignment_action
+ {
+ $$ = 0; /* FIXME */
+ }
| conditional_expression
{
$$ = 0; /* FIXME */
@@ -710,10 +724,6 @@ operand_0 : operand_1
{
write_exp_elt_opcode (BINOP_BITWISE_XOR);
}
- | single_assignment_action
- {
- $$ = 0; /* FIXME */
- }
;
/* Z.200, 5.3.4 */
@@ -814,8 +824,6 @@ operand_4 : operand_5
;
/* Z.200, 5.3.8 */
-/* Note that we accept any expression for BINOP_CONCAT, not just
- integer literal expressions. (FIXME?) */
operand_5 : operand_6
{
@@ -829,7 +837,9 @@ operand_5 : operand_6
{
write_exp_elt_opcode (UNOP_LOGICAL_NOT);
}
- | parenthesised_expression operand_6
+ | parenthesised_expression CHARACTER_STRING_LITERAL
+/* We require the string operand to be a literal, to avoid some
+ nasty parsing ambiguities. */
{
write_exp_elt_opcode (BINOP_CONCAT);
}
@@ -839,7 +849,7 @@ operand_5 : operand_6
operand_6 : POINTER location
{
- $$ = 0; /* FIXME */
+ write_exp_elt_opcode (UNOP_ADDR);
}
| RECEIVE buffer_location
{
@@ -932,11 +942,10 @@ mode_argument : mode_name
}
;
-upper_lower_argument : location
- {
- $$ = 0; /* FIXME */
- }
- | expression
+mode_name : TYPENAME
+ ;
+
+upper_lower_argument : expression
{
$$ = 0; /* FIXME */
}
@@ -946,11 +955,7 @@ upper_lower_argument : location
}
;
-length_argument : location
- {
- $$ = 0; /* FIXME */
- }
- | expression
+length_argument : expression
{
$$ = 0; /* FIXME */
}
@@ -983,8 +988,6 @@ lower_element : FIXME_20 { $$ = 0; }
upper_element : FIXME_21 { $$ = 0; }
first_element : FIXME_22 { $$ = 0; }
structure_primitive_value: FIXME_23 { $$ = 0; }
-field_name : FIXME_24 { $$ = 0; }
-mode_name : FIXME_25 { $$ = 0; }
boolean_expression : FIXME_26 { $$ = 0; }
case_selector_list : FIXME_27 { $$ = 0; }
subexpression : FIXME_28 { $$ = 0; }
@@ -1762,6 +1765,7 @@ static const struct token tokentab2[] =
{
{ ":=", GDB_ASSIGNMENT },
{ "//", SLASH_SLASH },
+ { "->", POINTER },
{ "/=", NOTEQUAL },
{ "<=", LEQ },
{ ">=", GTR },
@@ -1797,7 +1801,6 @@ yylex ()
case ';':
case '!':
case '+':
- case '-':
case '*':
case '(':
case ')':
@@ -1896,6 +1899,7 @@ yylex ()
would already have found it. */
switch (*lexptr)
{
+ case '-':
case ':':
case '/':
case '<':
@@ -1976,8 +1980,10 @@ yylex ()
case LOC_LABEL:
return (LOCATION_NAME);
break;
- case LOC_UNDEF:
case LOC_TYPEDEF:
+ yylval.tsym.type = SYMBOL_TYPE (sym);
+ return TYPENAME;
+ case LOC_UNDEF:
case LOC_CONST_BYTES:
case LOC_OPTIMIZED_OUT:
error ("Symbol \"%s\" names no location.", simplename);
@@ -2000,7 +2006,12 @@ yylex ()
switch (*lexptr)
{
case '.': /* Not float for example. */
- return (*lexptr++);
+ lexptr++;
+ while (isspace (*lexptr)) lexptr++;
+ simplename = match_simple_name_string ();
+ if (!simplename)
+ return '.';
+ return FIELD_NAME;
}
return (ILLEGAL_TOKEN);
diff --git a/gdb/ch-typeprint.c b/gdb/ch-typeprint.c
index e016baf..c3cdcd2 100644
--- a/gdb/ch-typeprint.c
+++ b/gdb/ch-typeprint.c
@@ -46,44 +46,12 @@ chill_print_type (type, varstring, stream, show, level)
int show;
int level;
{
- struct type *index_type;
- struct type *range_type;
- LONGEST low_bound;
- LONGEST high_bound;
-
if (varstring != NULL && *varstring != '\0')
{
fputs_filtered (varstring, stream);
fputs_filtered (" ", stream);
}
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
- range_type = TYPE_FIELD_TYPE (type, 0);
- index_type = TYPE_TARGET_TYPE (range_type);
- low_bound = TYPE_FIELD_BITPOS (range_type, 0);
- high_bound = TYPE_FIELD_BITPOS (range_type, 1);
- fputs_filtered ("array (", stream);
- print_type_scalar (index_type, low_bound, stream);
- fputs_filtered (":", stream);
- print_type_scalar (index_type, high_bound, stream);
- fputs_filtered (") ", stream);
- chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
- break;
-
- case TYPE_CODE_STRING:
- range_type = TYPE_FIELD_TYPE (type, 0);
- index_type = TYPE_TARGET_TYPE (range_type);
- high_bound = TYPE_FIELD_BITPOS (range_type, 1);
- fputs_filtered ("CHAR (", stream);
- print_type_scalar (index_type, high_bound + 1, stream);
- fputs_filtered (")", stream);
- break;
-
- default:
- chill_type_print_base (type, stream, show, level);
- break;
- }
+ chill_type_print_base (type, stream, show, level);
}
/* Print the name of the type (or the ultimate pointer target,
@@ -108,6 +76,10 @@ chill_type_print_base (type, stream, show, level)
char *name;
register int len;
register int i;
+ struct type *index_type;
+ struct type *range_type;
+ LONGEST low_bound;
+ LONGEST high_bound;
QUIT;
@@ -129,11 +101,48 @@ chill_type_print_base (type, stream, show, level)
switch (TYPE_CODE (type))
{
- case TYPE_CODE_ARRAY:
case TYPE_CODE_PTR:
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
+ {
+ fprintf_filtered (stream, "PTR");
+ break;
+ }
+ fprintf_filtered (stream, "REF ");
+ chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ break;
+
+ case TYPE_CODE_ARRAY:
+ range_type = TYPE_FIELD_TYPE (type, 0);
+ index_type = TYPE_TARGET_TYPE (range_type);
+ low_bound = TYPE_FIELD_BITPOS (range_type, 0);
+ high_bound = TYPE_FIELD_BITPOS (range_type, 1);
+ fputs_filtered ("ARRAY (", stream);
+ print_type_scalar (index_type, low_bound, stream);
+ fputs_filtered (":", stream);
+ print_type_scalar (index_type, high_bound, stream);
+ fputs_filtered (") ", stream);
+ chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
+ break;
+
+ case TYPE_CODE_STRING:
+ range_type = TYPE_FIELD_TYPE (type, 0);
+ index_type = TYPE_TARGET_TYPE (range_type);
+ high_bound = TYPE_FIELD_BITPOS (range_type, 1);
+ fputs_filtered ("CHAR (", stream);
+ print_type_scalar (index_type, high_bound + 1, stream);
+ fputs_filtered (")", stream);
+ break;
+
case TYPE_CODE_MEMBER:
+ fprintf_filtered (stream, "MEMBER ");
+ chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ break;
case TYPE_CODE_REF:
+ fprintf_filtered (stream, "/*LOC*/ ");
+ chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ break;
case TYPE_CODE_FUNC:
+ fprintf_filtered (stream, "PROC (?)");
chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
break;
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c
index c0ec4f7..e779758 100644
--- a/gdb/ch-valprint.c
+++ b/gdb/ch-valprint.c
@@ -157,7 +157,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
}
if (addressprint && format != 's')
{
- fprintf_filtered (stream, "0x%x", addr);
+ fprintf_filtered (stream, "H'%x", addr);
}
/* For a pointer to char or unsigned char, also print the string
@@ -185,7 +185,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
}
if (addressprint && format != 's')
{
- fprintf_filtered (stream, "0x%x ", addr);
+ fprintf_filtered (stream, "H'%x ", addr);
}
i = TYPE_LENGTH (type);
LA_PRINT_STRING (stream, valaddr, i, 0);
@@ -199,20 +199,50 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
0);
break;
- case TYPE_CODE_MEMBER:
case TYPE_CODE_REF:
- case TYPE_CODE_UNION:
+ if (addressprint)
+ {
+ fprintf_filtered (stream, "LOC(H'%lx)",
+ unpack_long (builtin_type_int, valaddr));
+ if (deref_ref)
+ fputs_filtered (": ", stream);
+ }
+ /* De-reference the reference. */
+ if (deref_ref)
+ {
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF)
+ {
+ value deref_val =
+ value_at
+ (TYPE_TARGET_TYPE (type),
+ unpack_pointer (lookup_pointer_type (builtin_type_void),
+ valaddr));
+ val_print (VALUE_TYPE (deref_val),
+ VALUE_CONTENTS (deref_val),
+ VALUE_ADDRESS (deref_val), stream, format,
+ deref_ref, recurse + 1, pretty);
+ }
+ else
+ fputs_filtered ("???", stream);
+ }
+ break;
+
case TYPE_CODE_ENUM:
+ c_val_print (type, valaddr, address, stream, format,
+ deref_ref, recurse, pretty);
+ break;
+
+ case TYPE_CODE_MEMBER:
+ case TYPE_CODE_UNION:
case TYPE_CODE_FUNC:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
case TYPE_CODE_RANGE:
- error ("Unimplemented chill_val_print support for type %d",
- TYPE_CODE (type));
- break;
-
default:
- error ("Invalid Chill type code %d in symbol table.", TYPE_CODE (type));
+ /* Let's derfer printing to the C printer, rather than
+ print an error message. FIXME! */
+ c_val_print (type, valaddr, address, stream, format,
+ deref_ref, recurse, pretty);
}
fflush (stream);
return (0);
@@ -243,7 +273,7 @@ chill_print_value_fields (type, valaddr, stream, format, recurse, pretty,
check_stub_type (type);
- fprintf_filtered (stream, "(");
+ fprintf_filtered (stream, "[");
len = TYPE_NFIELDS (type);
if (len == 0)
{
@@ -267,9 +297,10 @@ chill_print_value_fields (type, valaddr, stream, format, recurse, pretty,
{
wrap_here (n_spaces (2 + 2 * recurse));
}
+ fputs_filtered (".", stream);
fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
language_chill, DMGL_NO_OPTS);
- fputs_filtered (" = ", stream);
+ fputs_filtered (": ", stream);
if (TYPE_FIELD_PACKED (type, i))
{
value v;
@@ -295,6 +326,6 @@ chill_print_value_fields (type, valaddr, stream, format, recurse, pretty,
print_spaces_filtered (2 * recurse, stream);
}
}
- fprintf_filtered (stream, ")");
+ fprintf_filtered (stream, "]");
}
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 170dbe8..52c6c72 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -2370,32 +2370,12 @@ read_struct_type (pp, type, objfile)
member functions, attach them to the type, and then read any tilde
field (baseclass specifier for the class holding the main vtable). */
- if (!read_baseclasses (&fi, pp, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!read_struct_fields (&fi, pp, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!attach_fields_to_type (&fi, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!read_member_functions (&fi, pp, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!attach_fn_fields_to_type (&fi, type))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!read_tilde_fields (&fi, pp, type, objfile))
+ if (!read_baseclasses (&fi, pp, type, objfile)
+ || !read_struct_fields (&fi, pp, type, objfile)
+ || !attach_fields_to_type (&fi, type, objfile)
+ || !read_member_functions (&fi, pp, type, objfile)
+ || !attach_fn_fields_to_type (&fi, type)
+ || !read_tilde_fields (&fi, pp, type, objfile))
{
do_cleanups (back_to);
return (error_type (pp));