src@eliabel.sf.ca.us (08/18/90)
Here are the patches to make gdb 3.5 run with COFF on UNIX ISC2.2: The second patch is a tar uuencode and compressed file of additional files. GDB is build using GNU COFF and additional ISC patches. Eric P. Meyer ELIABEL Corp. emeyer@eliabel.sf.ca.us diff -rp dist-gdb/Makefile.dist ../dist-gdb/Makefile.dist *** dist-gdb/Makefile.dist Tue Jan 30 18:42:57 1990 --- ../dist-gdb/Makefile.dist Wed Aug 1 15:59:56 1990 *************** ALLOCA1 = *** 83,89 **** (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. */ --- 83,89 ---- (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 ! 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 ! 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 ${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 ${READLINEOBS} ! TSOBS = core.o inflow.o dep.o M_COBJS NTSOBS = standalone.o diff -rp dist-gdb/a.out.gnu.h ../dist-gdb/a.out.gnu.h *** dist-gdb/a.out.gnu.h Tue Jan 16 19:17:57 1990 --- ../dist-gdb/a.out.gnu.h Wed Aug 1 15:20:48 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 -rp dist-gdb/coffread.c ../dist-gdb/coffread.c *** dist-gdb/coffread.c Wed Jan 10 15:54:43 1990 --- ../dist-gdb/coffread.c Fri Aug 3 21:35:24 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 *************** make_blockvector () *** 368,374 **** /* Manage the vector of line numbers. */ - static record_line (line, pc) int line; CORE_ADDR pc; --- 368,373 ---- diff -rp dist-gdb/config.gdb ../dist-gdb/config.gdb *** dist-gdb/config.gdb Tue Jan 30 12:35:46 1990 --- ../dist-gdb/config.gdb Fri Aug 3 16:19:59 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_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 -rp dist-gdb/core.c ../dist-gdb/core.c *** dist-gdb/core.c Wed Jan 10 15:55:17 1990 --- ../dist-gdb/core.c Wed Aug 1 15:20:51 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 -rp dist-gdb/dbxread.c ../dist-gdb/dbxread.c *** dist-gdb/dbxread.c Fri Jan 26 23:30:54 1990 --- ../dist-gdb/dbxread.c Wed Aug 1 15:20:57 1990 *************** the Free Software Foundation, 675 Mass A *** 40,51 **** #define L_INCR 1 #endif ! #ifdef COFF_ENCAPSULATE ! #include "a.out.encap.h" ! #include "stab.gnu.h" #else ! #include <a.out.h> ! #include <stab.h> #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 *** 129,134 **** --- 138,275 ---- #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 (); *** 187,195 **** #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 --- 328,336 ---- #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; *** 335,341 **** /* 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, --- 476,485 ---- /* 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_ *** 473,480 **** --- 617,631 ---- #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 () *** 1078,1085 **** } /* Manage the vector of line numbers. */ ! ! static void record_line (line, pc) int line; CORE_ADDR pc; --- 1229,1238 ---- } /* 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) *** 1132,1138 **** 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) --- 1285,1291 ---- 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 *** 1568,1573 **** --- 1721,1729 ---- /* 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) *** 1629,1634 **** --- 1785,1795 ---- 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) *** 1656,1661 **** --- 1817,1830 ---- 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) *** 1662,1667 **** --- 1831,1840 ---- #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) *** 1712,1717 **** --- 1885,1894 ---- 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 () *** 1761,1776 **** } /* 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. --- 1938,1955 ---- } /* 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; *** 1781,1790 **** 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; } --- 1960,1972 ---- 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 () *** 1797,1806 **** static char * next_symbol_text () { ! if (symbuf_idx == symbuf_end) ! fill_symbuf (); ! symnum++; ! return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global; } /* --- 1979,1985 ---- static char * next_symbol_text () { ! NEXT_SYMBOL_TEXT(); /* contains return of ptr */ } /* *************** read_dbx_symtab (desc, stringtab, string *** 1989,1994 **** --- 2168,2176 ---- 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 *** 1995,2001 **** 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]++; --- 2177,2183 ---- 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 *** 2005,2011 **** * 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 --- 2187,2195 ---- * 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 *** 2018,2029 **** 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 { \ --- 2202,2207 ---- *************** read_dbx_symtab (desc, stringtab, string *** 2063,2072 **** 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 --- 2241,2247 ---- 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 *** 2127,2135 **** 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) --- 2302,2309 ---- 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 *** 2137,2146 **** 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; --- 2311,2323 ---- 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 *** 2210,2216 **** 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; --- 2387,2393 ---- 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 *** 2221,2227 **** past_first_source_file = 1; pst = start_psymtab (namestring, bufp->n_value, ! symnum * sizeof (struct nlist), global_psymbols.next, static_psymbols.next); continue; --- 2398,2404 ---- 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 *** 2417,2422 **** --- 2594,2604 ---- 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 *** 2601,2607 **** 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; --- 2783,2789 ---- 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) *** 2905,2910 **** --- 3087,3093 ---- 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) *** 2930,2935 **** --- 3113,3121 ---- 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 *** 3064,3079 **** 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 --- 3250,3266 ---- 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 *** 3090,3107 **** 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 (offset && --- 3277,3294 ---- 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 (offset && *************** read_ofile_symtab (desc, stringtab, stri *** 3108,3117 **** (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, --- 3295,3301 ---- (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 *** 3227,3232 **** --- 3411,3421 ---- 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 *** 3322,3329 **** --- 3511,3523 ---- 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 () *** 3477,3488 **** /* 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; --- 3671,3683 ---- /* 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 *** 3497,3502 **** --- 3692,3701 ---- 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 *** 3507,3515 **** 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) ) { --- 3706,3714 ---- 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 *** 3549,3557 **** 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 --- 3748,3755 ---- 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) *** 3742,3749 **** 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. */ --- 3940,3951 ---- 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 () *** 4162,4168 **** --- 4364,4409 ---- } 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 a dbx type reference or definition; *************** read_struct_type (pp, type) *** 4566,4572 **** if (**pp == '\\') *pp = next_symbol_text (); ! switch (*(*pp)++) { case '0': via_virtual = 0; --- 4807,4813 ---- if (**pp == '\\') *pp = next_symbol_text (); ! switch (**pp) { case '0': via_virtual = 0; *************** read_struct_type (pp, type) *** 4578,4585 **** error ("Invalid symbol data: bad visibility format at symtab pos %d", symnum); } ! switch (*(*pp)++) { case '0': via_public = 0; --- 4819,4827 ---- 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) *** 4588,4597 **** 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. */ --- 4830,4841 ---- 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) *** 4707,4714 **** 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, ';'); --- 4951,4959 ---- 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 *** 4807,4815 **** while (*p != ':') p++; if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == '$') { ! static char opname[32] = "operator "; ! char *o = opname + 9; ! /* Skip past '::'. */ p += 2; while (*p != '.') --- 5052,5062 ---- while (*p != ':') p++; if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == '$') { ! /* This lets the user type "break operator+". ! We could just put in "+" as the name, but that wouldn't ! work for "*". */ ! static char opname[32] = "operator"; ! char *o = opname + 8; /* Skip past '::'. */ p += 2; while (*p != '.') *************** Therefore GDB will not know about your c *** 4836,4843 **** new_sublist->fn_field.type = read_type (pp); if (**pp != ':') ! error ("invalid symtab info for method at symbol number %d.", ! symnum); *pp += 1; new_sublist->fn_field.args = TYPE_ARG_TYPES (new_sublist->fn_field.type); --- 5083,5091 ---- new_sublist->fn_field.type = read_type (pp); if (**pp != ':') ! /* Invalid symtab info for method. */ ! return error_type (pp); ! *pp += 1; new_sublist->fn_field.args = TYPE_ARG_TYPES (new_sublist->fn_field.type); *************** Therefore GDB will not know about your c *** 4975,4981 **** t = read_type (pp); p = (*pp)++; ! while (*p != ';') p++; TYPE_VPTR_BASETYPE (type) = t; if (type == t) { --- 5223,5233 ---- 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 *** 4989,4995 **** break; } if (i < 0) ! error ("virtual function table field not found"); } else TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, 1)); --- 5241,5248 ---- break; } if (i < 0) ! /* Virtual function table field not found. */ ! return error_type (pp); } else TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, 1)); *************** read_array_type (pp, type) *** 5031,5038 **** 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')) { --- 5284,5293 ---- 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) *** 5303,5309 **** 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; --- 5558,5565 ---- 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 -rp dist-gdb/i386-dep.c ../dist-gdb/i386-dep.c *** dist-gdb/i386-dep.c Wed Jan 10 15:58:05 1990 --- ../dist-gdb/i386-dep.c Fri Aug 3 22:37:16 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 -rp dist-gdb/m-i386-sv32.h ../dist-gdb/m-i386-sv32.h *** dist-gdb/m-i386-sv32.h Wed Aug 16 14:20:30 1989 --- ../dist-gdb/m-i386-sv32.h Fri Aug 3 22:20:50 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@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 -rp dist-gdb/main.c ../dist-gdb/main.c *** dist-gdb/main.c Fri Jan 26 12:12:59 1990 --- ../dist-gdb/main.c Wed Aug 1 16:35:43 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); + #ifndef USG sigsetmask (0); + #endif kill (getpid (), SIGTSTP); signal (SIGTSTP, stop_sig); #else diff -rp dist-gdb/munch ../dist-gdb/munch *** dist-gdb/munch Wed Jul 5 12:46:28 1989 --- ../dist-gdb/munch Wed Aug 1 15:21:00 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 -rp dist-gdb/readline/Makefile ../dist-gdb/readline/Makefile *** dist-gdb/readline/Makefile Wed Feb 7 22:05:33 1990 --- ../dist-gdb/readline/Makefile Wed Aug 1 15:21:18 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 -rp dist-gdb/readline/readline.c ../dist-gdb/readline/readline.c *** dist-gdb/readline/readline.c Sun Nov 26 13:31:36 1989 --- ../dist-gdb/readline/readline.c Wed Aug 1 15:21:26 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 -rp dist-gdb/symseg.h ../dist-gdb/symseg.h *** dist-gdb/symseg.h Sat Jan 6 19:11:57 1990 --- ../dist-gdb/symseg.h Wed Aug 1 15:21:01 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 *** 464,473 **** * 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. --- 465,474 ---- * 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 -rp dist-gdb/symtab.c ../dist-gdb/symtab.c *** dist-gdb/symtab.c Wed Jan 10 15:56:39 1990 --- ../dist-gdb/symtab.c Wed Aug 1 15:21:03 1990 *************** struct type *builtin_type_unsigned_long_ *** 65,70 **** --- 65,71 ---- #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 *************** are listed."); *** 2432,2436 **** --- 2433,2439 ---- 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 -rp dist-gdb/symtab.h ../dist-gdb/symtab.h *** dist-gdb/symtab.h Thu Sep 7 17:59:14 1989 --- ../dist-gdb/symtab.h Wed Aug 1 15:21:04 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 *** 318,323 **** --- 322,330 ---- 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;