Patches for GDB 3.6- for ISC 2.2 (386)
src at eliabel.sf.ca.us
src at eliabel.sf.ca.us
Sat Aug 18 16:13:01 AEST 1990
Those are the patches for GDB 3.6- for G++ support under ISC 2.2.
WARNING: The Tar files distributed as the second part of the patches
for ISC 2.2 should be also used for GDB 3.6-. I do not report it for
GDB 3.6- as there is no changes, but some of those files are needed.
Eric P. Meyer
ELIABEL Corp.
emeyer at eliabel.sf.ca.us
diff -pr gdb-3.6/Makefile.dist ../gdb-3.6/Makefile.dist
*** gdb-3.6/Makefile.dist Tue Jun 26 06:23:36 1990
--- ../gdb-3.6/Makefile.dist Tue Aug 7 21:26:21 1990
*************** ALLOCA1 =
*** 82,89 ****
define this to be "malloc.o" if you want to use the gnu malloc routine
(useful for debugging memory allocation problems in gdb). Otherwise, leave
it blank. */
! /* GNU_MALLOC = */
! GNU_MALLOC = malloc.o
/* Flags to be used in compiling malloc.o
Specify range checking for storage allocation. */
--- 82,89 ----
define this to be "malloc.o" if you want to use the gnu malloc routine
(useful for debugging memory allocation problems in gdb). Otherwise, leave
it blank. */
! GNU_MALLOC =
! /* GNU_MALLOC = malloc.o */
/* Flags to be used in compiling malloc.o
Specify range checking for storage allocation. */
*************** TERMCAP = -ltermcap
*** 114,119 ****
--- 114,126 ----
#ifndef M_CLIBS
#define M_CLIBS
#endif
+
+ /* M_COBJS, if defined, has system-dependent objects
+ For example, coff-dbx-dep.o on systems using stabs in coff. */
+ #ifndef M_COBJS
+ #define M_COBJS
+ #endif
+
CLIBS = ${ADD_FILES} ${TERMCAP} M_CLIBS
ADD_FILES = ${OBSTACK} ${REGEX} ${ALLOCA} ${GNU_MALLOC}
*************** SFILES = blockframe.c breakpoint.c dbxre
*** 126,132 ****
utils.c valarith.c valops.c valprint.c values.c version.c expread.y \
xgdb.c cplus-dem.c
! DEPFILES = umax-dep.c gould-dep.c default-dep.c sun3-dep.c \
sparc-dep.c hp9k320-dep.c hp300bsd-dep.c news-dep.c i386-dep.c \
symmetry-dep.c convex-dep.c altos-dep.c isi-dep.c pyr-dep.c
--- 133,139 ----
utils.c valarith.c valops.c valprint.c values.c version.c expread.y \
xgdb.c cplus-dem.c
! DEPFILES = umax-dep.c gould-dep.c default-dep.c sun3-dep.c coff-dbx-dep.c \
sparc-dep.c hp9k320-dep.c hp300bsd-dep.c news-dep.c i386-dep.c \
symmetry-dep.c convex-dep.c altos-dep.c isi-dep.c pyr-dep.c
*************** OBS = main.o blockframe.o breakpoint.o f
*** 177,183 ****
command.o utils.o expread.o expprint.o pinsn.o environ.o version.o \
copying.o cplus-dem.o ${READLINEOBS}
! TSOBS = core.o inflow.o dep.o
NTSOBS = standalone.o
--- 184,190 ----
command.o utils.o expread.o expprint.o pinsn.o environ.o version.o \
copying.o cplus-dem.o ${READLINEOBS}
! TSOBS = core.o inflow.o dep.o M_COBJS
NTSOBS = standalone.o
diff -pr gdb-3.6/a.out.gnu.h ../gdb-3.6/a.out.gnu.h
*** gdb-3.6/a.out.gnu.h Tue Jan 16 19:17:57 1990
--- ../gdb-3.6/a.out.gnu.h Tue Aug 7 21:00:14 1990
*************** enum machine_type {
*** 37,43 ****
M_68020 = 2,
#endif
#if defined (M_SPARC)
! M__SPARC = M_SPARC
#else
M_SPARC = 3,
#endif
--- 37,43 ----
M_68020 = 2,
#endif
#if defined (M_SPARC)
! M__SPARC = M_SPARC,
#else
M_SPARC = 3,
#endif
diff -pr gdb-3.6/breakpoint.c ../gdb-3.6/breakpoint.c
*** gdb-3.6/breakpoint.c Sat Jun 30 06:03:33 1990
--- ../gdb-3.6/breakpoint.c Thu Aug 16 17:43:37 1990
*************** breakpoint_1 (bnum)
*** 436,442 ****
ALL_BREAKPOINTS (b)
if (bnum == -1 || bnum == b->number)
{
! printf_filtered ("#%-3d %c 0x%08x ", b->number,
"nyod"[(int) b->enable],
b->address);
last_addr = b->address;
--- 436,442 ----
ALL_BREAKPOINTS (b)
if (bnum == -1 || bnum == b->number)
{
! printf_filtered ("#%-3d %c 0x%08x", b->number,
"nyod"[(int) b->enable],
b->address);
last_addr = b->address;
*************** breakpoint_1 (bnum)
*** 444,467 ****
{
sym = find_pc_function (b->address);
if (sym)
- printf_filtered (" in %s (%s line %d)", SYMBOL_NAME (sym),
- b->symtab->filename, b->line_number);
- else
- printf_filtered ("%s line %d", b->symtab->filename, b->line_number);
- }
- else
- {
- char *name;
- int addr;
-
- if (find_pc_partial_function (b->address, &name, &addr))
{
! if (b->address - addr)
! printf_filtered ("<%s+%d>", name, b->address - addr);
! else
! printf_filtered ("<%s>", name);
}
}
printf_filtered ("\n");
--- 444,460 ----
{
sym = find_pc_function (b->address);
if (sym)
{
! fputs_filtered (" in ", stdout);
! fputs_demangled (SYMBOL_NAME (sym), stdout, 1);
! fputs_filtered (" (", stdout);
}
+ fputs_filtered (b->symtab->filename, stdout);
+ printf_filtered (" line %d", b->line_number);
+ if (sym) fputs_filtered(")", stdout);
}
+ else
+ print_address_symbolic (b->address, stdout);
printf_filtered ("\n");
diff -pr gdb-3.6/coffread.c ../gdb-3.6/coffread.c
*** gdb-3.6/coffread.c Wed Jan 10 15:54:43 1990
--- ../gdb-3.6/coffread.c Tue Aug 7 21:00:17 1990
*************** the Free Software Foundation, 675 Mass A
*** 23,29 ****
#include <stdio.h>
#include "defs.h"
#include "param.h"
! #ifdef COFF_FORMAT
#include "symtab.h"
#ifdef USG
--- 23,29 ----
#include <stdio.h>
#include "defs.h"
#include "param.h"
! #if defined(COFF_FORMAT) && !defined(READ_DBX_FORMAT)
#include "symtab.h"
#ifdef USG
diff -pr gdb-3.6/config.gdb ../gdb-3.6/config.gdb
*** gdb-3.6/config.gdb Tue Jan 30 12:35:46 1990
--- ../gdb-3.6/config.gdb Tue Aug 7 23:06:46 1990
***************
*** 1,3 ****
--- 1,4 ----
+
#!/bin/sh
#
*************** altosgas)
*** 134,139 ****
--- 135,150 ----
depfile=altos-dep.c
opcodefile=m68k-opcode.h
;;
+ pbb)
+ m_regex=-DM_REGEX=regex.o
+ m_clibs=-DM_CLIBS=-lbsd
+ m_cflags=-DM_CFLAGS=-DSETJMP_MASKS_SIGNALS
+ m_cobjs=-DM_COBJS=coff-dbx-dep.o
+ makedefine="$m_regex $m_cobjs $m_clibs $m_cflags -DM_SYSV"
+ pinsnfile=m68k-pinsn.c
+ depfile=pbb-dep.c
+ opcodefile=m68k-opcode.h
+ ;;
pyramid)
echo
echo "Note that GDB on Pyramids only works with GCC."
*************** i386gas)
*** 195,201 ****
# These names are short and cryptic due to the @#$#!@#$@! System V
# 14 character file name limit.
i386-sv32)
! makedefine="-DM_CLIBS=-lPW -DM_SYSV -DM_REGEX=regex.o"
pinsnfile=i386-pinsn.c
depfile=i386-dep.c
# The following is a lie, but a necessary one. See comment at beginning
--- 206,212 ----
# These names are short and cryptic due to the @#$#!@#$@! System V
# 14 character file name limit.
i386-sv32)
! makedefine="-DM_CLIBS=-lPW -DM_SYSV -DM_REGEX=regex.o -DM_CFLAGS=-USETJMP_MASKS_SIGNALS -DM_COBJS=coff-dbx-dep.o"
pinsnfile=i386-pinsn.c
depfile=i386-dep.c
# The following is a lie, but a necessary one. See comment at beginning
*************** sun3os4|sun3-os4)
*** 285,290 ****
--- 296,315 ----
pinsnfile=m68k-pinsn.c
opcodefile=m68k-opcode.h
depfile=sun3-dep.c
+ ;;
+ sun386i)
+ # Compile GDB without shared libraries so that it can be run on itself.
+ makedefine="-DM_CFLAGS=-Bstatic -DM_COBJS=coff-dbx-dep.o"
+ echo
+ echo "Make sure to compile any program on which you want to run gdb"
+ echo " without shared libraries (cc -Bstatic)"
+ echo
+ paramfile=m-sun386i.h
+ pinsnfile=i386-pinsn.c
+ # The following is a lie, but a necessary one. See comment at beginning
+ # of this file about unneeded files.
+ opcodefile=m68k-opcode.h
+ depfile=sun386i-dep.c
;;
sun4os4|sun4-os4)
# Compile GDB without shared libraries so that it can be run on itself.
diff -pr gdb-3.6/core.c ../gdb-3.6/core.c
*** gdb-3.6/core.c Wed Jan 10 15:55:17 1990
--- ../gdb-3.6/core.c Tue Aug 7 21:00:18 1990
*************** xfer_core_file (memaddr, myaddr, len)
*** 343,348 ****
--- 343,352 ----
int fileptr;
int returnval = 0;
+ #ifdef KERNEL_CORE_HOOK
+ KERNEL_CORE_HOOK /* can have data definitions and code using them */
+ #endif
+
while (len > 0)
{
xferfile = 0;
diff -pr gdb-3.6/cplus-dem.c ../gdb-3.6/cplus-dem.c
*** gdb-3.6/cplus-dem.c Tue Jun 26 06:23:14 1990
--- ../gdb-3.6/cplus-dem.c Thu Aug 16 17:44:39 1990
***************
*** 23,29 ****
/* This file exports one function
! char *cplus_demangle (const char *name, int ansi)
If NAME is a mangled function name produced by GNU C++, then
a pointer to a malloced string giving a C++ representation
--- 23,29 ----
/* This file exports one function
! char *cplus_demangle (const char *name, int mode)
If NAME is a mangled function name produced by GNU C++, then
a pointer to a malloced string giving a C++ representation
***************
*** 31,39 ****
It is the caller's responsibility to free the string which
is returned.
! If ANSI is non-zero, then ANSI qualifiers such as `const',
`void', and the ellipses operator `...' are output. Otherwise
they are not.
For example,
--- 31,40 ----
It is the caller's responsibility to free the string which
is returned.
! If MODE > 0, then ANSI qualifiers such as `const',
`void', and the ellipses operator `...' are output. Otherwise
they are not.
+ if MODE >= 0, parameter are emiitted; otherwise not.
For example,
***************
*** 59,67 ****
--- 60,70 ----
#include <strings.h>
#define memcpy(s1, s2, n) bcopy ((s2), (s1), (n))
#define memcmp(s1, s2, n) bcmp ((s2), (s1), (n))
+ #ifndef i386
#define strchr index
#define strrchr rindex
#endif
+ #endif
#ifndef __STDC__
#define const
***************
*** 68,74 ****
#endif
#ifdef __STDC__
! extern char *cplus_demangle (const char *type, int ansi);
#else
extern char *cplus_demangle ();
#endif
--- 71,77 ----
#endif
#ifdef __STDC__
! extern char *cplus_demangle (const char *type, int mode);
#else
extern char *cplus_demangle ();
#endif
*************** static void string_prepends (string *p,
*** 148,158 ****
#endif
static void string_prependn (string *p, const char *s, int n);
static int get_count (const char **type, int *count);
! static int do_args (const char **type, string *decl);
! static int do_type (const char **type, string *result);
! static int do_arg (const char **type, string *result);
! static int do_args (const char **type, string *decl);
! static void munge_function_name (string *name);
static void remember_type (const char *type, int len);
#else
static void string_need ();
--- 151,160 ----
#endif
static void string_prependn (string *p, const char *s, int n);
static int get_count (const char **type, int *count);
! static int do_args (const char **type, string *decl, int arg_mode);
! static int do_type (const char **type, string *result, int arg_mode);
! static int do_arg (const char **type, string *result, int arg_mode);
! static void munge_function_name (string *name, int arg_mode);
static void remember_type (const char *type, int len);
#else
static void string_need ();
*************** static void munge_function_name ();
*** 175,186 ****
static void remember_type ();
#endif
- static int print_ansi_qualifiers;
-
char *
! cplus_demangle (type, ansi)
const char *type;
! int ansi;
{
string decl;
int n;
--- 177,186 ----
static void remember_type ();
#endif
char *
! cplus_demangle (type, arg_mode)
const char *type;
! int arg_mode;
{
string decl;
int n;
*************** cplus_demangle (type, ansi)
*** 193,199 ****
const char *premangle;
#endif
! print_ansi_qualifiers = ansi;
if (type == NULL || *type == '\0')
return NULL;
--- 193,200 ----
const char *premangle;
#endif
! #define print_ansi_qualifiers (arg_mode > 0)
! #define print_arg_types (arg_mode >= 0)
if (type == NULL || *type == '\0')
return NULL;
*************** cplus_demangle (type, ansi)
*** 253,259 ****
else
{
string_appendn (&decl, type, p - type);
! munge_function_name (&decl);
}
p += 2;
--- 254,260 ----
else
{
string_appendn (&decl, type, p - type);
! munge_function_name (&decl, arg_mode);
}
p += 2;
*************** cplus_demangle (type, ansi)
*** 310,322 ****
#ifndef LONGERNAMES
remember_type (premangle, p - premangle);
#endif
! success = do_args (&p, &decl);
! if (const_flag)
string_append (&decl, " const");
break;
case 'F':
p += 1;
! success = do_args (&p, &decl);
break;
}
--- 311,323 ----
#ifndef LONGERNAMES
remember_type (premangle, p - premangle);
#endif
! success = do_args (&p, &decl, arg_mode);
! if (const_flag && print_arg_types)
string_append (&decl, " const");
break;
case 'F':
p += 1;
! success = do_args (&p, &decl, arg_mode);
break;
}
*************** get_count (type, count)
*** 376,384 ****
/* result will be initialised here; it will be freed on failure */
static int
! do_type (type, result)
const char **type;
string *result;
{
int n;
int done;
--- 377,386 ----
/* result will be initialised here; it will be freed on failure */
static int
! do_type (type, result, arg_mode)
const char **type;
string *result;
+ int arg_mode;
{
int n;
int done;
*************** do_type (type, result)
*** 425,431 ****
string_prepend (&decl, "(");
string_append (&decl, ")");
}
! if (!do_args (type, &decl) || **type != '_')
success = 0;
else
*type += 1;
--- 427,433 ----
string_prepend (&decl, "(");
string_append (&decl, ")");
}
! if (!do_args (type, &decl, arg_mode) || **type != '_')
success = 0;
else
*type += 1;
*************** do_type (type, result)
*** 480,486 ****
break;
}
}
! if ((member && !do_args (type, &decl)) || **type != '_')
{
success = 0;
break;
--- 482,488 ----
break;
}
}
! if ((member && !do_args (type, &decl, arg_mode)) || **type != '_')
{
success = 0;
break;
*************** do_type (type, result)
*** 502,508 ****
string_append (&decl, " ");
else
non_empty = 1;
! string_append (&decl, "volatilep");
}
break;
}
--- 504,510 ----
string_append (&decl, " ");
else
non_empty = 1;
! string_append (&decl, "volatile");
}
break;
}
*************** do_type (type, result)
*** 691,703 ****
/* `result' will be initialised in do_type; it will be freed on failure */
static int
! do_arg (type, result)
const char **type;
string *result;
{
const char *start = *type;
! if (!do_type (type, result))
return 0;
remember_type (start, *type - start);
return 1;
--- 693,706 ----
/* `result' will be initialised in do_type; it will be freed on failure */
static int
! do_arg (type, result, arg_mode)
const char **type;
string *result;
+ int arg_mode;
{
const char *start = *type;
! if (!do_type (type, result, arg_mode))
return 0;
remember_type (start, *type - start);
return 1;
*************** remember_type (start, len)
*** 733,746 ****
it won't be freed on failure */
static int
! do_args (type, decl)
const char **type;
string *decl;
{
string arg;
int need_comma = 0;
! string_append (decl, "(");
while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v')
{
--- 736,751 ----
it won't be freed on failure */
static int
! do_args (type, decl, arg_mode)
const char **type;
string *decl;
+ int arg_mode;
{
string arg;
int need_comma = 0;
! if (print_arg_types)
! string_append (decl, "(");
while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v')
{
*************** do_args (type, decl)
*** 754,764 ****
while (--r >= 0)
{
const char *tem = typevec[t];
! if (need_comma)
string_append (decl, ", ");
! if (!do_arg (&tem, &arg))
return 0;
! string_appends (decl, &arg);
string_delete (&arg);
need_comma = 1;
}
--- 759,770 ----
while (--r >= 0)
{
const char *tem = typevec[t];
! if (need_comma && print_arg_types)
string_append (decl, ", ");
! if (!do_arg (&tem, &arg, arg_mode))
return 0;
! if (print_arg_types)
! string_appends (decl, &arg);
string_delete (&arg);
need_comma = 1;
}
*************** do_args (type, decl)
*** 765,775 ****
}
else
{
! if (need_comma)
string_append (decl, ", ");
! if (!do_arg (type, &arg))
return 0;
! string_appends (decl, &arg);
string_delete (&arg);
need_comma = 1;
}
--- 771,782 ----
}
else
{
! if (need_comma && print_arg_types)
string_append (decl, ", ");
! if (!do_arg (type, &arg, arg_mode))
return 0;
! if (print_arg_types)
! string_appends (decl, &arg);
string_delete (&arg);
need_comma = 1;
}
*************** do_args (type, decl)
*** 780,796 ****
else if (**type == 'e')
{
*type += 1;
! if (need_comma)
! string_append (decl, ",");
! string_append (decl, "...");
}
! string_append (decl, ")");
return 1;
}
static void
! munge_function_name (name)
string *name;
{
if (!string_empty (name) && name->p - name->b >= 3
--- 787,807 ----
else if (**type == 'e')
{
*type += 1;
! if (print_arg_types)
! {
! if (need_comma)
! string_append (decl, ",");
! string_append (decl, "...");
! }
}
! if (print_arg_types)
! string_append (decl, ")");
return 1;
}
static void
! munge_function_name (name, arg_mode)
string *name;
{
if (!string_empty (name) && name->p - name->b >= 3
*************** munge_function_name (name)
*** 838,844 ****
/* type conversion operator */
string type;
const char *tem = name->b + 5;
! if (do_type (&tem, &type))
{
string_clear (name);
string_append (name, "operator ");
--- 849,855 ----
/* type conversion operator */
string type;
const char *tem = name->b + 5;
! if (do_type (&tem, &type, arg_mode))
{
string_clear (name);
string_append (name, "operator ");
diff -pr gdb-3.6/dbxread.c ../gdb-3.6/dbxread.c
*** gdb-3.6/dbxread.c Tue Jul 3 12:38:14 1990
--- ../gdb-3.6/dbxread.c Tue Aug 7 21:03:54 1990
*************** the Free Software Foundation, 675 Mass A
*** 40,57 ****
#define L_INCR 1
#endif
! #ifdef COFF_ENCAPSULATE
! #include "a.out.encap.h"
! #include "stab.gnu.h"
#else
! #include <a.out.h>
!
! #if 0
! #include <stab.h>
! #else
! #include "stab.gnu.h"
! #endif /* 0 */
!
#endif
#include <ctype.h>
--- 40,60 ----
#define L_INCR 1
#endif
! #ifdef COFF_FORMAT
! # ifdef COFF_ENCAPSULATE
! # include "a.out.encap.h"
! # include "stab.gnu.h"
! # else
! # include "coff-a.out.h"
! # ifdef NO_NATIVE_STAB_INCLUDE
! # include "stab.gnu.h"
! # else
! # include <stab.h>
! # endif
! # endif
#else
! # include <a.out.h>
! # include <stab.h>
#endif
#include <ctype.h>
*************** the Free Software Foundation, 675 Mass A
*** 139,144 ****
--- 142,279 ----
#include "defs.h"
#include "symtab.h"
+ #ifndef SET_NAMESTRING
+ /* Set namestring based on bufp. */
+
+ #ifndef COFF_FORMAT
+
+ #define SET_NAMESTRING()\
+ if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) \
+ error ("Invalid symbol data: bad string table offset: %d", \
+ bufp->n_un.n_strx); \
+ namestring = bufp->n_un.n_strx + stringtab
+
+ #define NEXT_SYMBOL_TEXT() \
+ if (symbuf_idx == symbuf_end) \
+ fill_symbuf (); \
+ symnum++; \
+ return NLIST_INDEX(symbuf,symbuf_idx++).n_un.n_strx + stringtab_global; \
+
+ #define IS_O_FILE_START(name,len) ((name[0] == '-' && name[1] == 'l') \
+ || (name [(len = strlen (name)) - 1] == 'o' \
+ && name [len - 2] == '.'))
+
+
+ #else /* COFF FORMAT */
+
+ /* copy of symbol count */
+ int number_of_symbols;
+
+ /* Set namestring based on bufp. */
+
+ struct extra_strings {
+ int next;
+ char *strings; /* to handle 8 byte or shorter strings
+ * and continuations.
+ */
+ };
+
+ struct extra_strings extra_strings = { 0};
+ struct extra_strings addl_extra_strings = { 0};
+ struct extra_strings *cur_extra = 0;
+
+ #define EXTRA_STRINGS_INIT(extra) \
+ { \
+ if (extra.strings) \
+ free (extra.strings); \
+ extra.next = 0; \
+ cur_extra = &extra; \
+ extra.strings = xmalloc(number_of_symbols * (SYMNMLEN+1)); }
+
+ #define SET_NAMESTRING() \
+ if (bufp->n_zeroes) \
+ { \
+ ADD_STRING(namestring,(char *) &bufp->n_zeroes); \
+ } \
+ else { \
+ if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) \
+ error ("Invalid symbol data: bad string table offset: %d", \
+ bufp->n_un.n_strx); \
+ namestring = bufp->n_un.n_strx + stringtab; \
+ }
+ #if 0
+ #ifndef SYMNMLEN
+ #define SYMNMLEN 8
+ #endif
+ #endif
+
+ #define ADD_STRING(result,str) { \
+ int i = cur_extra->next; \
+ char *new = &cur_extra->strings[i]; \
+ strncpy(new,str,SYMNMLEN); \
+ new[SYMNMLEN] = 0; \
+ cur_extra->next = i + 1 + strlen(new); \
+ result = new; }
+
+ #define NEXT_SYMBOL_TEXT() { \
+ struct nlist *bufp; \
+ if (symbuf_idx == symbuf_end) \
+ fill_symbuf (); \
+ symnum++; \
+ bufp = &NLIST_INDEX(symbuf,symbuf_idx++); \
+ if (bufp->n_zeroes) \
+ { \
+ char *namestring; \
+ ADD_STRING(namestring,(char *) &bufp->n_zeroes); \
+ return namestring; \
+ } \
+ else \
+ return bufp->n_un.n_strx + stringtab_global; \
+ }
+
+ #define IS_DOT_FILE(name) ( name [0] == '.' && name [1] == 'f' \
+ && name [2] == 'i' && name [3] == 'l' \
+ && name [4] == 'e' && name [5] == 0 )
+
+ #define IS_DOT_TEXT(name) ( name [0] == '.' && name [1] == 't' \
+ && name [2] == 'e' && name [3] == 'x' \
+ && name [4] == 't' && name [5] == 0 )
+ #ifndef IS_O_FILE_START
+ #ifdef sun386
+ /* on the sun386i, the .file symbol oddly
+ * has the same value as the .text symbol
+ * DESPITE (!) it having scnum -2, and the
+ * .text symbol comes too late.
+ */
+ #define IS_O_FILE_START(name,len) IS_DOT_FILE(name)
+ #else /* not sun386 */
+ #define IS_O_FILE_START(name,len) IS_DOT_TEXT(name)
+ #endif /* not sun386 */
+ #endif /* notdef IS_OFILE_START */
+
+
+ #endif /* COFF FORMAT */
+ #endif /* SET_NAMESTRING */
+
+ /* Macro for the size of the on disk symbol table entry. Due to machine
+ * dependent alignment considerations, This might not be the same size
+ * as that generated by the native compiler for the equivalent defining
+ * structure definition.
+ * The sun386i is one machine for which this is a problem.
+ *
+ * The "index" argument to NLIST_INDEX macro must not be multiply evaluated
+ */
+ #ifndef NLIST_STRUCT_SIZE
+ #define NLIST_STRUCT_SIZE sizeof(struct nlist)
+ #define NLIST_INCR(p) p++
+ #define NLIST_INDEX(ptr,index) ptr[index]
+ #endif
+
+ /* Size (in elements) of buffer for reading the symbol table entries. */
+ #ifndef SYMBUFSIZE
+ #define SYMBUFSIZE 4096
+ #endif
+
#ifndef COFF_FORMAT
#ifndef AOUTHDR
#define AOUTHDR struct exec
*************** static struct type **read_args ();
*** 197,205 ****
#ifdef COFF_HEADER
#define NUMBER_OF_SYMBOLS \
((COFF_HEADER(hdr) ? hdr.coffhdr.filehdr.f_nsyms : hdr.a_syms) / \
! sizeof (struct nlist))
#else
! #define NUMBER_OF_SYMBOLS (hdr.a_syms / sizeof (struct nlist))
#endif
#endif
--- 332,340 ----
#ifdef COFF_HEADER
#define NUMBER_OF_SYMBOLS \
((COFF_HEADER(hdr) ? hdr.coffhdr.filehdr.f_nsyms : hdr.a_syms) / \
! NLIST_STRUCT_SIZE)
#else
! #define NUMBER_OF_SYMBOLS (hdr.a_syms / NLIST_STRUCT_SIZE)
#endif
#endif
*************** static struct subfile *current_subfile;
*** 345,351 ****
/* Count symbols as they are processed, for error messages. */
! static int symnum;
/* Vector of types defined so far, indexed by their dbx type numbers.
(In newer sun systems, dbx uses a pair of numbers in parens,
--- 480,489 ----
/* Count symbols as they are processed, for error messages. */
! static int symnum=0;
! /* dont bother ifdeffing these; theyre cheap */
! int symnum_limit =0;
! int conv_symnum =0;
/* Vector of types defined so far, indexed by their dbx type numbers.
(In newer sun systems, dbx uses a pair of numbers in parens,
*************** static int undef_types_allocated, undef_
*** 485,492 ****
--- 623,637 ----
#ifdef NAMES_HAVE_UNDERSCORE
#define HASH_OFFSET 1
+ #define IS_ETEXT(name) name[6] == '\0' && name[5] == 't' \
+ && name[4] == 'x' && name[3] == 'e' \
+ && name[2] == 't' && name[1] == 'e' \
+ && name[0] == '_'
#else
#define HASH_OFFSET 0
+ #define IS_ETEXT(name) name[5] == '\0' && name[4] == 't' \
+ && name[3] == 'x' && name[2] == 'e' \
+ && name[1] == 't' && name[0] == 'e'
#endif
#if 0
*************** make_blockvector ()
*** 1090,1097 ****
}
/* Manage the vector of line numbers. */
!
! static void
record_line (line, pc)
int line;
CORE_ADDR pc;
--- 1235,1244 ----
}
/* Manage the vector of line numbers. */
! /* not static: must be visible from dep.c
! * at least on sun 386i systems.
! */
! void
record_line (line, pc)
int line;
CORE_ADDR pc;
*************** start_symtab (name, start_addr)
*** 1144,1150 ****
new_object_header_files ();
for (s = symseg_chain; s; s = s->next)
! if (s->ldsymoff == symnum * sizeof (struct nlist))
break;
current_symseg = s;
if (s != 0)
--- 1291,1297 ----
new_object_header_files ();
for (s = symseg_chain; s; s = s->next)
! if (s->ldsymoff == symnum * NLIST_STRUCT_SIZE)
break;
current_symseg = s;
if (s != 0)
*************** extern struct symtab *psymtab_to_symtab
*** 1580,1585 ****
--- 1727,1735 ----
/* The entry point. */
static CORE_ADDR entry_point;
+ static char *symfile_string_table;
+ static int symfile_string_table_size;
+
/* This is the symbol-file command. Read the file, analyze its symbols,
and add a struct symtab to symtab_list. */
*************** symbol_file_command (name, from_tty)
*** 1641,1646 ****
--- 1791,1801 ----
READ_FILE_HEADERS (desc, name);
+ #ifdef N_MULTI_LINE_TYPE
+ val = init_lineno (desc, scn[text_scn].s_lnnoptr, scn[text_scn].s_nlnno);
+ if (val < 0)
+ error ("\"%s\": error reading line numbers\n", name);
+ #endif
entry_point = ENTRY_POINT;
if (NUMBER_OF_SYMBOLS == 0)
*************** symbol_file_command (name, from_tty)
*** 1668,1673 ****
--- 1823,1836 ----
READ_STRING_TABLE_SIZE (buffer);
if (buffer >= 0 && buffer < statbuf.st_size)
{
+ /* This should speed things up without consuming much
+ extra memory (because probably little of the space is going
+ to be reused anyway, whether in data or stack space).
+
+ A quick test (running GDB on itself and setting 9 breakpoints
+ in different files) showed that memory usage was almost
+ identical for the two cases. */
+ #if 0
#ifdef BROKEN_LARGE_ALLOCA
stringtab = (char *) xmalloc (buffer);
make_cleanup (free, stringtab);
*************** symbol_file_command (name, from_tty)
*** 1674,1679 ****
--- 1837,1846 ----
#else
stringtab = (char *) alloca (buffer);
#endif
+ #endif
+ stringtab = (char *) xmalloc (buffer);
+ symfile_string_table = stringtab;
+ symfile_string_table_size = buffer;
}
else
stringtab = NULL;
*************** symbol_file_command (name, from_tty)
*** 1724,1729 ****
--- 1891,1900 ----
global_symbols = 0;
make_cleanup (really_free_pendings, 0);
+ #ifdef EXTRA_STRINGS_INIT
+ EXTRA_STRINGS_INIT (extra_strings)
+ #endif
+
/* Now that the symbol table data of the executable file are all in core,
process them and define symbols accordingly. Closes desc. */
*************** get_sym_file ()
*** 1773,1788 ****
}
/* Buffer for reading the symbol table entries. */
! static struct nlist symbuf[4096];
static int symbuf_idx;
! static int symbuf_end;
!
/* I/O descriptor for reading the symbol table. */
static int symtab_input_desc;
/* The address of the string table
of the object file we are reading (as copied into core). */
! static char *stringtab_global;
/* Refill the symbol table input buffer
and set the variables that control fetching entries from it.
--- 1944,1961 ----
}
/* Buffer for reading the symbol table entries. */
! static struct nlist symbuf[SYMBUFSIZE];
static int symbuf_idx;
! int symbuf_end; /* Not static: may be adjusted from dep.c
! * on coff systems if the buffer's last symbol
! * has an auxent.
! */
/* I/O descriptor for reading the symbol table. */
static int symtab_input_desc;
/* The address of the string table
of the object file we are reading (as copied into core). */
! char *stringtab_global; /* Not static: dep.c may need it. */
/* Refill the symbol table input buffer
and set the variables that control fetching entries from it.
*************** static char *stringtab_global;
*** 1793,1802 ****
static int
fill_symbuf ()
{
! int nbytes = myread (symtab_input_desc, symbuf, sizeof (symbuf));
if (nbytes <= 0)
error ("error or end of file reading symbol table");
! symbuf_end = nbytes / sizeof (struct nlist);
symbuf_idx = 0;
return 1;
}
--- 1966,1978 ----
static int
fill_symbuf ()
{
! int nbytes = myread (symtab_input_desc, symbuf, SYMBUFSIZE * NLIST_STRUCT_SIZE);
if (nbytes <= 0)
error ("error or end of file reading symbol table");
! symbuf_end = nbytes / NLIST_STRUCT_SIZE;
! #ifdef CONVERT_SYMBUF
! convert_symbuf(symtab_input_desc,symbuf,symbuf_end);
! #endif
symbuf_idx = 0;
return 1;
}
*************** fill_symbuf ()
*** 1809,1818 ****
static char *
next_symbol_text ()
{
! if (symbuf_idx == symbuf_end)
! fill_symbuf ();
! symnum++;
! return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global;
}
/*
--- 1985,1991 ----
static char *
next_symbol_text ()
{
! NEXT_SYMBOL_TEXT(); /* contains return of ptr */
}
/*
*************** read_dbx_symtab (desc, stringtab, string
*** 2001,2006 ****
--- 2174,2182 ----
symtab_input_desc = desc; /* This is needed for fill_symbuf below */
symbuf_end = symbuf_idx = 0;
+ symnum_limit = nlistlen;
+ conv_symnum = 0;
+
for (symnum = 0; symnum < nlistlen; symnum++)
{
/* Get the symbol for this run and pull out some info */
*************** read_dbx_symtab (desc, stringtab, string
*** 2007,2013 ****
QUIT; /* allow this to be interruptable */
if (symbuf_idx == symbuf_end)
fill_symbuf ();
! bufp = &symbuf[symbuf_idx++];
#ifdef PROFILE_TYPES
profile_types[bufp->n_type]++;
--- 2183,2189 ----
QUIT; /* allow this to be interruptable */
if (symbuf_idx == symbuf_end)
fill_symbuf ();
! bufp = & NLIST_INDEX(symbuf,symbuf_idx++);
#ifdef PROFILE_TYPES
profile_types[bufp->n_type]++;
*************** read_dbx_symtab (desc, stringtab, string
*** 2017,2023 ****
* Special case to speed up readin.
*/
if (bufp->n_type == N_SLINE) continue;
!
/* Ok. There is a lot of code duplicated in the rest of this
switch statiement (for efficiency reasons). Since I don't
like duplicating code, I will do my penance here, and
--- 2193,2201 ----
* Special case to speed up readin.
*/
if (bufp->n_type == N_SLINE) continue;
! #ifdef N_MULTI_LINE_TYPE
! if (bufp->n_type == N_MULTI_LINE_TYPE) continue;
! #endif
/* Ok. There is a lot of code duplicated in the rest of this
switch statiement (for efficiency reasons). Since I don't
like duplicating code, I will do my penance here, and
*************** read_dbx_symtab (desc, stringtab, string
*** 2030,2041 ****
I've imbedded it in the following macro.
*/
- /* Set namestring based on bufp. */
- #define SET_NAMESTRING()\
- if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) \
- error ("Invalid symbol data: bad string table offset: %d", \
- bufp->n_un.n_strx); \
- namestring = bufp->n_un.n_strx + stringtab
#define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE)\
do { \
--- 2208,2213 ----
*************** read_dbx_symtab (desc, stringtab, string
*** 2075,2084 ****
SET_NAMESTRING();
! if (namestring[6] == '\0' && namestring[5] == 't'
! && namestring[4] == 'x' && namestring[3] == 'e'
! && namestring[2] == 't' && namestring[1] == 'e'
! && namestring[0] == '_')
end_of_text_addr = bufp->n_value;
/* Figure out beginning and end of global linker symbol
--- 2247,2253 ----
SET_NAMESTRING();
! if (IS_ETEXT(namestring))
end_of_text_addr = bufp->n_value;
/* Figure out beginning and end of global linker symbol
*************** read_dbx_symtab (desc, stringtab, string
*** 2139,2147 ****
case N_TEXT:
/* #endif */
SET_NAMESTRING();
! if ((namestring[0] == '-' && namestring[1] == 'l')
! || (namestring [(nsl = strlen (namestring)) - 1] == 'o'
! && namestring [nsl - 2] == '.'))
{
if (entry_point < bufp->n_value
&& entry_point >= last_o_file_start)
--- 2308,2315 ----
case N_TEXT:
/* #endif */
SET_NAMESTRING();
!
! if (IS_O_FILE_START(namestring,nsl))
{
if (entry_point < bufp->n_value
&& entry_point >= last_o_file_start)
*************** read_dbx_symtab (desc, stringtab, string
*** 2149,2158 ****
startup_file_start = last_o_file_start;
startup_file_end = bufp->n_value;
}
! if (past_first_source_file && pst)
{
end_psymtab (pst, psymtab_include_list, includes_used,
! symnum * sizeof (struct nlist), bufp->n_value,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
--- 2317,2329 ----
startup_file_start = last_o_file_start;
startup_file_end = bufp->n_value;
}
! if (past_first_source_file && pst
! /* The gould NP1 uses low values for .o and -l symbols
! which are not the address. */
! && bufp->n_value > pst->textlow)
{
end_psymtab (pst, psymtab_include_list, includes_used,
! symnum * NLIST_STRUCT_SIZE, bufp->n_value,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
*************** read_dbx_symtab (desc, stringtab, string
*** 2222,2228 ****
if (pst && past_first_source_file)
{
end_psymtab (pst, psymtab_include_list, includes_used,
! symnum * sizeof (struct nlist), bufp->n_value,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
--- 2393,2399 ----
if (pst && past_first_source_file)
{
end_psymtab (pst, psymtab_include_list, includes_used,
! symnum * NLIST_STRUCT_SIZE, bufp->n_value,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
*************** read_dbx_symtab (desc, stringtab, string
*** 2233,2239 ****
past_first_source_file = 1;
pst = start_psymtab (namestring, bufp->n_value,
! symnum * sizeof (struct nlist),
global_psymbols.next, static_psymbols.next);
continue;
--- 2404,2410 ----
past_first_source_file = 1;
pst = start_psymtab (namestring, bufp->n_value,
! symnum * NLIST_STRUCT_SIZE,
global_psymbols.next, static_psymbols.next);
continue;
*************** read_dbx_symtab (desc, stringtab, string
*** 2437,2442 ****
--- 2608,2618 ----
case N_STSYM: /* Data seg var -- static */
case N_LCSYM: /* BSS " */
+ #if defined (N_NBSTS)
+ case N_NBSTS: /* Gould nobase. */
+ case N_NBLCS: /* symbols. */
+ #endif
+
/* Following may probably be ignored; I'll leave them here
for now (until I do Pascal and Modula 2 extensions). */
*************** read_dbx_symtab (desc, stringtab, string
*** 2627,2633 ****
if (pst)
{
end_psymtab (pst, psymtab_include_list, includes_used,
! symnum * sizeof (struct nlist), end_of_text_addr,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
includes_used = 0;
--- 2803,2809 ----
if (pst)
{
end_psymtab (pst, psymtab_include_list, includes_used,
! symnum * NLIST_STRUCT_SIZE, end_of_text_addr,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
includes_used = 0;
*************** psymtab_to_symtab(pst)
*** 2931,2936 ****
--- 3107,3113 ----
READ_FILE_HEADERS (desc, name);
+ #if 0
/* Read in the string table */
lseek (desc, STRING_TABLE_OFFSET, L_SET);
READ_STRING_TABLE_SIZE (stsize);
*************** psymtab_to_symtab(pst)
*** 2956,2961 ****
--- 3133,3141 ----
val = myread (desc, stringtab, stsize);
if (val < 0)
perror_with_name (name);
+ #endif /* 0 */
+ stringtab = symfile_string_table;
+ stsize = symfile_string_table_size;
psymtab_to_symtab_1 (pst, desc, stringtab, stsize,
SYMBOL_TABLE_OFFSET);
*************** read_ofile_symtab (desc, stringtab, stri
*** 3090,3105 ****
Detecting this in read_dbx_symtab
would slow down initial readin, so we look for it here instead. */
! if (sym_offset >= sizeof (struct nlist))
{
! lseek (desc, sym_offset - sizeof (struct nlist), L_INCR);
fill_symbuf ();
! bufp = &symbuf[symbuf_idx++];
! if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)
! error ("Invalid symbol data: bad string table offset: %d",
! bufp->n_un.n_strx);
! namestring = bufp->n_un.n_strx + stringtab;
processing_gcc_compilation =
(bufp->n_type == N_TEXT
--- 3270,3286 ----
Detecting this in read_dbx_symtab
would slow down initial readin, so we look for it here instead. */
!
! conv_symnum = 0;
! symnum_limit = sym_size / NLIST_STRUCT_SIZE;
!
! if (sym_offset >= NLIST_STRUCT_SIZE)
{
! lseek (desc, sym_offset - NLIST_STRUCT_SIZE, L_INCR);
fill_symbuf ();
! bufp = & NLIST_INDEX(symbuf,symbuf_idx++);
! SET_NAMESTRING();
processing_gcc_compilation =
(bufp->n_type == N_TEXT
*************** read_ofile_symtab (desc, stringtab, stri
*** 3116,3133 ****
if (symbuf_idx == symbuf_end)
fill_symbuf();
! bufp = &symbuf[symbuf_idx];
if ((unsigned char) bufp->n_type != N_SO)
fatal("First symbol in segment of executable not a source symbol");
for (symnum = 0;
! symnum < sym_size / sizeof(struct nlist);
symnum++)
{
QUIT; /* Allow this to be interruptable */
if (symbuf_idx == symbuf_end)
fill_symbuf();
! bufp = &symbuf[symbuf_idx++];
type = bufp->n_type;
if (type == N_CATCH)
--- 3297,3314 ----
if (symbuf_idx == symbuf_end)
fill_symbuf();
! bufp = & NLIST_INDEX(symbuf,symbuf_idx);
if ((unsigned char) bufp->n_type != N_SO)
fatal("First symbol in segment of executable not a source symbol");
for (symnum = 0;
! symnum < sym_size / NLIST_STRUCT_SIZE;
symnum++)
{
QUIT; /* Allow this to be interruptable */
if (symbuf_idx == symbuf_end)
fill_symbuf();
! bufp = & NLIST_INDEX(symbuf,symbuf_idx++);
type = bufp->n_type;
if (type == N_CATCH)
*************** read_ofile_symtab (desc, stringtab, stri
*** 3140,3149 ****
(type == N_TEXT || type == N_DATA || type == N_BSS))
bufp->n_value += text_offset;
! if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)
! error ("Invalid symbol data: bad string table offset: %d",
! bufp->n_un.n_strx);
! namestring = bufp->n_un.n_strx + stringtab;
if (type & N_STAB)
process_one_symbol(type, bufp->n_desc,
--- 3321,3327 ----
(type == N_TEXT || type == N_DATA || type == N_BSS))
bufp->n_value += text_offset;
! SET_NAMESTRING();
if (type & N_STAB)
process_one_symbol(type, bufp->n_desc,
*************** process_one_symbol (type, desc, value, n
*** 3259,3264 ****
--- 3437,3447 ----
switch (type)
{
+ #ifdef N_MULTI_LINE_TYPE
+ case N_MULTI_LINE_TYPE:
+ sun_enter_linenos (value);
+ break;
+ #endif
case N_FUN:
case N_FNAME:
/* Either of these types of symbols indicates the start of
*************** process_one_symbol (type, desc, value, n
*** 3366,3373 ****
--- 3549,3561 ----
new->start_addr = value;
/* Make a block for the local symbols within. */
finish_block (0, &local_symbols, new->old_blocks,
+ #if defined (BLOCK_ADDRESS_ABSOLUTE)
+ new->start_addr,
+ value);
+ #else
new->start_addr + last_source_start_addr,
value + last_source_start_addr);
+ #endif
}
else
{
*************** condense_addl_misc_bunches ()
*** 3521,3532 ****
/* Read in another .o file and create a symtab entry for it.*/
static void
! read_addl_syms (desc, stringtab, nlistlen, text_addr, text_size)
int desc;
register char *stringtab;
register int nlistlen;
unsigned text_addr;
int text_size;
{
FILE *stream = fdopen (desc, "r");
register char *namestring;
--- 3709,3721 ----
/* Read in another .o file and create a symtab entry for it.*/
static void
! read_addl_syms (desc, stringtab, nlistlen, text_addr, text_size, stringtab_size)
int desc;
register char *stringtab;
register int nlistlen;
unsigned text_addr;
int text_size;
+ int stringtab_size;
{
FILE *stream = fdopen (desc, "r");
register char *namestring;
*************** read_addl_syms (desc, stringtab, nlistle
*** 3541,3546 ****
--- 3730,3739 ----
bzero (global_sym_chain, sizeof global_sym_chain);
symtab_input_desc = desc;
stringtab_global = stringtab;
+
+ conv_symnum = 0;
+ symnum_limit = nlistlen;
+
fill_symbuf ();
for (symnum = 0; symnum < nlistlen; symnum++)
*************** read_addl_syms (desc, stringtab, nlistle
*** 3551,3559 ****
QUIT; /* allow this to be interruptable */
if (symbuf_idx == symbuf_end)
fill_symbuf ();
! bufp = &symbuf[symbuf_idx++];
type = bufp->n_type & N_TYPE;
! namestring = bufp->n_un.n_strx + stringtab;
if( (type == N_TEXT) || (type == N_DATA) || (type == N_BSS) )
{
--- 3744,3752 ----
QUIT; /* allow this to be interruptable */
if (symbuf_idx == symbuf_end)
fill_symbuf ();
! bufp = & NLIST_INDEX(symbuf,symbuf_idx++);
type = bufp->n_type & N_TYPE;
! SET_NAMESTRING();
if( (type == N_TEXT) || (type == N_DATA) || (type == N_BSS) )
{
*************** read_addl_syms (desc, stringtab, nlistle
*** 3593,3601 ****
int used_up = 0;
/* Record the location of _etext. */
! if (type == (N_TEXT | N_EXT)
! && !strcmp (namestring, "_etext"))
! end_of_text_addr = bufp->n_value;
#if 0
/* 25 Sep 89: The following seems to be stolen from
--- 3786,3793 ----
int used_up = 0;
/* Record the location of _etext. */
! if (type == (N_TEXT | N_EXT) && IS_ETEXT (namestring))
! end_of_text_addr = bufp->n_value;
#if 0
/* 25 Sep 89: The following seems to be stolen from
*************** add_file_command (arg_string)
*** 3786,3793 ****
global_symbols = 0;
make_cleanup (really_free_pendings, 0);
read_addl_syms (desc, stringtab, NUMBER_OF_SYMBOLS, text_addr,
! SIZE_OF_TEXT_SEGMENT);
/* Sort symbols alphabetically within each block. */
--- 3978,3989 ----
global_symbols = 0;
make_cleanup (really_free_pendings, 0);
+ #ifdef EXTRA_STRINGS_INIT
+ EXTRA_STRINGS_INIT (addl_extra_strings)
+ #endif
+
read_addl_syms (desc, stringtab, NUMBER_OF_SYMBOLS, text_addr,
! SIZE_OF_TEXT_SEGMENT, buffer /* really string table size */);
/* Sort symbols alphabetically within each block. */
*************** cleanup_undefined_types ()
*** 4282,4287 ****
--- 4478,4522 ----
}
undef_types_length = 0;
}
+ /* Skip rest of this symbol and return an error type.
+
+ General notes on error recovery: error_type always skips to the
+ end of the symbol (modulo cretinous dbx symbol name continuation).
+ Thus code like this:
+
+ if (*(*pp)++ != ';')
+ return error_type (pp);
+
+ is wrong because if *pp starts out pointing at '\0' (typically as the
+ result of an earlier error), it will be incremented to point to the
+ start of the next symbol, which might produce strange results, at least
+ if you run off the end of the string table. Instead use
+
+ if (**pp != ';')
+ return error_type (pp);
+ ++*pp;
+
+ And in case it isn't obvious, the point of all this hair is so the compiler
+ can define new types and new syntaxes, and old versions of the
+ debugger will be able to read the new symbol tables. */
+ static struct type *
+ error_type (pp)
+ char **pp;
+ {
+ while (1)
+ {
+ /* Skip to end of symbol. */
+ while (**pp != '\0')
+ (*pp)++;
+
+ /* Check for and handle cretinous dbx symbol name continuation! */
+ if ((*pp)[-1] == '\\')
+ *pp = next_symbol_text ();
+ else
+ break;
+ }
+ return builtin_type_error;
+ }
*************** read_struct_type (pp, type)
*** 4722,4728 ****
if (**pp == '\\')
*pp = next_symbol_text ();
! switch (*(*pp)++)
{
case '0':
via_virtual = 0;
--- 4957,4963 ----
if (**pp == '\\')
*pp = next_symbol_text ();
! switch (**pp)
{
case '0':
via_virtual = 0;
*************** read_struct_type (pp, type)
*** 4734,4741 ****
error ("Invalid symbol data: bad visibility format at symtab pos %d",
symnum);
}
! switch (*(*pp)++)
{
case '0':
via_public = 0;
--- 4969,4977 ----
error ("Invalid symbol data: bad visibility format at symtab pos %d",
symnum);
}
+ ++*pp;
! switch (**pp)
{
case '0':
via_public = 0;
*************** read_struct_type (pp, type)
*** 4744,4753 ****
via_public = 1;
break;
default:
! error ("Invalid symbol data: bad visibility format at symtab pos %d.",
! symnum);
}
/* Offset of the portion of the object corresponding to
this baseclass. Always zero in the absence of
multiple inheritance. */
--- 4980,4991 ----
via_public = 1;
break;
default:
! /* Bad visibility format. */
! return error_type (pp);
}
+ ++*pp;
+
/* Offset of the portion of the object corresponding to
this baseclass. Always zero in the absence of
multiple inheritance. */
*************** read_struct_type (pp, type)
*** 4911,4918 ****
continue;
}
else if (**pp != ',')
! error ("Invalid symbol data: bad structure-type format at symtab pos %d.",
! symnum);
(*pp)++; /* Skip the comma. */
list->field.bitpos = read_number (pp, ',');
list->field.bitsize = read_number (pp, ';');
--- 5149,5157 ----
continue;
}
else if (**pp != ',')
! /* Bad structure-type format. */
! return error_type (pp);
!
(*pp)++; /* Skip the comma. */
list->field.bitpos = read_number (pp, ',');
list->field.bitsize = read_number (pp, ';');
*************** Therefore GDB will not know about your c
*** 5040,5047 ****
new_sublist->fn_field.type = read_type (pp);
if (**pp != ':')
! error ("invalid symtab info for method at symbol number %d.",
! symnum);
*pp += 1;
p = *pp;
while (*p != ';') p++;
--- 5279,5287 ----
new_sublist->fn_field.type = read_type (pp);
if (**pp != ':')
! /* Invalid symtab info for method. */
! return error_type (pp);
!
*pp += 1;
p = *pp;
while (*p != ';') p++;
*************** Therefore GDB will not know about your c
*** 5180,5186 ****
t = read_type (pp);
p = (*pp)++;
! while (*p != ';') p++;
TYPE_VPTR_BASETYPE (type) = t;
if (type == t)
{
--- 5420,5430 ----
t = read_type (pp);
p = (*pp)++;
! while (*p != '\0' && *p != ';') p++;
! if (*p == '\0')
! /* Premature end of symbol. */
! return error_type (pp);
!
TYPE_VPTR_BASETYPE (type) = t;
if (type == t)
{
*************** Therefore GDB will not know about your c
*** 5193,5199 ****
break;
}
if (i < 0)
! error ("virtual function table field not found");
}
else
TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
--- 5437,5444 ----
break;
}
if (i < 0)
! /* Virtual function table field not found. */
! return error_type (pp);
}
else
TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
*************** read_array_type (pp, type)
*** 5235,5242 ****
for these, produce a type like float[][]. */
index_type = read_type (pp);
! if (*(*pp)++ != ';')
! error ("Invalid symbol data; improper format of array type decl.");
if (!(**pp >= '0' && **pp <= '9'))
{
--- 5480,5489 ----
for these, produce a type like float[][]. */
index_type = read_type (pp);
! if (**pp != ';')
! /* Improper format of array type decl. */
! return error_type (pp);
! ++*pp;
if (!(**pp >= '0' && **pp <= '9'))
{
*************** read_range_type (pp, typenums)
*** 5507,5513 ****
else if (n2 >= MIN_OF_TYPE(long) && n3 <= MAX_OF_TYPE(long))
TYPE_LENGTH (result_type) = sizeof (long);
else
! error ("Ranged type doesn't fit within known sizes.");
TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type));
TYPE_CODE (result_type) = TYPE_CODE_RANGE;
--- 5754,5761 ----
else if (n2 >= MIN_OF_TYPE(long) && n3 <= MAX_OF_TYPE(long))
TYPE_LENGTH (result_type) = sizeof (long);
else
! /* Ranged type doesn't fit within known sizes. */
! return error_type (pp);
TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type));
TYPE_CODE (result_type) = TYPE_CODE_RANGE;
diff -pr gdb-3.6/i386-dep.c ../gdb-3.6/i386-dep.c
*** gdb-3.6/i386-dep.c Wed Jan 10 15:58:05 1990
--- ../gdb-3.6/i386-dep.c Tue Aug 7 22:04:08 1990
*************** exec_file_command (filename, from_tty)
*** 501,508 ****
--- 501,513 ----
aout_hdrsize = file_hdr.f_opthdr;
num_sections = file_hdr.f_nscns;
+ #ifndef NEVER
+ if ( ! aout_hdrsize )
+ printf ("Warning: no optional header--File may be relocatable.\n");
+ #else
if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0)
error ("\"%s\": can't read optional aouthdr", execfile);
+ #endif
if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections,
aout_hdrsize) < 0)
diff -pr gdb-3.6/m-i386-sv32.h ../gdb-3.6/m-i386-sv32.h
*** gdb-3.6/m-i386-sv32.h Wed Aug 16 14:20:30 1989
--- ../gdb-3.6/m-i386-sv32.h Tue Aug 7 22:04:08 1990
*************** You should have received a copy of the G
*** 17,24 ****
along with GDB; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
! #include "m-i386.h"
/* Apparently there is inconsistency among various System V's about what
the name of this field is. */
#define U_FPSTATE(u) u.u_fps.u_fpstate
--- 17,398 ----
along with GDB; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
! /* Define the bit, byte, and word ordering of the machine. */
! /* #define BITS_BIG_ENDIAN */
! /* #define BYTES_BIG_ENDIAN */
! /* #define WORDS_BIG_ENDIAN */
+ /*
+ * Changes for 80386 by Pace Willisson (pace at prep.ai.mit.edu)
+ * July 1988
+ */
+
+
+ #ifndef i386
+ #define i386
+ #endif
+
+ /* I'm running gdb 3.4 under 386/ix 2.0.2, which is a derivative of AT&T's
+ Sys V/386 3.2.
+
+ On some machines, gdb crashes when it's starting up while calling the
+ vendor's termio tgetent() routine. It always works when run under
+ itself (actually, under 3.2, it's not an infinitely recursive bug.)
+ After some poking around, it appears that depending on the environment
+ size, or whether you're running YP, or the phase of the moon or something,
+ the stack is not always long-aligned when main() is called, and tgetent()
+ takes strong offense at that. On some machines this bug never appears, but
+ on those where it does, it occurs quite reliably. */
+ #define ALIGN_STACK_ON_STARTUP
+
+ /* define USG if you are using sys5 /usr/include's */
+ #define USG
+
+ /* USG systems need these */
+ #define vfork() fork()
+ #define MAXPATHLEN 500
+
+ /* define this if you don't have the extension to coff that allows
+ * file names to appear in the string table
+ * (aux.x_file.x_foff)
+ */
+ #define COFF_NO_LONG_FILE_NAMES
+
+ /* turn this on when rest of gdb is ready */
+ /* #define IEEE_FLOAT */
+
+ #define NBPG NBPC
+ #define UPAGES USIZE
+
+ #define HAVE_TERMIO
+
+ /* Get rid of any system-imposed stack limit if possible. */
+
+ /* #define SET_STACK_LIMIT_HUGE not in sys5 */
+
+ /* Define this if the C compiler puts an underscore at the front
+ of external names before giving them to the linker. */
+
+ /* #define NAMES_HAVE_UNDERSCORE */
+
+ /* Specify debugger information format. */
+
+ #define READ_DBX_FORMAT
+ #define COFF_FORMAT
+
+ /* number of traps that happen between exec'ing the shell
+ * to run an inferior, and when we finally get to
+ * the inferior code. This is 2 on most implementations.
+ */
+ #define START_INFERIOR_TRAPS_EXPECTED 4
+
+ /* Offset from address of function to start of its code.
+ Zero on most machines. */
+
+ #define FUNCTION_START_OFFSET 0
+
+ /* Advance PC across any function entry prologue instructions
+ to reach some "real" code. */
+
+ #define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
+
+ /* Immediately after a function call, return the saved pc.
+ Can't always go through the frames for this because on some machines
+ the new frame is not set up until the new function executes
+ some instructions. */
+
+ #define SAVED_PC_AFTER_CALL(frame) \
+ (read_memory_integer (read_register (SP_REGNUM), 4))
+
+ /* This is the amount to subtract from u.u_ar0
+ to get the offset in the core file of the register values. */
+
+ #define KERNEL_U_ADDR 0xe0000000
+
+ /* Address of end of stack space. */
+
+ #define STACK_END_ADDR 0x80000000
+
+ /* Stack grows downward. */
+
+ #define INNER_THAN <
+
+ /* Sequence of bytes for breakpoint instruction. */
+
+ #define BREAKPOINT {0xcc}
+
+ /* Amount PC must be decremented by after a breakpoint.
+ This is often the number of bytes in BREAKPOINT
+ but not always. */
+
+ #define DECR_PC_AFTER_BREAK 1
+
+ /* Nonzero if instruction at PC is a return instruction. */
+
+ #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc3)
+
+ /* Return 1 if P points to an invalid floating point value.
+ LEN is the length in bytes -- not relevant on the 386. */
+
+ #define INVALID_FLOAT(p, len) (0)
+
+ /* code to execute to print interesting information about the
+ * floating point processor (if any)
+ * No need to define if there is nothing to do.
+ */
+ #define FLOAT_INFO { i386_float_info (); }
+
+
+ /* Largest integer type */
+ #define LONGEST long
+
+ /* Name of the builtin type for the LONGEST type above. */
+ #define BUILTIN_TYPE_LONGEST builtin_type_long
+
+ /* Say how long (ordinary) registers are. */
+
+ #define REGISTER_TYPE long
+
+ /* Number of machine registers */
+
+ #define NUM_REGS 16
+
+ /* Initializer for an array of names of registers.
+ There should be NUM_REGS strings in this initializer. */
+
+ /* the order of the first 8 registers must match the compiler's
+ * numbering scheme (which is the same as the 386 scheme)
+ * also, this table must match regmap in i386-pinsn.c.
+ */
+ #define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \
+ "esp", "ebp", "esi", "edi", \
+ "eip", "ps", "cs", "ss", \
+ "ds", "es", "fs", "gs", \
+ }
+
+ /* Register numbers of various important registers.
+ Note that some of these values are "real" register numbers,
+ and correspond to the general registers of the machine,
+ and some are "phony" register numbers which are too large
+ to be actual register numbers as far as the user is concerned
+ but do serve to get the desired values when passed to read_register. */
+
+ #define FP_REGNUM 5 /* Contains address of executing stack frame */
+ #define SP_REGNUM 4 /* Contains address of top of stack */
+
+ #define PC_REGNUM 8
+ #define PS_REGNUM 9
+
+ #define REGISTER_U_ADDR(addr, blockend, regno) \
+ (addr) = i386_register_u_addr ((blockend),(regno));
+
+ /* Total amount of space needed to store our copies of the machine's
+ register state, the array `registers'. */
+ #define REGISTER_BYTES (NUM_REGS * 4)
+
+ /* Index within `registers' of the first byte of the space for
+ register N. */
+
+ #define REGISTER_BYTE(N) ((N)*4)
+
+ /* Number of bytes of storage in the actual machine representation
+ for register N. */
+
+ #define REGISTER_RAW_SIZE(N) (4)
+
+ /* Number of bytes of storage in the program's representation
+ for register N. */
+
+ #define REGISTER_VIRTUAL_SIZE(N) (4)
+
+ /* Largest value REGISTER_RAW_SIZE can have. */
+
+ #define MAX_REGISTER_RAW_SIZE 4
+
+ /* Largest value REGISTER_VIRTUAL_SIZE can have. */
+
+ #define MAX_REGISTER_VIRTUAL_SIZE 4
+
+ /* Nonzero if register N requires conversion
+ from raw format to virtual format. */
+
+ #define REGISTER_CONVERTIBLE(N) (0)
+
+ /* Convert data from raw format for register REGNUM
+ to virtual format for register REGNUM. */
+
+ #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
+
+ /* Convert data from virtual format for register REGNUM
+ to raw format for register REGNUM. */
+
+ #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
+
+ /* Return the GDB type object for the "standard" data type
+ of data in register N. */
+
+ #define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
+
+ /* Store the address of the place in which to copy the structure the
+ subroutine will return. This is called from call_function. */
+
+ #define STORE_STRUCT_RETURN(ADDR, SP) \
+ { (SP) -= sizeof (ADDR); \
+ write_memory ((SP), &(ADDR), sizeof (ADDR)); }
+
+ /* Extract from an array REGBUF containing the (raw) register state
+ a function return value of type TYPE, and copy that, in virtual format,
+ into VALBUF. */
+
+ #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
+ bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
+
+ /* Write into appropriate registers a function return value
+ of type TYPE, given in virtual format. */
+
+ #define STORE_RETURN_VALUE(TYPE,VALBUF) \
+ write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
+
+ /* Extract from an array REGBUF containing the (raw) register state
+ the address in which a function should return its structure value,
+ as a CORE_ADDR (or an expression that can be used as one). */
+
+ #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
+
+
+ /* Describe the pointer in each stack frame to the previous stack frame
+ (its caller). */
+
+ /* FRAME_CHAIN takes a frame's nominal address
+ and produces the frame's chain-pointer.
+
+ FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
+ and produces the nominal address of the caller frame.
+
+ However, if FRAME_CHAIN_VALID returns zero,
+ it means the given frame is the outermost one and has no caller.
+ In that case, FRAME_CHAIN_COMBINE is not used. */
+
+ #define FRAME_CHAIN(thisframe) \
+ (outside_startup_file ((thisframe)->pc) ? \
+ read_memory_integer ((thisframe)->frame, 4) :\
+ 0)
+
+ #define FRAME_CHAIN_VALID(chain, thisframe) \
+ (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
+
+ #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
+
+ /* Define other aspects of the stack frame. */
+
+ /* A macro that tells us whether the function invocation represented
+ by FI does not have a frame on the stack associated with it. If it
+ does not, FRAMELESS is set to 1, else 0. */
+ #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
+ FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
+
+ #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
+
+ #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
+
+ #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
+
+ /* Return number of args passed to a frame.
+ Can return -1, meaning no way to tell. */
+
+ #define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi)
+
+ /* Return number of bytes at start of arglist that are not really args. */
+
+ #define FRAME_ARGS_SKIP 8
+
+ /* Put here the code to store, into a struct frame_saved_regs,
+ the addresses of the saved registers of frame described by FRAME_INFO.
+ This includes special registers such as pc and fp saved in special
+ ways in the stack frame. sp is even more special:
+ the address we return for it IS the sp for the next frame. */
+
+ #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
+ { i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
+
+
+ /* Things needed for making the inferior call functions. */
+
+ /* Push an empty stack frame, to record the current PC, etc. */
+
+ #define PUSH_DUMMY_FRAME { i386_push_dummy_frame (); }
+
+ /* Discard from the stack the innermost frame, restoring all registers. */
+
+ #define POP_FRAME { i386_pop_frame (); }
+
+ /* this is
+ * call 11223344 (32 bit relative)
+ * int3
+ */
+
+ #define CALL_DUMMY { 0x223344e8, 0xcc11 }
+
+ #define CALL_DUMMY_LENGTH 8
+
+ #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
+
+ /* Insert the specified number of args and function address
+ into a call sequence of the above form stored at DUMMYNAME. */
+
+ #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
+ { \
+ int from, to, delta, loc; \
+ loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
+ from = loc + 5; \
+ to = (int)(fun); \
+ delta = to - from; \
+ *(int *)((char *)(dummyname) + 1) = delta; \
+ }
+
+
+ #if 0
+ /* Interface definitions for kernel debugger KDB. */
+
+ /* Map machine fault codes into signal numbers.
+ First subtract 0, divide by 4, then index in a table.
+ Faults for which the entry in this table is 0
+ are not handled by KDB; the program's own trap handler
+ gets to handle then. */
+
+ #define FAULT_CODE_ORIGIN 0
+ #define FAULT_CODE_UNITS 4
+ #define FAULT_TABLE \
+ { 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0}
+
+ /* Start running with a stack stretching from BEG to END.
+ BEG and END should be symbols meaningful to the assembler.
+ This is used only for kdb. */
+
+ #define INIT_STACK(beg, end) {}
+
+ /* Push the frame pointer register on the stack. */
+ #define PUSH_FRAME_PTR {}
+
+ /* Copy the top-of-stack to the frame pointer register. */
+ #define POP_FRAME_PTR {}
+
+ /* After KDB is entered by a fault, push all registers
+ that GDB thinks about (all NUM_REGS of them),
+ so that they appear in order of ascending GDB register number.
+ The fault code will be on the stack beyond the last register. */
+
+ #define PUSH_REGISTERS {}
+
+ /* Assuming the registers (including processor status) have been
+ pushed on the stack in order of ascending GDB register number,
+ restore them and return to the address in the saved PC register. */
+
+ #define POP_REGISTERS {}
+ #endif
+
/* Apparently there is inconsistency among various System V's about what
the name of this field is. */
#define U_FPSTATE(u) u.u_fps.u_fpstate
*************** the Free Software Foundation, 675 Mass A
*** 26,28 ****
--- 400,498 ----
/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars
is not. This makes problems for inflow.c. */
#define TIOCGETC_BROKEN
+
+ /* COFF PARAMS: */
+ /* Macro to declare variables to hold the file's header data. */
+ #define DECLARE_FILE_HEADERS struct aouthdr hdr; \
+ FILHDR coffhdr; SCNHDR scn[10];/*char * extra_strings; */ \
+ extern int text_scn, data_scn, bss_scn
+
+ /* macro to declare the entry point of this file */
+ #define ENTRY_POINT hdr.entry
+
+ /* Macro for number of symbol table entries */
+ #define NUMBER_OF_SYMBOLS (coffhdr.f_nsyms)
+
+ /* Macro for file-offset of string table (in usual a.out format). */
+ #define STRING_TABLE_OFFSET (coffhdr.f_symptr+coffhdr.f_nsyms*SYMESZ)
+
+ /* Macro for file-offset of symbol table (in usual a.out format). */
+ #define SYMBOL_TABLE_OFFSET (coffhdr.f_symptr)
+
+ #define IS_OBJECT_FILE ((hdr.f_flags & F_EXEC) == 0)
+
+ /* Get the address in debugged memory of the start
+ of the text segment. */
+ #define ADDR_OF_TEXT_SEGMENT (scn[text_scn].s_vaddr)
+
+ /* Macro for size of text segment */
+ #define SIZE_OF_TEXT_SEGMENT (scn[text_scn].s_size)
+
+ #define TEXT_SECTION_NAME ".text"
+ #define DATA_SECTION_NAME ".data"
+ #define BSS_SECTION_NAME ".bss"
+
+ /* Macro to read the header data from descriptor DESC and validate it.
+ NAME is the file name, for error messages. */
+
+ #define READ_FILE_HEADERS(DESC, NAME) \
+ { int optsz,i; \
+ int val = myread (DESC, &coffhdr, sizeof coffhdr); \
+ if (val < 0) \
+ perror_with_name (NAME); \
+ if (!ISCOFF(coffhdr.f_magic)) \
+ error ("File \"%s\" not in coff executable format.", NAME); \
+ number_of_symbols = coffhdr.f_nsyms; \
+ optsz = (coffhdr.f_opthdr> sizeof hdr)?sizeof hdr:coffhdr.f_opthdr; \
+ val = myread (DESC, &hdr, optsz); \
+ if (val < 0) \
+ perror_with_name (NAME); \
+ /* if (N_BADMAG (hdr)) \
+ error ("File \"%s\" not in executable format.", NAME); */ \
+ bzero(&scn[0],sizeof(scn[0])); \
+ val = myread (DESC, &scn[1], sizeof scn[0]*coffhdr.f_nscns); \
+ if (val < 0) \
+ perror_with_name (NAME); \
+ clear_coff_sections(); \
+ for (i = 1; i <=coffhdr.f_nscns;i++) \
+ map_coff_section(i,&scn[i]); \
+ }
+
+ /* Define SETJMP_MASKS_SIGNALS if your operating system uses bsd style
+ signals but has the old signal mask is not restored after a longjmp. */
+ /* #define SETJMP_MASKS_SIGNALS DEFINED via config.gdb now */
+
+ #ifdef COFF_FORMAT
+
+ /* This is the type to set unwanted symbols to in convert_symbuf() */
+ #define IGNORED_SYMBOL_TYPE ( 0xff)
+
+ /* Function auxents containing line table indexes are converted to symbols
+ having this type: */
+ #define N_MULTI_LINE_TYPE ( 0xf0)
+
+ /* This is how dbxread recognizes symbols to be ignored */
+ #define IGNORE_SYMBOL(type) (IGNORED_SYMBOL_TYPE==type)
+
+ #endif
+
+ /* this is the ON DISK size of a symbol. This may not be the same as the
+ value sizeof() yields. On the sun 386i, they are not the same */
+ #define NLIST_STRUCT_SIZE SYMESZ
+
+ /* This is how to increment a pointer to a symbol. usually: p++ */
+ #define NLIST_INCR(p) p = (struct nlist *) ((int)p + SYMESZ )
+
+ /* This is how to index into an arrayof symbols. Usually: ptr[index] */
+ #define NLIST_INDEX(ptr,index) (* (struct nlist *) ((int)ptr + index*SYMESZ))
+
+ /* define this if preprocessing needs to be done on a buffer of symbols. */
+ #define CONVERT_SYMBUF
+
+ /* define this if absolute values are used for block symbols */
+ #define BLOCK_ADDRESS_ABSOLUTE
+
+ #define ADJUST_STARTUP_VALUES
+ #define NO_NATIVE_STAB_INCLUDE
+
+ #define EXTRA_MISC_INIT extra_misc_init() ; /* move to dep */
diff -pr gdb-3.6/main.c ../gdb-3.6/main.c
*** gdb-3.6/main.c Fri Jan 26 12:12:59 1990
--- ../gdb-3.6/main.c Wed Aug 8 17:20:53 1990
*************** int linesize;
*** 156,161 ****
--- 156,174 ----
jmp_buf to_top_level;
+ /* This kludge is for the TTI Unicom "pbb" systems, which implement
+ the signal mask in signal() but not in setjmp()!!! The expression
+ below will call setjmp, and then if setjmp returned nonzero, it executes
+ the sigsetmask and returns a 1 itself. None of the setjmp callers
+ in this function care about the result from setjmp, only whether it
+ is zero or nonzero. */
+
+ #ifdef SETJMP_MASKS_SIGNALS
+ #define kludge_setjmp(x) (setjmp(x) && (sigsetmask (0), 1))
+ #else
+ #define kludge_setjmp(x) setjmp(x)
+ #endif
+
void
return_to_top_level ()
{
*************** catch_errors (func, arg, errstring)
*** 187,193 ****
bcopy (to_top_level, saved, sizeof (jmp_buf));
! if (setjmp (to_top_level) == 0)
val = (*func) (arg);
else
{
--- 200,206 ----
bcopy (to_top_level, saved, sizeof (jmp_buf));
! if (kludge_setjmp (to_top_level) == 0)
val = (*func) (arg);
else
{
*************** GDB manual (available as on-line info or
*** 351,357 ****
if (++i == argc)
fprintf (stderr, "No argument follows \"%s\".\n", arg);
! if (!setjmp (to_top_level))
{
/* -s foo: get syms from foo. -e foo: execute foo.
-se foo: do both with foo. -c foo: use foo as core dump. */
--- 364,370 ----
if (++i == argc)
fprintf (stderr, "No argument follows \"%s\".\n", arg);
! if (!kludge_setjmp (to_top_level))
{
/* -s foo: get syms from foo. -e foo: execute foo.
-se foo: do both with foo. -c foo: use foo as core dump. */
*************** GDB manual (available as on-line info or
*** 396,402 ****
are treated as, first, the symbol/executable file
and, second, the core dump file. */
count++;
! if (!setjmp (to_top_level))
switch (count)
{
case 1:
--- 409,415 ----
are treated as, first, the symbol/executable file
and, second, the core dump file. */
count++;
! if (!kludge_setjmp (to_top_level))
switch (count)
{
case 1:
*************** GDB manual (available as on-line info or
*** 427,433 ****
strcpy (homeinit, getenv ("HOME"));
strcat (homeinit, "/.gdbinit");
if (!inhibit_gdbinit && access (homeinit, R_OK) == 0)
! if (!setjmp (to_top_level))
source_command (homeinit);
/* Do stats; no need to do them elsewhere since we'll only
--- 440,446 ----
strcpy (homeinit, getenv ("HOME"));
strcat (homeinit, "/.gdbinit");
if (!inhibit_gdbinit && access (homeinit, R_OK) == 0)
! if (!kludge_setjmp (to_top_level))
source_command (homeinit);
/* Do stats; no need to do them elsewhere since we'll only
*************** GDB manual (available as on-line info or
*** 451,457 ****
(char *) &cwdbuf,
sizeof (struct stat)))
if (!inhibit_gdbinit && access (".gdbinit", R_OK) == 0)
! if (!setjmp (to_top_level))
source_command (".gdbinit");
}
--- 464,470 ----
(char *) &cwdbuf,
sizeof (struct stat)))
if (!inhibit_gdbinit && access (".gdbinit", R_OK) == 0)
! if (!kludge_setjmp (to_top_level))
source_command (".gdbinit");
}
*************** GDB manual (available as on-line info or
*** 471,477 ****
while (1)
{
! if (!setjmp (to_top_level))
command_loop ();
clearerr (stdin); /* Don't get hung if C-d is typed. */
}
--- 484,490 ----
while (1)
{
! if (!kludge_setjmp (to_top_level))
command_loop ();
clearerr (stdin); /* Don't get hung if C-d is typed. */
}
*************** stop_sig ()
*** 751,757 ****
--- 764,772 ----
{
#if STOP_SIGNAL == SIGTSTP
signal (SIGTSTP, SIG_DFL);
+ #ifdef SETJMP_MASKS_SIGNALS
sigsetmask (0);
+ #endif
kill (getpid (), SIGTSTP);
signal (SIGTSTP, stop_sig);
#else
diff -pr gdb-3.6/malloc.c ../gdb-3.6/malloc.c
*** gdb-3.6/malloc.c Sat Sep 30 12:48:54 1989
--- ../gdb-3.6/malloc.c Tue Aug 7 21:23:14 1990
*************** what you give them. Help stamp out sof
*** 171,177 ****
--- 171,179 ----
#ifndef BSD4_2
#ifndef USG
+ #ifndef i386
#include <sys/vlimit.h> /* warn the user when near the end */
+ #endif
#endif /* not USG */
#else /* if BSD4_2 */
#include <sys/time.h>
diff -pr gdb-3.6/munch ../gdb-3.6/munch
*** gdb-3.6/munch Wed Jul 5 12:46:28 1989
--- ../gdb-3.6/munch Tue Aug 7 21:00:37 1990
*************** if test "$1" = "-DSYSV" ; then
*** 10,17 ****
nm $* | egrep '^(.*[^a-zA-Z_]_|_)initialize_' | \
sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\)[^a-zA-Z0-9_].*$/ \1 ();/'
else
! nm -p $* | egrep 'T *__initialize_' | \
! sed -e 's/^.*T *_*\(.*\)/ _\1 ();/'
fi
echo '}'
--- 10,25 ----
nm $* | egrep '^(.*[^a-zA-Z_]_|_)initialize_' | \
sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\)[^a-zA-Z0-9_].*$/ \1 ();/'
else
!
! # if (NAMES_HAVE_UNDERSCORES)
!
! if test ""`nm version.o |grep -c _version` != 0 ; then
! nm -p $* | egrep 'T *__initialize_' | \
! sed -e 's/^.*T *_*\(.*\)/ _\1 ();/'
! else
! nm -p $* | egrep 'T *_initialize_' | \
! sed -e 's/^.*T *_*\(.*\)/ _\1 ();/'
! fi
fi
echo '}'
diff -pr gdb-3.6/printcmd.c ../gdb-3.6/printcmd.c
*** gdb-3.6/printcmd.c Fri Jan 19 19:32:54 1990
--- ../gdb-3.6/printcmd.c Thu Aug 16 17:44:41 1990
*************** set_next_address (addr)
*** 396,428 ****
value_from_long (builtin_type_int, (LONGEST) addr));
}
! /* Print address ADDR symbolically on STREAM.
! First print it as a number. Then perhaps print
! <SYMBOL + OFFSET> after the number. */
void
! print_address (addr, stream)
CORE_ADDR addr;
FILE *stream;
{
- register int i = 0;
register char *format;
- register struct symbol *fs;
- char *name;
int name_location;
- i = find_pc_partial_function (addr, &name, &name_location);
-
/* If nothing comes out, don't print anything symbolic. */
!
! if (i == 0)
! format = "0x%x";
! else if (addr - name_location)
! format = "0x%x <%s+%d>";
else
! format = "0x%x <%s>";
! fprintf_filtered (stream, format, addr, name, addr - name_location);
}
/* Examine data at address ADDR in format FMT.
--- 396,436 ----
value_from_long (builtin_type_int, (LONGEST) addr));
}
! /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM. */
void
! print_address_symbolic (addr, stream)
CORE_ADDR addr;
FILE *stream;
{
register char *format;
int name_location;
+ register int i = find_pc_misc_function (addr);
/* If nothing comes out, don't print anything symbolic. */
! if (i < 0) return;
! name_location = misc_function_vector[i].address;
!
! if (addr - name_location)
! format = " <%s+%d>";
else
! format = " <%s>";
!
! fprintf_filtered (stream, format,
! misc_function_vector[i].name, addr - name_location);
! }
!
! /* Print address ADDR symbolically on STREAM.
! First print it as a number. Then perhaps print
! <SYMBOL + OFFSET> after the number. */
! void
! print_address (addr, stream)
! CORE_ADDR addr;
! FILE *stream;
! {
! fprintf_filtered (stream, "0x%x", addr);
! print_address_symbolic (addr, stream);
}
/* Examine data at address ADDR in format FMT.
diff -pr gdb-3.6/readline/Makefile ../gdb-3.6/readline/Makefile
*** gdb-3.6/readline/Makefile Wed Feb 7 22:05:33 1990
--- ../gdb-3.6/readline/Makefile Tue Aug 7 21:00:54 1990
*************** READLINE_DEFINES = -DVI_MODE
*** 33,39 ****
DEBUG_FLAGS = -g
LDFLAGS = $(DEBUG_FLAGS)
! CFLAGS = $(DEBUG_FLAGS) $(TYPE) $(SYSV) -I.
# A good alternative is gcc -traditional.
#CC = gcc -traditional
--- 33,39 ----
DEBUG_FLAGS = -g
LDFLAGS = $(DEBUG_FLAGS)
! CFLAGS = $(DEBUG_FLAGS) $(TYPES) $(SIGS) $(SYSV) -I.
# A good alternative is gcc -traditional.
#CC = gcc -traditional
diff -pr gdb-3.6/readline/readline.c ../gdb-3.6/readline/readline.c
*** gdb-3.6/readline/readline.c Sun Nov 26 13:31:36 1989
--- ../gdb-3.6/readline/readline.c Tue Aug 7 21:01:06 1990
*************** readline_internal ()
*** 320,330 ****
while (!rl_done)
{
int lk = last_command_was_kill;
int code = setjmp (readline_top_level);
if (code)
! rl_redisplay ();
!
if (!rl_pending_input)
{
/* Then initialize the argument and number of keys read. */
--- 320,337 ----
while (!rl_done)
{
int lk = last_command_was_kill;
+ #ifdef SETJMP_MASKS_SIGNALS
+ int mask = sigblock(0);
+ #endif
int code = setjmp (readline_top_level);
if (code)
! {
! #ifdef SETJMP_MASKS_SIGNALS
! sigsetmask(mask);
! #endif
! rl_redisplay ();
! }
if (!rl_pending_input)
{
/* Then initialize the argument and number of keys read. */
diff -pr gdb-3.6/stack.c ../gdb-3.6/stack.c
*** gdb-3.6/stack.c Tue Jun 5 07:19:27 1990
--- ../gdb-3.6/stack.c Thu Aug 16 17:44:42 1990
*************** print_frame_info (fi, level, source, arg
*** 99,105 ****
printf_filtered ("#%-2d ", level);
printf_filtered ("0x%x in ", fi->pc);
! printf_filtered ("%s (...) (...)\n", fname);
return;
}
--- 99,106 ----
printf_filtered ("#%-2d ", level);
printf_filtered ("0x%x in ", fi->pc);
! fputs_demangled(fname, stdout, -1);
! fputs_filtered(" (...)\n", stdout);
return;
}
*************** print_frame_info (fi, level, source, arg
*** 152,158 ****
printf ("#%-2d ", 0);
if (fi->pc != sal.pc || !sal.symtab)
printf_filtered ("0x%x in ", fi->pc);
! printf_filtered ("%s (", funname ? funname : "??");
if (args)
{
FRAME_NUM_ARGS (numargs, fi);
--- 153,160 ----
printf ("#%-2d ", 0);
if (fi->pc != sal.pc || !sal.symtab)
printf_filtered ("0x%x in ", fi->pc);
! fputs_demangled(funname ? funname : "??", stdout, -1);
! printf_filtered(" (");
if (args)
{
FRAME_NUM_ARGS (numargs, fi);
*************** print_block_frame_labels (b, frame, have
*** 571,577 ****
struct symtab_and_line sal;
sal = find_pc_line (SYMBOL_VALUE (sym), 0);
values_printed = 1;
! fputs_filtered (SYMBOL_NAME (sym), stream);
fprintf_filtered (stream, " 0x%x in file %s, line %d\n",
SYMBOL_VALUE (sym), sal.symtab->filename, sal.line);
fflush (stream);
--- 573,579 ----
struct symtab_and_line sal;
sal = find_pc_line (SYMBOL_VALUE (sym), 0);
values_printed = 1;
! fputs_demangled (SYMBOL_NAME (sym), stream, 1);
fprintf_filtered (stream, " 0x%x in file %s, line %d\n",
SYMBOL_VALUE (sym), sal.symtab->filename, sal.line);
fflush (stream);
diff -pr gdb-3.6/symseg.h ../gdb-3.6/symseg.h
*** gdb-3.6/symseg.h Tue Jun 26 05:39:01 1990
--- ../gdb-3.6/symseg.h Tue Aug 7 21:00:38 1990
*************** enum type_code
*** 117,122 ****
--- 117,123 ----
TYPE_CODE_SET, /* Pascal sets */
TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */
TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */
+ TYPE_CODE_ERROR, /* Unknown type */
/* C++ */
TYPE_CODE_MEMBER, /* Member type */
*************** struct partial_symbol
*** 470,479 ****
* Vectors of all partial symbols read in from file; actually declared
* and used in dbxread.c.
*/
! extern struct psymbol_allocation_list {
struct partial_symbol *list, *next;
int size;
! } global_psymbols, static_psymbols;
/* Source-file information.
--- 471,480 ----
* Vectors of all partial symbols read in from file; actually declared
* and used in dbxread.c.
*/
! struct psymbol_allocation_list {
struct partial_symbol *list, *next;
int size;
! };
/* Source-file information.
diff -pr gdb-3.6/symtab.c ../gdb-3.6/symtab.c
*** gdb-3.6/symtab.c Wed Jul 4 05:27:41 1990
--- ../gdb-3.6/symtab.c Thu Aug 16 17:44:44 1990
*************** the Free Software Foundation, 675 Mass A
*** 26,31 ****
--- 26,33 ----
#include <assert.h>
char *index ();
+ extern char *cplus_demangle ();
+ extern struct value * value_of_this ();
/* Allocate an obstack to hold objects that should be freed
when we load a new symbol table.
*************** struct type *builtin_type_unsigned_long_
*** 65,70 ****
--- 67,73 ----
#endif
struct type *builtin_type_float;
struct type *builtin_type_double;
+ struct type *builtin_type_error;
/* Block in which the most recently searched-for symbol was found.
Might be better to make this a parameter to lookup_symbol and
*************** lookup_symbol (name, block, namespace, i
*** 934,940 ****
check to see if NAME is a field of `this'. */
if (is_a_field_of_this)
{
! int v = (int) value_of_this (0);
*is_a_field_of_this = 0;
if (v && check_field (v, name))
--- 937,943 ----
check to see if NAME is a field of `this'. */
if (is_a_field_of_this)
{
! struct value *v = value_of_this (0);
*is_a_field_of_this = 0;
if (v && check_field (v, name))
*************** lookup_symbol (name, block, namespace, i
*** 967,972 ****
--- 970,995 ----
{
int index = lookup_misc_func (name);
+ if (index == -1)
+ { /* Look for a mangled C++ name for NAME. */
+ int name_len = strlen (name);
+ for (index = misc_function_count; --index >= 0; )
+ /* Assume orginal name is prefix of mangled name. */
+ if (!strncmp (misc_function_vector[index].name, name, name_len))
+ {
+ char *demangled =
+ cplus_demangle(misc_function_vector[index].name, -1);
+ if (demangled != NULL)
+ {
+ int cond = strcmp (demangled, name);
+ free (demangled);
+ if (!cond)
+ break;
+ }
+ }
+ /* Loop terminates on no match with index == -1. */
+ }
+
if (index != -1)
{
ps = find_pc_psymtab (misc_function_vector[index].address);
*************** decode_line_1 (argptr, funfirstline, def
*** 1861,1869 ****
if (sym)
error ("%s is not a function.", copy);
! if ((i = lookup_misc_func (copy)) < 0)
! error ("Function %s not defined.", copy);
! else
{
value.symtab = 0;
value.line = 0;
--- 1884,1893 ----
if (sym)
error ("%s is not a function.", copy);
! if (symtab_list == 0 && partial_symtab_list == 0)
! error ("No symbol table is loaded. Use the \"symbol-file\" command.");
!
! if ((i = lookup_misc_func (copy)) >= 0)
{
value.symtab = 0;
value.line = 0;
*************** decode_line_1 (argptr, funfirstline, def
*** 1876,1883 ****
return values;
}
- if (symtab_list == 0 && partial_symtab_list == 0)
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
error ("Function %s not defined.", copy);
}
--- 1900,1905 ----
*************** decode_line_2 (argptr, sym_arr, physname
*** 1929,1934 ****
--- 1951,1957 ----
if (funfirstline)
SKIP_PROLOGUE (pc);
values.sals[i] = find_pc_line (pc, 0);
+ values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ? values.sals[i].end : pc;
printf("[%d] file:%s; line number:%d\n",
(i+2), values.sals[i].symtab->filename, values.sals[i].line);
}
*************** are listed.");
*** 2547,2551 ****
--- 2570,2576 ----
builtin_type_unsigned_long_long =
init_type (TYPE_CODE_INT, sizeof (long long), 1, "unsigned long long");
#endif
+ builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0, "<unknown type>");
+
}
diff -pr gdb-3.6/symtab.h ../gdb-3.6/symtab.h
*** gdb-3.6/symtab.h Tue Jun 26 23:47:00 1990
--- ../gdb-3.6/symtab.h Tue Aug 7 21:00:42 1990
*************** struct symtab *symtab_list;
*** 159,164 ****
--- 159,168 ----
struct partial_symtab *partial_symtab_list;
+ /* From symtab.c */
+
+ extern struct psymbol_allocation_list static_psymbols, global_psymbols;
+
/* This symtab variable specifies the current file for printing source lines */
struct symtab *current_source_symtab;
*************** extern struct type *builtin_type_unsigne
*** 325,330 ****
--- 329,337 ----
extern struct type *builtin_type_unsigned_long;
extern struct type *builtin_type_float;
extern struct type *builtin_type_double;
+ /* This type represents a type that was unrecognized in symbol
+ read-in. */
+ extern struct type *builtin_type_error;
#ifdef LONG_LONG
extern struct type *builtin_type_long_long;
diff -pr gdb-3.6/utils.c ../gdb-3.6/utils.c
*** gdb-3.6/utils.c Tue Jun 26 06:20:28 1990
--- ../gdb-3.6/utils.c Thu Aug 16 17:44:45 1990
*************** screensize_info (arg, from_tty)
*** 582,656 ****
Note that a longjmp to top level may occur in this routine
(since prompt_for_continue may do so) so this routine should not be
! called when cleanups are not in place.
- fputs_filtered demangles g++ names.*/
-
- void _fputs_filtered (); /* forward decl. */
-
-
void
fputs_filtered (linebuffer, stream)
char *linebuffer;
FILE *stream;
{
- #ifdef __STDC__
- extern char *cplus_demangle (const char *, int);
- #else
- extern char *cplus_demangle ();
- #endif
- #define SYMBOL_MAX 1024
-
- #define SYMBOL_CHAR(c) (isascii(c) && (isalnum(c) || (c) == '_' || (c) == '$'))
-
- char buf[SYMBOL_MAX+1];
- char *p;
-
- if (linebuffer == NULL)
- return;
-
- p = linebuffer;
-
- while ( *p != (char) 0 ) {
- int i = 0;
-
- /* collect non-interesting characters into buf */
- while ( *p != (char) 0 && !SYMBOL_CHAR(*p) ) {
- buf[i++] = *p;
- p++;
- }
- if (i > 0) {
- /* output the non-interesting characters without demangling */
- buf[i] = (char) 0;
- _fputs_filtered(buf, stream);
- i = 0; /* reset buf */
- }
-
- /* and now the interesting characters */
- while (i < SYMBOL_MAX && *p != (char) 0 && SYMBOL_CHAR(*p) ) {
- buf[i++] = *p;
- p++;
- }
- buf[i] = (char) 0;
- if (i > 0) {
- char * result;
-
- if ( (result = cplus_demangle(buf, 1)) != NULL ) {
- _fputs_filtered(result, stream);
- free(result);
- }
- else {
- _fputs_filtered(buf, stream);
- }
- }
- }
- }
-
- void
- _fputs_filtered (linebuffer, stream)
- char *linebuffer;
- FILE *stream;
- {
char *lineptr;
if (linebuffer == 0)
--- 582,594 ----
Note that a longjmp to top level may occur in this routine
(since prompt_for_continue may do so) so this routine should not be
! called when cleanups are not in place. */
void
fputs_filtered (linebuffer, stream)
char *linebuffer;
FILE *stream;
{
char *lineptr;
if (linebuffer == 0)
*************** _fputs_filtered (linebuffer, stream)
*** 711,716 ****
--- 649,714 ----
chars_printed = 0;
}
}
+ }
+
+ /* fputs_demangled is a variant of fputs_filtered that
+ demangles g++ names.*/
+
+ void
+ fputs_demangled (linebuffer, stream, arg_mode)
+ char *linebuffer;
+ FILE *stream;
+ {
+ #ifdef __STDC__
+ extern char *cplus_demangle (const char *, int);
+ #else
+ extern char *cplus_demangle ();
+ #endif
+ #define SYMBOL_MAX 1024
+
+ #define SYMBOL_CHAR(c) (isascii(c) && (isalnum(c) || (c) == '_' || (c) == '$'))
+
+ char buf[SYMBOL_MAX+1];
+ char *p;
+
+ if (linebuffer == NULL)
+ return;
+
+ p = linebuffer;
+
+ while ( *p != (char) 0 ) {
+ int i = 0;
+
+ /* collect non-interesting characters into buf */
+ while ( *p != (char) 0 && !SYMBOL_CHAR(*p) ) {
+ buf[i++] = *p;
+ p++;
+ }
+ if (i > 0) {
+ /* output the non-interesting characters without demangling */
+ buf[i] = (char) 0;
+ fputs_filtered(buf, stream);
+ i = 0; /* reset buf */
+ }
+
+ /* and now the interesting characters */
+ while (i < SYMBOL_MAX && *p != (char) 0 && SYMBOL_CHAR(*p) ) {
+ buf[i++] = *p;
+ p++;
+ }
+ buf[i] = (char) 0;
+ if (i > 0) {
+ char * result;
+
+ if ( (result = cplus_demangle(buf, arg_mode)) != NULL ) {
+ fputs_filtered(result, stream);
+ free(result);
+ }
+ else {
+ fputs_filtered(buf, stream);
+ }
+ }
+ }
}
/* Print ARG1, ARG2, and ARG3 on stdout using format FORMAT. If this
diff -pr gdb-3.6/valops.c ../gdb-3.6/valops.c
*** gdb-3.6/valops.c Tue Jun 26 23:47:04 1990
--- ../gdb-3.6/valops.c Thu Aug 16 17:44:46 1990
*************** value_string (ptr, len)
*** 768,773 ****
--- 768,807 ----
return val;
}
+ /* 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 treat the result as having type TYPE.
+ If found, return value, else return NULL. */
+
+ static value search_struct_field (name, arg1, offset, type)
+ char *name;
+ register value arg1;
+ int offset;
+ register struct type *type;
+ {
+ int i;
+ check_stub_type (type);
+ for (i = TYPE_NFIELDS (type) - 1; i >= 0; i--)
+ {
+ char *t_field_name = TYPE_FIELD_NAME (type, i);
+ if (t_field_name && !strcmp (t_field_name, name))
+ return TYPE_FIELD_STATIC (type, i)
+ ? value_static_field (type, name, i)
+ : value_primitive_field (arg1, offset, i, type);
+ }
+
+ for (i = TYPE_N_BASECLASSES (type); --i >= 0; )
+ {
+ /* Needs work for virtual base classes */
+ value v = search_struct_field (name,
+ arg1,
+ offset + TYPE_FIELD_BITPOS (type, i) / 8,
+ TYPE_FIELD_TYPE (type, i));
+ if (v) return v;
+ }
+ return NULL;
+ }
+
/* Given ARG1, a value of type (pointer to a)* structure/union,
extract the component named NAME from the ultimate target structure/union
and return it as a value with its appropriate type.
*************** value_struct_elt (arg1, args, name, stat
*** 827,856 ****
/* Try as a variable first, because if we succeed, there
is less work to be done. */
! while (t)
! {
! check_stub_type (t);
!
! for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
! {
! char *t_field_name = TYPE_FIELD_NAME (t, i);
! if (t_field_name && !strcmp (t_field_name, name))
! {
! found = 1;
! break;
! }
! }
!
! if (i >= 0)
! return TYPE_FIELD_STATIC (t, i)
! ? value_static_field (t, name, i) : value_field (arg1, i);
!
! if (TYPE_N_BASECLASSES (t) == 0)
! break;
!
! t = TYPE_BASECLASS (t, 1);
! VALUE_TYPE (arg1) = t; /* side effect! */
! }
/* C++: If it was not found as a data field, then try to
return it as a pointer to a method. */
--- 861,868 ----
/* Try as a variable first, because if we succeed, there
is less work to be done. */
! value v = search_struct_field (name, arg1, 0, t);
! 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. */
*************** destructor_name_p (name, type)
*** 998,1003 ****
--- 1010,1055 ----
return 0;
}
+ /* Helper function for check_field: Given TYPE, a structure/union,
+ return 1 if the component named NAME from the ultimate
+ target structure/union is defined, otherwise, return 0. */
+
+ static int
+ check_field_in (type, name)
+ register struct type *type;
+ char *name;
+ {
+ register int i;
+
+ for (i = TYPE_NFIELDS (type); --i >= 0; )
+ {
+ char *t_field_name = TYPE_FIELD_NAME (type, i);
+ if (t_field_name && !strcmp (t_field_name, name))
+ return 1;
+ }
+
+ /* C++: If it was not found as a data field, then try to
+ return it as a pointer to a method. */
+
+ /* Destructors are a special case. */
+ if (destructor_name_p (name, type))
+ return 1;
+
+ for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
+ {
+ if (!strcmp (TYPE_FN_FIELDLIST_NAME (type, i), name))
+ return 1;
+ }
+
+ for (i = TYPE_N_BASECLASSES (type); i > 0; i--)
+ {
+ if (check_field_in (TYPE_BASECLASS (type, i), name))
+ return 1;
+ }
+
+ return 0;
+ }
+
/* C++: Given ARG1, a value of type (pointer to a)* structure/union,
return 1 if the component named NAME from the ultimate
target structure/union is defined, otherwise, return 0. */
*************** check_field (arg1, name)
*** 1008,1018 ****
char *name;
{
register struct type *t;
- register int i;
- int found = 0;
-
- struct type *baseclass;
-
COERCE_ARRAY (arg1);
t = VALUE_TYPE (arg1);
--- 1060,1065 ----
*************** check_field (arg1, name)
*** 1029,1075 ****
&& TYPE_CODE (t) != TYPE_CODE_UNION)
error ("Internal error: `this' is not an aggregate");
! baseclass = t;
!
! while (t)
! {
! for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
! {
! char *t_field_name = TYPE_FIELD_NAME (t, i);
! if (t_field_name && !strcmp (t_field_name, name))
! {
! return 1;
! }
! }
! if (TYPE_N_BASECLASSES (t) == 0)
! break;
!
! t = TYPE_BASECLASS (t, 1);
! }
!
! /* C++: If it was not found as a data field, then try to
! return it as a pointer to a method. */
! t = baseclass;
! VALUE_TYPE (arg1) = t; /* side effect! */
!
! /* Destructors are a special case. */
! if (destructor_name_p (name, t))
! return 1;
!
! while (t)
! {
! for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
! {
! if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
! return 1;
! }
!
! if (TYPE_N_BASECLASSES (t) == 0)
! break;
!
! t = TYPE_BASECLASS (t, 1);
! }
! return 0;
}
/* C++: Given an aggregate type DOMAIN, and a member name NAME,
--- 1076,1082 ----
&& TYPE_CODE (t) != TYPE_CODE_UNION)
error ("Internal error: `this' is not an aggregate");
! return check_field_in (t, name);
}
/* C++: Given an aggregate type DOMAIN, and a member name NAME,
*************** value_of_this (complain)
*** 1251,1257 ****
else return 0;
sym = BLOCK_SYM (b, 0);
! if (strncmp ("$this", SYMBOL_NAME (sym), 5))
if (complain)
error ("current stack frame not in method");
else return 0;
--- 1258,1264 ----
else return 0;
sym = BLOCK_SYM (b, 0);
! if (strcmp ("this", SYMBOL_NAME (sym)))
if (complain)
error ("current stack frame not in method");
else return 0;
diff -pr gdb-3.6/valprint.c ../gdb-3.6/valprint.c
*** gdb-3.6/valprint.c Tue Jun 26 23:47:04 1990
--- ../gdb-3.6/valprint.c Thu Aug 16 17:44:47 1990
*************** val_print (type, valaddr, address, strea
*** 635,654 ****
val_print (TYPE_FIELD_TYPE (type, i-1), baddr,
0, stream, 0, 0, recurse + 1, pretty);
}
- if (i > 1) {
- fprintf_filtered (stream, "\n");
- print_spaces_filtered (2 + 2 * recurse, stream);
- fputs_filtered ("members of ", stream);
- fputs_filtered (type_name_no_tag (type), stream);
- fputs_filtered (": ", stream);
- }
if (!len && i == 1)
fprintf_filtered (stream, "<No data fields>");
else
{
for (i -= 1; i < len; i++)
{
! if (i > n_baseclasses) fprintf_filtered (stream, ", ");
if (pretty)
{
fprintf_filtered (stream, "\n");
--- 635,660 ----
val_print (TYPE_FIELD_TYPE (type, i-1), baddr,
0, stream, 0, 0, recurse + 1, pretty);
}
if (!len && i == 1)
fprintf_filtered (stream, "<No data fields>");
else
{
+ int fields_seen = 0;
for (i -= 1; i < len; i++)
{
! /* check if static field */
! if (TYPE_FIELD_STATIC (type, i))
! continue;
! if (fields_seen) fprintf_filtered (stream, ", ");
! else if (n_baseclasses > 0)
! {
! fprintf_filtered (stream, "\n");
! print_spaces_filtered (2 + 2 * recurse, stream);
! fputs_filtered ("members of ", stream);
! fputs_filtered (type_name_no_tag (type), stream);
! fputs_filtered (": ", stream);
! }
! fields_seen = 1;
if (pretty)
{
fprintf_filtered (stream, "\n");
*************** val_print (type, valaddr, address, strea
*** 656,672 ****
}
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
fputs_filtered (" = ", stream);
! /* check if static field */
! if (TYPE_FIELD_STATIC (type, i))
! {
! value v;
!
! v = value_static_field (type, TYPE_FIELD_NAME (type, i), i);
! val_print (TYPE_FIELD_TYPE (type, i),
! VALUE_CONTENTS (v), 0, stream, format,
! deref_ref, recurse + 1, pretty);
! }
! else if (TYPE_FIELD_PACKED (type, i))
{
char *valp = (char *) & val;
union {int i; char c;} test;
--- 662,668 ----
}
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
fputs_filtered (" = ", stream);
! if (TYPE_FIELD_PACKED (type, i))
{
char *valp = (char *) & val;
union {int i; char c;} test;
*************** type_print_method_args (args, prefix, va
*** 893,900 ****
int i;
fputs_filtered (" ", stream);
! fputs_filtered (prefix, stream);
! fputs_filtered (varstring, stream);
fputs_filtered (" (", stream);
if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
{
--- 889,896 ----
int i;
fputs_filtered (" ", stream);
! fputs_demangled (prefix, stream, 1);
! fputs_demangled (varstring, stream, 1);
fputs_filtered (" (", stream);
if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
{
*************** type_print_derivation_info (stream, type
*** 930,957 ****
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
struct type *basetype = 0;
! while (type && n_baseclasses == 1)
! {
!
! check_stub_type(type); /* Not actually sure about this one -- Bryan. */
!
! basetype = TYPE_BASECLASS (type, 1);
! if (name = type_name_no_tag (basetype))
! {
! fprintf_filtered (stream, ": %s%s ",
! TYPE_VIA_PUBLIC (basetype) ? "public" : "private",
! TYPE_VIA_VIRTUAL (basetype) ? " virtual" : "");
! fputs_filtered (name, stream);
! fputs_filtered (" ", stream);
! }
! n_baseclasses = TYPE_N_BASECLASSES (basetype);
! type = basetype;
! }
!
! if (type)
{
! if (n_baseclasses != 0)
! fprintf_filtered (stream, ": ");
for (i = 1; i <= n_baseclasses; i++)
{
basetype = TYPE_BASECLASS (type, i);
--- 926,937 ----
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
struct type *basetype = 0;
! while (type && n_baseclasses > 0)
{
! /* Not actually sure about this one -- Bryan. */
! check_stub_type (type);
!
! fprintf_filtered (stream, ": ");
for (i = 1; i <= n_baseclasses; i++)
{
basetype = TYPE_BASECLASS (type, i);
*************** type_print_derivation_info (stream, type
*** 965,971 ****
--- 945,955 ----
if (i < n_baseclasses)
fprintf_filtered (stream, ", ");
}
+
fprintf_filtered (stream, " ");
+ if (n_baseclasses != 1) break;
+ n_baseclasses = TYPE_N_BASECLASSES (basetype);
+ type = basetype;
}
}
*************** type_print_base (type, stream, show, lev
*** 1288,1294 ****
fprintf_filtered (stream, ";\n");
}
- if (len2) fprintf_filtered (stream, "\n");
}
print_spaces_filtered (level, stream);
--- 1272,1277 ----
diff -pr gdb-3.6/value.h ../gdb-3.6/value.h
*** gdb-3.6/value.h Mon Jun 25 23:51:38 1990
--- ../gdb-3.6/value.h Thu Aug 16 17:44:48 1990
*************** value value_assign ();
*** 165,171 ****
value value_neg ();
value value_lognot ();
value value_struct_elt (), value_struct_elt_for_address ();
! value value_field ();
value value_cast ();
value value_zero ();
value value_repeat ();
--- 165,171 ----
value value_neg ();
value value_lognot ();
value value_struct_elt (), value_struct_elt_for_address ();
! value value_field (), value_primitive_field();
value value_cast ();
value value_zero ();
value value_repeat ();
diff -pr gdb-3.6/values.c ../gdb-3.6/values.c
*** gdb-3.6/values.c Tue Jul 3 09:39:15 1990
--- ../gdb-3.6/values.c Thu Aug 16 17:44:50 1990
*************** unpack_double (type, valaddr, invp)
*** 642,648 ****
return (double) 0; /* To silence compiler warning. */
}
! /* Given a value ARG1 of a struct or union type,
extract and return the value of one of its fields.
FIELDNO says which field.
--- 642,649 ----
return (double) 0; /* To silence compiler warning. */
}
! /* Given a value ARG1 (offset by OFFSET bytes)
! of a struct or union type ARG_TYPE,
extract and return the value of one of its fields.
FIELDNO says which field.
*************** unpack_double (type, valaddr, invp)
*** 649,676 ****
For C++, must also be able to return values from static fields */
value
! value_field (arg1, fieldno)
register value arg1;
register int fieldno;
{
register value v;
register struct type *type;
- register int offset;
! check_stub_type (VALUE_TYPE (arg1));
! type = TYPE_FIELD_TYPE (VALUE_TYPE (arg1), fieldno);
/* Handle packed fields */
! offset = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) / 8;
if (TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno))
{
v = value_from_long (type,
! unpack_field_as_long (VALUE_TYPE (arg1),
VALUE_CONTENTS (arg1),
fieldno));
! VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) % 8;
! VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno);
}
else
{
--- 650,677 ----
For C++, must also be able to return values from static fields */
value
! value_primitive_field (arg1, offset, fieldno, arg_type)
register value arg1;
register int fieldno;
+ register struct type *arg_type;
{
register value v;
register struct type *type;
! check_stub_type (arg_type);
! type = TYPE_FIELD_TYPE (arg_type, fieldno);
/* Handle packed fields */
! offset += TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
if (TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno))
{
v = value_from_long (type,
! unpack_field_as_long (arg_type,
VALUE_CONTENTS (arg1),
fieldno));
! VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (arg_type, fieldno) % 8;
! VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (arg_type, fieldno);
}
else
{
*************** value_field (arg1, fieldno)
*** 685,690 ****
--- 686,705 ----
VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1);
VALUE_OFFSET (v) = offset + VALUE_OFFSET (arg1);
return v;
+ }
+
+ /* Given a value ARG1 of a struct or union type,
+ extract and return the value of one of its fields.
+ FIELDNO says which field.
+
+ For C++, must also be able to return values from static fields */
+
+ value
+ value_field (arg1, fieldno)
+ register value arg1;
+ register int fieldno;
+ {
+ return value_primitive_field (arg1, 0, VALUE_TYPE (arg1), fieldno);
}
value
More information about the Comp.unix.i386
mailing list