From bbcc95bdb1c2eb0c07778e1a1195743537d44224 Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Thu, 20 Jul 1995 05:52:42 +0000 Subject: [PATCH] * config/m68k/tm-m68kv4.h (DWARF_REG_TO_REGNUM): Define to correctly map floating point registers numbers. * dwarfread.c (locval, new_symbol): Handle variables that are optimized out. * mdebugread.c: Replace all uses of builtin_type_* with mdebug_type_*. Define and initialize mdebug_type_*. * serial.h (serial_close): Add additional argument `really_close'. (SERIAL_CLOSE): Update serial_close call accordingly. (SERIAL_UN_FDOPEN): Use serial_close to handle refcnt properly. * serial.c (serial_close): Handle `really_close'. * serial.h (scb_base): Moved to serial.c, made static. * valops.c (value_addr): Don't coerce arrays. (typecmp): Coerce arrays instead of calling value_addr if necessary. --- gdb/ChangeLog | 20 +++++ gdb/dwarfread.c | 14 ++- gdb/mdebugread.c | 226 ++++++++++++++++++++++++++++++++++------------- gdb/serial.c | 10 ++- gdb/serial.h | 11 +-- 5 files changed, 208 insertions(+), 73 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a0474d661aa..f6bf9c39a05 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,23 @@ +Wed Jul 19 22:42:43 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * config/m68k/tm-m68kv4.h (DWARF_REG_TO_REGNUM): Define to + correctly map floating point registers numbers. + + * dwarfread.c (locval, new_symbol): Handle variables that are + optimized out. + + * mdebugread.c: Replace all uses of builtin_type_* with + mdebug_type_*. Define and initialize mdebug_type_*. + + * serial.h (serial_close): Add additional argument `really_close'. + (SERIAL_CLOSE): Update serial_close call accordingly. + (SERIAL_UN_FDOPEN): Use serial_close to handle refcnt properly. + * serial.c (serial_close): Handle `really_close'. + * serial.h (scb_base): Moved to serial.c, made static. + + * valops.c (value_addr): Don't coerce arrays. + (typecmp): Coerce arrays instead of calling value_addr if necessary. + Wed Jul 19 18:19:28 1995 Stan Shebs From Richard Earnshaw (rearnsha@armltd.co.uk): diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 8c13087095f..3cc9bd178d4 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -1,5 +1,5 @@ /* DWARF debugging format support for GDB. - Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. Written by Fred Fish at Cygnus Support. Portions based on dbxread.c, mipsread.c, coffread.c, and dwarfread.c from a Data General SVR4 gdb port. @@ -327,6 +327,7 @@ static int dbsize; /* Size of dwarf info in bytes */ static int dbroff; /* Relative offset from start of .debug section */ static char *lnbase; /* Base pointer to line section */ static int isreg; /* Kludge to identify register variables */ +static int optimized_out; /* Kludge to identify optimized out variables */ /* Kludge to identify basereg references. Nonzero if we have an offset relative to a basereg. */ static int offreg; @@ -2151,6 +2152,9 @@ DESCRIPTION Given pointer to a string of bytes that define a location, compute the location and return the value. + A location description containing no atoms indicates that the + object is optimized out. The global optimized_out flag is set for + those, the return value is meaningless. When computing values involving the current value of the frame pointer, the value zero is used, which results in a value relative to the frame @@ -2189,9 +2193,11 @@ locval (loc) stack[stacki] = 0; isreg = 0; offreg = 0; + optimized_out = 1; loc_value_size = TARGET_FT_LONG_SIZE (current_objfile); while (loc < end) { + optimized_out = 0; loc_atom_code = target_to_host (loc, SIZEOF_LOC_ATOM_CODE, GET_UNSIGNED, current_objfile); loc += SIZEOF_LOC_ATOM_CODE; @@ -2934,7 +2940,11 @@ new_symbol (dip, objfile) { SYMBOL_VALUE (sym) = locval (dip -> at_location); add_symbol_to_list (sym, list_in_scope); - if (isreg) + if (optimized_out) + { + SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT; + } + else if (isreg) { SYMBOL_CLASS (sym) = LOC_REGISTER; } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index c4f18890072..4676ba481b8 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -267,12 +267,30 @@ static int n_undef_symbols, n_undef_labels, n_undef_vars, n_undef_procs; static char stabs_symbol[] = STABS_SYMBOL; -/* Types corresponding to btComplex, btDComplex, etc. These are here - rather than in gdbtypes.c or some such, because the meaning of codes - like btComplex is specific to the mdebug debug format. FIXME: We should - be using our own types thoughout this file, instead of sometimes using - builtin_type_*. */ - +/* Types corresponding to mdebug format bt* basic types. */ + +static struct type *mdebug_type_void; +static struct type *mdebug_type_char; +static struct type *mdebug_type_short; +static struct type *mdebug_type_int_32; +#define mdebug_type_int mdebug_type_int_32 +static struct type *mdebug_type_int_64; +static struct type *mdebug_type_long_32; +static struct type *mdebug_type_long_64; +static struct type *mdebug_type_long_long_64; +static struct type *mdebug_type_unsigned_char; +static struct type *mdebug_type_unsigned_short; +static struct type *mdebug_type_unsigned_int_32; +static struct type *mdebug_type_unsigned_int_64; +static struct type *mdebug_type_unsigned_long_32; +static struct type *mdebug_type_unsigned_long_64; +static struct type *mdebug_type_unsigned_long_long_64; +static struct type *mdebug_type_adr_32; +static struct type *mdebug_type_adr_64; +static struct type *mdebug_type_float; +static struct type *mdebug_type_double; +static struct type *mdebug_type_complex; +static struct type *mdebug_type_double_complex; static struct type *mdebug_type_fixed_dec; static struct type *mdebug_type_float_dec; static struct type *mdebug_type_string; @@ -805,7 +823,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; /* so that it can be used */ SYMBOL_CLASS (s) = LOC_LABEL; /* but not misused */ SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value; - SYMBOL_TYPE (s) = builtin_type_int; + SYMBOL_TYPE (s) = mdebug_type_int; add_symbol (s, top_stack->cur_block); break; @@ -816,7 +834,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) SYMBOL_CLASS (s) = LOC_BLOCK; /* Type of the return value */ if (sh->sc == scUndefined || sh->sc == scNil) - t = builtin_type_int; + t = mdebug_type_int; else t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name); b = top_stack->cur_block; @@ -1160,7 +1178,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) s = new_symbol (MIPS_EFI_SYMBOL_NAME); SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE; SYMBOL_CLASS (s) = LOC_CONST; - SYMBOL_TYPE (s) = builtin_type_void; + SYMBOL_TYPE (s) = mdebug_type_void; e = ((struct mips_extra_func_info *) obstack_alloc (¤t_objfile->symbol_obstack, sizeof (struct mips_extra_func_info))); @@ -1376,43 +1394,43 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) /* Null entries in this map are treated specially */ static struct type **map_bt[] = { - &builtin_type_void, /* btNil */ - 0, /* btAdr */ - &builtin_type_char, /* btChar */ - &builtin_type_unsigned_char,/* btUChar */ - &builtin_type_short, /* btShort */ - &builtin_type_unsigned_short, /* btUShort */ - &builtin_type_int, /* btInt */ - &builtin_type_unsigned_int, /* btUInt */ - &builtin_type_long, /* btLong */ - &builtin_type_unsigned_long,/* btULong */ - &builtin_type_float, /* btFloat */ - &builtin_type_double, /* btDouble */ - 0, /* btStruct */ - 0, /* btUnion */ - 0, /* btEnum */ - 0, /* btTypedef */ - 0, /* btRange */ - 0, /* btSet */ - &builtin_type_complex, /* btComplex */ - &builtin_type_double_complex,/* btDComplex */ - 0, /* btIndirect */ - &mdebug_type_fixed_dec, /* btFixedDec */ - &mdebug_type_float_dec, /* btFloatDec */ - &mdebug_type_string, /* btString */ - 0, /* btBit */ - 0, /* btPicture */ - &builtin_type_void, /* btVoid */ - 0, /* DEC C++: Pointer to member */ - 0, /* DEC C++: Virtual function table */ - 0, /* DEC C++: Class (Record) */ - &builtin_type_long, /* btLong64 */ - &builtin_type_unsigned_long, /* btULong64 */ - &builtin_type_long_long, /* btLongLong64 */ - &builtin_type_unsigned_long_long, /* btULongLong64 */ - &builtin_type_unsigned_long, /* btAdr64 */ - &builtin_type_long, /* btInt64 */ - &builtin_type_unsigned_long, /* btUInt64 */ + &mdebug_type_void, /* btNil */ + &mdebug_type_adr_32, /* btAdr */ + &mdebug_type_char, /* btChar */ + &mdebug_type_unsigned_char, /* btUChar */ + &mdebug_type_short, /* btShort */ + &mdebug_type_unsigned_short, /* btUShort */ + &mdebug_type_int_32, /* btInt */ + &mdebug_type_unsigned_int_32, /* btUInt */ + &mdebug_type_long_32, /* btLong */ + &mdebug_type_unsigned_long_32, /* btULong */ + &mdebug_type_float, /* btFloat */ + &mdebug_type_double, /* btDouble */ + 0, /* btStruct */ + 0, /* btUnion */ + 0, /* btEnum */ + 0, /* btTypedef */ + 0, /* btRange */ + 0, /* btSet */ + &mdebug_type_complex, /* btComplex */ + &mdebug_type_double_complex, /* btDComplex */ + 0, /* btIndirect */ + &mdebug_type_fixed_dec, /* btFixedDec */ + &mdebug_type_float_dec, /* btFloatDec */ + &mdebug_type_string, /* btString */ + 0, /* btBit */ + 0, /* btPicture */ + &mdebug_type_void, /* btVoid */ + 0, /* DEC C++: Pointer to member */ + 0, /* DEC C++: Virtual function table */ + 0, /* DEC C++: Class (Record) */ + &mdebug_type_long_64, /* btLong64 */ + &mdebug_type_unsigned_long_64, /* btULong64 */ + &mdebug_type_long_long_64, /* btLongLong64 */ + &mdebug_type_unsigned_long_long_64, /* btULongLong64 */ + &mdebug_type_adr_64, /* btAdr64 */ + &mdebug_type_int_64, /* btInt64 */ + &mdebug_type_unsigned_int_64, /* btUInt64 */ }; TIR t[1]; @@ -1421,13 +1439,13 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) /* Handle undefined types, they have indexNil. */ if (aux_index == indexNil) - return builtin_type_int; + return mdebug_type_int; /* Handle corrupt aux indices. */ if (aux_index >= (debug_info->fdr + fd)->caux) { complain (&index_complaint, sym_name); - return builtin_type_int; + return mdebug_type_int; } ax += aux_index; @@ -1436,7 +1454,7 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) if (t->bt >= (sizeof (map_bt) / sizeof (*map_bt))) { complain (&basic_type_complaint, t->bt, sym_name); - return builtin_type_int; + return mdebug_type_int; } if (map_bt[t->bt]) { @@ -1448,9 +1466,6 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) /* Cannot use builtin types -- build our own */ switch (t->bt) { - case btAdr: - tp = lookup_pointer_type (builtin_type_void); - break; case btStruct: type_code = TYPE_CODE_STRUCT; break; @@ -1473,7 +1488,7 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) break; default: complain (&basic_type_complaint, t->bt, sym_name); - return builtin_type_int; + return mdebug_type_int; } } @@ -1487,7 +1502,7 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) if (bs == (int *)NULL) { complain (&bad_fbitfield_complaint, sym_name); - return builtin_type_int; + return mdebug_type_int; } *bs = AUX_GET_WIDTH (bigend, ax); ax++; @@ -1602,7 +1617,7 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) if (tp == (struct type *) NULL) { complain (&unable_to_cross_ref_complaint, sym_name); - tp = builtin_type_int; + tp = mdebug_type_int; } } @@ -1718,7 +1733,7 @@ upgrade_type (fd, tpp, tq, ax, bigend, sym_name) if (TYPE_CODE (indx) != TYPE_CODE_INT) { complain (&array_index_type_complaint, sym_name); - indx = builtin_type_int; + indx = mdebug_type_int; } /* Get the bounds, and create the array type. */ @@ -1868,7 +1883,7 @@ parse_procedure (pr, search_symtab, first_off, pst) SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; SYMBOL_CLASS (s) = LOC_BLOCK; /* Donno its type, hope int is ok */ - SYMBOL_TYPE (s) = lookup_function_type (builtin_type_int); + SYMBOL_TYPE (s) = lookup_function_type (mdebug_type_int); add_symbol (s, top_stack->cur_block); /* Wont have symbols for this one */ b = new_block (2); @@ -3160,7 +3175,7 @@ psymtab_to_symtab_1 (pst, filename) memset ((PTR) e, 0, sizeof (struct mips_extra_func_info)); SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE; SYMBOL_CLASS (s) = LOC_CONST; - SYMBOL_TYPE (s) = builtin_type_void; + SYMBOL_TYPE (s) = mdebug_type_void; SYMBOL_VALUE (s) = (long) e; e->pdr.framereg = -1; add_symbol_to_list (s, &local_symbols); @@ -4061,7 +4076,7 @@ fixup_sigtramp () SYMBOL_CLASS (s) = LOC_BLOCK; SYMBOL_TYPE (s) = init_type (TYPE_CODE_FUNC, 4, 0, (char *) NULL, st->objfile); - TYPE_TARGET_TYPE (SYMBOL_TYPE (s)) = builtin_type_void; + TYPE_TARGET_TYPE (SYMBOL_TYPE (s)) = mdebug_type_void; /* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */ b = new_block (1); @@ -4103,7 +4118,7 @@ fixup_sigtramp () SYMBOL_VALUE (s) = (long) e; SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE; SYMBOL_CLASS (s) = LOC_CONST; - SYMBOL_TYPE (s) = builtin_type_void; + SYMBOL_TYPE (s) = mdebug_type_void; current_objfile = NULL; } @@ -4113,7 +4128,94 @@ fixup_sigtramp () void _initialize_mdebugread () { - /* Missing basic types */ + mdebug_type_void = + init_type (TYPE_CODE_VOID, 1, + 0, + "void", (struct objfile *) NULL); + mdebug_type_char = + init_type (TYPE_CODE_INT, 1, + 0, + "char", (struct objfile *) NULL); + mdebug_type_unsigned_char = + init_type (TYPE_CODE_INT, 1, + TYPE_FLAG_UNSIGNED, + "unsigned char", (struct objfile *) NULL); + mdebug_type_short = + init_type (TYPE_CODE_INT, 2, + 0, + "short", (struct objfile *) NULL); + mdebug_type_unsigned_short = + init_type (TYPE_CODE_INT, 2, + TYPE_FLAG_UNSIGNED, + "unsigned short", (struct objfile *) NULL); + mdebug_type_int_32 = + init_type (TYPE_CODE_INT, 4, + 0, + "int", (struct objfile *) NULL); + mdebug_type_unsigned_int_32 = + init_type (TYPE_CODE_INT, 4, + TYPE_FLAG_UNSIGNED, + "unsigned int", (struct objfile *) NULL); + mdebug_type_int_64 = + init_type (TYPE_CODE_INT, 8, + 0, + "int", (struct objfile *) NULL); + mdebug_type_unsigned_int_64 = + init_type (TYPE_CODE_INT, 8, + TYPE_FLAG_UNSIGNED, + "unsigned int", (struct objfile *) NULL); + mdebug_type_long_32 = + init_type (TYPE_CODE_INT, 4, + 0, + "long", (struct objfile *) NULL); + mdebug_type_unsigned_long_32 = + init_type (TYPE_CODE_INT, 4, + TYPE_FLAG_UNSIGNED, + "unsigned long", (struct objfile *) NULL); + mdebug_type_long_64 = + init_type (TYPE_CODE_INT, 8, + 0, + "long", (struct objfile *) NULL); + mdebug_type_unsigned_long_64 = + init_type (TYPE_CODE_INT, 8, + TYPE_FLAG_UNSIGNED, + "unsigned long", (struct objfile *) NULL); + mdebug_type_long_long_64 = + init_type (TYPE_CODE_INT, 8, + 0, + "long long", (struct objfile *) NULL); + mdebug_type_unsigned_long_long_64 = + init_type (TYPE_CODE_INT, 8, + TYPE_FLAG_UNSIGNED, + "unsigned long long", (struct objfile *) NULL); + mdebug_type_adr_32 = + init_type (TYPE_CODE_PTR, 4, + TYPE_FLAG_UNSIGNED, + "adr_32", (struct objfile *) NULL); + TYPE_TARGET_TYPE (mdebug_type_adr_32) = mdebug_type_void; + mdebug_type_adr_64 = + init_type (TYPE_CODE_PTR, 8, + TYPE_FLAG_UNSIGNED, + "adr_64", (struct objfile *) NULL); + TYPE_TARGET_TYPE (mdebug_type_adr_64) = mdebug_type_void; + mdebug_type_float = + init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, + 0, + "float", (struct objfile *) NULL); + mdebug_type_double = + init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, + 0, + "double", (struct objfile *) NULL); + mdebug_type_complex = + init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT, + 0, + "complex", (struct objfile *) NULL); + TYPE_TARGET_TYPE (mdebug_type_complex) = mdebug_type_float; + mdebug_type_double_complex = + init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, + 0, + "double complex", (struct objfile *) NULL); + TYPE_TARGET_TYPE (mdebug_type_double_complex) = mdebug_type_double; /* Is a "string" the way btString means it the same as TYPE_CODE_STRING? FIXME. */ @@ -4140,7 +4242,7 @@ _initialize_mdebugread () nodebug_func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0, "", NULL); - TYPE_TARGET_TYPE (nodebug_func_symbol_type) = builtin_type_int; + TYPE_TARGET_TYPE (nodebug_func_symbol_type) = mdebug_type_int; nodebug_var_symbol_type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0, "", NULL); diff --git a/gdb/serial.c b/gdb/serial.c index 291ff3da38c..5efd5b70cef 100644 --- a/gdb/serial.c +++ b/gdb/serial.c @@ -28,6 +28,10 @@ static struct serial_ops *serial_ops_list = NULL; static serial_t last_serial_opened = NULL; +/* Pointer to list of scb's. */ + +static serial_t scb_base; + static struct serial_ops * serial_interface_lookup (name) char *name; @@ -137,8 +141,9 @@ serial_fdopen (fd) } void -serial_close(scb) +serial_close(scb, really_close) serial_t scb; + int really_close; { serial_t tmp_scb; @@ -154,7 +159,8 @@ serial_close(scb) if (scb->refcnt > 0) return; - scb->ops->close (scb); + if (really_close) + scb->ops->close (scb); if (scb->name) free (scb->name); diff --git a/gdb/serial.h b/gdb/serial.h index 8f4222f2ed8..c639deb8660 100644 --- a/gdb/serial.h +++ b/gdb/serial.h @@ -43,8 +43,6 @@ struct _serial_t typedef struct _serial_t *serial_t; -serial_t scb_base; /* Pointer to list of scb's */ - struct serial_ops { char *name; struct serial_ops *next; @@ -161,13 +159,12 @@ serial_t serial_fdopen PARAMS ((const int fd)); /* Push out all buffers, close the device and destroy SERIAL_T. */ -void serial_close PARAMS ((serial_t)); +void serial_close PARAMS ((serial_t, int)); -#define SERIAL_CLOSE(SERIAL_T) serial_close(SERIAL_T) +#define SERIAL_CLOSE(SERIAL_T) serial_close(SERIAL_T, 1) -/* Destroy SERIAL_T without doing the rest of the stuff that SERIAL_CLOSE - does. */ +/* Push out all buffers and destroy SERIAL_T without closing the device. */ -#define SERIAL_UN_FDOPEN(SERIAL_T) (free (SERIAL_T)) +#define SERIAL_UN_FDOPEN(SERIAL_T) serial_close(SERIAL_T, 0) #endif /* SERIAL_H */ -- 2.30.2