summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2001-07-06 19:17:05 +0000
committerDaniel Berlin <dberlin@dberlin.org>2001-07-06 19:17:05 +0000
commit1956a8b461b357b60dfd7602d2db87caaa80b019 (patch)
tree399ddd3a8e133e267dad2eab0a1aba6223d0700e
parent6bd3be32bbe1382e066c99ef592ce8064cf4c1eb (diff)
downloadbinutils-gdb-dberlin-typesystem-branch.tar.gz
Typesystem work initial import.dberlin-typesystem-branch
Note that this currently isn't building, i'm in the middle of converting make_function_type/lookup_function_type
-rw-r--r--gdb/ChangeLog82
-rw-r--r--gdb/Makefile.in43
-rw-r--r--gdb/arm-linux-tdep.c4
-rw-r--r--gdb/arm-tdep.c4
-rw-r--r--gdb/ax-gdb.c64
-rw-r--r--gdb/bcache.c29
-rw-r--r--gdb/bcache.h2
-rw-r--r--gdb/blockframe.c57
-rw-r--r--gdb/breakpoint.c282
-rw-r--r--gdb/buildsym.c253
-rw-r--r--gdb/buildsym.h3
-rw-r--r--gdb/c-exp.y138
-rw-r--r--gdb/c-lang.c65
-rw-r--r--gdb/c-typeprint.c75
-rw-r--r--gdb/c-valprint.c32
-rw-r--r--gdb/ch-exp.c14
-rw-r--r--gdb/ch-lang.c89
-rw-r--r--gdb/ch-typeprint.c52
-rw-r--r--gdb/ch-valprint.c27
-rw-r--r--gdb/coffread.c97
-rw-r--r--gdb/completer.c1
-rw-r--r--gdb/config/powerpc/nm-linux.h1
-rw-r--r--gdb/cp-abi.c25
-rw-r--r--gdb/cp-abi.h11
-rw-r--r--gdb/cp-valprint.c77
-rw-r--r--gdb/d10v-tdep.c8
-rw-r--r--gdb/dbxread.c6
-rw-r--r--gdb/dstread.c2
-rw-r--r--gdb/dwarf2read.c3347
-rw-r--r--gdb/dwarfread.c30
-rw-r--r--gdb/eval.c222
-rw-r--r--gdb/expprint.c2
-rw-r--r--gdb/f-exp.y12
-rw-r--r--gdb/f-lang.c9
-rw-r--r--gdb/f-typeprint.c26
-rw-r--r--gdb/f-valprint.c38
-rw-r--r--gdb/findvar.c6
-rw-r--r--gdb/gdbarch.c3
-rw-r--r--gdb/gdbtypes.c1034
-rw-r--r--gdb/gdbtypes.h408
-rw-r--r--gdb/gnu-v2-abi.c99
-rw-r--r--gdb/gnu-v3-abi.c84
-rw-r--r--gdb/hpacc-abi.c111
-rw-r--r--gdb/ia64-tdep.c2
-rw-r--r--gdb/infcmd.c3
-rw-r--r--gdb/infrun.c2
-rw-r--r--gdb/jv-exp.y2
-rw-r--r--gdb/jv-lang.c24
-rw-r--r--gdb/jv-typeprint.c6
-rw-r--r--gdb/jv-valprint.c6
-rw-r--r--gdb/linespec.c6
-rw-r--r--gdb/m2-exp.y3
-rw-r--r--gdb/m2-lang.c8
-rw-r--r--gdb/main.c4
-rw-r--r--gdb/mdebugread.c33
-rw-r--r--gdb/minsyms.c77
-rw-r--r--gdb/objfiles.c21
-rw-r--r--gdb/objfiles.h3
-rw-r--r--gdb/p-exp.y5
-rw-r--r--gdb/p-lang.c5
-rw-r--r--gdb/p-typeprint.c64
-rw-r--r--gdb/p-valprint.c53
-rw-r--r--gdb/parse.c25
-rw-r--r--gdb/ppc-linux-nat.c2
-rw-r--r--gdb/printcmd.c6
-rw-r--r--gdb/solib-svr4.c2
-rw-r--r--gdb/stabsread.c165
-rw-r--r--gdb/symfile.c15
-rw-r--r--gdb/symfile.h2
-rw-r--r--gdb/symmisc.c24
-rw-r--r--gdb/symtab.c483
-rw-r--r--gdb/symtab.h80
-rw-r--r--gdb/thread-db.c2
-rw-r--r--gdb/top.c9
-rw-r--r--gdb/tracepoint.c10
-rw-r--r--gdb/typeprint.c12
-rw-r--r--gdb/utils.c8
-rw-r--r--gdb/valarith.c29
-rw-r--r--gdb/valops.c641
-rw-r--r--gdb/valprint.c2
-rw-r--r--gdb/value.h5
-rw-r--r--gdb/values.c181
-rw-r--r--gdb/varobj.c15
83 files changed, 5216 insertions, 3803 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 59ffe44adc1..685ee49b72e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,85 @@
+2001-05-30 Daniel Berlin <dan@cgsoftware.com>
+
+ * coffread.c (patch_opaque_types): Use BLOCK_NBUCKETS,
+ BLOCK_BUCKETS, handle the fact that we now have symbol chains.
+
+2001-05-29 Daniel Berlin <dan@cgsoftware.com>
+
+ * bcache.c (hash): Fix indenting, make it FNV-1 hash rather than
+ FNV-0 hash (just a change in the starting constant).
+
+ * minsyms.c (msymbol_hash_iw): Rewrite, based on FNV-1 hash from
+ bcache.c. Don't modulo the hash by the table size here, so we can
+ reuse this function elsewhere.
+ Add comments about changing the loop this function uses, and how
+ symbol lookup is dominated by this function now.
+ (msymbol_hash): Just use FNV-1 hash from bcache.c. Also don't
+ modulo the hash by the table size here, so we can reuse this
+ function.
+ (add_minsym_to_hash_table): Modulo the msymbol_hash return value
+ by the hash table size.
+ (add_minsym_to_demangled_hash_table): Ditto for msymbol_hash_iw.
+ (lookup_minimal_symbol): Ditto for both.
+
+ * symtab.c (lookup_block_symbol): Complete rewrite.
+ (search_symbols): Use BLOCK_NBUCKETS, BLOCK_BUCKET, and walk the
+ chain, since it's trying to go through all the symbols in blocks
+ we know to be in hash table form.
+ (make_symbol_completion_list): Ditto.
+ (make_symbol_overload_list): Ditto.
+
+ * buildsym.c (finish_block): Use the syms array in the block as a
+ hash table if possible (IE, the block isn't a function). Default
+ number of buckets is 1/4 the number of symbols.
+
+ * symtab.h: (BLOCK_BUCKET): New macro. Currently the same as
+ BLOCK_SYM, since we reuse the sym array as the hash table.
+ (BLOCK_NBUCKETS): New macro. Currently the same as BLOCK_NSYMS,
+ for the same reason.
+ (BLOCK_SHOULD_SHORT): Never sort, not necessary anymore.
+ (struct symbol): Add hash_next member.
+
+
+2001-05-29 Daniel Berlin <dan@cgsoftware.co>
+
+ * Makefile.in (SFILES): Add symeval.c.
+ (symeval_h): New.
+ (COMMON_OBS): Add symeval.o
+ (symeval.o): New.
+ (findvar.o): Depend on $(symeval_h), too.
+
+ * symtab.h: Add LOC_LOC_EXPR and LOC_LOC_LIST to the location types.
+ Add dynamic_location and loc/frameloc to the symbol structure.
+ (SYMBOL_LOC_EXPR): New macro.
+ (SYMBOL_FRAME_LOC_EXPR): Ditto.
+ Add forward declaration of locexpr struct.
+
+ * symeval.c: New file.
+
+ * symeval.def: New file.
+
+ * symeval.h: New file.
+
+
+2001-05-27 Daniel Berlin <dan@cgsoftware.com>
+
+ * symfile.c (default_symfile_offsets): Allocate in misc_obstack.
+ (reread_symbols): Handle misc_obstack too, and use it where
+ psymbol_obstack didn't belong.
+ (allocate_psymtab): Ditto.
+
+ * objfiles.c (add_to_objfile_sections): Use misc_obstack, not psymbol_obstack.
+ (build_objfile_section_table): Ditto.
+ (free_objfile): Free the misc_obstack.
+ (allocate_objfile): Setup misc_obstack too.
+
+ * objfiles.h: Add misc_obstack to object file.
+
+2001-05-22 Daniel Berlin <dan@cgsoftware.com>
+
+ * linespec.c (find_toplevel_char): '<' and '>' also increase and
+ decrease the depth we are at, in the case of templates.
+
2001-07-06 Jim Blandy <jimb@redhat.com>
* gdbtypes.h (builtin_type_void_func_ptr): New builtin type.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 46bd68d6c76..4df26451c6b 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -312,7 +312,7 @@ GLOBAL_CFLAGS = $(MT_CFLAGS) $(MH_CFLAGS)
# CFLAGS is specifically reserved for setting from the command line
# when running make. I.E. "make CFLAGS=-Wmissing-prototypes".
-CFLAGS = @CFLAGS@
+CFLAGS = @CFLAGS@ -Werror -O
# Need to pass this to testsuite for "make check". Probably should be
# consistent with top-level Makefile.in and gdb/testsuite/Makefile.in
@@ -511,7 +511,7 @@ TARGET_FLAGS_TO_PASS = \
# SFILES is used in building the distribution archive.
SFILES = ax-general.c ax-gdb.c bcache.c blockframe.c breakpoint.c \
- buildsym.c c-exp.y c-lang.c c-typeprint.c c-valprint.c \
+ bitmap.c buildsym.c c-exp.y c-lang.c c-typeprint.c c-valprint.c \
ch-exp.c ch-lang.c ch-typeprint.c ch-valprint.c coffread.c \
complaints.c completer.c corefile.c cp-valprint.c dbxread.c \
demangle.c dwarfread.c dwarf2read.c elfread.c environ.c eval.c \
@@ -596,7 +596,6 @@ xm_h = @xm_h@
tm_h = @tm_h@
nm_h = @nm_h@
defs_h = defs.h $(xm_h) $(tm_h) $(nm_h) config.status config.h gdbarch.h ui-file.h
-
top_h = top.h
inferior_h = inferior.h $(breakpoint_h)
target_h = target.h $(bfd_h) $(symtab_h) $(dcache_h) $(memattr_h)
@@ -627,7 +626,7 @@ cp_abi_h = cp-abi.h
# wrong if TAGS has files twice). Because this is tricky to get
# right, it is probably easiest just to list .h files here directly.
-HFILES_NO_SRCDIR = bcache.h buildsym.h call-cmds.h coff-solib.h defs.h \
+HFILES_NO_SRCDIR = bcache.h bitmap.h buildsym.h call-cmds.h coff-solib.h defs.h \
dst.h environ.h $(gdbcmd_h) gdbcore.h \
gdb-stabs.h hpread.h $(inferior_h) language.h minimon.h monitor.h \
objfiles.h parser-defs.h partial-stab.h serial.h solib.h \
@@ -678,7 +677,7 @@ COMMON_OBS = version.o blockframe.o breakpoint.o findvar.o regcache.o \
expprint.o environ.o stack.o thread.o \
event-loop.o event-top.o inf-loop.o completer.o \
gdbarch.o arch-utils.o gdbtypes.o copying.o $(DEPFILES) \
- memattr.o mem-break.o target.o parse.o language.o $(YYOBJ) buildsym.o \
+ memattr.o mem-break.o target.o parse.o language.o $(YYOBJ) bitmap.o buildsym.o \
kod.o kod-cisco.o \
gdb-events.o \
exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \
@@ -1027,7 +1026,7 @@ version.o: version.c $(version_h)
# If we said c-exp.tab.c rather than ./c-exp.tab.c some makes
# would sometimes re-write it into $(srcdir)/c-exp.tab.c.
-
+YFLAGS += --debug
# Remove bogus decls for malloc/realloc/free which conflict with everything
# else. Strictly speaking c-exp.tab.c should therefore depend on
# Makefile.in, but that was a pretty big annoyance.
@@ -1225,7 +1224,7 @@ breakpoint.o: breakpoint.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) \
gdb-events.h linespec.h $(ui_out_h)
buildsym.o: buildsym.c $(bfd_h) buildsym.h complaints.h $(defs_h) \
- objfiles.h symfile.h $(symtab_h) $(gdb_string_h)
+ objfiles.h symfile.h $(symtab_h) $(gdb_string_h) $(gdbtypes_h)
c-lang.o: c-lang.c c-lang.h $(defs_h) $(expression_h) $(gdbtypes_h) \
language.h parser-defs.h $(symtab_h)
@@ -1291,7 +1290,7 @@ corelow.o: corelow.c $(command_h) $(defs_h) $(gdbcore_h) $(inferior_h) \
cp-abi.o: cp-abi.c $(defs_h) $(value_h) $(cp_abi_h)
cp-valprint.o: cp-valprint.c $(defs_h) $(expression_h) $(gdbcmd_h) \
- $(gdbtypes_h) $(symtab_h) $(value_h) $(gdb_string_h)
+ $(gdbtypes_h) $(symtab_h) $(value_h) $(gdb_string_h) $(cp_abi_h)
dcache.o: dcache.c $(dcache_h) $(defs_h) $(gdbcmd_h) $(gdb_string_h) \
$(gdbcore_h) target.h
@@ -1347,7 +1346,7 @@ expprint.o: expprint.c $(defs_h) $(expression_h) $(gdbtypes_h) \
language.h parser-defs.h $(symtab_h) $(value_h)
findvar.o: findvar.c $(defs_h) $(gdbcore_h) $(inferior_h) target.h \
- $(gdb_string_h) $(regcache_h)
+ $(gdb_string_h) $(regcache_h)
frame.o: frame.c $(defs_h) $(frame_h) $(target_h) $(value_h) $(inferior_h) \
$(regcache_h)
@@ -1492,18 +1491,20 @@ go32-nat.o: go32-nat.c $(defs_h) $(inferior_h) gdb_wait.h $(gdbcore_h) \
gnu-nat.o: process_reply_S.h exc_request_S.h notify_S.h msg_reply_S.h \
exc_request_U.h msg_U.h gnu-nat.h
-gnu-v2-abi.o: gnu-v2-abi.c $(defs_h) $(gdb_string_h) $(symtab_h) \
- $(gdbtypes_h) $(value_h) $(demangle_h) $(cp_abi_h)
+gnu-v3-abi.o: gnu-v3-abi.c $(cp_abi_h) $(defs_h) $(gdb_string_h) $(symtab_h) \
+ $(gdbtypes_h) $(value_h) $(demangle_h)
+
+gnu-v2-abi.o: gnu-v2-abi.c $(defs_h) $(cp_abi_h) $(gdb_string_h $(symtab_h) \
+ $(gdbtypes_h) $(value_h) $(demangle_h) $(cp_abi_h)
-gnu-v3-abi.o: gnu-v2-abi.c $(defs_h) $(value_h) $(cp_abi_h) $(demangle_h)
-
h8300-tdep.o: h8300-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(regcache_h)
+h8300-tdep.o: h8300-tdep.c $(defs_h) $(frame_h) $(symtab_h)
+
h8500-tdep.o: h8500-tdep.c $(bfd_h) $(dis-asm_h) $(defs_h) \
- $(expression_h) $(frame_h) $(gdbcmd_h) $(gdbtypes_h) $(symtab_h) \
- $(value_h) $(regcache_h)
+ $(expression_h) $(frame_h) $(gdbcmd_h) $(gdbtypes_h) $(symtab_h)
-hp300ux-nat.o: hp300ux-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) $(regcache_h)
+hp300ux-nat.o: hp300ux-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) $(value_h) $(regcache_h)
hpacc-abi.o: hpacc-abi.c $(defs_h) $(cp_abi_h) $(gdb_string_h) $(gdbtypes_h) \
$(value_h) $(gdbcore_h)
@@ -1636,7 +1637,7 @@ p-typeprint.o: p-typeprint.c p-lang.h $(defs_h) $(expression_h) \
target.h typeprint.h $(value_h) $(gdb_string_h)
p-valprint.o: p-valprint.c p-lang.h $(defs_h) $(expression_h) $(gdbtypes_h) \
- language.h $(symtab_h) valprint.h $(value_h) $(gdb_string_h)
+ language.h $(symtab_h) valprint.h $(value_h) $(gdb_string_h) $(cp_abi_h)
m68k-tdep.o: m68k-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(value_h) \
$(gdbcore_h) $(gdb_string_h) $(regcache_h)
@@ -2023,7 +2024,10 @@ linespec.o: linespec.c linespec.h $(defs_h) $(frame_h) $(value_h) \
objfiles.h symfile.h completer.h $(symtab_h) \
$(demangle_h) command.h $(cp_abi_h)
-tic80-tdep.o: tic80-tdep.c $(defs_h) $(regcache_h)
+# OBSOLETE tahoe-tdep.o: tahoe-tdep.c $(OP_INCLUDE)/tahoe.h $(defs_h) \
+# OBSOLETE $(symtab_h)
+
+tic80-tdep.o: tic80-tdep.c $(defs_h)
target.o: target.c $(bfd_h) $(defs_h) $(gdbcmd_h) $(inferior_h) \
objfiles.h symfile.h target.h $(gdb_string_h) $(regcache_h)
@@ -2066,7 +2070,7 @@ valprint.o: valprint.c $(defs_h) $(expression_h) $(gdbcmd_h) \
values.o: values.c $(defs_h) $(expression_h) $(frame_h) $(gdbcmd_h) \
$(gdbcore_h) $(gdbtypes_h) $(symtab_h) target.h $(value_h) \
- $(gdb_string_h) scm-lang.h
+ $(gdb_string_h) scm-lang.h $(cp_abi_h)
vax-tdep.o: vax-tdep.c $(OP_INCLUDE)/vax.h $(defs_h) $(symtab_h)
@@ -2133,6 +2137,7 @@ varobj.o: varobj.c $(defs_h) $(frame_h) $(value_h) \
wrapper.o: wrapper.c $(defs_h) $(frame_h) $(value_h) wrapper.h
+
#
# CLI dependencies
#
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 293a8b72057..4e558996e77 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -192,8 +192,8 @@ arm_linux_push_arguments (int nargs, value_ptr * args, CORE_ADDR sp,
/* If the argument is a pointer to a function, and it is a Thumb
function, set the low bit of the pointer. */
if (TYPE_CODE_PTR == typecode
- && NULL != target_type
- && TYPE_CODE_FUNC == TYPE_CODE (target_type))
+ && POINTER_TARGET_TYPE (arg_type) != NULL
+ && TYPE_CODE_FUNC == TYPE_CODE (POINTER_TARGET_TYPE (arg_type)))
{
CORE_ADDR regval = extract_address (val, len);
if (arm_pc_is_thumb (regval))
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a4d16329402..b4fd7df2c42 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -1353,8 +1353,8 @@ arm_push_arguments (int nargs, value_ptr * args, CORE_ADDR sp,
/* If the argument is a pointer to a function, and it is a Thumb
function, set the low bit of the pointer. */
if (TYPE_CODE_PTR == typecode
- && NULL != target_type
- && TYPE_CODE_FUNC == TYPE_CODE (target_type))
+ && POINTER_TARGET_TYPE (arg_type) != NULL
+ && TYPE_CODE_FUNC == TYPE_CODE (POINTER_TARGET_TYPE (arg_type)))
{
CORE_ADDR regval = extract_address (val, len);
if (arm_pc_is_thumb (regval))
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 3fe66772ae9..a5270fdcf11 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -353,7 +353,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
{
/* Do we need to sign-extend this? */
if (!TYPE_UNSIGNED (type))
- ax_ext (ax, type->length * TARGET_CHAR_BIT);
+ ax_ext (ax, TYPE_LENGTH(type) * TARGET_CHAR_BIT);
}
@@ -363,7 +363,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
static void
gen_extend (struct agent_expr *ax, struct type *type)
{
- int bits = type->length * TARGET_CHAR_BIT;
+ int bits = TYPE_LENGTH(type) * TARGET_CHAR_BIT;
/* I just had to. */
((TYPE_UNSIGNED (type) ? ax_zero_ext : ax_ext) (ax, bits));
}
@@ -381,7 +381,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
ax_trace_quick (ax, TYPE_LENGTH (type));
}
- switch (type->code)
+ switch (TYPE_CODE(type))
{
case TYPE_CODE_PTR:
case TYPE_CODE_ENUM:
@@ -389,7 +389,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
case TYPE_CODE_CHAR:
/* It's a scalar value, so we know how to dereference it. How
many bytes long is it? */
- switch (type->length)
+ switch (TYPE_LENGTH(type))
{
case 8 / TARGET_CHAR_BIT:
ax_simple (ax, aop_ref8);
@@ -697,7 +697,7 @@ gen_usual_unary (struct agent_expr *ax, struct axs_value *value)
the stack. Should we tweak the type? */
/* Some types require special handling. */
- switch (value->type->code)
+ switch (TYPE_CODE(value->type))
{
/* Functions get converted to a pointer to the function. */
case TYPE_CODE_FUNC:
@@ -709,7 +709,7 @@ gen_usual_unary (struct agent_expr *ax, struct axs_value *value)
are no longer an lvalue. */
case TYPE_CODE_ARRAY:
{
- struct type *elements = TYPE_TARGET_TYPE (value->type);
+ struct type *elements = ARRAY_ELEMENT_TYPE (value->type);
value->type = lookup_pointer_type (elements);
value->kind = axs_rvalue;
/* We don't need to generate any code; the address of the array
@@ -872,7 +872,7 @@ gen_cast (struct agent_expr *ax, struct axs_value *value, struct type *type)
/* Dereference typedefs. */
type = check_typedef (type);
- switch (type->code)
+ switch (TYPE_CODE(type))
{
case TYPE_CODE_PTR:
/* It's implementation-defined, and I'll bet this is what GCC
@@ -923,9 +923,9 @@ gen_scale (struct agent_expr *ax, enum agent_op op, struct type *type)
{
struct type *element = TYPE_TARGET_TYPE (type);
- if (element->length != 1)
+ if (TYPE_LENGTH(element) != 1)
{
- ax_const_l (ax, element->length);
+ ax_const_l (ax, TYPE_LENGTH(element));
ax_simple (ax, op);
}
}
@@ -941,8 +941,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
struct axs_value *value1, struct axs_value *value2, char *name)
{
/* Is it INT+PTR? */
- if (value1->type->code == TYPE_CODE_INT
- && value2->type->code == TYPE_CODE_PTR)
+ if (TYPE_CODE(value1->type) == TYPE_CODE_INT
+ && TYPE_CODE(value2->type) == TYPE_CODE_PTR)
{
/* Swap the values and proceed normally. */
ax_simple (ax, aop_swap);
@@ -953,8 +953,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
}
/* Is it PTR+INT? */
- else if (value1->type->code == TYPE_CODE_PTR
- && value2->type->code == TYPE_CODE_INT)
+ else if (TYPE_CODE(value1->type) == TYPE_CODE_PTR
+ && TYPE_CODE(value2->type) == TYPE_CODE_INT)
{
gen_scale (ax, aop_mul, value1->type);
ax_simple (ax, aop_add);
@@ -964,8 +964,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
/* Must be number + number; the usual binary conversions will have
brought them both to the same width. */
- else if (value1->type->code == TYPE_CODE_INT
- && value2->type->code == TYPE_CODE_INT)
+ else if (TYPE_CODE(value1->type) == TYPE_CODE_INT
+ && TYPE_CODE(value2->type) == TYPE_CODE_INT)
{
ax_simple (ax, aop_add);
gen_extend (ax, value1->type); /* Catch overflow. */
@@ -987,10 +987,10 @@ static void
gen_sub (struct agent_expr *ax, struct axs_value *value,
struct axs_value *value1, struct axs_value *value2)
{
- if (value1->type->code == TYPE_CODE_PTR)
+ if (TYPE_CODE(value1->type) == TYPE_CODE_PTR)
{
/* Is it PTR - INT? */
- if (value2->type->code == TYPE_CODE_INT)
+ if (TYPE_CODE(value2->type) == TYPE_CODE_INT)
{
gen_scale (ax, aop_mul, value1->type);
ax_simple (ax, aop_sub);
@@ -1001,7 +1001,7 @@ gen_sub (struct agent_expr *ax, struct axs_value *value,
/* Is it PTR - PTR? Strictly speaking, the types ought to
match, but this is what the normal GDB expression evaluator
tests for. */
- else if (value2->type->code == TYPE_CODE_PTR
+ else if (TYPE_CODE(value2->type) == TYPE_CODE_PTR
&& (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type))
== TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type))))
{
@@ -1016,8 +1016,8 @@ an integer nor a pointer of the same type.");
}
/* Must be number + number. */
- else if (value1->type->code == TYPE_CODE_INT
- && value2->type->code == TYPE_CODE_INT)
+ else if (TYPE_CODE(value1->type) == TYPE_CODE_INT
+ && TYPE_CODE(value2->type) == TYPE_CODE_INT)
{
ax_simple (ax, aop_sub);
gen_extend (ax, value1->type); /* Catch overflow. */
@@ -1042,8 +1042,8 @@ gen_binop (struct agent_expr *ax, struct axs_value *value,
enum agent_op op_unsigned, int may_carry, char *name)
{
/* We only handle INT op INT. */
- if ((value1->type->code != TYPE_CODE_INT)
- || (value2->type->code != TYPE_CODE_INT))
+ if ((TYPE_CODE(value1->type) != TYPE_CODE_INT)
+ || (TYPE_CODE(value2->type) != TYPE_CODE_INT))
error ("Illegal combination of types in %s.", name);
ax_simple (ax,
@@ -1090,7 +1090,7 @@ gen_deref (struct agent_expr *ax, struct axs_value *value)
{
/* The caller should check the type, because several operators use
this, and we don't know what error message to generate. */
- if (value->type->code != TYPE_CODE_PTR)
+ if (TYPE_CODE(value->type) != TYPE_CODE_PTR)
internal_error (__FILE__, __LINE__,
"gen_deref: expected a pointer");
@@ -1100,7 +1100,7 @@ gen_deref (struct agent_expr *ax, struct axs_value *value)
T" to "T", and mark the value as an lvalue in memory. Leave it
to the consumer to actually dereference it. */
value->type = check_typedef (TYPE_TARGET_TYPE (value->type));
- value->kind = ((value->type->code == TYPE_CODE_FUNC)
+ value->kind = ((TYPE_CODE(value->type) == TYPE_CODE_FUNC)
? axs_rvalue : axs_lvalue_memory);
}
@@ -1112,7 +1112,7 @@ gen_address_of (struct agent_expr *ax, struct axs_value *value)
/* Special case for taking the address of a function. The ANSI
standard describes this as a special case, too, so this
arrangement is not without motivation. */
- if (value->type->code == TYPE_CODE_FUNC)
+ if (TYPE_CODE(value->type) == TYPE_CODE_FUNC)
/* The value's already an rvalue on the stack, so we just need to
change the type. */
value->type = lookup_pointer_type (value->type);
@@ -1163,7 +1163,7 @@ find_field (struct type *type, char *name)
}
error ("Couldn't find member named `%s' in struct/union `%s'",
- name, type->tag_name);
+ name, TYPE_TAG_NAME(type));
return 0;
}
@@ -1344,7 +1344,7 @@ gen_struct_ref (struct agent_expr *ax, struct axs_value *value, char *field,
/* Follow pointers until we reach a non-pointer. These aren't the C
semantics, but they're what the normal GDB evaluator does, so we
should at least be consistent. */
- while (value->type->code == TYPE_CODE_PTR)
+ while (TYPE_CODE(value->type) == TYPE_CODE_PTR)
{
gen_usual_unary (ax, value);
gen_deref (ax, value);
@@ -1408,7 +1408,7 @@ gen_repeat (union exp_element **pc, struct agent_expr *ax,
if (!v)
error ("Right operand of `@' must be a constant, in agent expressions.");
- if (v->type->code != TYPE_CODE_INT)
+ if (TYPE_CODE(v->type) != TYPE_CODE_INT)
error ("Right operand of `@' must be an integer.");
length = value_as_long (v);
if (length <= 0)
@@ -1417,11 +1417,11 @@ gen_repeat (union exp_element **pc, struct agent_expr *ax,
/* The top of the stack is already the address of the object, so
all we need to do is frob the type of the lvalue. */
{
- /* FIXME-type-allocation: need a way to free this type when we are
+ /* TYPEFIX-type-allocation: need a way to free this type when we are
done with it. */
- struct type *range
- = create_range_type (0, builtin_type_int, 0, length - 1);
- struct type *array = create_array_type (0, value1.type, range);
+ struct range_type *range
+ = make_range_type (NULL, builtin_type_int, 0, length - 1);
+ struct type *array = (struct type *)make_array_type (NULL, value1.type, range);
value->kind = axs_lvalue_memory;
value->type = array;
diff --git a/gdb/bcache.c b/gdb/bcache.c
index 0f9c2a25ccc..3398393999e 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -28,25 +28,27 @@
#include "bcache.h"
#include "gdb_string.h" /* For memcpy declaration */
-/* The old hash function was stolen from SDBM. This is what DB 3.0 uses now,
+/* The old hash function was stolen from SDBM. This is what DB 3.1 uses now,
* and is better than the old one.
+ * It's the FNV hash.
*/
unsigned long
-hash(void *addr, int length)
+hash (void *addr, int length)
{
- const unsigned char *k, *e;
- unsigned long h;
-
- k = (const unsigned char *)addr;
- e = k+length;
- for (h=0; k< e;++k)
- {
- h *=16777619;
- h ^= *k;
- }
- return (h);
+ const unsigned char *k, *e;
+ unsigned long h;
+
+ k = (const unsigned char *)addr;
+ e = k+length;
+ for (h=0x811c9dc5; k< e;++k)
+ {
+ h *=16777619;
+ h ^= *k;
+ }
+ return (h);
}
+
/* Growing the bcache's hash table. */
@@ -159,7 +161,6 @@ bcache (void *addr, int length, struct bcache *bcache)
bcache->unique_count++;
bcache->unique_size += length;
bcache->structure_size += BSTRING_SIZE (length);
-
return &new->d.data;
}
}
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 6b32c577d4f..ada2b5f9ed9 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -81,7 +81,7 @@ struct bstring {
union
{
- char data[1];
+ char *data;
double dummy;
}
d;
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 34e1484f749..a15cd914373 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -1270,7 +1270,10 @@ generic_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
saved by frames INTERIOR TO the current frame, we skip examining
the current frame itself: otherwise, we would be getting the
previous frame's registers which were saved by the current frame. */
-
+ if (frame)
+ {
+ struct symbol *sym = get_frame_function (frame);
+ }
while (frame && ((frame = frame->next) != NULL))
{
if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
@@ -1284,29 +1287,39 @@ generic_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
REGISTER_RAW_SIZE (regnum));
return;
}
-
- FRAME_INIT_SAVED_REGS (frame);
- if (frame->saved_regs != NULL
- && frame->saved_regs[regnum] != 0)
+#if 0
+ if (dwarf2_get_cfa_for_addr (frame->pc) != 0)
{
- if (lval) /* found it saved on the stack */
- *lval = lval_memory;
- if (regnum == SP_REGNUM)
- {
- if (raw_buffer) /* SP register treated specially */
- store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
- frame->saved_regs[regnum]);
- }
- else
- {
- if (addrp) /* any other register */
- *addrp = frame->saved_regs[regnum];
- if (raw_buffer)
- read_memory (frame->saved_regs[regnum], raw_buffer,
- REGISTER_RAW_SIZE (regnum));
- }
- return;
+ dwarf2_execute_cfa_program(frame);
+ }
+ else
+ {
+#endif
+ FRAME_INIT_SAVED_REGS (frame);
+#if 0
}
+#endif
+ if (frame->saved_regs != NULL
+ && frame->saved_regs[regnum] != 0)
+ {
+ if (lval) /* found it saved on the stack */
+ *lval = lval_memory;
+ if (regnum == SP_REGNUM)
+ {
+ if (raw_buffer) /* SP register treated specially */
+ store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
+ frame->saved_regs[regnum]);
+ }
+ else
+ {
+ if (addrp) /* any other register */
+ *addrp = frame->saved_regs[regnum];
+ if (raw_buffer)
+ read_memory (frame->saved_regs[regnum], raw_buffer,
+ REGISTER_RAW_SIZE (regnum));
+ }
+ return;
+ }
}
/* If we get thru the loop to this point, it means the register was
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ed152bede86..54dcdf8ba12 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -75,7 +75,6 @@ static void clear_command (char *, int);
static void catch_command (char *, int);
-static void handle_gnu_4_16_catch_command (char *, int, int);
static struct symtabs_and_lines get_catch_sals (int);
@@ -5754,184 +5753,6 @@ struct sal_chain
struct symtab_and_line sal;
};
-#if 0
-/* Not really used -- invocation in handle_gnu_4_16_catch_command
- had been commented out in the v.4.16 sources, and stays
- disabled there now because "catch NAME" syntax isn't allowed.
- pai/1997-07-11 */
-/* This isn't used; I don't know what it was for. */
-/* For each catch clause identified in ARGS, run FUNCTION
- with that clause as an argument. */
-static struct symtabs_and_lines
-map_catch_names (char *args, int (*function) ())
-{
- register char *p = args;
- register char *p1;
- struct symtabs_and_lines sals;
-#if 0
- struct sal_chain *sal_chain = 0;
-#endif
-
- if (p == 0)
- error_no_arg ("one or more catch names");
-
- sals.nelts = 0;
- sals.sals = NULL;
-
- while (*p)
- {
- p1 = p;
- /* Don't swallow conditional part. */
- if (p1[0] == 'i' && p1[1] == 'f'
- && (p1[2] == ' ' || p1[2] == '\t'))
- break;
-
- if (isalpha (*p1))
- {
- p1++;
- while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
- p1++;
- }
-
- if (*p1 && *p1 != ' ' && *p1 != '\t')
- error ("Arguments must be catch names.");
-
- *p1 = 0;
-#if 0
- if (function (p))
- {
- struct sal_chain *next = (struct sal_chain *)
- alloca (sizeof (struct sal_chain));
- next->next = sal_chain;
- next->sal = get_catch_sal (p);
- sal_chain = next;
- goto win;
- }
-#endif
- printf_unfiltered ("No catch clause for exception %s.\n", p);
-#if 0
- win:
-#endif
- p = p1;
- while (*p == ' ' || *p == '\t')
- p++;
- }
-}
-#endif
-
-/* This shares a lot of code with `print_frame_label_vars' from stack.c. */
-
-static struct symtabs_and_lines
-get_catch_sals (int this_level_only)
-{
- register struct blockvector *bl;
- register struct block *block;
- int index, have_default = 0;
- CORE_ADDR pc;
- struct symtabs_and_lines sals;
- struct sal_chain *sal_chain = 0;
- char *blocks_searched;
-
- /* Not sure whether an error message is always the correct response,
- but it's better than a core dump. */
- if (selected_frame == NULL)
- error ("No selected frame.");
- block = get_frame_block (selected_frame);
- pc = selected_frame->pc;
-
- sals.nelts = 0;
- sals.sals = NULL;
-
- if (block == 0)
- error ("No symbol table info available.\n");
-
- bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
- blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
- memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
-
- while (block != 0)
- {
- CORE_ADDR end = BLOCK_END (block) - 4;
- int last_index;
-
- if (bl != blockvector_for_pc (end, &index))
- error ("blockvector blotch");
- if (BLOCKVECTOR_BLOCK (bl, index) != block)
- error ("blockvector botch");
- last_index = BLOCKVECTOR_NBLOCKS (bl);
- index += 1;
-
- /* Don't print out blocks that have gone by. */
- while (index < last_index
- && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
- index++;
-
- while (index < last_index
- && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
- {
- if (blocks_searched[index] == 0)
- {
- struct block *b = BLOCKVECTOR_BLOCK (bl, index);
- int nsyms;
- register int i;
- register struct symbol *sym;
-
- nsyms = BLOCK_NSYMS (b);
-
- for (i = 0; i < nsyms; i++)
- {
- sym = BLOCK_SYM (b, i);
- if (STREQ (SYMBOL_NAME (sym), "default"))
- {
- if (have_default)
- continue;
- have_default = 1;
- }
- if (SYMBOL_CLASS (sym) == LOC_LABEL)
- {
- struct sal_chain *next = (struct sal_chain *)
- alloca (sizeof (struct sal_chain));
- next->next = sal_chain;
- next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym),
- 0);
- sal_chain = next;
- }
- }
- blocks_searched[index] = 1;
- }
- index++;
- }
- if (have_default)
- break;
- if (sal_chain && this_level_only)
- break;
-
- /* After handling the function's top-level block, stop.
- Don't continue to its superblock, the block of
- per-file symbols. */
- if (BLOCK_FUNCTION (block))
- break;
- block = BLOCK_SUPERBLOCK (block);
- }
-
- if (sal_chain)
- {
- struct sal_chain *tmp_chain;
-
- /* Count the number of entries. */
- for (index = 0, tmp_chain = sal_chain; tmp_chain;
- tmp_chain = tmp_chain->next)
- index++;
-
- sals.nelts = index;
- sals.sals = (struct symtab_and_line *)
- xmalloc (index * sizeof (struct symtab_and_line));
- for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
- sals.sals[index] = sal_chain->sal;
- }
-
- return sals;
-}
static void
ep_skip_leading_whitespace (char **s)
@@ -6276,7 +6097,6 @@ catch_exception_command_1 (enum exception_event_kind ex_event, char *arg,
Try GNU C++ exception breakpoints using labels in debug info. */
if (ex_event == EX_EVENT_CATCH)
{
- handle_gnu_4_16_catch_command (arg, tempflag, from_tty);
}
else if (ex_event == EX_EVENT_THROW)
{
@@ -6308,108 +6128,6 @@ cover_target_enable_exception_callback (PTR arg)
-/* This is the original v.4.16 and earlier version of the
- catch_command_1() function. Now that other flavours of "catch"
- have been introduced, and since exception handling can be handled
- in other ways (through target ops) also, this is used only for the
- GNU C++ exception handling system.
- Note: Only the "catch" flavour of GDB 4.16 is handled here. The
- "catch NAME" is now no longer allowed in catch_command_1(). Also,
- there was no code in GDB 4.16 for "catch throw".
-
- Called from catch_exception_command_1 () */
-
-
-static void
-handle_gnu_4_16_catch_command (char *arg, int tempflag, int from_tty)
-{
- /* First, translate ARG into something we can deal with in terms
- of breakpoints. */
-
- struct symtabs_and_lines sals;
- struct symtab_and_line sal;
- register struct expression *cond = 0;
- register struct breakpoint *b;
- char *save_arg;
- int i;
-
- INIT_SAL (&sal); /* initialize to zeroes */
-
- /* If no arg given, or if first arg is 'if ', all active catch clauses
- are breakpointed. */
-
- if (!arg || (arg[0] == 'i' && arg[1] == 'f'
- && (arg[2] == ' ' || arg[2] == '\t')))
- {
- /* Grab all active catch clauses. */
- sals = get_catch_sals (0);
- }
- else
- {
- /* Grab selected catch clauses. */
- error ("catch NAME not implemented");
-
-#if 0
- /* Not sure why this code has been disabled. I'm leaving
- it disabled. We can never come here now anyway
- since we don't allow the "catch NAME" syntax.
- pai/1997-07-11 */
-
- /* This isn't used; I don't know what it was for. */
- sals = map_catch_names (arg, catch_breakpoint);
-#endif
- }
-
- if (!sals.nelts)
- return;
-
- save_arg = arg;
- for (i = 0; i < sals.nelts; i++)
- {
- resolve_sal_pc (&sals.sals[i]);
-
- while (arg && *arg)
- {
- if (arg[0] == 'i' && arg[1] == 'f'
- && (arg[2] == ' ' || arg[2] == '\t'))
- cond = parse_exp_1 ((arg += 2, &arg),
- block_for_pc (sals.sals[i].pc), 0);
- else
- error ("Junk at end of arguments.");
- }
- arg = save_arg;
- }
-
- for (i = 0; i < sals.nelts; i++)
- {
- sal = sals.sals[i];
-
- if (from_tty)
- describe_other_breakpoints (sal.pc, sal.section);
-
- /* Important -- this is an ordinary breakpoint. For platforms
- with callback support for exceptions,
- create_exception_catchpoint() will create special bp types
- (bp_catch_catch and bp_catch_throw), and there is code in
- insert_breakpoints() and elsewhere that depends on that. */
- b = set_raw_breakpoint (sal, bp_breakpoint);
- set_breakpoint_count (breakpoint_count + 1);
- b->number = breakpoint_count;
-
- b->cond = cond;
- b->enable = enabled;
- b->disposition = tempflag ? del : donttouch;
-
- mention (b);
- }
-
- if (sals.nelts > 1)
- {
- warning ("Multiple breakpoints were set.");
- warning ("Use the \"delete\" command to delete unwanted breakpoints.");
- }
- xfree (sals.sals);
-}
#if 0
/* This creates a temporary internal breakpoint
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b62c3464d01..46222f05df4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1,6 +1,5 @@
/* Support routines for building symbol tables in GDB's internal format.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1986-2000 Free Software Foundation, Inc.
This file is part of GDB.
@@ -38,18 +37,20 @@
#include "expression.h" /* For "enum exp_opcode" used by... */
#include "language.h" /* For "longest_local_hex_string_custom" */
#include "bcache.h"
-#include "filenames.h" /* For DOSish file names */
+#include "demangle.h"
/* Ask buildsym.h to define the vars it normally declares `extern'. */
#define EXTERN
/**/
#include "buildsym.h" /* Our own declarations */
+#include "splay-tree.h"
#undef EXTERN
-
+static int block_id=0;
/* For cleanup_undefined_types and finish_global_stabs (somewhat
questionable--see comment where we call them). */
#include "stabsread.h"
+splay_tree symbolsplay = 0;
/* List of free `struct pending' structures for reuse. */
static struct pending *free_pendings;
@@ -79,7 +80,7 @@ struct complaint anon_block_end_complaint =
{"block end address 0x%lx less than block start address 0x%lx (patched it)", 0, 0};
struct complaint innerblock_complaint =
-{"inner block not inside outer block in %s", 0, 0};
+{"inner block (0x%lx-0x%lx) not inside outer block (0x%lx-0x%lx) in %s", 0, 0};
struct complaint innerblock_anon_complaint =
{"inner block (0x%lx-0x%lx) not inside outer block (0x%lx-0x%lx)", 0, 0};
@@ -173,7 +174,7 @@ really_free_pendings (PTR dummy)
for (next = free_pendings; next; next = next1)
{
next1 = next->next;
- xfree ((void *) next);
+ free ((void *) next);
}
free_pendings = NULL;
@@ -182,14 +183,14 @@ really_free_pendings (PTR dummy)
for (next = file_symbols; next != NULL; next = next1)
{
next1 = next->next;
- xfree ((void *) next);
+ free ((void *) next);
}
file_symbols = NULL;
for (next = global_symbols; next != NULL; next = next1)
{
next1 = next->next;
- xfree ((void *) next);
+ free ((void *) next);
}
global_symbols = NULL;
}
@@ -199,17 +200,6 @@ really_free_pendings (PTR dummy)
void
free_pending_blocks (void)
{
-#if 0 /* Now we make the links in the
- symbol_obstack, so don't free
- them. */
- struct pending_block *bnext, *bnext1;
-
- for (bnext = pending_blocks; bnext; bnext = bnext1)
- {
- bnext1 = bnext->next;
- xfree ((void *) bnext);
- }
-#endif
pending_blocks = NULL;
}
@@ -229,32 +219,76 @@ finish_block (struct symbol *symbol, struct pending **listhead,
struct pending_block *opblock;
register int i;
register int j;
-
+ unsigned int closest_size;
/* Count the length of the list of symbols. */
-
for (next = *listhead, i = 0;
next;
i += next->nsyms, next = next->next)
{
/* EMPTY */ ;
}
-
- block = (struct block *) obstack_alloc (&objfile->symbol_obstack,
- (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *))));
-
- /* Copy the symbols into the block. */
-
- BLOCK_NSYMS (block) = i;
+ /* If it's a block representing a function, we can't use a hash
+ table, or else the args will get out of order. */
+ if (symbol)
+ {
+ block = (struct block *) obstack_alloc (&objfile->symbol_obstack,
+ (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *))));
+
+ /* Copy the symbols into the block. */
+ BLOCK_NSYMS (block) = i;
+ }
+ /* Otherwise, use a hash table representation */
+ else
+ {
+ block = (struct block *) obstack_alloc (&objfile->symbol_obstack,
+ (sizeof (struct block) + ((((i - 1)/4)+1) * sizeof (struct symbol *))));
+ BLOCK_NBUCKETS (block) = (i/4) + 1;
+ for (j = 0; j < BLOCK_NBUCKETS (block); j++)
+ BLOCK_BUCKET (block, j) = 0;
+ }
+ BLOCK_ID (block) = block_id++;
for (next = *listhead; next; next = next->next)
{
for (j = next->nsyms - 1; j >= 0; j--)
{
- BLOCK_SYM (block, --i) = next->symbol[j];
+ splay_tree_node result;
+ struct block_splay_data *temp;
+ const char *symname;
+ SYMBOL_INIT_DEMANGLED_NAME (next->symbol[j], &objfile->symbol_obstack);
+ symname = SYMBOL_SOURCE_NAME (next->symbol[j]);
+ result = splay_tree_lookup (symbolsplay, (splay_tree_key) symname);
+ if (result != NULL)
+ {
+ temp = (struct block_splay_data *)result->value;
+ bitmap_set_bit (temp->blocks, BLOCK_ID (block));
+ }
+ else
+ {
+ temp = xmalloc (sizeof (struct block_splay_data));
+ temp->blocks = BITMAP_XMALLOC();
+ bitmap_set_bit (temp->blocks, BLOCK_ID (block));
+ splay_tree_insert (symbolsplay, (splay_tree_key)symname, (splay_tree_value) temp);
+ }
+ if (symbol)
+ {
+ BLOCK_SYM (block, --i) = next->symbol[j];
+ }
+ else
+ {
+ unsigned int hashval;
+ hashval = msymbol_hash_iw (symname) % BLOCK_NBUCKETS (block);
+ if (BLOCK_BUCKET (block, hashval) != NULL)
+ {
+ next->symbol[j]->hash_next = BLOCK_BUCKET (block, hashval);
+ }
+ BLOCK_BUCKET (block, hashval) = next->symbol[j];
+ }
}
}
-
+
BLOCK_START (block) = start;
BLOCK_END (block) = end;
+
/* Superblock filled in when containing block is made */
BLOCK_SUPERBLOCK (block) = NULL;
@@ -372,7 +406,10 @@ finish_block (struct symbol *symbol, struct pending **listhead,
}
else
{
- complain (&anon_block_end_complaint, BLOCK_END (block), BLOCK_START (block));
+ /* FIXME 32x64 */
+ complain (&anon_block_end_complaint,
+ (unsigned long) BLOCK_END (block),
+ (unsigned long) BLOCK_START (block));
}
/* Better than nothing */
BLOCK_END (block) = BLOCK_START (block);
@@ -396,18 +433,26 @@ finish_block (struct symbol *symbol, struct pending **listhead,
{
if (symbol)
{
+ /* FIXME 32x64 */
complain (&innerblock_complaint,
+ (unsigned long) BLOCK_START (pblock->block),
+ (unsigned long) BLOCK_END (pblock->block),
+ (unsigned long) BLOCK_START (block),
+ (unsigned long) BLOCK_END (block),
SYMBOL_SOURCE_NAME (symbol));
}
else
{
- complain (&innerblock_anon_complaint, BLOCK_START (pblock->block),
- BLOCK_END (pblock->block), BLOCK_START (block),
- BLOCK_END (block));
+ /* FIXME 32x64 */
+ complain (&innerblock_anon_complaint,
+ (unsigned long) BLOCK_START (pblock->block),
+ (unsigned long) BLOCK_END (pblock->block),
+ (unsigned long) BLOCK_START (block),
+ (unsigned long) BLOCK_END (block));
}
if (BLOCK_START (pblock->block) < BLOCK_START (block))
BLOCK_START (pblock->block) = BLOCK_START (block);
- if (BLOCK_END (pblock->block) > BLOCK_END (block))
+ if (BLOCK_END (pblock->block) > BLOCK_END (block))
BLOCK_END (pblock->block) = BLOCK_END (block);
}
#endif
@@ -447,6 +492,31 @@ record_pending_block (struct objfile *objfile, struct block *block,
}
}
+static int
+compare_blocks (const void *v1, const void *v2)
+{
+ const struct block *const *b1 = v1;
+ const struct block *const *b2 = v2;
+
+ if ((*b1)->startaddr < (*b2)->startaddr)
+ return -1;
+ else if ((*b1)->startaddr > (*b2)->startaddr)
+ return 1;
+ else if ((*b1)->endaddr < (*b2)->endaddr)
+ return 1;
+ else if ((*b1)->endaddr > (*b2)->endaddr)
+ return -1;
+ else
+ return 0;
+}
+
+static int
+compare_names (splay_tree_key v1, splay_tree_key v2)
+{
+ const char *b1 = (const char *)v1;
+ const char *b2 = (const char *)v2;
+ return (strcmp (b1, b2));
+}
/* Note that this is only used in this file and in dstread.c, which
should be fixed to not need direct access to this function. When
that is done, it can be made static again. */
@@ -481,37 +551,16 @@ make_blockvector (struct objfile *objfile)
BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
}
-#if 0 /* Now we make the links in the
- obstack, so don't free them. */
- /* Now free the links of the list, and empty the list. */
-
- for (next = pending_blocks; next; next = next1)
- {
- next1 = next->next;
- xfree (next);
- }
-#endif
pending_blocks = NULL;
-#if 1 /* FIXME, shut this off after a while
- to speed up symbol reading. */
- /* Some compilers output blocks in the wrong order, but we depend on
- their being in the right order so we can binary search. Check the
- order and moan about it. FIXME. */
- if (BLOCKVECTOR_NBLOCKS (blockvector) > 1)
+#if 1
+ if (objfile->flags & OBJF_REORDERED)
{
- for (i = 1; i < BLOCKVECTOR_NBLOCKS (blockvector); i++)
- {
- if (BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i - 1))
- > BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i)))
- {
- CORE_ADDR start
- = BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i));
-
- complain (&blockvector_complaint,
- longest_local_hex_string ((LONGEST) start));
- }
- }
+ if (BLOCKVECTOR_NBLOCKS (blockvector) > 2)
+ qsort (&blockvector->block[2],
+ BLOCKVECTOR_NBLOCKS (blockvector) - 2,
+ sizeof (struct block *),
+ compare_blocks);
}
#endif
@@ -533,7 +582,7 @@ start_subfile (char *name, char *dirname)
for (subfile = subfiles; subfile; subfile = subfile->next)
{
- if (FILENAME_CMP (subfile->name, name) == 0)
+ if (STREQ (subfile->name, name))
{
current_subfile = subfile;
return;
@@ -669,7 +718,7 @@ push_subfile (void)
subfile_stack = tem;
if (current_subfile == NULL || current_subfile->name == NULL)
{
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
+ error ("no entry to push onto subfile stack");
}
tem->name = current_subfile->name;
}
@@ -682,11 +731,11 @@ pop_subfile (void)
if (link == NULL)
{
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
+ error ("subfile stack empty");
}
name = link->name;
subfile_stack = link->next;
- xfree ((void *) link);
+ free ((void *) link);
return (name);
}
@@ -727,7 +776,7 @@ record_line (register struct subfile *subfile, int line, CORE_ADDR pc)
e = subfile->line_vector->item + subfile->line_vector->nitems++;
e->line = line;
- e->pc = ADDR_BITS_REMOVE(pc);
+ e->pc = pc;
}
/* Needed in order to sort line tables from IBM xcoff files. Sigh! */
@@ -821,6 +870,7 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
finish_block (cstk->name, &local_symbols, cstk->old_blocks,
cstk->start_addr, end_addr, objfile);
+
if (context_stack_depth > 0)
{
/* This is said to happen with SCO. The old coffread.c
@@ -835,38 +885,6 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
}
}
- /* Reordered executables may have out of order pending blocks; if
- OBJF_REORDERED is true, then sort the pending blocks. */
- if ((objfile->flags & OBJF_REORDERED) && pending_blocks)
- {
- /* FIXME! Remove this horrid bubble sort and use merge sort!!! */
- int swapped;
- do
- {
- struct pending_block *pb, *pbnext;
-
- pb = pending_blocks;
- pbnext = pb->next;
- swapped = 0;
-
- while (pbnext)
- {
- /* swap blocks if unordered! */
-
- if (BLOCK_START (pb->block) < BLOCK_START (pbnext->block))
- {
- struct block *tmp = pb->block;
- pb->block = pbnext->block;
- pbnext->block = tmp;
- swapped = 1;
- }
- pb = pbnext;
- pbnext = pbnext->next;
- }
- }
- while (swapped);
- }
-
/* Cleanup any undefined types that have been left hanging around
(this needs to be done before the finish_blocks so that
file_symbols is still good).
@@ -891,12 +909,9 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
}
else
{
- /* Define the STATIC_BLOCK & GLOBAL_BLOCK, and build the
- blockvector. */
- finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr,
- objfile);
- finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr,
- objfile);
+ /* Define STATIC_BLOCK and GLOBAL_BLOCK and build the blockvector. */
+ finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr, objfile);
+ finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr, objfile);
blockvector = make_blockvector (objfile);
}
@@ -921,14 +936,6 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
{
linetablesize = sizeof (struct linetable) +
subfile->line_vector->nitems * sizeof (struct linetable_entry);
-#if 0
- /* I think this is artifact from before it went on the
- obstack. I doubt we'll need the memory between now
- and when we free it later in this function. */
- /* First, shrink the linetable to make more memory. */
- subfile->line_vector = (struct linetable *)
- xrealloc ((char *) subfile->line_vector, linetablesize);
-#endif
/* Like the pending blocks, the line table may be
scrambled in reordered executables. Sort it if
@@ -995,23 +1002,23 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
}
if (subfile->name != NULL)
{
- xfree ((void *) subfile->name);
+ free ((void *) subfile->name);
}
if (subfile->dirname != NULL)
{
- xfree ((void *) subfile->dirname);
+ free ((void *) subfile->dirname);
}
if (subfile->line_vector != NULL)
{
- xfree ((void *) subfile->line_vector);
+ free ((void *) subfile->line_vector);
}
if (subfile->debugformat != NULL)
{
- xfree ((void *) subfile->debugformat);
+ free ((void *) subfile->debugformat);
}
nextsub = subfile->next;
- xfree ((void *) subfile);
+ free ((void *) subfile);
}
/* Set this for the main source file. */
@@ -1123,3 +1130,11 @@ buildsym_new_init (void)
{
buildsym_init ();
}
+
+void
+_initialize_buildsym (void)
+{
+ symbolsplay = splay_tree_new (compare_names,
+ NULL,
+ (splay_tree_delete_value_fn)free);
+}
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 40a339deae7..f9ef5f18e5c 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -1,6 +1,5 @@
/* Build symbol tables in GDB's internal format.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1996,
- 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1986-1993, 1996-1999 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 226fb816711..d7dd0c1757a 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1,6 +1,5 @@
/* YACC parser for C expressions, for GDB.
- Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 1998, 1999, 2000
+ Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1996, 1997
Free Software Foundation, Inc.
This file is part of GDB.
@@ -49,9 +48,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h" /* Required by objfiles.h. */
#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
-
-/* Flag indicating we're dealing with HP-compiled objects */
-extern int hp_som_som_object_present;
+#include "inferior.h"
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
@@ -100,7 +97,7 @@ extern int hp_som_som_object_present;
#define yycheck c_yycheck
#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
+#define YYDEBUG 1 /* Default to no yydebug support */
#endif
int yyparse (void);
@@ -650,7 +647,7 @@ variable: qualified_name
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
+ (struct type *) make_function_type (NULL, builtin_type_int, 0, NULL, 0),
builtin_type_int);
}
else
@@ -706,7 +703,7 @@ variable: name_not_typename
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
+ (struct type *)make_function_type (NULL, builtin_type_int, 0, NULL, 0),
builtin_type_int);
}
else if (!have_full_symbols () && !have_partial_symbols ())
@@ -1212,7 +1209,7 @@ yylex ()
return tokentab2[i].token;
}
- switch (c = *tokstart)
+ switch ( (c = *tokstart))
{
case 0:
return 0;
@@ -1544,6 +1541,98 @@ yylex ()
/* Only do it if not inside single quotes */
sym_class = parse_nested_classes_for_hpacc (yylval.sval.ptr, yylval.sval.length,
&token_string, &class_prefix, &lexptr);
+
+ /* Some compilers generate a fully qualified name for a nested
+ class. If the program counter is inside a nested class, no sym_class
+ can be found for an expression like 'inner::x' as the full class name
+ is like 'outer::inner'.
+
+ If the program counter is within a function of a nested class,
+ construct an expression as 'outer::inner::x' to find the sym_class.
+ */
+ if (!sym_class && (*lexptr == ':') && (*(lexptr+1) == ':'))
+ {
+ char * symname, * last_colon;
+ int fieldlen, tokenlen;
+
+ symname = 0;
+
+ /* Find the symbol name that can used to construct a full name. */
+ if (yylval.ssym.sym != 0 &&
+ (SYMBOL_CLASS (yylval.ssym.sym) == LOC_ARG ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_LOCAL ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_STATIC ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_LOCAL_ARG ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_REGISTER))
+ {
+ /* The previous token is a local variable or parameter. Use its
+ type name to construct a full name. */
+ symname = TYPE_TAG_NAME(SYMBOL_TYPE(yylval.ssym.sym));
+ }
+ else
+ {
+ /* Use the function name of the current program counter to
+ construct a full name. */
+ struct symbol * sym = find_pc_function(read_pc());
+ if (sym)
+ symname = SYMBOL_DEMANGLED_NAME(sym);
+ }
+
+ /* Find the last colon of yylval.sval.ptr. */
+ last_colon = strrchr(yylval.sval.ptr, ':');
+
+ /* If the symbol name is 'outer::inner::func', we need to check
+ if yylval.sval.ptr points to 'inner::x'. I.e., the symbol name
+ and yylval.sval.ptr must have a common nested class name 'inner'.
+ must have a common class name 'inner'.
+ */
+ if (symname != 0 && *(--last_colon) == ':')
+ {
+ boolean found = false;
+ char *cur_index, *fullname_index, *i;
+ tokenlen = strlen(yylval.sval.ptr);
+ /* Calculate the length of the field, e.g., ::x. */
+ fieldlen = tokenlen - (last_colon - yylval.sval.ptr);
+
+
+ /*Set the full name index to the beginning to the symbol name.*/
+ fullname_index = symname;
+
+ /* Search for the name after each '::' until a match is found. */
+ for (cur_index = symname; !found && cur_index;)
+ {
+ /* Search for "::". */
+ cur_index = strstr (cur_index, "::");
+
+ /* Move the index after "::'. */
+ if (cur_index)
+ {
+ cur_index += 2;
+
+ /* Compare the nested class names. */
+ if (!strncmp (cur_index, yylval.sval.ptr,
+ tokenlen - fieldlen))
+ {
+ /* Reconstruct the fully qualified name. */
+ char *fullname = alloca (strlen (symname) + fieldlen);
+
+ /* Copy 'outer::' to the full name. */
+ strncpy (fullname, fullname_index,
+ (cur_index - fullname_index));
+ fullname[cur_index - fullname_index] = '\0';
+
+ /* Append 'inner::x' to the full name. */
+ strcat (fullname, yylval.sval.ptr);
+ sym_class = parse_nested_classes_for_hpacc (
+ fullname, strlen(fullname) - fieldlen,
+ &token_string, &class_prefix, &lexptr);
+ found = true;
+ }
+ }
+ }
+ }
+ }
+
if (sym_class)
{
/* Replace the current token with the bigger one we found */
@@ -1568,6 +1657,16 @@ yylex ()
current_language->la_language == language_cplus
? &is_a_field_of_this : (int *) NULL,
(struct symtab **) NULL);
+
+ /* If no symbol is found, and the symbol is within a class, try
+ to look for the symbol one more time without checking if the name
+ is a field of 'this'. */
+ if ((*lexptr == ':') && (*(lexptr+1) == ':') && !sym && sym_class)
+ sym = lookup_symbol (tmp, expression_context_block,
+ VAR_NAMESPACE,
+ (int *) NULL,
+ (struct symtab **) NULL);
+
/* Call lookup_symtab, not lookup_partial_symtab, in case there are
no psymtabs (coff, xcoff, or some future change to blow away the
psymtabs once once symbols are read). */
@@ -1660,6 +1759,9 @@ yylex ()
{
best_sym = cur_sym;
lexptr = p;
+
+ /* Update tmp to be used in the next iteration.*/
+ tmp = ncopy;
}
else
break;
@@ -1674,6 +1776,24 @@ yylex ()
break;
}
+ /* If the best symbol found contains '::', the previous token is
+ a local variable or parameter, and the type names of the current
+ and the best symbol do not match, return NAME. */
+ if (yylval.ssym.sym)
+ if (strstr (SYMBOL_NAME(best_sym), "::") != 0 &&
+ (TYPE_CODE (SYMBOL_TYPE (yylval.ssym.sym)) == TYPE_CODE_STRUCT) &&
+ (TYPE_CODE (SYMBOL_TYPE (best_sym)) == TYPE_CODE_STRUCT) &&
+ (SYMBOL_CLASS (yylval.ssym.sym) == LOC_ARG ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_LOCAL ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_STATIC ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_LOCAL_ARG ||
+ SYMBOL_CLASS (yylval.ssym.sym) == LOC_REGISTER) &&
+ strcmp (TYPE_TAG_NAME (SYMBOL_TYPE (yylval.ssym.sym)),
+ TYPE_TAG_NAME (SYMBOL_TYPE (best_sym))) != 0)
+ {
+ return NAME;
+ }
+
yylval.tsym.type = SYMBOL_TYPE (best_sym);
#else /* not 0 */
yylval.tsym.type = SYMBOL_TYPE (sym);
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 818125f8b00..2d1aa253ce0 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -232,9 +232,7 @@ c_create_fundamental_type (struct objfile *objfile, int typeid)
warning ("internal error: no C/C++ fundamental type %d", typeid);
break;
case FT_VOID:
- type = init_type (TYPE_CODE_VOID,
- TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0, "void", objfile);
+ type = builtin_type_void;
break;
case FT_BOOLEAN:
type = init_type (TYPE_CODE_BOOL,
@@ -243,80 +241,49 @@ c_create_fundamental_type (struct objfile *objfile, int typeid)
break;
case FT_CHAR:
- type = init_type (TYPE_CODE_INT,
- TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0, "char", objfile);
- TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN;
+ type = builtin_type_char;
break;
case FT_SIGNED_CHAR:
- type = init_type (TYPE_CODE_INT,
- TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0, "signed char", objfile);
+ type = builtin_type_signed_char;
break;
case FT_UNSIGNED_CHAR:
- type = init_type (TYPE_CODE_INT,
- TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED, "unsigned char", objfile);
+ type = builtin_type_unsigned_char;
break;
case FT_SHORT:
- type = init_type (TYPE_CODE_INT,
- TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- 0, "short", objfile);
+ type = builtin_type_short;
break;
case FT_SIGNED_SHORT:
- type = init_type (TYPE_CODE_INT,
- TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- 0, "short", objfile); /* FIXME-fnf */
+ type = builtin_type_short;
break;
case FT_UNSIGNED_SHORT:
- type = init_type (TYPE_CODE_INT,
- TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
+ type = builtin_type_unsigned_short;
break;
case FT_INTEGER:
- type = init_type (TYPE_CODE_INT,
- TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0, "int", objfile);
+ type = builtin_type_int;
break;
case FT_SIGNED_INTEGER:
- type = init_type (TYPE_CODE_INT,
- TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0, "int", objfile); /* FIXME -fnf */
+ type = builtin_type_int;
break;
case FT_UNSIGNED_INTEGER:
- type = init_type (TYPE_CODE_INT,
- TARGET_INT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
+ type = builtin_type_unsigned_int;
break;
case FT_LONG:
- type = init_type (TYPE_CODE_INT,
- TARGET_LONG_BIT / TARGET_CHAR_BIT,
- 0, "long", objfile);
+ type = builtin_type_long;
break;
case FT_SIGNED_LONG:
- type = init_type (TYPE_CODE_INT,
- TARGET_LONG_BIT / TARGET_CHAR_BIT,
- 0, "long", objfile); /* FIXME -fnf */
+ type = builtin_type_long;
break;
case FT_UNSIGNED_LONG:
- type = init_type (TYPE_CODE_INT,
- TARGET_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
+ type = builtin_type_unsigned_long;
break;
case FT_LONG_LONG:
- type = init_type (TYPE_CODE_INT,
- TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- 0, "long long", objfile);
+ type = builtin_type_long_long;
break;
case FT_SIGNED_LONG_LONG:
- type = init_type (TYPE_CODE_INT,
- TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- 0, "signed long long", objfile);
+ type = builtin_type_long_long;
break;
case FT_UNSIGNED_LONG_LONG:
- type = init_type (TYPE_CODE_INT,
- TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
+ type = builtin_type_unsigned_long_long;
break;
case FT_FLOAT:
type = init_type (TYPE_CODE_FLT,
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 789d5f0b2df..06ece5b0198 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -128,7 +128,7 @@ c_print_type (struct type *type, char *varstring, struct ui_file *stream,
static void
cp_type_print_derivation_info (struct ui_file *stream, struct type *type)
{
- char *name;
+ const char *name;
int i;
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
@@ -157,7 +157,7 @@ cp_type_print_method_args (struct type **args, char *prefix, char *varstring,
fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI);
fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI);
fputs_filtered ("(", stream);
- if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
+ if (args && args[!staticp] && TYPE_CODE(args[!staticp]) != TYPE_CODE_VOID)
{
i = !staticp; /* skip the class variable */
while (1)
@@ -168,7 +168,7 @@ cp_type_print_method_args (struct type **args, char *prefix, char *varstring,
fprintf_filtered (stream, " ...");
break;
}
- else if (args[i]->code != TYPE_CODE_VOID)
+ else if (TYPE_CODE(args[i]) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ", ");
}
@@ -197,7 +197,7 @@ void
c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
int show, int passed_a_ptr)
{
- char *name;
+ const char *name;
if (type == 0)
return;
@@ -209,7 +209,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
- c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
+ c_type_print_varspec_prefix (POINTER_TARGET_TYPE (type), stream, 0, 1);
fprintf_filtered (stream, "*");
c_type_print_cv_qualifier (type, stream, 1, 0);
break;
@@ -240,19 +240,19 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
break;
case TYPE_CODE_REF:
- c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
+ c_type_print_varspec_prefix (POINTER_TARGET_TYPE (type), stream, 0, 1);
fprintf_filtered (stream, "&");
c_type_print_cv_qualifier (type, stream, 1, 0);
break;
case TYPE_CODE_FUNC:
- c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
+ c_type_print_varspec_prefix (FUNCTION_RETURN_VALUE (type), stream, 0, 0);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
case TYPE_CODE_ARRAY:
- c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
+ c_type_print_varspec_prefix (ARRAY_ELEMENT_TYPE (type), stream, 0, 0);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
@@ -335,7 +335,7 @@ c_type_print_args (struct type *type, struct ui_file *stream)
{
fprintf_filtered (stream, "...");
}
- else if ((args[1]->code == TYPE_CODE_VOID) &&
+ else if ((TYPE_CODE(args[1]) == TYPE_CODE_VOID) &&
(current_language->la_language == language_cplus))
{
fprintf_filtered (stream, "void");
@@ -343,7 +343,7 @@ c_type_print_args (struct type *type, struct ui_file *stream)
else
{
for (i = 1;
- args[i] != NULL && args[i]->code != TYPE_CODE_VOID;
+ args[i] != NULL && TYPE_CODE(args[i]) != TYPE_CODE_VOID;
i++)
{
c_print_type (args[i], "", stream, -1, 0);
@@ -351,7 +351,7 @@ c_type_print_args (struct type *type, struct ui_file *stream)
{
fprintf_filtered (stream, "...");
}
- else if (args[i + 1]->code != TYPE_CODE_VOID)
+ else if (TYPE_CODE(args[i + 1]) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ",");
wrap_here (" ");
@@ -519,11 +519,10 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
fprintf_filtered (stream, ")");
fprintf_filtered (stream, "[");
- if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
- && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
+ if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (ARRAY_ELEMENT_TYPE (type)) > 0)
fprintf_filtered (stream, "%d",
(TYPE_LENGTH (type)
- / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
+ / TYPE_LENGTH (ARRAY_ELEMENT_TYPE (type))));
fprintf_filtered (stream, "]");
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
@@ -546,8 +545,10 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
break;
case TYPE_CODE_PTR:
+ c_type_print_varspec_suffix (POINTER_TARGET_TYPE (type), stream, 0, 1, 0);
+ break;
case TYPE_CODE_REF:
- c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
+ c_type_print_varspec_suffix (POINTER_TARGET_TYPE (type), stream, 0, 1, 0);
break;
case TYPE_CODE_FUNC:
@@ -555,7 +556,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
fprintf_filtered (stream, ")");
if (!demangled_args)
{
- int i, len = TYPE_NFIELDS (type);
+ int i, len = FUNCTION_NUM_ARGUMENTS (type);
fprintf_filtered (stream, "(");
if ((len == 0) && (current_language->la_language == language_cplus))
{
@@ -569,11 +570,11 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
fputs_filtered (", ", stream);
wrap_here (" ");
}
- c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
+ c_print_type (FUNCTION_ARGUMENT_TYPE (type, i), "", stream, -1, 0);
}
fprintf_filtered (stream, ")");
}
- c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+ c_type_print_varspec_suffix (FUNCTION_RETURN_VALUE (type), stream, 0,
passed_a_ptr, 0);
break;
@@ -664,12 +665,18 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
switch (TYPE_CODE (type))
{
- case TYPE_CODE_TYPEDEF:
- case TYPE_CODE_ARRAY:
case TYPE_CODE_PTR:
- case TYPE_CODE_MEMBER:
case TYPE_CODE_REF:
+ c_type_print_base (POINTER_TARGET_TYPE (type), stream, show, level);
+ break;
+ case TYPE_CODE_ARRAY:
+ c_type_print_base (ARRAY_ELEMENT_TYPE (type), stream, show, level);
+ break;
case TYPE_CODE_FUNC:
+ c_type_print_base (FUNCTION_RETURN_VALUE (type), stream, show, level);
+ break;
+ case TYPE_CODE_TYPEDEF:
+ case TYPE_CODE_MEMBER:
case TYPE_CODE_METHOD:
c_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
break;
@@ -683,13 +690,13 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
{
switch (TYPE_DECLARED_TYPE (type))
{
- case DECLARED_TYPE_CLASS:
+ case DT_class:
fprintf_filtered (stream, "class ");
break;
- case DECLARED_TYPE_UNION:
+ case DT_union:
fprintf_filtered (stream, "union ");
break;
- case DECLARED_TYPE_STRUCT:
+ case DT_struct:
fprintf_filtered (stream, "struct ");
break;
default:
@@ -757,8 +764,8 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
masquerading as a class, if all members are public, there's
no need for a "public:" label. */
- if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_CLASS) ||
- (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_TEMPLATE))
+ if ((TYPE_DECLARED_TYPE (type) == DT_class) ||
+ (TYPE_DECLARED_TYPE (type) == DT_template))
{
QUIT;
len = TYPE_NFIELDS (type);
@@ -786,8 +793,8 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
}
}
}
- else if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_STRUCT) ||
- (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION))
+ else if ((TYPE_DECLARED_TYPE (type) == DT_struct) ||
+ (TYPE_DECLARED_TYPE (type) == DT_union))
{
QUIT;
len = TYPE_NFIELDS (type);
@@ -899,7 +906,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
- char *name = type_name_no_tag (type);
+ const char *name = type_name_no_tag (type);
int is_constructor = name && STREQ (method_name, name);
for (j = 0; j < len2; j++)
{
@@ -1061,7 +1068,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
{
fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
+ len = ENUM_NUM_VALUES (type);
lastval = 0;
for (i = 0; i < len; i++)
{
@@ -1069,11 +1076,11 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- if (lastval != TYPE_FIELD_BITPOS (type, i))
+ fputs_filtered (ENUM_VALUE_NAME (type, i), stream);
+ if (lastval != ENUM_VALUE_VALUE (type, i))
{
- fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
- lastval = TYPE_FIELD_BITPOS (type, i);
+ fprintf_filtered (stream, " = %d", ENUM_VALUE_VALUE (type, i));
+ lastval = ENUM_VALUE_VALUE (type, i);
}
lastval++;
}
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index e1e8b8211b4..aa3dbc30c6a 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -80,8 +80,8 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
- if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
+ elttype = check_typedef (ARRAY_ELEMENT_TYPE (type));
+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (ARRAY_ELEMENT_TYPE (type)) > 0)
{
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
@@ -153,7 +153,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
print_function_pointer_address (addr, stream);
break;
}
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_METHOD)
{
cp_print_class_method (valaddr + embedded_offset, type, stream);
@@ -161,14 +161,14 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
else if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
{
cp_print_class_member (valaddr + embedded_offset,
- TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)),
+ TYPE_DOMAIN_TYPE (POINTER_TARGET_TYPE (type)),
stream, "&");
}
else
{
addr = unpack_pointer (type, valaddr + embedded_offset);
print_unpacked_pointer:
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
@@ -227,7 +227,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
}
else
{
- wtype = TYPE_TARGET_TYPE (type);
+ wtype = POINTER_TARGET_TYPE (type);
}
vt_val = value_at (wtype, vt_address, NULL);
val_print (VALUE_TYPE (vt_val), VALUE_CONTENTS (vt_val), 0,
@@ -253,7 +253,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
break;
case TYPE_CODE_REF:
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
{
cp_print_class_member (valaddr + embedded_offset,
@@ -277,7 +277,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
{
value_ptr deref_val =
value_at
- (TYPE_TARGET_TYPE (type),
+ (POINTER_TARGET_TYPE (type),
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset),
NULL);
@@ -311,8 +311,8 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
/* Print vtable entry - we only get here if NOT using
-fvtable_thunks. (Otherwise, look under TYPE_CODE_PTR.) */
int offset = (embedded_offset +
- TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8);
- struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET);
+ TYPE_FIELD_BITPOS (type, 2) / 8);
+ struct type *field_type = TYPE_FIELD_TYPE (type, 2);
CORE_ADDR addr
= extract_typed_address (valaddr + offset, field_type);
@@ -329,19 +329,19 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
break;
}
- len = TYPE_NFIELDS (type);
+ len = ENUM_NUM_VALUES (type);
val = unpack_long (type, valaddr + embedded_offset);
for (i = 0; i < len; i++)
{
QUIT;
- if (val == TYPE_FIELD_BITPOS (type, i))
+ if (val == ENUM_VALUE_VALUE (type, i))
{
break;
}
}
if (i < len)
{
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+ fputs_filtered (ENUM_VALUE_NAME (type, i), stream);
}
else
{
@@ -488,8 +488,8 @@ c_value_print (value_ptr val, struct ui_file *stream, int format,
type is indicated by the quoted string anyway. */
if (TYPE_CODE (type) == TYPE_CODE_PTR &&
TYPE_NAME (type) == NULL &&
- TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL &&
- STREQ (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char"))
+ TYPE_NAME (POINTER_TARGET_TYPE (type)) != NULL &&
+ STREQ (TYPE_NAME (POINTER_TARGET_TYPE (type)), "char"))
{
/* Print nothing */
}
@@ -503,7 +503,7 @@ c_value_print (value_ptr val, struct ui_file *stream, int format,
*/
value_ptr temparg;
temparg=value_copy(val);
- VALUE_TYPE (temparg) = lookup_pointer_type(TYPE_TARGET_TYPE(type));
+ VALUE_TYPE (temparg) = lookup_pointer_type (POINTER_TARGET_TYPE (type));
val=temparg;
}
/* Pointer to class, check real type of object */
diff --git a/gdb/ch-exp.c b/gdb/ch-exp.c
index c5d2fdaab35..89c5bff6103 100644
--- a/gdb/ch-exp.c
+++ b/gdb/ch-exp.c
@@ -567,18 +567,18 @@ parse_tuple_element (struct type *type)
if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
/* do this as a range from low to high */
- struct type *range_type = TYPE_FIELD_TYPE (type, 0);
+ struct range_type *range_type = ARRAY_RANGE_TYPE (type);
LONGEST low_bound, high_bound;
- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
- error ("cannot determine bounds for (*)");
+ low_bound = RANGE_LOWER_BOUND (range_type);
+ high_bound = RANGE_UPPER_BOUND (range_type);
/* lower bound */
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (range_type);
+ write_exp_elt_type ((struct type *)range_type);
write_exp_elt_longcst (low_bound);
write_exp_elt_opcode (OP_LONG);
/* upper bound */
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (range_type);
+ write_exp_elt_type ((struct type *)range_type);
write_exp_elt_longcst (high_bound);
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (BINOP_RANGE);
@@ -709,6 +709,7 @@ parse_primval (void)
FORWARD_TOKEN ();
break;
case ARRAY:
+#if TYPEFIX
FORWARD_TOKEN ();
/* This is pseudo-Chill, similar to C's '(TYPE[])EXPR'
which casts to an artificial array. */
@@ -724,10 +725,11 @@ parse_primval (void)
type = create_array_type ((struct type *) NULL, type,
create_range_type ((struct type *) NULL,
builtin_type_int, 0, 0));
- TYPE_ARRAY_UPPER_BOUND_TYPE (type) = BOUND_CANNOT_BE_DETERMINED;
+ TYPE_ARRAY_UPPER_BOUND_TYPE (type) = BT_cannot_be_determined;
write_exp_elt_opcode (UNOP_CAST);
write_exp_elt_type (type);
write_exp_elt_opcode (UNOP_CAST);
+#endif
break;
#if 0
case CONST:
diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c
index fb6dc419e83..e6d06fa0548 100644
--- a/gdb/ch-lang.c
+++ b/gdb/ch-lang.c
@@ -224,51 +224,45 @@ chill_printstr (struct ui_file *stream, char *string, unsigned int length,
static struct type *
chill_create_fundamental_type (struct objfile *objfile, int typeid)
{
+
register struct type *type = NULL;
switch (typeid)
{
default:
- /* FIXME: For now, if we are asked to produce a type not in this
- language, create the equivalent of a C integer type with the
- name "<?type?>". When all the dust settles from the type
- reconstruction work, this should probably become an error. */
- type = init_type (TYPE_CODE_INT, 2, 0, "<?type?>", objfile);
warning ("internal error: no chill fundamental type %d", typeid);
+ type = NULL;
break;
case FT_VOID:
- /* FIXME: Currently the GNU Chill compiler emits some DWARF entries for
- typedefs, unrelated to anything directly in the code being compiled,
- that have some FT_VOID types. Just fake it for now. */
- type = init_type (TYPE_CODE_VOID, 0, 0, "<?VOID?>", objfile);
+ type = (struct type *) make_void_type (objfile, "VOID");
break;
case FT_BOOLEAN:
- type = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED, "BOOL", objfile);
+ type = (struct type *) make_boolean_type (objfile, "BOOL");
break;
case FT_CHAR:
- type = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED, "CHAR", objfile);
+ type = (struct type *) make_character_type (objfile, "CHAR", 1, ST_unsigned);
break;
case FT_SIGNED_CHAR:
- type = init_type (TYPE_CODE_INT, 1, 0, "BYTE", objfile);
+ type = (struct type *) make_integer_type (objfile, "BYTE", 1, ST_signed);
break;
case FT_UNSIGNED_CHAR:
- type = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, "UBYTE", objfile);
+ type = (struct type *) make_integer_type (objfile, "UBYTE", 1, ST_unsigned);
break;
case FT_SHORT: /* Chill ints are 2 bytes */
- type = init_type (TYPE_CODE_INT, 2, 0, "INT", objfile);
+ type = (struct type *) make_integer_type (objfile, "INT", 2, ST_signed);
break;
case FT_UNSIGNED_SHORT: /* Chill ints are 2 bytes */
- type = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, "UINT", objfile);
+ type = (struct type *) make_integer_type (objfile, "UINT", 2, ST_unsigned);
break;
case FT_INTEGER: /* FIXME? */
case FT_SIGNED_INTEGER: /* FIXME? */
case FT_LONG: /* Chill longs are 4 bytes */
case FT_SIGNED_LONG: /* Chill longs are 4 bytes */
- type = init_type (TYPE_CODE_INT, 4, 0, "LONG", objfile);
+ type = (struct type *) make_integer_type (objfile, "LONG", 4, ST_signed);
break;
case FT_UNSIGNED_INTEGER: /* FIXME? */
case FT_UNSIGNED_LONG: /* Chill longs are 4 bytes */
- type = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, "ULONG", objfile);
+ type = (struct type *) make_integer_type (objfile, "ULONG", 4, ST_unsigned);
break;
case FT_FLOAT:
type = init_type (TYPE_CODE_FLT, 4, 0, "REAL", objfile);
@@ -351,26 +345,33 @@ type_lower_upper (enum exp_opcode op, /* Either UNOP_LOWER or UNOP_UPPER */
if (chill_varying_type (type))
return type_lower_upper (op, TYPE_FIELD_TYPE (type, 1), result_type);
break;
- case TYPE_CODE_ARRAY:
+ /* TYPEFIX - Check if bitstring is really *always a set* */
case TYPE_CODE_BITSTRING:
+ type = (struct type *) SET_RANGE_TYPE (type);
+ /* ... fall through ... */
+ case TYPE_CODE_ARRAY:
case TYPE_CODE_STRING:
- type = TYPE_FIELD_TYPE (type, 0); /* Get index type */
+ type = (struct type *) ARRAY_RANGE_TYPE (type); /* Get index type */
/* ... fall through ... */
case TYPE_CODE_RANGE:
- *result_type = TYPE_TARGET_TYPE (type);
- return op == UNOP_LOWER ? TYPE_LOW_BOUND (type) : TYPE_HIGH_BOUND (type);
+ *result_type = RANGE_INDEX_TYPE (type);
+ return op == UNOP_LOWER ? RANGE_LOWER_BOUND (type) : RANGE_UPPER_BOUND (type);
case TYPE_CODE_ENUM:
case TYPE_CODE_BOOL:
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
+#if TYPEFIX
if (get_discrete_bounds (type, &low, &high) >= 0)
{
*result_type = type;
return op == UNOP_LOWER ? low : high;
}
break;
+#else
+ break;
+#endif
case TYPE_CODE_UNDEF:
case TYPE_CODE_PTR:
case TYPE_CODE_UNION:
@@ -423,14 +424,14 @@ value_chill_card (value_ptr val)
LONGEST tmp = 0;
struct type *type = VALUE_TYPE (val);
CHECK_TYPEDEF (type);
-
if (TYPE_CODE (type) == TYPE_CODE_SET)
{
- struct type *range_type = TYPE_INDEX_TYPE (type);
+ struct range_type *range_type = SET_RANGE_TYPE (type);
LONGEST lower_bound, upper_bound;
int i;
- get_discrete_bounds (range_type, &lower_bound, &upper_bound);
+ lower_bound = RANGE_LOWER_BOUND (range_type);
+ upper_bound = RANGE_UPPER_BOUND (range_type);
for (i = lower_bound; i <= upper_bound; i++)
if (value_bit_index (type, VALUE_CONTENTS (val), i) > 0)
tmp++;
@@ -446,17 +447,17 @@ value_chill_max_min (enum exp_opcode op, value_ptr val)
{
LONGEST tmp = 0;
struct type *type = VALUE_TYPE (val);
- struct type *elttype;
+ struct range_type *elttype;
CHECK_TYPEDEF (type);
-
if (TYPE_CODE (type) == TYPE_CODE_SET)
{
LONGEST lower_bound, upper_bound;
int i, empty = 1;
- elttype = TYPE_INDEX_TYPE (type);
- CHECK_TYPEDEF (elttype);
- get_discrete_bounds (elttype, &lower_bound, &upper_bound);
+ elttype = SET_RANGE_TYPE (type);
+ CHECK_TYPEDEF ((struct type *)elttype);
+ lower_bound = RANGE_LOWER_BOUND (elttype);
+ upper_bound = RANGE_UPPER_BOUND (elttype);
if (op == UNOP_CHMAX)
{
@@ -489,8 +490,8 @@ value_chill_max_min (enum exp_opcode op, value_ptr val)
error ("bad argument to %s builtin", op == UNOP_CHMAX ? "MAX" : "MIN");
return value_from_longest (TYPE_CODE (elttype) == TYPE_CODE_RANGE
- ? TYPE_TARGET_TYPE (elttype)
- : elttype,
+ ? (struct type *)RANGE_INDEX_TYPE (elttype)
+ : (struct type *)elttype,
tmp);
}
@@ -525,7 +526,7 @@ evaluate_subexp_chill (struct type *expect_type,
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
- type = check_typedef (TYPE_TARGET_TYPE (type));
+ type = check_typedef (POINTER_TARGET_TYPE (type));
if (!type || TYPE_CODE (type) != TYPE_CODE_FUNC)
error ("reference value used as function");
/* ... fall through ... */
@@ -539,10 +540,10 @@ evaluate_subexp_chill (struct type *expect_type,
argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2));
argvec[0] = arg1;
tem = 1;
- for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++)
+ for (; tem <= nargs && tem <= FUNCTION_NUM_ARGUMENTS (type); tem++)
{
argvec[tem]
- = evaluate_subexp_chill (TYPE_FIELD_TYPE (type, tem - 1),
+ = evaluate_subexp_chill (FUNCTION_ARGUMENT_TYPE (type, tem),
exp, pos, noside);
}
for (; tem <= nargs; tem++)
@@ -636,22 +637,10 @@ const struct language_defn chill_language_defn =
void
_initialize_chill_language (void)
{
- builtin_type_chill_bool =
- init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "BOOL", (struct objfile *) NULL);
- builtin_type_chill_char =
- init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "CHAR", (struct objfile *) NULL);
- builtin_type_chill_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
- 0,
- "LONG", (struct objfile *) NULL);
- builtin_type_chill_ulong =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "ULONG", (struct objfile *) NULL);
+ builtin_type_chill_bool = (struct type *) make_boolean_type (NULL, "BOOL");
+ builtin_type_chill_char = (struct type *) make_character_type (NULL, "CHAR", 1, ST_unsigned);
+ builtin_type_chill_long = (struct type *) make_integer_type (NULL, "LONG", TARGET_LONG_BIT / TARGET_CHAR_BIT, ST_signed);
+ builtin_type_chill_ulong = (struct type *) make_integer_type (NULL, "ULONG", TARGET_LONG_BIT / TARGET_CHAR_BIT, ST_unsigned);
builtin_type_chill_real =
init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
0,
diff --git a/gdb/ch-typeprint.c b/gdb/ch-typeprint.c
index 339dd0b32d3..7a64464e6de 100644
--- a/gdb/ch-typeprint.c
+++ b/gdb/ch-typeprint.c
@@ -68,7 +68,7 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
register int len;
register int i;
struct type *index_type;
- struct type *range_type;
+ struct range_type *range_type;
LONGEST low_bound;
LONGEST high_bound;
@@ -99,14 +99,14 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
break;
case TYPE_CODE_PTR:
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
+ if (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_VOID)
{
fprintf_filtered (stream,
TYPE_NAME (type) ? TYPE_NAME (type) : "PTR");
break;
}
fprintf_filtered (stream, "REF ");
- chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
+ chill_type_print_base (POINTER_TARGET_TYPE (type), stream, 0, level);
break;
case TYPE_CODE_BOOL:
@@ -120,14 +120,14 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
case TYPE_CODE_ARRAY:
fputs_filtered ("ARRAY (", stream);
- range_type = TYPE_FIELD_TYPE (type, 0);
+ range_type = ARRAY_RANGE_TYPE (type);
if (TYPE_CODE (range_type) != TYPE_CODE_RANGE)
- chill_print_type (range_type, "", stream, 0, level);
+ chill_print_type ((struct type *)range_type, "", stream, 0, level);
else
{
- index_type = TYPE_TARGET_TYPE (range_type);
- low_bound = TYPE_FIELD_BITPOS (range_type, 0);
- high_bound = TYPE_FIELD_BITPOS (range_type, 1);
+ index_type = RANGE_INDEX_TYPE (range_type);
+ low_bound = RANGE_LOWER_BOUND (range_type);
+ high_bound = RANGE_UPPER_BOUND (range_type);
print_type_scalar (index_type, low_bound, stream);
fputs_filtered (":", stream);
print_type_scalar (index_type, high_bound, stream);
@@ -140,17 +140,15 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
fprintf_filtered (stream, "BOOLS (%d)",
TYPE_FIELD_BITPOS (TYPE_FIELD_TYPE (type, 0), 1) + 1);
break;
-
case TYPE_CODE_SET:
fputs_filtered ("POWERSET ", stream);
- chill_print_type (TYPE_INDEX_TYPE (type), "", stream,
+ chill_print_type ((struct type *)SET_RANGE_TYPE (type), "", stream,
show - 1, 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);
+ range_type = ARRAY_RANGE_TYPE (type);
+ index_type = RANGE_INDEX_TYPE (range_type);
+ high_bound = RANGE_UPPER_BOUND (range_type);
fputs_filtered ("CHARS (", stream);
print_type_scalar (index_type, high_bound + 1, stream);
fputs_filtered (")", stream);
@@ -162,14 +160,14 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
break;
case TYPE_CODE_REF:
fprintf_filtered (stream, "/*LOC*/ ");
- chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ chill_type_print_base (POINTER_TARGET_TYPE (type), stream, show, level);
break;
case TYPE_CODE_FUNC:
fprintf_filtered (stream, "PROC (");
- len = TYPE_NFIELDS (type);
+ len = FUNCTION_NUM_ARGUMENTS (type);
for (i = 0; i < len; i++)
{
- struct type *param_type = TYPE_FIELD_TYPE (type, i);
+ struct type *param_type = FUNCTION_ARGUMENT_TYPE (type, i);
if (i > 0)
{
fputs_filtered (", ", stream);
@@ -177,7 +175,7 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
}
if (TYPE_CODE (param_type) == TYPE_CODE_REF)
{
- chill_type_print_base (TYPE_TARGET_TYPE (param_type),
+ chill_type_print_base (POINTER_TARGET_TYPE (param_type),
stream, 0, level);
fputs_filtered (" LOC", stream);
}
@@ -185,10 +183,10 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
chill_type_print_base (param_type, stream, show, level);
}
fprintf_filtered (stream, ")");
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+ if (TYPE_CODE (FUNCTION_RETURN_TYPE (type)) != TYPE_CODE_VOID)
{
fputs_filtered (" RETURNS (", stream);
- chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
+ chill_type_print_base (FUNCTION_RETURN_TYPE (type), stream, 0, level);
fputs_filtered (")", stream);
}
break;
@@ -281,9 +279,9 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
if (target == NULL)
target = builtin_type_long;
fputs_filtered (" (", stream);
- print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
+ print_type_scalar (target, RANGE_LOWER_BOUND (type), stream);
fputs_filtered (":", stream);
- print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
+ print_type_scalar (target, RANGE_UPPER_BOUND (type), stream);
fputs_filtered (")", stream);
}
break;
@@ -292,18 +290,18 @@ chill_type_print_base (struct type *type, struct ui_file *stream, int show,
{
register int lastval = 0;
fprintf_filtered (stream, "SET (");
- len = TYPE_NFIELDS (type);
+ len = ENUM_NUM_VALUES (type);
for (i = 0; i < len; i++)
{
QUIT;
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- if (lastval != TYPE_FIELD_BITPOS (type, i))
+ fputs_filtered (ENUM_VALUE_NAME (type, i), stream);
+ if (lastval != ENUM_VALUE_VALUE (type, i))
{
- fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
- lastval = TYPE_FIELD_BITPOS (type, i);
+ fprintf_filtered (stream, " = %d", ENUM_VALUE_VALUE (type, i));
+ lastval = ENUM_VALUE_VALUE (type, i);
}
lastval++;
}
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c
index 0a893eb79d6..ed84c950cab 100644
--- a/gdb/ch-valprint.c
+++ b/gdb/ch-valprint.c
@@ -205,7 +205,7 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (ARRAY_RANGE_TYPE (type)) > 0)
{
if (prettyprint_arrays)
{
@@ -286,7 +286,7 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
break;
}
addr = unpack_pointer (type, valaddr);
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
/* We assume a NULL pointer is all zeros ... */
if (addr == 0)
@@ -330,10 +330,9 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
null if we have "reached the end". */
return (i + (print_max && i != print_max));
break;
-
case TYPE_CODE_BITSTRING:
case TYPE_CODE_SET:
- elttype = TYPE_INDEX_TYPE (type);
+ elttype = (struct type *) SET_RANGE_TYPE (type);
CHECK_TYPEDEF (elttype);
if (TYPE_FLAGS (elttype) & TYPE_FLAG_STUB)
{
@@ -342,7 +341,7 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
break;
}
{
- struct type *range = elttype;
+ struct range_type *range = (struct range_type *) elttype;
LONGEST low_bound, high_bound;
int i;
int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING;
@@ -353,7 +352,9 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
else
fputs_filtered ("[", stream);
- i = get_discrete_bounds (range, &low_bound, &high_bound);
+ low_bound = RANGE_LOWER_BOUND (range);
+ high_bound = RANGE_UPPER_BOUND (range);
+ i = (low_bound < 0 || high_bound < 0) ? -1 : 0;
maybe_bad_bstring:
if (i < 0)
{
@@ -375,7 +376,7 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
{
if (need_comma)
fputs_filtered (", ", stream);
- chill_print_type_scalar (range, (LONGEST) i, stream);
+ chill_print_type_scalar ((struct type *)range, (LONGEST) i, stream);
need_comma = 1;
/* Look for a continuous range of true elements. */
@@ -386,7 +387,7 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
while (i + 1 <= high_bound
&& value_bit_index (type, valaddr, ++i))
j = i;
- chill_print_type_scalar (range, (LONGEST) j, stream);
+ chill_print_type_scalar ((struct type *)range, (LONGEST) j, stream);
}
}
}
@@ -397,7 +398,6 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
fputs_filtered ("]", stream);
}
break;
-
case TYPE_CODE_STRUCT:
if (chill_varying_type (type))
{
@@ -443,11 +443,11 @@ chill_val_print (struct type *type, char *valaddr, int embedded_offset,
/* De-reference the reference. */
if (deref_ref)
{
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF)
+ if (TYPE_CODE (POINTER_TARGET_TYPE (type)) != TYPE_CODE_UNDEF)
{
value_ptr deref_val =
value_at
- (TYPE_TARGET_TYPE (type),
+ (POINTER_TARGET_TYPE (type),
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr),
NULL);
@@ -573,7 +573,6 @@ chill_value_print (value_ptr val, struct ui_file *stream, int format,
/* If it is a pointer, indicate what it points to.
Print type also if it is a reference. */
-
if (TYPE_CODE (real_type) == TYPE_CODE_PTR ||
TYPE_CODE (real_type) == TYPE_CODE_REF)
{
@@ -582,10 +581,10 @@ chill_value_print (value_ptr val, struct ui_file *stream, int format,
if (TYPE_CODE (type) != TYPE_CODE_PTR || addr != 0)
{
int i;
- char *name = TYPE_NAME (type);
+ const char *name = TYPE_NAME (type);
if (name)
fputs_filtered (name, stream);
- else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
+ else if (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_VOID)
fputs_filtered ("PTR", stream);
else
{
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 60ef89640a8..c5ebf1b5c32 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1424,12 +1424,9 @@ patch_type (struct type *type, struct type *real_type)
TYPE_FIELDS (target) = (struct field *) TYPE_ALLOC (target, field_size);
memcpy (TYPE_FIELDS (target), TYPE_FIELDS (real_target), field_size);
-
if (TYPE_NAME (real_target))
{
- if (TYPE_NAME (target))
- xfree (TYPE_NAME (target));
- TYPE_NAME (target) = concat (TYPE_NAME (real_target), NULL);
+ TYPE_NAME (target) = TYPE_NAME (real_target);
}
}
@@ -1445,53 +1442,55 @@ patch_opaque_types (struct symtab *s)
/* Go through the per-file symbols only */
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
- for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--)
+ for (i = BLOCK_NBUCKETS (b) - 1; i >= 0; i--)
{
/* Find completed typedefs to use to fix opaque ones.
Remove syms from the chain when their types are stored,
but search the whole chain, as there may be several syms
from different files with the same name. */
- real_sym = BLOCK_SYM (b, i);
- if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF &&
- SYMBOL_NAMESPACE (real_sym) == VAR_NAMESPACE &&
- TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR &&
- TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
+ for (real_sym = BLOCK_BUCKET (b, i); real_sym; real_sym = real_sym->hash_next)
{
- register char *name = SYMBOL_NAME (real_sym);
- register int hash = hashname (name);
- register struct symbol *sym, *prev;
-
- prev = 0;
- for (sym = opaque_type_chain[hash]; sym;)
+ if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF &&
+ SYMBOL_NAMESPACE (real_sym) == VAR_NAMESPACE &&
+ TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR &&
+ TYPE_LENGTH (POINTER_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
{
- if (name[0] == SYMBOL_NAME (sym)[0] &&
- STREQ (name + 1, SYMBOL_NAME (sym) + 1))
+ register char *name = SYMBOL_NAME (real_sym);
+ register int hash = hashname (name);
+ register struct symbol *sym, *prev;
+
+ prev = 0;
+ for (sym = opaque_type_chain[hash]; sym;)
{
- if (prev)
- {
- SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
- }
- else
- {
- opaque_type_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
- }
-
- patch_type (SYMBOL_TYPE (sym), SYMBOL_TYPE (real_sym));
-
- if (prev)
+ if (name[0] == SYMBOL_NAME (sym)[0] &&
+ STREQ (name + 1, SYMBOL_NAME (sym) + 1))
{
- sym = SYMBOL_VALUE_CHAIN (prev);
+ if (prev)
+ {
+ SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
+ }
+ else
+ {
+ opaque_type_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
+ }
+
+ patch_type (SYMBOL_TYPE (sym), SYMBOL_TYPE (real_sym));
+
+ if (prev)
+ {
+ sym = SYMBOL_VALUE_CHAIN (prev);
+ }
+ else
+ {
+ sym = opaque_type_chain[hash];
+ }
}
else
{
- sym = opaque_type_chain[hash];
+ prev = sym;
+ sym = SYMBOL_VALUE_CHAIN (sym);
}
}
- else
- {
- prev = sym;
- sym = SYMBOL_VALUE_CHAIN (sym);
- }
}
}
}
@@ -1523,8 +1522,8 @@ process_coff_symbol (register struct coff_symbol *cs,
if (ISFCN (cs->c_type))
{
SYMBOL_VALUE (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- SYMBOL_TYPE (sym) =
- lookup_function_type (decode_function_type (cs, cs->c_type, aux));
+ SYMBOL_TYPE (sym) = (struct type *)
+ make_function_type (objfile, decode_function_type (cs, cs->c_type, aux), 0, NULL, 0);
SYMBOL_CLASS (sym) = LOC_BLOCK;
if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
@@ -1683,8 +1682,8 @@ process_coff_symbol (register struct coff_symbol *cs,
empty structured type, though; the forward references
work themselves out via the magic of coff_lookup_type. */
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR &&
- TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (sym))) == 0 &&
- TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (sym))) !=
+ TYPE_LENGTH (POINTER_TARGET_TYPE (SYMBOL_TYPE (sym))) == 0 &&
+ TYPE_CODE (POINTER_TARGET_TYPE (SYMBOL_TYPE (sym))) !=
TYPE_CODE_UNDEF)
{
register int i = hashname (SYMBOL_NAME (sym));
@@ -1741,13 +1740,15 @@ decode_type (register struct coff_symbol *cs, unsigned int c_type,
else if (ISFCN (c_type))
{
type = decode_type (cs, new_c_type, aux);
- type = lookup_function_type (type);
+ type = (struct type *) make_function_type (current_objfile, type, 0, NULL, 0);
+
}
else if (ISARY (c_type))
{
int i, n;
register unsigned short *dim;
- struct type *base_type, *index_type, *range_type;
+ struct type *base_type, *index_type;
+ struct range_type *range_type;
/* Define an array type. */
/* auxent refers to array, not base type */
@@ -1765,9 +1766,9 @@ decode_type (register struct coff_symbol *cs, unsigned int c_type,
base_type = decode_type (cs, new_c_type, aux);
index_type = lookup_fundamental_type (current_objfile, FT_INTEGER);
range_type =
- create_range_type ((struct type *) NULL, index_type, 0, n - 1);
- type =
- create_array_type ((struct type *) NULL, base_type, range_type);
+ make_range_type (current_objfile, index_type, 0, n - 1);
+ type = (struct type *)
+ make_array_type (current_objfile, base_type, range_type);
}
return type;
}
@@ -2158,10 +2159,10 @@ coff_read_enum_type (int index, int length, int lastsym)
if (syms == osyms)
break;
}
-
+#if FIXTYPE
if (unsigned_enum)
TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
-
+#endif
return type;
}
diff --git a/gdb/completer.c b/gdb/completer.c
index 19db617f9cd..917387de671 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -173,7 +173,6 @@ filename_completer (char *text, char *word)
#endif
return return_val;
}
-
/* Complete on locations, which might be of two possible forms:
file:line
diff --git a/gdb/config/powerpc/nm-linux.h b/gdb/config/powerpc/nm-linux.h
index f37c58cda4c..743513f84b0 100644
--- a/gdb/config/powerpc/nm-linux.h
+++ b/gdb/config/powerpc/nm-linux.h
@@ -30,6 +30,7 @@ extern int kernel_u_size (void);
#define U_REGS_OFFSET 0
+int ppc_register_u_addr (int ustart, int regnum);
#define REGISTER_U_ADDR(addr, blockend, regno) \
(addr) = ppc_register_u_addr ((blockend),(regno));
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index eb31270367e..42e6e5fbd04 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -20,6 +20,7 @@
#include "defs.h"
#include "value.h"
+#include "gdbcmd.h"
#include "cp-abi.h"
struct cp_abi_ops current_cp_abi;
@@ -60,6 +61,16 @@ is_operator_name (const char *name)
return (*current_cp_abi.is_operator_name) (name);
}
+int
+baseclass_offset (struct type *type, int index, value_ptr * arg1p,
+ char *valaddr, CORE_ADDR address, int offset)
+{
+ if ((current_cp_abi.baseclass_offset) == NULL)
+ error ("ABI doesn't define required function baseclass_offset");
+ return (*current_cp_abi.baseclass_offset) (type, index, arg1p, valaddr,
+ address, offset);
+}
+
value_ptr
value_virtual_fn_field (value_ptr * arg1p, struct fn_field * f, int j,
struct type * type, int offset)
@@ -97,3 +108,17 @@ switch_to_cp_abi (const char *short_name)
return 1;
}
+static void
+maintenance_print_cpabi (char *args, int from_tty)
+{
+ fprintf_unfiltered (gdb_stdout, "Current C++ ABI is %s (%s)\n%s\n",
+ current_cp_abi.shortname, current_cp_abi.longname,
+ current_cp_abi.doc);
+}
+void
+_initialize_cp_abi (void)
+{
+ add_cmd ("c++-abi", class_maintenance, maintenance_print_cpabi,
+ "Print out the current C++ ABI being used\n",
+ &maintenanceprintlist);
+}
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index bd5430d5a93..8b60180d314 100644
--- a/gdb/cp-abi.h
+++ b/gdb/cp-abi.h
@@ -146,6 +146,15 @@ struct cp_abi_ops
int j, struct type * type, int offset);
struct type *(*rtti_type) (value_ptr v, int *full, int *top,
int *using_enc);
+
+ /* Compute the offset of the INDEXth baseclass of class TYPE, for
+ value at VALADDR (in host) at ADDRESS (in target). The result
+ should be the offset of the baseclass value relative to the
+ ADDRESS. */
+ int (*baseclass_offset) (struct type * type, int index,
+ value_ptr * arg1p, char *valaddr,
+ CORE_ADDR address, int offset);
+
};
@@ -154,6 +163,8 @@ extern int num_cp_abis;
extern struct cp_abi_ops current_cp_abi;
extern int register_cp_abi (struct cp_abi_ops abi);
extern int switch_to_cp_abi (const char *short_name);
+extern int baseclass_offset (struct type *type, int index, value_ptr * arg1p,
+ char *valaddr, CORE_ADDR address, int offset);
#endif
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 6b01e0c60e6..0d62978a8cf 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -33,6 +33,7 @@
#include "gdb_string.h"
#include "c-lang.h"
#include "target.h"
+#include "cp-abi.h"
/* Indication of presence of HP-compiled object files */
extern int hp_som_som_object_present; /* defined in symtab.c */
@@ -187,7 +188,7 @@ const char hpacc_vtbl_ptr_type_name[] = "__vftyp";
int
cp_is_vtbl_ptr_type (struct type *type)
{
- char *typename = type_name_no_tag (type);
+ const char *typename = type_name_no_tag (type);
return (typename != NULL
&& (STREQ (typename, vtbl_ptr_name)
@@ -202,10 +203,10 @@ cp_is_vtbl_member (struct type *type)
{
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
- type = TYPE_TARGET_TYPE (type);
+ type = POINTER_TARGET_TYPE (type);
if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
- type = TYPE_TARGET_TYPE (type);
+ type = ARRAY_ELEMENT_TYPE (type);
if (TYPE_CODE (type) == TYPE_CODE_STRUCT /* if not using thunks */
|| TYPE_CODE (type) == TYPE_CODE_PTR) /* if using thunks */
{
@@ -520,7 +521,7 @@ cp_print_value (struct type *type, struct type *real_type, char *valaddr,
int boffset;
int skip;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
- char *basename = TYPE_NAME (baseclass);
+ const char *basename = TYPE_NAME (baseclass);
char *base_valaddr;
if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -537,46 +538,30 @@ cp_print_value (struct type *type, struct type *real_type, char *valaddr,
obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
}
-
- if (TYPE_HAS_VTABLE (type) && BASETYPE_VIA_VIRTUAL (type, i))
- {
- /* Assume HP/Taligent runtime convention */
- find_rt_vbase_offset (type, TYPE_BASECLASS (type, i),
- valaddr, offset, &boffset, &skip);
- if (skip >= 0)
- error ("Virtual base class offset not found from vtable while"
- " printing");
- base_valaddr = valaddr;
- }
- else
- {
- boffset = baseclass_offset (type, i,
- valaddr + offset,
- address + offset);
- skip = ((boffset == -1) || (boffset + offset) < 0) ? 1 : -1;
-
- if (BASETYPE_VIA_VIRTUAL (type, i))
+
+ boffset = baseclass_offset (type, i, NULL, valaddr + offset, address + offset, offset);
+ base_valaddr = valaddr;
+ skip = ((boffset == -1) || (boffset + offset) < 0) ? 1 : -1;
+
+ if (BASETYPE_VIA_VIRTUAL (type, i))
+ {
+ /* The virtual base class pointer might have been clobbered by the
+ user program. Make sure that it still points to a valid memory
+ location. */
+
+ if (boffset != -1 && ((boffset + offset) < 0 || (boffset + offset) >= TYPE_LENGTH (type)))
{
- /* The virtual base class pointer might have been
- clobbered by the user program. Make sure that it
- still points to a valid memory location. */
-
- if (boffset != -1
- && ((boffset + offset) < 0
- || (boffset + offset) >= TYPE_LENGTH (type)))
- {
- base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
- if (target_read_memory (address + boffset, base_valaddr,
- TYPE_LENGTH (baseclass)) != 0)
- skip = 1;
- }
- else
- base_valaddr = valaddr;
+ base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
+ if (target_read_memory (address + boffset, base_valaddr,
+ TYPE_LENGTH (baseclass)) != 0)
+ skip = 1;
}
- else
+ else
base_valaddr = valaddr;
}
-
+ else
+ base_valaddr = valaddr;
+
/* now do the printing */
if (pretty)
{
@@ -593,12 +578,12 @@ cp_print_value (struct type *type, struct type *real_type, char *valaddr,
if (skip >= 1)
fprintf_filtered (stream, "<invalid address>");
else
- cp_print_value_fields (baseclass, real_type, base_valaddr,
- offset + boffset, address, stream, format,
- recurse, pretty,
- ((struct type **)
- obstack_base (&dont_print_vb_obstack)),
+ {
+ cp_print_value_fields (baseclass, real_type, base_valaddr, offset + boffset, address,
+ stream, format, recurse, pretty,
+ (struct type **) obstack_base (&dont_print_vb_obstack),
0);
+ }
fputs_filtered (", ", stream);
flush_it:
@@ -711,7 +696,7 @@ cp_print_class_member (char *valaddr, struct type *domain,
}
if (i < len)
{
- char *name;
+ const char *name;
fprintf_filtered (stream, prefix);
name = type_name_no_tag (domain);
if (name)
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index 2a3c18b5c5a..06336fe4349 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -1017,8 +1017,8 @@ d10v_push_arguments (int nargs, value_ptr *args, CORE_ADDR sp,
then store */
long val = extract_signed_integer (contents, len);
len = 2;
- if (TYPE_TARGET_TYPE (type)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
+ if (POINTER_TARGET_TYPE (type)
+ && (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
{
/* function pointer */
val = d10v_convert_iaddr_to_raw (val);
@@ -1099,8 +1099,8 @@ d10v_extract_return_value (struct type *type, char regbuf[REGISTER_BYTES],
int len;
/* printf("RET: TYPE=%d len=%d r%d=0x%x\n",type->code, TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM, (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), REGISTER_RAW_SIZE (RET1_REGNUM))); */
if (TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_TARGET_TYPE (type)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
+ && POINTER_TARGET_TYPE (type)
+ && (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
{
/* pointer to function */
int num;
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index d3a1489bc81..ad555e165bc 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1020,6 +1020,12 @@ add_bincl_to_list (struct partial_symtab *pst, char *name, int instance)
next_bincl++->name = name;
}
+static struct symtab *
+find_corresponding_bincl_symtab (char *name, int instance)
+{
+ struct header_file_location *bincl;
+ return lookup_symtab (name);
+}
/* Given a name, value pair, find the corresponding
bincl in the list. Return the partial symtab associated
with that header_file_location. */
diff --git a/gdb/dstread.c b/gdb/dstread.c
index c3a73f064cd..167b1dfd842 100644
--- a/gdb/dstread.c
+++ b/gdb/dstread.c
@@ -1308,7 +1308,7 @@ process_dst_function (struct objfile *objfile, dst_rec_ptr_t entry, char *name,
{
ftype = create_new_type (objfile);
type->function_type = ftype;
- ftype->target_type = type;
+ FUNCTION_RETURN_VALUE (ftype) = type;
ftype->code = TYPE_CODE_FUNC;
}
SYMBOL_TYPE (sym) = type->function_type;
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a3ca771eef5..53be710a027 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8,6 +8,7 @@
Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
based on Fred Fish's (Cygnus Support) implementation of DWARF 1
support in dwarfread.c
+ Largely rewritten by Daniel Berlin (dan@cgsoftware.com)
This file is part of GDB.
@@ -41,44 +42,28 @@
#include "language.h"
#include "complaints.h"
#include "bcache.h"
+#include "frame.h"
#include <fcntl.h>
#include "gdb_string.h"
#include <sys/types.h>
-
+#include <search.h>
#ifndef DWARF2_REG_TO_REGNUM
#define DWARF2_REG_TO_REGNUM(REG) (REG)
#endif
-#if 0
-/* .debug_info header for a compilation unit
- Because of alignment constraints, this structure has padding and cannot
- be mapped directly onto the beginning of the .debug_info section. */
-typedef struct comp_unit_header
- {
- unsigned int length; /* length of the .debug_info
- contribution */
- unsigned short version; /* version number -- 2 for DWARF
- version 2 */
- unsigned int abbrev_offset; /* offset into .debug_abbrev section */
- unsigned char addr_size; /* byte size of an address -- 4 */
- }
-_COMP_UNIT_HEADER;
-#define _ACTUAL_COMP_UNIT_HEADER_SIZE 11
-#endif
-
/* .debug_pubnames header
Because of alignment constraints, this structure has padding and cannot
be mapped directly onto the beginning of the .debug_info section. */
typedef struct pubnames_header
- {
- unsigned int length; /* length of the .debug_pubnames
+{
+ unsigned int length; /* length of the .debug_pubnames
contribution */
- unsigned char version; /* version number -- 2 for DWARF
+ unsigned char version; /* version number -- 2 for DWARF
version 2 */
- unsigned int info_offset; /* offset into .debug_info section */
- unsigned int info_size; /* byte size of .debug_info section
+ unsigned int info_offset; /* offset into .debug_info section */
+ unsigned int info_size; /* byte size of .debug_info section
portion */
- }
+}
_PUBNAMES_HEADER;
#define _ACTUAL_PUBNAMES_HEADER_SIZE 13
@@ -86,15 +71,15 @@ _PUBNAMES_HEADER;
Because of alignment constraints, this structure has padding and cannot
be mapped directly onto the beginning of the .debug_info section. */
typedef struct aranges_header
- {
- unsigned int length; /* byte len of the .debug_aranges
+{
+ unsigned int length; /* byte len of the .debug_aranges
contribution */
- unsigned short version; /* version number -- 2 for DWARF
+ unsigned short version; /* version number -- 2 for DWARF
version 2 */
- unsigned int info_offset; /* offset into .debug_info section */
- unsigned char addr_size; /* byte size of an address */
- unsigned char seg_size; /* byte size of segment descriptor */
- }
+ unsigned int info_offset; /* offset into .debug_info section */
+ unsigned char addr_size; /* byte size of an address */
+ unsigned char seg_size; /* byte size of segment descriptor */
+}
_ARANGES_HEADER;
#define _ACTUAL_ARANGES_HEADER_SIZE 12
@@ -102,44 +87,46 @@ _ARANGES_HEADER;
Because of alignment constraints, this structure has padding and cannot
be mapped directly onto the beginning of the .debug_info section. */
typedef struct statement_prologue
- {
- unsigned int total_length; /* byte length of the statement
+{
+ unsigned int total_length; /* byte length of the statement
information */
- unsigned short version; /* version number -- 2 for DWARF
+ unsigned short version; /* version number -- 2 for DWARF
version 2 */
- unsigned int prologue_length; /* # bytes between prologue &
- stmt program */
- unsigned char minimum_instruction_length; /* byte size of
+ unsigned int prologue_length; /* # bytes between prologue &
+ stmt program */
+ unsigned char minimum_instruction_length; /* byte size of
smallest instr */
- unsigned char default_is_stmt; /* initial value of is_stmt
+ unsigned char default_is_stmt; /* initial value of is_stmt
register */
- char line_base;
- unsigned char line_range;
- unsigned char opcode_base; /* number assigned to first special
+ char line_base;
+ unsigned char line_range;
+ unsigned char opcode_base; /* number assigned to first special
opcode */
- unsigned char *standard_opcode_lengths;
- }
+ unsigned char *standard_opcode_lengths;
+}
_STATEMENT_PROLOGUE;
/* offsets and sizes of debugging sections */
-static file_ptr dwarf_info_offset;
-static file_ptr dwarf_abbrev_offset;
-static file_ptr dwarf_line_offset;
-static file_ptr dwarf_pubnames_offset;
-static file_ptr dwarf_aranges_offset;
-static file_ptr dwarf_loc_offset;
-static file_ptr dwarf_macinfo_offset;
-static file_ptr dwarf_str_offset;
-
-static unsigned int dwarf_info_size;
-static unsigned int dwarf_abbrev_size;
-static unsigned int dwarf_line_size;
-static unsigned int dwarf_pubnames_size;
-static unsigned int dwarf_aranges_size;
-static unsigned int dwarf_loc_size;
-static unsigned int dwarf_macinfo_size;
-static unsigned int dwarf_str_size;
+static file_ptr dwarf2_info_offset;
+static file_ptr dwarf2_abbrev_offset;
+static file_ptr dwarf2_line_offset;
+static file_ptr dwarf2_pubnames_offset;
+static file_ptr dwarf2_aranges_offset;
+static file_ptr dwarf2_loc_offset;
+static file_ptr dwarf2_macinfo_offset;
+static file_ptr dwarf2_str_offset;
+static file_ptr dwarf2_frame_offset;
+
+static unsigned int dwarf2_info_size;
+static unsigned int dwarf2_abbrev_size;
+static unsigned int dwarf2_line_size;
+static unsigned int dwarf2_pubnames_size;
+static unsigned int dwarf2_aranges_size;
+static unsigned int dwarf2_loc_size;
+static unsigned int dwarf2_macinfo_size;
+static unsigned int dwarf2_str_size;
+static unsigned int dwarf2_frame_size;
/* names of the debugging sections */
@@ -151,103 +138,103 @@ static unsigned int dwarf_str_size;
#define LOC_SECTION ".debug_loc"
#define MACINFO_SECTION ".debug_macinfo"
#define STR_SECTION ".debug_str"
+#define FRAME_SECTION ".debug_frame"
/* local data types */
/* The data in a compilation unit header, after target2host
translation, looks like this. */
struct comp_unit_head
- {
- unsigned long length;
- short version;
- unsigned int abbrev_offset;
- unsigned char addr_size;
- unsigned char signed_addr_p;
- unsigned int offset_size; /* size of file offsets; either 4 or 8 */
- unsigned int initial_length_size; /* size of the length field; either
- 4 or 12 */
- };
+{
+ unsigned long length;
+ short version;
+ unsigned int abbrev_offset;
+ unsigned char addr_size;
+ unsigned char signed_addr_p;
+ unsigned int offset_size; /* size of file offsets; either 4 or 8 */
+ unsigned int initial_length_size; /* size of the length field; either
+ 4 or 12 */
+};
/* The data in the .debug_line statement prologue looks like this. */
struct line_head
- {
- unsigned int total_length;
- unsigned short version;
- unsigned int prologue_length;
- unsigned char minimum_instruction_length;
- unsigned char default_is_stmt;
- int line_base;
- unsigned char line_range;
- unsigned char opcode_base;
- unsigned char *standard_opcode_lengths;
- };
+{
+ unsigned int total_length;
+ unsigned short version;
+ unsigned int prologue_length;
+ unsigned char minimum_instruction_length;
+ unsigned char default_is_stmt;
+ int line_base;
+ unsigned char line_range;
+ unsigned char opcode_base;
+ unsigned char *standard_opcode_lengths;
+};
/* When we construct a partial symbol table entry we only
need this much information. */
struct partial_die_info
- {
- enum dwarf_tag tag;
- unsigned char has_children;
- unsigned char is_external;
- unsigned char is_declaration;
- unsigned char has_type;
- unsigned int offset;
- unsigned int abbrev;
- char *name;
- int has_pc_info;
- CORE_ADDR lowpc;
- CORE_ADDR highpc;
- struct dwarf_block *locdesc;
- unsigned int language;
- char *sibling;
- };
+{
+ enum dwarf_tag tag;
+ unsigned char has_children;
+ unsigned char is_external;
+ unsigned char is_declaration;
+ unsigned char has_type;
+ unsigned int offset;
+ unsigned int abbrev;
+ char *name;
+ CORE_ADDR lowpc;
+ CORE_ADDR highpc;
+ struct dwarf2_block *locdesc;
+ unsigned int language;
+ char *sibling;
+};
/* This data structure holds the information of an abbrev. */
struct abbrev_info
- {
- unsigned int number; /* number identifying abbrev */
- enum dwarf_tag tag; /* dwarf tag */
- int has_children; /* boolean */
- unsigned int num_attrs; /* number of attributes */
- struct attr_abbrev *attrs; /* an array of attribute descriptions */
- struct abbrev_info *next; /* next in chain */
- };
+{
+ unsigned int number; /* number identifying abbrev */
+ enum dwarf_tag tag; /* dwarf tag */
+ int has_children; /* boolean */
+ unsigned int num_attrs; /* number of attributes */
+ struct attr_abbrev *attrs; /* an array of attribute descriptions */
+ struct abbrev_info *next; /* next in chain */
+};
struct attr_abbrev
- {
- enum dwarf_attribute name;
- enum dwarf_form form;
- };
+{
+ enum dwarf_attribute name;
+ enum dwarf_form form;
+};
/* This data structure holds a complete die structure. */
struct die_info
- {
- enum dwarf_tag tag; /* Tag indicating type of die */
- unsigned short has_children; /* Does the die have children */
- unsigned int abbrev; /* Abbrev number */
- unsigned int offset; /* Offset in .debug_info section */
- unsigned int num_attrs; /* Number of attributes */
- struct attribute *attrs; /* An array of attributes */
- struct die_info *next_ref; /* Next die in ref hash table */
- struct die_info *next; /* Next die in linked list */
- struct type *type; /* Cached type information */
- };
+{
+ enum dwarf_tag tag; /* Tag indicating type of die */
+ unsigned short has_children; /* Does the die have children */
+ unsigned int abbrev; /* Abbrev number */
+ unsigned int offset; /* Offset in .debug_info section */
+ unsigned int num_attrs; /* Number of attributes */
+ struct attribute *attrs; /* An array of attributes */
+ struct die_info *next_ref; /* Next die in ref hash table */
+ struct die_info *next; /* Next die in linked list */
+ struct type *type; /* Cached type information */
+};
/* Attributes have a name and a value */
struct attribute
+{
+ enum dwarf_attribute name;
+ enum dwarf_form form;
+ union
{
- enum dwarf_attribute name;
- enum dwarf_form form;
- union
- {
- char *str;
- struct dwarf_block *blk;
- unsigned long unsnd;
- long int snd;
- CORE_ADDR addr;
- }
- u;
- };
+ char *str;
+ struct dwarf2_block *blk;
+ unsigned long unsnd;
+ long int snd;
+ CORE_ADDR addr;
+ }
+ u;
+};
/* Get at parts of an attribute structure */
@@ -258,14 +245,20 @@ struct attribute
#define DW_ADDR(attr) ((attr)->u.addr)
/* Blocks are a bunch of untyped bytes. */
-struct dwarf_block
- {
- unsigned int size;
- char *data;
- };
+struct dwarf2_block
+{
+ unsigned int size;
+ char *data;
+};
+struct comp_unit_instance
+{
+ bfd *abfd;
+ int offset;
+ struct comp_unit_head cu_header;
+ int cu_header_offset;
-/* We only hold one compilation unit's abbrevs in
- memory at any one time. */
+ /* We only hold one compilation unit's abbrevs in
+ memory at any one time. */
#ifndef ABBREV_HASH_SIZE
#define ABBREV_HASH_SIZE 121
#endif
@@ -273,38 +266,41 @@ struct dwarf_block
#define ATTR_ALLOC_CHUNK 4
#endif
-static struct abbrev_info *dwarf2_abbrevs[ABBREV_HASH_SIZE];
+ struct abbrev_info *dwarf2_abbrevs[ABBREV_HASH_SIZE];
-/* A hash table of die offsets for following references. */
+ /* A hash table of die offsets for following references. */
#ifndef REF_HASH_SIZE
#define REF_HASH_SIZE 1021
#endif
-static struct die_info *die_ref_table[REF_HASH_SIZE];
+ struct die_info *die_ref_table[REF_HASH_SIZE];
-/* Obstack for allocating temporary storage used during symbol reading. */
-static struct obstack dwarf2_tmp_obstack;
-/* Offset to the first byte of the current compilation unit header,
- for resolving relative reference dies. */
-static unsigned int cu_header_offset;
-/* Allocate fields for structs, unions and enums in this size. */
+ /* Allocate fields for structs, unions and enums in this size. */
#ifndef DW_FIELD_ALLOC_CHUNK
#define DW_FIELD_ALLOC_CHUNK 4
#endif
-/* The language we are debugging. */
-static enum language cu_language;
-static const struct language_defn *cu_language_defn;
+ /* The language we are debugging. */
+ enum language cu_language;
+ const struct language_defn *cu_language_defn;
-/* Actually data from the sections. */
-static char *dwarf_info_buffer;
-static char *dwarf_abbrev_buffer;
-static char *dwarf_line_buffer;
+ struct comp_unit_instance *next;
+};
+
+#ifndef COMP_UNIT_HASH_SIZE
+#define COMP_UNIT_HASH_SIZE 121
+#endif
-/* A zeroed version of a partial die for initialization purposes. */
-static struct partial_die_info zeroed_partial_die;
+static struct comp_unit_instance *compilation_units[COMP_UNIT_HASH_SIZE];
+
+static struct obstack dwarf2_tmp_obstack;
+/* Actually data from the sections. */
+static char *dwarf2_info_buffer;
+static char *dwarf2_abbrev_buffer;
+static char *dwarf2_line_buffer;
+static char *dwarf2_frame_buffer;
/* The generic symbol table building routines have separate lists for
file scope symbols and all all other scopes (local scopes). So
@@ -363,35 +359,38 @@ static CORE_ADDR baseaddr; /* Add to each symbol value */
of symbols read from an object file. */
struct dwarf2_pinfo
- {
- /* Pointer to start of dwarf info buffer for the objfile. */
+{
+ /* Pointer to start of dwarf info buffer for the objfile. */
- char *dwarf_info_buffer;
+ char *dwarf2_info_buffer;
- /* Offset in dwarf_info_buffer for this compilation unit. */
+ /* Offset in dwarf2_info_buffer for this compilation unit. */
- unsigned long dwarf_info_offset;
+ unsigned long dwarf2_info_offset;
- /* Pointer to start of dwarf abbreviation buffer for the objfile. */
+ /* Pointer to start of dwarf abbreviation buffer for the objfile. */
- char *dwarf_abbrev_buffer;
+ char *dwarf2_abbrev_buffer;
- /* Size of dwarf abbreviation section for the objfile. */
+ /* Size of dwarf abbreviation section for the objfile. */
- unsigned int dwarf_abbrev_size;
+ unsigned int dwarf2_abbrev_size;
- /* Pointer to start of dwarf line buffer for the objfile. */
+ /* Pointer to start of dwarf line buffer for the objfile. */
- char *dwarf_line_buffer;
- };
+ char *dwarf2_line_buffer;
-#define PST_PRIVATE(p) ((struct dwarf2_pinfo *)(p)->read_symtab_private)
-#define DWARF_INFO_BUFFER(p) (PST_PRIVATE(p)->dwarf_info_buffer)
-#define DWARF_INFO_OFFSET(p) (PST_PRIVATE(p)->dwarf_info_offset)
-#define DWARF_ABBREV_BUFFER(p) (PST_PRIVATE(p)->dwarf_abbrev_buffer)
-#define DWARF_ABBREV_SIZE(p) (PST_PRIVATE(p)->dwarf_abbrev_size)
-#define DWARF_LINE_BUFFER(p) (PST_PRIVATE(p)->dwarf_line_buffer)
+ char *dwarf2_frame_buffer;
+
+};
+#define PST_PRIVATE(p) ((struct dwarf2_pinfo *)(p)->read_symtab_private)
+#define DWARF2_INFO_BUFFER(p) (PST_PRIVATE(p)->dwarf2_info_buffer)
+#define DWARF2_INFO_OFFSET(p) (PST_PRIVATE(p)->dwarf2_info_offset)
+#define DWARF2_ABBREV_BUFFER(p) (PST_PRIVATE(p)->dwarf2_abbrev_buffer)
+#define DWARF2_ABBREV_SIZE(p) (PST_PRIVATE(p)->dwarf2_abbrev_size)
+#define DWARF2_FRAME_BUFFER(p) (PST_PRIVATE(p)->dwarf2_frame_buffer)
+#define DWARF2_LINE_BUFFER(p) (PST_PRIVATE(p)->dwarf2_line_buffer)
/* Maintain an array of referenced fundamental types for the current
compilation unit being read. For DWARF version 1, we have to construct
the fundamental types on the fly, since no information about the
@@ -412,49 +411,49 @@ static int bits_per_byte = 8;
pass lists of data member fields and lists of member function fields
in an instance of a field_info structure, as defined below. */
struct field_info
+{
+ /* List of data member and baseclasses fields. */
+ struct nextfield
{
- /* List of data member and baseclasses fields. */
- struct nextfield
- {
- struct nextfield *next;
- int accessibility;
- int virtuality;
- struct field field;
- }
- *fields;
+ struct nextfield *next;
+ int accessibility;
+ int virtuality;
+ struct field field;
+ }
+ *fields;
- /* Number of fields. */
- int nfields;
+ /* Number of fields. */
+ int nfields;
- /* Number of baseclasses. */
- int nbaseclasses;
+ /* Number of baseclasses. */
+ int nbaseclasses;
- /* Set if the accesibility of one of the fields is not public. */
- int non_public_fields;
+ /* Set if the accesibility of one of the fields is not public. */
+ int non_public_fields;
- /* Member function fields array, entries are allocated in the order they
- are encountered in the object file. */
- struct nextfnfield
- {
- struct nextfnfield *next;
- struct fn_field fnfield;
- }
- *fnfields;
+ /* Member function fields array, entries are allocated in the order they
+ are encountered in the object file. */
+ struct nextfnfield
+ {
+ struct nextfnfield *next;
+ struct fn_field fnfield;
+ }
+ *fnfields;
- /* Member function fieldlist array, contains name of possibly overloaded
- member function, number of overloaded member functions and a pointer
- to the head of the member function field chain. */
- struct fnfieldlist
- {
- char *name;
- int length;
- struct nextfnfield *head;
- }
- *fnfieldlists;
+ /* Member function fieldlist array, contains name of possibly overloaded
+ member function, number of overloaded member functions and a pointer
+ to the head of the member function field chain. */
+ struct fnfieldlist
+ {
+ char *name;
+ int length;
+ struct nextfnfield *head;
+ }
+ *fnfieldlists;
- /* Number of entries in the fnfieldlists array. */
- int nfnfields;
- };
+ /* Number of entries in the fnfieldlists array. */
+ int nfnfields;
+};
/* FIXME: Kludge to mark a varargs function type for C++ member function
argument processing. */
@@ -469,88 +468,67 @@ struct field_info
/* Various complaints about symbol reading that don't abort the process */
-static struct complaint dwarf2_const_ignored =
-{
+static struct complaint dwarf2_const_ignored = {
"type qualifier 'const' ignored", 0, 0
};
-static struct complaint dwarf2_volatile_ignored =
-{
+static struct complaint dwarf2_volatile_ignored = {
"type qualifier 'volatile' ignored", 0, 0
};
-static struct complaint dwarf2_non_const_array_bound_ignored =
-{
+static struct complaint dwarf2_non_const_array_bound_ignored = {
"non-constant array bounds form '%s' ignored", 0, 0
};
-static struct complaint dwarf2_missing_line_number_section =
-{
+static struct complaint dwarf2_missing_line_number_section = {
"missing .debug_line section", 0, 0
};
-static struct complaint dwarf2_mangled_line_number_section =
-{
+static struct complaint dwarf2_mangled_line_number_section = {
"mangled .debug_line section", 0, 0
};
-static struct complaint dwarf2_unsupported_die_ref_attr =
-{
+static struct complaint dwarf2_unsupported_die_ref_attr = {
"unsupported die ref attribute form: '%s'", 0, 0
};
-static struct complaint dwarf2_unsupported_stack_op =
-{
+static struct complaint dwarf2_unsupported_stack_op = {
"unsupported stack op: '%s'", 0, 0
};
-static struct complaint dwarf2_complex_location_expr =
-{
+static struct complaint dwarf2_complex_location_expr = {
"location expression too complex", 0, 0
};
-static struct complaint dwarf2_unsupported_tag =
-{
+static struct complaint dwarf2_unsupported_tag = {
"unsupported tag: '%s'", 0, 0
};
-static struct complaint dwarf2_unsupported_at_encoding =
-{
+static struct complaint dwarf2_unsupported_at_encoding = {
"unsupported DW_AT_encoding: '%s'", 0, 0
};
-static struct complaint dwarf2_unsupported_at_frame_base =
-{
+static struct complaint dwarf2_unsupported_at_frame_base = {
"unsupported DW_AT_frame_base for function '%s'", 0, 0
};
-static struct complaint dwarf2_unexpected_tag =
-{
+static struct complaint dwarf2_unexpected_tag = {
"unexepected tag in read_type_die: '%s'", 0, 0
};
-static struct complaint dwarf2_missing_at_frame_base =
-{
+static struct complaint dwarf2_missing_at_frame_base = {
"DW_AT_frame_base missing for DW_OP_fbreg", 0, 0
};
-static struct complaint dwarf2_bad_static_member_name =
-{
+static struct complaint dwarf2_bad_static_member_name = {
"unrecognized static data member name '%s'", 0, 0
};
-static struct complaint dwarf2_unsupported_accessibility =
-{
+static struct complaint dwarf2_unsupported_accessibility = {
"unsupported accessibility %d", 0, 0
};
-static struct complaint dwarf2_bad_member_name_complaint =
-{
+static struct complaint dwarf2_bad_member_name_complaint = {
"cannot extract member name from '%s'", 0, 0
};
-static struct complaint dwarf2_missing_member_fn_type_complaint =
-{
+static struct complaint dwarf2_missing_member_fn_type_complaint = {
"member function type missing for '%s'", 0, 0
};
-static struct complaint dwarf2_vtbl_not_found_complaint =
-{
+static struct complaint dwarf2_vtbl_not_found_complaint = {
"virtual function table pointer not found when defining class '%s'", 0, 0
};
-static struct complaint dwarf2_absolute_sibling_complaint =
-{
+static struct complaint dwarf2_absolute_sibling_complaint = {
"ignoring absolute DW_AT_sibling", 0, 0
};
-static struct complaint dwarf2_const_value_length_mismatch =
-{
+static struct complaint dwarf2_const_value_length_mismatch = {
"const value length mismatch for '%s', got %d, expected %d", 0, 0
};
-static struct complaint dwarf2_unsupported_const_value_attr =
-{
+static struct complaint dwarf2_unsupported_const_value_attr = {
"unsupported const value attribute form: '%s'", 0, 0
};
@@ -561,18 +539,16 @@ extern int info_verbose; /* From main.c; nonzero => verbose */
static void dwarf2_locate_sections (bfd *, asection *, PTR);
-#if 0
static void dwarf2_build_psymtabs_easy (struct objfile *, int);
-#endif
static void dwarf2_build_psymtabs_hard (struct objfile *, int);
static char *scan_partial_symbols (char *, struct objfile *,
CORE_ADDR *, CORE_ADDR *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void add_partial_symbol (struct partial_die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void dwarf2_psymtab_to_symtab (struct partial_symtab *);
@@ -580,21 +556,25 @@ static void psymtab_to_symtab_1 (struct partial_symtab *);
static char *dwarf2_read_section (struct objfile *, file_ptr, unsigned int);
-static void dwarf2_read_abbrevs (bfd *, unsigned int);
+static void dwarf2_read_abbrevs (bfd *, struct comp_unit_instance *,
+ unsigned int);
static void dwarf2_empty_abbrev_table (PTR);
-static struct abbrev_info *dwarf2_lookup_abbrev (unsigned int);
+static struct abbrev_info *dwarf2_lookup_abbrev (unsigned int,
+ const struct
+ comp_unit_instance *);
static char *read_partial_die (struct partial_die_info *,
- bfd *, char *,
- const struct comp_unit_head *);
+ bfd *, char *, int *,
+ const struct comp_unit_instance *);
static char *read_full_die (struct die_info **, bfd *, char *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static char *read_attribute (struct attribute *, struct attr_abbrev *,
- bfd *, char *, const struct comp_unit_head *);
+ bfd *, char *,
+ const struct comp_unit_instance *);
static unsigned int read_1_byte (bfd *, char *);
@@ -606,14 +586,15 @@ static unsigned int read_4_bytes (bfd *, char *);
static unsigned long read_8_bytes (bfd *, char *);
-static CORE_ADDR read_address (bfd *, char *ptr, const struct comp_unit_head *,
+static CORE_ADDR read_address (bfd *, char *ptr,
+ const struct comp_unit_instance *,
int *bytes_read);
static LONGEST read_initial_length (bfd *, char *,
- struct comp_unit_head *, int *bytes_read);
+ struct comp_unit_head *, int *bytes_read);
static LONGEST read_offset (bfd *, char *, const struct comp_unit_head *,
- int *bytes_read);
+ int *bytes_read);
static char *read_n_bytes (bfd *, char *, unsigned int);
@@ -623,62 +604,64 @@ static unsigned long read_unsigned_leb128 (bfd *, char *, unsigned int *);
static long read_signed_leb128 (bfd *, char *, unsigned int *);
-static void set_cu_language (unsigned int);
+static void set_cu_language (struct comp_unit_instance *, unsigned int);
-static struct attribute *dwarf_attr (struct die_info *, unsigned int);
+static struct attribute *dwarf2_attr (struct die_info *, unsigned int,
+ const struct comp_unit_instance *);
-static int die_is_declaration (struct die_info *);
+static int die_is_declaration (struct die_info *,
+ const struct comp_unit_instance *);
-static void dwarf_decode_lines (unsigned int, char *, bfd *,
- const struct comp_unit_head *);
+static void dwarf2_decode_lines (unsigned int, char *, bfd *,
+ const struct comp_unit_instance *);
static void dwarf2_start_subfile (char *, char *);
static struct symbol *new_symbol (struct die_info *, struct type *,
- struct objfile *, const struct comp_unit_head *);
+ struct objfile *,
+ const struct comp_unit_instance *);
static void dwarf2_const_value (struct attribute *, struct symbol *,
- struct objfile *, const struct comp_unit_head *);
+ struct objfile *,
+ const struct comp_unit_instance *);
static void dwarf2_const_value_data (struct attribute *attr,
- struct symbol *sym,
- int bits);
+ struct symbol *sym, int bits);
static struct type *die_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static struct type *die_containing_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
-
-#if 0
-static struct type *type_at_offset (unsigned int, struct objfile *);
-#endif
+ const struct comp_unit_instance *);
static struct type *tag_type_to_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_type_die (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_typedef (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
-static void read_base_type (struct die_info *, struct objfile *);
+static void read_base_type (struct die_info *, struct objfile *,
+ const struct comp_unit_instance *);
static void read_file_scope (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_func_scope (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_lexical_block_scope (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static int dwarf2_get_pc_bounds (struct die_info *,
- CORE_ADDR *, CORE_ADDR *, struct objfile *);
+ CORE_ADDR *, CORE_ADDR *, struct objfile *,
+ const struct comp_unit_instance *);
static void dwarf2_add_field (struct field_info *, struct die_info *,
- struct objfile *, const struct comp_unit_head *);
+ struct objfile *,
+ const struct comp_unit_instance *);
static void dwarf2_attach_fields_to_type (struct field_info *,
struct type *, struct objfile *);
@@ -686,113 +669,125 @@ static void dwarf2_attach_fields_to_type (struct field_info *,
static void dwarf2_add_member_fn (struct field_info *,
struct die_info *, struct type *,
struct objfile *objfile,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void dwarf2_attach_fn_fields_to_type (struct field_info *,
struct type *, struct objfile *);
static void read_structure_scope (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *, const char *);
static void read_common_block (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_enumeration (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
-static struct type *dwarf_base_type (int, int, struct objfile *);
+static struct type *dwarf2_base_type (int, int, struct objfile *,
+ const struct comp_unit_instance *);
-static CORE_ADDR decode_locdesc (struct dwarf_block *, struct objfile *,
- const struct comp_unit_head *);
+static CORE_ADDR decode_locdesc (struct dwarf2_block *, struct objfile *,
+ const struct comp_unit_instance *);
static void read_array_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_tag_pointer_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_tag_ptr_to_member_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_tag_reference_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_tag_const_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
static void read_tag_volatile_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
-static void read_tag_string_type (struct die_info *, struct objfile *);
+static void read_tag_string_type (struct die_info *, struct objfile *,
+ const struct comp_unit_instance *);
static void read_subroutine_type (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+ const struct comp_unit_instance *);
-static struct die_info *read_comp_unit (char *, bfd *,
- const struct comp_unit_head *);
+struct die_info *read_comp_unit_dies (char *, bfd *,
+ const struct comp_unit_instance *);
static void free_die_list (struct die_info *);
static struct cleanup *make_cleanup_free_die_list (struct die_info *);
-static void process_die (struct die_info *, struct objfile *,
- const struct comp_unit_head *);
+static struct comp_unit_instance *dwarf2_get_cu_by_offset (bfd *, int);
-static char *dwarf2_linkage_name (struct die_info *);
+static struct comp_unit_instance *dwarf2_get_comp_unit (bfd *, int);
-static char *dwarf_tag_name (unsigned int);
+static struct comp_unit_instance *dwarf2_get_or_read_comp_unit (bfd *, int);
-static char *dwarf_attr_name (unsigned int);
+static struct comp_unit_instance *dwarf2_read_comp_unit (bfd *, int);
-static char *dwarf_form_name (unsigned int);
+static void process_die (struct die_info *, struct objfile *,
+ const struct comp_unit_instance *);
-static char *dwarf_stack_op_name (unsigned int);
+static char *dwarf2_linkage_name (struct die_info *,
+ const struct comp_unit_instance *);
-static char *dwarf_bool_name (unsigned int);
+static char *dwarf2_tag_name (unsigned int);
-static char *dwarf_type_encoding_name (unsigned int);
+static char *dwarf2_attr_name (unsigned int);
-#if 0
-static char *dwarf_cfi_name (unsigned int);
+static char *dwarf2_form_name (unsigned int);
-struct die_info *copy_die (struct die_info *);
-#endif
+static char *dwarf2_stack_op_name (unsigned int);
+
+static char *dwarf2_bool_name (unsigned int);
-static struct die_info *sibling_die (struct die_info *);
+static char *dwarf2_type_encoding_name (unsigned int);
-static void dump_die (struct die_info *);
+struct die_info *sibling_die (struct die_info *);
-static void dump_die_list (struct die_info *);
+void dump_die (struct die_info *, const struct comp_unit_instance *);
-static void store_in_ref_table (unsigned int, struct die_info *);
+void store_in_ref_table (unsigned int, struct die_info *,
+ struct comp_unit_instance *);
-static void dwarf2_empty_hash_tables (void);
+static void dwarf2_empty_hash_tables (struct comp_unit_instance *);
-static unsigned int dwarf2_get_ref_die_offset (struct attribute *);
+static unsigned int dwarf2_get_ref_die_offset (const struct comp_unit_instance
+ *, struct attribute *);
-static struct die_info *follow_die_ref (unsigned int);
+struct die_info *follow_die_ref (unsigned int,
+ const struct comp_unit_instance *);
-static struct type *dwarf2_fundamental_type (struct objfile *, int);
+static struct type *dwarf2_fundamental_type (struct objfile *, int,
+ const struct comp_unit_instance
+ *);
/* memory allocation interface */
static void dwarf2_free_tmp_obstack (PTR);
-static struct dwarf_block *dwarf_alloc_block (void);
+static struct dwarf2_block *dwarf2_alloc_block (void);
-static struct abbrev_info *dwarf_alloc_abbrev (void);
+static struct abbrev_info *dwarf2_alloc_abbrev (void);
-static struct die_info *dwarf_alloc_die (void);
+static struct die_info *dwarf2_alloc_die (void);
+
+static struct comp_unit_instance *dwarf2_alloc_comp_unit_instance (void);
+
+static void dwarf2_read_frame_info (struct objfile *);
/* Try to locate the sections we need for DWARF 2 debugging
information and return true if we have enough to do something. */
int
-dwarf2_has_info (bfd *abfd)
+dwarf2_has_info (bfd * abfd)
{
- dwarf_info_offset = dwarf_abbrev_offset = dwarf_line_offset = 0;
+ dwarf2_info_offset = dwarf2_abbrev_offset = dwarf2_line_offset = 0;
bfd_map_over_sections (abfd, dwarf2_locate_sections, NULL);
- if (dwarf_info_offset && dwarf_abbrev_offset)
+ if (dwarf2_info_offset && dwarf2_abbrev_offset)
{
return 1;
}
@@ -807,47 +802,52 @@ dwarf2_has_info (bfd *abfd)
in. */
static void
-dwarf2_locate_sections (bfd *ignore_abfd, asection *sectp, PTR ignore_ptr)
+dwarf2_locate_sections (bfd * ignore_abfd, asection * sectp, PTR ignore_ptr)
{
if (STREQ (sectp->name, INFO_SECTION))
{
- dwarf_info_offset = sectp->filepos;
- dwarf_info_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_info_offset = sectp->filepos;
+ dwarf2_info_size = bfd_get_section_size_before_reloc (sectp);
}
else if (STREQ (sectp->name, ABBREV_SECTION))
{
- dwarf_abbrev_offset = sectp->filepos;
- dwarf_abbrev_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_abbrev_offset = sectp->filepos;
+ dwarf2_abbrev_size = bfd_get_section_size_before_reloc (sectp);
}
else if (STREQ (sectp->name, LINE_SECTION))
{
- dwarf_line_offset = sectp->filepos;
- dwarf_line_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_line_offset = sectp->filepos;
+ dwarf2_line_size = bfd_get_section_size_before_reloc (sectp);
}
else if (STREQ (sectp->name, PUBNAMES_SECTION))
{
- dwarf_pubnames_offset = sectp->filepos;
- dwarf_pubnames_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_pubnames_offset = sectp->filepos;
+ dwarf2_pubnames_size = bfd_get_section_size_before_reloc (sectp);
}
else if (STREQ (sectp->name, ARANGES_SECTION))
{
- dwarf_aranges_offset = sectp->filepos;
- dwarf_aranges_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_aranges_offset = sectp->filepos;
+ dwarf2_aranges_size = bfd_get_section_size_before_reloc (sectp);
}
else if (STREQ (sectp->name, LOC_SECTION))
{
- dwarf_loc_offset = sectp->filepos;
- dwarf_loc_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_loc_offset = sectp->filepos;
+ dwarf2_loc_size = bfd_get_section_size_before_reloc (sectp);
}
else if (STREQ (sectp->name, MACINFO_SECTION))
{
- dwarf_macinfo_offset = sectp->filepos;
- dwarf_macinfo_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_macinfo_offset = sectp->filepos;
+ dwarf2_macinfo_size = bfd_get_section_size_before_reloc (sectp);
}
else if (STREQ (sectp->name, STR_SECTION))
{
- dwarf_str_offset = sectp->filepos;
- dwarf_str_size = bfd_get_section_size_before_reloc (sectp);
+ dwarf2_str_offset = sectp->filepos;
+ dwarf2_str_size = bfd_get_section_size_before_reloc (sectp);
+ }
+ else if (STREQ (sectp->name, FRAME_SECTION))
+ {
+ dwarf2_frame_offset = sectp->filepos;
+ dwarf2_frame_size = bfd_get_section_size_before_reloc (sectp);
}
}
@@ -856,97 +856,157 @@ dwarf2_locate_sections (bfd *ignore_abfd, asection *sectp, PTR ignore_ptr)
void
dwarf2_build_psymtabs (struct objfile *objfile, int mainline)
{
-
/* We definitely need the .debug_info and .debug_abbrev sections */
- dwarf_info_buffer = dwarf2_read_section (objfile,
- dwarf_info_offset,
- dwarf_info_size);
- dwarf_abbrev_buffer = dwarf2_read_section (objfile,
- dwarf_abbrev_offset,
- dwarf_abbrev_size);
- dwarf_line_buffer = dwarf2_read_section (objfile,
- dwarf_line_offset,
- dwarf_line_size);
-
+ dwarf2_info_buffer = dwarf2_read_section (objfile,
+ dwarf2_info_offset,
+ dwarf2_info_size);
+ dwarf2_abbrev_buffer = dwarf2_read_section (objfile,
+ dwarf2_abbrev_offset,
+ dwarf2_abbrev_size);
+ dwarf2_line_buffer = dwarf2_read_section (objfile,
+ dwarf2_line_offset,
+ dwarf2_line_size);
+ dwarf2_frame_buffer = dwarf2_read_section (objfile,
+ dwarf2_frame_offset,
+ dwarf2_frame_size);
+ dwarf2_read_frame_info (objfile);
if (mainline || objfile->global_psymbols.size == 0 ||
objfile->static_psymbols.size == 0)
{
init_psymbol_list (objfile, 1024);
}
-#if 0
- if (dwarf_aranges_offset && dwarf_pubnames_offset)
+ if (dwarf2_aranges_offset && dwarf2_pubnames_offset)
{
/* Things are significantly easier if we have .debug_aranges and
.debug_pubnames sections */
dwarf2_build_psymtabs_easy (objfile, mainline);
}
+#if 0
else
-#endif
/* only test this case for now */
{
+#endif
/* In this case we have to work a bit harder */
dwarf2_build_psymtabs_hard (objfile, mainline);
+#if 0
}
+#endif
}
-#if 0
+char *aranges_buffer, *pubnames_buffer;
+
/* Build the partial symbol table from the information in the
.debug_pubnames and .debug_aranges sections. */
+static char *
+get_pubname_for_offset (bfd *abfd, int looking_for_offset, const struct comp_unit_instance *cui)
+{
+ char *pubnames_ptr;
+ unsigned int entry_length, version, info_offset, info_size;
+ pubnames_ptr = pubnames_buffer;
+ while ((pubnames_ptr - pubnames_buffer) < dwarf2_pubnames_size)
+ {
+ struct comp_unit_head cu_header;
+ int bytes_read;
+ unsigned char *data;
+ unsigned long offset;
+
+ entry_length = read_4_bytes (abfd, pubnames_ptr);
+ pubnames_ptr += 4;
+ version = read_2_bytes (abfd, pubnames_ptr);
+ pubnames_ptr += 2;
+ info_offset = read_4_bytes (abfd, pubnames_ptr);
+ pubnames_ptr += 4;
+ info_size = read_4_bytes (abfd, pubnames_ptr);
+ pubnames_ptr += 4;
+ data = pubnames_ptr;
+
+ do
+ {
+ offset = read_4_bytes (abfd, pubnames_ptr);
+ if (offset != 0)
+ {
+ pubnames_ptr += 4;
+ data = pubnames_ptr;
+ pubnames_ptr += strlen ((char *) data) + 1;
+ if (cui->offset == info_offset && offset == looking_for_offset-1)
+ {
+ return data;
+ }
+ }
+ }
+ while (offset != 0);
+ }
+ return NULL;
+}
+
static void
dwarf2_build_psymtabs_easy (struct objfile *objfile, int mainline)
{
bfd *abfd = objfile->obfd;
- char *aranges_buffer, *pubnames_buffer;
char *aranges_ptr, *pubnames_ptr;
unsigned int entry_length, version, info_offset, info_size;
pubnames_buffer = dwarf2_read_section (objfile,
- dwarf_pubnames_offset,
- dwarf_pubnames_size);
+ dwarf2_pubnames_offset,
+ dwarf2_pubnames_size);
pubnames_ptr = pubnames_buffer;
- while ((pubnames_ptr - pubnames_buffer) < dwarf_pubnames_size)
+ while ((pubnames_ptr - pubnames_buffer) < dwarf2_pubnames_size)
{
struct comp_unit_head cu_header;
int bytes_read;
+ unsigned char *data;
+ unsigned long offset;
- entry_length = read_initial_length (abfd, pubnames_ptr, &cu_header,
- &bytes_read);
- pubnames_ptr += bytes_read;
- version = read_1_byte (abfd, pubnames_ptr);
- pubnames_ptr += 1;
+ entry_length = read_4_bytes (abfd, pubnames_ptr);
+ pubnames_ptr += 4;
+ version = read_2_bytes (abfd, pubnames_ptr);
+ pubnames_ptr += 2;
info_offset = read_4_bytes (abfd, pubnames_ptr);
pubnames_ptr += 4;
info_size = read_4_bytes (abfd, pubnames_ptr);
pubnames_ptr += 4;
+ data = pubnames_ptr;
+
+ do
+ {
+ offset = read_4_bytes (abfd, pubnames_ptr);
+ if (offset != 0)
+ {
+ pubnames_ptr += 4;
+ data = pubnames_ptr;
+ pubnames_ptr += strlen ((char *) data) + 1;
+ }
+ }
+ while (offset != 0);
+
+
}
aranges_buffer = dwarf2_read_section (objfile,
- dwarf_aranges_offset,
- dwarf_aranges_size);
-
+ dwarf2_aranges_offset,
+ dwarf2_aranges_size);
}
-#endif
/* Read in the comp unit header information from the debug_info at
info_ptr. */
static char *
read_comp_unit_head (struct comp_unit_head *cu_header,
- char *info_ptr, bfd *abfd)
+ char *info_ptr, bfd * abfd)
{
int signed_addr;
int bytes_read;
cu_header->length = read_initial_length (abfd, info_ptr, cu_header,
- &bytes_read);
+ &bytes_read);
info_ptr += bytes_read;
cu_header->version = read_2_bytes (abfd, info_ptr);
info_ptr += 2;
cu_header->abbrev_offset = read_offset (abfd, info_ptr, cu_header,
- &bytes_read);
+ &bytes_read);
info_ptr += bytes_read;
cu_header->addr_size = read_1_byte (abfd, info_ptr);
info_ptr += 1;
@@ -957,6 +1017,81 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
cu_header->signed_addr_p = signed_addr;
return info_ptr;
}
+static struct comp_unit_instance *
+dwarf2_get_cu_by_offset (bfd * abfd, int offset)
+{
+ int i;
+ struct comp_unit_instance *cui;
+
+ for (i = 0; i < COMP_UNIT_HASH_SIZE; i++)
+ {
+ cui = compilation_units[i];
+ while (cui)
+ {
+ if (offset >= cui->offset
+ && offset <= (cui->offset + cui->cu_header.length))
+ {
+ if (cui->abfd == abfd)
+ return cui;
+ }
+ cui = cui->next;
+ }
+ }
+ return NULL;
+}
+static struct comp_unit_instance *
+dwarf2_get_comp_unit (bfd * abfd, int offset)
+{
+ struct comp_unit_instance *cui;
+ int h;
+
+ h = (offset % COMP_UNIT_HASH_SIZE);
+ cui = compilation_units[h];
+ while (cui)
+ {
+ if (cui->offset == offset && cui->abfd == abfd)
+ {
+ return cui;
+ }
+ cui = cui->next;
+ }
+ return NULL;
+}
+static struct comp_unit_instance *
+dwarf2_get_or_read_comp_unit (bfd * abfd, int offset)
+{
+ struct comp_unit_instance *cui;
+ cui = dwarf2_get_comp_unit (abfd, offset);
+ if (cui != NULL)
+ return cui;
+ cui = dwarf2_read_comp_unit (abfd, offset);
+ return cui;
+}
+
+static struct comp_unit_instance *
+dwarf2_read_comp_unit (bfd * abfd, int offset)
+{
+ int h;
+ char *info_ptr;
+ struct comp_unit_instance *cui = dwarf2_alloc_comp_unit_instance ();
+ h = (offset % COMP_UNIT_HASH_SIZE);
+ cui->next = compilation_units[h];
+ compilation_units[h] = cui;
+
+ info_ptr = dwarf2_info_buffer + offset;
+ cui->offset = offset;
+ cui->abfd = abfd;
+
+ /* read in the comp_unit header */
+ info_ptr = read_comp_unit_head (&cui->cu_header, info_ptr, abfd);
+
+ /* Read the abbrevs for this compilation unit */
+ dwarf2_read_abbrevs (abfd, cui, cui->cu_header.abbrev_offset);
+// make_cleanup (dwarf2_empty_abbrev_table, cui);
+
+ return cui;
+
+}
/* Build the partial symbol table by doing a quick pass through the
.debug_info and .debug_abbrev sections. */
@@ -972,79 +1107,85 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
struct partial_die_info comp_unit_die;
struct partial_symtab *pst;
struct cleanup *back_to;
+ int comp_unit_has_pc_info;
CORE_ADDR lowpc, highpc;
-
- info_ptr = dwarf_info_buffer;
- abbrev_ptr = dwarf_abbrev_buffer;
-
+ struct comp_unit_instance *cui;
+ int i;
+ info_ptr = dwarf2_info_buffer;
+ abbrev_ptr = dwarf2_abbrev_buffer;
obstack_init (&dwarf2_tmp_obstack);
back_to = make_cleanup (dwarf2_free_tmp_obstack, NULL);
- /* Since the objects we're extracting from dwarf_info_buffer vary in
- length, only the individual functions to extract them (like
- read_comp_unit_head and read_partial_die) can really know whether
- the buffer is large enough to hold another complete object.
-
- At the moment, they don't actually check that. If
- dwarf_info_buffer holds just one extra byte after the last
- compilation unit's dies, then read_comp_unit_head will happily
- read off the end of the buffer. read_partial_die is similarly
- casual. Those functions should be fixed.
-
- For this loop condition, simply checking whether there's any data
- left at all should be sufficient. */
- while (info_ptr < dwarf_info_buffer + dwarf_info_size)
+#if 0
+ while ((unsigned int) (info_ptr - dwarf2_info_buffer)
+ + ((info_ptr - dwarf2_info_buffer) % 4) < dwarf2_info_size)
+ {
+ beg_of_comp_unit = info_ptr;
+ cui =
+ dwarf2_get_or_read_comp_unit (abfd,
+ beg_of_comp_unit - dwarf2_info_buffer);
+ info_ptr =
+ beg_of_comp_unit + cui->cu_header.length +
+ cui->cu_header.initial_length_size;
+ }
+ info_ptr = dwarf2_info_buffer;
+#endif
+ while ((unsigned int) (info_ptr - dwarf2_info_buffer)
+ + ((info_ptr - dwarf2_info_buffer) % 4) < dwarf2_info_size)
{
struct comp_unit_head cu_header;
beg_of_comp_unit = info_ptr;
+ cui =
+ dwarf2_get_or_read_comp_unit (abfd,
+ beg_of_comp_unit - dwarf2_info_buffer);
info_ptr = read_comp_unit_head (&cu_header, info_ptr, abfd);
- if (cu_header.version != 2)
+ if (cui->cu_header.version != 2)
{
error ("Dwarf Error: wrong version in compilation unit header.");
return;
}
- if (cu_header.abbrev_offset >= dwarf_abbrev_size)
+ if (cui->cu_header.abbrev_offset >= dwarf2_abbrev_size)
{
- error ("Dwarf Error: bad offset (0x%lx) in compilation unit header (offset 0x%lx + 6).",
- (long) cu_header.abbrev_offset,
- (long) (beg_of_comp_unit - dwarf_info_buffer));
+ error
+ ("Dwarf Error: bad offset (0x%lx) in compilation unit header (offset 0x%lx + 6).",
+ (long) cui->cu_header.abbrev_offset,
+ (long) (beg_of_comp_unit - dwarf2_info_buffer));
return;
}
- if (beg_of_comp_unit + cu_header.length + cu_header.initial_length_size
- > dwarf_info_buffer + dwarf_info_size)
+ if (beg_of_comp_unit + cui->cu_header.length + cui->cu_header.initial_length_size
+ > dwarf2_info_buffer + dwarf2_info_size)
{
- error ("Dwarf Error: bad length (0x%lx) in compilation unit header (offset 0x%lx + 0).",
- (long) cu_header.length,
- (long) (beg_of_comp_unit - dwarf_info_buffer));
+ error
+ ("Dwarf Error: bad length (0x%lx) in compilation unit header (offset 0x%lx + 0).",
+ (long) cui->cu_header.length,
+ (long) (beg_of_comp_unit - dwarf2_info_buffer));
return;
}
- /* Read the abbrevs for this compilation unit into a table */
- dwarf2_read_abbrevs (abfd, cu_header.abbrev_offset);
- make_cleanup (dwarf2_empty_abbrev_table, NULL);
-
/* Read the compilation unit die */
info_ptr = read_partial_die (&comp_unit_die, abfd, info_ptr,
- &cu_header);
+ &comp_unit_has_pc_info, cui);
/* Set the language we're debugging */
- set_cu_language (comp_unit_die.language);
+ set_cu_language (cui, comp_unit_die.language);
/* Allocate a new partial symbol table structure */
pst = start_psymtab_common (objfile, objfile->section_offsets,
- comp_unit_die.name ? comp_unit_die.name : "",
- comp_unit_die.lowpc,
+ comp_unit_die.name ? comp_unit_die.
+ name : "", comp_unit_die.lowpc,
objfile->global_psymbols.next,
objfile->static_psymbols.next);
pst->read_symtab_private = (char *)
- obstack_alloc (&objfile->psymbol_obstack, sizeof (struct dwarf2_pinfo));
- cu_header_offset = beg_of_comp_unit - dwarf_info_buffer;
- DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
- DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf_info_buffer;
- DWARF_ABBREV_BUFFER (pst) = dwarf_abbrev_buffer;
- DWARF_ABBREV_SIZE (pst) = dwarf_abbrev_size;
- DWARF_LINE_BUFFER (pst) = dwarf_line_buffer;
+ obstack_alloc (&objfile->psymbol_obstack,
+ sizeof (struct dwarf2_pinfo));
+ cui->cu_header_offset = beg_of_comp_unit - dwarf2_info_buffer;
+ DWARF2_INFO_BUFFER (pst) = dwarf2_info_buffer;
+ DWARF2_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf2_info_buffer;
+ DWARF2_ABBREV_BUFFER (pst) = dwarf2_abbrev_buffer;
+ DWARF2_ABBREV_SIZE (pst) = dwarf2_abbrev_size;
+ DWARF2_LINE_BUFFER (pst) = dwarf2_line_buffer;
+ DWARF2_FRAME_BUFFER (pst) = dwarf2_frame_buffer;
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
/* Store the function that reads in the rest of the symbol table */
@@ -1056,11 +1197,10 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
if (comp_unit_die.has_children)
{
info_ptr = scan_partial_symbols (info_ptr, objfile, &lowpc, &highpc,
- &cu_header);
-
+ cui);
/* If the compilation unit didn't have an explicit address range,
then use the information extracted from its child dies. */
- if (! comp_unit_die.has_pc_info)
+ if (!comp_unit_has_pc_info)
{
comp_unit_die.lowpc = lowpc;
comp_unit_die.highpc = highpc;
@@ -1080,8 +1220,8 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
also happen.) This happens in VxWorks. */
free_named_symtabs (pst->filename);
- info_ptr = beg_of_comp_unit + cu_header.length
- + cu_header.initial_length_size;
+ info_ptr = beg_of_comp_unit + cui->cu_header.length
+ + cui->cu_header.initial_length_size;
}
do_cleanups (back_to);
}
@@ -1090,8 +1230,8 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
static char *
scan_partial_symbols (char *info_ptr, struct objfile *objfile,
- CORE_ADDR *lowpc, CORE_ADDR *highpc,
- const struct comp_unit_head *cu_header)
+ CORE_ADDR * lowpc, CORE_ADDR * highpc,
+ const struct comp_unit_instance *cui)
{
bfd *abfd = objfile->obfd;
struct partial_die_info pdi;
@@ -1103,20 +1243,21 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
back to that level. */
int nesting_level = 1;
+ int has_pc_info;
- *lowpc = ((CORE_ADDR) -1);
+ *lowpc = ((CORE_ADDR) - 1);
*highpc = ((CORE_ADDR) 0);
while (nesting_level)
{
- info_ptr = read_partial_die (&pdi, abfd, info_ptr, cu_header);
+ info_ptr = read_partial_die (&pdi, abfd, info_ptr, &has_pc_info, cui);
if (pdi.name)
{
switch (pdi.tag)
{
case DW_TAG_subprogram:
- if (pdi.has_pc_info)
+ if (has_pc_info)
{
if (pdi.lowpc < *lowpc)
{
@@ -1129,7 +1270,7 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
if ((pdi.is_external || nesting_level == 1)
&& !pdi.is_declaration)
{
- add_partial_symbol (&pdi, objfile, cu_header);
+ add_partial_symbol (&pdi, objfile, cui);
}
}
break;
@@ -1142,20 +1283,20 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
if ((pdi.is_external || nesting_level == 1)
&& !pdi.is_declaration)
{
- add_partial_symbol (&pdi, objfile, cu_header);
+ add_partial_symbol (&pdi, objfile, cui);
}
break;
case DW_TAG_enumerator:
/* File scope enumerators are added to the partial symbol
table. */
if (nesting_level == 2)
- add_partial_symbol (&pdi, objfile, cu_header);
+ add_partial_symbol (&pdi, objfile, cui);
break;
case DW_TAG_base_type:
/* File scope base type definitions are added to the partial
symbol table. */
if (nesting_level == 1)
- add_partial_symbol (&pdi, objfile, cu_header);
+ add_partial_symbol (&pdi, objfile, cui);
break;
default:
break;
@@ -1184,14 +1325,14 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile,
/* If we didn't find a lowpc, set it to highpc to avoid complaints
from `maint check'. */
- if (*lowpc == ((CORE_ADDR) -1))
+ if (*lowpc == ((CORE_ADDR) - 1))
*lowpc = *highpc;
return info_ptr;
}
static void
add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
CORE_ADDR addr = 0;
@@ -1205,7 +1346,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
add_psymbol_to_list (pdi->name, strlen (pdi->name),
VAR_NAMESPACE, LOC_BLOCK,
&objfile->global_psymbols,
- 0, pdi->lowpc + baseaddr, cu_language, objfile);
+ 0, pdi->lowpc + baseaddr, cui->cu_language,
+ objfile);
}
else
{
@@ -1214,7 +1356,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
add_psymbol_to_list (pdi->name, strlen (pdi->name),
VAR_NAMESPACE, LOC_BLOCK,
&objfile->static_psymbols,
- 0, pdi->lowpc + baseaddr, cu_language, objfile);
+ 0, pdi->lowpc + baseaddr, cui->cu_language,
+ objfile);
}
break;
case DW_TAG_variable:
@@ -1234,25 +1377,26 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
table building. */
if (pdi->locdesc)
- addr = decode_locdesc (pdi->locdesc, objfile, cu_header);
+ addr = decode_locdesc (pdi->locdesc, objfile, cui);
if (pdi->locdesc || pdi->has_type)
add_psymbol_to_list (pdi->name, strlen (pdi->name),
VAR_NAMESPACE, LOC_STATIC,
&objfile->global_psymbols,
- 0, addr + baseaddr, cu_language, objfile);
+ 0, addr + baseaddr, cui->cu_language,
+ objfile);
}
else
{
/* Static Variable. Skip symbols without location descriptors. */
if (pdi->locdesc == NULL)
return;
- addr = decode_locdesc (pdi->locdesc, objfile, cu_header);
+ addr = decode_locdesc (pdi->locdesc, objfile, cui);
/*prim_record_minimal_symbol (pdi->name, addr + baseaddr,
mst_file_data, objfile); */
add_psymbol_to_list (pdi->name, strlen (pdi->name),
VAR_NAMESPACE, LOC_STATIC,
&objfile->static_psymbols,
- 0, addr + baseaddr, cu_language, objfile);
+ 0, addr + baseaddr, cui->cu_language, objfile);
}
break;
case DW_TAG_typedef:
@@ -1260,7 +1404,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
add_psymbol_to_list (pdi->name, strlen (pdi->name),
VAR_NAMESPACE, LOC_TYPEDEF,
&objfile->static_psymbols,
- 0, (CORE_ADDR) 0, cu_language, objfile);
+ 0, (CORE_ADDR) 0, cui->cu_language, objfile);
break;
case DW_TAG_class_type:
case DW_TAG_structure_type:
@@ -1273,22 +1417,22 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
add_psymbol_to_list (pdi->name, strlen (pdi->name),
STRUCT_NAMESPACE, LOC_TYPEDEF,
&objfile->static_psymbols,
- 0, (CORE_ADDR) 0, cu_language, objfile);
+ 0, (CORE_ADDR) 0, cui->cu_language, objfile);
- if (cu_language == language_cplus)
+ if (cui->cu_language == language_cplus)
{
/* For C++, these implicitly act as typedefs as well. */
add_psymbol_to_list (pdi->name, strlen (pdi->name),
VAR_NAMESPACE, LOC_TYPEDEF,
&objfile->static_psymbols,
- 0, (CORE_ADDR) 0, cu_language, objfile);
+ 0, (CORE_ADDR) 0, cui->cu_language, objfile);
}
break;
case DW_TAG_enumerator:
add_psymbol_to_list (pdi->name, strlen (pdi->name),
VAR_NAMESPACE, LOC_CONST,
&objfile->static_psymbols,
- 0, (CORE_ADDR) 0, cu_language, objfile);
+ 0, (CORE_ADDR) 0, cui->cu_language, objfile);
break;
default:
break;
@@ -1329,7 +1473,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
{
struct objfile *objfile = pst->objfile;
bfd *abfd = objfile->obfd;
- struct comp_unit_head cu_header;
+ struct comp_unit_instance *cui;
struct die_info *dies;
unsigned long offset;
CORE_ADDR lowpc, highpc;
@@ -1337,16 +1481,18 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
char *info_ptr;
struct symtab *symtab;
struct cleanup *back_to;
-
+ int i = 0;
/* Set local variables from the partial symbol table info. */
- offset = DWARF_INFO_OFFSET (pst);
- dwarf_info_buffer = DWARF_INFO_BUFFER (pst);
- dwarf_abbrev_buffer = DWARF_ABBREV_BUFFER (pst);
- dwarf_abbrev_size = DWARF_ABBREV_SIZE (pst);
- dwarf_line_buffer = DWARF_LINE_BUFFER (pst);
+ offset = DWARF2_INFO_OFFSET (pst);
+ dwarf2_info_buffer = DWARF2_INFO_BUFFER (pst);
+ dwarf2_abbrev_buffer = DWARF2_ABBREV_BUFFER (pst);
+ dwarf2_abbrev_size = DWARF2_ABBREV_SIZE (pst);
+ dwarf2_line_buffer = DWARF2_LINE_BUFFER (pst);
+ dwarf2_frame_buffer = DWARF2_FRAME_BUFFER (pst);
baseaddr = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (objfile));
- cu_header_offset = offset;
- info_ptr = dwarf_info_buffer + offset;
+ cui = dwarf2_get_or_read_comp_unit (abfd, offset);
+ cui->cu_header_offset = offset;
+ info_ptr = dwarf2_info_buffer + offset;
obstack_init (&dwarf2_tmp_obstack);
back_to = make_cleanup (dwarf2_free_tmp_obstack, NULL);
@@ -1354,21 +1500,16 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
buildsym_init ();
make_cleanup (really_free_pendings, NULL);
- /* read in the comp_unit header */
- info_ptr = read_comp_unit_head (&cu_header, info_ptr, abfd);
-
- /* Read the abbrevs for this compilation unit */
- dwarf2_read_abbrevs (abfd, cu_header.abbrev_offset);
- make_cleanup (dwarf2_empty_abbrev_table, NULL);
-
- dies = read_comp_unit (info_ptr, abfd, &cu_header);
+ /* read in the comp_unit header, again, because we don't know it's size */
+ info_ptr = read_comp_unit_head (&cui->cu_header, info_ptr, abfd);
+ dies = read_comp_unit_dies (info_ptr, abfd, cui);
make_cleanup_free_die_list (dies);
/* Do line number decoding in read_file_scope () */
- process_die (dies, objfile, &cu_header);
+ process_die (dies, objfile, cui);
- if (!dwarf2_get_pc_bounds (dies, &lowpc, &highpc, objfile))
+ if (!dwarf2_get_pc_bounds (dies, &lowpc, &highpc, objfile, cui))
{
/* Some compilers don't define a DW_AT_high_pc attribute for
the compilation unit. If the DW_AT_high_pc is missing,
@@ -1383,7 +1524,8 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
{
CORE_ADDR low, high;
- if (dwarf2_get_pc_bounds (child_die, &low, &high, objfile))
+ if (dwarf2_get_pc_bounds
+ (child_die, &low, &high, objfile, cui))
{
highpc = max (highpc, high);
}
@@ -1398,14 +1540,17 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
If the compilation is from a C file generated by language preprocessors,
do not set the language if it was already deduced by start_subfile. */
if (symtab != NULL
- && !(cu_language == language_c && symtab->language != language_c))
+ && !(cui->cu_language == language_c && symtab->language != language_c))
{
- symtab->language = cu_language;
+ symtab->language = cui->cu_language;
}
pst->symtab = symtab;
pst->readin = 1;
- sort_symtab_syms (pst->symtab);
-
+ sort_symtab_syms (symtab);
+ xfree (dwarf2_info_buffer);
+ xfree (dwarf2_abbrev_buffer);
+ xfree (dwarf2_line_buffer);
+ xfree (dwarf2_frame_buffer);
do_cleanups (back_to);
}
@@ -1413,78 +1558,78 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
static void
process_die (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
switch (die->tag)
{
case DW_TAG_padding:
break;
case DW_TAG_compile_unit:
- read_file_scope (die, objfile, cu_header);
+ read_file_scope (die, objfile, cui);
break;
case DW_TAG_subprogram:
- read_subroutine_type (die, objfile, cu_header);
- read_func_scope (die, objfile, cu_header);
+ read_subroutine_type (die, objfile, cui);
+ read_func_scope (die, objfile, cui);
break;
case DW_TAG_inlined_subroutine:
- /* FIXME: These are ignored for now.
- They could be used to set breakpoints on all inlined instances
- of a function and make GDB `next' properly over inlined functions. */
+ /* DJB - handled now */
+ read_subroutine_type (die, objfile, cui);
+ read_func_scope (die, objfile, cui);
break;
case DW_TAG_lexical_block:
- read_lexical_block_scope (die, objfile, cu_header);
+ read_lexical_block_scope (die, objfile, cui);
break;
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
- read_structure_scope (die, objfile, cu_header);
+ read_structure_scope (die, objfile, cui, NULL);
break;
case DW_TAG_enumeration_type:
- read_enumeration (die, objfile, cu_header);
+ read_enumeration (die, objfile, cui);
break;
case DW_TAG_subroutine_type:
- read_subroutine_type (die, objfile, cu_header);
+ read_subroutine_type (die, objfile, cui);
break;
case DW_TAG_array_type:
- read_array_type (die, objfile, cu_header);
+ read_array_type (die, objfile, cui);
break;
case DW_TAG_pointer_type:
- read_tag_pointer_type (die, objfile, cu_header);
+ read_tag_pointer_type (die, objfile, cui);
break;
case DW_TAG_ptr_to_member_type:
- read_tag_ptr_to_member_type (die, objfile, cu_header);
+ read_tag_ptr_to_member_type (die, objfile, cui);
break;
case DW_TAG_reference_type:
- read_tag_reference_type (die, objfile, cu_header);
+ read_tag_reference_type (die, objfile, cui);
break;
case DW_TAG_string_type:
- read_tag_string_type (die, objfile);
+ read_tag_string_type (die, objfile, cui);
break;
case DW_TAG_base_type:
- read_base_type (die, objfile);
- if (dwarf_attr (die, DW_AT_name))
+ read_base_type (die, objfile, cui);
+ if (dwarf2_attr (die, DW_AT_name, cui))
{
/* Add a typedef symbol for the base type definition. */
- new_symbol (die, die->type, objfile, cu_header);
+ new_symbol (die, die->type, objfile, cui);
}
break;
case DW_TAG_common_block:
- read_common_block (die, objfile, cu_header);
+ read_common_block (die, objfile, cui);
break;
case DW_TAG_common_inclusion:
break;
default:
- new_symbol (die, NULL, objfile, cu_header);
+ new_symbol (die, NULL, objfile, cui);
break;
}
}
static void
read_file_scope (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
unsigned int line_offset = 0;
- CORE_ADDR lowpc = ((CORE_ADDR) -1);
+ CORE_ADDR lowpc = ((CORE_ADDR) - 1);
CORE_ADDR highpc = ((CORE_ADDR) 0);
struct attribute *attr;
char *name = "<unknown>";
@@ -1492,7 +1637,7 @@ read_file_scope (struct die_info *die, struct objfile *objfile,
struct die_info *child_die;
bfd *abfd = objfile->obfd;
- if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile))
+ if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile, cui))
{
if (die->has_children)
{
@@ -1503,7 +1648,8 @@ read_file_scope (struct die_info *die, struct objfile *objfile,
{
CORE_ADDR low, high;
- if (dwarf2_get_pc_bounds (child_die, &low, &high, objfile))
+ if (dwarf2_get_pc_bounds
+ (child_die, &low, &high, objfile, cui))
{
lowpc = min (lowpc, low);
highpc = max (highpc, high);
@@ -1516,17 +1662,17 @@ read_file_scope (struct die_info *die, struct objfile *objfile,
/* If we didn't find a lowpc, set it to highpc to avoid complaints
from finish_block. */
- if (lowpc == ((CORE_ADDR) -1))
+ if (lowpc == ((CORE_ADDR) - 1))
lowpc = highpc;
lowpc += baseaddr;
highpc += baseaddr;
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr)
{
name = DW_STRING (attr);
}
- attr = dwarf_attr (die, DW_AT_comp_dir);
+ attr = dwarf2_attr (die, DW_AT_comp_dir, cui);
if (attr)
{
comp_dir = DW_STRING (attr);
@@ -1541,17 +1687,16 @@ read_file_scope (struct die_info *die, struct objfile *objfile,
}
}
- if (objfile->ei.entry_point >= lowpc &&
- objfile->ei.entry_point < highpc)
+ if (objfile->ei.entry_point >= lowpc && objfile->ei.entry_point < highpc)
{
objfile->ei.entry_file_lowpc = lowpc;
objfile->ei.entry_file_highpc = highpc;
}
- attr = dwarf_attr (die, DW_AT_language);
+ attr = dwarf2_attr (die, DW_AT_language, cui);
if (attr)
{
- set_cu_language (DW_UNSND (attr));
+ set_cu_language ((struct comp_unit_instance *) cui, DW_UNSND (attr));
}
/* We assume that we're processing GCC output. */
@@ -1572,11 +1717,11 @@ read_file_scope (struct die_info *die, struct objfile *objfile,
record_debugformat ("DWARF 2");
/* Decode line number information if present. */
- attr = dwarf_attr (die, DW_AT_stmt_list);
+ attr = dwarf2_attr (die, DW_AT_stmt_list, cui);
if (attr)
{
line_offset = DW_UNSND (attr);
- dwarf_decode_lines (line_offset, comp_dir, abfd, cu_header);
+ dwarf2_decode_lines (line_offset, comp_dir, abfd, cui);
}
/* Process all dies in compilation unit. */
@@ -1585,7 +1730,7 @@ read_file_scope (struct die_info *die, struct objfile *objfile,
child_die = die->next;
while (child_die && child_die->tag)
{
- process_die (child_die, objfile, cu_header);
+ process_die (child_die, objfile, cui);
child_die = sibling_die (child_die);
}
}
@@ -1593,7 +1738,7 @@ read_file_scope (struct die_info *die, struct objfile *objfile,
static void
read_func_scope (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
register struct context_stack *new;
CORE_ADDR lowpc;
@@ -1601,19 +1746,20 @@ read_func_scope (struct die_info *die, struct objfile *objfile,
struct die_info *child_die;
struct attribute *attr;
char *name;
-
- name = dwarf2_linkage_name (die);
+ struct dwarf2_block *d2loc;
+ void *data;
+ name = dwarf2_linkage_name (die, cui);
/* Ignore functions with missing or empty names and functions with
missing or invalid low and high pc attributes. */
- if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile))
+ if (name == NULL
+ || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile, cui))
return;
lowpc += baseaddr;
highpc += baseaddr;
- if (objfile->ei.entry_point >= lowpc &&
- objfile->ei.entry_point < highpc)
+ if (objfile->ei.entry_point >= lowpc && objfile->ei.entry_point < highpc)
{
objfile->ei.entry_func_lowpc = lowpc;
objfile->ei.entry_func_highpc = highpc;
@@ -1623,10 +1769,10 @@ read_func_scope (struct die_info *die, struct objfile *objfile,
for DW_OP_fbreg operands in decode_locdesc. */
frame_base_reg = -1;
frame_base_offset = 0;
- attr = dwarf_attr (die, DW_AT_frame_base);
+ attr = dwarf2_attr (die, DW_AT_frame_base, cui);
if (attr)
{
- CORE_ADDR addr = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ CORE_ADDR addr = decode_locdesc (DW_BLOCK (attr), objfile, cui);
if (isderef)
complain (&dwarf2_unsupported_at_frame_base, name);
else if (isreg)
@@ -1641,7 +1787,22 @@ read_func_scope (struct die_info *die, struct objfile *objfile,
}
new = push_context (0, lowpc);
- new->name = new_symbol (die, die->type, objfile, cu_header);
+ new->name = new_symbol (die, die->type, objfile, cui);
+ if (attr)
+ {
+#if 0
+ SYMBOL_FRAME_LOC_EXPR (new->name) = obstack_alloc (&objfile->symbol_obstack, sizeof (struct dwarf2_block));
+ d2loc = SYMBOL_FRAME_LOC_EXPR (new->name);
+ memset (d2loc, 0, DW_BLOCK (attr)->size);
+ d2loc->size = DW_BLOCK (attr)->size;
+ d2loc->data = xmalloc (DW_BLOCK (attr)->size);
+ memset (d2loc->data, 0, DW_BLOCK (attr)->size);
+ memcpy (d2loc->data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
+ data = d2loc->data;
+ d2loc->data = bcache (data, DW_BLOCK (attr)->size, &objfile->psymbol_cache);
+ xfree (data);
+#endif
+ }
list_in_scope = &local_symbols;
if (die->has_children)
@@ -1649,7 +1810,7 @@ read_func_scope (struct die_info *die, struct objfile *objfile,
child_die = die->next;
while (child_die && child_die->tag)
{
- process_die (child_die, objfile, cu_header);
+ process_die (child_die, objfile, cui);
child_die = sibling_die (child_die);
}
}
@@ -1666,14 +1827,14 @@ read_func_scope (struct die_info *die, struct objfile *objfile,
static void
read_lexical_block_scope (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
register struct context_stack *new;
CORE_ADDR lowpc, highpc;
struct die_info *child_die;
/* Ignore blocks with missing or invalid low and high pc attributes. */
- if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile))
+ if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile, cui))
return;
lowpc += baseaddr;
highpc += baseaddr;
@@ -1684,7 +1845,7 @@ read_lexical_block_scope (struct die_info *die, struct objfile *objfile,
child_die = die->next;
while (child_die && child_die->tag)
{
- process_die (child_die, objfile, cu_header);
+ process_die (child_die, objfile, cui);
child_die = sibling_die (child_die);
}
}
@@ -1702,19 +1863,20 @@ read_lexical_block_scope (struct die_info *die, struct objfile *objfile,
Return 1 if the attributes are present and valid, otherwise, return 0. */
static int
-dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, CORE_ADDR *highpc,
- struct objfile *objfile)
+dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR * lowpc,
+ CORE_ADDR * highpc, struct objfile *objfile,
+ const struct comp_unit_instance *cui)
{
struct attribute *attr;
CORE_ADDR low;
CORE_ADDR high;
- attr = dwarf_attr (die, DW_AT_low_pc);
+ attr = dwarf2_attr (die, DW_AT_low_pc, cui);
if (attr)
low = DW_ADDR (attr);
else
return 0;
- attr = dwarf_attr (die, DW_AT_high_pc);
+ attr = dwarf2_attr (die, DW_AT_high_pc, cui);
if (attr)
high = DW_ADDR (attr);
else
@@ -1744,7 +1906,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, CORE_ADDR *highpc,
static void
dwarf2_add_field (struct field_info *fip, struct die_info *die,
struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct nextfield *new_field;
struct attribute *attr;
@@ -1768,12 +1930,12 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
new_field->accessibility = DW_ACCESS_private;
new_field->virtuality = DW_VIRTUALITY_none;
- attr = dwarf_attr (die, DW_AT_accessibility);
+ attr = dwarf2_attr (die, DW_AT_accessibility, cui);
if (attr)
new_field->accessibility = DW_UNSND (attr);
if (new_field->accessibility != DW_ACCESS_public)
fip->non_public_fields = 1;
- attr = dwarf_attr (die, DW_AT_virtuality);
+ attr = dwarf2_attr (die, DW_AT_virtuality, cui);
if (attr)
new_field->virtuality = DW_UNSND (attr);
@@ -1781,10 +1943,10 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
if (die->tag == DW_TAG_member)
{
/* Get type of field. */
- fp->type = die_type (die, objfile, cu_header);
+ fp->type = die_type (die, objfile, cui);
/* Get bit size of field (zero if none). */
- attr = dwarf_attr (die, DW_AT_bit_size);
+ attr = dwarf2_attr (die, DW_AT_bit_size, cui);
if (attr)
{
FIELD_BITSIZE (*fp) = DW_UNSND (attr);
@@ -1795,15 +1957,15 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
}
/* Get bit offset of field. */
- attr = dwarf_attr (die, DW_AT_data_member_location);
+ attr = dwarf2_attr (die, DW_AT_data_member_location, cui);
if (attr)
{
FIELD_BITPOS (*fp) =
- decode_locdesc (DW_BLOCK (attr), objfile, cu_header) * bits_per_byte;
+ decode_locdesc (DW_BLOCK (attr), objfile, cui) * bits_per_byte;
}
else
FIELD_BITPOS (*fp) = 0;
- attr = dwarf_attr (die, DW_AT_bit_offset);
+ attr = dwarf2_attr (die, DW_AT_bit_offset, cui);
if (attr)
{
if (BITS_BIG_ENDIAN)
@@ -1826,7 +1988,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
int anonymous_size;
int bit_offset = DW_UNSND (attr);
- attr = dwarf_attr (die, DW_AT_byte_size);
+ attr = dwarf2_attr (die, DW_AT_byte_size, cui);
if (attr)
{
/* The size of the anonymous object containing
@@ -1848,15 +2010,18 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
}
/* Get name of field. */
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
fieldname = DW_STRING (attr);
- fp->name = obsavestring (fieldname, strlen (fieldname),
- &objfile->type_obstack);
+ fp->name = /*obsavestring (fieldname, strlen (fieldname),
+ &objfile->type_obstack); */ bcache (fieldname,
+ strlen (fieldname) + 1, &objfile->
+ psymbol_cache);
+
/* Change accessibility for artificial fields (e.g. virtual table
pointer or virtual base class pointer) to private. */
- if (dwarf_attr (die, DW_AT_artificial))
+ if (dwarf2_attr (die, DW_AT_artificial, cui))
{
new_field->accessibility = DW_ACCESS_private;
fip->non_public_fields = 1;
@@ -1867,32 +2032,34 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
char *physname;
/* C++ static member.
- Get name of field. */
- attr = dwarf_attr (die, DW_AT_name);
+ Get name of field. */
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
fieldname = DW_STRING (attr);
else
return;
/* Get physical name. */
- physname = dwarf2_linkage_name (die);
+ physname = dwarf2_linkage_name (die, cui);
- SET_FIELD_PHYSNAME (*fp, obsavestring (physname, strlen (physname),
- &objfile->type_obstack));
- FIELD_TYPE (*fp) = die_type (die, objfile, cu_header);
- FIELD_NAME (*fp) = obsavestring (fieldname, strlen (fieldname),
- &objfile->type_obstack);
+ SET_FIELD_PHYSNAME (*fp, bcache (physname, strlen (physname) + 1, &objfile->psymbol_cache) /*obsavestring (physname, strlen (physname),
+ &objfile->type_obstack) */ );
+ FIELD_TYPE (*fp) = die_type (die, objfile, cui);
+ FIELD_NAME (*fp) = /*obsavestring (fieldname, strlen (fieldname),
+ &objfile->type_obstack); */ bcache (physname,
+ strlen (physname) + 1, &objfile->
+ psymbol_cache);
}
else if (die->tag == DW_TAG_inheritance)
{
/* C++ base class field. */
- attr = dwarf_attr (die, DW_AT_data_member_location);
+ attr = dwarf2_attr (die, DW_AT_data_member_location, cui);
if (attr)
- FIELD_BITPOS (*fp) = (decode_locdesc (DW_BLOCK (attr), objfile, cu_header)
+ FIELD_BITPOS (*fp) = (decode_locdesc (DW_BLOCK (attr), objfile, cui)
* bits_per_byte);
FIELD_BITSIZE (*fp) = 0;
- FIELD_TYPE (*fp) = die_type (die, objfile, cu_header);
- FIELD_NAME (*fp) = type_name_no_tag (fp->type);
+ FIELD_TYPE (*fp) = die_type (die, objfile, cui);
+ FIELD_NAME (*fp) = xstrdup(type_name_no_tag (fp->type));
fip->nbaseclasses++;
}
}
@@ -1989,7 +2156,7 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
static void
dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
struct type *type, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct attribute *attr;
struct fnfieldlist *flp;
@@ -2000,14 +2167,14 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
struct nextfnfield *new_fnfield;
/* Get name of member function. */
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
fieldname = DW_STRING (attr);
else
return;
/* Get the mangled name. */
- physname = dwarf2_linkage_name (die);
+ physname = dwarf2_linkage_name (die, cui);
/* Look up member function name in fieldlist. */
for (i = 0; i < fip->nfnfields; i++)
@@ -2031,7 +2198,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
make_cleanup (free_current_contents, &fip->fnfieldlists);
}
flp = &fip->fnfieldlists[fip->nfnfields];
- flp->name = fieldname;
+ flp->name = bcache (fieldname, strlen(fieldname)+1, &objfile->psymbol_cache);
flp->length = 0;
flp->head = NULL;
fip->nfnfields++;
@@ -2048,27 +2215,28 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
/* Fill in the member function field info. */
fnp = &new_fnfield->fnfield;
- fnp->physname = obsavestring (physname, strlen (physname),
- &objfile->type_obstack);
+ fnp->physname = /*obsavestring (physname, strlen (physname),
+ &objfile->type_obstack); */ bcache (physname, strlen (physname) + 1,
+ &objfile->psymbol_cache);
fnp->type = alloc_type (objfile);
if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC)
{
- struct type *return_type = TYPE_TARGET_TYPE (die->type);
+ struct type *return_type = FUNCTION_RETURN_VALUE (die->type);
struct type **arg_types;
- int nparams = TYPE_NFIELDS (die->type);
+ int nparams = FUNCTION_NUM_ARGUMENTS (die->type);
int iparams;
/* Copy argument types from the subroutine type. */
arg_types = (struct type **)
TYPE_ALLOC (fnp->type, (nparams + 1) * sizeof (struct type *));
for (iparams = 0; iparams < nparams; iparams++)
- arg_types[iparams] = TYPE_FIELD_TYPE (die->type, iparams);
+ arg_types[iparams] = FUNCTION_ARGUMENT_TYPE (die->type, iparams);
/* Set last entry in argument type vector. */
if (TYPE_FLAGS (die->type) & TYPE_FLAG_VARARGS)
arg_types[nparams] = NULL;
else
- arg_types[nparams] = dwarf2_fundamental_type (objfile, FT_VOID);
+ arg_types[nparams] = dwarf2_fundamental_type (objfile, FT_VOID, cui);
smash_to_method_type (fnp->type, type, return_type, arg_types);
@@ -2085,14 +2253,14 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
complain (&dwarf2_missing_member_fn_type_complaint, physname);
/* Get fcontext from DW_AT_containing_type if present. */
- if (dwarf_attr (die, DW_AT_containing_type) != NULL)
- fnp->fcontext = die_containing_type (die, objfile, cu_header);
+ if (dwarf2_attr (die, DW_AT_containing_type, cui) != NULL)
+ fnp->fcontext = die_containing_type (die, objfile, cui);
/* dwarf2 doesn't have stubbed physical names, so the setting of is_const
and is_volatile is irrelevant, as it is needed by gdb_mangle_name only. */
/* Get accessibility. */
- attr = dwarf_attr (die, DW_AT_accessibility);
+ attr = dwarf2_attr (die, DW_AT_accessibility, cui);
if (attr)
{
switch (DW_UNSND (attr))
@@ -2107,9 +2275,9 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
}
/* Get index in virtual function table if it is a virtual member function. */
- attr = dwarf_attr (die, DW_AT_vtable_elem_location);
+ attr = dwarf2_attr (die, DW_AT_vtable_elem_location, cui);
if (attr)
- fnp->voffset = decode_locdesc (DW_BLOCK (attr), objfile, cu_header) + 2;
+ fnp->voffset = decode_locdesc (DW_BLOCK (attr), objfile, cui) + 2;
}
/* Create the vector of member function fields, and attach it to the type. */
@@ -2160,11 +2328,14 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type,
wants to find the one with the complete definition. Note that if
it is complete, we just call new_symbol, which does it's own
checking about whether the struct/union is anonymous or not (and
- suppresses creating a symbol table entry itself). */
+ suppresses creating a symbol table entry itself).
+
+ To handle naming of nested structure scopes, we prepend prefix to the name.
+ */
static void
read_structure_scope (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui, const char *prefix)
{
struct type *type;
struct attribute *attr;
@@ -2172,12 +2343,27 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
type = alloc_type (objfile);
INIT_CPLUS_SPECIFIC (type);
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
{
- TYPE_TAG_NAME (type) = obsavestring (DW_STRING (attr),
- strlen (DW_STRING (attr)),
- &objfile->type_obstack);
+ if (prefix != NULL)
+ {
+ char *structname;
+ structname = xcalloc (strlen (DW_STRING (attr)) + strlen (prefix) + strlen("::") + 1, sizeof (char));
+ strcat (structname, prefix);
+ strcat (structname, "::");
+ strcat (structname, DW_STRING (attr));
+ TYPE_TAG_NAME (type) = bcache (structname, strlen (structname) + 1, &objfile->psymbol_cache);
+ xfree (structname);
+ }
+ else
+ {
+ TYPE_TAG_NAME (type) = /*obsavestring (DW_STRING (attr),
+ strlen (DW_STRING (attr)),
+ &objfile->type_obstack); */ bcache (DW_STRING (attr),
+ strlen (DW_STRING (attr)) + 1,
+ &objfile->psymbol_cache);
+ }
}
if (die->tag == DW_TAG_structure_type)
@@ -2195,7 +2381,7 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
TYPE_CODE (type) = TYPE_CODE_CLASS;
}
- attr = dwarf_attr (die, DW_AT_byte_size);
+ attr = dwarf2_attr (die, DW_AT_byte_size, cui);
if (attr)
{
TYPE_LENGTH (type) = DW_UNSND (attr);
@@ -2210,7 +2396,9 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
type within the structure itself. */
die->type = type;
- if (die->has_children && ! die_is_declaration (die))
+ /* We cannot assume that a declaration is a stub. You can define and
+ declare something in the same place. */
+ if (die->has_children)
{
struct field_info fi;
struct die_info *child_die;
@@ -2224,27 +2412,31 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
{
if (child_die->tag == DW_TAG_member)
{
- dwarf2_add_field (&fi, child_die, objfile, cu_header);
+ dwarf2_add_field (&fi, child_die, objfile, cui);
+ }
+ else if (child_die->tag == DW_TAG_structure_type)
+ {
+ read_structure_scope (child_die, objfile, cui, TYPE_TAG_NAME (type));
}
else if (child_die->tag == DW_TAG_variable)
{
/* C++ static member. */
- dwarf2_add_field (&fi, child_die, objfile, cu_header);
+ dwarf2_add_field (&fi, child_die, objfile, cui);
}
else if (child_die->tag == DW_TAG_subprogram)
{
/* C++ member function. */
- process_die (child_die, objfile, cu_header);
- dwarf2_add_member_fn (&fi, child_die, type, objfile, cu_header);
+ process_die (child_die, objfile, cui);
+ dwarf2_add_member_fn (&fi, child_die, type, objfile, cui);
}
else if (child_die->tag == DW_TAG_inheritance)
{
/* C++ base class field. */
- dwarf2_add_field (&fi, child_die, objfile, cu_header);
+ dwarf2_add_field (&fi, child_die, objfile, cui);
}
else
{
- process_die (child_die, objfile, cu_header);
+ process_die (child_die, objfile, cui);
}
child_die = sibling_die (child_die);
}
@@ -2260,25 +2452,24 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
class itself) which contains the vtable pointer for the current
class from the DW_AT_containing_type attribute. */
- if (dwarf_attr (die, DW_AT_containing_type) != NULL)
+ if (dwarf2_attr (die, DW_AT_containing_type, cui) != NULL)
{
- struct type *t = die_containing_type (die, objfile, cu_header);
-
+ struct type *t = die_containing_type (die, objfile, cui);
TYPE_VPTR_BASETYPE (type) = t;
if (type == t)
{
static const char vptr_name[] =
- {'_', 'v', 'p', 't', 'r', '\0'};
+ { '_', 'v', 'p', 't', 'r', '\0' };
int i;
/* Our own class provides vtbl ptr. */
for (i = TYPE_NFIELDS (t) - 1;
- i >= TYPE_N_BASECLASSES (t);
- --i)
+ i >= TYPE_N_BASECLASSES (t); --i)
{
char *fieldname = TYPE_FIELD_NAME (t, i);
- if (STREQN (fieldname, vptr_name, strlen (vptr_name) - 1)
+ if (STREQN
+ (fieldname, vptr_name, strlen (vptr_name) - 1)
&& is_cplus_marker (fieldname[strlen (vptr_name)]))
{
TYPE_VPTR_FIELDNO (type) = i;
@@ -2289,7 +2480,8 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
/* Complain if virtual function table field not found. */
if (i < TYPE_N_BASECLASSES (t))
complain (&dwarf2_vtbl_not_found_complaint,
- TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : "");
+ TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) :
+ "");
}
else
{
@@ -2298,7 +2490,7 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
}
}
- new_symbol (die, type, objfile, cu_header);
+ new_symbol (die, type, objfile, cui);
do_cleanups (back_to);
}
@@ -2322,7 +2514,7 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
static void
read_enumeration (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct die_info *child_die;
struct type *type;
@@ -2335,15 +2527,16 @@ read_enumeration (struct die_info *die, struct objfile *objfile,
type = alloc_type (objfile);
TYPE_CODE (type) = TYPE_CODE_ENUM;
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
{
- TYPE_TAG_NAME (type) = obsavestring (DW_STRING (attr),
- strlen (DW_STRING (attr)),
- &objfile->type_obstack);
+ TYPE_TAG_NAME (type) = /*obsavestring (DW_STRING (attr), strlen (DW_STRING (attr))
+ &objfile->type_obstack); */
+ bcache (DW_STRING (attr), strlen (DW_STRING (attr)) + 1,
+ &objfile->psymbol_cache);
}
- attr = dwarf_attr (die, DW_AT_byte_size);
+ attr = dwarf2_attr (die, DW_AT_byte_size, cui);
if (attr)
{
TYPE_LENGTH (type) = DW_UNSND (attr);
@@ -2362,14 +2555,14 @@ read_enumeration (struct die_info *die, struct objfile *objfile,
{
if (child_die->tag != DW_TAG_enumerator)
{
- process_die (child_die, objfile, cu_header);
+ process_die (child_die, objfile, cui);
}
else
{
- attr = dwarf_attr (child_die, DW_AT_name);
+ attr = dwarf2_attr (child_die, DW_AT_name, cui);
if (attr)
{
- sym = new_symbol (child_die, type, objfile, cu_header);
+ sym = new_symbol (child_die, type, objfile, cui);
if (SYMBOL_VALUE (sym) < 0)
unsigned_enum = 0;
@@ -2402,11 +2595,13 @@ read_enumeration (struct die_info *die, struct objfile *objfile,
sizeof (struct field) * num_fields);
xfree (fields);
}
+#if TYPEFIX
if (unsigned_enum)
TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
+#endif
}
die->type = type;
- new_symbol (die, type, objfile, cu_header);
+ new_symbol (die, type, objfile, cui);
}
/* Extract all information from a DW_TAG_array_type DIE and put it in
@@ -2415,12 +2610,13 @@ read_enumeration (struct die_info *die, struct objfile *objfile,
static void
read_array_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct die_info *child_die;
struct type *type = NULL;
- struct type *element_type, *range_type, *index_type;
- struct type **range_types = NULL;
+ struct type *element_type, *index_type;
+ struct range_type *range_type;
+ struct range_type **range_types = NULL;
struct attribute *attr;
int ndim = 0;
struct cleanup *back_to;
@@ -2431,15 +2627,15 @@ read_array_type (struct die_info *die, struct objfile *objfile,
return;
}
- element_type = die_type (die, objfile, cu_header);
+ element_type = die_type (die, objfile, cui);
/* Irix 6.2 native cc creates array types without children for
arrays with unspecified length. */
if (die->has_children == 0)
{
- index_type = dwarf2_fundamental_type (objfile, FT_INTEGER);
- range_type = create_range_type (NULL, index_type, 0, -1);
- die->type = create_array_type (NULL, element_type, range_type);
+ index_type = dwarf2_fundamental_type (objfile, FT_INTEGER, cui);
+ range_type = make_range_type (objfile, index_type, 0, -1);
+ die->type = (struct type *)make_array_type (objfile, element_type, range_type);
return;
}
@@ -2454,14 +2650,14 @@ read_array_type (struct die_info *die, struct objfile *objfile,
/* Default bounds to an array with unspecified length. */
low = 0;
high = -1;
- if (cu_language == language_fortran)
+ if (cui->cu_language == language_fortran)
{
/* FORTRAN implies a lower bound of 1, if not given. */
low = 1;
}
- index_type = die_type (child_die, objfile, cu_header);
- attr = dwarf_attr (child_die, DW_AT_lower_bound);
+ index_type = die_type (child_die, objfile, cui);
+ attr = dwarf2_attr (child_die, DW_AT_lower_bound, cui);
if (attr)
{
if (attr->form == DW_FORM_sdata)
@@ -2478,7 +2674,7 @@ read_array_type (struct die_info *die, struct objfile *objfile,
else
{
complain (&dwarf2_non_const_array_bound_ignored,
- dwarf_form_name (attr->form));
+ dwarf2_form_name (attr->form));
#ifdef FORTRAN_HACK
die->type = lookup_pointer_type (element_type);
return;
@@ -2487,7 +2683,7 @@ read_array_type (struct die_info *die, struct objfile *objfile,
#endif
}
}
- attr = dwarf_attr (child_die, DW_AT_upper_bound);
+ attr = dwarf2_attr (child_die, DW_AT_upper_bound, cui);
if (attr)
{
if (attr->form == DW_FORM_sdata)
@@ -2513,7 +2709,7 @@ read_array_type (struct die_info *die, struct objfile *objfile,
else
{
complain (&dwarf2_non_const_array_bound_ignored,
- dwarf_form_name (attr->form));
+ dwarf2_form_name (attr->form));
#ifdef FORTRAN_HACK
die->type = lookup_pointer_type (element_type);
return;
@@ -2526,13 +2722,14 @@ read_array_type (struct die_info *die, struct objfile *objfile,
/* Create a range type and save it for array type creation. */
if ((ndim % DW_FIELD_ALLOC_CHUNK) == 0)
{
- range_types = (struct type **)
+ range_types = (struct range_type **)
xrealloc (range_types, (ndim + DW_FIELD_ALLOC_CHUNK)
- * sizeof (struct type *));
+ * sizeof (struct range_type *));
if (ndim == 0)
make_cleanup (free_current_contents, &range_types);
}
- range_types[ndim++] = create_range_type (NULL, index_type, low, high);
+ range_types[ndim++] =
+ make_range_type (objfile, index_type, low, high);
}
child_die = sibling_die (child_die);
}
@@ -2541,7 +2738,7 @@ read_array_type (struct die_info *die, struct objfile *objfile,
necessary array types in backwards order. */
type = element_type;
while (ndim-- > 0)
- type = create_array_type (NULL, type, range_types[ndim]);
+ type = (struct type *)make_array_type (objfile, type, range_types[ndim]);
do_cleanups (back_to);
@@ -2553,29 +2750,29 @@ read_array_type (struct die_info *die, struct objfile *objfile,
static void
read_common_block (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct die_info *child_die;
struct attribute *attr;
struct symbol *sym;
CORE_ADDR base = (CORE_ADDR) 0;
- attr = dwarf_attr (die, DW_AT_location);
+ attr = dwarf2_attr (die, DW_AT_location, cui);
if (attr)
{
- base = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ base = decode_locdesc (DW_BLOCK (attr), objfile, cui);
}
if (die->has_children)
{
child_die = die->next;
while (child_die && child_die->tag)
{
- sym = new_symbol (child_die, NULL, objfile, cu_header);
- attr = dwarf_attr (child_die, DW_AT_data_member_location);
+ sym = new_symbol (child_die, NULL, objfile, cui);
+ attr = dwarf2_attr (child_die, DW_AT_data_member_location, cui);
if (attr)
{
SYMBOL_VALUE_ADDRESS (sym) =
- base + decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ base + decode_locdesc (DW_BLOCK (attr), objfile, cui);
add_symbol_to_list (sym, &global_symbols);
}
child_die = sibling_die (child_die);
@@ -2588,7 +2785,7 @@ read_common_block (struct die_info *die, struct objfile *objfile,
static void
read_tag_pointer_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *type;
struct attribute *attr;
@@ -2598,15 +2795,15 @@ read_tag_pointer_type (struct die_info *die, struct objfile *objfile,
return;
}
- type = lookup_pointer_type (die_type (die, objfile, cu_header));
- attr = dwarf_attr (die, DW_AT_byte_size);
+ type = lookup_pointer_type (die_type (die, objfile, cui));
+ attr = dwarf2_attr (die, DW_AT_byte_size, cui);
if (attr)
{
TYPE_LENGTH (type) = DW_UNSND (attr);
}
else
{
- TYPE_LENGTH (type) = cu_header->addr_size;
+ TYPE_LENGTH (type) = cui->cu_header.addr_size;
}
die->type = type;
}
@@ -2616,7 +2813,7 @@ read_tag_pointer_type (struct die_info *die, struct objfile *objfile,
static void
read_tag_ptr_to_member_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *type;
struct type *to_type;
@@ -2628,8 +2825,8 @@ read_tag_ptr_to_member_type (struct die_info *die, struct objfile *objfile,
}
type = alloc_type (objfile);
- to_type = die_type (die, objfile, cu_header);
- domain = die_containing_type (die, objfile, cu_header);
+ to_type = die_type (die, objfile, cui);
+ domain = die_containing_type (die, objfile, cui);
smash_to_member_type (type, domain, to_type);
die->type = type;
@@ -2640,7 +2837,7 @@ read_tag_ptr_to_member_type (struct die_info *die, struct objfile *objfile,
static void
read_tag_reference_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *type;
struct attribute *attr;
@@ -2650,22 +2847,22 @@ read_tag_reference_type (struct die_info *die, struct objfile *objfile,
return;
}
- type = lookup_reference_type (die_type (die, objfile, cu_header));
- attr = dwarf_attr (die, DW_AT_byte_size);
+ type = lookup_reference_type (die_type (die, objfile, cui));
+ attr = dwarf2_attr (die, DW_AT_byte_size, cui);
if (attr)
{
TYPE_LENGTH (type) = DW_UNSND (attr);
}
else
{
- TYPE_LENGTH (type) = cu_header->addr_size;
+ TYPE_LENGTH (type) = cui->cu_header.addr_size;
}
die->type = type;
}
static void
read_tag_const_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *base_type;
@@ -2674,13 +2871,13 @@ read_tag_const_type (struct die_info *die, struct objfile *objfile,
return;
}
- base_type = die_type (die, objfile, cu_header);
+ base_type = die_type (die, objfile, cui);
die->type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
}
static void
read_tag_volatile_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *base_type;
@@ -2689,7 +2886,7 @@ read_tag_volatile_type (struct die_info *die, struct objfile *objfile,
return;
}
- base_type = die_type (die, objfile, cu_header);
+ base_type = die_type (die, objfile, cui);
die->type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0);
}
@@ -2699,9 +2896,11 @@ read_tag_volatile_type (struct die_info *die, struct objfile *objfile,
attribute to reference it. */
static void
-read_tag_string_type (struct die_info *die, struct objfile *objfile)
+read_tag_string_type (struct die_info *die, struct objfile *objfile,
+ const struct comp_unit_instance *cui)
{
- struct type *type, *range_type, *index_type, *char_type;
+ struct type *type, *index_type, *char_type;
+ struct range_type *range_type;
struct attribute *attr;
unsigned int length;
@@ -2710,7 +2909,7 @@ read_tag_string_type (struct die_info *die, struct objfile *objfile)
return;
}
- attr = dwarf_attr (die, DW_AT_string_length);
+ attr = dwarf2_attr (die, DW_AT_string_length, cui);
if (attr)
{
length = DW_UNSND (attr);
@@ -2719,10 +2918,11 @@ read_tag_string_type (struct die_info *die, struct objfile *objfile)
{
length = 1;
}
- index_type = dwarf2_fundamental_type (objfile, FT_INTEGER);
- range_type = create_range_type (NULL, index_type, 1, length);
- char_type = dwarf2_fundamental_type (objfile, FT_CHAR);
- type = create_string_type (char_type, range_type);
+ index_type = dwarf2_fundamental_type (objfile, FT_INTEGER, cui);
+ range_type = make_range_type (objfile, index_type, 1, length);
+/* TYPEFIX : Is this still necessary?
+ char_type = dwarf2_fundamental_type (objfile, FT_CHAR, cui);*/
+ type = (struct type *)make_string_type (objfile, range_type);
die->type = type;
}
@@ -2739,24 +2939,23 @@ read_tag_string_type (struct die_info *die, struct objfile *objfile)
static void
read_subroutine_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
+#if TYPEFIX
struct type *type; /* Type that this function returns */
struct type *ftype; /* Function that returns above type */
struct attribute *attr;
/* Decode the type that this subroutine returns */
if (die->type)
- {
return;
- }
- type = die_type (die, objfile, cu_header);
+
+ type = die_type (die, objfile, cui);
ftype = lookup_function_type (type);
/* All functions in C++ have prototypes. */
- attr = dwarf_attr (die, DW_AT_prototyped);
- if ((attr && (DW_UNSND (attr) != 0))
- || cu_language == language_cplus)
+ attr = dwarf2_attr (die, DW_AT_prototyped, cui);
+ if ((attr && (DW_UNSND (attr) != 0)) || cui->cu_language == language_cplus)
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
if (die->has_children)
@@ -2793,13 +2992,13 @@ read_subroutine_type (struct die_info *die, struct objfile *objfile,
parameter for non-static member functions (which is the
this pointer) as artificial. We pass this information
to dwarf2_add_member_fn via TYPE_FIELD_ARTIFICIAL. */
- attr = dwarf_attr (child_die, DW_AT_artificial);
+ attr = dwarf2_attr (child_die, DW_AT_artificial, cui);
if (attr)
TYPE_FIELD_ARTIFICIAL (ftype, iparams) = DW_UNSND (attr);
else
TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die, objfile,
- cu_header);
+ cui);
iparams++;
}
child_die = sibling_die (child_die);
@@ -2807,11 +3006,12 @@ read_subroutine_type (struct die_info *die, struct objfile *objfile,
}
die->type = ftype;
+#endif
}
static void
read_typedef (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *type;
@@ -2820,17 +3020,19 @@ read_typedef (struct die_info *die, struct objfile *objfile,
struct attribute *attr;
struct type *xtype;
- xtype = die_type (die, objfile, cu_header);
+ xtype = die_type (die, objfile, cui);
type = alloc_type (objfile);
TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
TYPE_TARGET_TYPE (type) = xtype;
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
- TYPE_NAME (type) = obsavestring (DW_STRING (attr),
- strlen (DW_STRING (attr)),
- &objfile->type_obstack);
+ TYPE_NAME (type) = /*obsavestring (DW_STRING (attr),
+ strlen (DW_STRING (attr)),
+ &objfile->type_obstack); */ bcache (DW_STRING (attr),
+ strlen (DW_STRING (attr)) + 1,
+ &objfile->psymbol_cache);
die->type = type;
}
@@ -2840,7 +3042,8 @@ read_typedef (struct die_info *die, struct objfile *objfile,
it in the TYPE field of the die. */
static void
-read_base_type (struct die_info *die, struct objfile *objfile)
+read_base_type (struct die_info *die, struct objfile *objfile,
+ const struct comp_unit_instance *cui)
{
struct type *type;
struct attribute *attr;
@@ -2852,17 +3055,17 @@ read_base_type (struct die_info *die, struct objfile *objfile)
return;
}
- attr = dwarf_attr (die, DW_AT_encoding);
+ attr = dwarf2_attr (die, DW_AT_encoding, cui);
if (attr)
{
encoding = DW_UNSND (attr);
}
- attr = dwarf_attr (die, DW_AT_byte_size);
+ attr = dwarf2_attr (die, DW_AT_byte_size, cui);
if (attr)
{
size = DW_UNSND (attr);
}
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
{
enum type_code code = TYPE_CODE_INT;
@@ -2894,25 +3097,27 @@ read_base_type (struct die_info *die, struct objfile *objfile)
break;
default:
complain (&dwarf2_unsupported_at_encoding,
- dwarf_type_encoding_name (encoding));
+ dwarf2_type_encoding_name (encoding));
break;
}
- type = init_type (code, size, is_unsigned, DW_STRING (attr), objfile);
if (encoding == DW_ATE_address)
- TYPE_TARGET_TYPE (type) = dwarf2_fundamental_type (objfile, FT_VOID);
+ type = (struct type *)make_pointer_type (objfile, dwarf2_fundamental_type (objfile, FT_VOID, cui));
+ else
+ type = init_type (code, size, is_unsigned, DW_STRING (attr), objfile);
+
}
else
{
- type = dwarf_base_type (encoding, size, objfile);
+ type = dwarf2_base_type (encoding, size, objfile, cui);
}
die->type = type;
}
/* Read a whole compilation unit into a linked list of dies. */
-static struct die_info *
-read_comp_unit (char *info_ptr, bfd *abfd,
- const struct comp_unit_head *cu_header)
+struct die_info *
+read_comp_unit_dies (char *info_ptr, bfd * abfd,
+ const struct comp_unit_instance *cui)
{
struct die_info *first_die, *last_die, *die;
char *cur_ptr;
@@ -2920,14 +3125,14 @@ read_comp_unit (char *info_ptr, bfd *abfd,
/* Reset die reference table; we are
building new ones now. */
- dwarf2_empty_hash_tables ();
+ dwarf2_empty_hash_tables ((struct comp_unit_instance *) cui);
cur_ptr = info_ptr;
nesting_level = 0;
first_die = last_die = NULL;
do
{
- cur_ptr = read_full_die (&die, abfd, cur_ptr, cu_header);
+ cur_ptr = read_full_die (&die, abfd, cur_ptr, cui);
if (die->has_children)
{
nesting_level++;
@@ -2940,7 +3145,8 @@ read_comp_unit (char *info_ptr, bfd *abfd,
die->next = NULL;
/* Enter die in reference hash table */
- store_in_ref_table (die->offset, die);
+ store_in_ref_table (die->offset, die,
+ (struct comp_unit_instance *) cui);
if (!first_die)
{
@@ -2987,7 +3193,7 @@ make_cleanup_free_die_list (struct die_info *dies)
/* Read the contents of the section at OFFSET and of size SIZE from the
- object file specified by OBJFILE into the psymbol_obstack and return it. */
+ object file specified by OBJFILE and return it. */
static char *
dwarf2_read_section (struct objfile *objfile, file_ptr offset,
@@ -2998,8 +3204,7 @@ dwarf2_read_section (struct objfile *objfile, file_ptr offset,
if (size == 0)
return NULL;
-
- buf = (char *) obstack_alloc (&objfile->psymbol_obstack, size);
+ buf = (char *) xmalloc (size);
if ((bfd_seek (abfd, offset, SEEK_SET) != 0) ||
(bfd_read (buf, size, 1, abfd) != size))
{
@@ -3016,7 +3221,8 @@ dwarf2_read_section (struct objfile *objfile, file_ptr offset,
in a hash table. */
static void
-dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
+dwarf2_read_abbrevs (bfd * abfd, struct comp_unit_instance *cui,
+ unsigned int offset)
{
char *abbrev_ptr;
struct abbrev_info *cur_abbrev;
@@ -3024,16 +3230,16 @@ dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
unsigned int abbrev_form, hash_number;
/* empty the table */
- dwarf2_empty_abbrev_table (NULL);
+ dwarf2_empty_abbrev_table (cui);
- abbrev_ptr = dwarf_abbrev_buffer + offset;
+ abbrev_ptr = dwarf2_abbrev_buffer + offset;
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
/* loop until we reach an abbrev number of 0 */
while (abbrev_number)
{
- cur_abbrev = dwarf_alloc_abbrev ();
+ cur_abbrev = dwarf2_alloc_abbrev ();
/* read in abbrev header */
cur_abbrev->number = abbrev_number;
@@ -3065,8 +3271,8 @@ dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
}
hash_number = abbrev_number % ABBREV_HASH_SIZE;
- cur_abbrev->next = dwarf2_abbrevs[hash_number];
- dwarf2_abbrevs[hash_number] = cur_abbrev;
+ cur_abbrev->next = cui->dwarf2_abbrevs[hash_number];
+ cui->dwarf2_abbrevs[hash_number] = cur_abbrev;
/* Get next abbreviation.
Under Irix6 the abbreviations for a compilation unit are not
@@ -3075,12 +3281,12 @@ dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
already read (which means we are about to read the abbreviations
for the next compile unit) or if the end of the abbreviation
table is reached. */
- if ((unsigned int) (abbrev_ptr - dwarf_abbrev_buffer)
- >= dwarf_abbrev_size)
+ if ((unsigned int) (abbrev_ptr - dwarf2_abbrev_buffer)
+ >= dwarf2_abbrev_size)
break;
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
- if (dwarf2_lookup_abbrev (abbrev_number) != NULL)
+ if (dwarf2_lookup_abbrev (abbrev_number, cui) != NULL)
break;
}
}
@@ -3089,15 +3295,15 @@ dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
/* ARGSUSED */
static void
-dwarf2_empty_abbrev_table (PTR ignore)
+dwarf2_empty_abbrev_table (PTR cu)
{
int i;
struct abbrev_info *abbrev, *next;
-
+ struct comp_unit_instance *cui = (struct comp_unit_instance *) cu;
for (i = 0; i < ABBREV_HASH_SIZE; ++i)
{
next = NULL;
- abbrev = dwarf2_abbrevs[i];
+ abbrev = cui->dwarf2_abbrevs[i];
while (abbrev)
{
next = abbrev->next;
@@ -3105,20 +3311,23 @@ dwarf2_empty_abbrev_table (PTR ignore)
xfree (abbrev);
abbrev = next;
}
- dwarf2_abbrevs[i] = NULL;
+ cui->dwarf2_abbrevs[i] = NULL;
}
}
/* Lookup an abbrev_info structure in the abbrev hash table. */
static struct abbrev_info *
-dwarf2_lookup_abbrev (unsigned int number)
+dwarf2_lookup_abbrev (unsigned int number,
+ const struct comp_unit_instance *cui)
{
unsigned int hash_number;
struct abbrev_info *abbrev;
+ struct comp_unit_instance *cui_for_die;
+
hash_number = number % ABBREV_HASH_SIZE;
- abbrev = dwarf2_abbrevs[hash_number];
+ abbrev = cui->dwarf2_abbrevs[hash_number];
while (abbrev)
{
@@ -3133,8 +3342,9 @@ dwarf2_lookup_abbrev (unsigned int number)
/* Read a minimal amount of information into the minimal die structure. */
static char *
-read_partial_die (struct partial_die_info *part_die, bfd *abfd,
- char *info_ptr, const struct comp_unit_head *cu_header)
+read_partial_die (struct partial_die_info *part_die, bfd * abfd,
+ char *info_ptr, int *has_pc_info,
+ const struct comp_unit_instance *cui)
{
unsigned int abbrev_number, bytes_read, i;
struct abbrev_info *abbrev;
@@ -3144,18 +3354,20 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd,
int has_low_pc_attr = 0;
int has_high_pc_attr = 0;
- *part_die = zeroed_partial_die;
+
+ memset(part_die, 0, sizeof(struct partial_die_info));
+ *has_pc_info = 0;
abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
if (!abbrev_number)
return info_ptr;
- abbrev = dwarf2_lookup_abbrev (abbrev_number);
+ abbrev = dwarf2_lookup_abbrev (abbrev_number, cui);
if (!abbrev)
{
error ("Dwarf Error: Could not find abbrev number %d.", abbrev_number);
}
- part_die->offset = info_ptr - dwarf_info_buffer;
+ part_die->offset = info_ptr - dwarf2_info_buffer;
part_die->tag = abbrev->tag;
part_die->has_children = abbrev->has_children;
part_die->abbrev = abbrev_number;
@@ -3163,14 +3375,13 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd,
for (i = 0; i < abbrev->num_attrs; ++i)
{
info_ptr = read_attribute (&attr, &abbrev->attrs[i], abfd,
- info_ptr, cu_header);
+ info_ptr, cui);
/* Store the data if it is of an attribute we want to keep in a
partial symbol table. */
switch (attr.name)
{
case DW_AT_name:
-
/* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
if (part_die->name == NULL)
part_die->name = DW_STRING (&attr);
@@ -3213,7 +3424,7 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd,
complain (&dwarf2_absolute_sibling_complaint);
else
part_die->sibling =
- dwarf_info_buffer + dwarf2_get_ref_die_offset (&attr);
+ dwarf2_info_buffer + dwarf2_get_ref_die_offset (cui, &attr);
break;
default:
break;
@@ -3228,12 +3439,14 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd,
struct partial_die_info spec_die;
char *spec_ptr;
int dummy;
-
- spec_ptr = dwarf_info_buffer + dwarf2_get_ref_die_offset (&spec_attr);
- read_partial_die (&spec_die, abfd, spec_ptr, cu_header);
+ part_die->name = get_pubname_for_offset (abfd, part_die->offset, cui);
+ spec_ptr =
+ dwarf2_info_buffer + dwarf2_get_ref_die_offset (cui, &spec_attr);
+ read_partial_die (&spec_die, abfd, spec_ptr, &dummy, cui);
if (spec_die.name)
{
- part_die->name = spec_die.name;
+ if (part_die->name == NULL)
+ part_die->name = spec_die.name;
/* Copy DW_AT_external attribute if it is set. */
if (spec_die.is_external)
@@ -3251,9 +3464,8 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd,
so that GDB will ignore it. */
if (has_low_pc_attr && has_high_pc_attr
&& part_die->lowpc < part_die->highpc
- && (part_die->lowpc != 0
- || (bfd_get_file_flags (abfd) & HAS_RELOC)))
- part_die->has_pc_info = 1;
+ && (part_die->lowpc != 0 || (bfd_get_file_flags (abfd) & HAS_RELOC)))
+ *has_pc_info = 1;
return info_ptr;
}
@@ -3261,19 +3473,19 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd,
point to a newly allocated die with its information. */
static char *
-read_full_die (struct die_info **diep, bfd *abfd, char *info_ptr,
- const struct comp_unit_head *cu_header)
+read_full_die (struct die_info **diep, bfd * abfd, char *info_ptr,
+ const struct comp_unit_instance *cui)
{
unsigned int abbrev_number, bytes_read, i, offset;
struct abbrev_info *abbrev;
struct die_info *die;
- offset = info_ptr - dwarf_info_buffer;
+ offset = info_ptr - dwarf2_info_buffer;
abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
if (!abbrev_number)
{
- die = dwarf_alloc_die ();
+ die = dwarf2_alloc_die ();
die->tag = 0;
die->abbrev = abbrev_number;
die->type = NULL;
@@ -3281,12 +3493,12 @@ read_full_die (struct die_info **diep, bfd *abfd, char *info_ptr,
return info_ptr;
}
- abbrev = dwarf2_lookup_abbrev (abbrev_number);
+ abbrev = dwarf2_lookup_abbrev (abbrev_number, cui);
if (!abbrev)
{
error ("Dwarf Error: could not find abbrev number %d.", abbrev_number);
}
- die = dwarf_alloc_die ();
+ die = dwarf2_alloc_die ();
die->offset = offset;
die->tag = abbrev->tag;
die->has_children = abbrev->has_children;
@@ -3300,7 +3512,7 @@ read_full_die (struct die_info **diep, bfd *abfd, char *info_ptr,
for (i = 0; i < abbrev->num_attrs; ++i)
{
info_ptr = read_attribute (&die->attrs[i], &abbrev->attrs[i],
- abfd, info_ptr, cu_header);
+ abfd, info_ptr, cui);
}
*diep = die;
@@ -3311,11 +3523,11 @@ read_full_die (struct die_info **diep, bfd *abfd, char *info_ptr,
static char *
read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
- bfd *abfd, char *info_ptr,
- const struct comp_unit_head *cu_header)
+ bfd * abfd, char *info_ptr,
+ const struct comp_unit_instance *cui)
{
unsigned int bytes_read;
- struct dwarf_block *blk;
+ struct dwarf2_block *blk;
attr->name = abbrev->name;
attr->form = abbrev->form;
@@ -3323,11 +3535,11 @@ read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
{
case DW_FORM_addr:
case DW_FORM_ref_addr:
- DW_ADDR (attr) = read_address (abfd, info_ptr, cu_header, &bytes_read);
+ DW_ADDR (attr) = read_address (abfd, info_ptr, cui, &bytes_read);
info_ptr += bytes_read;
break;
case DW_FORM_block2:
- blk = dwarf_alloc_block ();
+ blk = dwarf2_alloc_block ();
blk->size = read_2_bytes (abfd, info_ptr);
info_ptr += 2;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
@@ -3335,7 +3547,7 @@ read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
DW_BLOCK (attr) = blk;
break;
case DW_FORM_block4:
- blk = dwarf_alloc_block ();
+ blk = dwarf2_alloc_block ();
blk->size = read_4_bytes (abfd, info_ptr);
info_ptr += 4;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
@@ -3359,7 +3571,7 @@ read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
info_ptr += bytes_read;
break;
case DW_FORM_block:
- blk = dwarf_alloc_block ();
+ blk = dwarf2_alloc_block ();
blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
@@ -3367,7 +3579,7 @@ read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
DW_BLOCK (attr) = blk;
break;
case DW_FORM_block1:
- blk = dwarf_alloc_block ();
+ blk = dwarf2_alloc_block ();
blk->size = read_1_byte (abfd, info_ptr);
info_ptr += 1;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
@@ -3414,7 +3626,7 @@ read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
case DW_FORM_indirect:
default:
error ("Dwarf Error: Cannot handle %s in DWARF reader.",
- dwarf_form_name (abbrev->form));
+ dwarf2_form_name (abbrev->form));
}
return info_ptr;
}
@@ -3422,56 +3634,56 @@ read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
/* read dwarf information from a buffer */
static unsigned int
-read_1_byte (bfd *abfd, char *buf)
+read_1_byte (bfd * abfd, char *buf)
{
return bfd_get_8 (abfd, (bfd_byte *) buf);
}
static int
-read_1_signed_byte (bfd *abfd, char *buf)
+read_1_signed_byte (bfd * abfd, char *buf)
{
return bfd_get_signed_8 (abfd, (bfd_byte *) buf);
}
static unsigned int
-read_2_bytes (bfd *abfd, char *buf)
+read_2_bytes (bfd * abfd, char *buf)
{
return bfd_get_16 (abfd, (bfd_byte *) buf);
}
static int
-read_2_signed_bytes (bfd *abfd, char *buf)
+read_2_signed_bytes (bfd * abfd, char *buf)
{
return bfd_get_signed_16 (abfd, (bfd_byte *) buf);
}
static unsigned int
-read_4_bytes (bfd *abfd, char *buf)
+read_4_bytes (bfd * abfd, char *buf)
{
return bfd_get_32 (abfd, (bfd_byte *) buf);
}
static int
-read_4_signed_bytes (bfd *abfd, char *buf)
+read_4_signed_bytes (bfd * abfd, char *buf)
{
return bfd_get_signed_32 (abfd, (bfd_byte *) buf);
}
static unsigned long
-read_8_bytes (bfd *abfd, char *buf)
+read_8_bytes (bfd * abfd, char *buf)
{
return bfd_get_64 (abfd, (bfd_byte *) buf);
}
static CORE_ADDR
-read_address (bfd *abfd, char *buf, const struct comp_unit_head *cu_header,
+read_address (bfd * abfd, char *buf, const struct comp_unit_instance *cui,
int *bytes_read)
{
CORE_ADDR retval = 0;
- if (cu_header->signed_addr_p)
+ if (cui->cu_header.signed_addr_p)
{
- switch (cu_header->addr_size)
+ switch (cui->cu_header.addr_size)
{
case 2:
retval = bfd_get_signed_16 (abfd, (bfd_byte *) buf);
@@ -3489,7 +3701,7 @@ read_address (bfd *abfd, char *buf, const struct comp_unit_head *cu_header,
}
else
{
- switch (cu_header->addr_size)
+ switch (cui->cu_header.addr_size)
{
case 2:
retval = bfd_get_16 (abfd, (bfd_byte *) buf);
@@ -3506,7 +3718,7 @@ read_address (bfd *abfd, char *buf, const struct comp_unit_head *cu_header,
}
}
- *bytes_read = cu_header->addr_size;
+ *bytes_read = cui->cu_header.addr_size;
return retval;
}
@@ -3537,8 +3749,8 @@ read_address (bfd *abfd, char *buf, const struct comp_unit_head *cu_header,
] */
static LONGEST
-read_initial_length (bfd *abfd, char *buf, struct comp_unit_head *cu_header,
- int *bytes_read)
+read_initial_length (bfd * abfd, char *buf, struct comp_unit_head *cu_header,
+ int *bytes_read)
{
LONGEST retval = 0;
@@ -3564,15 +3776,15 @@ read_initial_length (bfd *abfd, char *buf, struct comp_unit_head *cu_header,
}
}
- return retval;
+ return retval;
}
/* Read an offset from the data stream. The size of the offset is
given by cu_header->offset_size. */
static LONGEST
-read_offset (bfd *abfd, char *buf, const struct comp_unit_head *cu_header,
- int *bytes_read)
+read_offset (bfd * abfd, char *buf, const struct comp_unit_head *cu_header,
+ int *bytes_read)
{
LONGEST retval = 0;
@@ -3587,15 +3799,14 @@ read_offset (bfd *abfd, char *buf, const struct comp_unit_head *cu_header,
*bytes_read = 8;
break;
default:
- internal_error (__FILE__, __LINE__,
- "read_offset: bad switch");
+ internal_error (__FILE__, __LINE__, "read_offset: bad switch");
}
- return retval;
+ return retval;
}
static char *
-read_n_bytes (bfd *abfd, char *buf, unsigned int size)
+read_n_bytes (bfd * abfd, char *buf, unsigned int size)
{
/* If the size of a host char is 8 bits, we can return a pointer
to the buffer, otherwise we have to copy the data to a buffer
@@ -3617,7 +3828,7 @@ read_n_bytes (bfd *abfd, char *buf, unsigned int size)
}
static char *
-read_string (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
+read_string (bfd * abfd, char *buf, unsigned int *bytes_read_ptr)
{
/* If the size of a host char is 8 bits, we can return a pointer
to the string, otherwise we have to copy the string to a buffer
@@ -3652,7 +3863,7 @@ read_string (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
}
static unsigned long
-read_unsigned_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
+read_unsigned_leb128 (bfd * abfd, char *buf, unsigned int *bytes_read_ptr)
{
unsigned long result;
unsigned int num_read;
@@ -3668,7 +3879,7 @@ read_unsigned_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
byte = bfd_get_8 (abfd, (bfd_byte *) buf);
buf++;
num_read++;
- result |= ((unsigned long)(byte & 127) << shift);
+ result |= ((unsigned long) (byte & 127) << shift);
if ((byte & 128) == 0)
{
break;
@@ -3680,7 +3891,7 @@ read_unsigned_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
}
static long
-read_signed_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
+read_signed_leb128 (bfd * abfd, char *buf, unsigned int *bytes_read_ptr)
{
long result;
int i, shift, size, num_read;
@@ -3696,7 +3907,7 @@ read_signed_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
byte = bfd_get_8 (abfd, (bfd_byte *) buf);
buf++;
num_read++;
- result |= ((long)(byte & 127) << shift);
+ result |= ((long) (byte & 127) << shift);
shift += 7;
if ((byte & 128) == 0)
{
@@ -3712,26 +3923,26 @@ read_signed_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
}
static void
-set_cu_language (unsigned int lang)
+set_cu_language (struct comp_unit_instance *cui, unsigned int lang)
{
switch (lang)
{
case DW_LANG_C89:
case DW_LANG_C:
- cu_language = language_c;
+ cui->cu_language = language_c;
break;
case DW_LANG_C_plus_plus:
- cu_language = language_cplus;
+ cui->cu_language = language_cplus;
break;
case DW_LANG_Fortran77:
case DW_LANG_Fortran90:
- cu_language = language_fortran;
+ cui->cu_language = language_fortran;
break;
case DW_LANG_Mips_Assembler:
- cu_language = language_asm;
+ cui->cu_language = language_asm;
break;
case DW_LANG_Java:
- cu_language = language_java;
+ cui->cu_language = language_java;
break;
case DW_LANG_Ada83:
case DW_LANG_Cobol74:
@@ -3739,16 +3950,17 @@ set_cu_language (unsigned int lang)
case DW_LANG_Pascal83:
case DW_LANG_Modula2:
default:
- cu_language = language_unknown;
+ cui->cu_language = language_unknown;
break;
}
- cu_language_defn = language_def (cu_language);
+ cui->cu_language_defn = language_def (cui->cu_language);
}
/* Return the named attribute or NULL if not there. */
static struct attribute *
-dwarf_attr (struct die_info *die, unsigned int name)
+dwarf2_attr (struct die_info *die, unsigned int name,
+ const struct comp_unit_instance *cui)
{
unsigned int i;
struct attribute *spec = NULL;
@@ -3756,9 +3968,8 @@ dwarf_attr (struct die_info *die, unsigned int name)
for (i = 0; i < die->num_attrs; ++i)
{
if (die->attrs[i].name == name)
- {
return &die->attrs[i];
- }
+
if (die->attrs[i].name == DW_AT_specification
|| die->attrs[i].name == DW_AT_abstract_origin)
spec = &die->attrs[i];
@@ -3766,22 +3977,13 @@ dwarf_attr (struct die_info *die, unsigned int name)
if (spec)
{
struct die_info *ref_die =
- follow_die_ref (dwarf2_get_ref_die_offset (spec));
-
+ follow_die_ref (dwarf2_get_ref_die_offset (cui, spec), cui);
if (ref_die)
- return dwarf_attr (ref_die, name);
+ return dwarf2_attr (ref_die, name, cui);
}
-
return NULL;
}
-static int
-die_is_declaration (struct die_info *die)
-{
- return (dwarf_attr (die, DW_AT_declaration)
- && ! dwarf_attr (die, DW_AT_specification));
-}
-
/* Decode the line number information for the compilation unit whose
line number info is at OFFSET in the .debug_line section.
The compilation directory of the file is passed in COMP_DIR. */
@@ -3790,24 +3992,24 @@ struct filenames
{
unsigned int num_files;
struct fileinfo
- {
- char *name;
- unsigned int dir;
- unsigned int time;
- unsigned int size;
- }
+ {
+ char *name;
+ unsigned int dir;
+ unsigned int time;
+ unsigned int size;
+ }
*files;
};
struct directories
- {
- unsigned int num_dirs;
- char **dirs;
- };
+{
+ unsigned int num_dirs;
+ char **dirs;
+};
static void
-dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
- const struct comp_unit_head *cu_header)
+dwarf2_decode_lines (unsigned int offset, char *comp_dir, bfd * abfd,
+ const struct comp_unit_instance *cui)
{
char *line_ptr;
char *line_end;
@@ -3823,7 +4025,7 @@ dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
struct filenames files;
struct directories dirs;
- if (dwarf_line_buffer == NULL)
+ if (dwarf2_line_buffer == NULL)
{
complain (&dwarf2_missing_line_number_section);
return;
@@ -3835,7 +4037,7 @@ dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
dirs.num_dirs = 0;
dirs.dirs = NULL;
- line_ptr = dwarf_line_buffer + offset;
+ line_ptr = dwarf2_line_buffer + offset;
/* read in the prologue */
lh.total_length = read_initial_length (abfd, line_ptr, NULL, &bytes_read);
@@ -3843,7 +4045,8 @@ dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
line_end = line_ptr + lh.total_length;
lh.version = read_2_bytes (abfd, line_ptr);
line_ptr += 2;
- lh.prologue_length = read_offset (abfd, line_ptr, cu_header, &bytes_read);
+ lh.prologue_length =
+ read_offset (abfd, line_ptr, &cui->cu_header, &bytes_read);
line_ptr += bytes_read;
lh.minimum_instruction_length = read_1_byte (abfd, line_ptr);
line_ptr += 1;
@@ -3955,7 +4158,7 @@ dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
not the ends. This is a weakness of GDB. */
break;
case DW_LNE_set_address:
- address = read_address (abfd, line_ptr, cu_header, &bytes_read);
+ address = read_address (abfd, line_ptr, cui, &bytes_read);
line_ptr += bytes_read;
address += baseaddr;
break;
@@ -4009,8 +4212,7 @@ dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
dwarf2_start_subfile
(files.files[file - 1].name,
(files.files[file - 1].dir
- ? dirs.dirs[files.files[file - 1].dir - 1]
- : comp_dir));
+ ? dirs.dirs[files.files[file - 1].dir - 1] : comp_dir));
break;
case DW_LNS_set_column:
column = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
@@ -4022,11 +4224,11 @@ dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
case DW_LNS_set_basic_block:
basic_block = 1;
break;
- /* Add to the address register of the state machine the
- address increment value corresponding to special opcode
- 255. Ie, this value is scaled by the minimum instruction
- length since special opcode 255 would have scaled the
- the increment. */
+ /* Add to the address register of the state machine the
+ address increment value corresponding to special opcode
+ 255. Ie, this value is scaled by the minimum instruction
+ length since special opcode 255 would have scaled the
+ the increment. */
case DW_LNS_const_add_pc:
address += (lh.minimum_instruction_length
* ((255 - lh.opcode_base) / lh.line_range));
@@ -4103,7 +4305,7 @@ dwarf2_start_subfile (char *filename, char *dirname)
static struct symbol *
new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct symbol *sym = NULL;
char *name;
@@ -4111,15 +4313,16 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
struct attribute *attr2 = NULL;
CORE_ADDR addr;
- name = dwarf2_linkage_name (die);
+ name = dwarf2_linkage_name (die, cui);
if (name)
{
sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
sizeof (struct symbol));
OBJSTAT (objfile, n_syms++);
memset (sym, 0, sizeof (struct symbol));
- SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
- &objfile->symbol_obstack);
+ SYMBOL_NAME (sym) = /* obsavestring (name, strlen (name),
+ &objfile->symbol_obstack); */ bcache (name, strlen (name) + 1,
+ &objfile->psymbol_cache);
/* Default assumptions.
Use the passed type or decode it from the die. */
@@ -4128,8 +4331,8 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
if (type != NULL)
SYMBOL_TYPE (sym) = type;
else
- SYMBOL_TYPE (sym) = die_type (die, objfile, cu_header);
- attr = dwarf_attr (die, DW_AT_decl_line);
+ SYMBOL_TYPE (sym) = die_type (die, objfile, cui);
+ attr = dwarf2_attr (die, DW_AT_decl_line, cui);
if (attr)
{
SYMBOL_LINE (sym) = DW_UNSND (attr);
@@ -4141,31 +4344,28 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
of time because it sped up C++ symbol lookups by a factor of
about 20. */
- SYMBOL_LANGUAGE (sym) = cu_language;
+ SYMBOL_LANGUAGE (sym) = cui->cu_language;
SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
switch (die->tag)
{
case DW_TAG_label:
- attr = dwarf_attr (die, DW_AT_low_pc);
+ attr = dwarf2_attr (die, DW_AT_low_pc, cui);
if (attr)
{
SYMBOL_VALUE_ADDRESS (sym) = DW_ADDR (attr) + baseaddr;
}
SYMBOL_CLASS (sym) = LOC_LABEL;
break;
+ case DW_TAG_inlined_subroutine:
case DW_TAG_subprogram:
/* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
finish_block. */
SYMBOL_CLASS (sym) = LOC_BLOCK;
- attr2 = dwarf_attr (die, DW_AT_external);
+ attr2 = dwarf2_attr (die, DW_AT_external, cui);
if (attr2 && (DW_UNSND (attr2) != 0))
- {
- add_symbol_to_list (sym, &global_symbols);
- }
+ add_symbol_to_list (sym, &global_symbols);
else
- {
- add_symbol_to_list (sym, list_in_scope);
- }
+ add_symbol_to_list (sym, list_in_scope);
break;
case DW_TAG_variable:
/* Compilation with minimal debug info may result in variables
@@ -4176,25 +4376,25 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
TARGET_INT_BIT / HOST_CHAR_BIT, 0,
"<variable, no debug info>",
objfile);
- attr = dwarf_attr (die, DW_AT_const_value);
+ attr = dwarf2_attr (die, DW_AT_const_value, cui);
if (attr)
{
- dwarf2_const_value (attr, sym, objfile, cu_header);
- attr2 = dwarf_attr (die, DW_AT_external);
+ dwarf2_const_value (attr, sym, objfile, cui);
+ attr2 = dwarf2_attr (die, DW_AT_external, cui);
if (attr2 && (DW_UNSND (attr2) != 0))
add_symbol_to_list (sym, &global_symbols);
else
add_symbol_to_list (sym, list_in_scope);
break;
}
- attr = dwarf_attr (die, DW_AT_location);
+ attr = dwarf2_attr (die, DW_AT_location, cui);
if (attr)
{
- attr2 = dwarf_attr (die, DW_AT_external);
+ attr2 = dwarf2_attr (die, DW_AT_external, cui);
if (attr2 && (DW_UNSND (attr2) != 0))
{
SYMBOL_VALUE_ADDRESS (sym) =
- decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ decode_locdesc (DW_BLOCK (attr), objfile, cui);
add_symbol_to_list (sym, &global_symbols);
/* In shared libraries the address of the variable
@@ -4209,7 +4409,7 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
fixup_symbol_section (sym, objfile);
SYMBOL_VALUE_ADDRESS (sym) +=
ANOFFSET (objfile->section_offsets,
- SYMBOL_SECTION (sym));
+ SYMBOL_SECTION (sym));
SYMBOL_CLASS (sym) = LOC_STATIC;
}
else
@@ -4217,8 +4417,26 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
}
else
{
+ struct dwarf2_block *d2loc;
+ void *data;
+#if 0
+ SYMBOL_LOC_EXPR (sym) =
+ obstack_alloc (&objfile->symbol_obstack, sizeof (struct dwarf2_block));
+ d2loc = SYMBOL_LOC_EXPR (sym);
+ memset (d2loc, 0, sizeof (struct dwarf2_block));
+ d2loc->size = DW_BLOCK (attr)->size;
+ d2loc->data = xmalloc (DW_BLOCK (attr)->size);
+ memset (d2loc->data, 0, DW_BLOCK (attr)->size);
+ memcpy (d2loc->data, DW_BLOCK (attr)->data,
+ DW_BLOCK (attr)->size);
+ data = d2loc->data;
+ d2loc->data =
+ bcache (data, DW_BLOCK (attr)->size,
+ &objfile->psymbol_cache);
+ xfree (data);
+#endif
SYMBOL_VALUE (sym) = addr =
- decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ decode_locdesc (DW_BLOCK (attr), objfile, cui);
add_symbol_to_list (sym, list_in_scope);
if (optimized_out)
{
@@ -4227,7 +4445,7 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
else if (isreg)
{
SYMBOL_CLASS (sym) = LOC_REGISTER;
- SYMBOL_VALUE (sym) =
+ SYMBOL_VALUE (sym) =
DWARF2_REG_TO_REGNUM (SYMBOL_VALUE (sym));
}
else if (offreg)
@@ -4243,8 +4461,8 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
{
fixup_symbol_section (sym, objfile);
SYMBOL_VALUE_ADDRESS (sym) =
- addr + ANOFFSET (objfile->section_offsets,
- SYMBOL_SECTION (sym));
+ addr + ANOFFSET (objfile->section_offsets,
+ SYMBOL_SECTION (sym));
SYMBOL_CLASS (sym) = LOC_STATIC;
}
}
@@ -4257,9 +4475,9 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
The address of the variable will then be determined from
the minimal symbol table whenever the variable is
referenced. */
- attr2 = dwarf_attr (die, DW_AT_external);
+ attr2 = dwarf2_attr (die, DW_AT_external, cui);
if (attr2 && (DW_UNSND (attr2) != 0)
- && dwarf_attr (die, DW_AT_type) != NULL)
+ && dwarf2_attr (die, DW_AT_type, cui) != NULL)
{
SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
add_symbol_to_list (sym, &global_symbols);
@@ -4267,15 +4485,31 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
}
break;
case DW_TAG_formal_parameter:
- attr = dwarf_attr (die, DW_AT_location);
+ attr = dwarf2_attr (die, DW_AT_location, cui);
if (attr)
{
+ struct dwarf2_block *d2loc;
+ void *data;
+#if 0
+ SYMBOL_LOC_EXPR (sym) = obstack_alloc (&objfile->symbol_obstack, sizeof (struct dwarf2_block));
+ d2loc = SYMBOL_LOC_EXPR (sym);
+ memset (d2loc, 0, sizeof (struct dwarf2_block));
+ d2loc->size = DW_BLOCK (attr)->size;
+ d2loc->data = xmalloc (DW_BLOCK (attr)->size);
+ memset (d2loc->data, 0, DW_BLOCK (attr)->size);
+ memcpy (d2loc->data, DW_BLOCK (attr)->data,
+ DW_BLOCK (attr)->size);
+ data = d2loc->data;
+ d2loc->data =
+ bcache (data, DW_BLOCK (attr)->size, &objfile->psymbol_cache);
+ xfree (data);
+#endif
SYMBOL_VALUE (sym) =
- decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ decode_locdesc (DW_BLOCK (attr), objfile, cui);
if (isreg)
{
SYMBOL_CLASS (sym) = LOC_REGPARM;
- SYMBOL_VALUE (sym) =
+ SYMBOL_VALUE (sym) =
DWARF2_REG_TO_REGNUM (SYMBOL_VALUE (sym));
}
else if (offreg)
@@ -4297,10 +4531,10 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
SYMBOL_CLASS (sym) = LOC_ARG;
}
}
- attr = dwarf_attr (die, DW_AT_const_value);
+ attr = dwarf2_attr (die, DW_AT_const_value, cui);
if (attr)
{
- dwarf2_const_value (attr, sym, objfile, cu_header);
+ dwarf2_const_value (attr, sym, objfile, cui);
}
add_symbol_to_list (sym, list_in_scope);
break;
@@ -4315,23 +4549,32 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
case DW_TAG_enumeration_type:
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
+ /* For nested structures, the tag name is the correct symbol name, and, if we don't already have a type name, the symbol name is the correct type name. */
+ if (TYPE_TAG_NAME (type) != NULL)
+ {
+ if (TYPE_NAME (type) == NULL && SYMBOL_NAME (sym) != NULL)
+ TYPE_NAME (type) = SYMBOL_NAME (sym);
+ SYMBOL_NAME (sym) = TYPE_TAG_NAME (type);
+ }
add_symbol_to_list (sym, list_in_scope);
-
+
/* The semantics of C++ state that "struct foo { ... }" also
defines a typedef for "foo". Synthesize a typedef symbol so
that "ptype foo" works as expected. */
- if (cu_language == language_cplus)
+ if (cui->cu_language == language_cplus)
{
struct symbol *typedef_sym = (struct symbol *)
- obstack_alloc (&objfile->symbol_obstack,
- sizeof (struct symbol));
+ obstack_alloc (&objfile->symbol_obstack,
+ sizeof (struct symbol));
*typedef_sym = *sym;
SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
TYPE_NAME (SYMBOL_TYPE (sym)) =
- obsavestring (SYMBOL_NAME (sym),
+/* obsavestring (SYMBOL_NAME (sym),
strlen (SYMBOL_NAME (sym)),
- &objfile->type_obstack);
+ &objfile->type_obstack);*/
+ bcache (SYMBOL_NAME (sym), strlen (SYMBOL_NAME (sym)) + 1,
+ &objfile->psymbol_cache);
add_symbol_to_list (typedef_sym, list_in_scope);
}
break;
@@ -4342,10 +4585,10 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
add_symbol_to_list (sym, list_in_scope);
break;
case DW_TAG_enumerator:
- attr = dwarf_attr (die, DW_AT_const_value);
+ attr = dwarf2_attr (die, DW_AT_const_value, cui);
if (attr)
{
- dwarf2_const_value (attr, sym, objfile, cu_header);
+ dwarf2_const_value (attr, sym, objfile, cui);
}
add_symbol_to_list (sym, list_in_scope);
break;
@@ -4354,7 +4597,7 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
trash data, but since we must specifically ignore things
we don't recognize, there is nothing else we should do at
this point. */
- complain (&dwarf2_unsupported_tag, dwarf_tag_name (die->tag));
+ complain (&dwarf2_unsupported_tag, dwarf2_tag_name (die->tag));
break;
}
}
@@ -4366,19 +4609,19 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
static void
dwarf2_const_value (struct attribute *attr, struct symbol *sym,
struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
- struct dwarf_block *blk;
+ struct dwarf2_block *blk;
switch (attr->form)
{
case DW_FORM_addr:
- if (TYPE_LENGTH (SYMBOL_TYPE (sym)) != cu_header->addr_size)
+ if (TYPE_LENGTH (SYMBOL_TYPE (sym)) != cui->cu_header.addr_size)
complain (&dwarf2_const_value_length_mismatch, SYMBOL_NAME (sym),
- cu_header->addr_size, TYPE_LENGTH (SYMBOL_TYPE (sym)));
+ cui->cu_header.addr_size, TYPE_LENGTH (SYMBOL_TYPE (sym)));
SYMBOL_VALUE_BYTES (sym) = (char *)
- obstack_alloc (&objfile->symbol_obstack, cu_header->addr_size);
- store_address (SYMBOL_VALUE_BYTES (sym), cu_header->addr_size,
+ obstack_alloc (&objfile->symbol_obstack, cui->cu_header.addr_size);
+ store_address (SYMBOL_VALUE_BYTES (sym), cui->cu_header.addr_size,
DW_ADDR (attr));
SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
break;
@@ -4397,10 +4640,10 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
break;
/* The DW_AT_const_value attributes are supposed to carry the
- symbol's value "represented as it would be on the target
- architecture." By the time we get here, it's already been
- converted to host endianness, so we just need to sign- or
- zero-extend it as appropriate. */
+ symbol's value "represented as it would be on the target
+ architecture." By the time we get here, it's already been
+ converted to host endianness, so we just need to sign- or
+ zero-extend it as appropriate. */
case DW_FORM_data1:
dwarf2_const_value_data (attr, sym, 8);
break;
@@ -4426,7 +4669,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
default:
complain (&dwarf2_unsupported_const_value_attr,
- dwarf_form_name (attr->form));
+ dwarf2_form_name (attr->form));
SYMBOL_VALUE (sym) = 0;
SYMBOL_CLASS (sym) = LOC_CONST;
break;
@@ -4437,9 +4680,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
/* Given an attr with a DW_FORM_dataN value in host byte order, sign-
or zero-extend it as appropriate for the symbol's type. */
static void
-dwarf2_const_value_data (struct attribute *attr,
- struct symbol *sym,
- int bits)
+dwarf2_const_value_data (struct attribute *attr, struct symbol *sym, int bits)
{
LONGEST l = DW_UNSND (attr);
@@ -4460,34 +4701,35 @@ dwarf2_const_value_data (struct attribute *attr,
static struct type *
die_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *type;
struct attribute *type_attr;
struct die_info *type_die;
unsigned int ref;
- type_attr = dwarf_attr (die, DW_AT_type);
+ type_attr = dwarf2_attr (die, DW_AT_type, cui);
if (!type_attr)
{
/* A missing DW_AT_type represents a void type. */
- return dwarf2_fundamental_type (objfile, FT_VOID);
+ return dwarf2_fundamental_type (objfile, FT_VOID, cui);
}
else
{
- ref = dwarf2_get_ref_die_offset (type_attr);
- type_die = follow_die_ref (ref);
+ ref = dwarf2_get_ref_die_offset (cui, type_attr);
+ type_die = follow_die_ref (ref, cui);
if (!type_die)
{
error ("Dwarf Error: Cannot find referent at offset %d.", ref);
return NULL;
}
}
- type = tag_type_to_type (type_die, objfile, cu_header);
+ type = tag_type_to_type (type_die, objfile, cui);
if (!type)
{
- dump_die (type_die);
- error ("Dwarf Error: Problem turning type die at offset into gdb type.");
+ dump_die (type_die, cui);
+ error
+ ("Dwarf Error: Problem turning type die at offset into gdb type.");
}
return type;
}
@@ -4497,55 +4739,37 @@ die_type (struct die_info *die, struct objfile *objfile,
static struct type *
die_containing_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
struct type *type = NULL;
struct attribute *type_attr;
struct die_info *type_die = NULL;
unsigned int ref;
- type_attr = dwarf_attr (die, DW_AT_containing_type);
+ type_attr = dwarf2_attr (die, DW_AT_containing_type, cui);
if (type_attr)
{
- ref = dwarf2_get_ref_die_offset (type_attr);
- type_die = follow_die_ref (ref);
+ ref = dwarf2_get_ref_die_offset (cui, type_attr);
+ type_die = follow_die_ref (ref, cui);
if (!type_die)
{
error ("Dwarf Error: Cannot find referent at offset %d.", ref);
return NULL;
}
- type = tag_type_to_type (type_die, objfile, cu_header);
+ type = tag_type_to_type (type_die, objfile, cui);
}
if (!type)
{
if (type_die)
- dump_die (type_die);
+ dump_die (type_die, cui);
error ("Dwarf Error: Problem turning containing type into gdb type.");
}
return type;
}
-#if 0
-static struct type *
-type_at_offset (unsigned int offset, struct objfile *objfile)
-{
- struct die_info *die;
- struct type *type;
-
- die = follow_die_ref (offset);
- if (!die)
- {
- error ("Dwarf Error: Cannot find type referent at offset %d.", offset);
- return NULL;
- }
- type = tag_type_to_type (die, objfile);
- return type;
-}
-#endif
-
static struct type *
tag_type_to_type (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
if (die->type)
{
@@ -4553,10 +4777,10 @@ tag_type_to_type (struct die_info *die, struct objfile *objfile,
}
else
{
- read_type_die (die, objfile, cu_header);
+ read_type_die (die, objfile, cui);
if (!die->type)
{
- dump_die (die);
+ dump_die (die, cui);
error ("Dwarf Error: Cannot find type of die.");
}
return die->type;
@@ -4565,57 +4789,58 @@ tag_type_to_type (struct die_info *die, struct objfile *objfile,
static void
read_type_die (struct die_info *die, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_instance *cui)
{
switch (die->tag)
{
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
- read_structure_scope (die, objfile, cu_header);
+ read_structure_scope (die, objfile, cui, NULL);
break;
case DW_TAG_enumeration_type:
- read_enumeration (die, objfile, cu_header);
+ read_enumeration (die, objfile, cui);
break;
case DW_TAG_subprogram:
case DW_TAG_subroutine_type:
- read_subroutine_type (die, objfile, cu_header);
+ read_subroutine_type (die, objfile, cui);
break;
case DW_TAG_array_type:
- read_array_type (die, objfile, cu_header);
+ read_array_type (die, objfile, cui);
break;
case DW_TAG_pointer_type:
- read_tag_pointer_type (die, objfile, cu_header);
+ read_tag_pointer_type (die, objfile, cui);
break;
case DW_TAG_ptr_to_member_type:
- read_tag_ptr_to_member_type (die, objfile, cu_header);
+ read_tag_ptr_to_member_type (die, objfile, cui);
break;
case DW_TAG_reference_type:
- read_tag_reference_type (die, objfile, cu_header);
+ read_tag_reference_type (die, objfile, cui);
break;
case DW_TAG_const_type:
- read_tag_const_type (die, objfile, cu_header);
+ read_tag_const_type (die, objfile, cui);
break;
case DW_TAG_volatile_type:
- read_tag_volatile_type (die, objfile, cu_header);
+ read_tag_volatile_type (die, objfile, cui);
break;
case DW_TAG_string_type:
- read_tag_string_type (die, objfile);
+ read_tag_string_type (die, objfile, cui);
break;
case DW_TAG_typedef:
- read_typedef (die, objfile, cu_header);
+ read_typedef (die, objfile, cui);
break;
case DW_TAG_base_type:
- read_base_type (die, objfile);
+ read_base_type (die, objfile, cui);
break;
default:
- complain (&dwarf2_unexpected_tag, dwarf_tag_name (die->tag));
+ complain (&dwarf2_unexpected_tag, dwarf2_tag_name (die->tag));
break;
}
}
static struct type *
-dwarf_base_type (int encoding, int size, struct objfile *objfile)
+dwarf2_base_type (int encoding, int size, struct objfile *objfile,
+ const struct comp_unit_instance *cui)
{
/* FIXME - this should not produce a new (struct type *)
every time. It should cache base types. */
@@ -4623,161 +4848,109 @@ dwarf_base_type (int encoding, int size, struct objfile *objfile)
switch (encoding)
{
case DW_ATE_address:
- type = dwarf2_fundamental_type (objfile, FT_VOID);
+ type = dwarf2_fundamental_type (objfile, FT_VOID, cui);
return type;
case DW_ATE_boolean:
- type = dwarf2_fundamental_type (objfile, FT_BOOLEAN);
+ type = dwarf2_fundamental_type (objfile, FT_BOOLEAN, cui);
return type;
case DW_ATE_complex_float:
if (size == 16)
- {
- type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_COMPLEX);
- }
+ type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_COMPLEX, cui);
else
- {
- type = dwarf2_fundamental_type (objfile, FT_COMPLEX);
- }
+ type = dwarf2_fundamental_type (objfile, FT_COMPLEX, cui);
return type;
case DW_ATE_float:
if (size == 8)
- {
- type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT);
- }
+ type = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT, cui);
else
- {
- type = dwarf2_fundamental_type (objfile, FT_FLOAT);
- }
+ type = dwarf2_fundamental_type (objfile, FT_FLOAT, cui);
return type;
case DW_ATE_signed:
switch (size)
{
case 1:
- type = dwarf2_fundamental_type (objfile, FT_SIGNED_CHAR);
+ type = dwarf2_fundamental_type (objfile, FT_SIGNED_CHAR, cui);
break;
case 2:
- type = dwarf2_fundamental_type (objfile, FT_SIGNED_SHORT);
+ type = dwarf2_fundamental_type (objfile, FT_SIGNED_SHORT, cui);
break;
default:
case 4:
- type = dwarf2_fundamental_type (objfile, FT_SIGNED_INTEGER);
+ type = dwarf2_fundamental_type (objfile, FT_SIGNED_INTEGER, cui);
break;
}
return type;
case DW_ATE_signed_char:
- type = dwarf2_fundamental_type (objfile, FT_SIGNED_CHAR);
+ type = dwarf2_fundamental_type (objfile, FT_SIGNED_CHAR, cui);
return type;
case DW_ATE_unsigned:
switch (size)
{
case 1:
- type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_CHAR);
+ type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_CHAR, cui);
break;
case 2:
- type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_SHORT);
+ type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_SHORT, cui);
break;
default:
case 4:
- type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_INTEGER);
+ type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_INTEGER, cui);
break;
}
return type;
case DW_ATE_unsigned_char:
- type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_CHAR);
+ type = dwarf2_fundamental_type (objfile, FT_UNSIGNED_CHAR, cui);
return type;
default:
- type = dwarf2_fundamental_type (objfile, FT_SIGNED_INTEGER);
+ type = dwarf2_fundamental_type (objfile, FT_SIGNED_INTEGER, cui);
return type;
}
}
-#if 0
-struct die_info *
-copy_die (struct die_info *old_die)
-{
- struct die_info *new_die;
- int i, num_attrs;
-
- new_die = (struct die_info *) xmalloc (sizeof (struct die_info));
- memset (new_die, 0, sizeof (struct die_info));
-
- new_die->tag = old_die->tag;
- new_die->has_children = old_die->has_children;
- new_die->abbrev = old_die->abbrev;
- new_die->offset = old_die->offset;
- new_die->type = NULL;
-
- num_attrs = old_die->num_attrs;
- new_die->num_attrs = num_attrs;
- new_die->attrs = (struct attribute *)
- xmalloc (num_attrs * sizeof (struct attribute));
-
- for (i = 0; i < old_die->num_attrs; ++i)
- {
- new_die->attrs[i].name = old_die->attrs[i].name;
- new_die->attrs[i].form = old_die->attrs[i].form;
- new_die->attrs[i].u.addr = old_die->attrs[i].u.addr;
- }
-
- new_die->next = NULL;
- return new_die;
-}
-#endif
-
/* Return sibling of die, NULL if no sibling. */
-static struct die_info *
+struct die_info *
sibling_die (struct die_info *die)
{
int nesting_level = 0;
-
+
if (!die->has_children)
{
if (die->next && (die->next->tag == 0))
- {
- return NULL;
- }
+ return NULL;
else
- {
- return die->next;
- }
+ return die->next;
}
else
{
do
{
if (die->has_children)
- {
- nesting_level++;
- }
+ nesting_level++;
if (die->tag == 0)
- {
- nesting_level--;
- }
+ nesting_level--;
die = die->next;
}
while (nesting_level);
if (die && (die->tag == 0))
- {
- return NULL;
- }
+ return NULL;
else
- {
- return die;
- }
+ return die;
}
}
/* Get linkage name of a die, return NULL if not found. */
static char *
-dwarf2_linkage_name (struct die_info *die)
+dwarf2_linkage_name (struct die_info *die,
+ const struct comp_unit_instance *cui)
{
struct attribute *attr;
- attr = dwarf_attr (die, DW_AT_MIPS_linkage_name);
+ attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cui);
if (attr && DW_STRING (attr))
return DW_STRING (attr);
- attr = dwarf_attr (die, DW_AT_name);
+ attr = dwarf2_attr (die, DW_AT_name, cui);
if (attr && DW_STRING (attr))
return DW_STRING (attr);
return NULL;
@@ -4786,7 +4959,7 @@ dwarf2_linkage_name (struct die_info *die)
/* Convert a DIE tag into its string name. */
static char *
-dwarf_tag_name (register unsigned tag)
+dwarf2_tag_name (register unsigned tag)
{
switch (tag)
{
@@ -4902,7 +5075,7 @@ dwarf_tag_name (register unsigned tag)
/* Convert a DWARF attribute code into its string name. */
static char *
-dwarf_attr_name (register unsigned attr)
+dwarf2_attr_name (register unsigned attr)
{
switch (attr)
{
@@ -5068,7 +5241,7 @@ dwarf_attr_name (register unsigned attr)
/* Convert a DWARF value form code into its string name. */
static char *
-dwarf_form_name (register unsigned form)
+dwarf2_form_name (register unsigned form)
{
switch (form)
{
@@ -5122,7 +5295,7 @@ dwarf_form_name (register unsigned form)
/* Convert a DWARF stack opcode into its string name. */
static char *
-dwarf_stack_op_name (register unsigned op)
+dwarf2_stack_op_name (register unsigned op)
{
switch (op)
{
@@ -5422,7 +5595,7 @@ dwarf_stack_op_name (register unsigned op)
}
static char *
-dwarf_bool_name (unsigned mybool)
+dwarf2_bool_name (unsigned mybool)
{
if (mybool)
return "TRUE";
@@ -5433,7 +5606,7 @@ dwarf_bool_name (unsigned mybool)
/* Convert a DWARF type code into its string name. */
static char *
-dwarf_type_encoding_name (register unsigned enc)
+dwarf2_type_encoding_name (register unsigned enc)
{
switch (enc)
{
@@ -5458,75 +5631,22 @@ dwarf_type_encoding_name (register unsigned enc)
}
}
-/* Convert a DWARF call frame info operation to its string name. */
-
-#if 0
-static char *
-dwarf_cfi_name (register unsigned cfi_opc)
-{
- switch (cfi_opc)
- {
- case DW_CFA_advance_loc:
- return "DW_CFA_advance_loc";
- case DW_CFA_offset:
- return "DW_CFA_offset";
- case DW_CFA_restore:
- return "DW_CFA_restore";
- case DW_CFA_nop:
- return "DW_CFA_nop";
- case DW_CFA_set_loc:
- return "DW_CFA_set_loc";
- case DW_CFA_advance_loc1:
- return "DW_CFA_advance_loc1";
- case DW_CFA_advance_loc2:
- return "DW_CFA_advance_loc2";
- case DW_CFA_advance_loc4:
- return "DW_CFA_advance_loc4";
- case DW_CFA_offset_extended:
- return "DW_CFA_offset_extended";
- case DW_CFA_restore_extended:
- return "DW_CFA_restore_extended";
- case DW_CFA_undefined:
- return "DW_CFA_undefined";
- case DW_CFA_same_value:
- return "DW_CFA_same_value";
- case DW_CFA_register:
- return "DW_CFA_register";
- case DW_CFA_remember_state:
- return "DW_CFA_remember_state";
- case DW_CFA_restore_state:
- return "DW_CFA_restore_state";
- case DW_CFA_def_cfa:
- return "DW_CFA_def_cfa";
- case DW_CFA_def_cfa_register:
- return "DW_CFA_def_cfa_register";
- case DW_CFA_def_cfa_offset:
- return "DW_CFA_def_cfa_offset";
- /* SGI/MIPS specific */
- case DW_CFA_MIPS_advance_loc8:
- return "DW_CFA_MIPS_advance_loc8";
- default:
- return "DW_CFA_<unknown>";
- }
-}
-#endif
-
-static void
-dump_die (struct die_info *die)
+void
+dump_die (struct die_info *die, const struct comp_unit_instance *cui)
{
unsigned int i;
fprintf (stderr, "Die: %s (abbrev = %d, offset = %d)\n",
- dwarf_tag_name (die->tag), die->abbrev, die->offset);
+ dwarf2_tag_name (die->tag), die->abbrev, die->offset);
fprintf (stderr, "\thas children: %s\n",
- dwarf_bool_name (die->has_children));
+ dwarf2_bool_name (die->has_children));
fprintf (stderr, "\tattributes:\n");
for (i = 0; i < die->num_attrs; ++i)
{
fprintf (stderr, "\t\t%s (%s) ",
- dwarf_attr_name (die->attrs[i].name),
- dwarf_form_name (die->attrs[i].form));
+ dwarf2_attr_name (die->attrs[i].name),
+ dwarf2_form_name (die->attrs[i].form));
switch (die->attrs[i].form)
{
case DW_FORM_ref_addr:
@@ -5573,39 +5693,32 @@ dump_die (struct die_info *die)
}
}
-static void
-dump_die_list (struct die_info *die)
-{
- while (die)
- {
- dump_die (die);
- die = die->next;
- }
-}
-
-static void
-store_in_ref_table (unsigned int offset, struct die_info *die)
+void
+store_in_ref_table (unsigned int offset, struct die_info *die,
+ struct comp_unit_instance *cui)
{
int h;
struct die_info *old;
h = (offset % REF_HASH_SIZE);
- old = die_ref_table[h];
+ old = cui->die_ref_table[h];
die->next_ref = old;
- die_ref_table[h] = die;
+ cui->die_ref_table[h] = die;
}
static void
-dwarf2_empty_hash_tables (void)
+dwarf2_empty_hash_tables (struct comp_unit_instance *cui)
{
- memset (die_ref_table, 0, sizeof (die_ref_table));
+ memset (cui->die_ref_table, 0, sizeof (cui->die_ref_table));
}
static unsigned int
-dwarf2_get_ref_die_offset (struct attribute *attr)
+dwarf2_get_ref_die_offset (const struct comp_unit_instance *cui,
+ struct attribute *attr)
{
unsigned int result = 0;
+ struct comp_unit_instance *cui_for_die;
switch (attr->form)
{
@@ -5617,22 +5730,32 @@ dwarf2_get_ref_die_offset (struct attribute *attr)
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_udata:
- result = cu_header_offset + DW_UNSND (attr);
+ result = cui->cu_header_offset + DW_UNSND (attr);
break;
default:
- complain (&dwarf2_unsupported_die_ref_attr, dwarf_form_name (attr->form));
+ complain (&dwarf2_unsupported_die_ref_attr,
+ dwarf2_form_name (attr->form));
}
return result;
}
-static struct die_info *
-follow_die_ref (unsigned int offset)
+struct die_info *
+follow_die_ref (unsigned int offset, const struct comp_unit_instance *cui)
{
- struct die_info *die;
+ struct die_info *die = NULL;
int h;
-
+ struct comp_unit_instance *cui_for_die;
+ cui_for_die = dwarf2_get_cu_by_offset (cui->abfd, offset);
+ if (cui_for_die == 0)
+ error ("Can't find CU for die");
+ if (cui_for_die != cui)
+ {
+ read_full_die (&die, cui_for_die->abfd, dwarf2_info_buffer + offset,
+ cui_for_die);
+ return die;
+ }
h = (offset % REF_HASH_SIZE);
- die = die_ref_table[h];
+ die = cui->die_ref_table[h];
while (die)
{
if (die->offset == offset)
@@ -5641,11 +5764,14 @@ follow_die_ref (unsigned int offset)
}
die = die->next_ref;
}
- return NULL;
+ die = NULL;
+ read_full_die (&die, cui->abfd, dwarf2_info_buffer + offset, cui);
+ return die;
}
static struct type *
-dwarf2_fundamental_type (struct objfile *objfile, int typeid)
+dwarf2_fundamental_type (struct objfile *objfile, int typeid,
+ const struct comp_unit_instance *cui)
{
if (typeid < 0 || typeid >= FT_NUM_MEMBERS)
{
@@ -5659,7 +5785,7 @@ dwarf2_fundamental_type (struct objfile *objfile, int typeid)
if (ftypes[typeid] == NULL)
{
- ftypes[typeid] = cu_language_defn->la_fund_type (objfile, typeid);
+ ftypes[typeid] = cui->cu_language_defn->la_fund_type (objfile, typeid);
}
return (ftypes[typeid]);
@@ -5694,8 +5820,8 @@ dwarf2_fundamental_type (struct objfile *objfile, int typeid)
Note that stack overflow is not yet handled. */
static CORE_ADDR
-decode_locdesc (struct dwarf_block *blk, struct objfile *objfile,
- const struct comp_unit_head *cu_header)
+decode_locdesc (struct dwarf2_block *blk, struct objfile *objfile,
+ const struct comp_unit_instance *cui)
{
int i;
int size = blk->size;
@@ -5803,7 +5929,8 @@ decode_locdesc (struct dwarf_block *blk, struct objfile *objfile,
case DW_OP_breg31:
offreg = 1;
basereg = op - DW_OP_breg0;
- stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
+ stack[++stacki] =
+ read_signed_leb128 (NULL, (data + i), &bytes_read);
i += bytes_read;
break;
@@ -5811,12 +5938,14 @@ decode_locdesc (struct dwarf_block *blk, struct objfile *objfile,
offreg = 1;
basereg = read_unsigned_leb128 (NULL, (data + i), &bytes_read);
i += bytes_read;
- stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
+ stack[++stacki] =
+ read_signed_leb128 (NULL, (data + i), &bytes_read);
i += bytes_read;
break;
case DW_OP_fbreg:
- stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
+ stack[++stacki] =
+ read_signed_leb128 (NULL, (data + i), &bytes_read);
i += bytes_read;
if (frame_base_reg >= 0)
{
@@ -5833,7 +5962,7 @@ decode_locdesc (struct dwarf_block *blk, struct objfile *objfile,
case DW_OP_addr:
stack[++stacki] = read_address (objfile->obfd, &data[i],
- cu_header, &bytes_read);
+ cui, &bytes_read);
i += bytes_read;
break;
@@ -5874,7 +6003,8 @@ decode_locdesc (struct dwarf_block *blk, struct objfile *objfile,
break;
case DW_OP_consts:
- stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
+ stack[++stacki] =
+ read_signed_leb128 (NULL, (data + i), &bytes_read);
i += bytes_read;
break;
@@ -5884,7 +6014,8 @@ decode_locdesc (struct dwarf_block *blk, struct objfile *objfile,
break;
case DW_OP_plus_uconst:
- stack[stacki] += read_unsigned_leb128 (NULL, (data + i), &bytes_read);
+ stack[stacki] +=
+ read_unsigned_leb128 (NULL, (data + i), &bytes_read);
i += bytes_read;
break;
@@ -5902,7 +6033,7 @@ decode_locdesc (struct dwarf_block *blk, struct objfile *objfile,
break;
default:
- complain (&dwarf2_unsupported_stack_op, dwarf_stack_op_name (op));
+ complain (&dwarf2_unsupported_stack_op, dwarf2_stack_op_name (op));
return (stack[stacki]);
}
}
@@ -5918,18 +6049,18 @@ dwarf2_free_tmp_obstack (PTR ignore)
obstack_free (&dwarf2_tmp_obstack, NULL);
}
-static struct dwarf_block *
-dwarf_alloc_block (void)
+static struct dwarf2_block *
+dwarf2_alloc_block (void)
{
- struct dwarf_block *blk;
+ struct dwarf2_block *blk;
- blk = (struct dwarf_block *)
- obstack_alloc (&dwarf2_tmp_obstack, sizeof (struct dwarf_block));
+ blk = (struct dwarf2_block *)
+ obstack_alloc (&dwarf2_tmp_obstack, sizeof (struct dwarf2_block));
return (blk);
}
static struct abbrev_info *
-dwarf_alloc_abbrev (void)
+dwarf2_alloc_abbrev (void)
{
struct abbrev_info *abbrev;
@@ -5938,8 +6069,19 @@ dwarf_alloc_abbrev (void)
return (abbrev);
}
+static struct comp_unit_instance *
+dwarf2_alloc_comp_unit_instance (void)
+{
+ struct comp_unit_instance *cui;
+
+ cui =
+ (struct comp_unit_instance *)
+ xmalloc (sizeof (struct comp_unit_instance));
+ memset (cui, 0, sizeof (struct comp_unit_instance));
+ return cui;
+}
static struct die_info *
-dwarf_alloc_die (void)
+dwarf2_alloc_die (void)
{
struct die_info *die;
@@ -5947,3 +6089,1032 @@ dwarf_alloc_die (void)
memset (die, 0, sizeof (struct die_info));
return (die);
}
+typedef struct Frame_Chunk
+{
+ struct Frame_Chunk *next;
+ unsigned int fde_offset;
+ unsigned char *chunk_start;
+ int ncols;
+ /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
+ short int *col_type;
+ int *col_offset;
+ char *augmentation;
+ unsigned int code_factor;
+ signed int data_factor;
+ unsigned long pc_begin;
+ unsigned long pc_range;
+ int cfa_reg;
+ int cfa_offset;
+ int ra;
+}
+Frame_Chunk;
+
+/* A marker for a col_type that means this column was never referenced
+ in the frame info. */
+#define DW_CFA_unreferenced (-1)
+
+static void
+frame_need_space (fc, reg)
+ Frame_Chunk *fc;
+ int reg;
+{
+ int prev = fc->ncols;
+
+ if (reg < fc->ncols)
+ return;
+
+ fc->ncols = reg + 1;
+ fc->col_type = (short int *) xrealloc (fc->col_type,
+ fc->ncols * sizeof (short int));
+ fc->col_offset = (int *) xrealloc (fc->col_offset,
+ fc->ncols * sizeof (int));
+
+ while (prev < fc->ncols)
+ {
+ fc->col_type[prev] = DW_CFA_unreferenced;
+ fc->col_offset[prev] = 0;
+ prev++;
+ }
+}
+
+static void
+frame_display_row (fc, need_col_headers, max_regs)
+ Frame_Chunk *fc;
+ int *need_col_headers;
+ int *max_regs;
+{
+ int r;
+ char tmp[100];
+
+ if (*max_regs < fc->ncols)
+ *max_regs = fc->ncols;
+
+ if (*need_col_headers)
+ {
+ *need_col_headers = 0;
+
+ printf (" LOC CFA ");
+
+ for (r = 0; r < *max_regs; r++)
+ if (fc->col_type[r] != DW_CFA_unreferenced)
+ {
+ if (r == fc->ra)
+ printf ("ra ");
+ else
+ printf ("r%-4d", r);
+ }
+
+ printf ("\n");
+ }
+
+ printf ("%08x ", (unsigned int) fc->pc_begin);
+ sprintf (tmp, "r%d%+d", fc->cfa_reg, fc->cfa_offset);
+ printf ("%-8s ", tmp);
+
+ for (r = 0; r < fc->ncols; r++)
+ {
+ if (fc->col_type[r] != DW_CFA_unreferenced)
+ {
+ switch (fc->col_type[r])
+ {
+ case DW_CFA_undefined:
+ strcpy (tmp, "u");
+ break;
+ case DW_CFA_same_value:
+ strcpy (tmp, "s");
+ break;
+ case DW_CFA_offset:
+ sprintf (tmp, "c%+d", fc->col_offset[r]);
+ break;
+ case DW_CFA_register:
+ sprintf (tmp, "r%d", fc->col_offset[r]);
+ break;
+ default:
+ strcpy (tmp, "n/a");
+ break;
+ }
+ printf ("%-5s", tmp);
+ }
+ }
+ printf ("\n");
+}
+
+#define GET(N) read_n_bytes (abfd, start, N); start += N
+#define LEB() read_unsigned_leb128 (abfd, start, & length_return); start += length_return
+#define SLEB() read_signed_leb128 (abfd, start, & length_return); start += length_return
+static Frame_Chunk **fde_array;
+static unsigned int fde_array_size=0;
+static unsigned int fde_array_elems=0;
+static int
+compare_fde (const void *a, const void *b)
+{
+ Frame_Chunk **first, **second;
+ first = (Frame_Chunk **) a;
+ second = (Frame_Chunk **) b;
+ return (*first)->pc_begin - (*second)->pc_begin;
+}
+static int
+dwarf2_read_frame_info_1 (struct objfile *obj, unsigned char *start, unsigned char *end)
+{
+ bfd *abfd = obj->obfd;
+ unsigned char *section_start = start;
+ Frame_Chunk *chunks = 0;
+ Frame_Chunk *remembered_state = 0;
+ Frame_Chunk *rs;
+ int is_eh = 0;
+ int length_return;
+ int max_regs = 0;
+
+
+ while (start < end)
+ {
+ unsigned char *saved_start;
+ unsigned char *block_end;
+ unsigned long length;
+ unsigned long cie_id;
+ Frame_Chunk *fc;
+ Frame_Chunk *cie;
+ int need_col_headers = 1;
+
+ saved_start = start;
+ length = read_4_bytes (abfd, start);
+ start += 4;
+
+ if (length == 0)
+ return 1;
+
+ block_end = saved_start + length + 4;
+ cie_id = read_4_bytes (abfd, start);
+ start += 4;
+
+ printf ("\n%08x %08lx %08lx ", saved_start - section_start, length, cie_id);
+
+ if (is_eh ? (cie_id == 0) : (cie_id == DW_CIE_ID))
+ {
+ fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
+ memset (fc, 0, sizeof (Frame_Chunk));
+
+ fc->next = chunks;
+ chunks = fc;
+ fc->chunk_start = saved_start;
+ fc->ncols = 0;
+ fc->col_type = (short int *) xmalloc (sizeof (short int));
+ fc->col_offset = (int *) xmalloc (sizeof (int));
+ frame_need_space (fc, max_regs - 1);
+
+ start++; /* version */
+ fc->augmentation = start;
+
+ while (*start)
+ start++;
+
+ start++; /* skip past NUL */
+
+ if (fc->augmentation[0] == 'z')
+ {
+ int xtra;
+ fc->code_factor = LEB ();
+ fc->data_factor = SLEB ();
+ fc->ra = read_1_byte (abfd, start);
+ start += 1;
+ xtra = LEB ();
+ printf ("skipping %d extra bytes\n", xtra);
+ start += xtra;
+ }
+ else if (strcmp (fc->augmentation, "eh") == 0)
+ {
+ start += 4;
+ fc->code_factor = LEB ();
+ fc->data_factor = SLEB ();
+ fc->ra = read_1_byte (abfd, start);
+ start += 1;
+ }
+ else
+ {
+ fc->code_factor = LEB ();
+ fc->data_factor = SLEB ();
+ fc->ra = read_1_byte (abfd, start);
+ start += 1;
+ }
+ cie = fc;
+ printf ("CIE \"%s\" cf=%d df=%d ra=%d\n",
+ fc->augmentation, fc->code_factor, fc->data_factor, fc->ra);
+
+ frame_need_space (fc, fc->ra);
+ }
+ else
+ {
+ unsigned char *look_for;
+
+ fc = (struct Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
+ memset (fc, 0, sizeof (Frame_Chunk));
+
+ look_for = is_eh ? start - 4 - cie_id : (unsigned char *) cie_id;
+ fc->fde_offset = saved_start - section_start;
+ fc->pc_begin = read_4_bytes (abfd, start) + ANOFFSET (obj->section_offsets, SECT_OFF_TEXT (obj));
+ start += 4;
+ fc->pc_range = read_4_bytes (abfd, start);
+ start += 4;
+ if (fde_array_elems+1 > fde_array_size)
+ {
+ fde_array = xrealloc(fde_array, ((fde_array_size+1) * 2) * sizeof (Frame_Chunk *));
+ fde_array_size += 1;
+ fde_array_size *= 2;
+ }
+ fde_array_elems += 1;
+ fde_array[fde_array_elems-1]=fc;
+ for (cie = chunks;
+ cie && (cie->chunk_start != section_start + (int) look_for);
+ cie = cie->next);
+ if (!cie)
+ {
+ warning ("Invalid CIE pointer %08lx in FDE at %08lx\n", cie_id,
+ (long unsigned int)saved_start);
+ start = block_end;
+ fc->ncols = 0;
+ fc->col_type = (short int *) xmalloc (sizeof (short int));
+ fc->col_offset = (int *) xmalloc (sizeof (int));
+ frame_need_space (fc, max_regs - 1);
+ cie = fc;
+ fc->augmentation = "";
+ }
+ else
+ {
+ fc->ncols = cie->ncols;
+ fc->col_type =
+ (short int *) xmalloc (fc->ncols * sizeof (short int));
+ fc->col_offset = (int *) xmalloc (fc->ncols * sizeof (int));
+ memcpy (fc->col_type, cie->col_type,
+ fc->ncols * sizeof (short int));
+ memcpy (fc->col_offset, cie->col_offset,
+ fc->ncols * sizeof (int));
+ fc->augmentation = cie->augmentation;
+ fc->code_factor = cie->code_factor;
+ fc->data_factor = cie->data_factor;
+ fc->cfa_reg = cie->cfa_reg;
+ fc->cfa_offset = cie->cfa_offset;
+ fc->ra = cie->ra;
+ frame_need_space (fc, max_regs - 1);
+ }
+
+ if (cie->augmentation[0] == 'z')
+ {
+ unsigned long l = LEB ();
+ start += l;
+ }
+
+ printf ("FDE cie=%08x pc=%08lx..%08lx\n",
+ cie->chunk_start-section_start, fc->pc_begin,
+ fc->pc_begin + fc->pc_range);
+ }
+#if 0
+ /* At this point, fc is the current chunk, cie (if any) is set, and we're
+ about to interpret instructions for the chunk. */
+
+ /* This exists for readelf maintainers. */
+//#define FDEBUG 1
+
+ {
+ /* Start by making a pass over the chunk, allocating storage
+ and taking note of what registers are used. */
+ unsigned char *tmp = start;
+
+ while (start < block_end)
+ {
+ unsigned op, opa;
+ unsigned long reg;
+ bfd_vma vma;
+
+ op = *start++;
+ opa = op & 0x3f;
+ if (op & 0xc0)
+ op &= 0xc0;
+
+ /* Warning: if you add any more cases to this switch, be
+ sure to add them to the corresponding switch below. */
+ switch (op)
+ {
+ case DW_CFA_advance_loc:
+ break;
+ case DW_CFA_offset:
+ LEB ();
+ frame_need_space (fc, opa);
+ fc->col_type[opa] = DW_CFA_undefined;
+ break;
+ case DW_CFA_restore:
+ frame_need_space (fc, opa);
+ fc->col_type[opa] = DW_CFA_undefined;
+ break;
+ case DW_CFA_set_loc:
+ start += sizeof (vma);
+ break;
+ case DW_CFA_advance_loc1:
+ start += 1;
+ break;
+ case DW_CFA_advance_loc2:
+ start += 2;
+ break;
+ case DW_CFA_advance_loc4:
+ start += 4;
+ break;
+ case DW_CFA_offset_extended:
+ reg = LEB ();
+ LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_restore_extended:
+ reg = LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_undefined:
+ reg = LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_same_value:
+ reg = LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_register:
+ reg = LEB ();
+ LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_def_cfa:
+ LEB ();
+ LEB ();
+ break;
+ case DW_CFA_def_cfa_register:
+ LEB ();
+ break;
+ case DW_CFA_def_cfa_offset:
+ LEB ();
+ break;
+#ifndef DW_CFA_GNU_args_size
+#define DW_CFA_GNU_args_size 0x2e
+#endif
+ case DW_CFA_GNU_args_size:
+ LEB ();
+ break;
+#ifndef DW_CFA_GNU_negative_offset_extended
+#define DW_CFA_GNU_negative_offset_extended 0x2f
+#endif
+ case DW_CFA_GNU_negative_offset_extended:
+ reg = LEB ();
+ LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+
+ default:
+ break;
+ }
+ }
+ start = tmp;
+ }
+ /* Now we know what registers are used, make a second pass over
+ the chunk, this time actually printing out the info. */
+
+ while (start < block_end)
+ {
+ unsigned op, opa;
+ unsigned long ul, reg, roffs;
+ long l, ofs;
+ bfd_vma vma;
+
+ op = *start++;
+ opa = op & 0x3f;
+ if (op & 0xc0)
+ op &= 0xc0;
+
+ /* Warning: if you add any more cases to this switch, be
+ sure to add them to the corresponding switch above. */
+ switch (op)
+ {
+ case DW_CFA_advance_loc:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+#if FDEBUG
+ printf (" DW_CFA_advance_loc: %08x = %08x + %d*%d\n",
+ fc->pc_begin + opa * fc->code_factor, fc->pc_begin, opa,
+ fc->code_factor);
+#endif
+ fc->pc_begin += opa * fc->code_factor;
+ break;
+
+ case DW_CFA_offset:
+ roffs = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_offset: r%d = cfa[%d*%d]\n", opa, roffs,
+ fc->data_factor);
+#endif
+ fc->col_type[opa] = DW_CFA_offset;
+ fc->col_offset[opa] = roffs * fc->data_factor;
+ break;
+
+ case DW_CFA_restore:
+#if FDEBUG
+ printf (" DW_CFA_restore: r%d\n", opa);
+#endif
+ fc->col_type[opa] = cie->col_type[opa];
+ fc->col_offset[opa] = cie->col_offset[opa];
+ break;
+
+ case DW_CFA_set_loc:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ vma = read_n_bytes (abfd, start, sizeof (vma));
+ start += sizeof (vma);
+#if FDEBUG
+ printf (" DW_CFA_set_loc: %08x\n", vma);
+#endif
+ fc->pc_begin = vma;
+ break;
+
+ case DW_CFA_advance_loc1:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ ofs = read_1_byte (abfd, start);
+ start += 1;
+#if FDEBUG
+ printf (" DW_CFA_advance_loc1: %08x = %08x + %d*%d\n",
+ fc->pc_begin + ofs * fc->code_factor, fc->pc_begin, ofs,
+ fc->code_factor);
+#endif
+ fc->pc_begin += ofs * fc->code_factor;
+ break;
+
+ case DW_CFA_advance_loc2:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ ofs = read_2_bytes (abfd, start);
+ start += 2;
+#if FDEBUG
+ printf (" DW_CFA_advance_loc2: %08x = %08x + %d*%d\n",
+ fc->pc_begin + ofs * fc->code_factor, fc->pc_begin, ofs,
+ fc->code_factor);
+#endif
+ fc->pc_begin += ofs * fc->code_factor;
+ break;
+
+ case DW_CFA_advance_loc4:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ ofs = read_4_bytes (abfd, start);
+ start += 4;
+#if FDEBUG
+ printf (" DW_CFA_advance_loc4: %08x = %08x + %d*%d\n",
+ fc->pc_begin + ofs * fc->code_factor, fc->pc_begin, ofs,
+ fc->code_factor);
+#endif
+ fc->pc_begin += ofs * fc->code_factor;
+ break;
+
+ case DW_CFA_offset_extended:
+ reg = LEB ();
+ roffs = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_offset_extended: r%d = cfa[%d*%d]\n", reg,
+ roffs, fc->data_factor);
+#endif
+ fc->col_type[reg] = DW_CFA_offset;
+ fc->col_offset[reg] = roffs * fc->data_factor;
+ break;
+
+ case DW_CFA_restore_extended:
+ reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_restore_extended: r%d\n", reg);
+#endif
+ fc->col_type[reg] = cie->col_type[reg];
+ fc->col_offset[reg] = cie->col_offset[reg];
+ break;
+
+ case DW_CFA_undefined:
+ reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_undefined: r%d\n", reg);
+#endif
+ fc->col_type[reg] = DW_CFA_undefined;
+ fc->col_offset[reg] = 0;
+ break;
+
+ case DW_CFA_same_value:
+ reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_same_value: r%d\n", reg);
+#endif
+ fc->col_type[reg] = DW_CFA_same_value;
+ fc->col_offset[reg] = 0;
+ break;
+
+ case DW_CFA_register:
+ reg = LEB ();
+ roffs = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_register: r%d\n", reg);
+#endif
+ fc->col_type[reg] = DW_CFA_register;
+ fc->col_offset[reg] = roffs;
+ break;
+
+ case DW_CFA_remember_state:
+#if FDEBUG
+ printf (" DW_CFA_remember_state\n");
+#endif
+ rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
+ rs->ncols = fc->ncols;
+ rs->col_type =
+ (short int *) xmalloc (rs->ncols * sizeof (short int));
+ rs->col_offset = (int *) xmalloc (rs->ncols * sizeof (int));
+ memcpy (rs->col_type, fc->col_type, rs->ncols);
+ memcpy (rs->col_offset, fc->col_offset,
+ rs->ncols * sizeof (int));
+ rs->next = remembered_state;
+ remembered_state = rs;
+ break;
+
+ case DW_CFA_restore_state:
+#if FDEBUG
+ printf (" DW_CFA_restore_state\n");
+#endif
+ rs = remembered_state;
+ remembered_state = rs->next;
+ frame_need_space (fc, rs->ncols - 1);
+ memcpy (fc->col_type, rs->col_type, rs->ncols);
+ memcpy (fc->col_offset, rs->col_offset,
+ rs->ncols * sizeof (int));
+ xfree (rs->col_type);
+ xfree (rs->col_offset);
+ xfree (rs);
+ break;
+
+ case DW_CFA_def_cfa:
+ fc->cfa_reg = LEB ();
+ fc->cfa_offset = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_def_cfa: reg %d ofs %d\n", fc->cfa_reg,
+ fc->cfa_offset);
+#endif
+ break;
+
+ case DW_CFA_def_cfa_register:
+ fc->cfa_reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_def_cfa_reg: %d\n", fc->cfa_reg);
+#endif
+ break;
+
+ case DW_CFA_def_cfa_offset:
+ fc->cfa_offset = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset);
+#endif
+ break;
+
+ case DW_CFA_nop:
+#if FDEBUG
+ printf (" DW_CFA_nop\n");
+#endif
+ break;
+
+#ifndef DW_CFA_GNU_window_save
+#define DW_CFA_GNU_window_save 0x2d
+#endif
+ case DW_CFA_GNU_window_save:
+#if FDEBUG
+ printf (" DW_CFA_GNU_window_save\n");
+#endif
+ break;
+
+#ifndef DW_CFA_GNU_args_size
+#define DW_CFA_GNU_args_size 0x2e
+#endif
+ case DW_CFA_GNU_args_size:
+ ul = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_GNU_args_size: %d\n", ul);
+#endif
+ break;
+
+#ifndef DW_CFA_GNU_negative_offset_extended
+#define DW_CFA_GNU_negative_offset_extended 0x2f
+#endif
+ case DW_CFA_GNU_negative_offset_extended:
+ reg = LEB ();
+ l = -LEB ();
+ frame_need_space (fc, reg);
+#if FDEBUG
+ printf
+ (" DW_CFA_GNU_negative_offset_extended: r%d = cfa[%d*%d]\n",
+ reg, l, fc->data_factor);
+#endif
+ fc->col_type[reg] = DW_CFA_offset;
+ fc->col_offset[reg] = l * fc->data_factor;
+ break;
+
+ default:
+ fprintf (stderr, "unsupported or unknown DW_CFA_%d\n", op);
+ start = block_end;
+ }
+ }
+
+ frame_display_row (fc, &need_col_headers, &max_regs);
+#endif
+ start = block_end;
+ }
+
+ printf ("\n");
+
+ return 1;
+}
+
+#undef GET
+#undef LEB
+#undef SLEB
+#if 0
+ /* At this point, fc is the current chunk, cie (if any) is set, and we're
+ about to interpret instructions for the chunk. */
+
+ /* This exists for readelf maintainers. */
+//#define FDEBUG 1
+
+{
+ /* Start by making a pass over the chunk, allocating storage
+ and taking note of what registers are used. */
+ unsigned char *tmp = start;
+
+ while (start < block_end)
+ {
+ unsigned op, opa;
+ unsigned long reg;
+ bfd_vma vma;
+
+ op = *start++;
+ opa = op & 0x3f;
+ if (op & 0xc0)
+ op &= 0xc0;
+
+ /* Warning: if you add any more cases to this switch, be
+ sure to add them to the corresponding switch below. */
+ switch (op)
+ {
+ case DW_CFA_advance_loc:
+ break;
+ case DW_CFA_offset:
+ LEB ();
+ frame_need_space (fc, opa);
+ fc->col_type[opa] = DW_CFA_undefined;
+ break;
+ case DW_CFA_restore:
+ frame_need_space (fc, opa);
+ fc->col_type[opa] = DW_CFA_undefined;
+ break;
+ case DW_CFA_set_loc:
+ start += sizeof (vma);
+ break;
+ case DW_CFA_advance_loc1:
+ start += 1;
+ break;
+ case DW_CFA_advance_loc2:
+ start += 2;
+ break;
+ case DW_CFA_advance_loc4:
+ start += 4;
+ break;
+ case DW_CFA_offset_extended:
+ reg = LEB ();
+ LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_restore_extended:
+ reg = LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_undefined:
+ reg = LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_same_value:
+ reg = LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_register:
+ reg = LEB ();
+ LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+ break;
+ case DW_CFA_def_cfa:
+ LEB ();
+ LEB ();
+ break;
+ case DW_CFA_def_cfa_register:
+ LEB ();
+ break;
+ case DW_CFA_def_cfa_offset:
+ LEB ();
+ break;
+#ifndef DW_CFA_GNU_args_size
+#define DW_CFA_GNU_args_size 0x2e
+#endif
+ case DW_CFA_GNU_args_size:
+ LEB ();
+ break;
+#ifndef DW_CFA_GNU_negative_offset_extended
+#define DW_CFA_GNU_negative_offset_extended 0x2f
+#endif
+ case DW_CFA_GNU_negative_offset_extended:
+ reg = LEB ();
+ LEB ();
+ frame_need_space (fc, reg);
+ fc->col_type[reg] = DW_CFA_undefined;
+
+ default:
+ break;
+ }
+ }
+ start = tmp;
+}
+
+ /* Now we know what registers are used, make a second pass over
+ the chunk, this time actually printing out the info. */
+
+while (start < block_end)
+ {
+ unsigned op, opa;
+ unsigned long ul, reg, roffs;
+ long l, ofs;
+ bfd_vma vma;
+
+ op = *start++;
+ opa = op & 0x3f;
+ if (op & 0xc0)
+ op &= 0xc0;
+
+ /* Warning: if you add any more cases to this switch, be
+ sure to add them to the corresponding switch above. */
+ switch (op)
+ {
+ case DW_CFA_advance_loc:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+#if FDEBUG
+ printf (" DW_CFA_advance_loc: %08x = %08x + %d*%d\n",
+ fc->pc_begin + opa * fc->code_factor, fc->pc_begin, opa,
+ fc->code_factor);
+#endif
+ fc->pc_begin += opa * fc->code_factor;
+ break;
+
+ case DW_CFA_offset:
+ roffs = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_offset: r%d = cfa[%d*%d]\n", opa, roffs,
+ fc->data_factor);
+#endif
+ fc->col_type[opa] = DW_CFA_offset;
+ fc->col_offset[opa] = roffs * fc->data_factor;
+ break;
+
+ case DW_CFA_restore:
+#if FDEBUG
+ printf (" DW_CFA_restore: r%d\n", opa);
+#endif
+ fc->col_type[opa] = cie->col_type[opa];
+ fc->col_offset[opa] = cie->col_offset[opa];
+ break;
+
+ case DW_CFA_set_loc:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ vma = read_n_bytes (abfd, start, sizeof (vma));
+ start += sizeof (vma);
+#if FDEBUG
+ printf (" DW_CFA_set_loc: %08x\n", vma);
+#endif
+ fc->pc_begin = vma;
+ break;
+
+ case DW_CFA_advance_loc1:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ ofs = read_1_byte (abfd, start);
+ start += 1;
+#if FDEBUG
+ printf (" DW_CFA_advance_loc1: %08x = %08x + %d*%d\n",
+ fc->pc_begin + ofs * fc->code_factor, fc->pc_begin, ofs,
+ fc->code_factor);
+#endif
+ fc->pc_begin += ofs * fc->code_factor;
+ break;
+
+ case DW_CFA_advance_loc2:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ ofs = read_2_bytes (abfd, start);
+ start += 2;
+#if FDEBUG
+ printf (" DW_CFA_advance_loc2: %08x = %08x + %d*%d\n",
+ fc->pc_begin + ofs * fc->code_factor, fc->pc_begin, ofs,
+ fc->code_factor);
+#endif
+ fc->pc_begin += ofs * fc->code_factor;
+ break;
+
+ case DW_CFA_advance_loc4:
+ frame_display_row (fc, &need_col_headers, &max_regs);
+ ofs = read_4_bytes (abfd, start);
+ start += 4;
+#if FDEBUG
+ printf (" DW_CFA_advance_loc4: %08x = %08x + %d*%d\n",
+ fc->pc_begin + ofs * fc->code_factor, fc->pc_begin, ofs,
+ fc->code_factor);
+#endif
+ fc->pc_begin += ofs * fc->code_factor;
+ break;
+
+ case DW_CFA_offset_extended:
+ reg = LEB ();
+ roffs = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_offset_extended: r%d = cfa[%d*%d]\n", reg, roffs,
+ fc->data_factor);
+#endif
+ fc->col_type[reg] = DW_CFA_offset;
+ fc->col_offset[reg] = roffs * fc->data_factor;
+ break;
+
+ case DW_CFA_restore_extended:
+ reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_restore_extended: r%d\n", reg);
+#endif
+ fc->col_type[reg] = cie->col_type[reg];
+ fc->col_offset[reg] = cie->col_offset[reg];
+ break;
+
+ case DW_CFA_undefined:
+ reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_undefined: r%d\n", reg);
+#endif
+ fc->col_type[reg] = DW_CFA_undefined;
+ fc->col_offset[reg] = 0;
+ break;
+
+ case DW_CFA_same_value:
+ reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_same_value: r%d\n", reg);
+#endif
+ fc->col_type[reg] = DW_CFA_same_value;
+ fc->col_offset[reg] = 0;
+ break;
+
+ case DW_CFA_register:
+ reg = LEB ();
+ roffs = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_register: r%d\n", reg);
+#endif
+ fc->col_type[reg] = DW_CFA_register;
+ fc->col_offset[reg] = roffs;
+ break;
+
+ case DW_CFA_remember_state:
+#if FDEBUG
+ printf (" DW_CFA_remember_state\n");
+#endif
+ rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
+ rs->ncols = fc->ncols;
+ rs->col_type = (short int *) xmalloc (rs->ncols * sizeof (short int));
+ rs->col_offset = (int *) xmalloc (rs->ncols * sizeof (int));
+ memcpy (rs->col_type, fc->col_type, rs->ncols);
+ memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (int));
+ rs->next = remembered_state;
+ remembered_state = rs;
+ break;
+
+ case DW_CFA_restore_state:
+#if FDEBUG
+ printf (" DW_CFA_restore_state\n");
+#endif
+ rs = remembered_state;
+ remembered_state = rs->next;
+ frame_need_space (fc, rs->ncols - 1);
+ memcpy (fc->col_type, rs->col_type, rs->ncols);
+ memcpy (fc->col_offset, rs->col_offset, rs->ncols * sizeof (int));
+ xfree (rs->col_type);
+ xfree (rs->col_offset);
+ xfree (rs);
+ break;
+
+ case DW_CFA_def_cfa:
+ fc->cfa_reg = LEB ();
+ fc->cfa_offset = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_def_cfa: reg %d ofs %d\n", fc->cfa_reg,
+ fc->cfa_offset);
+#endif
+ break;
+
+ case DW_CFA_def_cfa_register:
+ fc->cfa_reg = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_def_cfa_reg: %d\n", fc->cfa_reg);
+#endif
+ break;
+
+ case DW_CFA_def_cfa_offset:
+ fc->cfa_offset = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset);
+#endif
+ break;
+
+ case DW_CFA_nop:
+#if FDEBUG
+ printf (" DW_CFA_nop\n");
+#endif
+ break;
+
+#ifndef DW_CFA_GNU_window_save
+#define DW_CFA_GNU_window_save 0x2d
+#endif
+ case DW_CFA_GNU_window_save:
+#if FDEBUG
+ printf (" DW_CFA_GNU_window_save\n");
+#endif
+ break;
+
+#ifndef DW_CFA_GNU_args_size
+#define DW_CFA_GNU_args_size 0x2e
+#endif
+ case DW_CFA_GNU_args_size:
+ ul = LEB ();
+#if FDEBUG
+ printf (" DW_CFA_GNU_args_size: %d\n", ul);
+#endif
+ break;
+
+#ifndef DW_CFA_GNU_negative_offset_extended
+#define DW_CFA_GNU_negative_offset_extended 0x2f
+#endif
+ case DW_CFA_GNU_negative_offset_extended:
+ reg = LEB ();
+ l = -LEB ();
+ frame_need_space (fc, reg);
+#if FDEBUG
+ printf (" DW_CFA_GNU_negative_offset_extended: r%d = cfa[%d*%d]\n",
+ reg, l, fc->data_factor);
+#endif
+ fc->col_type[reg] = DW_CFA_offset;
+ fc->col_offset[reg] = l * fc->data_factor;
+ break;
+
+ default:
+ fprintf (stderr, "unsupported or unknown DW_CFA_%d\n", op);
+ start = block_end;
+ }
+ }
+
+frame_display_row (fc, &need_col_headers, &max_regs);
+#endif
+/* Read in the .debug_frame/.eh_frame section, and process it */
+static void
+dwarf2_read_frame_info (struct objfile *obj)
+{
+ dwarf2_read_frame_info_1 (obj, dwarf2_frame_buffer,
+ dwarf2_frame_buffer + dwarf2_frame_size);
+ qsort(fde_array, fde_array_elems, sizeof(Frame_Chunk *), compare_fde);
+}
+
+/* Get the Call Frame Annotation info for a given PC. Uses a binary
+ search through the fde_array. */
+Frame_Chunk *
+dwarf2_get_cfa_for_addr (CORE_ADDR pc)
+{
+ size_t lo, hi;
+ Frame_Chunk *chunk=NULL;
+ lo=0;
+ hi=fde_array_elems;
+ do
+ {
+ size_t i = (lo + hi) / 2;
+ chunk = fde_array[i];
+ if (pc < chunk->pc_begin)
+ hi = i;
+ else if (pc >= chunk->pc_begin + chunk->pc_range)
+ lo = i + 1;
+ else
+ return chunk;
+ } while (lo < hi);
+
+ return chunk;
+}
+/* We can search the fde array ourselves very inexpensively, so there
+ is no need to pass along the actual frame program data. */
+void
+dwarf2_execute_cfa_program (struct frame_info *frame)
+{
+
+}
diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c
index 0bfb4fdda68..c39af7991f4 100644
--- a/gdb/dwarfread.c
+++ b/gdb/dwarfread.c
@@ -1280,7 +1280,7 @@ decode_subscript_data_item (char *scan, char *end)
struct type *typep = NULL; /* Array type we are building */
struct type *nexttype; /* Type of each element (may be array) */
struct type *indextype; /* Type of this index */
- struct type *rangetype;
+ struct range_type *rangetype;
unsigned int format;
unsigned short fundtype;
unsigned long lowbound;
@@ -1312,9 +1312,9 @@ decode_subscript_data_item (char *scan, char *end)
complain (&subscript_data_items, DIE_ID, DIE_NAME);
nexttype = dwarf_fundamental_type (current_objfile, FT_INTEGER);
}
- rangetype = create_range_type ((struct type *) NULL, indextype,
+ rangetype = make_range_type (current_objfile, indextype,
lowbound, highbound);
- typep = create_array_type ((struct type *) NULL, nexttype, rangetype);
+ typep = (struct type *) make_array_type (current_objfile, nexttype, rangetype);
break;
case FMT_FT_C_X:
case FMT_FT_X_C:
@@ -1325,14 +1325,14 @@ decode_subscript_data_item (char *scan, char *end)
case FMT_UT_X_X:
complain (&unhandled_array_subscript_format, DIE_ID, DIE_NAME, format);
nexttype = dwarf_fundamental_type (current_objfile, FT_INTEGER);
- rangetype = create_range_type ((struct type *) NULL, nexttype, 0, 0);
- typep = create_array_type ((struct type *) NULL, nexttype, rangetype);
+ rangetype = make_range_type (current_objfile, nexttype, 0, 0);
+ typep = (struct type *)make_array_type (current_objfile, nexttype, rangetype);
break;
default:
complain (&unknown_array_subscript_format, DIE_ID, DIE_NAME, format);
nexttype = dwarf_fundamental_type (current_objfile, FT_INTEGER);
- rangetype = create_range_type ((struct type *) NULL, nexttype, 0, 0);
- typep = create_array_type ((struct type *) NULL, nexttype, rangetype);
+ rangetype = make_range_type (current_objfile, nexttype, 0, 0);
+ typep = (struct type *)make_array_type (current_objfile, nexttype, rangetype);
break;
}
return (typep);
@@ -1432,7 +1432,7 @@ read_tag_pointer_type (struct dieinfo *dip)
}
else
{
- TYPE_TARGET_TYPE (utype) = type;
+ POINTER_TARGET_TYPE (utype) = type;
TYPE_POINTER_TYPE (type) = utype;
/* We assume the machine has only one representation for pointers! */
@@ -1465,7 +1465,7 @@ read_tag_string_type (struct dieinfo *dip)
{
struct type *utype;
struct type *indextype;
- struct type *rangetype;
+ struct range_type *rangetype;
unsigned long lowbound = 0;
unsigned long highbound;
@@ -1480,7 +1480,7 @@ read_tag_string_type (struct dieinfo *dip)
highbound = 1;
}
indextype = dwarf_fundamental_type (current_objfile, FT_INTEGER);
- rangetype = create_range_type ((struct type *) NULL, indextype, lowbound,
+ rangetype = make_range_type (current_objfile, indextype, lowbound,
highbound);
utype = lookup_utype (dip->die_ref);
@@ -1501,7 +1501,7 @@ read_tag_string_type (struct dieinfo *dip)
}
/* Create the string type using the blank type we either found or created. */
- utype = create_string_type (utype, rangetype);
+ utype = (struct type *)make_string_type (current_objfile, rangetype);
}
/*
@@ -1548,16 +1548,18 @@ read_subroutine_type (struct dieinfo *dip, char *thisdie, char *enddie)
{
/* This is the first reference to one of these types. Make
a new one and place it in the user defined types. */
- ftype = lookup_function_type (type);
+ ftype = (struct type *)make_function_type (current_objfile, type, 0, NULL, 0);
alloc_utype (dip->die_ref, ftype);
}
else if (TYPE_CODE (ftype) == TYPE_CODE_UNDEF)
{
+#if TYPEFIX
/* We have an existing partially constructed type, so bash it
into the correct type. */
TYPE_TARGET_TYPE (ftype) = type;
TYPE_LENGTH (ftype) = 1;
TYPE_CODE (ftype) = TYPE_CODE_FUNC;
+#endif
}
else
{
@@ -1728,8 +1730,10 @@ enum_type (struct dieinfo *dip, struct objfile *objfile)
vector. */
if (nfields > 0)
{
+#if TYPEFIX
if (unsigned_enum)
TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
+#endif
TYPE_NFIELDS (type) = nfields;
TYPE_FIELDS (type) = (struct field *)
obstack_alloc (&objfile->symbol_obstack, sizeof (struct field) * nfields);
@@ -2875,7 +2879,7 @@ new_symbol (struct dieinfo *dip, struct objfile *objfile)
case TAG_global_subroutine:
case TAG_subroutine:
SYMBOL_VALUE_ADDRESS (sym) = dip->at_low_pc;
- SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
+ SYMBOL_TYPE (sym) = (struct type *)make_function_type (objfile, SYMBOL_TYPE (sym), 0, NULL, 0);
if (dip->at_prototyped)
TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED;
SYMBOL_CLASS (sym) = LOC_BLOCK;
diff --git a/gdb/eval.c b/gdb/eval.c
index fad995ee35c..26ecfe2354e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -372,7 +372,59 @@ init_array_element (value_ptr array, value_ptr element,
}
return index;
}
+/* Given a function "f" which is a member of a class, find
+ * the classname that it is a member of. Used to construct
+ * the name (e.g., "c::f") which GDB will put in the
+ * "demangled name" field of the function's symbol.
+ * Called from hpread_process_one_debug_symbol()
+ * If "f" is not a member function, return NULL.
+ */
+const char *
+class_of (functype)
+ struct type *functype;
+{
+ struct type *first_param_type;
+ char *first_param_name;
+ struct type *pointed_to_type;
+ const char *class_name;
+
+ /* Check that the function has a first argument "this",
+ * and that "this" is a pointer to a class. If not,
+ * functype is not a member function, so return NULL.
+ */
+ if (TYPE_NFIELDS (functype) == 0)
+ return NULL;
+ first_param_name = TYPE_FIELD_NAME (functype, 0);
+ if (first_param_name == NULL)
+ return NULL; /* paranoia */
+ if (strcmp (first_param_name, "this"))
+ return NULL;
+ first_param_type = TYPE_FIELD_TYPE (functype, 0);
+ if (first_param_type == NULL)
+ return NULL; /* paranoia */
+ if (TYPE_CODE (first_param_type) != TYPE_CODE_PTR)
+ return NULL;
+
+ /* Get the thing that "this" points to, check that
+ * it's a class, and get its class name.
+ */
+ pointed_to_type = POINTER_TARGET_TYPE (first_param_type);
+ if (pointed_to_type == NULL)
+ return NULL; /* paranoia */
+ if (TYPE_CODE (pointed_to_type) != TYPE_CODE_CLASS)
+ return NULL;
+ class_name = TYPE_NAME (pointed_to_type);
+ if (class_name == NULL)
+ return NULL; /* paranoia */
+ /* The class name may be of the form "class c", in which case
+ * we want to strip off the leading "class ".
+ */
+ if (strncmp (class_name, "class ", 6) == 0)
+ class_name += 6;
+
+ return class_name;
+}
value_ptr
evaluate_subexp_standard (struct type *expect_type,
register struct expression *exp, register int *pos,
@@ -398,17 +450,74 @@ evaluate_subexp_standard (struct type *expect_type,
switch (op)
{
case OP_SCOPE:
+ {
+ int look_for_this = 0;
tem = longest_to_int (exp->elts[pc + 2].longconst);
(*pos) += 4 + BYTES_TO_EXP_ELEM (tem + 1);
+ /* Handle class_name::member. If it is a static data member,
+ the compiler generates a fully qualified symbol name for it. 'yylex'
+ routine has already looked ahead in order to get a symbol for it.
+ However, if it is not a static data member, it is simply a field of
+ its class. To get around the problem, a flag 'look_for_this' is
+ used to tell the callees to check if it is a data member of 'this'.
+ */
+ if (current_language->la_language == language_cplus)
+ {
+ if (pc && exp->elts[pc - 1].opcode == UNOP_ADDR)
+ {
+ /* If we see 'object.class_name::member', it is not a member of
+ 'this'. */
+ look_for_this = 0;
+ }
+ else
+ {
+ char * class_name = TYPE_TAG_NAME(exp->elts[pc + 1].type);
+ if (selected_frame)
+ {
+ /* If pc is in a member function of its class or the class
+ is dervied from virtual class, it can be member of
+ 'this'. */
+ struct symbol * func_sym =
+ find_pc_function (selected_frame->pc);
+
+ if (func_sym)
+ {
+
+ const char * func_class_name =
+ class_of (SYMBOL_TYPE (func_sym));
+
+ /* it could be a data member in which case we
+ will just save some time digging up info for
+ class functions. */
+ if (func_class_name != NULL)
+ {
+ if (!strcmp(class_name, func_class_name))
+ look_for_this = 1;
+ else
+ {
+ struct symbol * func_class_sym =
+ lookup_symbol (func_class_name, 0,
+ VAR_NAMESPACE, 0, 0);
+
+ fill_in_vptr_fieldno (SYMBOL_TYPE (func_class_sym));
+ if (func_class_sym &&
+ TYPE_VPTR_FIELDNO (SYMBOL_TYPE (func_class_sym)) != -1)
+ look_for_this = 1;
+ }
+ }
+ }
+ }
+ }
+ }
arg1 = value_struct_elt_for_reference (exp->elts[pc + 1].type,
0,
exp->elts[pc + 1].type,
&exp->elts[pc + 3].string,
- NULL_TYPE);
+ NULL_TYPE, look_for_this);
if (arg1 == NULL)
error ("There is no field named %s", &exp->elts[pc + 3].string);
return arg1;
-
+ }
case OP_LONG:
(*pos) += 3;
return value_from_longest (exp->elts[pc + 1].type,
@@ -495,16 +604,13 @@ evaluate_subexp_standard (struct type *expect_type,
if (expect_type != NULL_TYPE && noside != EVAL_SKIP
&& TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
- struct type *range_type = TYPE_FIELD_TYPE (type, 0);
- struct type *element_type = TYPE_TARGET_TYPE (type);
+ struct range_type *range_type = ARRAY_RANGE_TYPE (type);
+ struct type *element_type = ARRAY_ELEMENT_TYPE (type);
value_ptr array = allocate_value (expect_type);
int element_size = TYPE_LENGTH (check_typedef (element_type));
LONGEST low_bound, high_bound, index;
- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
- {
- low_bound = 0;
- high_bound = (TYPE_LENGTH (type) / element_size) - 1;
- }
+ low_bound = RANGE_LOWER_BOUND (range_type);
+ high_bound = RANGE_UPPER_BOUND (range_type);
index = low_bound;
memset (VALUE_CONTENTS_RAW (array), 0, TYPE_LENGTH (expect_type));
for (tem = nargs; --nargs >= 0;)
@@ -541,22 +647,20 @@ evaluate_subexp_standard (struct type *expect_type,
}
return array;
}
-
if (expect_type != NULL_TYPE && noside != EVAL_SKIP
&& TYPE_CODE (type) == TYPE_CODE_SET)
{
value_ptr set = allocate_value (expect_type);
char *valaddr = VALUE_CONTENTS_RAW (set);
- struct type *element_type = TYPE_INDEX_TYPE (type);
- struct type *check_type = element_type;
+ struct range_type *element_type = SET_RANGE_TYPE (type);
+ struct type *check_type;
LONGEST low_bound, high_bound;
-
- /* get targettype of elementtype */
- while (TYPE_CODE (check_type) == TYPE_CODE_RANGE ||
- TYPE_CODE (check_type) == TYPE_CODE_TYPEDEF)
- check_type = TYPE_TARGET_TYPE (check_type);
-
- if (get_discrete_bounds (element_type, &low_bound, &high_bound) < 0)
+ check_type = check_typedef ((struct type *)element_type);
+ while (TYPE_CODE (check_type) == TYPE_CODE_RANGE)
+ check_type = check_typedef (RANGE_INDEX_TYPE (check_type));
+ low_bound = RANGE_LOWER_BOUND (element_type);
+ high_bound = RANGE_UPPER_BOUND (element_type);
+ if (low_bound < 0 || high_bound < 0)
error ("(power)set type with unknown size");
memset (valaddr, '\0', TYPE_LENGTH (type));
for (tem = 0; tem < nargs; tem++)
@@ -567,16 +671,16 @@ evaluate_subexp_standard (struct type *expect_type,
if (exp->elts[*pos].opcode == BINOP_RANGE)
{
(*pos)++;
- elem_val = evaluate_subexp (element_type, exp, pos, noside);
+ elem_val = evaluate_subexp ((struct type *)element_type, exp, pos, noside);
range_low_type = VALUE_TYPE (elem_val);
range_low = value_as_long (elem_val);
- elem_val = evaluate_subexp (element_type, exp, pos, noside);
+ elem_val = evaluate_subexp ((struct type *)element_type, exp, pos, noside);
range_high_type = VALUE_TYPE (elem_val);
range_high = value_as_long (elem_val);
}
else
{
- elem_val = evaluate_subexp (element_type, exp, pos, noside);
+ elem_val = evaluate_subexp ((struct type *)element_type, exp, pos, noside);
range_low_type = range_high_type = VALUE_TYPE (elem_val);
range_low = range_high = value_as_long (elem_val);
}
@@ -584,9 +688,9 @@ evaluate_subexp_standard (struct type *expect_type,
different types. Also check if type of element is "compatible"
with element type of powerset */
if (TYPE_CODE (range_low_type) == TYPE_CODE_RANGE)
- range_low_type = TYPE_TARGET_TYPE (range_low_type);
+ range_low_type = RANGE_INDEX_TYPE (range_low_type);
if (TYPE_CODE (range_high_type) == TYPE_CODE_RANGE)
- range_high_type = TYPE_TARGET_TYPE (range_high_type);
+ range_high_type = RANGE_INDEX_TYPE (range_high_type);
if ((TYPE_CODE (range_low_type) != TYPE_CODE (range_high_type)) ||
(TYPE_CODE (range_low_type) == TYPE_CODE_ENUM &&
(range_low_type != range_high_type)))
@@ -616,7 +720,6 @@ evaluate_subexp_standard (struct type *expect_type,
}
return set;
}
-
argvec = (value_ptr *) alloca (sizeof (value_ptr) * nargs);
for (tem = 0; tem < nargs; tem++)
{
@@ -792,14 +895,14 @@ evaluate_subexp_standard (struct type *expect_type,
tem = 1;
type = VALUE_TYPE (argvec[0]);
if (type && TYPE_CODE (type) == TYPE_CODE_PTR)
- type = TYPE_TARGET_TYPE (type);
+ type = POINTER_TARGET_TYPE (type);
if (type && TYPE_CODE (type) == TYPE_CODE_FUNC)
{
- for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++)
+ for (; tem <= nargs && tem <= FUNCTION_NUM_ARGUMENTS (type); tem++)
{
/* pai: FIXME This seems to be coercing arguments before
* overload resolution has been done! */
- argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type, tem - 1),
+ argvec[tem] = evaluate_subexp (FUNCTION_ARGUMENT_TYPE (type, tem - 1),
exp, pos, noside);
}
}
@@ -1039,9 +1142,8 @@ evaluate_subexp_standard (struct type *expect_type,
struct type *type = VALUE_TYPE (arg1);
struct type *real_type;
int full, top, using_enc;
-
- if (objectprint && TYPE_TARGET_TYPE(type) &&
- (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+ if (objectprint && POINTER_TARGET_TYPE(type) &&
+ (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
{
real_type = value_rtti_target_type (arg1, &full, &top, &using_enc);
if (real_type)
@@ -1075,7 +1177,7 @@ evaluate_subexp_standard (struct type *expect_type,
/* With HP aCC, pointers to methods do not point to the function code */
if (hp_som_som_object_present &&
(TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) &&
- (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
+ (TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
error ("Pointers to methods not supported with HP aCC"); /* 1997-08-19 */
mem_offset = value_as_long (arg2);
@@ -1088,7 +1190,7 @@ evaluate_subexp_standard (struct type *expect_type,
/* With HP aCC, pointers to methods do not point to the function code */
if (hp_som_som_object_present &&
(TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) &&
- (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
+ (TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
error ("Pointers to methods not supported with HP aCC"); /* 1997-08-19 */
mem_offset = value_as_long (arg2);
@@ -1107,7 +1209,7 @@ evaluate_subexp_standard (struct type *expect_type,
type = check_typedef (VALUE_TYPE (arg2));
if (TYPE_CODE (type) != TYPE_CODE_PTR)
goto bad_pointer_to_member;
- type = check_typedef (TYPE_TARGET_TYPE (type));
+ type = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (type) == TYPE_CODE_METHOD)
error ("not implemented: pointer-to-method in pointer-to-member construct");
if (TYPE_CODE (type) != TYPE_CODE_MEMBER)
@@ -1143,12 +1245,12 @@ evaluate_subexp_standard (struct type *expect_type,
sequence (thunk) in memory -- in any case it is *not* the address
of the function as it would be in a naive implementation. */
if ((TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) &&
- (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_METHOD))
+ (TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_METHOD))
error ("Assignment to pointers to methods not implemented with HP aCC");
/* HP aCC pointers to data members require a constant bias */
if ((TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) &&
- (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_MEMBER))
+ (TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_MEMBER))
{
unsigned int *ptr = (unsigned int *) VALUE_CONTENTS (arg2); /* forces evaluation */
*ptr |= 0x20000000; /* set 29th bit */
@@ -1253,7 +1355,12 @@ evaluate_subexp_standard (struct type *expect_type,
}
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
+ {
+ if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ return value_zero (POINTER_TARGET_TYPE (type), VALUE_LVAL (arg1));
+ else
+ return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
+ }
else
return value_subscript (arg1, arg2);
}
@@ -1591,11 +1698,11 @@ evaluate_subexp_standard (struct type *expect_type,
case UNOP_IND:
if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
- expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type));
+ expect_type = POINTER_TARGET_TYPE (check_typedef (expect_type));
arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if ((TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) &&
- ((TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_METHOD) ||
- (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_MEMBER)))
+ if ((POINTER_TARGET_TYPE (VALUE_TYPE (arg1))) &&
+ ((TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_METHOD) ||
+ (TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_MEMBER)))
error ("Attempt to dereference pointer to member without an object");
if (noside == EVAL_SKIP)
goto nosideret;
@@ -1604,13 +1711,14 @@ evaluate_subexp_standard (struct type *expect_type,
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
type = check_typedef (VALUE_TYPE (arg1));
+ /* TYPEFIX */
if (TYPE_CODE (type) == TYPE_CODE_PTR
- || TYPE_CODE (type) == TYPE_CODE_REF
- /* In C you can dereference an array to get the 1st elt. */
- || TYPE_CODE (type) == TYPE_CODE_ARRAY
- )
- return value_zero (TYPE_TARGET_TYPE (type),
+ || TYPE_CODE (type) == TYPE_CODE_REF)
+ return value_zero (POINTER_TARGET_TYPE (type),
lval_memory);
+ /* In C you can dereference an array to get the 1st elt. */
+ else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+ return value_zero (ARRAY_ELEMENT_TYPE (type), lval_memory);
else if (TYPE_CODE (type) == TYPE_CODE_INT)
/* GDB allows dereferencing an int. */
return value_zero (builtin_type_int, lval_memory);
@@ -1641,7 +1749,7 @@ evaluate_subexp_standard (struct type *expect_type,
/* If HP aCC object, use bias for pointers to members */
if (hp_som_som_object_present &&
(TYPE_CODE (VALUE_TYPE (retvalp)) == TYPE_CODE_PTR) &&
- (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (retvalp))) == TYPE_CODE_MEMBER))
+ (TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (retvalp))) == TYPE_CODE_MEMBER))
{
unsigned int *ptr = (unsigned int *) VALUE_CONTENTS (retvalp); /* forces evaluation */
*ptr |= 0x20000000; /* set 29th bit */
@@ -1876,7 +1984,7 @@ evaluate_subexp_with_coercion (register struct expression *exp,
val =
locate_var_value
(var, block_innermost_frame (exp->elts[pc + 1].block));
- return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (check_typedef (SYMBOL_TYPE (var)))),
+ return value_cast (lookup_pointer_type (ARRAY_ELEMENT_TYPE (check_typedef (SYMBOL_TYPE (var)))),
val);
}
/* FALLTHROUGH */
@@ -1915,9 +2023,19 @@ evaluate_subexp_for_sizeof (register struct expression *exp, register int *pos)
&& TYPE_CODE (type) != TYPE_CODE_REF
&& TYPE_CODE (type) != TYPE_CODE_ARRAY)
error ("Attempt to take contents of a non-pointer value.");
- type = check_typedef (TYPE_TARGET_TYPE (type));
- return value_from_longest (builtin_type_int, (LONGEST)
- TYPE_LENGTH (type));
+ if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+ {
+ type = check_typedef (ARRAY_ELEMENT_TYPE (type));
+ return value_from_longest (builtin_type_int, (LONGEST) TYPE_LENGTH (type));
+ }
+ else
+ {
+ type = check_typedef (POINTER_TARGET_TYPE (type));
+ return value_from_longest (builtin_type_int, (LONGEST)
+ TYPE_LENGTH (type));
+ }
+
+
case UNOP_MEMVAL:
(*pos) += 3;
@@ -1967,7 +2085,7 @@ calc_f77_array_dims (struct type *array_type)
tmp_type = array_type;
- while ((tmp_type = TYPE_TARGET_TYPE (tmp_type)))
+ while ((tmp_type = ARRAY_ELEMENT_TYPE (tmp_type)))
{
if (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
++ndimen;
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 0603dddbbdb..131f25d1591 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -334,7 +334,7 @@ print_subexp (register struct expression *exp, register int *pos,
(*pos) += 2;
if ((int) prec > (int) PREC_PREFIX)
fputs_filtered ("(", stream);
- if (exp->elts[pc + 1].type->code == TYPE_CODE_FUNC &&
+ if (TYPE_CODE(exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
exp->elts[pc + 3].opcode == OP_LONG)
{
/* We have a minimal symbol fn, probably. It's encoded
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 7cbfd5ac8f2..83f6e69fc3b 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -475,7 +475,7 @@ variable: name_not_typename
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
+ (struct type *)make_function_type (NULL, builtin_type_int, 0, NULL, 0),
builtin_type_int);
}
else if (!have_full_symbols () && !have_partial_symbols ())
@@ -498,7 +498,7 @@ ptype : typebase
int done = 0;
int array_size;
struct type *follow_type = $1;
- struct type *range_type;
+ struct range_type *range_type;
while (!done)
switch (pop_type ())
@@ -517,18 +517,18 @@ ptype : typebase
if (array_size != -1)
{
range_type =
- create_range_type ((struct type *) NULL,
+ make_range_type (NULL,
builtin_type_f_integer, 0,
array_size - 1);
- follow_type =
- create_array_type ((struct type *) NULL,
+ follow_type = (struct type *)
+ make_array_type (NULL,
follow_type, range_type);
}
else
follow_type = lookup_pointer_type (follow_type);
break;
case tp_function:
- follow_type = lookup_function_type (follow_type);
+ follow_type = (struct type *)make_function_type (NULL, follow_type, 0, NULL, 0);
break;
}
$$ = follow_type;
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index bee4063c9d0..1fb3bae17cd 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -250,7 +250,8 @@ f_printstr (struct ui_file *stream, char *string, unsigned int length,
static struct type *
f_create_fundamental_type (struct objfile *objfile, int typeid)
{
- register struct type *type = NULL;
+#if TYPEFIX
+ register struct type *type = NULL;
switch (typeid)
{
@@ -399,6 +400,9 @@ f_create_fundamental_type (struct objfile *objfile, int typeid)
break;
}
return (type);
+#else
+ return NULL;
+#endif
}
@@ -486,6 +490,8 @@ const struct language_defn f_language_defn =
void
_initialize_f_language (void)
{
+#if TYPEFIX
+
builtin_type_f_void =
init_type (TYPE_CODE_VOID, 1,
0,
@@ -563,6 +569,7 @@ _initialize_f_language (void)
"character string", (struct objfile *) NULL);
add_language (&f_language_defn);
+#endif
}
#if 0
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 6e2f8b05f38..c45f6112097 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -108,17 +108,17 @@ f_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
- f_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
+ f_type_print_varspec_prefix (POINTER_TARGET_TYPE (type), stream, 0, 1);
break;
case TYPE_CODE_FUNC:
- f_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
+ f_type_print_varspec_prefix (FUNCTION_RETURN_VALUE (type), stream, 0, 0);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
case TYPE_CODE_ARRAY:
- f_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
+ f_type_print_varspec_prefix (ARRAY_ELEMENT_TYPE (type), stream, 0, 0);
break;
case TYPE_CODE_UNDEF:
@@ -205,14 +205,16 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
switch (TYPE_CODE (type))
{
+
+ /* TYPEFIX - handle fortran arrays properly again */
case TYPE_CODE_ARRAY:
arrayprint_recurse_level++;
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, "(");
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+ if (TYPE_CODE (ARRAY_ELEMENT_TYPE (type)) == TYPE_CODE_ARRAY)
+ f_type_print_varspec_suffix (ARRAY_ELEMENT_TYPE (type), stream, 0, 0, 0);
retcode = f77_get_dynamic_lowerbound (type, &lower_bound);
@@ -233,7 +235,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
/* Make sure that, if we have an assumed size array, we
print out a warning and print the upperbound as '*' */
- if (TYPE_ARRAY_UPPER_BOUND_TYPE (type) == BOUND_CANNOT_BE_DETERMINED)
+ if (TYPE_ARRAY_UPPER_BOUND_TYPE (type) == BT_cannot_be_determined)
fprintf_filtered (stream, "*");
else
{
@@ -256,12 +258,12 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
+ f_type_print_varspec_suffix (POINTER_TARGET_TYPE (type), stream, 0, 1, 0);
fprintf_filtered (stream, ")");
break;
case TYPE_CODE_FUNC:
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+ f_type_print_varspec_suffix (FUNCTION_RETURN_VALUE (type), stream, 0,
passed_a_ptr, 0);
if (passed_a_ptr)
fprintf_filtered (stream, ")");
@@ -354,13 +356,15 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
break;
case TYPE_CODE_ARRAY:
+ f_type_print_base (ARRAY_ELEMENT_TYPE (type), stream, show, level);
+ break;
case TYPE_CODE_FUNC:
- f_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ f_type_print_base (FUNCTION_RETURN_VALUE (type), stream, show, level);
break;
case TYPE_CODE_PTR:
fprintf_filtered (stream, "PTR TO -> ( ");
- f_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
+ f_type_print_base (POINTER_TARGET_TYPE (type), stream, 0, level);
break;
case TYPE_CODE_VOID:
@@ -407,7 +411,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
case TYPE_CODE_STRING:
/* Strings may have dynamic upperbounds (lengths) like arrays. */
- if (TYPE_ARRAY_UPPER_BOUND_TYPE (type) == BOUND_CANNOT_BE_DETERMINED)
+ if (TYPE_ARRAY_UPPER_BOUND_TYPE (type) == BT_cannot_be_determined)
fprintf_filtered (stream, "character*(*)");
else
{
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 48c511377e8..7c262922d06 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -73,7 +73,7 @@ f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type))
{
- case BOUND_BY_VALUE_ON_STACK:
+ case BT_by_value_on_stack:
current_frame_addr = selected_frame->frame;
if (current_frame_addr > 0)
{
@@ -89,15 +89,15 @@ f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
}
break;
- case BOUND_SIMPLE:
+ case BT_simple:
*lower_bound = TYPE_ARRAY_LOWER_BOUND_VALUE (type);
break;
- case BOUND_CANNOT_BE_DETERMINED:
+ case BT_cannot_be_determined:
error ("Lower bound may not be '*' in F77");
break;
- case BOUND_BY_REF_ON_STACK:
+ case BT_by_ref_on_stack:
current_frame_addr = selected_frame->frame;
if (current_frame_addr > 0)
{
@@ -114,8 +114,8 @@ f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
}
break;
- case BOUND_BY_REF_IN_REG:
- case BOUND_BY_VALUE_IN_REG:
+ case BT_by_ref_in_reg:
+ case BT_by_value_in_reg:
default:
error ("??? unhandled dynamic array bound type ???");
break;
@@ -131,7 +131,7 @@ f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type))
{
- case BOUND_BY_VALUE_ON_STACK:
+ case BT_by_value_on_stack:
current_frame_addr = selected_frame->frame;
if (current_frame_addr > 0)
{
@@ -147,11 +147,11 @@ f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
}
break;
- case BOUND_SIMPLE:
+ case BT_simple:
*upper_bound = TYPE_ARRAY_UPPER_BOUND_VALUE (type);
break;
- case BOUND_CANNOT_BE_DETERMINED:
+ case BT_cannot_be_determined:
/* we have an assumed size array on our hands. Assume that
upper_bound == lower_bound so that we show at least
1 element.If the user wants to see more elements, let
@@ -160,7 +160,7 @@ f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
f77_get_dynamic_lowerbound (type, upper_bound);
break;
- case BOUND_BY_REF_ON_STACK:
+ case BT_by_ref_on_stack:
current_frame_addr = selected_frame->frame;
if (current_frame_addr > 0)
{
@@ -177,8 +177,8 @@ f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
}
break;
- case BOUND_BY_REF_IN_REG:
- case BOUND_BY_VALUE_IN_REG:
+ case BT_by_ref_in_reg:
+ case BT_by_value_in_reg:
default:
error ("??? unhandled dynamic array bound type ???");
break;
@@ -204,9 +204,9 @@ f77_get_dynamic_length_of_aggregate (struct type *type)
This function also works for strings which behave very
similarly to arrays. */
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY
- || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRING)
- f77_get_dynamic_length_of_aggregate (TYPE_TARGET_TYPE (type));
+ if (TYPE_CODE (ARRAY_ELEMENT_TYPE (type)) == TYPE_CODE_ARRAY
+ || TYPE_CODE (ARRAY_ELEMENT_TYPE (type)) == TYPE_CODE_STRING)
+ f77_get_dynamic_length_of_aggregate (ARRAY_ELEMENT_TYPE (type));
/* Recursion ends here, start setting up lengths. */
retcode = f77_get_dynamic_lowerbound (type, &lower_bound);
@@ -220,7 +220,7 @@ f77_get_dynamic_length_of_aggregate (struct type *type)
/* Patch in a valid length value. */
TYPE_LENGTH (type) =
- (upper_bound - lower_bound + 1) * TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
+ (upper_bound - lower_bound + 1) * TYPE_LENGTH (check_typedef (ARRAY_ELEMENT_TYPE (type)));
}
/* Function that sets up the array offset,size table for the array
@@ -238,7 +238,8 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
while ((TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY))
{
- if (TYPE_ARRAY_UPPER_BOUND_TYPE (tmp_type) == BOUND_CANNOT_BE_DETERMINED)
+#if TYPEFIX
+ if (TYPE_ARRAY_UPPER_BOUND_TYPE (tmp_type) == BT_cannot_be_determined)
fprintf_filtered (stream, "<assumed size array> ");
retcode = f77_get_dynamic_upperbound (tmp_type, &upper);
@@ -252,6 +253,7 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
F77_DIM_SIZE (ndimen) = upper - lower + 1;
tmp_type = TYPE_TARGET_TYPE (tmp_type);
+#endif
ndimen++;
}
@@ -389,7 +391,7 @@ f_val_print (struct type *type, char *valaddr, int embedded_offset,
else
{
addr = unpack_pointer (type, valaddr);
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
diff --git a/gdb/findvar.c b/gdb/findvar.c
index c5bf50755dc..35db176cf90 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -501,7 +501,6 @@ symbol_read_needs_frame (struct symbol *sym)
}
return 1;
}
-
/* Given a struct symbol for a variable,
and a stack frame id, read the value of the variable
and return a (pointer to a) struct value containing the value.
@@ -524,7 +523,6 @@ read_var_value (register struct symbol *var, struct frame_info *frame)
if (frame == NULL)
frame = selected_frame;
-
switch (SYMBOL_CLASS (var))
{
case LOC_CONST:
@@ -942,8 +940,8 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
snum = (unsigned short)
extract_unsigned_integer (VALUE_CONTENTS_RAW (v), 2);
- if (TYPE_TARGET_TYPE (type) /* pointer to function */
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
+ if (POINTER_TARGET_TYPE (type) /* pointer to function */
+ && (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
num = D10V_MAKE_IADDR (snum);
else /* pointer to data */
num = D10V_MAKE_DADDR (snum);
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index bac36c2948b..669730bee81 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -4553,7 +4553,8 @@ alloc_gdbarch_data (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch->data == NULL);
gdbarch->nr_data = gdbarch_data_registry.nr;
- gdbarch->data = xcalloc (gdbarch->nr_data, sizeof (void*));
+ if (gdbarch->nr_data != 0)
+ gdbarch->data = xcalloc (gdbarch->nr_data, sizeof (void*));
}
static void
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index f2fed5f5481..244928a8318 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -74,7 +74,6 @@ struct type *builtin_type_v8qi;
struct type *builtin_type_v4hi;
struct type *builtin_type_v2si;
struct type *builtin_type_ptr;
-struct type *builtin_type_void_func_ptr;
struct type *builtin_type_CORE_ADDR;
struct type *builtin_type_bfd_vma;
@@ -87,18 +86,201 @@ struct extra
int len;
}; /* maximum extension is 128! FIXME */
-static void add_name (struct extra *, char *);
+static void add_name (struct extra *, const char *);
static void add_mangled_type (struct extra *, struct type *);
-#if 0
-static void cfront_mangle_name (struct type *, int, int);
-#endif
static void print_bit_vector (B_TYPE *, int);
static void print_arg_types (struct type **, int);
static void dump_fn_fieldlists (struct type *, int);
static void print_cplus_stuff (struct type *, int);
static void virtual_base_list_aux (struct type *dclass);
+static struct type *
+alloc_type_internal (struct objfile *objfile, unsigned int size)
+{
+ register struct type *type;
+ if (objfile == NULL)
+ {
+ type = (struct type *) xmalloc (size);
+ }
+ else
+ {
+ type = (struct type *) obstack_alloc (&objfile->type_obstack,
+ size);
+ OBJSTAT (objfile, n_types++);
+ }
+ memset ((char *) type, 0, size);
+ return type;
+}
+struct function_type *
+make_function_type (struct objfile *objfile, struct type *return_type,
+ unsigned char num_args, struct argument_pair **pairs,
+ unsigned char is_varargs)
+{
+ struct type *new =
+ (struct type *) alloc_type_internal (objfile,
+ sizeof (struct function_type));
+ TYPE_CODE (new) = TYPE_CODE_FUNC;
+ TYPE_LENGTH (new) = 1;
+ FUNCTION_RETURN_VALUE (new) = return_type;
+ FUNCTION_NUM_ARGUMENTS (new) = num_args;
+ if (pairs != NULL)
+ FUNCTION_ARGUMENTS (new) = *pairs;
+ FUNCTION_IS_VARARGS (new) = is_varargs;
+ return FUNCTION_TYPE_CAST (new);
+}
+struct enum_type *
+make_enum_type (struct objfile *objfile, unsigned int numvals,
+ struct enum_pair ** pairs)
+{
+ int i;
+ struct type *new = (struct type *) alloc_type_internal (objfile,
+ sizeof (struct enum_type));
+ TYPE_CODE (new) = TYPE_CODE_ENUM;
+ TYPE_LENGTH (new) = TARGET_INT_BIT / HOST_CHAR_BIT;
+ ENUM_NUM_VALUES (new) = numvals;
+ ENUM_VALUES (new) = *pairs;
+ SIGNED_TYPE_SIGN (new) = ST_unsigned;
+ for (i = 0; i < ENUM_NUM_VALUES (new); i++)
+ if (ENUM_VALUE_VALUE (new, i) < 0)
+ {
+ SIGNED_TYPE_SIGN (new) = ST_signed;
+ break;
+ }
+
+ return ENUM_TYPE_CAST (new);
+}
+struct array_type *
+make_string_type (struct objfile *objfile, struct range_type *range_type)
+{
+ struct type *new = (struct type *)
+ make_array_type (objfile, *current_language->string_char_type, range_type);
+ TYPE_CODE (new) = TYPE_CODE_STRING;
+ return ARRAY_TYPE_CAST (new);
+}
+struct set_type *
+make_set_type (struct objfile *objfile, struct range_type *range_type)
+{
+ struct type *new = (struct type *)
+ alloc_type_internal (objfile, sizeof (struct set_type));
+ LONGEST bit_length;
+ if (! TYPE_FLAGS (range_type) & TYPE_FLAG_STUB)
+ {
+ bit_length =
+ (RANGE_UPPER_BOUND (range_type))-(RANGE_LOWER_BOUND (range_type)) + 1;
+ TYPE_LENGTH (new) = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
+ }
+ TYPE_CODE (new) = TYPE_CODE_SET;
+ SET_RANGE_TYPE (new) = range_type;
+ return SET_TYPE_CAST (new);
+}
+struct array_type *
+make_array_type (struct objfile *objfile, struct type *element_type,
+ struct range_type *range_type)
+{
+ struct type *new = alloc_type_internal (objfile, sizeof (struct array_type));
+
+ TYPE_CODE (new) = TYPE_CODE_ARRAY;
+ ARRAY_ELEMENT_TYPE (new) = element_type;
+ ARRAY_RANGE_TYPE (new) = range_type;
+ TYPE_LENGTH (new) = TYPE_LENGTH (element_type) *
+ (RANGE_UPPER_BOUND (range_type) - RANGE_LOWER_BOUND (range_type) + 1);
+
+ /* TYPEFIX - What to do here? TYPE_FLAGS_TARGET_STUB seems wrong. */
+ if (TYPE_LENGTH (new) == 0)
+ /*
+ error ("Need to handle zero length arrays properly!");
+ */
+ TYPE_FLAGS (new) |= TYPE_FLAG_TARGET_STUB;
+ return (ARRAY_TYPE_CAST (new));
+}
+struct range_type *
+make_range_type (struct objfile *objfile, struct type *index_type,
+ int lower_bound, int upper_bound)
+{
+ struct type *new = alloc_type_internal (objfile, sizeof (struct range_type));
+
+ TYPE_CODE (new) = TYPE_CODE_RANGE;
+ RANGE_UPPER_BOUND (new) = upper_bound;
+ RANGE_LOWER_BOUND (new) = lower_bound;
+ RANGE_INDEX_TYPE (new) = index_type;
+ TYPE_LENGTH (new) = TYPE_LENGTH (check_typedef (index_type));
+ return (RANGE_TYPE_CAST (new));
+}
+struct void_type *
+make_void_type (struct objfile *objfile, const char *name)
+{
+ struct type *new = alloc_type_internal (objfile, sizeof (struct void_type));
+ TYPE_CODE (new) = TYPE_CODE_VOID;
+ TYPE_LENGTH (new) = 1;
+ TYPE_NAME (new) = name;
+ return VOID_TYPE_CAST (new);
+}
+
+struct boolean_type *
+make_boolean_type (struct objfile *objfile, const char *name)
+{
+ struct type *new = alloc_type_internal (objfile,
+ sizeof (struct boolean_type));
+ TYPE_CODE (new) = TYPE_CODE_BOOL;
+ TYPE_LENGTH (new) = 1;
+ TYPE_NAME (new) = name;
+ return BOOLEAN_TYPE_CAST (new);
+}
+
+struct character_type *
+make_character_type (struct objfile *objfile, const char *name,
+ unsigned int length, enum sign_type sign)
+{
+ struct type *new = alloc_type_internal (objfile,
+ sizeof (struct character_type));
+ TYPE_CODE (new) = TYPE_CODE_CHAR;
+ TYPE_LENGTH(new) = length;
+ TYPE_NAME(new) = name;
+ SIGNED_TYPE_SIGN(new) = sign;
+ return CHARACTER_TYPE_CAST (new);
+}
+struct integer_type *
+make_integer_type (struct objfile *objfile, const char *name,
+ unsigned int length, enum sign_type sign)
+{
+ struct type *new = alloc_type_internal (objfile,
+ sizeof (struct integer_type));
+ TYPE_CODE (new) = TYPE_CODE_INT;
+ TYPE_LENGTH(new) = length;
+ TYPE_NAME(new) = name;
+ SIGNED_TYPE_SIGN(new) = sign;
+ return INTEGER_TYPE_CAST (new);
+}
+struct pointer_type *
+make_reference_type (struct objfile *objfile, struct type *target)
+{
+ struct type *new;
+
+ if (TYPE_REFERENCE_TYPE (target) != NULL)
+ return POINTER_TYPE_CAST (TYPE_REFERENCE_TYPE (target));
+
+ new = alloc_type_internal (objfile, sizeof (struct pointer_type));
+ TYPE_CODE (new) = TYPE_CODE_REF;
+ TYPE_LENGTH (new) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
+ POINTER_TARGET_TYPE (new) = target;
+ TYPE_REFERENCE_TYPE (target) = new;
+ return POINTER_TYPE_CAST (new);
+}
+struct pointer_type *
+make_pointer_type (struct objfile *objfile, struct type *target)
+{
+ struct type *new;
+
+ if (TYPE_POINTER_TYPE (target) != NULL)
+ return POINTER_TYPE_CAST (TYPE_POINTER_TYPE (target));
+ new = alloc_type_internal (objfile, sizeof (struct pointer_type));
+ TYPE_CODE (new) = TYPE_CODE_PTR;
+ TYPE_LENGTH (new) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
+ POINTER_TARGET_TYPE (new) = target;
+ TYPE_POINTER_TYPE (target) = new;
+ return POINTER_TYPE_CAST (new);
+}
/* Alloc a new type structure and fill it with some defaults. If
OBJFILE is non-NULL, then allocate the space for the type structure
in that objfile's type_obstack. */
@@ -111,9 +293,7 @@ alloc_type (struct objfile *objfile)
/* Alloc the structure and start off with all fields zeroed. */
if (objfile == NULL)
- {
type = (struct type *) xmalloc (sizeof (struct type));
- }
else
{
type = (struct type *) obstack_alloc (&objfile->type_obstack,
@@ -123,144 +303,37 @@ alloc_type (struct objfile *objfile)
memset ((char *) type, 0, sizeof (struct type));
/* Initialize the fields that might not be zero. */
-
+
+ if (current_language->la_language == language_cplus)
+ INIT_CPLUS_SPECIFIC (type);
+ else if (current_language->la_language == language_fortran)
+ INIT_FORTRAN_SPECIFIC (type);
+ else
+ INIT_CPLUS_SPECIFIC (type);
TYPE_CODE (type) = TYPE_CODE_UNDEF;
TYPE_OBJFILE (type) = objfile;
- TYPE_VPTR_FIELDNO (type) = -1;
TYPE_CV_TYPE (type) = type; /* chain back to itself */
+ TYPE_VPTR_FIELDNO (type) = -1;
+ TYPE_VPTR_BASETYPE (type) = NULL;
return (type);
}
-
-/* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
- to a pointer to memory where the pointer type should be stored.
- If *TYPEPTR is zero, update it to point to the pointer type we return.
- We allocate new memory if needed. */
-
-struct type *
-make_pointer_type (struct type *type, struct type **typeptr)
-{
- register struct type *ntype; /* New type */
- struct objfile *objfile;
-
- ntype = TYPE_POINTER_TYPE (type);
-
- if (ntype)
- {
- if (typeptr == 0)
- return ntype; /* Don't care about alloc, and have new type. */
- else if (*typeptr == 0)
- {
- *typeptr = ntype; /* Tracking alloc, and we have new type. */
- return ntype;
- }
- }
-
- if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
- {
- ntype = alloc_type (TYPE_OBJFILE (type));
- if (typeptr)
- *typeptr = ntype;
- }
- else
- /* We have storage, but need to reset it. */
- {
- ntype = *typeptr;
- objfile = TYPE_OBJFILE (ntype);
- memset ((char *) ntype, 0, sizeof (struct type));
- TYPE_OBJFILE (ntype) = objfile;
- }
-
- TYPE_TARGET_TYPE (ntype) = type;
- TYPE_POINTER_TYPE (type) = ntype;
-
- /* FIXME! Assume the machine has only one representation for pointers! */
-
- TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
- TYPE_CODE (ntype) = TYPE_CODE_PTR;
-
- /* Mark pointers as unsigned. The target converts between pointers
- and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and
- ADDRESS_TO_POINTER(). */
- TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED;
-
- if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */
- TYPE_POINTER_TYPE (type) = ntype;
-
- return ntype;
-}
-
/* Given a type TYPE, return a type of pointers to that type.
May need to construct such a type if this is the first use. */
struct type *
lookup_pointer_type (struct type *type)
{
- return make_pointer_type (type, (struct type **) 0);
-}
-
-/* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
- to a pointer to memory where the reference type should be stored.
- If *TYPEPTR is zero, update it to point to the reference type we return.
- We allocate new memory if needed. */
-
-struct type *
-make_reference_type (struct type *type, struct type **typeptr)
-{
- register struct type *ntype; /* New type */
- struct objfile *objfile;
-
- ntype = TYPE_REFERENCE_TYPE (type);
-
- if (ntype)
- {
- if (typeptr == 0)
- return ntype; /* Don't care about alloc, and have new type. */
- else if (*typeptr == 0)
- {
- *typeptr = ntype; /* Tracking alloc, and we have new type. */
- return ntype;
- }
- }
-
- if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
- {
- ntype = alloc_type (TYPE_OBJFILE (type));
- if (typeptr)
- *typeptr = ntype;
- }
- else
- /* We have storage, but need to reset it. */
- {
- ntype = *typeptr;
- objfile = TYPE_OBJFILE (ntype);
- memset ((char *) ntype, 0, sizeof (struct type));
- TYPE_OBJFILE (ntype) = objfile;
- }
-
- TYPE_TARGET_TYPE (ntype) = type;
- TYPE_REFERENCE_TYPE (type) = ntype;
-
- /* FIXME! Assume the machine has only one representation for references,
- and that it matches the (only) representation for pointers! */
-
- TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
- TYPE_CODE (ntype) = TYPE_CODE_REF;
-
- if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
- TYPE_REFERENCE_TYPE (type) = ntype;
-
- return ntype;
+ return (struct type *)make_pointer_type (NULL, type);
}
-
/* Same as above, but caller doesn't care about memory allocation details. */
struct type *
lookup_reference_type (struct type *type)
{
- return make_reference_type (type, (struct type **) 0);
+ return (struct type *)make_reference_type (NULL, type);
}
-
+#if 0
/* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
to a pointer to memory where the function type should be stored.
If *TYPEPTR is zero, update it to point to the function type we return.
@@ -304,7 +377,7 @@ lookup_function_type (struct type *type)
{
return make_function_type (type, (struct type **) 0);
}
-
+#endif
/* Make a "c-v" variant of a type -- a type that is identical to the
one supplied except that it may have const or volatile attributes
@@ -324,7 +397,7 @@ make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
struct objfile *objfile;
ntype = TYPE_CV_TYPE (type);
-
+
while (ntype != type)
{
if ((TYPE_CONST (ntype) == cnst) &&
@@ -341,7 +414,7 @@ make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
tmp_type = ntype;
ntype = TYPE_CV_TYPE (ntype);
}
-
+
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
ntype = alloc_type (TYPE_OBJFILE (type));
@@ -421,204 +494,6 @@ allocate_stub_method (struct type *type)
return (mtype);
}
-/* Create a range type using either a blank type supplied in RESULT_TYPE,
- or creating a new type, inheriting the objfile from INDEX_TYPE.
-
- Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
- HIGH_BOUND, inclusive.
-
- FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
- sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
-
-struct type *
-create_range_type (struct type *result_type, struct type *index_type,
- int low_bound, int high_bound)
-{
- if (result_type == NULL)
- {
- result_type = alloc_type (TYPE_OBJFILE (index_type));
- }
- TYPE_CODE (result_type) = TYPE_CODE_RANGE;
- TYPE_TARGET_TYPE (result_type) = index_type;
- if (TYPE_FLAGS (index_type) & TYPE_FLAG_STUB)
- TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
- else
- TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
- TYPE_NFIELDS (result_type) = 2;
- TYPE_FIELDS (result_type) = (struct field *)
- TYPE_ALLOC (result_type, 2 * sizeof (struct field));
- memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
- TYPE_FIELD_BITPOS (result_type, 0) = low_bound;
- TYPE_FIELD_BITPOS (result_type, 1) = high_bound;
- TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */
- TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */
-
- if (low_bound >= 0)
- TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
-
- return (result_type);
-}
-
-/* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
- Return 1 of type is a range type, 0 if it is discrete (and bounds
- will fit in LONGEST), or -1 otherwise. */
-
-int
-get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
-{
- CHECK_TYPEDEF (type);
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_RANGE:
- *lowp = TYPE_LOW_BOUND (type);
- *highp = TYPE_HIGH_BOUND (type);
- return 1;
- case TYPE_CODE_ENUM:
- if (TYPE_NFIELDS (type) > 0)
- {
- /* The enums may not be sorted by value, so search all
- entries */
- int i;
-
- *lowp = *highp = TYPE_FIELD_BITPOS (type, 0);
- for (i = 0; i < TYPE_NFIELDS (type); i++)
- {
- if (TYPE_FIELD_BITPOS (type, i) < *lowp)
- *lowp = TYPE_FIELD_BITPOS (type, i);
- if (TYPE_FIELD_BITPOS (type, i) > *highp)
- *highp = TYPE_FIELD_BITPOS (type, i);
- }
-
- /* Set unsigned indicator if warranted. */
- if (*lowp >= 0)
- {
- TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
- }
- }
- else
- {
- *lowp = 0;
- *highp = -1;
- }
- return 0;
- case TYPE_CODE_BOOL:
- *lowp = 0;
- *highp = 1;
- return 0;
- case TYPE_CODE_INT:
- if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */
- return -1;
- if (!TYPE_UNSIGNED (type))
- {
- *lowp = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1));
- *highp = -*lowp - 1;
- return 0;
- }
- /* ... fall through for unsigned ints ... */
- case TYPE_CODE_CHAR:
- *lowp = 0;
- /* This round-about calculation is to avoid shifting by
- TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
- if TYPE_LENGTH (type) == sizeof (LONGEST). */
- *highp = 1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1);
- *highp = (*highp - 1) | *highp;
- return 0;
- default:
- return -1;
- }
-}
-
-/* Create an array type using either a blank type supplied in RESULT_TYPE,
- or creating a new type, inheriting the objfile from RANGE_TYPE.
-
- Elements will be of type ELEMENT_TYPE, the indices will be of type
- RANGE_TYPE.
-
- FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
- sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
-
-struct type *
-create_array_type (struct type *result_type, struct type *element_type,
- struct type *range_type)
-{
- LONGEST low_bound, high_bound;
-
- if (result_type == NULL)
- {
- result_type = alloc_type (TYPE_OBJFILE (range_type));
- }
- TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (result_type) = element_type;
- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
- low_bound = high_bound = 0;
- CHECK_TYPEDEF (element_type);
- TYPE_LENGTH (result_type) =
- TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
- TYPE_NFIELDS (result_type) = 1;
- TYPE_FIELDS (result_type) =
- (struct field *) TYPE_ALLOC (result_type, sizeof (struct field));
- memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
- TYPE_FIELD_TYPE (result_type, 0) = range_type;
- TYPE_VPTR_FIELDNO (result_type) = -1;
-
- /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
- if (TYPE_LENGTH (result_type) == 0)
- TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
-
- return (result_type);
-}
-
-/* Create a string type using either a blank type supplied in RESULT_TYPE,
- or creating a new type. String types are similar enough to array of
- char types that we can use create_array_type to build the basic type
- and then bash it into a string type.
-
- For fixed length strings, the range type contains 0 as the lower
- bound and the length of the string minus one as the upper bound.
-
- FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
- sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
-
-struct type *
-create_string_type (struct type *result_type, struct type *range_type)
-{
- result_type = create_array_type (result_type,
- *current_language->string_char_type,
- range_type);
- TYPE_CODE (result_type) = TYPE_CODE_STRING;
- return (result_type);
-}
-
-struct type *
-create_set_type (struct type *result_type, struct type *domain_type)
-{
- LONGEST low_bound, high_bound, bit_length;
- if (result_type == NULL)
- {
- result_type = alloc_type (TYPE_OBJFILE (domain_type));
- }
- TYPE_CODE (result_type) = TYPE_CODE_SET;
- TYPE_NFIELDS (result_type) = 1;
- TYPE_FIELDS (result_type) = (struct field *)
- TYPE_ALLOC (result_type, 1 * sizeof (struct field));
- memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
-
- if (!(TYPE_FLAGS (domain_type) & TYPE_FLAG_STUB))
- {
- if (get_discrete_bounds (domain_type, &low_bound, &high_bound) < 0)
- low_bound = high_bound = 0;
- bit_length = high_bound - low_bound + 1;
- TYPE_LENGTH (result_type)
- = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
- }
- TYPE_FIELD_TYPE (result_type, 0) = domain_type;
-
- if (low_bound >= 0)
- TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
-
- return (result_type);
-}
-
/* Construct and return a type of the form:
struct NAME { ELT_TYPE ELT_NAME[N]; }
@@ -632,7 +507,7 @@ create_set_type (struct type *result_type, struct type *domain_type)
static struct type *
init_simd_type (char *name,
struct type *elt_type,
- char *elt_name,
+ const char *elt_name,
int n)
{
struct type *t;
@@ -642,16 +517,15 @@ init_simd_type (char *name,
f = xmalloc (sizeof (*f));
memset (f, 0, sizeof (*f));
f->loc.bitpos = 0;
- f->type = create_array_type (0, elt_type,
- create_range_type (0, builtin_type_int,
+ f->type = (struct type *)make_array_type (NULL, elt_type,
+ make_range_type (NULL, builtin_type_int,
0, n-1));
- f->name = elt_name;
-
+ TYPE_NAME (f->type) = elt_name;
/* Build a struct type with that field. */
t = init_type (TYPE_CODE_STRUCT, n * TYPE_LENGTH (elt_type), 0, 0, 0);
- t->nfields = 1;
- t->fields = f;
- t->tag_name = name;
+ TYPE_NFIELDS(t) = 1;
+ TYPE_FIELDS(t) = f;
+ TYPE_TAG_NAME(t) = name;
return t;
}
@@ -699,6 +573,7 @@ smash_to_method_type (struct type *type, struct type *domain,
objfile = TYPE_OBJFILE (type);
memset ((char *) type, 0, sizeof (struct type));
+ ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_OBJFILE (type) = objfile;
TYPE_TARGET_TYPE (type) = to_type;
TYPE_DOMAIN_TYPE (type) = domain;
@@ -710,7 +585,7 @@ smash_to_method_type (struct type *type, struct type *domain,
/* Return a typename for a struct/union/enum type without "struct ",
"union ", or "enum ". If the type has a NULL name, return NULL. */
-char *
+const char *
type_name_no_tag (register const struct type *type)
{
if (TYPE_TAG_NAME (type) != NULL)
@@ -726,13 +601,13 @@ type_name_no_tag (register const struct type *type)
Return zero if NAME is not a primitive type. */
struct type *
-lookup_primitive_typename (char *name)
+lookup_primitive_typename (const char *name)
{
struct type **const *p;
for (p = current_language->la_builtin_type_vector; *p != NULL; p++)
{
- if (STREQ ((**p)->name, name))
+ if (STREQ (TYPE_NAME((**p)), name))
{
return (**p);
}
@@ -745,7 +620,7 @@ lookup_primitive_typename (char *name)
If NOERR is nonzero, return zero if NAME is not suitably defined. */
struct type *
-lookup_typename (char *name, struct block *block, int noerr)
+lookup_typename (const char *name, struct block *block, int noerr)
{
register struct symbol *sym;
register struct type *tmp;
@@ -755,23 +630,17 @@ lookup_typename (char *name, struct block *block, int noerr)
{
tmp = lookup_primitive_typename (name);
if (tmp)
- {
- return (tmp);
- }
+ return (tmp);
else if (!tmp && noerr)
- {
- return (NULL);
- }
+ return (NULL);
else
- {
- error ("No type named %s.", name);
- }
+ error ("No type named %s.", name);
}
return (SYMBOL_TYPE (sym));
}
struct type *
-lookup_unsigned_typename (char *name)
+lookup_unsigned_typename (const char *name)
{
char *uns = alloca (strlen (name) + 10);
@@ -781,7 +650,7 @@ lookup_unsigned_typename (char *name)
}
struct type *
-lookup_signed_typename (char *name)
+lookup_signed_typename (const char *name)
{
struct type *t;
char *uns = alloca (strlen (name) + 8);
@@ -807,13 +676,9 @@ lookup_struct (char *name, struct block *block)
(struct symtab **) NULL);
if (sym == NULL)
- {
error ("No struct type named %s.", name);
- }
if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
- {
error ("This context has class, union or enum %s, not a struct.", name);
- }
return (SYMBOL_TYPE (sym));
}
@@ -841,7 +706,7 @@ lookup_union (char *name, struct block *block)
* a further "declared_type" field to discover it is really a union.
*/
if (HAVE_CPLUS_STRUCT (t))
- if (TYPE_DECLARED_TYPE (t) == DECLARED_TYPE_UNION)
+ if (TYPE_DECLARED_TYPE (t) == DT_union)
return (t);
/* If we get here, it's not a union */
@@ -860,13 +725,9 @@ lookup_enum (char *name, struct block *block)
sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0,
(struct symtab **) NULL);
if (sym == NULL)
- {
error ("No enum type named %s.", name);
- }
if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM)
- {
error ("This context has class, struct or union %s, not an enum.", name);
- }
return (SYMBOL_TYPE (sym));
}
@@ -874,34 +735,32 @@ lookup_enum (char *name, struct block *block)
visible in lexical block BLOCK. */
struct type *
-lookup_template_type (char *name, struct type *type, struct block *block)
+lookup_template_type (const char *name, struct type *type, struct block *block)
{
struct symbol *sym;
- char *nam = (char *) alloca (strlen (name) + strlen (type->name) + 4);
+ char *nam = (char *) alloca (strlen (name) + strlen (TYPE_NAME(type)) + 4);
strcpy (nam, name);
strcat (nam, "<");
- strcat (nam, type->name);
+ strcat (nam, TYPE_NAME(type));
strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
sym = lookup_symbol (nam, block, VAR_NAMESPACE, 0, (struct symtab **) NULL);
if (sym == NULL)
- {
error ("No template type named %s.", name);
- }
if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
- {
error ("This context has class, union or enum %s, not a struct.", name);
- }
return (SYMBOL_TYPE (sym));
}
/* Given a type TYPE, lookup the type of the component of type named NAME.
- TYPE can be either a struct or union, or a pointer or reference to a struct or
- union. If it is a pointer or reference, its target type is automatically used.
- Thus '.' and '->' are interchangable, as specified for the definitions of the
- expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
+ TYPE can be either a struct or union, or a pointer or reference to
+ a struct or union. If it is a pointer or reference, its target
+ type is automatically used.
+ Thus '.' and '->' are interchangable, as specified for the
+ definitions of the expression element types STRUCTOP_STRUCT and
+ STRUCTOP_PTR.
If NOERR is nonzero, return zero if NAME is not suitably defined.
If NAME is the name of a baseclass type, return that type. */
@@ -917,7 +776,7 @@ lookup_struct_elt_type (struct type *type, char *name, int noerr)
if (TYPE_CODE (type) != TYPE_CODE_PTR
&& TYPE_CODE (type) != TYPE_CODE_REF)
break;
- type = TYPE_TARGET_TYPE (type);
+ type = POINTER_TARGET_TYPE (type);
}
if (TYPE_CODE (type) != TYPE_CODE_STRUCT &&
@@ -967,9 +826,7 @@ lookup_struct_elt_type (struct type *type, char *name, int noerr)
}
if (noerr)
- {
return NULL;
- }
target_terminal_ours ();
gdb_flush (gdb_stdout);
@@ -996,7 +853,7 @@ fill_in_vptr_fieldno (struct type *type)
if (TYPE_VPTR_FIELDNO (type) < 0)
{
int i;
-
+
/* We must start at zero in case the first (and only) baseclass is
virtual (and hence we cannot share the table pointer). */
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
@@ -1064,7 +921,7 @@ check_typedef (register struct type *type)
{
if (!TYPE_TARGET_TYPE (type))
{
- char *name;
+ const char *name;
struct symbol *sym;
/* It is dangerous to call lookup_symbol if we are currently
@@ -1073,7 +930,7 @@ check_typedef (register struct type *type)
return type;
name = type_name_no_tag (type);
- /* FIXME: shouldn't we separately check the TYPE_NAME and the
+ /* TYPEFIX: shouldn't we separately check the TYPE_NAME and the
TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
as appropriate? (this code was written before TYPE_NAME and
TYPE_TAG_NAME were separate). */
@@ -1084,10 +941,12 @@ check_typedef (register struct type *type)
}
sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0,
(struct symtab **) NULL);
+
+ /* TYPEFIX */
if (sym)
TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
else
- TYPE_TARGET_TYPE (type) = alloc_type (NULL); /* TYPE_CODE_UNDEF */
+ TYPE_TARGET_TYPE (type) = alloc_type (NULL);
}
type = TYPE_TARGET_TYPE (type);
}
@@ -1097,9 +956,11 @@ check_typedef (register struct type *type)
type definition with no fields is issued for such types, instead of
identifying them as stub types in the first place */
- if (TYPE_IS_OPAQUE (type) && opaque_type_resolution && !currently_reading_symtab)
+ if (TYPE_IS_OPAQUE (type)
+ && opaque_type_resolution
+ && !currently_reading_symtab)
{
- char *name = type_name_no_tag (type);
+ const char *name = type_name_no_tag (type);
struct type *newtype;
if (name == NULL)
{
@@ -1107,6 +968,9 @@ check_typedef (register struct type *type)
return type;
}
newtype = lookup_transparent_type (name);
+
+ /* TYPEFIX -- VERY VERY VERY VERY VERY BAD IDEA. NOT VALID AT
+ ALL ANYMORE. IT WAS A SUCKY IDEA THEN, TOO.*/
if (newtype)
{
memcpy ((char *) type, (char *) newtype, sizeof (struct type));
@@ -1115,8 +979,8 @@ check_typedef (register struct type *type)
/* Otherwise, rely on the stub flag being set for opaque/stubbed types */
else if ((TYPE_FLAGS (type) & TYPE_FLAG_STUB) && !currently_reading_symtab)
{
- char *name = type_name_no_tag (type);
- /* FIXME: shouldn't we separately check the TYPE_NAME and the
+ const char *name = type_name_no_tag (type);
+ /* TYPEFIX: shouldn't we separately check the TYPE_NAME and the
TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
as appropriate? (this code was written before TYPE_NAME and
TYPE_TAG_NAME were separate). */
@@ -1127,30 +991,33 @@ check_typedef (register struct type *type)
return type;
}
sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0, (struct symtab **) NULL);
+ /* TYPEFIX: VERY VERY VERY VERY VERY VERY VERY VERY bad */
if (sym)
- {
- memcpy ((char *) type, (char *) SYMBOL_TYPE (sym), sizeof (struct type));
- }
+ memcpy ((char *) type, (char *) SYMBOL_TYPE (sym), sizeof (struct type));
}
if (TYPE_FLAGS (type) & TYPE_FLAG_TARGET_STUB)
{
- struct type *range_type;
- struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
+ struct range_type *range_type;
+ struct type *target_type;
+ if (TYPE_CODE (type) == TYPE_CODE_SET)
+ target_type = check_typedef ((struct type *)SET_RANGE_TYPE (type));
+ else
+ target_type = check_typedef ((struct type *)ARRAY_RANGE_TYPE (type));
if (TYPE_FLAGS (target_type) & (TYPE_FLAG_STUB | TYPE_FLAG_TARGET_STUB))
{
}
else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
&& TYPE_NFIELDS (type) == 1
- && (TYPE_CODE (range_type = TYPE_FIELD_TYPE (type, 0))
+ && (TYPE_CODE (range_type = ARRAY_RANGE_TYPE (type))
== TYPE_CODE_RANGE))
{
/* Now recompute the length of the array type, based on its
number of elements and the target type's length. */
TYPE_LENGTH (type) =
- ((TYPE_FIELD_BITPOS (range_type, 1)
- - TYPE_FIELD_BITPOS (range_type, 0)
+ ((RANGE_UPPER_BOUND (range_type)
+ - RANGE_LOWER_BOUND (range_type)
+ 1)
* TYPE_LENGTH (target_type));
TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB;
@@ -1171,7 +1038,7 @@ check_typedef (register struct type *type)
#define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; }
static void
-add_name (struct extra *pextras, char *n)
+add_name (struct extra *pextras, const char *n)
{
int nlen;
@@ -1186,7 +1053,7 @@ add_mangled_type (struct extra *pextras, struct type *t)
{
enum type_code tcode;
int tlen, tflags;
- char *tname;
+ const char *tname;
tcode = TYPE_CODE (t);
tlen = TYPE_LENGTH (t);
@@ -1210,7 +1077,8 @@ add_mangled_type (struct extra *pextras, struct type *t)
case 4:
{
char *pname;
- if ((pname = strrchr (tname, 'l'), pname) && !strcmp (pname, "long"))
+ if ((pname = strrchr (tname, 'l'), pname)
+ && !strcmp (pname, "long"))
{
ADD_EXTRA ('l');
}
@@ -1222,12 +1090,10 @@ add_mangled_type (struct extra *pextras, struct type *t)
break;
default:
{
-
- static struct complaint msg =
- {"Bad int type code length x%x\n", 0, 0};
+ static struct complaint msg =
+ {"Bad int type code length x%x\n", 0, 0};
complain (&msg, tlen);
-
}
}
break;
@@ -1262,7 +1128,7 @@ add_mangled_type (struct extra *pextras, struct type *t)
case TYPE_CODE_TYPEDEF:
{
static struct complaint msg =
- {"Typedefs in overloaded functions not yet supported\n", 0, 0};
+ {"Typedefs in overloaded functions not yet supported\n", 0, 0};
complain (&msg);
}
/* followed by type bytes & name */
@@ -1286,7 +1152,6 @@ add_mangled_type (struct extra *pextras, struct type *t)
/* followed by name of type */
add_name (pextras, tname);
break;
-
/* errors possible types/not supported */
case TYPE_CODE_CHAR:
case TYPE_CODE_ARRAY: /* Array type */
@@ -1301,64 +1166,14 @@ add_mangled_type (struct extra *pextras, struct type *t)
case TYPE_CODE_ERROR:
default:
{
- static struct complaint msg =
- {"Unknown type code x%x\n", 0, 0};
+ static struct complaint msg = {"Unknown type code x%x\n", 0, 0};
complain (&msg, tcode);
}
}
- if (t->target_type)
- add_mangled_type (pextras, t->target_type);
+ if (TYPE_TARGET_TYPE(t))
+ add_mangled_type (pextras, TYPE_TARGET_TYPE(t));
}
-#if 0
-void
-cfront_mangle_name (struct type *type, int i, int j)
-{
- struct fn_field *f;
- char *mangled_name = gdb_mangle_name (type, i, j);
-
- f = TYPE_FN_FIELDLIST1 (type, i); /* moved from below */
-
- /* kludge to support cfront methods - gdb expects to find "F" for
- ARM_mangled names, so when we mangle, we have to add it here */
- if (ARM_DEMANGLING)
- {
- int k;
- char *arm_mangled_name;
- struct fn_field *method = &f[j];
- char *field_name = TYPE_FN_FIELDLIST_NAME (type, i);
- char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
- char *newname = type_name_no_tag (type);
-
- struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
- int nargs = TYPE_NFIELDS (ftype); /* number of args */
- struct extra extras, *pextras = &extras;
- INIT_EXTRA
-
- if (TYPE_FN_FIELD_STATIC_P (f, j)) /* j for sublist within this list */
- ADD_EXTRA ('S')
- ADD_EXTRA ('F')
- /* add args here! */
- if (nargs <= 1) /* no args besides this */
- ADD_EXTRA ('v')
- else
- {
- for (k = 1; k < nargs; k++)
- {
- struct type *t;
- t = TYPE_FIELD_TYPE (ftype, k);
- add_mangled_type (pextras, t);
- }
- }
- ADD_EXTRA ('\0')
- printf ("add_mangled_type: %s\n", extras.str); /* FIXME */
- xasprintf (&arm_mangled_name, "%s%s", mangled_name, extras.str);
- xfree (mangled_name);
- mangled_name = arm_mangled_name;
- }
-}
-#endif /* 0 */
-
#undef ADD_EXTRA
/* End of new code added to support parsing of Cfront stabs strings */
@@ -1378,7 +1193,7 @@ safe_parse_type (char *p, int length)
/* Call parse_and_eval_type() without fear of longjmp()s. */
if (!gdb_parse_and_eval_type (p, length, &type))
type = builtin_type_void;
-
+
/* Stop suppressing error messages. */
ui_file_delete (gdb_stderr);
gdb_stderr = saved_gdb_stderr;
@@ -1387,7 +1202,7 @@ safe_parse_type (char *p, int length)
}
/* Ugly hack to convert method stubs into method types.
-
+
He ain't kiddin'. This demangles the name of the method into a string
including argument types, parses out each argument type, generates
a string casting a zero to that type, evaluates the string, and stuffs
@@ -1413,28 +1228,22 @@ check_stub_method (struct type *type, int method_id, int signature_id)
p = strchr (demangled_name, '(');
else
p = NULL;
-
+
if (demangled_name == NULL || p == NULL)
error ("Internal: Cannot demangle mangled name `%s'.", mangled_name);
-
+
/* Now, read in the parameters that define this type. */
p += 1;
argtypetext = p;
while (*p)
{
if (*p == '(' || *p == '<')
- {
- depth += 1;
- }
+ depth += 1;
else if (*p == ')' || *p == '>')
- {
- depth -= 1;
- }
+ depth -= 1;
else if (*p == ',' && depth == 0)
- {
- argcount += 1;
- }
-
+ argcount += 1;
+
p += 1;
}
@@ -1444,7 +1253,7 @@ check_stub_method (struct type *type, int method_id, int signature_id)
argtypes = (struct type **)
TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *));
p = argtypetext;
- /* FIXME: This is wrong for static member functions. */
+ /* TYPEFIX: This is wrong for static member functions. */
argtypes[0] = lookup_pointer_type (type);
argcount = 1;
@@ -1466,33 +1275,25 @@ check_stub_method (struct type *type, int method_id, int signature_id)
}
if (*p == '(' || *p == '<')
- {
- depth += 1;
- }
+ depth += 1;
else if (*p == ')' || *p == '>')
- {
- depth -= 1;
- }
+ depth -= 1;
p += 1;
}
}
if (p[-2] != '.') /* Not '...' */
- {
- argtypes[argcount] = builtin_type_void; /* List terminator */
- }
+ argtypes[argcount] = builtin_type_void; /* List terminator */
else
- {
- argtypes[argcount] = NULL; /* Ellist terminator */
- }
+ argtypes[argcount] = NULL; /* Ellist terminator */
xfree (demangled_name);
f = TYPE_FN_FIELDLIST1 (type, method_id);
TYPE_FN_FIELD_PHYSNAME (f, signature_id) = mangled_name;
-
+
/* Now update the old "stub" type into a real type. */
mtype = TYPE_FN_FIELD_TYPE (f, signature_id);
TYPE_DOMAIN_TYPE (mtype) = type;
@@ -1501,6 +1302,19 @@ check_stub_method (struct type *type, int method_id, int signature_id)
TYPE_FN_FIELD_STUB (f, signature_id) = 0;
}
+const struct fortran_struct_type fortran_struct_default;
+
+void
+allocate_fortran_struct_type (struct type *type)
+{
+ if (!HAVE_FORTRAN_STRUCT (type))
+ {
+ TYPE_FORTRAN_SPECIFIC (type) = (struct fortran_struct_type *)
+ TYPE_ALLOC (type, sizeof (struct fortran_struct_type));
+ *(TYPE_FORTRAN_SPECIFIC (type)) = fortran_struct_default;
+ }
+}
+
const struct cplus_struct_type cplus_struct_default;
void
@@ -1511,11 +1325,12 @@ allocate_cplus_struct_type (struct type *type)
TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
TYPE_ALLOC (type, sizeof (struct cplus_struct_type));
*(TYPE_CPLUS_SPECIFIC (type)) = cplus_struct_default;
+ TYPE_VPTR_FIELDNO (type) = -1;
}
}
/* Helper function to initialize the standard scalar types.
-
+
If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
of the string pointed to by name in the type_obstack for that objfile,
and initialize the type name to that copy. There are places (mipsread.c
@@ -1532,21 +1347,17 @@ init_type (enum type_code code, int length, int flags, char *name,
TYPE_LENGTH (type) = length;
TYPE_FLAGS (type) |= flags;
if ((name != NULL) && (objfile != NULL))
- {
- TYPE_NAME (type) =
- obsavestring (name, strlen (name), &objfile->type_obstack);
- }
+ TYPE_NAME (type) = obsavestring (name, strlen (name),
+ &objfile->type_obstack);
else
- {
- TYPE_NAME (type) = name;
- }
-
+ TYPE_NAME (type) = name;
+
/* C++ fancies. */
- if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
- {
- INIT_CPLUS_SPECIFIC (type);
- }
+ if (code == TYPE_CODE_ARRAY
+ && current_language->la_language == language_fortran)
+ INIT_FORTRAN_SPECIFIC (type);
+
return (type);
}
@@ -1578,9 +1389,7 @@ lookup_fundamental_type (struct objfile *objfile, int typeid)
register int nbytes;
if (typeid < 0 || typeid >= FT_NUM_MEMBERS)
- {
- error ("internal error - invalid fundamental type id %d", typeid);
- }
+ error ("internal error - invalid fundamental type id %d", typeid);
/* If this is the first time we need a fundamental type for this objfile
then we need to initialize the vector of type pointers. */
@@ -1599,22 +1408,19 @@ lookup_fundamental_type (struct objfile *objfile, int typeid)
typep = objfile->fundamental_types + typeid;
if (*typep == NULL)
- {
*typep = create_fundamental_type (objfile, typeid);
- }
return (*typep);
}
-
+/* Returns true for references and pointers */
int
can_dereference (struct type *t)
{
- /* FIXME: Should we return true for references as well as pointers? */
CHECK_TYPEDEF (t);
return
(t != NULL
- && TYPE_CODE (t) == TYPE_CODE_PTR
- && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID);
+ && (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
+ && TYPE_CODE (POINTER_TARGET_TYPE (t)) != TYPE_CODE_VOID);
}
int
@@ -1665,7 +1471,7 @@ is_ancestor (struct type *base, struct type *dclass)
if (TYPE_NAME (base) && TYPE_NAME (dclass) &&
!strcmp (TYPE_NAME (base), TYPE_NAME (dclass)))
return 1;
-
+
for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
if (is_ancestor (base, TYPE_BASECLASS (dclass, i)))
return 1;
@@ -1823,14 +1629,19 @@ virtual_base_list (struct type *dclass)
current_vbase_list = NULL;
virtual_base_list_aux (dclass);
- for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next)
+ for (i = 0, tmp_vbase = current_vbase_list;
+ tmp_vbase != NULL;
+ i++, tmp_vbase = tmp_vbase->next)
/* no body */ ;
count = i;
- vbase_array = (struct type **) xmalloc ((count + 1) * sizeof (struct type *));
+ vbase_array = (struct type **)
+ xmalloc ((count + 1) * sizeof (struct type *));
- for (i = count - 1, tmp_vbase = current_vbase_list; i >= 0; i--, tmp_vbase = tmp_vbase->next)
+ for (i = count - 1, tmp_vbase = current_vbase_list;
+ i >= 0;
+ i--, tmp_vbase = tmp_vbase->next)
vbase_array[i] = tmp_vbase->vbasetype;
/* Get rid of constructed chain */
@@ -1857,7 +1668,9 @@ virtual_base_list_length (struct type *dclass)
current_vbase_list = NULL;
virtual_base_list_aux (dclass);
- for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next)
+ for (i = 0, tmp_vbase = current_vbase_list;
+ tmp_vbase != NULL;
+ i++, tmp_vbase = tmp_vbase->next)
/* no body */ ;
return i;
}
@@ -1881,7 +1694,9 @@ virtual_base_list_length_skip_primaries (struct type *dclass)
current_vbase_list = NULL;
virtual_base_list_aux (dclass);
- for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; tmp_vbase = tmp_vbase->next)
+ for (i = 0, tmp_vbase = current_vbase_list;
+ tmp_vbase != NULL;
+ tmp_vbase = tmp_vbase->next)
{
if (virtual_base_index (tmp_vbase->vbasetype, primary) >= 0)
continue;
@@ -1943,7 +1758,8 @@ virtual_base_index_skip_primaries (struct type *base, struct type *dclass)
vbase = virtual_base_list (dclass)[0];
while (vbase)
{
- if (!primary || (virtual_base_index_skip_primaries (vbase, primary) < 0))
+ if (!primary
+ || (virtual_base_index_skip_primaries (vbase, primary) < 0))
j++;
if (vbase == base)
break;
@@ -2033,20 +1849,16 @@ compare_badness (struct badness_vector *a, struct badness_vector *b)
}
if (found_pos)
- {
- if (found_neg)
- return 1; /* incomparable */
- else
- return 3; /* A > B */
- }
+ if (found_neg)
+ return 1; /* incomparable */
+ else
+ return 3; /* A > B */
else
/* no positives */
- {
- if (found_neg)
- return 2; /* A < B */
- else
- return 0; /* A == B */
- }
+ if (found_neg)
+ return 2; /* A < B */
+ else
+ return 0; /* A == B */
}
/* Rank a function by comparing its parameter types (PARMS, length NPARMS),
@@ -2146,14 +1958,14 @@ rank_one_type (struct type *parm, struct type *arg)
switch (TYPE_CODE (arg))
{
case TYPE_CODE_PTR:
- if (TYPE_CODE (TYPE_TARGET_TYPE (parm)) == TYPE_CODE_VOID)
+ if (TYPE_CODE (POINTER_TARGET_TYPE (parm)) == TYPE_CODE_VOID)
return VOID_PTR_CONVERSION_BADNESS;
else
- return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
+ return rank_one_type (POINTER_TARGET_TYPE (parm), POINTER_TARGET_TYPE (arg));
case TYPE_CODE_ARRAY:
- return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
+ return rank_one_type (POINTER_TARGET_TYPE (parm), ARRAY_ELEMENT_TYPE (arg));
case TYPE_CODE_FUNC:
- return rank_one_type (TYPE_TARGET_TYPE (parm), arg);
+ return rank_one_type (POINTER_TARGET_TYPE (parm), arg);
case TYPE_CODE_INT:
case TYPE_CODE_ENUM:
case TYPE_CODE_CHAR:
@@ -2167,8 +1979,9 @@ rank_one_type (struct type *parm, struct type *arg)
switch (TYPE_CODE (arg))
{
case TYPE_CODE_PTR:
+ return rank_one_type (ARRAY_ELEMENT_TYPE (parm), POINTER_TARGET_TYPE (arg));
case TYPE_CODE_ARRAY:
- return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
+ return rank_one_type (ARRAY_ELEMENT_TYPE (parm), ARRAY_ELEMENT_TYPE (arg));
default:
return INCOMPATIBLE_TYPE_BADNESS;
}
@@ -2176,7 +1989,7 @@ rank_one_type (struct type *parm, struct type *arg)
switch (TYPE_CODE (arg))
{
case TYPE_CODE_PTR: /* funcptr -> func */
- return rank_one_type (parm, TYPE_TARGET_TYPE (arg));
+ return rank_one_type (parm, POINTER_TARGET_TYPE (arg));
default:
return INCOMPATIBLE_TYPE_BADNESS;
}
@@ -2366,6 +2179,9 @@ rank_one_type (struct type *parm, struct type *arg)
switch (TYPE_CODE (arg))
{
case TYPE_CODE_STRUCT:
+ /* If they have the same name, and are different, it's a violation of the ODR. */
+ if (!strcmp (TYPE_TAG_NAME (arg), TYPE_TAG_NAME (parm)))
+ return 0;
/* Check for derivation */
if (is_ancestor (parm, arg))
return BASE_CONVERSION_BADNESS;
@@ -2378,6 +2194,9 @@ rank_one_type (struct type *parm, struct type *arg)
switch (TYPE_CODE (arg))
{
case TYPE_CODE_UNION:
+ /* If they have the same name, and are different, it's a violation of the ODR. */
+ if (!strcmp (TYPE_NAME (arg), TYPE_NAME (parm)))
+ return 0;
default:
return INCOMPATIBLE_TYPE_BADNESS;
}
@@ -2461,7 +2280,7 @@ print_arg_types (struct type **args, int spaces)
while (*args != NULL)
{
recursive_dump_type (*args, spaces + 2);
- if ((*args++)->code == TYPE_CODE_VOID)
+ if (TYPE_CODE((*args++)) == TYPE_CODE_VOID)
{
break;
}
@@ -2619,7 +2438,7 @@ recursive_dump_type (struct type *type, int spaces)
printf_filtered ("\n");
printfi_filtered (spaces, "name '%s' (",
TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>");
- gdb_print_host_address (TYPE_NAME (type), gdb_stdout);
+ gdb_print_host_address ((char *)TYPE_NAME (type), gdb_stdout);
printf_filtered (")\n");
if (TYPE_TAG_NAME (type) != NULL)
{
@@ -2700,9 +2519,11 @@ recursive_dump_type (struct type *type, int spaces)
printfi_filtered (spaces, "objfile ");
gdb_print_host_address (TYPE_OBJFILE (type), gdb_stdout);
printf_filtered ("\n");
+#if TYPEFIX
printfi_filtered (spaces, "target_type ");
gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout);
printf_filtered ("\n");
+#endif
if (TYPE_TARGET_TYPE (type) != NULL)
{
recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
@@ -2714,10 +2535,13 @@ recursive_dump_type (struct type *type, int spaces)
gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
printf_filtered ("\n");
printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type));
- if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED)
+ if (TYPE_CAN_BE_SIGNED (type))
+ {
+ if (TYPE_UNSIGNED (type))
{
- puts_filtered (" TYPE_FLAG_UNSIGNED");
+ puts_filtered (" TYPE_UNSIGNED");
}
+ }
if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
{
puts_filtered (" TYPE_FLAG_STUB");
@@ -2744,18 +2568,21 @@ recursive_dump_type (struct type *type, int spaces)
recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
}
}
- printfi_filtered (spaces, "vptr_basetype ");
- gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
- puts_filtered ("\n");
if (TYPE_VPTR_BASETYPE (type) != NULL)
- {
- recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
- }
+ {
+ printfi_filtered (spaces, "vptr_basetype ");
+ gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
+ puts_filtered ("\n");
+ recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
+ }
printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type));
switch (TYPE_CODE (type))
{
- case TYPE_CODE_METHOD:
case TYPE_CODE_FUNC:
+ break;
+
+ case TYPE_CODE_METHOD:
+
printfi_filtered (spaces, "arg_types ");
gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout);
puts_filtered ("\n");
@@ -2796,54 +2623,31 @@ build_gdbtypes (void)
0,
"void", (struct objfile *) NULL);
builtin_type_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "char", (struct objfile *) NULL);
- TYPE_FLAGS (builtin_type_char) |= TYPE_FLAG_NOSIGN;
+ (struct type *)make_integer_type (NULL, "char", TARGET_CHAR_BIT / TARGET_CHAR_BIT, ST_nosign);
builtin_type_true_char =
- init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "true character", (struct objfile *) NULL);
+ (struct type *)make_character_type (NULL, "true character", TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ ST_signed);
builtin_type_signed_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "signed char", (struct objfile *) NULL);
- builtin_type_unsigned_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned char", (struct objfile *) NULL);
+ (struct type *)make_character_type (NULL, "signed char", TARGET_CHAR_BIT / TARGET_CHAR_BIT, ST_signed);
+ builtin_type_unsigned_char =
+ (struct type *)make_character_type (NULL, "unsigned char", TARGET_CHAR_BIT / TARGET_CHAR_BIT, ST_unsigned);
+
builtin_type_short =
- init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- 0,
- "short", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "short", TARGET_SHORT_BIT / TARGET_CHAR_BIT, ST_signed);
builtin_type_unsigned_short =
- init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned short", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "unsigned short", TARGET_SHORT_BIT / TARGET_CHAR_BIT, ST_unsigned);
builtin_type_int =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0,
- "int", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "int", TARGET_INT_BIT / TARGET_CHAR_BIT, ST_signed);
builtin_type_unsigned_int =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned int", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "unsigned int", TARGET_INT_BIT / TARGET_CHAR_BIT, ST_unsigned);
builtin_type_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
- 0,
- "long", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "long", TARGET_LONG_BIT / TARGET_CHAR_BIT, ST_signed);
builtin_type_unsigned_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned long", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "unsigned long", TARGET_LONG_BIT / TARGET_CHAR_BIT, ST_unsigned);
builtin_type_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- 0,
- "long long", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "long long", TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, ST_signed);
builtin_type_unsigned_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned long long", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "unsigned long long", TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, ST_unsigned);
builtin_type_float =
init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
0,
@@ -2871,37 +2675,21 @@ build_gdbtypes (void)
0,
"string", (struct objfile *) NULL);
builtin_type_int8 =
- init_type (TYPE_CODE_INT, 8 / 8,
- 0,
- "int8_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "int8_t", 8 / 8, ST_signed);
builtin_type_uint8 =
- init_type (TYPE_CODE_INT, 8 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint8_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "uint8_t", 8 / 8, ST_unsigned);
builtin_type_int16 =
- init_type (TYPE_CODE_INT, 16 / 8,
- 0,
- "int16_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "int16_t", 16 / 8, ST_signed);
builtin_type_uint16 =
- init_type (TYPE_CODE_INT, 16 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint16_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "uint16_t", 16 / 8, ST_unsigned);
builtin_type_int32 =
- init_type (TYPE_CODE_INT, 32 / 8,
- 0,
- "int32_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "int32_t", 32 / 8, ST_signed);
builtin_type_uint32 =
- init_type (TYPE_CODE_INT, 32 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint32_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "uint32_t", 32 / 8, ST_unsigned);
builtin_type_int64 =
- init_type (TYPE_CODE_INT, 64 / 8,
- 0,
- "int64_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "int64_t", 64 / 8, ST_signed);
builtin_type_uint64 =
- init_type (TYPE_CODE_INT, 64 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint64_t", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "uint64_t", 64 / 8, ST_unsigned);
builtin_type_bool =
init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
0,
@@ -2929,44 +2717,17 @@ build_gdbtypes (void)
= init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2);
/* Pointer/Address types. */
-
- /* NOTE: on some targets, addresses and pointers are not necessarily
- the same --- for example, on the D10V, pointers are 16 bits long,
- but addresses are 32 bits long. See doc/gdbint.texinfo,
- ``Pointers Are Not Always Addresses''.
-
- The upshot is:
- - gdb's `struct type' always describes the target's
- representation.
- - gdb's `struct value' objects should always hold values in
- target form.
- - gdb's CORE_ADDR values are addresses in the unified virtual
- address space that the assembler and linker work with. Thus,
- since target_read_memory takes a CORE_ADDR as an argument, it
- can access any memory on the target, even if the processor has
- separate code and data address spaces.
-
- So, for example:
- - If v is a value holding a D10V code pointer, its contents are
- in target form: a big-endian address left-shifted two bits.
- - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
- sizeof (void *) == 2 on the target.
-
- In this context, builtin_type_CORE_ADDR is a bit odd: it's a
- target type for a value the target will never see. It's only
- used to hold the values of (typeless) linker symbols, which are
- indeed in the unified virtual address space. */
- builtin_type_ptr = make_pointer_type (builtin_type_void, NULL);
- builtin_type_void_func_ptr
- = lookup_pointer_type (lookup_function_type (builtin_type_void));
+ /* NOTE: At present there is no way of differentiating between at
+ target address and the target C language pointer type type even
+ though the two can be different (cf d10v) */
+ builtin_type_ptr = (struct type *)make_pointer_type (NULL, builtin_type_void);
+
builtin_type_CORE_ADDR =
- init_type (TYPE_CODE_INT, TARGET_ADDR_BIT / 8,
- TYPE_FLAG_UNSIGNED,
- "__CORE_ADDR", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "__CORE_ADDR",
+ TARGET_ADDR_BIT / 8, ST_unsigned);
builtin_type_bfd_vma =
- init_type (TYPE_CODE_INT, TARGET_BFD_VMA_BIT / 8,
- TYPE_FLAG_UNSIGNED,
- "__bfd_vma", (struct objfile *) NULL);
+ (struct type *)make_integer_type (NULL, "__bfd_vma",
+ TARGET_BFD_VMA_BIT / 8, ST_unsigned);
}
@@ -3012,11 +2773,10 @@ _initialize_gdbtypes (void)
register_gdbarch_swap (&builtin_type_v4hi, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v2si, sizeof (struct type *), NULL);
REGISTER_GDBARCH_SWAP (builtin_type_ptr);
- REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma);
register_gdbarch_swap (NULL, 0, build_gdbtypes);
-
+
add_show_from_set (
add_set_cmd ("overload", no_class, var_zinteger, (char *) &overload_debug,
"Set debugging of C++ overloading.\n\
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 981dbec4b7c..62844e91498 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -130,28 +130,9 @@ enum type_code
TYPE_CODE_TEMPLATE_ARG /* C++ template arg */
};
-
-/* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
- alias for TYPE_CODE_STRUCT. This is for DWARF, which has a distinct
- "class" attribute. Perhaps we should actually have a separate TYPE_CODE
- so that we can print "class" or "struct" depending on what the debug
- info said. It's not clear we should bother. */
-
-#define TYPE_CODE_CLASS TYPE_CODE_STRUCT
-
+#define TYPE_CODE_CLASS TYPE_CODE_STRUCT
/* Some bits for the type's flags word. */
-/* Unsigned integer type. If this is not set for a TYPE_CODE_INT, the
- type is signed (unless TYPE_FLAG_NOSIGN (below) is set). */
-
-#define TYPE_FLAG_UNSIGNED (1 << 0)
-
-/* No sign for this type. In C++, "char", "signed char", and "unsigned
- char" are distinct types; so we need an extra flag to indicate the
- absence of a sign! */
-
-#define TYPE_FLAG_NOSIGN (1 << 1)
-
/* This appears in a type's flags word if it is a stub type (e.g., if
someone referenced a type that wasn't defined in a source file
via (struct sir_not_appearing_in_this_film *)). */
@@ -203,8 +184,17 @@ enum type_code
#define TYPE_FLAG_INCOMPLETE (1 << 8)
-
-struct type
+enum sign_type
+ {
+ /* Signed integer type */
+ ST_signed,
+ /* Unsigned integer type */
+ ST_unsigned,
+ /* No sign for this type. Needed for C++, where char, unsigned char, and signed char
+ are all distinct types.*/
+ ST_nosign
+ };
+struct common_type
{
/* Code for kind of type */
@@ -216,7 +206,7 @@ struct type
This is used for printing only, except by poorly designed C++ code.
For looking up a name, look for a symbol in the VAR_NAMESPACE. */
- char *name;
+ const char *name;
/* Tag name for this type, or NULL if none. This means that the
name of the type consists of a keyword followed by the tag name.
@@ -244,17 +234,6 @@ struct type
unsigned length;
- /* FIXME, these should probably be restricted to a Fortran-specific
- field in some fashion. */
-#define BOUND_CANNOT_BE_DETERMINED 5
-#define BOUND_BY_REF_ON_STACK 4
-#define BOUND_BY_VALUE_ON_STACK 3
-#define BOUND_BY_REF_IN_REG 2
-#define BOUND_BY_VALUE_IN_REG 1
-#define BOUND_SIMPLE 0
- int upper_bound_type;
- int lower_bound_type;
-
/* Every type is now associated with a particular objfile, and the
type is allocated on the type_obstack for that objfile. One problem
however, is that there are times when gdb allocates new types while
@@ -297,12 +276,33 @@ struct type
/* Flags about this type. */
- int flags;
+ short flags;
/* Number of fields described for this type */
short nfields;
+ /* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE
+ is the base class which defined the virtual function table pointer.
+
+ For types that are pointer to member types (TYPE_CODE_MEMBER),
+ VPTR_BASETYPE is the type that this pointer is a member of.
+
+ For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate
+ type that contains the method.
+
+ Unused otherwise. */
+
+ struct type *vptr_basetype;
+
+ /* Field number of the virtual function table pointer in
+ VPTR_BASETYPE. If -1, we were unable to find the virtual
+ function table pointer in initial symbol reading, and
+ fill_in_vptr_fieldno should be called to find it if possible.
+
+ Unused if this type does not have virtual functions. */
+
+ int vptr_fieldno;
/* For structure and union types, a description of each field.
For set and pascal array types, there is one "field",
whose type is the domain type of the set or array.
@@ -368,28 +368,6 @@ struct type
}
*fields;
- /* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE
- is the base class which defined the virtual function table pointer.
-
- For types that are pointer to member types (TYPE_CODE_MEMBER),
- VPTR_BASETYPE is the type that this pointer is a member of.
-
- For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate
- type that contains the method.
-
- Unused otherwise. */
-
- struct type *vptr_basetype;
-
- /* Field number of the virtual function table pointer in
- VPTR_BASETYPE. If -1, we were unable to find the virtual
- function table pointer in initial symbol reading, and
- fill_in_vptr_fieldno should be called to find it if possible.
-
- Unused if this type does not have virtual functions. */
-
- int vptr_fieldno;
-
/* Slot to point to additional language-specific fields of this type. */
union type_specific
@@ -408,13 +386,152 @@ struct type
cplus_struct_type. */
struct cplus_struct_type *cplus_stuff;
+ struct fortran_struct_type *fortran_stuff;
}
type_specific;
};
+/* TYPEFIX: types with names will eventually be derived from a named_type struct. No decision
+ on whether named_types will also have tag names or not. */
+struct void_type
+{
+ struct common_type ctype;
+};
+#define VOID_TYPE_CAST(type) ((struct void_type *)(type))
+struct boolean_type
+{
+ struct common_type ctype;
+};
+#define BOOLEAN_TYPE_CAST(type) ((struct boolean_type *)(type))
+struct signed_type_base
+{
+ struct common_type ctype;
+ enum sign_type sign;
+};
+#define SIGNED_TYPE_CAST(type) ((struct signed_type_base *)(type))
+#define SIGNED_TYPE_SIGN(type) (SIGNED_TYPE_CAST(type)->sign)
+struct integer_type
+{
+ struct signed_type_base base;
+};
+#define INTEGER_TYPE_CAST(type) ((struct integer_type *)(type))
+struct character_type
+{
+ struct signed_type_base base;
+};
+#define CHARACTER_TYPE_CAST(type) ((struct character_type *)(type))
+
+struct range_type
+{
+ struct common_type ctype;
+ struct type *index_type;
+ int lower_bound;
+ int upper_bound;
+};
+#define RANGE_TYPE_CAST(type) ((struct range_type *)(type))
+#define RANGE_INDEX_TYPE(type) (RANGE_TYPE_CAST(type)->index_type)
+#define RANGE_LOWER_BOUND(type) (RANGE_TYPE_CAST(type)->lower_bound)
+#define RANGE_UPPER_BOUND(type) (RANGE_TYPE_CAST(type)->upper_bound)
+struct array_type
+{
+ struct common_type ctype;
+ struct type *element_type;
+ struct range_type *range_type;
+};
+#define ARRAY_TYPE_CAST(type) ((struct array_type *)(type))
+#define ARRAY_ELEMENT_TYPE(type) (ARRAY_TYPE_CAST(type)->element_type)
+#define ARRAY_RANGE_TYPE(type) (ARRAY_TYPE_CAST(type)->range_type)
+struct set_type
+{
+ struct common_type ctype;
+ struct range_type *range_type;
+};
+#define SET_TYPE_CAST(type) ((struct set_type *)(type))
+#define SET_RANGE_TYPE(type) (SET_TYPE_CAST(type)->range_type)
+
+/* DJB - 05-31-01
+ * Do pointers need to be signed, also?
+ * Do they need a length?
+ * We've always been assuming they have one length.
+ * We can change that now without breaking anything else.
+ */
+struct pointer_type
+{
+ struct common_type ctype;
+ struct type *target_type;
+};
+#define POINTER_TYPE_CAST(type) ((struct pointer_type *)(type))
+#define POINTER_TARGET_TYPE(type) (POINTER_TYPE_CAST(type)->target_type)
+#define TYPE_CAN_BE_SIGNED(type) (TYPE_CODE (type) == TYPE_CODE_INT \
+ || TYPE_CODE (type) == TYPE_CODE_CHAR \
+ || TYPE_CODE (type) == TYPE_CODE_ENUM)
+
+struct enum_pair
+{
+ const char *name;
+ int value;
+};
+struct enum_type
+{
+ struct signed_type_base base;
+ unsigned int nvalues;
+ struct enum_pair *values;
+};
+#define ENUM_TYPE_CAST(type) ((struct enum_type *)(type))
+#define ENUM_NUM_VALUES(type) (ENUM_TYPE_CAST(type)->nvalues)
+#define ENUM_VALUES(type) (ENUM_TYPE_CAST(type)->values)
+#define ENUM_VALUE_NAME(type, i) (ENUM_VALUES(type)[i].name)
+#define ENUM_VALUE_VALUE(type, i) (ENUM_VALUES(type)[i].value)
+
+
+struct argument_pair
+{
+ unsigned char position;
+ struct type *type;
+};
+
+struct function_type
+{
+ struct common_type ctype;
+ struct type *return_value;
+ unsigned char narguments;
+ struct argument_pair *arguments;
+ unsigned char is_varargs:1;
+};
+#define FUNCTION_TYPE_CAST(type) ((struct function_type *)(type))
+#define FUNCTION_RETURN_VALUE(type) (FUNCTION_TYPE_CAST(type)->return_value)
+#define FUNCTION_NUM_ARGUMENTS(type) (FUNCTION_TYPE_CAST(type)->narguments)
+#define FUNCTION_ARGUMENTS(type) (FUNCTION_TYPE_CAST(type)->arguments)
+#define FUNCTION_ARGUMENT_POS(type, i) (FUNCTION_ARGUMENTS(type)[i].position)
+#define FUNCTION_ARGUMENT_TYPE(thetype, i) (FUNCTION_ARGUMENTS(thetype)[i].type)
+#define FUNCTION_IS_VARARGS(type) (FUNCTION_TYPE_CAST(type)->is_varargs)
#define NULL_TYPE ((struct type *) 0)
-
+struct type
+{
+ struct common_type ctype;
+};
+enum bound_type
+ {
+ BT_cannot_be_determined,
+ BT_by_ref_on_stack,
+ BT_by_value_on_stack,
+ BT_by_ref_in_reg,
+ BT_by_value_in_reg,
+ BT_simple
+ };
+struct fortran_struct_type
+{
+ enum bound_type upper_bound_type;
+ enum bound_type lower_bound_type;
+};
+enum declared_type
+ {
+ DT_class,
+ DT_struct,
+ DT_union,
+ DT_template
+ };
/* C++ language-specific information for TYPE_CODE_STRUCT and TYPE_CODE_UNION
nodes. */
@@ -425,7 +542,7 @@ struct cplus_struct_type
the struct type). I think only the `type' field of such a field has
any meaning. */
- short n_baseclasses;
+ unsigned char n_baseclasses;
/* Number of methods with unique names. All overloaded methods with
the same name count only once. */
@@ -444,12 +561,7 @@ struct cplus_struct_type
but we keep track of the real declaration so we can give
the correct information on "ptype". (Note: TEMPLATE may not
belong in this list...) */
-
-#define DECLARED_TYPE_CLASS 0
-#define DECLARED_TYPE_UNION 1
-#define DECLARED_TYPE_STRUCT 2
-#define DECLARED_TYPE_TEMPLATE 3
- short declared_type; /* One of the above codes */
+ enum declared_type declared_type; /* One of the above codes */
/* For derived classes, the number of base classes is given by n_baseclasses
and virtual_field_bits is a bit vector containing one bit per base class.
@@ -583,7 +695,7 @@ struct cplus_struct_type
* is a name. "type" will typically just point to a "struct type" with
* the placeholder TYPE_CODE_TEMPLATE_ARG type.
*/
- short ntemplate_args;
+ unsigned char ntemplate_args;
struct template_arg
{
char *name;
@@ -619,7 +731,7 @@ struct cplus_struct_type
*/
struct runtime_info
{
- short has_vtable;
+ unsigned char has_vtable;
struct type *primary_base;
struct type **virtual_base_list;
}
@@ -650,6 +762,18 @@ struct badness_vector
int *rank;
};
+/* The default value of TYPE_FORTRAN_SPECIFIC(T) points to the
+ this shared static structure. */
+
+extern const struct fortran_struct_type fortran_struct_default;
+
+extern void allocate_fortran_struct_type (struct type *);
+
+#define INIT_FORTRAN_SPECIFIC(type) \
+ (TYPE_FORTRAN_SPECIFIC(type)=(struct fortran_struct_type*)&fortran_struct_default)
+#define ALLOCATE_FORTRAN_STRUCT_TYPE(type) allocate_fortran_struct_type (type)
+#define HAVE_FORTRAN_STRUCT(type) \
+ (TYPE_FORTRAN_SPECIFIC(type) != &fortran_struct_default)
/* The default value of TYPE_CPLUS_SPECIFIC(T) points to the
this shared static structure. */
@@ -661,42 +785,38 @@ extern void allocate_cplus_struct_type (struct type *);
(TYPE_CPLUS_SPECIFIC(type)=(struct cplus_struct_type*)&cplus_struct_default)
#define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
#define HAVE_CPLUS_STRUCT(type) \
- (TYPE_CPLUS_SPECIFIC(type) != &cplus_struct_default)
-
-#define TYPE_NAME(thistype) (thistype)->name
-#define TYPE_TAG_NAME(type) ((type)->tag_name)
-#define TYPE_TARGET_TYPE(thistype) (thistype)->target_type
-#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
-#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
-#define TYPE_CV_TYPE(thistype) (thistype)->cv_type
+ (TYPE_CPLUS_SPECIFIC(type) && (TYPE_CPLUS_SPECIFIC(type) != &cplus_struct_default))
+
+#define TYPE_NAME(thistype) (thistype)->ctype.name
+#define TYPE_TAG_NAME(thistype) ((thistype)->ctype.tag_name)
+#define TYPE_TARGET_TYPE(thistype) (thistype)->ctype.target_type
+#define TYPE_POINTER_TYPE(thistype) (thistype)->ctype.pointer_type
+#define TYPE_REFERENCE_TYPE(thistype) (thistype)->ctype.reference_type
+#define TYPE_CV_TYPE(thistype) (thistype)->ctype.cv_type
/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
so you only have to call check_typedef once. Since allocate_value
calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */
-#define TYPE_LENGTH(thistype) (thistype)->length
-#define TYPE_OBJFILE(thistype) (thistype)->objfile
-#define TYPE_FLAGS(thistype) (thistype)->flags
-#define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED)
-#define TYPE_NOSIGN(thistype) ((thistype)->flags & TYPE_FLAG_NOSIGN)
-#define TYPE_CONST(thistype) ((thistype)->flags & TYPE_FLAG_CONST)
-#define TYPE_VOLATILE(thistype) ((thistype)->flags & TYPE_FLAG_VOLATILE)
-#define TYPE_INCOMPLETE(thistype) ((thistype)->flags & TYPE_FLAG_INCOMPLETE)
+#define TYPE_LENGTH(thistype) (thistype)->ctype.length
+#define TYPE_OBJFILE(thistype) (thistype)->ctype.objfile
+#define TYPE_FLAGS(thistype) (thistype)->ctype.flags
+#define TYPE_UNSIGNED(thistype) (SIGNED_TYPE_SIGN (thistype) == ST_unsigned)
+#define TYPE_NOSIGN(thistype) (SIGNED_TYPE_SIGN (thistype) == ST_nosign)
+#define TYPE_CONST(thistype) (TYPE_FLAGS(thistype) & TYPE_FLAG_CONST)
+#define TYPE_VOLATILE(thistype) (TYPE_FLAGS(thistype) & TYPE_FLAG_VOLATILE)
+#define TYPE_INCOMPLETE(thistype) (TYPE_FLAGS(thistype) & TYPE_FLAG_INCOMPLETE)
/* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you wan the real
type, you need to do TYPE_CODE (check_type (this_type)). */
-#define TYPE_CODE(thistype) (thistype)->code
-#define TYPE_NFIELDS(thistype) (thistype)->nfields
-#define TYPE_FIELDS(thistype) (thistype)->fields
+#define TYPE_CODE(thistype) (thistype)->ctype.code
+#define TYPE_NFIELDS(thistype) (thistype)->ctype.nfields
+#define TYPE_FIELDS(thistype) (thistype)->ctype.fields
#define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args
#define TYPE_INSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->instantiations
-#define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
-#define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0)
-#define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1)
-
/* Moto-specific stuff for FORTRAN arrays */
-#define TYPE_ARRAY_UPPER_BOUND_TYPE(thistype) (thistype)->upper_bound_type
-#define TYPE_ARRAY_LOWER_BOUND_TYPE(thistype) (thistype)->lower_bound_type
+#define TYPE_ARRAY_UPPER_BOUND_TYPE(thistype) TYPE_FORTRAN_SPECIFIC(thistype)->upper_bound_type
+#define TYPE_ARRAY_LOWER_BOUND_TYPE(thistype) TYPE_FORTRAN_SPECIFIC(thistype)->lower_bound_type
#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
(TYPE_FIELD_BITPOS((TYPE_FIELD_TYPE((arraytype),0)),1))
@@ -706,21 +826,22 @@ extern void allocate_cplus_struct_type (struct type *);
/* C++ */
-#define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype
-#define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype
-#define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno
+#define TYPE_VPTR_BASETYPE(thistype) (thistype)->ctype.vptr_basetype
+#define TYPE_DOMAIN_TYPE(thistype) (thistype)->ctype.vptr_basetype
+#define TYPE_VPTR_FIELDNO(thistype) (thistype)->ctype.vptr_fieldno
#define TYPE_FN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fields
#define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
#define TYPE_NFN_FIELDS_TOTAL(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields_total
#define TYPE_NTEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ntemplate_args
#define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations
#define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type
-#define TYPE_TYPE_SPECIFIC(thistype) (thistype)->type_specific
-#define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types
-#define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff
-#define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type
+#define TYPE_TYPE_SPECIFIC(thistype) (thistype)->ctype.type_specific
+#define TYPE_ARG_TYPES(thistype) (thistype)->ctype.type_specific.arg_types
+#define TYPE_FORTRAN_SPECIFIC(thistype) (thistype)->ctype.type_specific.fortran_stuff
+#define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->ctype.type_specific.cplus_stuff
+#define TYPE_BASECLASS(thistype,index) (thistype)->ctype.fields[index].type
#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
-#define TYPE_BASECLASS_NAME(thistype,index) (thistype)->fields[index].name
+#define TYPE_BASECLASS_NAME(thistype,index) (thistype)->ctype.fields[index].name
#define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
#define BASETYPE_VIA_PUBLIC(thistype, index) \
((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
@@ -739,7 +860,7 @@ extern void allocate_cplus_struct_type (struct type *);
((thisfld).bitsize = -1, FIELD_PHYSNAME(thisfld) = (name))
#define SET_FIELD_PHYSADDR(thisfld, name) \
((thisfld).bitsize = -2, FIELD_PHYSADDR(thisfld) = (name))
-#define TYPE_FIELD(thistype, n) (thistype)->fields[n]
+#define TYPE_FIELD(thistype, n) (thistype)->ctype.fields[n]
#define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS(TYPE_FIELD(thistype,n))
@@ -777,8 +898,8 @@ extern void allocate_cplus_struct_type (struct type *);
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
-#define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitsize < 0)
-#define TYPE_FIELD_STATIC_HAS_ADDR(thistype, n) ((thistype)->fields[n].bitsize == -2)
+#define TYPE_FIELD_STATIC(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n)) < 0)
+#define TYPE_FIELD_STATIC_HAS_ADDR(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype, n)) == -2)
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_PHYSNAME(TYPE_FIELD(thistype, n))
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_PHYSADDR(TYPE_FIELD(thistype, n))
@@ -955,6 +1076,54 @@ extern struct type *builtin_type_f_void;
? obstack_alloc (&TYPE_OBJFILE (t) -> type_obstack, size) \
: xmalloc (size))
+/* List of types that share structures, and reasoning:
+
+Reference type, pointer type, both are struct pointer_type's.
+
+IMHO, this is okay because references and pointers *are* the same
+thing in reality, they just have slightly different semantics.
+These different semantics are handled by looking at the type code.
+Nothing else different about them, so there is no reason to make a
+reference_type struct.
+
+Not that anyone is stopping anyone from doing it.
+:)
+
+String type, array type, both are struct array_type's.
+
+TYPE_CODE_STRING in GDB has always been a type that is an array with a
+different type code. This makes sense, seeing as how a string is just
+an array of chars (or unsigned shorts, or whatever, depending on your
+character set). Thus, I see no reason to make a struct string_type,
+as it would be an exact duplicate of struct array_type.
+
+*/
+
+extern struct void_type *make_void_type (struct objfile *, const char *);
+extern struct boolean_type *make_boolean_type (struct objfile *, const char *);
+extern struct character_type *make_character_type (struct objfile *,
+ const char *,
+ unsigned int,
+ enum sign_type);
+extern struct integer_type *make_integer_type (struct objfile *, const char *,
+ unsigned int, enum sign_type);
+extern struct pointer_type *make_reference_type (struct objfile *,
+ struct type *);
+extern struct pointer_type *make_pointer_type (struct objfile *,
+ struct type *);
+extern struct array_type *make_array_type (struct objfile *,
+ struct type *, struct range_type *);
+extern struct range_type *make_range_type (struct objfile *,
+ struct type *, int, int);
+extern struct set_type *make_set_type (struct objfile *,
+ struct range_type *);
+extern struct array_type *make_string_type (struct objfile *,
+ struct range_type *);
+extern struct enum_type *make_enum_type (struct objfile *, unsigned int,
+ struct enum_pair **);
+extern struct function_type *make_function_type (struct objfile *, struct type *,
+ unsigned char, struct argument_pair **,
+ unsigned char);
extern struct type *alloc_type (struct objfile *);
extern struct type *init_type (enum type_code, int, int, char *,
@@ -962,8 +1131,6 @@ extern struct type *init_type (enum type_code, int, int, char *,
extern struct type *lookup_reference_type (struct type *);
-extern struct type *make_reference_type (struct type *, struct type **);
-
extern struct type *make_cv_type (int, int, struct type *, struct type **);
extern struct type *lookup_member_type (struct type *, struct type *);
@@ -977,33 +1144,20 @@ smash_to_member_type (struct type *, struct type *, struct type *);
extern struct type *allocate_stub_method (struct type *);
-extern char *type_name_no_tag (const struct type *);
+extern const char *type_name_no_tag (const struct type *);
extern struct type *lookup_struct_elt_type (struct type *, char *, int);
-extern struct type *make_pointer_type (struct type *, struct type **);
-
extern struct type *lookup_pointer_type (struct type *);
-extern struct type *make_function_type (struct type *, struct type **);
-
-extern struct type *lookup_function_type (struct type *);
-
-extern struct type *create_range_type (struct type *, struct type *, int,
- int);
-
-extern struct type *create_array_type (struct type *, struct type *,
- struct type *);
-
-extern struct type *create_string_type (struct type *, struct type *);
-
-extern struct type *create_set_type (struct type *, struct type *);
+//extern struct type *make_function_type (struct type *, struct type **);
+//extern struct type *lookup_function_type (struct type *);
extern int chill_varying_type (struct type *);
-extern struct type *lookup_unsigned_typename (char *);
+extern struct type *lookup_unsigned_typename (const char *);
-extern struct type *lookup_signed_typename (char *);
+extern struct type *lookup_signed_typename (const char *);
extern struct type *check_typedef (struct type *);
@@ -1011,15 +1165,15 @@ extern struct type *check_typedef (struct type *);
extern void check_stub_method (struct type *, int, int);
-extern struct type *lookup_primitive_typename (char *);
+extern struct type *lookup_primitive_typename (const char *);
extern char *gdb_mangle_name (struct type *, int, int);
extern struct type *builtin_type (char **);
-extern struct type *lookup_typename (char *, struct block *, int);
+extern struct type *lookup_typename (const char *, struct block *, int);
-extern struct type *lookup_template_type (char *, struct type *,
+extern struct type *lookup_template_type (const char *, struct type *,
struct block *);
extern struct type *lookup_fundamental_type (struct objfile *, int);
@@ -1028,8 +1182,6 @@ extern void fill_in_vptr_fieldno (struct type *);
extern int get_destructor_fn_field (struct type *, int *, int *);
-extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
-
extern int is_ancestor (struct type *, struct type *);
extern int has_vtable (struct type *);
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index 8c46219971e..b5549ef1cdf 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -74,6 +74,50 @@ gnuv2_is_operator_name (const char *name)
}
+/* Return true if the INDEXth field of TYPE is a virtual baseclass
+ pointer which is for the base class whose type is BASECLASS. */
+
+static int
+vb_match (struct type *type, int index, struct type *basetype)
+{
+ struct type *fieldtype;
+ char *name = TYPE_FIELD_NAME (type, index);
+ char *field_class_name = NULL;
+
+ if (*name != '_')
+ return 0;
+ /* gcc 2.4 uses _vb$. */
+ if (name[1] == 'v' && name[2] == 'b' && is_cplus_marker (name[3]))
+ field_class_name = name + 4;
+ /* gcc 2.5 will use __vb_. */
+ if (name[1] == '_' && name[2] == 'v' && name[3] == 'b' && name[4] == '_')
+ field_class_name = name + 5;
+
+ if (field_class_name == NULL)
+ /* This field is not a virtual base class pointer. */
+ return 0;
+
+ /* It's a virtual baseclass pointer, now we just need to find out whether
+ it is for this baseclass. */
+ fieldtype = TYPE_FIELD_TYPE (type, index);
+ if (fieldtype == NULL || TYPE_CODE (fieldtype) != TYPE_CODE_PTR)
+ /* "Can't happen". */
+ return 0;
+
+ /* What we check for is that either the types are equal (needed for
+ nameless types) or have the same name. This is ugly, and a more
+ elegant solution should be devised (which would probably just push
+ the ugliness into symbol reading unless we change the stabs format). */
+ if (POINTER_TARGET_TYPE (fieldtype) == basetype)
+ return 1;
+
+ if (TYPE_NAME (basetype) != NULL
+ && TYPE_NAME (POINTER_TARGET_TYPE (fieldtype)) != NULL
+ && STREQ (TYPE_NAME (basetype),
+ TYPE_NAME (POINTER_TARGET_TYPE (fieldtype))))
+ return 1;
+ return 0;
+}
/* Return a virtual function as a value.
ARG1 is the object which provides the virtual function
table pointer. *ARG1P is side-effected in calling this function.
@@ -111,6 +155,7 @@ gnuv2_virtual_fn_field (value_ptr * arg1p, struct fn_field * f, int j,
if (TYPE_TARGET_TYPE (context) != type1)
{
value_ptr tmp = value_cast (context, value_addr (arg1));
+ VALUE_POINTED_TO_OFFSET (tmp) = 0;
arg1 = value_ind (tmp);
type1 = check_typedef (VALUE_TYPE (arg1));
}
@@ -132,7 +177,7 @@ gnuv2_virtual_fn_field (value_ptr * arg1p, struct fn_field * f, int j,
/* With older versions of g++, the vtbl field pointed to an array
of structures. Nowadays it points directly to the structure. */
if (TYPE_CODE (VALUE_TYPE (vtbl)) == TYPE_CODE_PTR
- && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (vtbl))) == TYPE_CODE_ARRAY)
+ && TYPE_CODE (POINTER_TARGET_TYPE (VALUE_TYPE (vtbl))) == TYPE_CODE_ARRAY)
{
/* Handle the case where the vtbl field points to an
array of structures. */
@@ -306,6 +351,55 @@ gnuv2_value_rtti_type (value_ptr v, int *full, int *top, int *using_enc)
return rtti_type;
}
+/* Compute the offset of the baseclass which is
+ the INDEXth baseclass of class TYPE,
+ for value at VALADDR (in host) at ADDRESS (in target).
+ The result is the offset of the baseclass value relative
+ to (the address of)(ARG) + OFFSET.
+
+ -1 is returned on error. */
+
+int
+gnuv2_baseclass_offset (struct type *type, int index, value_ptr * arg1p,
+ char *valaddr, CORE_ADDR address, int offset)
+{
+ struct type *basetype = TYPE_BASECLASS (type, index);
+
+ if (BASETYPE_VIA_VIRTUAL (type, index))
+ {
+ /* Must hunt for the pointer to this virtual baseclass. */
+ register int i, len = TYPE_NFIELDS (type);
+ register int n_baseclasses = TYPE_N_BASECLASSES (type);
+
+ /* First look for the virtual baseclass pointer
+ in the fields. */
+ for (i = n_baseclasses; i < len; i++)
+ {
+ if (vb_match (type, i, basetype))
+ {
+ CORE_ADDR addr = unpack_pointer (TYPE_FIELD_TYPE (type, i),
+ valaddr +
+ (TYPE_FIELD_BITPOS (type, i) /
+ 8));
+
+ return addr - (LONGEST) address;
+ }
+ }
+ /* Not in the fields, so try looking through the baseclasses. */
+ for (i = index + 1; i < n_baseclasses; i++)
+ {
+ int boffset =
+ gnuv2_baseclass_offset (type, i, arg1p, valaddr, address, offset);
+ if (boffset)
+ return boffset;
+ }
+ /* Not found. */
+ return -1;
+ }
+
+ /* Baseclass is easily computed. */
+ return TYPE_BASECLASS_BITPOS (type, index) / 8;
+}
static void
init_gnuv2_ops (void)
@@ -318,7 +412,8 @@ init_gnuv2_ops (void)
gnu_v2_abi_ops.is_vtable_name = gnuv2_is_vtable_name;
gnu_v2_abi_ops.is_operator_name = gnuv2_is_operator_name;
gnu_v2_abi_ops.virtual_fn_field = gnuv2_virtual_fn_field;
- gnu_v2_abi_ops.rtti_type = gnuv2_value_rtti_type;
+ gnu_v2_abi_ops.rtti_type = 0; /* Don't use this, it's too broken */
+ gnu_v2_abi_ops.baseclass_offset = gnuv2_baseclass_offset;
}
void
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index d9da17c8b90..a7eb61fa212 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -127,8 +127,8 @@ build_gdb_vtable_type (struct gdbarch *arch)
/* ptrdiff_t vcall_and_vbase_offsets[0]; */
FIELD_NAME (*field) = "vcall_and_vbase_offsets";
FIELD_TYPE (*field)
- = create_array_type (0, ptrdiff_type,
- create_range_type (0, builtin_type_int, 0, -1));
+ = (struct type *)make_array_type (NULL, ptrdiff_type,
+ make_range_type (NULL, builtin_type_int, 0, -1));
FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
@@ -150,8 +150,8 @@ build_gdb_vtable_type (struct gdbarch *arch)
/* void (*virtual_functions[0]) (); */
FIELD_NAME (*field) = "virtual_functions";
FIELD_TYPE (*field)
- = create_array_type (0, ptr_to_void_fn_type,
- create_range_type (0, builtin_type_int, 0, -1));
+ = (struct type *)make_array_type (NULL, ptr_to_void_fn_type,
+ make_range_type (NULL, builtin_type_int, 0, -1));
FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
@@ -179,6 +179,81 @@ vtable_address_point_offset ()
return (TYPE_FIELD_BITPOS (vtable_type, vtable_field_virtual_functions)
/ TARGET_CHAR_BIT);
}
+/* Since this appears to work okay, we might as well share it */
+/* Return true if the INDEXth field of TYPE is a virtual baseclass
+ pointer which is for the base class whose type is BASECLASS. */
+
+static int
+vb_match (struct type *type, int index, struct type *basetype)
+{
+ struct type *fieldtype;
+ char *name = TYPE_FIELD_NAME (type, index);
+ char *field_class_name = NULL;
+
+ if (*name != '_')
+ return 0;
+ if (strncmp (name, "_vptr.", 6) == 0)
+ field_class_name = name + 6;
+
+ if (field_class_name == NULL)
+ /* This field is not a virtual base class pointer. */
+ return 0;
+
+ /* It's a virtual baseclass pointer, now we just need to find out whether
+ it is for this baseclass. */
+ fieldtype = TYPE_FIELD_TYPE (type, index);
+ if (fieldtype == NULL || TYPE_CODE (fieldtype) != TYPE_CODE_PTR)
+ /* "Can't happen". */
+ return 0;
+
+ /* What we check for is that either the types are equal (needed for
+ nameless types) or have the same name. This is ugly, and a more
+ elegant solution should be devised (which would probably just push
+ the ugliness into symbol reading unless we change the stabs format). */
+ if (POINTER_TARGET_TYPE (fieldtype) == basetype)
+ return 1;
+
+ if (TYPE_NAME (basetype) != NULL
+ && TYPE_NAME (TYPE_TARGET_TYPE (fieldtype)) != NULL
+ && STREQ (TYPE_NAME (basetype),
+ TYPE_NAME (TYPE_TARGET_TYPE (fieldtype))))
+ return 1;
+ return 0;
+}
+
+/* Compute the offset of the baseclass which is
+ the INDEXth baseclass of class TYPE,
+ for value at VALADDR (in host) at ADDRESS (in target).
+ The result is the offset of the baseclass value relative
+ to (the address of)(ARG) + OFFSET.
+
+ -1 is returned on error. */
+
+int
+gnuv3_baseclass_offset (struct type *type, int index, value_ptr * arg1p,
+ char *valaddr, CORE_ADDR address, int offset)
+{
+ struct type *basetype = TYPE_BASECLASS (type, index);
+ CORE_ADDR coreptr;
+ struct type *pbc;
+ value_ptr testptr;
+ if (BASETYPE_VIA_VIRTUAL (type, index))
+ {
+ struct type **vbases;
+ if (arg1p)
+ offset -= VALUE_EMBEDDED_OFFSET (*arg1p);
+ vbases = virtual_base_list (type);
+
+ /* Completely wrong for non-trivial cases, i'm working on the correct way */
+ coreptr = (*((CORE_ADDR *) (valaddr)));
+ coreptr -= 12;
+ coreptr = value_as_long (value_at (builtin_type_int, coreptr, NULL));
+ return coreptr - offset;
+ }
+ /* Baseclass is easily computed. */
+ return (TYPE_BASECLASS_BITPOS (type, index) / 8) /*- offset*/ ;
+}
+
static struct type *
@@ -343,6 +418,7 @@ init_gnuv3_ops (void)
gnu_v3_abi_ops.is_operator_name = gnuv3_is_operator_name;
gnu_v3_abi_ops.rtti_type = gnuv3_rtti_type;
gnu_v3_abi_ops.virtual_fn_field = gnuv3_virtual_fn_field;
+ gnu_v3_abi_ops.baseclass_offset = gnuv3_baseclass_offset;
}
diff --git a/gdb/hpacc-abi.c b/gdb/hpacc-abi.c
index f9ec31745f3..491d38b1a4b 100644
--- a/gdb/hpacc-abi.c
+++ b/gdb/hpacc-abi.c
@@ -173,6 +173,115 @@ hpacc_virtual_fn_field (value_ptr * arg1p, struct fn_field * f, int j,
return vp;
}
+static void find_rt_vbase_offset (struct type *, struct type *, char *, int,
+ int *, int *);
+/* Return the offset (in bytes) of the virtual base of type BASETYPE
+ * in an object pointed to by VALADDR (on the host), assumed to be of
+ * type TYPE. OFFSET is number of bytes beyond start of ARG to start
+ * looking (in case VALADDR is the contents of an enclosing object).
+ *
+ * This routine recurses on the primary base of the derived class because
+ * the virtual base entries of the primary base appear before the other
+ * virtual base entries.
+ *
+ * If the virtual base is not found, a negative integer is returned.
+ * The magnitude of the negative integer is the number of entries in
+ * the virtual table to skip over (entries corresponding to various
+ * ancestral classes in the chain of primary bases).
+ *
+ */
+
+int
+hpacc_baseclass_offset (struct type *type, int index, value_ptr * arg1p,
+ char *valaddr, CORE_ADDR address, int offset)
+{
+ int skip;
+ int boffset;
+ if (arg1p != NULL)
+ find_rt_vbase_offset (type, TYPE_BASECLASS (type, index),
+ VALUE_CONTENTS_ALL (*arg1p),
+ offset + VALUE_EMBEDDED_OFFSET (*arg1p), &boffset,
+ &skip);
+ else
+ find_rt_vbase_offset (type, TYPE_BASECLASS (type, index),
+ valaddr - offset, offset, &boffset, &skip);
+
+ if (skip >= 0)
+ error ("Virtual base class offset not found in vtable");
+ return boffset;
+}
+
+static void
+find_rt_vbase_offset (struct type *type, struct type *basetype, char *valaddr,
+ int offset, int *boffset_p, int *skip_p)
+{
+ int boffset; /* offset of virtual base */
+ int index; /* displacement to use in virtual table */
+ int skip;
+
+ value_ptr vp;
+ CORE_ADDR vtbl; /* the virtual table pointer */
+ struct type *pbc; /* the primary base class */
+
+ /* Look for the virtual base recursively in the primary base, first.
+ * This is because the derived class object and its primary base
+ * subobject share the primary virtual table. */
+
+ boffset = 0;
+ pbc = TYPE_PRIMARY_BASE (type);
+ if (pbc)
+ {
+ find_rt_vbase_offset (pbc, basetype, valaddr, offset, &boffset, &skip);
+ if (skip < 0)
+ {
+ *boffset_p = boffset;
+ *skip_p = -1;
+ return;
+ }
+ }
+ else
+ skip = 0;
+
+
+ /* Find the index of the virtual base according to HP/Taligent
+ runtime spec. (Depth-first, left-to-right.) */
+ index = virtual_base_index_skip_primaries (basetype, type);
+
+ if (index < 0)
+ {
+ *skip_p = skip + virtual_base_list_length_skip_primaries (type);
+ *boffset_p = 0;
+ return;
+ }
+
+ /* pai: FIXME -- 32x64 possible problem */
+ /* First word (4 bytes) in object layout is the vtable pointer */
+ vtbl = *(CORE_ADDR *) (valaddr + offset);
+
+ /* Before the constructor is invoked, things are usually zero'd out. */
+ if (vtbl == 0)
+ error
+ ("Couldn't find virtual table -- object may not be constructed yet.");
+
+
+ /* Find virtual base's offset -- jump over entries for primary base
+ * ancestors, then use the index computed above. But also adjust by
+ * HP_ACC_VBASE_START for the vtable slots before the start of the
+ * virtual base entries. Offset is negative -- virtual base entries
+ * appear _before_ the address point of the virtual table. */
+
+ /* pai: FIXME -- 32x64 problem, if word = 8 bytes, change multiplier
+ & use long type */
+
+ /* epstein : FIXME -- added param for overlay section. May not be correct */
+ vp =
+ value_at (builtin_type_int,
+ vtbl + 4 * (-skip - index - HP_ACC_VBASE_START), NULL);
+ boffset = value_as_long (vp);
+ *skip_p = -1;
+ *boffset_p = boffset;
+ return;
+}
static struct type *
hpacc_value_rtti_type (value_ptr v, int *full, int *top, int *using_enc)
@@ -300,6 +409,8 @@ init_hpacc_ops (void)
hpacc_abi_ops.is_operator_name = hpacc_is_operator_name;
hpacc_abi_ops.virtual_fn_field = hpacc_virtual_fn_field;
hpacc_abi_ops.rtti_type = hpacc_value_rtti_type;
+ hpacc_abi_ops.baseclass_offset = hpacc_baseclass_offset;
+
}
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index cc2d0f23adc..0cba2e59207 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -1828,7 +1828,7 @@ ia64_push_arguments (int nargs, value_ptr *args, CORE_ADDR sp,
/* Special handling for function parameters */
if (len == 8
&& TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC)
+ && TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_FUNC)
{
char val_buf[8];
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 3f8572ed323..93d8c27e5de 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -42,6 +42,7 @@
#endif
#include "event-top.h"
#include "parser-defs.h"
+#include "completer.h"
/* Functions exported for general use: */
@@ -1705,7 +1706,7 @@ attach_command (char *args, int from_tty)
full_exec_path = savestring (exec_file, strlen (exec_file));
exec_file_attach (full_exec_path, from_tty);
- symbol_file_add_main (full_exec_path, from_tty);
+ symbol_file_command(full_exec_path, from_tty);
}
}
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 8b126db6523..19d763aa6bc 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -719,7 +719,7 @@ follow_exec (int pid, char *execd_pathname)
exec_file_attach (execd_pathname, 0);
/* And also is where symbols can be found. */
- symbol_file_add_main (execd_pathname, 0);
+ symbol_file_command (execd_pathname, 0);
/* Reset the shared library package. This ensures that we get
a shlib event when the child reaches "_start", at which point
diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
index 2a9b17e250d..0a96512b065 100644
--- a/gdb/jv-exp.y
+++ b/gdb/jv-exp.y
@@ -1397,7 +1397,7 @@ push_expression_name (name)
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
+ (struct type *) make_function_type (NULL, builtin_type_int, 0, NULL, 0),
builtin_type_int);
}
else if (!have_full_symbols () && !have_partial_symbols ())
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index abd0470b7d3..f1d1bf21207 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -230,7 +230,7 @@ java_class_from_object (value_ptr obj_val)
value_ptr vtable_val;
if (TYPE_CODE (VALUE_TYPE (obj_val)) == TYPE_CODE_PTR
- && TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (obj_val))) == 0)
+ && TYPE_LENGTH (POINTER_TARGET_TYPE (VALUE_TYPE (obj_val))) == 0)
obj_val = value_at (get_java_object_type (),
value_as_pointer (obj_val), NULL);
@@ -363,7 +363,7 @@ java_link_class_type (struct type *type, value_ptr clas)
{
tsuper = get_java_object_type ();
if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR)
- tsuper = TYPE_TARGET_TYPE (tsuper);
+ tsuper = POINTER_TARGET_TYPE (tsuper);
type_is_object = 1;
}
else
@@ -604,7 +604,7 @@ is_object_type (struct type *type)
CHECK_TYPEDEF (type);
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
- struct type *ttype = check_typedef (TYPE_TARGET_TYPE (type));
+ struct type *ttype = check_typedef (POINTER_TARGET_TYPE (type));
char *name;
if (TYPE_CODE (ttype) != TYPE_CODE_STRUCT)
return 0;
@@ -743,7 +743,7 @@ java_demangled_signature_copy (char *result, char *signature)
}
break;
default:
- ptr = TYPE_NAME (java_primitive_type (signature[0]));
+ ptr = (char *)TYPE_NAME (java_primitive_type (signature[0]));
i = strlen (ptr);
strcpy (result, ptr);
ptr = result + i;
@@ -788,13 +788,13 @@ java_lookup_type (char *signature)
struct type *
java_array_type (struct type *type, int dims)
{
- struct type *range_type;
+ struct range_type *range_type;
while (dims-- > 0)
{
- range_type = create_range_type (NULL, builtin_type_int, 0, 0);
- /* FIXME This is bogus! Java arrays are not gdb arrays! */
- type = create_array_type (NULL, type, range_type);
+ range_type = make_range_type (NULL, builtin_type_int, 0, 0);
+ /* TYPEFIX This is bogus! Java arrays are not gdb arrays! */
+ type = (struct type *)make_array_type (NULL, type, range_type);
}
return type;
@@ -851,7 +851,7 @@ evaluate_subexp_java (struct type *expect_type, register struct expression *exp,
{
int pc = *pos;
int i;
- char *name;
+ const char *name;
enum exp_opcode op = exp->elts[*pos].opcode;
value_ptr arg1, arg2;
struct type *type;
@@ -886,7 +886,7 @@ evaluate_subexp_java (struct type *expect_type, register struct expression *exp,
COERCE_REF (arg1);
type = check_typedef (VALUE_TYPE (arg1));
if (TYPE_CODE (type) == TYPE_CODE_PTR)
- type = check_typedef (TYPE_TARGET_TYPE (type));
+ type = check_typedef (POINTER_TARGET_TYPE (type));
name = TYPE_NAME (type);
if (name == NULL)
name = TYPE_TAG_NAME (type);
@@ -925,7 +925,7 @@ evaluate_subexp_java (struct type *expect_type, register struct expression *exp,
else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
+ return value_zero (ARRAY_ELEMENT_TYPE (type), VALUE_LVAL (arg1));
else
return value_subscript (arg1, arg2);
}
@@ -1066,7 +1066,7 @@ _initialize_java_language (void)
java_long_type = init_type (TYPE_CODE_INT, 8, 0, "long", NULL);
java_byte_type = init_type (TYPE_CODE_INT, 1, 0, "byte", NULL);
java_boolean_type = init_type (TYPE_CODE_BOOL, 1, 0, "boolean", NULL);
- java_char_type = init_type (TYPE_CODE_CHAR, 2, TYPE_FLAG_UNSIGNED, "char", NULL);
+ java_char_type = (struct type *)make_character_type (NULL, "char", 2, ST_unsigned);
java_float_type = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL);
java_double_type = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL);
java_void_type = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
diff --git a/gdb/jv-typeprint.c b/gdb/jv-typeprint.c
index c0d9ec92903..357f6ea8e5c 100644
--- a/gdb/jv-typeprint.c
+++ b/gdb/jv-typeprint.c
@@ -39,7 +39,7 @@ static void java_type_print_base (struct type * type,
static void
java_type_print_derivation_info (struct ui_file *stream, struct type *type)
{
- char *name;
+ const char *name;
int i;
int n_bases;
int prev;
@@ -115,7 +115,7 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show,
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
- java_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ java_type_print_base (POINTER_TARGET_TYPE (type), stream, show, level);
break;
case TYPE_CODE_STRUCT:
@@ -208,7 +208,7 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show,
struct fn_field *f;
int j;
char *method_name;
- char *name;
+ const char *name;
int is_constructor;
int n_overloads;
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 9ba953ee66a..5cf6b8e6280 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -70,7 +70,7 @@ java_value_print (value_ptr val, struct ui_file *stream, int format,
}
if (TYPE_CODE (type) == TYPE_CODE_PTR && !value_logical_not (val))
- type_print (TYPE_TARGET_TYPE (type), "", stream, -1);
+ type_print (POINTER_TARGET_TYPE (type), "", stream, -1);
name = TYPE_TAG_NAME (type);
if (TYPE_CODE (type) == TYPE_CODE_STRUCT && name != NULL
@@ -197,7 +197,7 @@ java_value_print (value_ptr val, struct ui_file *stream, int format,
/* If it's type String, print it */
if (TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_TARGET_TYPE (type)
+ && POINTER_TARGET_TYPE (type)
&& TYPE_NAME (TYPE_TARGET_TYPE (type))
&& strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "java.lang.String") == 0
&& (format == 0 || format == 's')
@@ -261,7 +261,7 @@ java_print_value_fields (struct type *type, char *valaddr, CORE_ADDR address,
{
int boffset;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
- char *basename = TYPE_NAME (baseclass);
+ const char *basename = TYPE_NAME (baseclass);
char *base_valaddr;
if (BASETYPE_VIA_VIRTUAL (type, i))
diff --git a/gdb/linespec.c b/gdb/linespec.c
index e23479035d3..910798fe861 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -105,7 +105,7 @@ find_methods (struct type *t, char *name, struct symbol **sym_arr)
{
int i1 = 0;
int ibase;
- char *class_name = type_name_no_tag (t);
+ const char *class_name = type_name_no_tag (t);
/* Ignore this class if it doesn't have a name. This is ugly, but
unless we figure out how to get the physname without the name of
@@ -274,9 +274,9 @@ find_toplevel_char (char *s, char c)
return scan;
else if (*scan == '"' || *scan == '\'')
quoted = *scan;
- else if (*scan == '(')
+ else if (*scan == '(' || *scan == '<')
depth++;
- else if (*scan == ')' && depth > 0)
+ else if ((*scan == ')' || *scan == '>') && depth > 0)
depth--;
}
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index eaaad5a3882..5a54d85c7e5 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -618,7 +618,8 @@ variable: NAME
{
write_exp_msymbol
(msymbol,
- lookup_function_type (builtin_type_int),
+ (struct type *) make_function_type (NULL, builtin_type_int, 0, NULL, 0),
+
builtin_type_int);
}
else if (!have_full_symbols () && !have_partial_symbols ())
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 15e36004b3b..69937018948 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -199,6 +199,7 @@ m2_printstr (struct ui_file *stream, char *string, unsigned int length,
static struct type *
m2_create_fundamental_type (struct objfile *objfile, int typeid)
{
+#if TYPEFIX
register struct type *type = NULL;
switch (typeid)
@@ -351,6 +352,9 @@ m2_create_fundamental_type (struct objfile *objfile, int typeid)
break;
}
return (type);
+#else
+ return NULL;
+#endif
}
@@ -442,6 +446,8 @@ const struct language_defn m2_language_defn =
void
_initialize_m2_language (void)
{
+#if TYPEFIX
+
/* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */
builtin_type_m2_int =
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
@@ -463,6 +469,6 @@ _initialize_m2_language (void)
init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT,
TYPE_FLAG_UNSIGNED,
"BOOLEAN", (struct objfile *) NULL);
-
add_language (&m2_language_defn);
+#endif
}
diff --git a/gdb/main.c b/gdb/main.c
index f7aa5188f39..c33c94df777 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -575,14 +575,14 @@ extern int gdbtk_test (char *);
open it, better only print one error message.
catch_command_errors returns non-zero on success! */
if (catch_command_errors (exec_file_attach, execarg, !batch, RETURN_MASK_ALL))
- catch_command_errors (symbol_file_add_main, symarg, 0, RETURN_MASK_ALL);
+ catch_command_errors (symbol_file_command, symarg, 0, RETURN_MASK_ALL);
}
else
{
if (execarg != NULL)
catch_command_errors (exec_file_attach, execarg, !batch, RETURN_MASK_ALL);
if (symarg != NULL)
- catch_command_errors (symbol_file_add_main, symarg, 0, RETURN_MASK_ALL);
+ catch_command_errors (symbol_file_command, symarg, 0, RETURN_MASK_ALL);
}
/* After the symbol file has been read, print a newline to get us
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index aab357e005e..c42b43d3168 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -834,7 +834,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
else
{
t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
- if (STREQ (name, "malloc") && t->code == TYPE_CODE_VOID)
+ if (STREQ (name, "malloc") && TYPE_CODE(t) == TYPE_CODE_VOID)
{
/* I don't know why, but, at least under Alpha GNU/Linux,
when linking against a malloc without debugging
@@ -846,7 +846,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
patch up the type and make it void*
instead. (davidm@azstarnet.com)
*/
- t = make_pointer_type (t, NULL);
+ t = (struct type *) make_pointer_type (NULL, t);
}
}
b = top_stack->cur_block;
@@ -1133,8 +1133,10 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
count++;
f++;
}
+#if TYPEFIX
if (unsigned_enum)
TYPE_FLAGS (t) |= TYPE_FLAG_UNSIGNED;
+#endif
}
/* make this the current type */
top_stack->cur_type = t;
@@ -1603,9 +1605,13 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
/* DEC c89 produces cross references to qualified aggregate types,
dereference them. */
- while (TYPE_CODE (tp) == TYPE_CODE_PTR
- || TYPE_CODE (tp) == TYPE_CODE_ARRAY)
- tp = tp->target_type;
+ while (TYPE_CODE (tp) == TYPE_CODE_PTR || TYPE_CODE (tp) == TYPE_CODE_ARRAY)
+ {
+ while (TYPE_CODE (tp) == TYPE_CODE_PTR)
+ tp = POINTER_TARGET_TYPE (tp);
+ while (TYPE_CODE (tp) == TYPE_CODE_ARRAY)
+ tp = ARRAY_ELEMENT_TYPE(tp);
+ }
/* Make sure that TYPE_CODE(tp) has an expected type code.
Any type may be returned from cross_ref if file indirect entries
@@ -1761,7 +1767,7 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend,
/* Used in array processing */
int rf, id;
FDR *fh;
- struct type *range;
+ struct range_type *range;
struct type *indx;
int lower, upper;
RNDXR rndx;
@@ -1813,10 +1819,10 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend,
ax++;
rf = AUX_GET_WIDTH (bigend, ax); /* bit size of array element */
- range = create_range_type ((struct type *) NULL, indx,
+ range = make_range_type (NULL, indx,
lower, upper);
- t = create_array_type ((struct type *) NULL, *tpp, range);
+ t = (struct type *)make_array_type (NULL, *tpp, range);
/* We used to fill in the supplied array element bitsize
here if the TYPE_LENGTH of the target type was zero.
@@ -4247,7 +4253,7 @@ fixup_sigtramp (void)
/* But what symtab does it live in ? */
st = find_pc_symtab (SYMBOL_VALUE (s));
-
+#if TYPEFIX
/*
* Ok, there goes the fix: turn it into a procedure, with all the
* needed info. Note we make it a nested procedure of sigvec,
@@ -4258,7 +4264,7 @@ fixup_sigtramp (void)
SYMBOL_TYPE (s) = init_type (TYPE_CODE_FUNC, 4, 0, (char *) NULL,
st->objfile);
TYPE_TARGET_TYPE (SYMBOL_TYPE (s)) = mdebug_type_void;
-
+#endif
/* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
b = new_block (1);
SYMBOL_BLOCK_VALUE (s) = b;
@@ -4311,6 +4317,7 @@ fixup_sigtramp (void)
void
_initialize_mdebugread (void)
{
+#if TYPEFIX
mdebug_type_void =
init_type (TYPE_CODE_VOID, 1,
0,
@@ -4423,10 +4430,10 @@ _initialize_mdebugread (void)
0, "floating decimal",
(struct objfile *) NULL);
- nodebug_func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
- "<function, no debug info>", NULL);
- TYPE_TARGET_TYPE (nodebug_func_symbol_type) = mdebug_type_int;
+ nodebug_func_symbol_type = (struct type *) make_function_type (NULL, mdebug_type_int, 0, NULL, 0, 0);
+ TYPE_NAME (nodebug_func_symbol_type) = "<function, no debug info>";
nodebug_var_symbol_type =
init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
"<variable, no debug info>", NULL);
+#endif
}
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 94817474318..0506d9b11f4 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -54,7 +54,7 @@
At the end, copy them all into one newly allocated location on an objfile's
symbol obstack. */
-#define BUNCH_SIZE 127
+#define BUNCH_SIZE 4096
struct msym_bunch
{
@@ -85,21 +85,69 @@ compact_minimal_symbols (struct minimal_symbol *, int, struct objfile *);
static void add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
struct minimal_symbol **table);
-/* Compute a hash code based using the same criteria as `strcmp_iw'. */
+/* Compute a hash code based using the same criteria as `strcmp_iw'.
+ Based on FNV-1 hash used in bcache.c.
-unsigned int
-msymbol_hash_iw (const char *string)
-{
- unsigned int hash = 0;
+ Note, we used to have a loop that, with the new hashing algorithm, would have looked like:
+
+ unsigned int hash = 0x811c9dc5;
while (*string && *string != '(')
{
while (isspace (*string))
++string;
if (*string && *string != '(')
- hash = (31 * hash) + *string;
+ {
+ hash *= 16777619;
+ hash ^= *string;
+ }
++string;
}
- return hash % MINIMAL_SYMBOL_HASH_SIZE;
+ return hash;
+}
+
+This loop is over twice as slow as the loop used in the function.
+
+The other possibility would have been
+
+ unsigned int hash = 0x811c9dc5;
+ for (*string; *string && *string != '('; ++string)
+ {
+ if (isspace (*string))
+ continue;
+ hash *= 16777619;
+ hash ^= *string;
+ }
+ return hash;
+
+This loop is 1.5 times as slow as below.
+
+All three were hand verified to give the same hash values for symbols
+with/without spaces in them, ending/not ending in parens, etc.
+
+These timings are consistent on a 500mhz G3 PPC, a 266mhz PII, and a
+500mhz PIII, and a 300mhz Ultrasparc IIi, using gcc 2.95.3 on all of
+them, so AFAIK, it's because the compiler can better optimize the loop
+below , not because of the platform I tested on.
+
+Since this function now almost completely dominates symbol lookup
+time, please be careful in changing it.
+
+*/
+
+unsigned int
+msymbol_hash_iw (const char *string)
+{
+ unsigned int hash = 0x811c9dc5;
+ unsigned int c;
+ unsigned int len = strlen(string);
+ for (c=0; c < len && string[c] != '('; c++)
+ {
+ if (isspace (string[c]))
+ continue;
+ hash *= 16777619;
+ hash ^= string[c];
+ }
+ return hash;
}
/* Compute a hash code for a string. */
@@ -107,10 +155,7 @@ msymbol_hash_iw (const char *string)
unsigned int
msymbol_hash (const char *string)
{
- unsigned int hash = 0;
- for (; *string; ++string)
- hash = (31 * hash) + *string;
- return hash % MINIMAL_SYMBOL_HASH_SIZE;
+ return hash((char *)string, strlen(string));
}
/* Add the minimal symbol SYM to an objfile's minsym hash table, TABLE. */
@@ -120,7 +165,7 @@ add_minsym_to_hash_table (struct minimal_symbol *sym,
{
if (sym->hash_next == NULL)
{
- unsigned int hash = msymbol_hash (SYMBOL_NAME (sym));
+ unsigned int hash = msymbol_hash (SYMBOL_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
sym->hash_next = table[hash];
table[hash] = sym;
}
@@ -134,7 +179,7 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
{
if (sym->demangled_hash_next == NULL)
{
- unsigned int hash = msymbol_hash_iw (SYMBOL_DEMANGLED_NAME (sym));
+ unsigned int hash = msymbol_hash_iw (SYMBOL_DEMANGLED_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
sym->demangled_hash_next = table[hash];
table[hash] = sym;
}
@@ -162,8 +207,8 @@ lookup_minimal_symbol (register const char *name, const char *sfile,
struct minimal_symbol *found_file_symbol = NULL;
struct minimal_symbol *trampoline_symbol = NULL;
- unsigned int hash = msymbol_hash (name);
- unsigned int dem_hash = msymbol_hash_iw (name);
+ unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
+ unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE;
#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (sfile != NULL)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 85762c3b4df..3a79853cc9d 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -96,7 +96,7 @@ add_to_objfile_sections (bfd *abfd, sec_ptr asect, PTR objfile_p_char)
section.ovly_mapped = 0;
section.addr = bfd_section_vma (abfd, asect);
section.endaddr = section.addr + bfd_section_size (abfd, asect);
- obstack_grow (&objfile->psymbol_obstack, (char *) &section, sizeof (section));
+ obstack_grow (&objfile->misc_obstack, (char *) &section, sizeof (section));
objfile->sections_end = (struct obj_section *) (((unsigned long) objfile->sections_end) + 1);
}
@@ -121,14 +121,17 @@ build_objfile_section_table (struct objfile *objfile)
{
/* objfile->sections can be already set when reading a mapped symbol
file. I believe that we do need to rebuild the section table in
- this case (we rebuild other things derived from the bfd), but we
- can't free the old one (it's in the psymbol_obstack). So we just
- waste some memory. */
+ this case (we rebuild other things derived from the bfd).
+ DJB - 05-27-2001
+ It's in the misc_obstack now, feel free to do what you need to.
+ All the stuff in objfile that was on the psymbol obstack, but didnt' belong, is in the misc obstack, which
+ I think is all the stuff you want to blow away anyway.
+ */
objfile->sections_end = 0;
bfd_map_over_sections (objfile->obfd, add_to_objfile_sections, (char *) objfile);
objfile->sections = (struct obj_section *)
- obstack_finish (&objfile->psymbol_obstack);
+ obstack_finish (&objfile->misc_obstack);
objfile->sections_end = objfile->sections + (unsigned long) objfile->sections_end;
return (0);
}
@@ -188,6 +191,8 @@ allocate_objfile (bfd *abfd, int flags)
/* Update pointers to functions to *our* copies */
obstack_chunkfun (&objfile->psymbol_cache.cache, xmmalloc);
obstack_freefun (&objfile->psymbol_cache.cache, mfree);
+ obstack_chunkfun (&objfile->misc_obstack, xmmalloc);
+ obstack_freefun (&objfile->misc_obstack, mfree);
obstack_chunkfun (&objfile->psymbol_obstack, xmmalloc);
obstack_freefun (&objfile->psymbol_obstack, mfree);
obstack_chunkfun (&objfile->symbol_obstack, xmmalloc);
@@ -218,6 +223,9 @@ allocate_objfile (bfd *abfd, int flags)
obstack_specify_allocation_with_arg (&objfile->psymbol_cache.cache,
0, 0, xmmalloc, mfree,
objfile->md);
+ obstack_specify_allocation_with_arg (&objfile->misc_obstack,
+ 0, 0, xmmalloc, mfree,
+ objfile->md);
obstack_specify_allocation_with_arg (&objfile->psymbol_obstack,
0, 0, xmmalloc, mfree,
objfile->md);
@@ -264,6 +272,8 @@ allocate_objfile (bfd *abfd, int flags)
objfile->md = NULL;
obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
xmalloc, xfree);
+ obstack_specify_allocation (&objfile->misc_obstack, 0, 0, xmalloc,
+ xfree);
obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc,
xfree);
obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc,
@@ -475,6 +485,7 @@ free_objfile (struct objfile *objfile)
mfree (objfile->md, objfile->static_psymbols.list);
/* Free the obstacks for non-reusable objfiles */
free_bcache (&objfile->psymbol_cache);
+ obstack_free (&objfile->misc_obstack, 0);
obstack_free (&objfile->psymbol_obstack, 0);
obstack_free (&objfile->symbol_obstack, 0);
obstack_free (&objfile->type_obstack, 0);
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index d3f669e9601..fcc521bf16d 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -202,7 +202,7 @@ extern void print_objfile_statistics (void);
extern void print_symbol_bcache_statistics (void);
/* Number of entries in the minimal symbol hash table. */
-#define MINIMAL_SYMBOL_HASH_SIZE 349
+#define MINIMAL_SYMBOL_HASH_SIZE 1024
/* Master structure for keeping track of each file from which
gdb reads symbols. There are several ways these get allocated: 1.
@@ -269,6 +269,7 @@ struct objfile
/* Obstacks to hold objects that should be freed when we load a new symbol
table from this object file. */
+ struct obstack misc_obstack; /* Misc stuff */
struct obstack psymbol_obstack; /* Partial symbols */
struct obstack symbol_obstack; /* Full symbols */
struct obstack type_obstack; /* Types */
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index d786af9f6e0..100bb1fa3d2 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -536,7 +536,8 @@ variable: qualified_name
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
+ (struct type *)make_function_type (NULL, builtin_type_int, 0, NULL, 0),
+
builtin_type_int);
}
else
@@ -592,7 +593,7 @@ variable: name_not_typename
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
+ (struct type *)make_function_type (NULL, builtin_type_int, 0, NULL, 0),
builtin_type_int);
}
else if (!have_full_symbols () && !have_partial_symbols ())
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 93dd2548f67..2c7b9fc9f02 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -212,6 +212,8 @@ pascal_printstr (struct ui_file *stream, char *string, unsigned int length,
struct type *
pascal_create_fundamental_type (struct objfile *objfile, int typeid)
{
+#if TYPEFIX
+
register struct type *type = NULL;
switch (typeid)
@@ -323,6 +325,9 @@ pascal_create_fundamental_type (struct objfile *objfile, int typeid)
break;
}
return (type);
+#else
+ return NULL;
+#endif
}
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 0facebfa9d1..73a0f2d1c79 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -75,6 +75,7 @@ pascal_print_type (struct type *type, char *varstring, struct ui_file *stream,
fputs_filtered (" : ", stream);
}
+
if (!(code == TYPE_CODE_FUNC ||
code == TYPE_CODE_METHOD))
{
@@ -117,7 +118,7 @@ pascal_print_type (struct type *type, char *varstring, struct ui_file *stream,
static void
pascal_type_print_derivation_info (struct ui_file *stream, struct type *type)
{
- char *name;
+ const char *name;
int i;
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
@@ -193,7 +194,7 @@ void
pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
int show, int passed_a_ptr)
{
- char *name;
+ const char *name;
if (type == 0)
return;
@@ -206,7 +207,7 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
{
case TYPE_CODE_PTR:
fprintf_filtered (stream, "^");
- pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
+ pascal_type_print_varspec_prefix (POINTER_TARGET_TYPE (type), stream, 0, 1);
break; /* pointer should be handled normally in pascal */
case TYPE_CODE_MEMBER:
@@ -251,7 +252,7 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
if (passed_a_ptr)
fprintf_filtered (stream, "(");
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+ if (TYPE_CODE (FUNCTION_RETURN_VALUE (type)) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, "function ");
}
@@ -263,16 +264,17 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
break;
case TYPE_CODE_ARRAY:
+#if TYPEFIX
if (passed_a_ptr)
fprintf_filtered (stream, "(");
fprintf_filtered (stream, "array ");
- if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
- && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
+ if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (ARRAY_ELEMENT_TYPE (type)) > 0)
fprintf_filtered (stream, "[%d..%d] ",
TYPE_ARRAY_LOWER_BOUND_VALUE (type),
TYPE_ARRAY_UPPER_BOUND_VALUE (type)
);
fprintf_filtered (stream, "of ");
+#endif
break;
case TYPE_CODE_UNDEF:
@@ -312,7 +314,7 @@ pascal_type_print_args (struct type *type, struct ui_file *stream)
args = TYPE_ARG_TYPES (type);
if (args != NULL)
{
- if ((args[1] != NULL && args[1]->code != TYPE_CODE_VOID) ||
+ if ((args[1] != NULL && TYPE_CODE(args[1]) != TYPE_CODE_VOID) ||
(args[2] != NULL))
{
fprintf_filtered (stream, "(");
@@ -324,7 +326,7 @@ pascal_type_print_args (struct type *type, struct ui_file *stream)
else
{
for (i = 1;
- args[i] != NULL && args[i]->code != TYPE_CODE_VOID;
+ args[i] != NULL && TYPE_CODE(args[i]) != TYPE_CODE_VOID;
i++)
{
pascal_print_type (args[i], "", stream, -1, 0);
@@ -332,14 +334,14 @@ pascal_type_print_args (struct type *type, struct ui_file *stream)
{
fprintf_filtered (stream, "...");
}
- else if (args[i + 1]->code != TYPE_CODE_VOID)
+ else if (TYPE_CODE(args[i + 1]) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ",");
wrap_here (" ");
}
}
}
- if ((args[1] != NULL && args[1]->code != TYPE_CODE_VOID) ||
+ if ((args[1] != NULL && TYPE_CODE(args[1]) != TYPE_CODE_VOID) ||
(args[2] != NULL))
{
fprintf_filtered (stream, ")");
@@ -425,7 +427,7 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
- pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
+ pascal_type_print_varspec_suffix (POINTER_TARGET_TYPE (type), stream, 0, 1, 0);
break;
case TYPE_CODE_FUNC:
@@ -433,12 +435,12 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
fprintf_filtered (stream, ")");
if (!demangled_args)
pascal_print_func_args (type, stream);
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+ if (TYPE_CODE (FUNCTION_RETURN_VALUE (type)) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, " : ");
- pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
- pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0);
- pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+ pascal_type_print_varspec_prefix (FUNCTION_RETURN_VALUE (type), stream, 0, 0);
+ pascal_type_print_base (FUNCTION_RETURN_VALUE (type), stream, show, 0);
+ pascal_type_print_varspec_suffix (FUNCTION_RETURN_VALUE (type), stream, 0,
passed_a_ptr, 0);
}
break;
@@ -507,7 +509,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
}
/* void pointer */
- if ((TYPE_CODE (type) == TYPE_CODE_PTR) && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID))
+ if ((TYPE_CODE (type) == TYPE_CODE_PTR) && (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_VOID))
{
fprintf_filtered (stream,
TYPE_NAME (type) ? TYPE_NAME (type) : "pointer");
@@ -527,10 +529,12 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
switch (TYPE_CODE (type))
{
- case TYPE_CODE_TYPEDEF:
+ case TYPE_CODE_REF:
case TYPE_CODE_PTR:
+ pascal_type_print_base (POINTER_TARGET_TYPE (type), stream, show, level);
+ break;
+ case TYPE_CODE_TYPEDEF:
case TYPE_CODE_MEMBER:
- case TYPE_CODE_REF:
/* case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD: */
pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
@@ -540,7 +544,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
/* pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0); */
- pascal_print_type (TYPE_TARGET_TYPE (type), NULL, stream, 0, 0);
+ pascal_print_type (ARRAY_ELEMENT_TYPE (type), NULL, stream, 0, 0);
break;
case TYPE_CODE_FUNC:
@@ -678,7 +682,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
- char *name = type_name_no_tag (type);
+ const char *name = type_name_no_tag (type);
/* this is GNU C++ specific
how can we know constructor/destructor?
It might work for GNU pascal */
@@ -787,7 +791,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
{
fprintf_filtered (stream, "(");
- len = TYPE_NFIELDS (type);
+ len = ENUM_NUM_VALUES (type);
lastval = 0;
for (i = 0; i < len; i++)
{
@@ -795,11 +799,11 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- if (lastval != TYPE_FIELD_BITPOS (type, i))
+ fputs_filtered (ENUM_VALUE_NAME (type, i), stream);
+ if (lastval != ENUM_VALUE_VALUE (type, i))
{
- fprintf_filtered (stream, " := %d", TYPE_FIELD_BITPOS (type, i));
- lastval = TYPE_FIELD_BITPOS (type, i);
+ fprintf_filtered (stream, " := %d", ENUM_VALUE_VALUE (type, i));
+ lastval = ENUM_VALUE_VALUE (type, i);
}
lastval++;
}
@@ -822,21 +826,19 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
/* this probably does not work for enums */
case TYPE_CODE_RANGE:
{
- struct type *target = TYPE_TARGET_TYPE (type);
+ struct type *target = RANGE_INDEX_TYPE (type);
if (target == NULL)
target = builtin_type_long;
- print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
+ print_type_scalar (target, RANGE_LOWER_BOUND (type), stream);
fputs_filtered ("..", stream);
- print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
+ print_type_scalar (target, RANGE_UPPER_BOUND (type), stream);
}
break;
-
case TYPE_CODE_SET:
fputs_filtered ("set of ", stream);
- pascal_print_type (TYPE_INDEX_TYPE (type), "", stream,
+ pascal_print_type ((struct type *)SET_RANGE_TYPE (type), "", stream,
show - 1, level);
break;
-
default:
/* Handle types not explicitly handled by the other cases,
such as fundamental types. For these, just print whatever
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 275427b455c..53a45745c72 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -36,6 +36,7 @@
#include "target.h"
#include "annotate.h"
#include "p-lang.h"
+#include "cp-abi.h"
@@ -70,9 +71,9 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (ARRAY_ELEMENT_TYPE (type)) > 0)
{
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (ARRAY_ELEMENT_TYPE (type));
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
if (prettyprint_arrays)
@@ -142,7 +143,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
stream, demangle);
break;
}
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_METHOD)
{
pascal_object_print_class_method (valaddr + embedded_offset, type, stream);
@@ -157,7 +158,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
{
addr = unpack_pointer (type, valaddr + embedded_offset);
print_unpacked_pointer:
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
@@ -257,7 +258,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
break;
case TYPE_CODE_REF:
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ elttype = check_typedef (POINTER_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
{
pascal_object_print_class_member (valaddr + embedded_offset,
@@ -281,7 +282,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
{
value_ptr deref_val =
value_at
- (TYPE_TARGET_TYPE (type),
+ (POINTER_TARGET_TYPE (type),
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset),
NULL);
@@ -309,8 +310,8 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
/* Print vtable entry - we only get here if NOT using
-fvtable_thunks. (Otherwise, look under TYPE_CODE_PTR.) */
print_address_demangle (extract_address (
- valaddr + embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8,
- TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET))),
+ valaddr + embedded_offset + TYPE_FIELD_BITPOS (type, 2) / 8,
+ TYPE_LENGTH (TYPE_FIELD_TYPE (type, 2))),
stream, demangle);
}
else
@@ -334,19 +335,19 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
break;
}
- len = TYPE_NFIELDS (type);
+ len = ENUM_NUM_VALUES (type);
val = unpack_long (type, valaddr + embedded_offset);
for (i = 0; i < len; i++)
{
QUIT;
- if (val == TYPE_FIELD_BITPOS (type, i))
+ if (val == ENUM_VALUE_VALUE (type, i))
{
break;
}
}
if (i < len)
{
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+ fputs_filtered (ENUM_VALUE_NAME (type, i), stream);
}
else
{
@@ -438,10 +439,9 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
print_floating (valaddr + embedded_offset, type, stream);
}
break;
-
case TYPE_CODE_BITSTRING:
case TYPE_CODE_SET:
- elttype = TYPE_INDEX_TYPE (type);
+ elttype = (struct type *)SET_RANGE_TYPE (type);
CHECK_TYPEDEF (elttype);
if (TYPE_FLAGS (elttype) & TYPE_FLAG_STUB)
{
@@ -451,7 +451,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
}
else
{
- struct type *range = elttype;
+ struct range_type *range = (struct range_type *)elttype;
LONGEST low_bound, high_bound;
int i;
int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING;
@@ -462,7 +462,9 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
else
fputs_filtered ("[", stream);
- i = get_discrete_bounds (range, &low_bound, &high_bound);
+ low_bound = RANGE_LOWER_BOUND (range);
+ high_bound = RANGE_UPPER_BOUND (range);
+ i = (low_bound < 0 || high_bound < 0) ? -1 : 0;
maybe_bad_bstring:
if (i < 0)
{
@@ -484,7 +486,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
{
if (need_comma)
fputs_filtered (", ", stream);
- print_type_scalar (range, i, stream);
+ print_type_scalar ((struct type *)range, i, stream);
need_comma = 1;
if (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i))
@@ -494,7 +496,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
while (i + 1 <= high_bound
&& value_bit_index (type, valaddr + embedded_offset, ++i))
j = i;
- print_type_scalar (range, j, stream);
+ print_type_scalar ((struct type *)range, j, stream);
}
}
}
@@ -505,7 +507,6 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
fputs_filtered ("]", stream);
}
break;
-
case TYPE_CODE_VOID:
fprintf_filtered (stream, "void");
break;
@@ -547,8 +548,8 @@ pascal_value_print (value_ptr val, struct ui_file *stream, int format,
type is indicated by the quoted string anyway. */
if (TYPE_CODE (type) == TYPE_CODE_PTR &&
TYPE_NAME (type) == NULL &&
- TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL &&
- STREQ (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char"))
+ TYPE_NAME (POINTER_TARGET_TYPE (type)) != NULL &&
+ STREQ (TYPE_NAME (POINTER_TARGET_TYPE (type)), "char"))
{
/* Print nothing */
}
@@ -691,7 +692,7 @@ const char pascal_vtbl_ptr_name[] =
int
pascal_object_is_vtbl_ptr_type (struct type *type)
{
- char *typename = type_name_no_tag (type);
+ const char *typename = type_name_no_tag (type);
return (typename != NULL
&& (STREQ (typename, pascal_vtbl_ptr_name)));
@@ -705,10 +706,10 @@ pascal_object_is_vtbl_member (struct type *type)
{
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
- type = TYPE_TARGET_TYPE (type);
+ type = POINTER_TARGET_TYPE (type);
if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
- type = TYPE_TARGET_TYPE (type);
+ type = ARRAY_ELEMENT_TYPE (type);
if (TYPE_CODE (type) == TYPE_CODE_STRUCT /* if not using thunks */
|| TYPE_CODE (type) == TYPE_CODE_PTR) /* if using thunks */
{
@@ -929,7 +930,7 @@ pascal_object_print_value (struct type *type, char *valaddr, CORE_ADDR address,
{
int boffset;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
- char *basename = TYPE_NAME (baseclass);
+ const char *basename = TYPE_NAME (baseclass);
char *base_valaddr;
if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -947,7 +948,7 @@ pascal_object_print_value (struct type *type, char *valaddr, CORE_ADDR address,
obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
}
- boffset = baseclass_offset (type, i, valaddr, address);
+ boffset = baseclass_offset (type, i, NULL, valaddr, address, 0);
if (pretty)
{
@@ -1079,7 +1080,7 @@ pascal_object_print_class_member (char *valaddr, struct type *domain,
}
if (i < len)
{
- char *name;
+ const char *name;
fprintf_filtered (stream, prefix);
name = type_name_no_tag (domain);
if (name)
diff --git a/gdb/parse.c b/gdb/parse.c
index 2edc6d76669..6fcc75119ca 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -531,7 +531,8 @@ write_dollar_variable (struct stoken str)
if (msym)
{
write_exp_msymbol (msym,
- lookup_function_type (builtin_type_int),
+ (struct type *)make_function_type (NULL, builtin_type_int, 0, NULL, 0)
+ /*lookup_function_type (builtin_type_int)*/,
builtin_type_int);
return;
}
@@ -1255,7 +1256,7 @@ follow_types (struct type *follow_type)
{
int done = 0;
int array_size;
- struct type *range_type;
+ struct range_type *range_type;
while (!done)
switch (pop_type ())
@@ -1271,23 +1272,23 @@ follow_types (struct type *follow_type)
break;
case tp_array:
array_size = pop_type_int ();
- /* FIXME-type-allocation: need a way to free this type when we are
+ /* TYPEFIX -type-allocation: need a way to free this type when we are
done with it. */
range_type =
- create_range_type ((struct type *) NULL,
+ make_range_type (NULL,
builtin_type_int, 0,
array_size >= 0 ? array_size - 1 : 0);
- follow_type =
- create_array_type ((struct type *) NULL,
+ follow_type = (struct type *)
+ make_array_type (NULL,
follow_type, range_type);
if (array_size < 0)
TYPE_ARRAY_UPPER_BOUND_TYPE (follow_type)
- = BOUND_CANNOT_BE_DETERMINED;
+ = BT_cannot_be_determined;
break;
case tp_function:
- /* FIXME-type-allocation: need a way to free this type when we are
+ /* TYPEFIX-type-allocation: need a way to free this type when we are
done with it. */
- follow_type = lookup_function_type (follow_type);
+ follow_type = (struct type *)make_function_type (NULL, follow_type, 0, NULL, 0);
break;
}
return follow_type;
@@ -1299,9 +1300,9 @@ build_parse (void)
{
int i;
- msym_text_symbol_type =
- init_type (TYPE_CODE_FUNC, 1, 0, "<text variable, no debug info>", NULL);
- TYPE_TARGET_TYPE (msym_text_symbol_type) = builtin_type_int;
+ msym_text_symbol_type = (struct type *)
+ make_function_type (NULL, builtin_type_int, 0, NULL, 0);
+ TYPE_NAME (msym_text_symbol_type) = "<text variable, no debug info>";
msym_data_symbol_type =
init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
"<data variable, no debug info>", NULL);
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index bcb438c543d..c87f2d5cd25 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -35,7 +35,7 @@
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
-
+typedef elf_greg_t greg_t;
int
kernel_u_size (void)
{
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 746a0646cc0..57d649dfc27 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -923,9 +923,10 @@ print_command_1 (char *exp, int inspect, int voidprint)
if (objectprint
&& (TYPE_CODE (type) == TYPE_CODE_PTR
|| TYPE_CODE (type) == TYPE_CODE_REF)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT
- || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_UNION))
+ && (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_STRUCT
+ || TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_UNION))
{
+#if 0
value_ptr v;
v = value_from_vtable_info (val, TYPE_TARGET_TYPE (type));
@@ -934,6 +935,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
val = v;
type = VALUE_TYPE (val);
}
+#endif
}
}
else
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 7da14815d11..0877078d161 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -876,7 +876,7 @@ open_symbol_file_object (void *from_ttyp)
make_cleanup (xfree, filename);
/* Have a pathname: read the symbol file. */
- symbol_file_add_main (filename, from_tty);
+ symbol_file_command (filename, from_tty);
return 1;
}
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 169f1f9acd4..a5d9cd83065 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -414,7 +414,9 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
We will fill it in later if we find out how. */
if (*type_addr == 0)
{
- *type_addr = alloc_type (objfile);
+ enum language old_language;
+ old_language = current_language->la_language;
+ *type_addr = alloc_type (objfile);
}
return (*type_addr);
@@ -731,7 +733,7 @@ read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
if (bsym)
{
new->field.type = SYMBOL_TYPE (bsym);
- new->field.name = type_name_no_tag (new->field.type);
+ new->field.name = xstrdup(type_name_no_tag (new->field.type));
}
else
{
@@ -837,7 +839,7 @@ read_cfront_member_functions (struct field_info *fip, char **pp,
else
dem_len = dem_args - dem_p;
main_fn_name =
- obsavestring (dem_p, dem_len, &objfile->type_obstack);
+ obsavestring (dem_p, dem_len, &objfile->type_obstack);
}
else
{
@@ -1329,8 +1331,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
switch (string[1])
{
case 't':
- SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
- &objfile->symbol_obstack);
+ SYMBOL_NAME (sym) = bcache("this", strlen("this")+1, &objfile->psymbol_cache);
+ /* obsavestring ("this", strlen ("this"),
+ &objfile->symbol_obstack);*/
break;
case 'v': /* $vtbl_ptr_type */
@@ -1580,8 +1583,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
/* Function result types are described as the result type in stabs.
We need to convert this to the function-returning-type-X type
in GDB. E.g. "int" is converted to "function returning int". */
- if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
- SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
+ if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
+ SYMBOL_TYPE (sym) = (struct type *)make_function_type (objfile, SYMBOL_TYPE (sym), 0, NULL, 0);
/* All functions in C++ have prototypes. */
if (SYMBOL_LANGUAGE (sym) == language_cplus)
@@ -1710,14 +1713,13 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
/* If it's gcc-compiled, if it says `short', believe it. */
if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
break;
-
+#if TYPEFIX
if (!BELIEVE_PCC_PROMOTION)
{
/* This is the signed type which arguments get promoted to. */
static struct type *pcc_promotion_type;
/* This is the unsigned type which arguments get promoted to. */
static struct type *pcc_unsigned_promotion_type;
-
/* Call it "int" because this is mainly C lossage. */
if (pcc_promotion_type == NULL)
pcc_promotion_type =
@@ -1785,6 +1787,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
break;
}
}
+#endif
case 'P':
/* acc seems to use P to declare the prototypes of functions that
@@ -1924,7 +1927,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
- type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
+ xstrdup(type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j)));
}
if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
@@ -2549,13 +2552,25 @@ again:
reference, or whatever, *in-place*. */
case '*':
- type1 = read_type (pp, objfile);
- type = make_pointer_type (type1, dbx_lookup_type (typenums));
+ {
+ struct type **oldtype;
+ type1 = read_type (pp, objfile);
+ oldtype = dbx_lookup_type (typenums);
+ type = (struct type *)make_pointer_type (objfile, type1);
+ if (oldtype != NULL)
+ *oldtype = type;
+ }
break;
-
+
case '&': /* Reference to another type */
- type1 = read_type (pp, objfile);
- type = make_reference_type (type1, dbx_lookup_type (typenums));
+ {
+ struct type **oldtype;
+ type1 = read_type (pp, objfile);
+ oldtype = dbx_lookup_type (typenums);
+ type = (struct type *)make_reference_type (objfile, type1);
+ if (oldtype != NULL)
+ *oldtype = type;
+ }
break;
case 'f': /* Function returning another type */
@@ -2599,6 +2614,7 @@ again:
break;
case '@':
+ current_subfile->language = language_cplus;
if (isdigit (**pp) || **pp == '(' || **pp == '-')
{ /* Member (class & variable) type */
/* FIXME -- we should be doing smash_to_XXX types here. */
@@ -2742,7 +2758,7 @@ again:
case 'S':
type1 = read_type (pp, objfile);
- type = create_set_type ((struct type *) NULL, type1);
+ type = (struct type *)make_set_type (objfile, (struct range_type *)type1);
if (is_string)
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
if (typenums[0] != -1)
@@ -2804,41 +2820,36 @@ rs6000_builtin_type (int typenum)
is other than 32 bits, then it should use a new negative type
number (or avoid negative type numbers for that case).
See stabs.texinfo. */
- rettype = init_type (TYPE_CODE_INT, 4, 0, "int", NULL);
+ rettype = builtin_type_int;
break;
case 2:
- rettype = init_type (TYPE_CODE_INT, 1, 0, "char", NULL);
+ rettype = builtin_type_char;
break;
case 3:
- rettype = init_type (TYPE_CODE_INT, 2, 0, "short", NULL);
+ rettype = builtin_type_short;
break;
case 4:
- rettype = init_type (TYPE_CODE_INT, 4, 0, "long", NULL);
+ rettype = builtin_type_long;
break;
case 5:
- rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
- "unsigned char", NULL);
+ rettype = builtin_type_unsigned_char;
break;
case 6:
- rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", NULL);
+ rettype = builtin_type_signed_char;
break;
case 7:
- rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
- "unsigned short", NULL);
+ rettype = builtin_type_unsigned_short;
break;
case 8:
- rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
- "unsigned int", NULL);
+ rettype = builtin_type_unsigned_int;
break;
case 9:
- rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
- "unsigned", NULL);
+ rettype = (struct type *)make_integer_type (NULL, "unsigned", 4, ST_unsigned);
case 10:
- rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
- "unsigned long", NULL);
+ rettype = builtin_type_unsigned_long;
break;
case 11:
- rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
+ rettype = builtin_type_void;
break;
case 12:
/* IEEE single precision (32 bit). */
@@ -2857,6 +2868,7 @@ rs6000_builtin_type (int typenum)
case 15:
rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", NULL);
break;
+#if TYPEFIX
case 16:
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
"boolean", NULL);
@@ -2910,13 +2922,14 @@ rs6000_builtin_type (int typenum)
case 30:
rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL);
break;
+#endif
case 31:
- rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL);
+ rettype = builtin_type_long_long;
break;
case 32:
- rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
- "unsigned long long", NULL);
+ rettype = builtin_type_unsigned_long_long;
break;
+#if TYPEFIX
case 33:
rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
"logical*8", NULL);
@@ -2924,6 +2937,7 @@ rs6000_builtin_type (int typenum)
case 34:
rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL);
break;
+#endif
}
negative_types[-typenum] = rettype;
return rettype;
@@ -3242,7 +3256,7 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
struct objfile *objfile)
{
register char *p;
- char *name;
+ const char *name;
char cpp_abbrev;
struct type *context;
@@ -3362,7 +3376,7 @@ read_one_struct_field (struct field_info *fip, char **pp, char *p,
else
fip->list->field.name =
- obsavestring (*pp, p - *pp, &objfile->type_obstack);
+ obsavestring (*pp, p - *pp, &objfile->type_obstack);
*pp = p + 1;
/* This means we have a visibility for a field coming. */
@@ -3700,7 +3714,7 @@ read_baseclasses (struct field_info *fip, char **pp, struct type *type,
field's name. */
new->field.type = read_type (pp, objfile);
- new->field.name = type_name_no_tag (new->field.type);
+ new->field.name = xstrdup(type_name_no_tag (new->field.type));
/* skip trailing ';' and bump count of number of fields seen */
if (**pp == ';')
@@ -3886,13 +3900,11 @@ read_cfront_static_fields (struct field_info *fip, char **pp, struct type *type,
dem_p = strrchr (dem, ':');
if (dem_p != 0 && *(dem_p - 1) == ':')
dem_p++;
- fip->list->field.name =
- obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
+ fip->list->field.name = obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
}
else
{
- fip->list->field.name =
- obsavestring (sname, strlen (sname), &objfile->type_obstack);
+ fip->list->field.name = obsavestring (sname, strlen (sname), &objfile->type_obstack);
}
} /* end of code for cfront work around */
} /* loop again for next static field */
@@ -4102,7 +4114,8 @@ static struct type *
read_array_type (register char **pp, register struct type *type,
struct objfile *objfile)
{
- struct type *index_type, *element_type, *range_type;
+ struct type *index_type, *element_type;
+ struct range_type *range_type;
int lower, upper;
int adjustable = 0;
int nbits;
@@ -4152,8 +4165,8 @@ read_array_type (register char **pp, register struct type *type,
}
range_type =
- create_range_type ((struct type *) NULL, index_type, lower, upper);
- type = create_array_type (type, element_type, range_type);
+ make_range_type (objfile, index_type, lower, upper);
+ type = (struct type *)make_array_type (objfile, element_type, range_type);
return type;
}
@@ -4176,8 +4189,7 @@ read_enum_type (register char **pp, register struct type *type,
struct pending *osyms, *syms;
int o_nsyms;
int nbits;
- int unsigned_enum = 1;
-
+ struct enum_pair *pairs;
#if 0
/* FIXME! The stabs produced by Sun CC merrily define things that ought
to be file-scope, between N_FN entries, using N_LSYM. What's a mother
@@ -4235,8 +4247,6 @@ read_enum_type (register char **pp, register struct type *type,
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_VALUE (sym) = n;
- if (n < 0)
- unsigned_enum = 0;
add_symbol_to_list (sym, symlist);
nsyms++;
}
@@ -4244,18 +4254,10 @@ read_enum_type (register char **pp, register struct type *type,
if (**pp == ';')
(*pp)++; /* Skip the semicolon. */
- /* Now fill in the fields of the type-structure. */
-
- TYPE_LENGTH (type) = TARGET_INT_BIT / HOST_CHAR_BIT;
- TYPE_CODE (type) = TYPE_CODE_ENUM;
- TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
- if (unsigned_enum)
- TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
- TYPE_NFIELDS (type) = nsyms;
- TYPE_FIELDS (type) = (struct field *)
- TYPE_ALLOC (type, sizeof (struct field) * nsyms);
- memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms);
-
+ pairs = (struct enum_pair *) obstack_alloc (&objfile->symbol_obstack,
+ sizeof (struct enum_pair) * nsyms);
+ type = (struct type *) make_enum_type (objfile, nsyms, &pairs);
+
/* Find the symbols for the values and put them into the type.
The symbols can be found in the symlist that we put them on
to cause them to be defined. osyms contains the old value
@@ -4272,9 +4274,10 @@ read_enum_type (register char **pp, register struct type *type,
{
struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type;
- TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
- TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
- TYPE_FIELD_BITSIZE (type, n) = 0;
+ ENUM_VALUE_NAME (type, n) = SYMBOL_NAME (xsym);
+ ENUM_VALUE_VALUE (type, n) = SYMBOL_VALUE (xsym);
+ if (SYMBOL_VALUE (xsym) < 0)
+ SIGNED_TYPE_SIGN (type) = ST_signed;
}
if (syms == osyms)
break;
@@ -4358,14 +4361,15 @@ read_sun_builtin_type (char **pp, int typenums[2], struct objfile *objfile)
++(*pp);
if (type_bits == 0)
- return init_type (TYPE_CODE_VOID, 1,
- signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
- objfile);
+ return builtin_type_void;
+#if TYPEFIX
else
return init_type (code,
type_bits / TARGET_CHAR_BIT,
signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
objfile);
+#endif
+ return NULL;
}
static struct type *
@@ -4517,7 +4521,7 @@ read_range_type (char **pp, int typenums[2], struct objfile *objfile)
long n2, n3;
int n2bits, n3bits;
int self_subrange;
- struct type *result_type;
+ struct range_type *result_type;
struct type *index_type = NULL;
/* First comes a type we are a subrange of.
@@ -4577,7 +4581,11 @@ read_range_type (char **pp, int typenums[2], struct objfile *objfile)
if (got_signed || got_unsigned)
{
return init_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT,
- got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL,
+ got_unsigned ?
+#if TYPEFIX
+ TYPE_FLAG_UNSIGNED :
+#endif
+0 : 0, NULL,
objfile);
}
else
@@ -4623,14 +4631,13 @@ read_range_type (char **pp, int typenums[2], struct objfile *objfile)
/* It is unsigned int or unsigned long. */
/* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
compatibility hack. */
- return init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED, NULL, objfile);
+ return builtin_type_unsigned_int;
}
/* Special case: char is defined (Who knows why) as a subrange of
itself with range 0-127. */
else if (self_subrange && n2 == 0 && n3 == 127)
- return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
+ return builtin_type_char;
else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill
&& !self_subrange)
@@ -4644,9 +4651,7 @@ read_range_type (char **pp, int typenums[2], struct objfile *objfile)
so don't need to test for it here. */
if (n3 < 0)
- /* n3 actually gives the size. */
- return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED,
- NULL, objfile);
+ return (struct type *)make_integer_type (objfile, NULL, -n3, ST_unsigned);
/* Is n3 == 2**(8n)-1 for some integer n? Then it's an
unsigned n-byte integer. But do require n to be a power of
@@ -4660,8 +4665,7 @@ read_range_type (char **pp, int typenums[2], struct objfile *objfile)
bits >>= 8;
if (bits == 0
&& ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */
- return init_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL,
- objfile);
+ return (struct type *) make_integer_type (objfile, NULL, bytes, ST_unsigned);
}
}
/* I think this is for Convex "long long". Since I don't know whether
@@ -4704,8 +4708,8 @@ handle_true_range:
index_type = range_type_index;
}
- result_type = create_range_type ((struct type *) NULL, index_type, n2, n3);
- return (result_type);
+ result_type = make_range_type (objfile, index_type, n2, n3);
+ return (struct type *)(result_type);
}
/* Read in an argument list. This is a list of types, separated by commas
@@ -4779,8 +4783,7 @@ common_block_start (char *name, struct objfile *objfile)
}
common_block = local_symbols;
common_block_i = local_symbols ? local_symbols->nsyms : 0;
- common_block_name = obsavestring (name, strlen (name),
- &objfile->symbol_obstack);
+ common_block_name = obsavestring (name, strlen (name), &objfile->symbol_obstack);
}
/* Process a N_ECOMM symbol. */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index ee4d65cf962..39c2a0f458b 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -371,7 +371,6 @@ psymtab_to_symtab (register struct partial_symtab *pst)
(*pst->read_symtab) (pst);
do_cleanups (back_to);
}
-
return pst->symtab;
}
@@ -496,7 +495,7 @@ default_symfile_offsets (struct objfile *objfile,
objfile->num_sections = SECT_OFF_MAX;
objfile->section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
+ obstack_alloc (&objfile->misc_obstack, SIZEOF_SECTION_OFFSETS);
memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS);
/* Now calculate offsets for section that were specified by the
@@ -1675,6 +1674,7 @@ reread_symbols (void)
/* Free the obstacks for non-reusable objfiles */
free_bcache (&objfile->psymbol_cache);
+ obstack_free (&objfile->misc_obstack, 0);
obstack_free (&objfile->psymbol_obstack, 0);
obstack_free (&objfile->symbol_obstack, 0);
obstack_free (&objfile->type_obstack, 0);
@@ -1700,6 +1700,8 @@ reread_symbols (void)
it is empty. */
obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
xmalloc, xfree);
+ obstack_specify_allocation (&objfile->misc_obstack, 0, 0,
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0,
xmalloc, xfree);
obstack_specify_allocation (&objfile->symbol_obstack, 0, 0,
@@ -1715,7 +1717,7 @@ reread_symbols (void)
/* We use the same section offsets as from last time. I'm not
sure whether that is always correct for shared libraries. */
objfile->section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
+ obstack_alloc (&objfile->misc_obstack, SIZEOF_SECTION_OFFSETS);
memcpy (objfile->section_offsets, offsets, SIZEOF_SECTION_OFFSETS);
objfile->num_sections = num_offsets;
@@ -1977,13 +1979,10 @@ allocate_psymtab (char *filename, struct objfile *objfile)
objfile->free_psymtabs = psymtab->next;
}
else
- psymtab = (struct partial_symtab *)
- obstack_alloc (&objfile->psymbol_obstack,
- sizeof (struct partial_symtab));
+ psymtab = (struct partial_symtab *) obstack_alloc (&objfile->misc_obstack, sizeof (struct partial_symtab));
memset (psymtab, 0, sizeof (struct partial_symtab));
- psymtab->filename = obsavestring (filename, strlen (filename),
- &objfile->psymbol_obstack);
+ psymtab->filename = obsavestring (filename, strlen(filename), &objfile->misc_obstack);
psymtab->symtab = NULL;
/* Prepend it to the psymtab list for the objfile it belongs to.
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 36447d7e526..b99337c2b8a 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -141,8 +141,6 @@ extend_psymbol_list (struct psymbol_allocation_list *, struct objfile *);
/* Add any kind of symbol to a psymbol_allocation_list. */
-/* #include "demangle.h" */
-
extern void
add_psymbol_to_list (char *, int, namespace_enum, enum address_class,
struct psymbol_allocation_list *, long, CORE_ADDR,
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 8199648aded..cc8824c8e7f 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -86,15 +86,18 @@ static void
free_symtab_block (struct objfile *objfile, struct block *b)
{
register int i, n;
- n = BLOCK_NSYMS (b);
+ n = BLOCK_NBUCKETS (b);
for (i = 0; i < n; i++)
{
+ register struct symbol *sym;
mfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i)));
- mfree (objfile->md, (PTR) BLOCK_SYM (b, i));
+ for (sym = BLOCK_BUCKET (b, i); sym; sym = sym->hash_next)
+ mfree (objfile->md, (PTR) sym);
}
mfree (objfile->md, (PTR) b);
}
+
/* Free all the storage associated with the struct symtab <- S.
Note that some symtabs have contents malloc'ed structure by structure,
while some have contents that all live inside one big block of memory,
@@ -455,7 +458,10 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
}
blen = BLOCK_NSYMS (b);
- fprintf_filtered (outfile, ", %d syms in ", blen);
+ if (BLOCK_FUNCTION (b))
+ fprintf_filtered (outfile, ", %d syms in ", blen);
+ else
+ fprintf_filtered (outfile, ", %d buckets of symbols in ", blen);
print_address_numeric (BLOCK_START (b), 1, outfile);
fprintf_filtered (outfile, "..");
print_address_numeric (BLOCK_END (b), 1, outfile);
@@ -475,11 +481,13 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
for (j = 0; j < blen; j++)
{
struct print_symbol_args s;
- s.symbol = BLOCK_SYM (b, j);
- s.depth = depth + 1;
- s.outfile = outfile;
- catch_errors (print_symbol, &s, "Error printing symbol:\n",
- RETURN_MASK_ALL);
+ for (s.symbol = BLOCK_BUCKET (b, j); s.symbol; s.symbol = s.symbol->hash_next)
+ {
+ s.depth = depth + 1;
+ s.outfile = outfile;
+ catch_errors (print_symbol, &s, "Error printing symbol:\n",
+ RETURN_MASK_ALL);
+ }
}
}
fprintf_filtered (outfile, "\n");
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a16393e81a7..965251733ec 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -47,6 +47,7 @@
#include "gdb_stat.h"
#include <ctype.h>
#include "cp-abi.h"
+#include "splay-tree.h"
/* Prototype for one function in parser-defs.h,
instead of including that entire file. */
@@ -195,30 +196,11 @@ struct symtab *
lookup_symtab (const char *name)
{
register struct symtab *s;
-#if 0
- register char *copy;
-#endif
s = lookup_symtab_1 (name);
if (s)
return s;
-#if 0
- /* This screws c-exp.y:yylex if there is both a type "tree" and a symtab
- "tree.c". */
-
- /* If name not found as specified, see if adding ".c" helps. */
- /* Why is this? Is it just a user convenience? (If so, it's pretty
- questionable in the presence of C++, FORTRAN, etc.). It's not in
- the GDB manual. */
-
- copy = (char *) alloca (strlen (name) + 3);
- strcpy (copy, name);
- strcat (copy, ".c");
- s = lookup_symtab_1 (copy);
- if (s)
- return s;
-#endif /* 0 */
/* We didn't find anything; die. */
return 0;
@@ -268,7 +250,7 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
struct fn_field *method = &f[signature_id];
char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
- char *newname = type_name_no_tag (type);
+ const char *newname = type_name_no_tag (type);
/* Does the form of physname indicate that it is the full mangled name
of a constructor (not just the args)? */
@@ -584,7 +566,7 @@ lookup_symbol (const char *name, const struct block *block,
return returnval;
}
-
+extern splay_tree symbolsplay;
static struct symbol *
lookup_symbol_aux (const char *name, const struct block *block,
const namespace_enum namespace, int *is_a_field_of_this,
@@ -597,78 +579,49 @@ lookup_symbol_aux (const char *name, const struct block *block,
register struct objfile *objfile = NULL;
register struct block *b;
register struct minimal_symbol *msymbol;
+ register splay_tree_node result;
+ int skipblocksearches=0;
+ struct block_splay_data *splaydata=NULL;
+ result = splay_tree_lookup (symbolsplay, (splay_tree_key) name);
+ if (result == NULL)
+ skipblocksearches = 1;
+ else
+ splaydata = (struct block_splay_data *)result->value;
-
- /* Search specified block and its superiors. */
-
- while (block != 0)
+ if (!skipblocksearches)
{
- sym = lookup_block_symbol (block, name, namespace);
- if (sym)
+ /* Search specified block and its superiors. */
+
+ while (block != 0)
{
- block_found = block;
- if (symtab != NULL)
+ if (bitmap_bit_p (splaydata->blocks, BLOCK_ID (block)))
{
- /* Search the list of symtabs for one which contains the
- address of the start of this block. */
- ALL_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- if (BLOCK_START (b) <= BLOCK_START (block)
- && BLOCK_END (b) > BLOCK_START (block))
- goto found;
- }
- found:
- *symtab = s;
+ sym = lookup_block_symbol (block, name, namespace);
+ if (sym)
+ {
+ block_found = block;
+ if (symtab != NULL)
+ {
+ /* Search the list of symtabs for one which contains the
+ address of the start of this block. */
+ ALL_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ if (BLOCK_START (b) <= BLOCK_START (block)
+ && BLOCK_END (b) > BLOCK_START (block))
+ goto found;
+ }
+ found:
+ *symtab = s;
+ }
+
+ return fixup_symbol_section (sym, objfile);
+ }
}
-
- return fixup_symbol_section (sym, objfile);
+ block = BLOCK_SUPERBLOCK (block);
}
- block = BLOCK_SUPERBLOCK (block);
- }
-
- /* FIXME: this code is never executed--block is always NULL at this
- point. What is it trying to do, anyway? We already should have
- checked the STATIC_BLOCK above (it is the superblock of top-level
- blocks). Why is VAR_NAMESPACE special-cased? */
- /* Don't need to mess with the psymtabs; if we have a block,
- that file is read in. If we don't, then we deal later with
- all the psymtab stuff that needs checking. */
- /* Note (RT): The following never-executed code looks unnecessary to me also.
- * If we change the code to use the original (passed-in)
- * value of 'block', we could cause it to execute, but then what
- * would it do? The STATIC_BLOCK of the symtab containing the passed-in
- * 'block' was already searched by the above code. And the STATIC_BLOCK's
- * of *other* symtabs (those files not containing 'block' lexically)
- * should not contain 'block' address-wise. So we wouldn't expect this
- * code to find any 'sym''s that were not found above. I vote for
- * deleting the following paragraph of code.
- */
- if (namespace == VAR_NAMESPACE && block != NULL)
- {
- struct block *b;
- /* Find the right symtab. */
- ALL_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- if (BLOCK_START (b) <= BLOCK_START (block)
- && BLOCK_END (b) > BLOCK_START (block))
- {
- sym = lookup_block_symbol (b, name, VAR_NAMESPACE);
- if (sym)
- {
- block_found = b;
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
- }
- }
- }
}
-
-
/* C++: If requested to do so by the caller,
check to see if NAME is a field of `this'. */
if (is_a_field_of_this)
@@ -689,84 +642,26 @@ lookup_symbol_aux (const char *name, const struct block *block,
check the psymtab's. If a psymtab indicates the existence
of the desired name as a global, then do psymtab-to-symtab
conversion on the fly and return the found symbol. */
-
- ALL_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, namespace);
- if (sym)
- {
- block_found = block;
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
- }
- }
-
-#ifndef HPUXHPPA
-
- /* Check for the possibility of the symbol being a function or
- a mangled variable that is stored in one of the minimal symbol tables.
- Eventually, all global symbols might be resolved in this way. */
-
- if (namespace == VAR_NAMESPACE)
+ if (!skipblocksearches)
{
- msymbol = lookup_minimal_symbol (name, NULL, NULL);
- if (msymbol != NULL)
+ ALL_SYMTABS (objfile, s)
{
- s = find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol),
- SYMBOL_BFD_SECTION (msymbol));
- if (s != NULL)
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ if (bitmap_bit_p (splaydata->blocks, BLOCK_ID (block)))
{
- /* This is a function which has a symtab for its address. */
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
- namespace);
- /* We kept static functions in minimal symbol table as well as
- in static scope. We want to find them in the symbol table. */
- if (!sym)
+ sym = lookup_block_symbol (block, name, namespace);
+ if (sym)
{
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
- namespace);
+ block_found = block;
+ if (symtab != NULL)
+ *symtab = s;
+ return fixup_symbol_section (sym, objfile);
}
-
- /* sym == 0 if symbol was found in the minimal symbol table
- but not in the symtab.
- Return 0 to use the msymbol definition of "foo_".
-
- This happens for Fortran "foo_" symbols,
- which are "foo" in the symtab.
-
- This can also happen if "asm" is used to make a
- regular symbol but not a debugging symbol, e.g.
- asm(".globl _main");
- asm("_main:");
- */
-
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
}
- else if (MSYMBOL_TYPE (msymbol) != mst_text
- && MSYMBOL_TYPE (msymbol) != mst_file_text
- && !STREQ (name, SYMBOL_NAME (msymbol)))
- {
- /* This is a mangled variable, look it up by its
- mangled name. */
- return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
- namespace, is_a_field_of_this, symtab);
- }
- /* There are no debug symbols for this file, or we are looking
- for an unmangled variable.
- Try to find a matching static symbol below. */
}
}
-
-#endif
-
+
ALL_PSYMTABS (objfile, ps)
{
if (!ps->readin && lookup_partial_symbol (ps, name, 1, namespace))
@@ -802,21 +697,26 @@ lookup_symbol_aux (const char *name, const struct block *block,
If a psymtab indicates the existence
of the desired name as a file-level static, then do psymtab-to-symtab
conversion on the fly and return the found symbol. */
-
- ALL_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, namespace);
- if (sym)
- {
- block_found = block;
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
- }
- }
-
+ if (!skipblocksearches)
+ {
+ ALL_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ if (bitmap_bit_p (splaydata->blocks, BLOCK_ID (block)))
+ {
+ sym = lookup_block_symbol (block, name, namespace);
+ if (sym)
+ {
+ block_found = block;
+ if (symtab != NULL)
+ *symtab = s;
+ return fixup_symbol_section (sym, objfile);
+ }
+ }
+ }
+ }
+
ALL_PSYMTABS (objfile, ps)
{
if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace))
@@ -846,7 +746,6 @@ lookup_symbol_aux (const char *name, const struct block *block,
}
}
-#ifdef HPUXHPPA
/* Check for the possibility of the symbol being a function or
a global variable that is stored in one of the minimal symbol tables.
@@ -940,7 +839,6 @@ lookup_symbol_aux (const char *name, const struct block *block,
}
}
-#endif
if (symtab != NULL)
*symtab = NULL;
@@ -984,11 +882,6 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
center = bottom + (top - bottom) / 2;
if (!(center < top))
internal_error (__FILE__, __LINE__, "failed internal consistency check");
- if (!do_linear_search
- && (SYMBOL_LANGUAGE (*center) == language_java))
- {
- do_linear_search = 1;
- }
if (strcmp (SYMBOL_SOURCE_NAME (*center), name) >= 0)
{
top = center;
@@ -1168,105 +1061,20 @@ find_main_psymtab (void)
/* Search BLOCK for symbol NAME in NAMESPACE.
- Note that if NAME is the demangled form of a C++ symbol, we will fail
- to find a match during the binary search of the non-encoded names, but
- for now we don't worry about the slight inefficiency of looking for
- a match we'll never find, since it will go pretty quick. Once the
- binary search terminates, we drop through and do a straight linear
- search on the symbols. Each symbol which is marked as being a C++
- symbol (language_cplus set) has both the encoded and non-encoded names
- tested for a match. */
+ If we couldn't use a hashtable for the block, we just do a linear search.
+ Otherwise, we hash the name, and walk the bucket's symbol chain to see if we find
+ the symbol we want.
+*/
struct symbol *
lookup_block_symbol (register const struct block *block, const char *name,
const namespace_enum namespace)
{
- register int bot, top, inc;
- register struct symbol *sym;
- register struct symbol *sym_found = NULL;
- register int do_linear_search = 1;
-
- /* If the blocks's symbols were sorted, start with a binary search. */
+ register unsigned int top,bot;
+ register struct symbol *sym, *sym_found=NULL;
+
- if (BLOCK_SHOULD_SORT (block))
- {
- /* Reset the linear search flag so if the binary search fails, we
- won't do the linear search once unless we find some reason to
- do so */
-
- do_linear_search = 0;
- top = BLOCK_NSYMS (block);
- bot = 0;
-
- /* Advance BOT to not far before the first symbol whose name is NAME. */
-
- while (1)
- {
- inc = (top - bot + 1);
- /* No need to keep binary searching for the last few bits worth. */
- if (inc < 4)
- {
- break;
- }
- inc = (inc >> 1) + bot;
- sym = BLOCK_SYM (block, inc);
- if (!do_linear_search && (SYMBOL_LANGUAGE (sym) == language_java))
- {
- do_linear_search = 1;
- }
- if (SYMBOL_SOURCE_NAME (sym)[0] < name[0])
- {
- bot = inc;
- }
- else if (SYMBOL_SOURCE_NAME (sym)[0] > name[0])
- {
- top = inc;
- }
- else if (strcmp (SYMBOL_SOURCE_NAME (sym), name) < 0)
- {
- bot = inc;
- }
- else
- {
- top = inc;
- }
- }
-
- /* Now scan forward until we run out of symbols, find one whose
- name is greater than NAME, or find one we want. If there is
- more than one symbol with the right name and namespace, we
- return the first one; I believe it is now impossible for us
- to encounter two symbols with the same name and namespace
- here, because blocks containing argument symbols are no
- longer sorted. */
-
- top = BLOCK_NSYMS (block);
- while (bot < top)
- {
- sym = BLOCK_SYM (block, bot);
- if (SYMBOL_NAMESPACE (sym) == namespace &&
- SYMBOL_MATCHES_NAME (sym, name))
- {
- return sym;
- }
- bot++;
- }
- }
-
- /* Here if block isn't sorted, or we fail to find a match during the
- binary search above. If during the binary search above, we find a
- symbol which is a C++ symbol, then we have re-enabled the linear
- search flag which was reset when starting the binary search.
-
- This loop is equivalent to the loop above, but hacked greatly for speed.
-
- Note that parameter symbols do not always show up last in the
- list; this loop makes sure to take anything else other than
- parameter symbols first; it only uses parameter symbols as a
- last resort. Note that this only takes up extra computation
- time on a match. */
-
- if (do_linear_search)
+ if (BLOCK_FUNCTION (block) != NULL)
{
top = BLOCK_NSYMS (block);
bot = 0;
@@ -1298,7 +1106,7 @@ lookup_block_symbol (register const struct block *block, const char *name,
if (SYMBOL_ALIASES (sym))
sym = find_active_alias (sym, read_pc ());
-
+
sym_found = sym;
if (SYMBOL_CLASS (sym) != LOC_ARG &&
SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
@@ -1313,7 +1121,19 @@ lookup_block_symbol (register const struct block *block, const char *name,
bot++;
}
}
- return (sym_found); /* Will be NULL if not found. */
+ else
+ {
+ top = msymbol_hash_iw (name) % BLOCK_NBUCKETS (block);
+ sym_found = BLOCK_BUCKET (block, top);
+ while (sym_found != NULL)
+ {
+ if (SYMBOL_NAMESPACE (sym_found) == namespace
+ && SYMBOL_MATCHES_NAME (sym_found, name))
+ break;
+ sym_found = sym_found->hash_next;
+ }
+ }
+ return sym_found;
}
/* Given a main symbol SYM and ADDR, search through the alias
@@ -1373,7 +1193,8 @@ find_pc_sect_symtab (CORE_ADDR pc, asection *section)
register struct partial_symtab *ps;
register struct objfile *objfile;
CORE_ADDR distance = 0;
-
+ if (pc == 0)
+ return NULL;
/* Search all symtabs for the one whose file contains our address, and which
is the smallest of all the ones containing the address. This is designed
to deal with a case like symtab a is at 0x1000-0x2000 and 0x3000-0x4000
@@ -1415,13 +1236,17 @@ find_pc_sect_symtab (CORE_ADDR pc, asection *section)
{
int i;
- for (i = 0; i < b->nsyms; i++)
+ for (i = 0; i < BLOCK_NBUCKETS(b); i++)
{
- fixup_symbol_section (b->sym[i], objfile);
- if (section == SYMBOL_BFD_SECTION (b->sym[i]))
- break;
+ register struct symbol *tempsym;
+ for (tempsym = BLOCK_BUCKET (b,i); tempsym; tempsym = tempsym->hash_next)
+ {
+ fixup_symbol_section (tempsym, objfile);
+ if (section == SYMBOL_BFD_SECTION (tempsym))
+ break;
+ }
}
- if (i >= b->nsyms)
+ if (i >= BLOCK_NBUCKETS(b))
continue; /* no symbol in this symtab matches section */
}
distance = BLOCK_END (b) - BLOCK_START (b);
@@ -2513,43 +2338,42 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
{
b = BLOCKVECTOR_BLOCK (bv, i);
- /* Skip the sort if this block is always sorted. */
- if (!BLOCK_SHOULD_SORT (b))
- sort_block_syms (b);
- for (j = 0; j < BLOCK_NSYMS (b); j++)
+ for (j = 0; j < BLOCK_NBUCKETS (b); j++)
{
QUIT;
- sym = BLOCK_SYM (b, j);
- if (file_matches (s->filename, files, nfiles)
- && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
+ for (sym = BLOCK_BUCKET (b, j); sym; sym = sym->hash_next)
+ {
+ if (file_matches (s->filename, files, nfiles)
+ && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
&& ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (sym) != LOC_TYPEDEF
&& SYMBOL_CLASS (sym) != LOC_BLOCK
&& SYMBOL_CLASS (sym) != LOC_CONST)
|| (kind == FUNCTIONS_NAMESPACE && SYMBOL_CLASS (sym) == LOC_BLOCK)
|| (kind == TYPES_NAMESPACE && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
|| (kind == METHODS_NAMESPACE && SYMBOL_CLASS (sym) == LOC_BLOCK))))
- {
- /* match */
- psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
- psr->block = i;
- psr->symtab = s;
- psr->symbol = sym;
- psr->msymbol = NULL;
- psr->next = NULL;
- if (tail == NULL)
{
- sr = psr;
- old_chain = make_cleanup_free_search_symbols (sr);
+ /* match */
+ psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
+ psr->block = i;
+ psr->symtab = s;
+ psr->symbol = sym;
+ psr->msymbol = NULL;
+ psr->next = NULL;
+ if (tail == NULL)
+ {
+ sr = psr;
+ old_chain = make_cleanup_free_search_symbols (sr);
+ }
+ else
+ tail->next = psr;
+ tail = psr;
}
- else
- tail->next = psr;
- tail = psr;
}
}
}
prev_bv = bv;
}
-
+
/* If there are no eyes, avoid all contact. I mean, if there are
no debug symbols, then print directly from the msymbol_vector. */
@@ -3030,23 +2854,26 @@ make_symbol_completion_list (char *text, char *word)
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
- for (i = 0; i < BLOCK_NSYMS (b); i++)
+ for (i = 0; i < BLOCK_NBUCKETS (b); i++)
{
- sym = BLOCK_SYM (b, i);
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
- if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ for (sym = BLOCK_BUCKET (b, i); sym; sym=sym->hash_next)
{
- struct type *t = SYMBOL_TYPE (sym);
- enum type_code c = TYPE_CODE (t);
-
- if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
+
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
- for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
+ struct type *t = SYMBOL_TYPE (sym);
+ enum type_code c = TYPE_CODE (t);
+
+ if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
{
- if (TYPE_FIELD_NAME (t, j))
+ for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
{
- completion_list_add_name (TYPE_FIELD_NAME (t, j),
- sym_text, sym_text_len, text, word);
+ if (TYPE_FIELD_NAME (t, j))
+ {
+ completion_list_add_name (TYPE_FIELD_NAME (t, j),
+ sym_text, sym_text_len, text, word);
+ }
}
}
}
@@ -3061,10 +2888,10 @@ make_symbol_completion_list (char *text, char *word)
{
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- for (i = 0; i < BLOCK_NSYMS (b); i++)
+ for (i = 0; i < BLOCK_NBUCKETS (b); i++)
{
- sym = BLOCK_SYM (b, i);
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ for (sym = BLOCK_BUCKET (b, i); sym; sym = sym->hash_next)
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
}
@@ -3075,10 +2902,10 @@ make_symbol_completion_list (char *text, char *word)
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
- for (i = 0; i < BLOCK_NSYMS (b); i++)
+ for (i = 0; i < BLOCK_NBUCKETS (b); i++)
{
- sym = BLOCK_SYM (b, i);
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ for (sym = BLOCK_BUCKET (b, i); sym; sym = sym->hash_next)
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
}
@@ -3568,10 +3395,10 @@ make_symbol_overload_list (struct symbol *fsym)
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
- for (i = 0; i < BLOCK_NSYMS (b); i++)
+ for (i = 0; i < BLOCK_NBUCKETS (b); i++)
{
- sym = BLOCK_SYM (b, i);
- overload_list_add_symbol (sym, oload_name);
+ for (sym = BLOCK_BUCKET (b, i); sym; sym=sym->hash_next)
+ overload_list_add_symbol (sym, oload_name);
}
}
@@ -3582,10 +3409,10 @@ make_symbol_overload_list (struct symbol *fsym)
{
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- for (i = 0; i < BLOCK_NSYMS (b); i++)
+ for (i = 0; i < BLOCK_NBUCKETS (b); i++)
{
- sym = BLOCK_SYM (b, i);
- overload_list_add_symbol (sym, oload_name);
+ for (sym = BLOCK_BUCKET (b, i); sym; sym=sym->hash_next)
+ overload_list_add_symbol (sym, oload_name);
}
}
@@ -3596,10 +3423,10 @@ make_symbol_overload_list (struct symbol *fsym)
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
- for (i = 0; i < BLOCK_NSYMS (b); i++)
+ for (i = 0; i < BLOCK_NBUCKETS (b); i++)
{
- sym = BLOCK_SYM (b, i);
- overload_list_add_symbol (sym, oload_name);
+ for (sym = BLOCK_BUCKET (b, i); sym; sym=sym->hash_next)
+ overload_list_add_symbol (sym, oload_name);
}
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index d85add3b3e8..d2995afbaff 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -29,7 +29,6 @@
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free xfree
#include "bcache.h"
-
/* Don't do this; it means that if some .o's are compiled with GNU C
and some are not (easy to do accidentally the way we configure
things; also it is a pain to have to "make clean" every time you
@@ -40,7 +39,8 @@
#else
#define BYTE_BITFIELD /*nothing */
#endif
-
+#include "bitmap.h"
+#include "splay-tree.h"
/* Define a structure for the information that is common to all symbol types,
including minimal symbols, partial symbols, and full symbols. In a
multilanguage environment, some language specific information may need to
@@ -119,6 +119,7 @@ struct general_symbol_info
/* The bfd section associated with this symbol. */
asection *bfd_section;
+
};
extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *);
@@ -167,7 +168,6 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *);
so we can avoid doing this work again the next time we encounter
the symbol. Any required space to store the name is obtained from the
specified obstack. */
-
#define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack) \
do { \
char *demangled = NULL; \
@@ -175,7 +175,8 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *);
SYMBOL_LANGUAGE (symbol) = language_auto; \
if (SYMBOL_LANGUAGE (symbol) == language_cplus \
|| SYMBOL_LANGUAGE (symbol) == language_auto) \
- { \
+ { \
+ if (SYMBOL_CPLUS_DEMANGLED_NAME (symbol) == NULL ) { \
demangled = \
cplus_demangle (SYMBOL_NAME (symbol), DMGL_PARAMS | DMGL_ANSI);\
if (demangled != NULL) \
@@ -189,6 +190,7 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *);
{ \
SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL; \
} \
+ } \
} \
if (SYMBOL_LANGUAGE (symbol) == language_java) \
{ \
@@ -361,10 +363,6 @@ struct minimal_symbol
list. This is the link. */
struct minimal_symbol *hash_next;
-
- /* Minimal symbols are stored in two different hash tables. This is
- the `next' pointer for the demangled hash table. */
-
struct minimal_symbol *demangled_hash_next;
};
@@ -415,10 +413,14 @@ struct blockvector
#define GLOBAL_BLOCK 0
#define STATIC_BLOCK 1
#define FIRST_LOCAL_BLOCK 2
-
+struct block_splay_data
+{
+ bitmap blocks;
+};
struct block
{
-
+ /* Unique block ID */
+ unsigned int id;
/* Addresses in the executable code that are in this block. */
CORE_ADDR startaddr;
@@ -448,31 +450,22 @@ struct block
of this flag is undefined. */
unsigned char gcc_compile_flag;
-
- /* Number of local symbols. */
-
- int nsyms;
-
- /* The symbols. If some of them are arguments, then they must be
- in the order in which we would like to print them. */
-
+ unsigned int nsyms;
struct symbol *sym[1];
};
#define BLOCK_START(bl) (bl)->startaddr
#define BLOCK_END(bl) (bl)->endaddr
-#define BLOCK_NSYMS(bl) (bl)->nsyms
-#define BLOCK_SYM(bl, n) (bl)->sym[n]
#define BLOCK_FUNCTION(bl) (bl)->function
#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
+#define BLOCK_NBUCKETS(bl) (bl)->nsyms
+#define BLOCK_NSYMS(bl) (bl)->nsyms
+#define BLOCK_ID(bl) (bl)->id
+#define BLOCK_BUCKET(bl, i) (bl)->sym[i]
+#define BLOCK_SYM(bl, i) (bl)->sym[i]
+#define BLOCK_SHOULD_SORT(bl) 0
-/* Nonzero if symbols of block BL should be sorted alphabetically.
- Don't sort a block which corresponds to a function. If we did the
- sorting would have to preserve the order of the symbols for the
- arguments. */
-
-#define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40 && BLOCK_FUNCTION (bl) == NULL)
/* Represent one symbol name; a variable, constant, function or typedef. */
@@ -654,7 +647,12 @@ enum address_class
* with a level of indirection.
*/
- LOC_INDIRECT
+ LOC_INDIRECT,
+
+ /* Location is a location expression */
+ LOC_LOC_EXPR,
+ /* Location is a location list (ranges + location expressions) */
+ LOC_LOC_LIST
};
@@ -674,6 +672,10 @@ struct alias_list
struct alias_list *next;
};
+/* This is purposely an incomplete type. If you get a compiler error,
+ it means your code is relying on the internal structure of location
+ expressions, and thus, broken. Fix it. */
+
struct symbol
{
@@ -713,6 +715,11 @@ struct symbol
short basereg;
}
aux_value;
+ struct
+ {
+ struct locexpr *loc;
+ struct locexpr *frameloc;
+ } dynamic_location;
/* Link to a list of aliases for this symbol.
@@ -722,6 +729,9 @@ struct symbol
/* List of ranges where this symbol is active. This is only
used by alias symbols at the current time. */
struct range_list *ranges;
+
+ struct symbol *hash_next;
+
};
@@ -730,6 +740,8 @@ struct symbol
#define SYMBOL_TYPE(symbol) (symbol)->type
#define SYMBOL_LINE(symbol) (symbol)->line
#define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg
+#define SYMBOL_LOC_EXPR(symbol) (symbol)->dynamic_location.loc
+#define SYMBOL_FRAME_LOC_EXPR(symbol) (symbol)->dynamic_location.frameloc
#define SYMBOL_ALIASES(symbol) (symbol)->aliases
#define SYMBOL_RANGES(symbol) (symbol)->ranges
@@ -805,6 +817,7 @@ struct linetable
struct linetable_entry item[1];
};
+struct locexpr;
/* All the information on one source file. */
struct source
@@ -1033,19 +1046,8 @@ struct partial_symtab
((pst) -> symtab != NULL ? (pst) -> symtab : psymtab_to_symtab (pst))
-/* The virtual function table is now an array of structures which have the
- form { int16 offset, delta; void *pfn; }.
-
- In normal virtual function tables, OFFSET is unused.
- DELTA is the amount which is added to the apparent object's base
- address in order to point to the actual object to which the
- virtual function should be applied.
- PFN is a pointer to the virtual function.
-
- Note that this macro is g++ specific (FIXME). */
-
-#define VTBL_FNADDR_OFFSET 2
+
/* External variables and functions for the objects described above. */
/* This symtab variable specifies the current file for printing source lines */
diff --git a/gdb/thread-db.c b/gdb/thread-db.c
index 8ddc6a27332..72fda0ad729 100644
--- a/gdb/thread-db.c
+++ b/gdb/thread-db.c
@@ -841,7 +841,7 @@ thread_db_store_registers (int regno)
if (err != TD_OK)
error ("Cannot store general-purpose registers for thread %ld: %s",
(long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
- err = td_thr_setfpregs_p (&th, &fpregset);
+ err = td_thr_setfpregs_p (&th, (const gdb_prfpregset_t *)&fpregset);
if (err != TD_OK)
error ("Cannot store floating-point registers for thread %ld: %s",
(long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
diff --git a/gdb/top.c b/gdb/top.c
index 79eaa41cf49..38df21d6c2e 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -723,7 +723,6 @@ execute_command (char *p, int from_tty)
extern void serial_log_command (const char *);
free_all_values ();
-
/* Force cleanup of any alloca areas if using C alloca instead of
a builtin alloca. */
alloca (0);
@@ -1512,7 +1511,7 @@ get_prompt_1 (void *data)
switch (TYPE_CODE (arg_type))
{
case TYPE_CODE_ARRAY:
- elt_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
+ elt_type = check_typedef (ARRAY_ELEMENT_TYPE (arg_type));
if (TYPE_LENGTH (arg_type) > 0 &&
TYPE_LENGTH (elt_type) == 1 &&
TYPE_CODE (elt_type) == TYPE_CODE_INT)
@@ -1617,15 +1616,15 @@ get_prompt_1 (void *data)
{
/* no default format for enum */
longval = value_as_long (arg_val);
- len = TYPE_NFIELDS (arg_type);
+ len = ENUM_NUM_VALUES (arg_type);
/* find enum name if possible */
for (i = 0; i < len; i++)
- if (TYPE_FIELD_BITPOS (arg_type, i) == longval)
+ if (ENUM_VALUE_VALUE (arg_type, i) == longval)
break; /* match -- end loop */
if (i < len) /* enum name found */
{
- char *name = TYPE_FIELD_NAME (arg_type, i);
+ const char *name = ENUM_VALUE_NAME (arg_type, i);
strncpy (outp, name, available);
/* in casel available < strlen (name), */
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index fbe377e02a1..49aee28807f 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -254,7 +254,7 @@ static void
set_traceframe_context (CORE_ADDR trace_pc)
{
static struct type *func_string, *file_string;
- static struct type *func_range, *file_range;
+ static struct range_type *func_range, *file_range;
static value_ptr func_val, file_val;
static struct type *charstar;
int len;
@@ -293,9 +293,9 @@ set_traceframe_context (CORE_ADDR trace_pc)
else
{
len = strlen (SYMBOL_NAME (traceframe_fun));
- func_range = create_range_type (func_range,
+ func_range = make_range_type (NULL,
builtin_type_int, 0, len - 1);
- func_string = create_array_type (func_string,
+ func_string = (struct type *)make_array_type (NULL,
builtin_type_char, func_range);
func_val = allocate_value (func_string);
VALUE_TYPE (func_val) = func_string;
@@ -314,9 +314,9 @@ set_traceframe_context (CORE_ADDR trace_pc)
else
{
len = strlen (traceframe_sal.symtab->filename);
- file_range = create_range_type (file_range,
+ file_range = make_range_type (NULL,
builtin_type_int, 0, len - 1);
- file_string = create_array_type (file_string,
+ file_string = (struct type *)make_array_type (NULL,
builtin_type_char, file_range);
file_val = allocate_value (file_string);
VALUE_TYPE (file_val) = file_string;
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 7ea7098c819..058e86aa573 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -31,8 +31,8 @@
#include "gdbcmd.h"
#include "target.h"
#include "language.h"
+#include "demangle.h"
#include "cp-abi.h"
-
#include "gdb_string.h"
#include <errno.h>
@@ -150,7 +150,7 @@ whatis_exp (char *exp, int show)
if (((TYPE_CODE (type) == TYPE_CODE_PTR) ||
(TYPE_CODE (type) == TYPE_CODE_REF))
&&
- (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+ (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
{
real_type = value_rtti_target_type (val, &full, &top, &using_enc);
if (real_type)
@@ -269,17 +269,17 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
{
case TYPE_CODE_ENUM:
- len = TYPE_NFIELDS (type);
+ len = ENUM_NUM_VALUES (type);
for (i = 0; i < len; i++)
{
- if (TYPE_FIELD_BITPOS (type, i) == val)
+ if (ENUM_VALUE_VALUE (type, i) == val)
{
break;
}
}
if (i < len)
{
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+ fputs_filtered (ENUM_VALUE_NAME (type, i), stream);
}
else
{
@@ -300,7 +300,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
break;
case TYPE_CODE_RANGE:
- print_type_scalar (TYPE_TARGET_TYPE (type), val, stream);
+ print_type_scalar (RANGE_INDEX_TYPE (type), val, stream);
return;
case TYPE_CODE_UNDEF:
diff --git a/gdb/utils.c b/gdb/utils.c
index 294ad426580..950fb7abec6 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -25,7 +25,6 @@
#include <ctype.h>
#include "gdb_string.h"
#include "event-top.h"
-
#ifdef HAVE_CURSES_H
#include <curses.h>
#endif
@@ -660,8 +659,10 @@ error_stream (struct ui_file *stream)
{
long size;
char *msg = ui_file_xstrdup (stream, &size);
- make_cleanup (xfree, msg);
+ struct cleanup *err_msg_cleanup;
+ err_msg_cleanup = make_cleanup (xfree, msg);
error ("%s", msg);
+ do_cleanups (err_msg_cleanup);
}
/* Get the last error message issued by gdb */
@@ -890,8 +891,6 @@ request_quit (int signo)
#if !defined (USE_MMALLOC)
-/* NOTE: These must use PTR so that their definition matches the
- declaration found in "mmalloc.h". */
PTR
mmalloc (PTR md, size_t size)
@@ -923,7 +922,6 @@ mfree (PTR md, PTR ptr)
#endif /* USE_MMALLOC */
#if !defined (USE_MMALLOC) || defined (NO_MMCHECK)
-
void
init_malloc (void *md)
{
diff --git a/gdb/valarith.c b/gdb/valarith.c
index aaa393f4b10..d8a8873da7a 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -75,7 +75,7 @@ value_add (value_ptr arg1, value_ptr arg2)
valint = arg1;
valptrtype = type2;
}
- len = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (valptrtype)));
+ len = TYPE_LENGTH (check_typedef (POINTER_TARGET_TYPE (valptrtype)));
if (len == 0)
len = 1; /* For (void *) */
retval = value_from_pointer (valptrtype,
@@ -102,17 +102,17 @@ value_sub (value_ptr arg1, value_ptr arg2)
if (TYPE_CODE (type2) == TYPE_CODE_INT)
{
/* pointer - integer. */
- LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
+ LONGEST sz = TYPE_LENGTH (check_typedef (POINTER_TARGET_TYPE (type1)));
return value_from_pointer (VALUE_TYPE (arg1),
(value_as_pointer (arg1)
- (sz * value_as_long (arg2))));
}
else if (TYPE_CODE (type2) == TYPE_CODE_PTR
- && TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)))
- == TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type2))))
+ && TYPE_LENGTH (check_typedef (POINTER_TARGET_TYPE (type1)))
+ == TYPE_LENGTH (check_typedef (POINTER_TARGET_TYPE (type2))))
{
/* pointer to <type x> - pointer to <type x>. */
- LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
+ LONGEST sz = TYPE_LENGTH (check_typedef (POINTER_TARGET_TYPE (type1)));
return value_from_longest
(builtin_type_long, /* FIXME -- should be ptrdiff_t */
(value_as_long (arg1) - value_as_long (arg2)) / sz);
@@ -148,9 +148,10 @@ value_subscript (value_ptr array, value_ptr idx)
if (TYPE_CODE (tarray) == TYPE_CODE_ARRAY
|| TYPE_CODE (tarray) == TYPE_CODE_STRING)
{
- struct type *range_type = TYPE_INDEX_TYPE (tarray);
+ struct range_type *range_type = ARRAY_RANGE_TYPE (tarray);
LONGEST lowerbound, upperbound;
- get_discrete_bounds (range_type, &lowerbound, &upperbound);
+ lowerbound = RANGE_LOWER_BOUND (range_type);
+ upperbound = RANGE_UPPER_BOUND (range_type);
if (VALUE_LVAL (array) != lval_memory)
return value_subscripted_rvalue (array, idx, lowerbound);
@@ -173,15 +174,15 @@ value_subscript (value_ptr array, value_ptr idx)
array = value_coerce_array (array);
}
-
if (TYPE_CODE (tarray) == TYPE_CODE_BITSTRING)
{
- struct type *range_type = TYPE_INDEX_TYPE (tarray);
+ struct range_type *range_type = SET_RANGE_TYPE (tarray);
LONGEST index = value_as_long (idx);
value_ptr v;
int offset, byte, bit_index;
LONGEST lowerbound, upperbound;
- get_discrete_bounds (range_type, &lowerbound, &upperbound);
+ lowerbound = RANGE_LOWER_BOUND (range_type);
+ upperbound = RANGE_UPPER_BOUND (range_type);
if (index < lowerbound || index > upperbound)
error ("bitstring index out of range");
index -= lowerbound;
@@ -1335,8 +1336,10 @@ value_bit_index (struct type *type, char *valaddr, int index)
LONGEST low_bound, high_bound;
LONGEST word;
unsigned rel_index;
- struct type *range = TYPE_FIELD_TYPE (type, 0);
- if (get_discrete_bounds (range, &low_bound, &high_bound) < 0)
+ struct range_type *range = SET_RANGE_TYPE (type);
+ low_bound = RANGE_LOWER_BOUND (range);
+ high_bound = RANGE_UPPER_BOUND (range);
+ if (low_bound < 0 || high_bound < 0)
return -2;
if (index < low_bound || index > high_bound)
return -1;
@@ -1356,7 +1359,7 @@ value_in (value_ptr element, value_ptr set)
struct type *settype = check_typedef (VALUE_TYPE (set));
struct type *eltype = check_typedef (VALUE_TYPE (element));
if (TYPE_CODE (eltype) == TYPE_CODE_RANGE)
- eltype = TYPE_TARGET_TYPE (eltype);
+ eltype = RANGE_INDEX_TYPE (eltype);
if (TYPE_CODE (settype) != TYPE_CODE_SET)
error ("Second argument of 'IN' has wrong type");
if (TYPE_CODE (eltype) != TYPE_CODE_INT
diff --git a/gdb/valops.c b/gdb/valops.c
index 7cc025d4eff..b3515d274b2 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -30,6 +30,7 @@
#include "demangle.h"
#include "language.h"
#include "gdbcmd.h"
+#include "cp-abi.h"
#include "regcache.h"
#include "cp-abi.h"
@@ -43,6 +44,12 @@ extern int hp_som_som_object_present;
extern int overload_debug;
/* Local functions. */
+enum looking_for_baseclass_type
+ {
+ no_baseclass,
+ only_baseclass,
+ struct_or_baseclass
+ };
static int typecmp (int staticp, struct type *t1[], value_ptr t2[]);
static CORE_ADDR find_function_addr (value_ptr, struct type **);
@@ -50,11 +57,14 @@ static value_ptr value_arg_coerce (value_ptr, struct type *, int);
static CORE_ADDR value_push (CORE_ADDR, value_ptr);
-
-static value_ptr search_struct_field (char *, value_ptr, int,
- struct type *, int);
-
-static value_ptr search_struct_method (char *, value_ptr *,
+static value_ptr
+search_struct_field (const char *, value_ptr, int, struct type *,
+ enum looking_for_baseclass_type, char *);
+static value_ptr
+search_struct_field_aux (const char *, value_ptr, int, struct type *,
+ enum looking_for_baseclass_type,
+ int *, char *, struct type **, char *);
+static value_ptr search_struct_method (const char *, value_ptr *,
value_ptr *,
int, int *, struct type *);
@@ -113,7 +123,7 @@ find_function_in_inferior (char *name)
struct type *type;
CORE_ADDR maddr;
type = lookup_pointer_type (builtin_type_char);
- type = lookup_function_type (type);
+ type = (struct type *)make_function_type (NULL, type, 0, NULL, 0);
type = lookup_pointer_type (type);
maddr = SYMBOL_VALUE_ADDRESS (msymbol);
return value_from_pointer (type, maddr);
@@ -183,10 +193,11 @@ value_cast (struct type *type, register value_ptr arg2)
where N is sizeof(OBJECT)/sizeof(TYPE). */
if (code1 == TYPE_CODE_ARRAY)
{
- struct type *element_type = TYPE_TARGET_TYPE (type);
+ struct type *element_type = ARRAY_ELEMENT_TYPE (type);
unsigned element_length = TYPE_LENGTH (check_typedef (element_type));
- if (element_length > 0
- && TYPE_ARRAY_UPPER_BOUND_TYPE (type) == BOUND_CANNOT_BE_DETERMINED)
+#if TYPEFIX
+ if (current_language->la_language == language_fortran && element_length > 0
+ && TYPE_ARRAY_UPPER_BOUND_TYPE (type) == BT_cannot_be_determined)
{
struct type *range_type = TYPE_INDEX_TYPE (type);
int val_length = TYPE_LENGTH (type2);
@@ -196,7 +207,7 @@ value_cast (struct type *type, register value_ptr arg2)
new_length = val_length / element_length;
if (val_length % element_length != 0)
warning ("array element type size does not divide object size in cast");
- /* FIXME-type-allocation: need a way to free this type when we are
+ /* TYPEFIX-type-allocation: need a way to free this type when we are
done with it. */
range_type = create_range_type ((struct type *) NULL,
TYPE_TARGET_TYPE (range_type),
@@ -206,6 +217,7 @@ value_cast (struct type *type, register value_ptr arg2)
element_type, range_type);
return arg2;
}
+#endif
}
if (current_language->c_style_arrays
@@ -242,7 +254,7 @@ value_cast (struct type *type, register value_ptr arg2)
type of the target as a superclass. If so, we'll need to
offset the object in addition to changing its type. */
value_ptr v = search_struct_field (type_name_no_tag (type),
- arg2, 0, type2, 1);
+ arg2, 0, type2, only_baseclass, 0);
if (v)
{
VALUE_TYPE (v) = type;
@@ -263,7 +275,7 @@ value_cast (struct type *type, register value_ptr arg2)
unsigned int *ptr;
value_ptr retvalp;
- switch (TYPE_CODE (TYPE_TARGET_TYPE (type2)))
+ switch (TYPE_CODE (POINTER_TARGET_TYPE (type2)))
{
/* With HP aCC, pointers to data members have a bias */
case TYPE_CODE_MEMBER:
@@ -314,8 +326,8 @@ value_cast (struct type *type, register value_ptr arg2)
{
if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
{
- struct type *t1 = check_typedef (TYPE_TARGET_TYPE (type));
- struct type *t2 = check_typedef (TYPE_TARGET_TYPE (type2));
+ struct type *t1 = check_typedef (POINTER_TARGET_TYPE (type));
+ struct type *t2 = check_typedef (POINTER_TARGET_TYPE (type2));
if (TYPE_CODE (t1) == TYPE_CODE_STRUCT
&& TYPE_CODE (t2) == TYPE_CODE_STRUCT
&& !value_logical_not (arg2))
@@ -328,7 +340,7 @@ value_cast (struct type *type, register value_ptr arg2)
if (TYPE_NAME (t1) != NULL)
{
v = search_struct_field (type_name_no_tag (t1),
- value_ind (arg2), 0, t2, 1);
+ value_ind (arg2), 0, t2, only_baseclass, 0);
if (v)
{
v = value_addr (v);
@@ -344,7 +356,7 @@ value_cast (struct type *type, register value_ptr arg2)
if (TYPE_NAME (t2) != NULL)
{
v = search_struct_field (type_name_no_tag (t2),
- value_zero (t1, not_lval), 0, t1, 1);
+ value_zero (t1, not_lval), 0, t1, only_baseclass, 0);
if (v)
{
value_ptr v2 = value_ind (arg2);
@@ -369,6 +381,7 @@ value_cast (struct type *type, register value_ptr arg2)
VALUE_POINTED_TO_OFFSET (arg2) = 0; /* pai: chk_val */
return arg2;
}
+#if TYPEFIX
else if (chill_varying_type (type))
{
struct type *range1, *range2, *eltype1, *eltype2;
@@ -412,6 +425,7 @@ value_cast (struct type *type, register value_ptr arg2)
(count1 - count2) * TYPE_LENGTH (eltype2));
return val;
}
+#endif
else if (VALUE_LVAL (arg2) == lval_memory)
{
return value_at_lazy (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2),
@@ -465,8 +479,8 @@ value_at (struct type *type, CORE_ADDR addr, asection *sect)
if (GDB_TARGET_IS_D10V
&& TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_TARGET_TYPE (type)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
+ && POINTER_TARGET_TYPE (type)
+ && (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
{
/* pointer to function */
unsigned long num;
@@ -536,8 +550,8 @@ value_fetch_lazy (register value_ptr val)
struct type *type = VALUE_TYPE (val);
if (GDB_TARGET_IS_D10V
&& TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_TARGET_TYPE (type)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
+ && POINTER_TARGET_TYPE (type)
+ && (TYPE_CODE (POINTER_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
{
/* pointer to function */
unsigned long num;
@@ -1001,13 +1015,13 @@ value_ind (value_ptr arg1)
/* We may be pointing to something embedded in a larger object */
/* Get the real type of the enclosing object */
enc_type = check_typedef (VALUE_ENCLOSING_TYPE (arg1));
- enc_type = TYPE_TARGET_TYPE (enc_type);
+ enc_type = POINTER_TARGET_TYPE (enc_type);
/* Retrieve the enclosing object pointed to */
arg2 = value_at_lazy (enc_type,
value_as_pointer (arg1) - VALUE_POINTED_TO_OFFSET (arg1),
VALUE_BFD_SECTION (arg1));
/* Re-adjust type */
- VALUE_TYPE (arg2) = TYPE_TARGET_TYPE (base_type);
+ VALUE_TYPE (arg2) = POINTER_TARGET_TYPE (base_type);
/* Add embedding info */
arg2 = value_change_enclosing_type (arg2, enc_type);
VALUE_EMBEDDED_OFFSET (arg2) = VALUE_POINTED_TO_OFFSET (arg1);
@@ -1211,7 +1225,7 @@ value_arg_coerce (value_ptr arg, struct type *param_type, int is_prototyped)
break;
case TYPE_CODE_ARRAY:
if (current_language->c_style_arrays)
- type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
+ type = lookup_pointer_type (ARRAY_ELEMENT_TYPE (type));
break;
case TYPE_CODE_UNDEF:
case TYPE_CODE_PTR:
@@ -1248,7 +1262,12 @@ find_function_addr (value_ptr function, struct type **retval_type)
part of it. */
/* Determine address to call. */
- if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
+ if (code == TYPE_CODE_FUNC)
+ {
+ funaddr = VALUE_ADDRESS (function);
+ value_type = FUNCTION_RETURN_VALUE (ftype);
+ }
+ else if (code == TYPE_CODE_METHOD)
{
funaddr = VALUE_ADDRESS (function);
value_type = TYPE_TARGET_TYPE (ftype);
@@ -1256,9 +1275,13 @@ find_function_addr (value_ptr function, struct type **retval_type)
else if (code == TYPE_CODE_PTR)
{
funaddr = value_as_pointer (function);
- ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
- if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
- || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
+ ftype = check_typedef (POINTER_TARGET_TYPE (ftype));
+ if (TYPE_CODE (ftype) == TYPE_CODE_FUNC)
+ {
+ funaddr =CONVERT_FROM_FUNC_PTR_ADDR (funaddr);
+ value_type = FUNCTION_RETURN_VALUE (ftype);
+ }
+ else if (TYPE_CODE (ftype) == TYPE_CODE_METHOD)
{
funaddr = CONVERT_FROM_FUNC_PTR_ADDR (funaddr);
value_type = TYPE_TARGET_TYPE (ftype);
@@ -1476,7 +1499,7 @@ hand_function_call (value_ptr function, int nargs, value_ptr *args)
if (param_type)
/* if this parameter is a pointer to function */
if (TYPE_CODE (param_type) == TYPE_CODE_PTR)
- if (TYPE_CODE (param_type->target_type) == TYPE_CODE_FUNC)
+ if (TYPE_CODE (POINTER_TARGET_TYPE(param_type)) == TYPE_CODE_FUNC)
/* elz: FIXME here should go the test about the compiler used
to compile the target. We want to issue the error
message only if the compiler used was HP's aCC.
@@ -1817,7 +1840,7 @@ value_array (int lowbound, int highbound, value_ptr *elemvec)
int idx;
unsigned int typelength;
value_ptr val;
- struct type *rangetype;
+ struct range_type *rangetype;
struct type *arraytype;
CORE_ADDR addr;
@@ -1838,9 +1861,9 @@ value_array (int lowbound, int highbound, value_ptr *elemvec)
}
}
- rangetype = create_range_type ((struct type *) NULL, builtin_type_int,
+ rangetype = make_range_type (NULL, builtin_type_int,
lowbound, highbound);
- arraytype = create_array_type ((struct type *) NULL,
+ arraytype = (struct type *)make_array_type (NULL,
VALUE_ENCLOSING_TYPE (elemvec[0]), rangetype);
if (!current_language->c_style_arrays)
@@ -1887,11 +1910,9 @@ value_string (char *ptr, int len)
{
value_ptr val;
int lowbound = current_language->string_lower_bound;
- struct type *rangetype = create_range_type ((struct type *) NULL,
- builtin_type_int,
- lowbound, len + lowbound - 1);
- struct type *stringtype
- = create_string_type ((struct type *) NULL, rangetype);
+ struct range_type *rangetype = make_range_type (NULL, builtin_type_int,
+ lowbound, len + lowbound - 1);
+ struct type *stringtype = (struct type *)make_string_type (NULL, rangetype);
CORE_ADDR addr;
if (current_language->c_style_arrays == 0)
@@ -1916,9 +1937,8 @@ value_ptr
value_bitstring (char *ptr, int len)
{
value_ptr val;
- struct type *domain_type = create_range_type (NULL, builtin_type_int,
- 0, len - 1);
- struct type *type = create_set_type ((struct type *) NULL, domain_type);
+ struct range_type *domain_type = make_range_type (NULL, builtin_type_int, 0, len - 1);
+ struct type *type = (struct type *)make_set_type (NULL, domain_type);
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
val = allocate_value (type);
memcpy (VALUE_CONTENTS_RAW (val), ptr, TYPE_LENGTH (type));
@@ -1982,13 +2002,16 @@ typecmp (int staticp, struct type *t1[], value_ptr t2[])
while ( TYPE_CODE(tt1) == TYPE_CODE_REF ||
TYPE_CODE (tt1) == TYPE_CODE_PTR)
{
- tt1 = check_typedef( TYPE_TARGET_TYPE(tt1) );
+ tt1 = check_typedef( POINTER_TARGET_TYPE(tt1) );
}
while ( TYPE_CODE(tt2) == TYPE_CODE_ARRAY ||
TYPE_CODE(tt2) == TYPE_CODE_PTR ||
TYPE_CODE(tt2) == TYPE_CODE_REF)
{
- tt2 = check_typedef( TYPE_TARGET_TYPE(tt2) );
+ while (TYPE_CODE (tt2) == TYPE_CODE_REF || TYPE_CODE (tt2) == TYPE_CODE_PTR)
+ tt2 = check_typedef (POINTER_TARGET_TYPE (tt2));
+ while (TYPE_CODE (tt2) == TYPE_CODE_ARRAY)
+ tt2 = check_typedef (ARRAY_ELEMENT_TYPE (tt2));
}
if (TYPE_CODE (tt1) == TYPE_CODE (tt2))
continue;
@@ -2010,34 +2033,123 @@ typecmp (int staticp, struct type *t1[], value_ptr t2[])
and search in it assuming it has (class) type TYPE.
If found, return value, else return NULL.
- If LOOKING_FOR_BASECLASS, then instead of looking for struct fields,
- look for a baseclass named NAME. */
+ looking_for_baseclass has three possible values :
+ 1) no_baseclass : look for structure field.
+ 2) only_baseclass : look for baseclass named NAME.
+ 3) struct_or_baseclass : look for structure field first, and then
+ the baseclass named NAME. Return the first
+ structure field if it is found.
+ The value is used when hp_som_som_object_present
+ is true. */
static value_ptr
-search_struct_field (char *name, register value_ptr arg1, int offset,
- register struct type *type, int looking_for_baseclass)
+search_struct_field (name, arg1, offset, type, looking_for_baseclass,
+ domain_name)
+ const char *name;
+ register value_ptr arg1;
+ int offset;
+ register struct type *type;
+ enum looking_for_baseclass_type looking_for_baseclass;
+ char *domain_name;
+{
+ int found = 0;
+ char found_class[1024];
+ value_ptr v;
+ struct type *vbase = NULL;
+
+ found_class[0] = '\000';
+
+ v = search_struct_field_aux (name, arg1, offset, type,
+ looking_for_baseclass, &found,
+ found_class, &vbase, domain_name);
+ if (found > 1)
+ warning ("%s ambiguous; using %s::%s. Use a cast to disambiguate.",
+ name, found_class, name);
+
+ return v;
+}
+
+static value_ptr
+search_struct_field_aux (name, arg1, offset, type,
+ looking_for_baseclass, found,
+ found_class_name, vbase, domain_name)
+ const char *name;
+ value_ptr arg1;
+ int offset;
+ register struct type *type;
+ enum looking_for_baseclass_type looking_for_baseclass;
+ int *found;
+ char *found_class_name;
+ struct type **vbase;
+ char *domain_name;
{
int i;
+ value_ptr retval = NULL;
+ char tmp_class_name[1024];
+ int tmp_found = 0;
+ int assigned = 0;
int nbases = TYPE_N_BASECLASSES (type);
+ tmp_class_name[0] = '\000';
+
CHECK_TYPEDEF (type);
- if (!looking_for_baseclass)
+ if (looking_for_baseclass == no_baseclass ||
+ looking_for_baseclass == struct_or_baseclass)
for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--)
{
char *t_field_name = TYPE_FIELD_NAME (type, i);
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
{
- value_ptr v;
+ value_ptr v = NULL;
if (TYPE_FIELD_STATIC (type, i))
v = value_static_field (type, i);
+ if (v != NULL)
+ {
+ if (!*found)
+ {
+ /* Record return value and class name, and continue
+ looking for possible ambiguous members */
+ char *class_name = TYPE_TAG_NAME (type);
+ retval = v;
+ if (class_name)
+ strcpy (found_class_name, class_name);
+ else
+ found_class_name = NULL;
+ }
+ (*found)++;
+ }
else
- v = value_primitive_field (arg1, offset, i, type);
- if (v == 0)
- error ("there is no field named %s", name);
- return v;
- }
+ {
+ char *fullname = (domain_name ?
+ (strncmp (domain_name, "data member of", 14) ?
+ NULL : &domain_name[15])
+ : NULL );
+ if (!fullname || !strcmp(TYPE_TAG_NAME(type), fullname))
+ {
+ v = value_primitive_field (arg1, offset, i, type);
+ if (v != NULL)
+ {
+ if (!*found)
+ {
+ /* Record return value and class name, and continue
+ looking for possible ambiguous members */
+ char *class_name = TYPE_TAG_NAME (type);
+ retval = v;
+ if (class_name)
+ strcpy (found_class_name, class_name);
+ else
+ found_class_name = NULL;
+ }
+ (*found)++;
+ }
+ }
+ }
+
+ if (v == 0 && looking_for_baseclass != struct_or_baseclass)
+ error ("Couldn't retrieve field named %s", name);
+ }
if (t_field_name
&& (t_field_name[0] == '\0'
@@ -2070,14 +2182,40 @@ search_struct_field (char *name, register value_ptr arg1, int offset,
&& TYPE_FIELD_BITPOS (field_type, 0) == 0))
new_offset += TYPE_FIELD_BITPOS (type, i) / 8;
- v = search_struct_field (name, arg1, new_offset, field_type,
- looking_for_baseclass);
- if (v)
- return v;
- }
- }
+ v = search_struct_field_aux (name, arg1, new_offset,
+ field_type,
+ looking_for_baseclass,
+ &tmp_found, tmp_class_name,
+ vbase, domain_name);
+ if (!*found && v)
+ {
+ /* Record return value and class name, and continue
+ looking for possible ambiguous members */
+ retval = v;
+ /* TYPE_TAG_NAME can be null in case of an anonymous union */
+ if (TYPE_TAG_NAME (type))
+ strcpy (found_class_name, TYPE_TAG_NAME (type));
+ else
+ strcpy (found_class_name, " ");
+ strcat (found_class_name, "::");
+ strcat (found_class_name, tmp_class_name);
+ }
+ *found += tmp_found;
+ tmp_found = 0;
+ }
+ }
}
+ /* Return the structure field if it is found. */
+ if (*found > 0 && looking_for_baseclass == struct_or_baseclass)
+ return retval;
+
+ /* RM: If we are looking for a structure field, and we have found
+ one, don't look through the baseclasses -- names there are
+ hidden. ANSI C++ standard, section 10.2 */
+ if (*found > 0 && looking_for_baseclass == no_baseclass)
+ return retval;
+
for (i = 0; i < nbases; i++)
{
value_ptr v;
@@ -2092,12 +2230,12 @@ search_struct_field (char *name, register value_ptr arg1, int offset,
if (BASETYPE_VIA_VIRTUAL (type, i))
{
int boffset;
- value_ptr v2 = allocate_value (basetype);
+ value_ptr v2 = allocate_value (VALUE_ENCLOSING_TYPE (arg1));
boffset = baseclass_offset (type, i,
- VALUE_CONTENTS (arg1) + offset,
+ &arg1, VALUE_CONTENTS (arg1) + offset,
VALUE_ADDRESS (arg1)
- + VALUE_OFFSET (arg1) + offset);
+ + VALUE_OFFSET (arg1) + offset, offset);
if (boffset == -1)
error ("virtual baseclass botch");
@@ -2110,12 +2248,13 @@ search_struct_field (char *name, register value_ptr arg1, int offset,
{
CORE_ADDR base_addr;
- base_addr = VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1) + boffset;
+ base_addr = VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1) + boffset;
if (target_read_memory (base_addr, VALUE_CONTENTS_RAW (v2),
TYPE_LENGTH (basetype)) != 0)
error ("virtual baseclass botch");
VALUE_LVAL (v2) = lval_memory;
VALUE_ADDRESS (v2) = base_addr;
+ assigned = 1;
}
else
{
@@ -2129,113 +2268,125 @@ search_struct_field (char *name, register value_ptr arg1, int offset,
VALUE_CONTENTS_RAW (arg1) + boffset,
TYPE_LENGTH (basetype));
}
-
- if (found_baseclass)
- return v2;
- v = search_struct_field (name, v2, 0, TYPE_BASECLASS (type, i),
- looking_for_baseclass);
- }
+#if 0
+ if (!assigned)
+ {
+ VALUE_LVAL (v2) = VALUE_LVAL (arg1);
+ VALUE_ADDRESS (v2) = VALUE_ADDRESS (arg1);
+ }
+ /* Earlier, this code used to allocate a value of type
+ basetype and copy the contents of arg1 at the
+ appropriate offset into the new value. This doesn't
+ work because there is important stuff (virtual bases,
+ for example) that could be anywhere in the contents
+ of arg1, and not just within the length of a basetype
+ object. In particular the boffset below could be
+ negative, with the HP/Taligent C++ runtime system.
+ So, the only way to ensure that required information
+ is not lost is to always allocate a value of the same
+ type as arg1 and to fill it with the _entire_
+ contents of arg1. It sounds wasteful, but there is
+ really no way around it if later member lookup,
+ casts, etc. have to work correctly with the returned
+ value. */
+
+
+ VALUE_TYPE (v2) = basetype;
+ VALUE_OFFSET (v2) = VALUE_OFFSET (arg1);
+ VALUE_EMBEDDED_OFFSET (v2)
+ = VALUE_EMBEDDED_OFFSET (arg1) + offset + boffset;
+ if (VALUE_LAZY (arg1))
+ VALUE_LAZY (v2) = 1;
+ else
+ memcpy ((char *) (v2)->aligner.contents,
+ (char *) (arg1)->aligner.contents,
+ TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg1)));
+#endif
+ if (found_baseclass)
+ {
+ /*return v2; */
+
+ if (!*found) /* not yet found anything */
+ {
+ /* Record return value and class name, and continue
+ looking for possible ambiguous members */
+ retval = v2;
+ strcpy (found_class_name, TYPE_TAG_NAME (type));
+ }
+ /* Don't count virtual bases twice when deciding ambiguity */
+ if (*vbase != basetype) /* works for null *vbase */
+ (*found)++;
+ /* Is this the first virtual base where we "found" something? */
+ if (!*vbase)
+ *vbase = basetype;
+ }
+ else
+ /* base not found, or looking for member */
+ {
+ v = search_struct_field_aux (name, /*arg1*/v2, 0/*offset + boffset*/,
+ TYPE_BASECLASS (type, i),
+ looking_for_baseclass, &tmp_found,
+ tmp_class_name, vbase, domain_name);
+ if (!*found && v)
+ {
+ /* Record return value and class name, and continue
+ looking for possible ambiguous members */
+ retval = v;
+ /* TYPE_TAG_NAME can be null in case of an anonymous union */
+ if (TYPE_TAG_NAME (type))
+ strcpy (found_class_name, TYPE_TAG_NAME (type));
+ else
+ strcpy (found_class_name, " ");
+ strcat (found_class_name, "::");
+ strcat (found_class_name, tmp_class_name);
+ }
+ /* Don't count virtual bases twice when deciding ambiguity */
+ if (*vbase != basetype) /* works for null *vbase */
+ *found += tmp_found;
+ /* Is this the first virtual base where we "found" something? */
+ if (!*vbase)
+ *vbase = basetype;
+ tmp_found = 0;
+ }
+ }
else if (found_baseclass)
- v = value_primitive_field (arg1, offset, i, type);
+ {
+ v = value_primitive_field (arg1, offset, i, type);
+ if (!*found)
+ {
+ /* Record return value and class name, and continue
+ looking for possible ambiguous members */
+ retval = v;
+ strcpy (found_class_name, TYPE_TAG_NAME (type));
+ }
+ (*found)++;
+ }
else
- v = search_struct_field (name, arg1,
- offset + TYPE_BASECLASS_BITPOS (type, i) / 8,
- basetype, looking_for_baseclass);
- if (v)
- return v;
- }
- return NULL;
-}
-
-
-/* Return the offset (in bytes) of the virtual base of type BASETYPE
- * in an object pointed to by VALADDR (on the host), assumed to be of
- * type TYPE. OFFSET is number of bytes beyond start of ARG to start
- * looking (in case VALADDR is the contents of an enclosing object).
- *
- * This routine recurses on the primary base of the derived class because
- * the virtual base entries of the primary base appear before the other
- * virtual base entries.
- *
- * If the virtual base is not found, a negative integer is returned.
- * The magnitude of the negative integer is the number of entries in
- * the virtual table to skip over (entries corresponding to various
- * ancestral classes in the chain of primary bases).
- *
- * Important: This assumes the HP / Taligent C++ runtime
- * conventions. Use baseclass_offset() instead to deal with g++
- * conventions. */
-
-void
-find_rt_vbase_offset (struct type *type, struct type *basetype, char *valaddr,
- int offset, int *boffset_p, int *skip_p)
-{
- int boffset; /* offset of virtual base */
- int index; /* displacement to use in virtual table */
- int skip;
-
- value_ptr vp;
- CORE_ADDR vtbl; /* the virtual table pointer */
- struct type *pbc; /* the primary base class */
-
- /* Look for the virtual base recursively in the primary base, first.
- * This is because the derived class object and its primary base
- * subobject share the primary virtual table. */
-
- boffset = 0;
- pbc = TYPE_PRIMARY_BASE (type);
- if (pbc)
- {
- find_rt_vbase_offset (pbc, basetype, valaddr, offset, &boffset, &skip);
- if (skip < 0)
- {
- *boffset_p = boffset;
- *skip_p = -1;
- return;
- }
- }
- else
- skip = 0;
-
-
- /* Find the index of the virtual base according to HP/Taligent
- runtime spec. (Depth-first, left-to-right.) */
- index = virtual_base_index_skip_primaries (basetype, type);
-
- if (index < 0)
- {
- *skip_p = skip + virtual_base_list_length_skip_primaries (type);
- *boffset_p = 0;
- return;
+ {
+ v = search_struct_field_aux (name, arg1,
+ offset + TYPE_BASECLASS_BITPOS (type, i) / 8,
+ basetype, looking_for_baseclass, &tmp_found,
+ tmp_class_name, vbase, domain_name);
+ if (!*found && v)
+ {
+ /* Record return value and class name, and continue
+ looking for possible ambiguous members */
+ retval = v;
+ /* TYPE_TAG_NAME can be null in case of an anonymous union */
+ if (TYPE_TAG_NAME (type))
+ strcpy (found_class_name, TYPE_TAG_NAME (type));
+ else
+ strcpy (found_class_name, " ");
+ strcat (found_class_name, "::");
+ strcat (found_class_name, tmp_class_name);
+ }
+ *found += tmp_found;
+ tmp_found = 0;
+ }
}
-
- /* pai: FIXME -- 32x64 possible problem */
- /* First word (4 bytes) in object layout is the vtable pointer */
- vtbl = *(CORE_ADDR *) (valaddr + offset);
-
- /* Before the constructor is invoked, things are usually zero'd out. */
- if (vtbl == 0)
- error ("Couldn't find virtual table -- object may not be constructed yet.");
-
-
- /* Find virtual base's offset -- jump over entries for primary base
- * ancestors, then use the index computed above. But also adjust by
- * HP_ACC_VBASE_START for the vtable slots before the start of the
- * virtual base entries. Offset is negative -- virtual base entries
- * appear _before_ the address point of the virtual table. */
-
- /* pai: FIXME -- 32x64 problem, if word = 8 bytes, change multiplier
- & use long type */
-
- /* epstein : FIXME -- added param for overlay section. May not be correct */
- vp = value_at (builtin_type_int, vtbl + 4 * (-skip - index - HP_ACC_VBASE_START), NULL);
- boffset = value_as_long (vp);
- *skip_p = -1;
- *boffset_p = boffset;
- return;
+ return retval;
}
-
/* Helper function used by value_struct_elt to recurse through baseclasses.
Look for a field NAME in ARG1. Adjust the address of ARG1 by OFFSET bytes,
and search in it assuming it has (class) type TYPE.
@@ -2243,7 +2394,7 @@ find_rt_vbase_offset (struct type *type, struct type *basetype, char *valaddr,
else return NULL. */
static value_ptr
-search_struct_method (char *name, register value_ptr *arg1p,
+search_struct_method (const char *name, register value_ptr *arg1p,
register value_ptr *args, int offset,
int *static_memfuncp, register struct type *type)
{
@@ -2300,46 +2451,31 @@ search_struct_method (char *name, register value_ptr *arg1p,
if (BASETYPE_VIA_VIRTUAL (type, i))
{
- if (TYPE_HAS_VTABLE (type))
- {
- /* HP aCC compiled type, search for virtual base offset
- according to HP/Taligent runtime spec. */
- int skip;
- find_rt_vbase_offset (type, TYPE_BASECLASS (type, i),
- VALUE_CONTENTS_ALL (*arg1p),
- offset + VALUE_EMBEDDED_OFFSET (*arg1p),
- &base_offset, &skip);
- if (skip >= 0)
- error ("Virtual base class offset not found in vtable");
- }
- else
+ struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
+ char *base_valaddr;
+
+ /* The virtual base class pointer might have been clobbered by the
+ user program. Make sure that it still points to a valid memory
+ location. */
+
+ if (offset < 0 || offset >= TYPE_LENGTH (type))
{
- struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
- char *base_valaddr;
-
- /* The virtual base class pointer might have been clobbered by the
- user program. Make sure that it still points to a valid memory
- location. */
-
- if (offset < 0 || offset >= TYPE_LENGTH (type))
- {
- base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
- if (target_read_memory (VALUE_ADDRESS (*arg1p)
- + VALUE_OFFSET (*arg1p) + offset,
- base_valaddr,
- TYPE_LENGTH (baseclass)) != 0)
- error ("virtual baseclass botch");
- }
- else
- base_valaddr = VALUE_CONTENTS (*arg1p) + offset;
-
- base_offset =
- baseclass_offset (type, i, base_valaddr,
- VALUE_ADDRESS (*arg1p)
- + VALUE_OFFSET (*arg1p) + offset);
- if (base_offset == -1)
+ base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
+ if (target_read_memory (VALUE_ADDRESS (*arg1p)
+ + VALUE_OFFSET (*arg1p) + offset,
+ base_valaddr,
+ TYPE_LENGTH (baseclass)) != 0)
error ("virtual baseclass botch");
}
+ else
+ base_valaddr = VALUE_CONTENTS (*arg1p) + offset;
+
+ base_offset =
+ baseclass_offset (type, i, arg1p, base_valaddr,
+ VALUE_ADDRESS (*arg1p)
+ + VALUE_OFFSET (*arg1p) + offset, offset);
+ if (base_offset == -1)
+ error ("virtual baseclass botch");
}
else
{
@@ -2414,13 +2550,20 @@ value_struct_elt (register value_ptr *argp, register value_ptr *args,
if (!args)
{
/* if there are no arguments ...do this... */
-
+
/* Try as a field first, because if we succeed, there
is less work to be done. */
- v = search_struct_field (name, *argp, 0, t, 0);
+ if (strncmp (err, "data member", 11))
+ {
+ v = search_struct_field (name, *argp, VALUE_EMBEDDED_OFFSET (*argp), t, no_baseclass, NULL);
+ }
+ else
+ {
+ v = search_struct_field (name, *argp, VALUE_EMBEDDED_OFFSET (*argp), t, struct_or_baseclass, err);
+ }
if (v)
return v;
-
+
/* C++: If it was not found as a data field, then try to
return it as a pointer to a method. */
@@ -2476,7 +2619,7 @@ value_struct_elt (register value_ptr *argp, register value_ptr *args,
/* See if user tried to invoke data as function. If so,
hand it back. If it's not callable (i.e., a pointer to function),
gdb should give an error. */
- v = search_struct_field (name, *argp, 0, t, 0);
+ v = search_struct_field (name, *argp, 0, t, no_baseclass, NULL);
}
if (!v)
@@ -2528,29 +2671,13 @@ find_method_list (value_ptr *argp, char *method, int offset,
int base_offset;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
- if (TYPE_HAS_VTABLE (type))
- {
- /* HP aCC compiled type, search for virtual base offset
- * according to HP/Taligent runtime spec. */
- int skip;
- find_rt_vbase_offset (type, TYPE_BASECLASS (type, i),
- VALUE_CONTENTS_ALL (*argp),
- offset + VALUE_EMBEDDED_OFFSET (*argp),
- &base_offset, &skip);
- if (skip >= 0)
- error ("Virtual base class offset not found in vtable");
- }
- else
- {
- /* probably g++ runtime model */
- base_offset = VALUE_OFFSET (*argp) + offset;
- base_offset =
- baseclass_offset (type, i,
- VALUE_CONTENTS (*argp) + base_offset,
- VALUE_ADDRESS (*argp) + base_offset);
- if (base_offset == -1)
- error ("virtual baseclass botch");
- }
+ base_offset = VALUE_OFFSET (*argp) + offset;
+ base_offset =
+ baseclass_offset (type, i, argp,
+ VALUE_CONTENTS (*argp) + base_offset,
+ VALUE_ADDRESS (*argp) + base_offset, offset);
+ if (base_offset == -1)
+ error ("virtual baseclass botch");
}
else
/* non-virtual base, simply use bit position from debug info */
@@ -2664,7 +2791,7 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method,
register int jj;
register int ix;
- char *obj_type_name = NULL;
+ const char *obj_type_name = NULL;
char *func_name = NULL;
/* Get the list of overloaded methods or functions */
@@ -2678,7 +2805,7 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method,
value rather than the object itself, so try again */
if ((!obj_type_name || !*obj_type_name) &&
(TYPE_CODE (VALUE_TYPE (obj)) == TYPE_CODE_PTR))
- obj_type_name = TYPE_NAME (TYPE_TARGET_TYPE (VALUE_TYPE (obj)));
+ obj_type_name = TYPE_NAME (POINTER_TARGET_TYPE (VALUE_TYPE (obj)));
fns_ptr = value_find_oload_method_list (&temp, name, 0,
staticp,
@@ -2880,7 +3007,7 @@ destructor_name_p (const char *name, const struct type *type)
if (name[0] == '~')
{
- char *dname = type_name_no_tag (type);
+ const char *dname = type_name_no_tag (type);
char *cp = strchr (dname, '<');
unsigned int len;
@@ -2958,7 +3085,7 @@ check_field (register value_ptr arg1, const char *name)
CHECK_TYPEDEF (t);
if (TYPE_CODE (t) != TYPE_CODE_PTR && TYPE_CODE (t) != TYPE_CODE_REF)
break;
- t = TYPE_TARGET_TYPE (t);
+ t = POINTER_TARGET_TYPE (t);
}
if (TYPE_CODE (t) == TYPE_CODE_MEMBER)
@@ -2981,12 +3108,12 @@ check_field (register value_ptr arg1, const char *name)
value_ptr
value_struct_elt_for_reference (struct type *domain, int offset,
struct type *curtype, char *name,
- struct type *intype)
+ struct type *intype, int look_for_this)
{
register struct type *t = curtype;
register int i;
value_ptr v;
-
+
if (TYPE_CODE (t) != TYPE_CODE_STRUCT
&& TYPE_CODE (t) != TYPE_CODE_UNION)
error ("Internal error: non-aggregate type to value_struct_elt_for_reference");
@@ -2997,6 +3124,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
if (t_field_name && STREQ (t_field_name, name))
{
+ value_ptr argp;
if (TYPE_FIELD_STATIC (t, i))
{
v = value_static_field (t, i);
@@ -3007,14 +3135,28 @@ value_struct_elt_for_reference (struct type *domain, int offset,
}
if (TYPE_FIELD_PACKED (t, i))
error ("pointers to bitfield members not allowed");
-
+ if (look_for_this)
+ {
+ /* It can be a class data member. */
+ argp = value_of_this (1);
+ if (argp != 0)
+ {
+ char *class_name;
+ class_name = alloca (strlen (TYPE_TAG_NAME(domain)) +strlen ("data member of ")+1);
+ strcat (class_name, "data member of ");
+ strcat (class_name, TYPE_TAG_NAME(domain));
+ v = value_struct_elt (&argp, NULL, name, NULL, class_name);
+ if (v != 0)
+ return v;
+ }
+ }
return value_from_longest
(lookup_reference_type (lookup_member_type (TYPE_FIELD_TYPE (t, i),
domain)),
offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
}
}
-
+
/* C++: If it was not found as a data field, then try to
return it as a pointer to a method. */
@@ -3026,7 +3168,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
/* Perform all necessary dereferencing. */
while (intype && TYPE_CODE (intype) == TYPE_CODE_PTR)
- intype = TYPE_TARGET_TYPE (intype);
+ intype = POINTER_TARGET_TYPE (intype);
for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
{
@@ -3104,7 +3246,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
offset + base_offset,
TYPE_BASECLASS (t, i),
name,
- intype);
+ intype, look_for_this);
if (v)
return v;
}
@@ -3256,7 +3398,8 @@ value_of_this (int complain)
value_ptr
value_slice (value_ptr array, int lowbound, int length)
{
- struct type *slice_range_type, *slice_type, *range_type;
+ struct type *slice_type;
+ struct range_type *slice_range_type, *range_type;
LONGEST lowerbound, upperbound, offset;
value_ptr slice;
struct type *array_type;
@@ -3266,24 +3409,24 @@ value_slice (value_ptr array, int lowbound, int length)
&& TYPE_CODE (array_type) != TYPE_CODE_STRING
&& TYPE_CODE (array_type) != TYPE_CODE_BITSTRING)
error ("cannot take slice of non-array");
- range_type = TYPE_INDEX_TYPE (array_type);
- if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0)
- error ("slice from bad array or bitstring");
+ range_type = ARRAY_RANGE_TYPE (array_type);
+ lowerbound = RANGE_LOWER_BOUND (range_type);
+ upperbound = RANGE_UPPER_BOUND (range_type);
if (lowbound < lowerbound || length < 0
|| lowbound + length - 1 > upperbound
/* Chill allows zero-length strings but not arrays. */
|| (current_language->la_language == language_chill
&& length == 0 && TYPE_CODE (array_type) == TYPE_CODE_ARRAY))
error ("slice out of range");
- /* FIXME-type-allocation: need a way to free this type when we are
+ /* TYPEFIX-type-allocation: need a way to free this type when we are
done with it. */
- slice_range_type = create_range_type ((struct type *) NULL,
- TYPE_TARGET_TYPE (range_type),
+ slice_range_type = make_range_type (NULL,
+ RANGE_INDEX_TYPE (range_type),
lowbound, lowbound + length - 1);
if (TYPE_CODE (array_type) == TYPE_CODE_BITSTRING)
{
int i;
- slice_type = create_set_type ((struct type *) NULL, slice_range_type);
+ slice_type = (struct type *)make_set_type (NULL, slice_range_type);
TYPE_CODE (slice_type) = TYPE_CODE_BITSTRING;
slice = value_zero (slice_type, not_lval);
for (i = 0; i < length; i++)
@@ -3307,10 +3450,10 @@ value_slice (value_ptr array, int lowbound, int length)
}
else
{
- struct type *element_type = TYPE_TARGET_TYPE (array_type);
+ struct type *element_type = ARRAY_ELEMENT_TYPE (array_type);
offset
= (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type));
- slice_type = create_array_type ((struct type *) NULL, element_type,
+ slice_type = (struct type *)make_array_type (NULL, element_type,
slice_range_type);
TYPE_CODE (slice_type) = TYPE_CODE (array_type);
slice = allocate_value (slice_type);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 49c6cb882c1..951fa97db18 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1001,7 +1001,7 @@ val_print_array_elements (struct type *type, char *valaddr, CORE_ADDR address,
/* Number of repetitions we have detected so far. */
unsigned int reps;
- elttype = TYPE_TARGET_TYPE (type);
+ elttype = ARRAY_ELEMENT_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype));
len = TYPE_LENGTH (type) / eltlen;
diff --git a/gdb/value.h b/gdb/value.h
index 8b1d18f0b5d..36d07179b2d 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -374,7 +374,7 @@ extern value_ptr value_struct_elt_for_reference (struct type *domain,
int offset,
struct type *curtype,
char *name,
- struct type *intype);
+ struct type *intype, int look_for_this);
extern value_ptr value_static_field (struct type *type, int fieldno);
@@ -539,7 +539,6 @@ extern void clear_internalvars (void);
extern value_ptr value_copy (value_ptr);
-extern int baseclass_offset (struct type *, int, char *, CORE_ADDR);
/* From valops.c */
@@ -555,8 +554,6 @@ extern int standard_coerce_float_to_double (struct type *, struct type *);
extern value_ptr value_literal_complex (value_ptr, value_ptr, struct type *);
-extern void find_rt_vbase_offset (struct type *, struct type *, char *, int,
- int *, int *);
extern value_ptr find_function_in_inferior (char *);
diff --git a/gdb/values.c b/gdb/values.c
index 43ff194c160..f86bcc3ea11 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -108,14 +108,14 @@ value_ptr
allocate_repeat_value (struct type *type, int count)
{
int low_bound = current_language->string_lower_bound; /* ??? */
- /* FIXME-type-allocation: need a way to free this type when we are
+ /* TYPEFIX-type-allocation: need a way to free this type when we are
done with it. */
- struct type *range_type
- = create_range_type ((struct type *) NULL, builtin_type_int,
+ struct range_type *range_type
+ = make_range_type (NULL, builtin_type_int,
low_bound, count + low_bound - 1);
- /* FIXME-type-allocation: need a way to free this type when we are
+ /* TYPEFIX-type-allocation: need a way to free this type when we are
done with it. */
- return allocate_value (create_array_type ((struct type *) NULL,
+ return allocate_value ((struct type *)make_array_type (NULL,
type, range_type));
}
@@ -757,18 +757,18 @@ value_static_field (struct type *type, int fieldno)
}
else
{
- /* Anything static that isn't a constant, has an address */
- if (SYMBOL_CLASS (sym) != LOC_CONST)
- {
+ /* Anything static that isn't a constant, has an address */
+ if (SYMBOL_CLASS (sym) != LOC_CONST)
+ {
addr = SYMBOL_VALUE_ADDRESS (sym);
sect = SYMBOL_BFD_SECTION (sym);
+ }
+ /* However, static const's do not, the value is already known. */
+ else
+ {
+ return value_from_longest (TYPE_FIELD_TYPE (type, fieldno), SYMBOL_VALUE (sym));
}
- /* However, static const's do not, the value is already known. */
- else
- {
- return value_from_longest (TYPE_FIELD_TYPE (type, fieldno), SYMBOL_VALUE (sym));
- }
- }
+ }
SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), addr);
}
return value_at (TYPE_FIELD_TYPE (type, fieldno), addr, sect);
@@ -779,7 +779,7 @@ value_static_field (struct type *type, int fieldno)
is set by the length of the enclosing type. So if NEW_ENCL_TYPE is bigger
than the old enclosing type, you have to allocate more space for the data.
The return value is a pointer to the new version of this value structure. */
-
+
value_ptr
value_change_enclosing_type (value_ptr val, struct type *new_encl_type)
{
@@ -790,32 +790,31 @@ value_change_enclosing_type (value_ptr val, struct type *new_encl_type)
}
else
{
- value_ptr new_val;
- register value_ptr prev;
-
- new_val = (value_ptr) xrealloc (val, sizeof (struct value) + TYPE_LENGTH (new_encl_type));
-
- /* We have to make sure this ends up in the same place in the value
- chain as the original copy, so it's clean-up behavior is the same.
- If the value has been released, this is a waste of time, but there
- is no way to tell that in advance, so... */
-
- if (val != all_values)
- {
- for (prev = all_values; prev != NULL; prev = prev->next)
- {
- if (prev->next == val)
- {
- prev->next = new_val;
- break;
- }
- }
- }
-
- return new_val;
+ value_ptr new_val;
+ register value_ptr prev;
+
+ new_val = (value_ptr) xrealloc (val, sizeof (struct value) + TYPE_LENGTH (new_encl_type));
+
+ /* We have to make sure this ends up in the same place in the value
+ chain as the original copy, so it's clean-up behavior is the same.
+ If the value has been released, this is a waste of time, but there
+ is no way to tell that in advance, so... */
+
+ if (val != all_values)
+ {
+ for (prev = all_values; prev != NULL; prev = prev->next)
+ {
+ if (prev->next == val)
+ {
+ prev->next = new_val;
+ break;
+ }
+ }
+ }
+
+ return new_val;
}
}
-
/* 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 (non-static) fields.
@@ -978,7 +977,7 @@ value_headof (value_ptr in_arg, struct type *btype, struct type *dtype)
vtbl = value_ind (value_field (value_ind (arg), TYPE_VPTR_FIELDNO (btype)));
/* Turn vtable into typeinfo function */
- VALUE_OFFSET(vtbl)+=4;
+ VALUE_OFFSET (vtbl) += 4;
msymbol = lookup_minimal_symbol_by_pc ( value_as_pointer(value_ind(vtbl)) );
if (msymbol == NULL
@@ -1022,100 +1021,6 @@ value_from_vtable_info (value_ptr arg, struct type *type)
return value_headof (arg, 0, type);
}
-/* Return true if the INDEXth field of TYPE is a virtual baseclass
- pointer which is for the base class whose type is BASECLASS. */
-
-static int
-vb_match (struct type *type, int index, struct type *basetype)
-{
- struct type *fieldtype;
- char *name = TYPE_FIELD_NAME (type, index);
- char *field_class_name = NULL;
-
- if (*name != '_')
- return 0;
- /* gcc 2.4 uses _vb$. */
- if (name[1] == 'v' && name[2] == 'b' && is_cplus_marker (name[3]))
- field_class_name = name + 4;
- /* gcc 2.5 will use __vb_. */
- if (name[1] == '_' && name[2] == 'v' && name[3] == 'b' && name[4] == '_')
- field_class_name = name + 5;
-
- if (field_class_name == NULL)
- /* This field is not a virtual base class pointer. */
- return 0;
-
- /* It's a virtual baseclass pointer, now we just need to find out whether
- it is for this baseclass. */
- fieldtype = TYPE_FIELD_TYPE (type, index);
- if (fieldtype == NULL
- || TYPE_CODE (fieldtype) != TYPE_CODE_PTR)
- /* "Can't happen". */
- return 0;
-
- /* What we check for is that either the types are equal (needed for
- nameless types) or have the same name. This is ugly, and a more
- elegant solution should be devised (which would probably just push
- the ugliness into symbol reading unless we change the stabs format). */
- if (TYPE_TARGET_TYPE (fieldtype) == basetype)
- return 1;
-
- if (TYPE_NAME (basetype) != NULL
- && TYPE_NAME (TYPE_TARGET_TYPE (fieldtype)) != NULL
- && STREQ (TYPE_NAME (basetype),
- TYPE_NAME (TYPE_TARGET_TYPE (fieldtype))))
- return 1;
- return 0;
-}
-
-/* Compute the offset of the baseclass which is
- the INDEXth baseclass of class TYPE,
- for value at VALADDR (in host) at ADDRESS (in target).
- The result is the offset of the baseclass value relative
- to (the address of)(ARG) + OFFSET.
-
- -1 is returned on error. */
-
-int
-baseclass_offset (struct type *type, int index, char *valaddr,
- CORE_ADDR address)
-{
- struct type *basetype = TYPE_BASECLASS (type, index);
-
- if (BASETYPE_VIA_VIRTUAL (type, index))
- {
- /* Must hunt for the pointer to this virtual baseclass. */
- register int i, len = TYPE_NFIELDS (type);
- register int n_baseclasses = TYPE_N_BASECLASSES (type);
-
- /* First look for the virtual baseclass pointer
- in the fields. */
- for (i = n_baseclasses; i < len; i++)
- {
- if (vb_match (type, i, basetype))
- {
- CORE_ADDR addr
- = unpack_pointer (TYPE_FIELD_TYPE (type, i),
- valaddr + (TYPE_FIELD_BITPOS (type, i) / 8));
-
- return addr - (LONGEST) address;
- }
- }
- /* Not in the fields, so try looking through the baseclasses. */
- for (i = index + 1; i < n_baseclasses; i++)
- {
- int boffset =
- baseclass_offset (type, i, valaddr, address);
- if (boffset)
- return boffset;
- }
- /* Not found. */
- return -1;
- }
-
- /* Baseclass is easily computed. */
- return TYPE_BASECLASS_BITPOS (type, index) / 8;
-}
/* Unpack a field FIELDNO of the specified TYPE, from the anonymous object at
VALADDR.
@@ -1274,12 +1179,12 @@ value_from_string (char *ptr)
value_ptr val;
int len = strlen (ptr);
int lowbound = current_language->string_lower_bound;
- struct type *rangetype =
- create_range_type ((struct type *) NULL,
+ struct range_type *rangetype =
+ make_range_type (NULL,
builtin_type_int,
lowbound, len + lowbound - 1);
- struct type *stringtype =
- create_array_type ((struct type *) NULL,
+ struct type *stringtype = (struct type *)
+ make_array_type ( NULL,
*current_language->string_char_type,
rangetype);
diff --git a/gdb/varobj.c b/gdb/varobj.c
index c62aecffd65..d18528288e1 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -1402,6 +1402,7 @@ get_type_deref (struct varobj *var)
static struct type *
get_target_type (struct type *type)
{
+#if TYPEFIX
if (type != NULL)
{
type = TYPE_TARGET_TYPE (type);
@@ -1410,6 +1411,10 @@ get_target_type (struct type *type)
}
return type;
+#else
+ return NULL;
+#endif
+
}
/* What is the default display for this variable? We assume that
@@ -1746,8 +1751,7 @@ c_number_of_children (struct varobj *var)
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
- && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
+ if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0)
children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
else
children = -1;
@@ -1922,6 +1926,7 @@ c_value_of_child (struct varobj *parent, int index)
char *name;
type = get_type (parent);
+ /* TYPEFIX */
target = get_target_type (type);
name = name_of_child (parent, index);
temp = parent->value;
@@ -1982,7 +1987,7 @@ c_type_of_child (struct varobj *parent, int index)
switch (TYPE_CODE (parent->type))
{
case TYPE_CODE_ARRAY:
- type = TYPE_TARGET_TYPE (parent->type);
+ type = ARRAY_ELEMENT_TYPE (parent->type);
break;
case TYPE_CODE_STRUCT:
@@ -1991,7 +1996,7 @@ c_type_of_child (struct varobj *parent, int index)
break;
case TYPE_CODE_PTR:
- switch (TYPE_CODE (TYPE_TARGET_TYPE (parent->type)))
+ switch (TYPE_CODE (POINTER_TARGET_TYPE (parent->type)))
{
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
@@ -1999,7 +2004,7 @@ c_type_of_child (struct varobj *parent, int index)
break;
default:
- type = TYPE_TARGET_TYPE (parent->type);
+ type = POINTER_TARGET_TYPE (parent->type);
break;
}
break;