aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1991-11-06 01:08:21 +0000
committerPer Bothner <per@bothner.com>1991-11-06 01:08:21 +0000
commit545af6ce070ded76ef1b8697495a18dbe0990e6c (patch)
tree6ee06fb285b476377d97fa7a7e8becdaf012e44f /gdb
parent4906534f1f4f6c1a3444f370cfd9ecdf986e66a0 (diff)
downloadgdb-545af6ce070ded76ef1b8697495a18dbe0990e6c.zip
gdb-545af6ce070ded76ef1b8697495a18dbe0990e6c.tar.gz
gdb-545af6ce070ded76ef1b8697495a18dbe0990e6c.tar.bz2
Add C++ as a separate language.
Also, fix a C++ problem when looking for methods in super-classes. (There was confusion between base and derived types.)
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog25
-rw-r--r--gdb/c-exp.y26
-rw-r--r--gdb/dwarfread.c14
-rw-r--r--gdb/language.c9
-rw-r--r--gdb/values.c18
5 files changed, 77 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f85cf89..a5cb83f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,28 @@
+Tue Nov 5 16:47:47 1991 Per Bothner (bothner at cygnus.com)
+
+ Add C++ as a separate language.
+ * defs.h (enum language): Add language_cplus.
+ * dwarfread.c (end_symtab): Support language_cplus.
+ * c-exp.y: Add new struct language_defn cplus_language_defn.
+ Don't set c to be the default language (see main.c).
+ * c-exp.y (yylex): Only look for field of this if
+ language is C++. (First difference from C!)
+ * language.c: Add case branches for C++ (currently, all
+ the same as C). Also, add c++ to "usage" note for "set lang".
+ * valprint.c (typedef_print). Add case branches for C++.
+ * main.c (main): New way to set initial language: Look at
+ file extension of psymtab containing main(). (Same as we
+ do for symtabs, but avoid loading the symtab yet.)
+ * symtab.c: New routine find_main_psymtab(), used by main()
+ to set initial language.
+ * symfile.c (allocate_symtab): Move code for mapping file
+ extensions-> languages to new deduce_language_from_filename().
+
+ Fix a C++ problem when looking for methods in super-classes.
+ There was confusion between base and derived types.
+ * valops.c (value_fn_field): Change function interface.
+ * values.c: Use new value_fn_field interface.
+
Mon Nov 4 10:49:33 1991 Per Bothner (bothner at cygnus.com)
* infrun.c: Fixed typo in comment.
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index b30729a..3e318fe 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1348,7 +1348,10 @@ yylex ()
int hextype;
sym = lookup_symbol (tmp, expression_context_block,
- VAR_NAMESPACE, &is_a_field_of_this, NULL);
+ VAR_NAMESPACE,
+ current_language->la_language == language_cplus
+ ? &is_a_field_of_this : NULL,
+ NULL);
if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
lookup_partial_symtab (tmp))
{
@@ -1480,8 +1483,6 @@ struct type ** const (c_builtin_types[]) =
0
};
-/* FIXME: Eventually do a separate defintion for C++. */
-
const struct language_defn c_language_defn = {
"c", /* Language name */
language_c,
@@ -1499,6 +1500,23 @@ const struct language_defn c_language_defn = {
LANG_MAGIC
};
+const struct language_defn cplus_language_defn = {
+ "c++", /* Language name */
+ language_cplus,
+ c_builtin_types,
+ range_check_off,
+ type_check_off,
+ c_parse,
+ c_error,
+ &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
+ &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
+ &builtin_type_double, /* longest floating point type */ /*FIXME*/
+ "0x%x", "0x%", "x", /* Hex format, prefix, suffix */
+ "0%o", "0%", "o", /* Octal format, prefix, suffix */
+ c_op_print_tab, /* expression operators for printing */
+ LANG_MAGIC
+};
+
void
_initialize_c_exp ()
{
@@ -1552,5 +1570,5 @@ _initialize_c_exp ()
"double complex");
add_language (&c_language_defn);
- set_language (language_c); /* Make C the default language */
+ add_language (&cplus_language_defn);
}
diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c
index ce29d83..47a6a79 100644
--- a/gdb/dwarfread.c
+++ b/gdb/dwarfread.c
@@ -1644,11 +1644,19 @@ DEFUN(end_symtab, (filename, language), char *filename AND long language)
symtab -> line_charpos = 0;
/* FIXME: The following may need to be expanded for other languages */
- if (language == LANG_C89 || language == LANG_C)
+ switch (language)
{
- symtab -> language = language_c;
+ case LANG_C89:
+ case LANG_C:
+ symtab -> language = language_c;
+ break;
+ case LANG_C_PLUS_PLUS:
+ symtab -> language = language_cplus;
+ break;
+ default:
+ ;
}
-
+
/* Link the new symtab into the list of such. */
symtab -> next = symtab_list;
symtab_list = symtab;
diff --git a/gdb/language.c b/gdb/language.c
index a7a1285..31c532c 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -122,6 +122,7 @@ set_language_command (ignore, from_tty)
printf("The currently understood settings are:\n\n\
local or auto Automatic setting based on source file\n\
c Use the C language\n\
+c++ Use the C++ language\n\
modula-2 Use the Modula-2 language\n");
/* Restore the silly string. */
set_language(current_language->la_language);
@@ -280,6 +281,7 @@ set_language(lang)
current_language = languages[i];
set_type_range ();
set_lang_str();
+ break;
}
}
}
@@ -379,6 +381,7 @@ binop_result_type(v1,v2)
switch(current_language->la_language)
{
case language_c:
+ case language_cplus:
if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT)
return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ?
VALUE_TYPE(v2) : VALUE_TYPE(v1);
@@ -537,6 +540,7 @@ integral_type (type)
switch(current_language->la_language)
{
case language_c:
+ case language_cplus:
return (TYPE_CODE(type) != TYPE_CODE_INT) &&
(TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1;
case language_m2:
@@ -572,6 +576,7 @@ character_type (type)
return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1;
case language_c:
+ case language_cplus:
return (TYPE_CODE(type) == TYPE_CODE_INT) &&
TYPE_LENGTH(type) == sizeof(char)
? 1 : 0;
@@ -589,6 +594,7 @@ boolean_type (type)
return TYPE_CODE(type) != TYPE_CODE_BOOL ? 0 : 1;
case language_c:
+ case language_cplus:
return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1;
}
}
@@ -618,6 +624,7 @@ structured_type(type)
switch(current_language->la_language)
{
case language_c:
+ case language_cplus:
return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
(TYPE_CODE(type) == TYPE_CODE_UNION) ||
(TYPE_CODE(type) == TYPE_CODE_ARRAY);
@@ -643,6 +650,7 @@ value_true(val)
switch (current_language->la_language) {
case language_c:
+ case language_cplus:
return !value_zerop (val);
case language_m2:
@@ -798,6 +806,7 @@ binop_type_check(arg1,arg2,op)
{
#ifdef _LANG_c
case language_c:
+ case language_cplus:
switch(op)
{
case BINOP_DIV:
diff --git a/gdb/values.c b/gdb/values.c
index a5b2c69..a7f959e 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -879,21 +879,23 @@ value_field (arg1, fieldno)
return value_primitive_field (arg1, 0, fieldno, VALUE_TYPE (arg1));
}
+/* Return a non-virtual function as a value.
+ F is the list of member functions which contains the desired method.
+ J is an index into F which provides the desired method. */
+
value
-value_fn_field (arg1, fieldno, subfieldno)
- register value arg1;
- register int fieldno;
- int subfieldno;
+value_fn_field (f, j)
+ struct fn_field *f;
+ int j;
{
register value v;
- struct fn_field *f = TYPE_FN_FIELDLIST1 (VALUE_TYPE (arg1), fieldno);
- register struct type *type = TYPE_FN_FIELD_TYPE (f, subfieldno);
+ register struct type *type = TYPE_FN_FIELD_TYPE (f, j);
struct symbol *sym;
- sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, subfieldno),
+ sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
0, VAR_NAMESPACE, 0, NULL);
if (! sym) error ("Internal error: could not find physical method named %s",
- TYPE_FN_FIELD_PHYSNAME (f, subfieldno));
+ TYPE_FN_FIELD_PHYSNAME (f, j));
v = allocate_value (type);
VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));