home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-28 | 46.3 KB | 1,706 lines |
- Xref: wupost comp.unix.xenix.sco:4109 alt.sources:3919
- Path: wupost!uunet!mcsun!ukc!stl!robobar!ronald
- From: Steve.Bleazard@robobar.Co.Uk
- Newsgroups: comp.unix.xenix.sco,alt.sources
- Subject: Xenix Patch Kit for GAS 1.38.1/GCC 1.40/GDB 3.5 (part 4/4)
- Message-ID: <Xenix/gdb-3.5b.pch@robobar.co.uk>
- Date: 27 Aug 91 14:27:51 GMT
- Sender: ronald@robobar.co.uk (Ronald S H Khoo)
- Organization: Robobar Ltd., Perivale, Middx., ENGLAND.
- Lines: 1693
- X-Md4-Signature: a6cfb1be7b3d046df8f61c52489a12fe
-
- Archive-Name: Xenix/gdb-3.5b.pch
-
- This is part 4 of a 4 part posting.
- Part 1 (the README) describes this package
-
- *** 3.5/Makefile.dist Wed Jan 31 03:42:57 1990
- --- Makefile.dist Thu Aug 1 18:01:18 1991
- ***************
- *** 124,130 ****
- kdb-start.c main.c printcmd.c \
- remote.c source.c stack.c standalone.c stuff.c symmisc.c symtab.c \
- 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 \
- --- 124,130 ----
- kdb-start.c main.c printcmd.c \
- remote.c source.c stack.c standalone.c stuff.c symmisc.c symtab.c \
- utils.c valarith.c valops.c valprint.c values.c version.c expread.y \
- ! x386dbx.c 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 \
- ***************
- *** 173,179 ****
-
- OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \
- values.o eval.o valops.o valarith.o valprint.o printcmd.o \
- ! symtab.o symmisc.o coffread.o dbxread.o infcmd.o infrun.o remote.o \
- command.o utils.o expread.o expprint.o pinsn.o environ.o version.o \
- copying.o ${READLINEOBS}
-
- --- 173,179 ----
-
- OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \
- values.o eval.o valops.o valarith.o valprint.o printcmd.o \
- ! symtab.o symmisc.o coffread.o dbxread.o x386dbx.o infcmd.o infrun.o remote.o \
- command.o utils.o expread.o expprint.o pinsn.o environ.o version.o \
- copying.o ${READLINEOBS}
-
- *** 3.5/config.gdb Tue Jan 30 21:35:46 1990
- --- config.gdb Thu Aug 1 19:36:23 1991
- ***************
- *** 326,331 ****
- --- 326,337 ----
- pinsnfile=three
- opcodefile=four
- ;;
- + xenix386)
- + makedefine="-DM_CLIBS=-lx -DM_REGEX=regex.o -Dcc=gcc -DM_CFLAGS=-traditional"
- + pinsnfile=i386-pinsn.c
- + opcodefile=m-xenix386.h
- + depfile=i386-dep.c # patched with #ifdef M_XENIX
- + ;;
- *)
- echo "Unknown machine type: \`$machine'"
- echo "Available types:"
- ***************
- *** 369,375 ****
- # edit the makefile
- echo "Editing Makefile"
- cp Makefile.dist tmp.c
- ! cc -E >Makefile tmp.c $makedefine -DM_MAKEDEFINE="$makedefine"
- rm -f tmp.c
-
- echo "GDB is now set up for use with a $machine." \
- --- 375,381 ----
- # edit the makefile
- echo "Editing Makefile"
- cp Makefile.dist tmp.c
- ! gcc -Ui386 -E >Makefile $makedefine -DM_MAKEDEFINE="$makedefine" tmp.c
- rm -f tmp.c
-
- echo "GDB is now set up for use with a $machine." \
- *** 3.5/core.c Thu Jan 11 00:55:17 1990
- --- core.c Thu Aug 1 18:01:22 1991
- ***************
- *** 49,54 ****
- --- 49,59 ----
- #ifdef UMAX_CORE
- #include <sys/ptrace.h>
- #else
- + #ifdef M_XENIX
- + struct user; struct buf; struct inode; struct proc; /* inhibit warnings */
- + #include <sys/page.h>
- + #include <sys/seg.h>
- + #endif
- #include <sys/user.h>
- #endif
-
- ***************
- *** 62,70 ****
- --- 67,79 ----
-
- #ifndef COFF_FORMAT
- #ifndef AOUTHDR
- + #ifdef M_XENIX
- + #define AOUTHDR struct xexec
- + #else
- #define AOUTHDR struct exec
- #endif
- #endif
- + #endif
-
- extern char *sys_siglist[];
-
- ***************
- *** 200,209 ****
- the core file, (s)he'll find out soon enough. */
- return;
-
- if (N_MAGIC (core_aouthdr) != 0
- && bcmp (&core_aouthdr, &exec_aouthdr, sizeof core_aouthdr))
- printf ("Warning: core file does not match specified executable file.\n");
- ! else if (exec_mtime > st_core.st_mtime)
- printf ("Warning: exec file is newer than core file.\n");
- }
- }
- --- 209,222 ----
- the core file, (s)he'll find out soon enough. */
- return;
-
- + /* cannot validate core file against executable file on xenix */
- + #ifndef M_XENIX
- if (N_MAGIC (core_aouthdr) != 0
- && bcmp (&core_aouthdr, &exec_aouthdr, sizeof core_aouthdr))
- printf ("Warning: core file does not match specified executable file.\n");
- ! else
- ! #endif
- ! if (exec_mtime > st_core.st_mtime)
- printf ("Warning: exec file is newer than core file.\n");
- }
- }
- *** 3.5/dbxread.c Sat Jan 27 08:30:54 1990
- --- dbxread.c Thu Aug 1 19:25:46 1991
- ***************
- *** 40,45 ****
- --- 40,60 ----
- #define L_INCR 1
- #endif
-
- + #ifdef M_XENIX
- + #include <sys/relsym.h>
- + #define nlist xenix_nlist /* the system nlist is broken */
- + #include <a.out.h>
- + #undef nlist
- + #define nlist gas_nlist
- + #include "stab.gnu.h"
- + #include "gas-nlist.h"
- +
- + #define STRING_SEG 4
- + #define SYMS_SEG 5
- + #define AOUTHDR struct xexec
- +
- + #else /* M_XENIX */
- +
- #ifdef COFF_ENCAPSULATE
- #include "a.out.encap.h"
- #include "stab.gnu.h"
- ***************
- *** 47,52 ****
- --- 62,69 ----
- #include <a.out.h>
- #include <stab.h>
- #endif
- + #endif /* M_XENIX */
- +
- #include <ctype.h>
-
- #ifndef NO_GNU_STABS
- ***************
- *** 167,172 ****
- --- 184,222 ----
- /* C++ */
- static struct type **read_args ();
-
- + #ifdef M_XENIX
- + extern struct xseg *find_segment();
- + #define NUMBER_OF_SYMBOLS \
- + ({ struct xseg *cseg; long z;\
- + cseg = find_segment(XS_TSYMS, SYMS_SEG); \
- + z = cseg ? cseg->xs_psize / sizeof(struct nlist) : 0; z;})
- + #define SYMBOL_TABLE_OFFSET \
- + ({ struct xseg *cseg; long z;\
- + cseg = find_segment(XS_TSYMS, SYMS_SEG); \
- + z = cseg ? cseg->xs_filpos : 0; z;})
- + #define STRING_TABLE_OFFSET \
- + ({ struct xseg *cseg; long z;\
- + cseg = find_segment(XS_TSYMS, STRING_SEG); \
- + z = cseg ? cseg->xs_filpos : 0; z; })
- + #define READ_STRING_TABLE_SIZE(INTO) \
- + { struct xseg *cseg; \
- + cseg = find_segment(XS_TSYMS, STRING_SEG); \
- + INTO = cseg ? cseg->xs_psize : 0; }
- + #define N_BADMAG(hdr)\
- + (hdr.x_magic != X_MAGIC && (hdr.x_cpu & XC_CPU) != XC_386 \
- + && (hdr.x_renv & XE_SEG) == 0 && (hdr.x_renv & XE_EXEC) == 0)
- + #define READ_FILE_HEADERS(DESC, NAME) \
- + { val = myread (DESC, &hdr, sizeof hdr); \
- + if (val < 0) perror_with_name (NAME); \
- + if (N_BADMAG (hdr)) \
- + error ("File \"%s\" not in executable format.", NAME);\
- + process_a_out(DESC, NAME); }
- + #define IS_OBJECT_FILE 0
- + #define SIZE_OF_TEXT_SEGMENT hdr.x_text
- + #define ADDR_OF_TEXT_SEGMENT 0
- + #define ENTRY_POINT hdr.x_entry
- + #endif
- +
- /* Macro to determine which symbols to ignore when reading the first symbol
- of a file. Some machines override this definition. */
- #ifdef N_NSYMS
- ***************
- *** 336,341 ****
- --- 386,394 ----
- /* Count symbols as they are processed, for error messages. */
-
- static int symnum;
- + #ifdef M_XENIX
- + static long lsym_count = 0;
- + #endif /* M_XENIX */
-
- /* Vector of types defined so far, indexed by their dbx type numbers.
- (In newer sun systems, dbx uses a pair of numbers in parens,
- ***************
- *** 1627,1632 ****
- --- 1680,1691 ----
- old_chain = make_cleanup (close, desc);
- make_cleanup (free_current_contents, &name);
-
- + #ifdef M_XENIX
- + /* On xenix (with gcc) READ_FILE_HEADER reads the segment table,
- + * fileinfo table and global symbol table as well.
- + */
- + #endif /* M_XENIX */
- +
- READ_FILE_HEADERS (desc, name);
-
- entry_point = ENTRY_POINT;
- ***************
- *** 1676,1681 ****
- --- 1735,1744 ----
- val = myread (desc, stringtab, buffer);
- if (val < 0)
- perror_with_name (name);
- + #ifdef X_DEBUG
- + printf("\nstring table offset = %d, size = %d, start = %s\n",
- + STRING_TABLE_OFFSET, buffer, stringtab);
- + #endif
-
- /* Throw away the old symbol table. */
-
- ***************
- *** 1720,1726 ****
- --- 1783,1793 ----
-
- /* Go over the misc functions and install them in vector. */
-
- + #ifndef M_XENIX /* This has already been done at header read time */
- condense_misc_bunches (0);
- + #else
- + process_global_symbol_table(desc, name);
- + #endif /* M_XENIX */
-
- /* Don't allow char * to have a typename (else would get caddr_t.) */
-
- ***************
- *** 1799,1805 ****
- {
- if (symbuf_idx == symbuf_end)
- fill_symbuf ();
- ! symnum++;
- return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global;
- }
-
- --- 1866,1872 ----
- {
- if (symbuf_idx == symbuf_end)
- fill_symbuf ();
- ! symnum++; lsym_count--;
- return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global;
- }
-
- ***************
- *** 1937,1942 ****
- --- 2004,2019 ----
- int global_funs = 0;
- #endif
-
- + #ifdef M_XENIX
- + long flsym_count = 0;
- + long file_string_base = 0;
- + long stringtab_offset = 0;
- + long symtab_pos = 0;
- + long filadd = 0;
- + long textsize = 0;
- + int file_count = 0;
- + #endif /* M_XENIX */
- +
- /* Current partial symtab */
- struct partial_symtab *pst;
-
- ***************
- *** 1989,1998 ****
- --- 2066,2123 ----
- symtab_input_desc = desc; /* This is needed for fill_symbuf below */
- symbuf_end = symbuf_idx = 0;
-
- + #ifdef M_XENIX
- + init_fileinfo_processing(); /* start processing the list of files */
- + nlistlen += 10; /* force the hack code to terminate the loop */
- + lsym_count = 0;
- + #endif /* M_XENIX */
- +
- for (symnum = 0; symnum < nlistlen; symnum++)
- {
- /* Get the symbol for this run and pull out some info */
- QUIT; /* allow this to be interruptable */
- + #ifdef M_XENIX
- +
- + /* This is a gross hack. Xenix places pointers to each files $$SYMBOLS
- + * (containing the symbols for DBX) and $$TYPES (containing the strings
- + * for DBX) in the file name table. There is also a partial symbol
- + * table record for each file produced by the loader - this is ignored
- + * at present.
- + */
- + if (lsym_count == 0)
- + {
- + try_next_file:
- + if (!get_next_fileinfo(&stringtab_offset, &flsym_count, &filadd,
- + &symtab_pos, &textsize))
- + { /* all files proccessed */
- + symnum = nlistlen;
- + continue;
- + }
- + else
- + {
- + lseek(desc, symtab_pos, 0);
- + stringtab_global = stringtab + stringtab_offset;
- + symbuf_idx = symbuf_end; /* force symbol reading */
- + lsym_count = flsym_count;
- + }
- +
- + file_count++;
- +
- + if (file_count == 2)
- + startup_file_start = filadd;
- +
- + if (file_count == 3)
- + startup_file_end = filadd;
- +
- + if (lsym_count == 0) /* skip this file if no symbols in it */
- + goto try_next_file;
- +
- + }
- +
- +
- + lsym_count--;
- +
- + #endif /* M_XENIX */
- if (symbuf_idx == symbuf_end)
- fill_symbuf ();
- bufp = &symbuf[symbuf_idx++];
- ***************
- *** 2023,2029 ****
- 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 { \
- --- 2148,2154 ----
- 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 + stringtab_offset
-
- #define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE)\
- do { \
- ***************
- *** 2051,2062 ****
- SYMBOL_VALUE (psym) = (VALUE); \
- } while (0);
-
-
- ! switch (bufp->n_type)
- {
- /*
- * Standard, non-debugger, symbols
- */
-
- case N_TEXT | N_EXT:
- /* Catch etext */
- --- 2176,2193 ----
- SYMBOL_VALUE (psym) = (VALUE); \
- } while (0);
-
- + #ifdef X_DEBUG
- + printf("%s = (%#x, %d, %#x)\n",
- + bufp->n_un.n_strx ? bufp->n_un.n_strx+stringtab+stringtab_offset : "<NONE>",
- + (unsigned char)bufp->n_type, bufp->n_desc, bufp->n_value);
- + #endif /* X_DEBUG */
-
- ! switch ((unsigned char)bufp->n_type)
- {
- /*
- * Standard, non-debugger, symbols
- */
- + #ifndef M_XENIX /* these are not present with Xenix / GCC */
-
- case N_TEXT | N_EXT:
- /* Catch etext */
- ***************
- *** 2176,2181 ****
- --- 2307,2314 ----
- case N_NBBSS:
- #endif
-
- + #endif /* M_XENIX */
- +
- /* Keep going . . .*/
-
- /*
- ***************
- *** 2209,2218 ****
- --- 2342,2358 ----
-
- if (pst && past_first_source_file)
- {
- + #ifndef M_XENIX
- 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);
- + #else
- + end_psymtab (pst, psymtab_include_list, includes_used,
- + symtab_pos + flsym_count * sizeof (struct nlist),
- + bufp->n_value, dependency_list, dependencies_used,
- + global_psymbols.next, static_psymbols.next);
- + #endif
- pst = (struct partial_symtab *) 0;
- includes_used = 0;
- dependencies_used = 0;
- ***************
- *** 2220,2228 ****
- --- 2360,2374 ----
- else
- past_first_source_file = 1;
-
- + #ifndef M_XENIX
- pst = start_psymtab (namestring, bufp->n_value,
- symnum * sizeof (struct nlist),
- global_psymbols.next, static_psymbols.next);
- + #else
- + pst = start_psymtab (namestring, bufp->n_value, symtab_pos,
- + global_psymbols.next, static_psymbols.next,
- + stringtab_offset, flsym_count, textsize);
- + #endif /* M_XENIX */
-
- continue;
-
- ***************
- *** 2591,2596 ****
- --- 2737,2743 ----
- }
-
- /* If there's stuff to be cleaned up, clean it up. */
- + #ifndef M_XENIX
- if (entry_point < bufp->n_value
- && entry_point >= last_o_file_start)
- {
- ***************
- *** 2597,2609 ****
- --- 2744,2764 ----
- startup_file_start = last_o_file_start;
- startup_file_end = bufp->n_value;
- }
- + #endif /* M_XENIX */
-
- if (pst)
- {
- + #ifndef M_XENIX
- 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);
- + #else /* M_XENIX */
- + end_psymtab (pst, psymtab_include_list, includes_used,
- + symtab_pos + flsym_count * sizeof (struct nlist),
- + end_of_text_addr, dependency_list, dependencies_used,
- + global_psymbols.next, static_psymbols.next);
- + #endif /* M_XENIX */
- includes_used = 0;
- dependencies_used = 0;
- pst = (struct partial_symtab *) 0;
- ***************
- *** 2653,2658 ****
- --- 2808,2814 ----
- * completely filled at the end of the symbol list.
- */
- static struct partial_symtab *
- + #ifndef M_XENIX
- start_psymtab (filename, textlow, ldsymoff, global_syms, static_syms)
- char *filename;
- int textlow;
- ***************
- *** 2659,2664 ****
- --- 2815,2832 ----
- int ldsymoff;
- struct partial_symbol *global_syms;
- struct partial_symbol *static_syms;
- + #else
- + start_psymtab (filename, textlow, ldsymoff, global_syms, static_syms, stroffset,
- + symcount, textsize)
- + char *filename;
- + int textlow;
- + int ldsymoff;
- + struct partial_symbol *global_syms;
- + struct partial_symbol *static_syms;
- + int stroffset;
- + int symcount;
- + long textsize;
- + #endif
- {
- struct partial_symtab *result =
- (struct partial_symtab *) obstack_alloc (psymbol_obstack,
- ***************
- *** 2671,2677 ****
-
- result->textlow = textlow;
- result->ldsymoff = ldsymoff;
- !
- result->readin = 0;
-
- result->globals_offset = global_syms - global_psymbols.list;
- --- 2839,2848 ----
-
- result->textlow = textlow;
- result->ldsymoff = ldsymoff;
- ! #ifdef M_XENIX
- ! result->texthigh = textlow + textsize;
- ! result->ldsymlen = symcount * sizeof(struct nlist);
- ! #endif
- result->readin = 0;
-
- result->globals_offset = global_syms - global_psymbols.list;
- ***************
- *** 2679,2684 ****
- --- 2850,2856 ----
-
- result->n_global_syms = 0;
- result->n_static_syms = 0;
- + result->stringtab_off = stroffset;
-
- return result;
- }
- ***************
- *** 2722,2729 ****
- --- 2894,2903 ----
- {
- int i;
-
- + #ifndef M_XENIX
- pst->ldsymlen = capping_symbol_offset - pst->ldsymoff;
- pst->texthigh = capping_text;
- + #endif /* M_XENIX */
-
- pst->n_global_syms =
- capping_global - (global_psymbols.list + pst->globals_offset);
- ***************
- *** 2830,2840 ****
- --- 3004,3023 ----
- old_chain = make_cleanup (really_free_pendings, 0);
-
- /* Read in this files symbols */
- + #ifndef M_XENIX
- lseek (desc, sym_offset, L_SET);
- +
- read_ofile_symtab (desc, stringtab, stringtab_size,
- pst->ldsymoff,
- pst->ldsymlen, pst->textlow,
- pst->texthigh - pst->textlow, 0);
- + #else /* M_XENIX */
- + read_ofile_symtab (desc, stringtab + pst->stringtab_off,
- + stringtab_size - pst->stringtab_off,
- + pst->ldsymoff,
- + pst->ldsymlen, pst->textlow,
- + pst->texthigh - pst->textlow, 0);
- + #endif /* M_XENIX */
- sort_symtab_syms (symtab_list); /* At beginning since just added */
-
- do_cleanups (old_chain);
- ***************
- *** 2903,2909 ****
- --- 3086,3094 ----
- if (desc < 0)
- error("Symbol file not readable");
-
- + #ifndef M_XENIX
- READ_FILE_HEADERS (desc, name);
- + #endif /* M_XENIX */
-
- /* Read in the string table */
- lseek (desc, STRING_TABLE_OFFSET, L_SET);
- ***************
- *** 3058,3063 ****
- --- 3243,3249 ----
- symtab_input_desc = desc;
- symbuf_end = symbuf_idx = 0;
-
- + #ifndef M_XENIX
- /* It is necessary to actually read one symbol *before* the start
- of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
- occurs before the N_SO symbol.
- ***************
- *** 3087,3092 ****
- --- 3273,3285 ----
- lseek(desc, sym_offset, L_INCR);
- processing_gcc_compilation = 0;
- }
- + #else /* M_XENIX */
- + lseek(desc, sym_offset, L_SET);
- + processing_gcc_compilation = 0;
- + #ifdef X_DEBUG
- + printf("sym_offset = %d, sym_size = %d\n", sym_offset, sym_size);
- + #endif /* X_DEBUG */
- + #endif /* M_XENIX */
-
- if (symbuf_idx == symbuf_end)
- fill_symbuf();
- ***************
- *** 3094,3099 ****
- --- 3287,3298 ----
- if ((unsigned char) bufp->n_type != N_SO)
- fatal("First symbol in segment of executable not a source symbol");
-
- + #ifdef X_DEBUG
- + printf("%s = (%#x, %d, %#x)\n",
- + bufp->n_un.n_strx ? bufp->n_un.n_strx+stringtab : "<NONE>",
- + (unsigned char)bufp->n_type, bufp->n_desc, bufp->n_value);
- + #endif /* X_DEBUG */
- +
- for (symnum = 0;
- symnum < sym_size / sizeof(struct nlist);
- symnum++)
- ***************
- *** 3103,3108 ****
- --- 3302,3312 ----
- fill_symbuf();
- bufp = &symbuf[symbuf_idx++];
- type = bufp->n_type;
- + #ifdef X_DEBUG
- + printf("%s = (%#x, %d, %#x)\n",
- + bufp->n_un.n_strx ? bufp->n_un.n_strx+stringtab : "<NONE>",
- + (unsigned char)bufp->n_type, bufp->n_desc, bufp->n_value);
- + #endif /* X_DEBUG */
-
- if (offset &&
- (type == N_TEXT || type == N_DATA || type == N_BSS))
- ***************
- *** 3476,3481 ****
- --- 3680,3687 ----
-
- /* Read in another .o file and create a symtab entry for it.*/
-
- + #ifndef M_XENIX /* Xenix can't do incremental loads */
- +
- static void
- read_addl_syms (desc, stringtab, nlistlen, text_addr, text_size)
- int desc;
- ***************
- *** 3772,3777 ****
- --- 3978,3984 ----
- printf ("done.\n");
- fflush (stdout);
- }
- + #endif /* M_XENIX */
-
- /* Read a number by which a type is referred to in dbx data,
- or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
- ***************
- *** 5469,5476 ****
- --- 5676,5685 ----
- add_com ("symbol-file", class_files, symbol_file_command,
- "Load symbol table (in dbx format) from executable file FILE.");
-
- + #ifndef M_XENIX
- add_com ("add-file", class_files, add_file_command,
- "Load the symbols from FILE, assuming its code is at TEXT_START.") ;
- + #endif /* M_XENIX */
- }
-
- #endif /* READ_DBX_FORMAT */
- *** 3.5/gas-nlist.h
- --- gas-nlist.h Thu Aug 1 18:01:31 1991
- ***************
- *** 0 ****
- --- 1,13 ----
- + #define N_STAB 0340
- +
- + struct gas_nlist {
- + union {
- + char *n_name;
- + struct gas_nlist *n_next;
- + long n_strx;
- + } n_un;
- + char n_type;
- + char n_other;
- + short n_desc;
- + unsigned n_value;
- + };
- *** 3.5/i386-dep.c Thu Jan 11 00:58:05 1990
- --- i386-dep.c Thu Aug 1 18:01:33 1991
- ***************
- *** 30,35 ****
- --- 30,49 ----
- #include <sys/param.h>
- #include <sys/dir.h>
- #include <signal.h>
- + #ifdef M_XENIX
- + struct user; struct buf; struct inode; struct proc; /* inhibit warnings */
- + #include <sys/page.h>
- + #include <sys/seg.h>
- + #define a_magic xa_magic
- + #define a_text xa_text
- + #define exec xexec
- + #undef U_FPSTATE
- + #define U_FPSTATE(u) u.u_fps
- + #define fpstate u_fps
- + #define u_fpvalid u_fpsaved
- + unsigned short text_segid; /* segment number of text segment */
- + unsigned short data_segid; /* segment number of data segment */
- + #endif
- #include <sys/user.h>
- #include <sys/ioctl.h>
- #include <fcntl.h>
- ***************
- *** 37,44 ****
- --- 51,60 ----
- #ifdef COFF_ENCAPSULATE
- #include "a.out.encap.h"
- #else
- + #ifndef M_XENIX /* already included by sys/user.h */
- #include <a.out.h>
- #endif
- + #endif
-
- #ifndef N_SET_MAGIC
- #ifdef COFF_FORMAT
- ***************
- *** 50,57 ****
- --- 66,94 ----
-
- #include <sys/file.h>
- #include <sys/stat.h>
- + #ifdef M_XENIX
- + #include <sys/proc.h>
- + #endif
-
- #include <sys/reg.h>
- + #ifdef M_XENIX
- + #define SS RSS
- + #define UESP RESP
- + #define EFL REFL
- + #define CS RCS
- + #define EIP REIP
- + #define EAX REAX
- + #define ECX RECX
- + #define EDX REDX
- + #define EBX REBX
- + #define EBP REBP
- + #define ESI RESI
- + #define EDI REDI
- + #define DS RDS
- + #define ES RES
- + #define FS RFS
- + #define GS RGS
- + #endif
-
- extern int errno;
-
- ***************
- *** 62,68 ****
- --- 99,120 ----
- call_ptrace (request, pid, arg3, arg4)
- int request, pid, arg3, arg4;
- {
- + #ifdef M_XENIX
- + extern CORE_ADDR text_end;
- + int addr_in_data_segment = arg3 > text_end;
- + #ifdef PTRACE_ADDR_ARG_STRUCT
- + struct saddr addr;
- + addr.sa_seg = addr_in_data_segment ? data_segid : text_segid;
- + if (request == 7 || request == 9) addr.sa_seg = 0;
- + addr.sa_off = arg3;
- + arg3 = (int) &addr;
- + #endif
- + if (addr_in_data_segment && (request == 1 || request == 4)) request++;
- + return ptrace (request, pid, arg3, arg4);
- + #define ptrace(a, b, c, d) call_ptrace(a, b, c, d)
- + #else
- return ptrace (request, pid, arg3, arg4);
- + #endif /* M_XENIX */
- }
-
- kill_inferior ()
- ***************
- *** 157,163 ****
- --- 209,220 ----
- perror_with_name (buf);
- }
- }
- + #ifdef M_XENIX
- + /* HACK: Xenix ptrace() disallows writing to where es, fs and gs are kept */
- + else for (regno = 0; regno < (NUM_REGS - 3); regno++)
- + #else
- else for (regno = 0; regno < NUM_REGS; regno++)
- + #endif
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- ***************
- *** 382,389 ****
- --- 439,451 ----
-
- data_start = 0;
- data_end = 0;
- + #ifdef M_XENIX
- + stack_start = 0;
- + stack_end = 0;
- + #else
- stack_start = STACK_END_ADDR;
- stack_end = STACK_END_ADDR;
- + #endif
-
- /* Now, if a new core file was specified, open it and digest it. */
-
- ***************
- *** 406,411 ****
- --- 468,474 ----
- val = myread (corechan, &u, sizeof u);
- if (val < 0)
- perror_with_name (filename);
- + #ifndef M_XENIX
- data_start = exec_data_start;
-
- data_end = data_start + NBPG * u.u_dsize;
- ***************
- *** 412,417 ****
- --- 475,490 ----
- stack_start = stack_end - NBPG * u.u_ssize;
- data_offset = NBPG * UPAGES;
- stack_offset = NBPG * (UPAGES + u.u_dsize);
- + #else
- + data_start = (CORE_ADDR)u.u_sdata;
- + data_end = (CORE_ADDR)u.u_edatau;
- + stack_start = (CORE_ADDR)u.u_stktop;
- + stack_end = (CORE_ADDR)u.u_stkbotu;
- +
- + data_offset = lseek(corechan, 0L, 2) - u.u_dsize;
- + stack_offset = (((sizeof u + (u.u_ldtlimit-1)*sizeof(struct descriptor)
- + + NBPC - 1) / NBPC) * NBPC);
- + #endif
- reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR;
-
- /* I don't know where to find this info.
- ***************
- *** 523,529 ****
- --- 596,651 ----
- exec_mtime = file_hdr.f_timdat;
- }
- #else /* not COFF_FORMAT */
- + #ifdef M_XENIX
- {
- + char *extended_header;
- + struct xext *xext;
- + struct stat st_exec;
- + struct xseg xseg;
- + extern char *malloc();
- + val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR));
- +
- + if (val < 0)
- + perror_with_name (filename);
- + if (exec_aouthdr.x_magic != X_MAGIC)
- + error ("\"%s\": not in executable format.", execfile);
- + if ( (exec_aouthdr.x_cpu & XC_CPU) != XC_386 )
- + error ("\"%s\": not a 386 executable.", execfile);
- + if ( (exec_aouthdr.x_renv & XE_SEG) == 0)
- + error ("\"%s\": not a segmented executable.", execfile);
- + if ( (exec_aouthdr.x_renv & XE_EXEC) == 0)
- + error ("\"%s\": not executable.", execfile);
- + extended_header = malloc(exec_aouthdr.x_ext);
- + val = myread (execchan, extended_header, exec_aouthdr.x_ext);
- + if (val < 0)
- + perror_with_name (filename);
- + xext = (struct xext *)extended_header;
- + lseek(execchan, xext->xe_segpos, 0);
- + if (myread (execchan, (char *)&xseg, sizeof(xseg)) < 0)
- + perror_with_name (filename);
- + if ( xseg.xs_type != XS_TTEXT )
- + error ("\"%s\": Text segment isn't first (huh?).", execfile);
- + text_segid = xseg.xs_seg;
- + text_start = xseg.xs_rbase;
- + text_end = text_start + xseg.xs_vsize;
- + text_offset = xseg.xs_filpos;
- +
- + if (myread (execchan, (char *)&xseg, sizeof(xseg)) < 0)
- + perror_with_name (filename);
- + if ( xseg.xs_type != XS_TDATA )
- + error ("\"%s\": Data segment isn't second (huh?).", execfile);
- + data_segid = xseg.xs_seg;
- + exec_data_start = xseg.xs_rbase;
- + exec_data_end = exec_data_start + xseg.xs_psize;
- + exec_data_offset = xseg.xs_filpos;
- + data_start = exec_data_start;
- + data_end += exec_data_start;
- +
- + fstat (execchan, &st_exec);
- + exec_mtime = st_exec.st_mtime;
- + free(extended_header);
- + }
- + #else /* not M_XENIX */
- struct stat st_exec;
-
- #ifdef HEADER_SEEK_FD
- ***************
- *** 549,554 ****
- --- 671,677 ----
- fstat (execchan, &st_exec);
- exec_mtime = st_exec.st_mtime;
- }
- + #endif /* not M_XENIX */
- #endif /* not COFF_FORMAT */
-
- validate_files ();
- ***************
- *** 1056,1061 ****
- --- 1179,1195 ----
-
- struct env387
- {
- + #ifdef M_XENIX
- + unsigned int control;
- + unsigned int status;
- + unsigned int tag;
- + unsigned long eip;
- + unsigned short code_seg;
- + unsigned short operand_seg;
- + unsigned long opcode;
- + unsigned long operand;
- + unsigned char regs[8][10];
- + #else
- unsigned short control;
- unsigned short r0;
- unsigned short status;
- ***************
- *** 1069,1074 ****
- --- 1203,1209 ----
- unsigned short operand_seg;
- unsigned short r3;
- unsigned char regs[8][10];
- + #endif
- };
-
- static
- ***************
- *** 1145,1150 ****
- --- 1280,1289 ----
- int fpreg;
- unsigned char *p;
-
- + #ifdef M_XENIX
- + if (ep->status != 0)
- + print_387_status_word (ep->status);
- + #else
- bothstatus = ((status != 0) && (ep->status != 0));
- if (status != 0)
- {
- ***************
- *** 1159,1164 ****
- --- 1298,1304 ----
- printf ("e: ");
- print_387_status_word (ep->status);
- }
- + #endif
-
- print_387_control_word (ep->control);
- printf ("last exception: ");
- ***************
- *** 1188,1193 ****
- --- 1328,1334 ----
- i387_to_double (ep->regs[fpreg], (char *)&val);
- printf (" %g\n", val);
- }
- + #ifndef M_XENIX
- if (ep->r0)
- printf ("warning: reserved0 is 0x%x\n", ep->r0);
- if (ep->r1)
- ***************
- *** 1196,1201 ****
- --- 1337,1343 ----
- printf ("warning: reserved2 is 0x%x\n", ep->r2);
- if (ep->r3)
- printf ("warning: reserved3 is 0x%x\n", ep->r3);
- + #endif
- }
-
- #ifndef U_FPSTATE
- ***************
- *** 1270,1275 ****
- --- 1412,1421 ----
- }
-
- fpstatep = (struct fpstate *)(buf + skip);
- + #ifdef M_XENIX
- + print_387_status (0, (struct env387 *)fpstatep);
- + #else
- print_387_status (fpstatep->status, (struct env387 *)fpstatep->state);
- + #endif
- }
-
- *** 3.5/infrun.c Wed Jan 24 00:10:35 1990
- --- infrun.c Thu Aug 1 18:01:35 1991
- ***************
- *** 146,151 ****
- --- 146,156 ----
- /* Needed by IN_SIGTRAMP on some machines (e.g. vax). */
- #include <sys/param.h>
- /* Needed by IN_SIGTRAMP on some machines (e.g. vax). */
- + #ifdef M_XENIX
- + struct user; struct buf; struct inode; struct proc; /* inhibit warnings */
- + #include <sys/page.h>
- + #include <sys/seg.h>
- + #endif
- #include <sys/user.h>
-
- extern char *sys_siglist[];
- *** 3.5/m-xenix386.h
- --- m-xenix386.h Thu Aug 1 18:01:35 1991
- ***************
- *** 0 ****
- --- 1,30 ----
- + /* SCO XENIX 386 version. Mostly like System V/386 3.2 */
- + #include "m-i386-sv32.h"
- +
- + /* define this if your DEVELOPMENT system is older than 2.3 */
- + /* #define PTRACE_ADDR_ARG_STRUCT */
- +
- + #define const /* workaround for SCO's include files */
- + /* This machine doesn't have the siginterrupt call. */
- + #define NO_SIGINTERRUPT
- + #define NAMES_HAVE_UNDERSCORE
- + /* support dbx-style debugging in x.out executables produced by
- + the accompanying port of GCC */
- + #undef COFF_FORMAT
- + #define READ_DBX_FORMAT
- + #undef START_INFERIOR_TRAPS_EXPECTED
- + #define START_INFERIOR_TRAPS_EXPECTED 2
- + #undef KERNEL_U_ADDR
- + #define KERNEL_U_ADDR 0x06000000
- + #undef FIX_CALL_DUMMY
- + #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
- + { \
- + extern CORE_ADDR text_end; \
- + int from, to, delta, loc; \
- + loc = text_end - CALL_DUMMY_LENGTH; \
- + from = loc + 5; \
- + to = (int)(fun); \
- + delta = to - from; \
- + *(int *)((char *)(dummyname) + 1) = delta; \
- + }
- + #define CANNOT_EXECUTE_STACK
- *** 3.5/munch Wed Jul 5 20:46:28 1989
- --- munch Thu Aug 1 18:01:35 1991
- ***************
- *** 5,17 ****
- echo '/* Do not modify this file. It is created automatically by "munch". */'
- echo 'void initialize_all_files () {'
-
- ! if test "$1" = "-DSYSV" ; then
- shift;
- 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 '}'
- --- 5,22 ----
- echo '/* Do not modify this file. It is created automatically by "munch". */'
- echo 'void initialize_all_files () {'
-
- ! if [ -f /xenix ]; then
- shift;
- + nm $* | egrep 'A *__initialize_' | \
- + sed -e 's/^.*A *_*\(.*\)/ _\1 ();/'
- + else if test "$1" = "-DSYSV" ; then
- + shift;
- 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
- fi
-
- echo '}'
- *** 3.5/readline/Makefile Thu Feb 8 07:05:33 1990
- --- readline/Makefile Thu Aug 1 18:01:43 1991
- ***************
- *** 38,44 ****
- # A good alternative is gcc -traditional.
- #CC = gcc -traditional
- CC = cc
- ! RANLIB = /usr/bin/ranlib
- AR = ar
- RM = rm
- CP = cp
- --- 38,44 ----
- # A good alternative is gcc -traditional.
- #CC = gcc -traditional
- CC = cc
- ! RANLIB = /bin/ranlib
- AR = ar
- RM = rm
- CP = cp
- *** 3.5/readline/readline.c Sun Nov 26 22:31:36 1989
- --- readline/readline.c Thu Aug 1 18:01:45 1991
- ***************
- *** 68,73 ****
- --- 68,77 ----
-
- #define HACK_TERMCAP_MOTION
-
- + #ifdef M_XENIX
- + #include <sys/ttold.h>
- + #include <sys/ndir.h>
- + #else
- #ifndef SYSV
- #include <sys/dir.h>
- #else /* SYSV */
- ***************
- *** 79,84 ****
- --- 83,89 ----
- #define d_namlen d_reclen
- #endif /* hpux */
- #endif /* SYSV */
- + #endif
-
- /* Some standard library routines. */
- #include "readline.h"
- *** 3.5/symtab.h Fri Sep 8 01:59:14 1989
- --- symtab.h Thu Aug 1 18:01:46 1991
- ***************
- *** 149,154 ****
- --- 149,157 ----
- to take a *lot* of time; check) or an error (and we don't care
- how long errors take). */
- int statics_offset, n_static_syms;
- + #ifdef M_XENIX
- + int stringtab_off;
- + #endif /* M_XENIX */
- };
-
- /* This is the list of struct symtab's that gdb considers current. */
- *** 3.5/values.c Sun Sep 10 04:39:19 1989
- --- values.c Thu Aug 1 18:01:48 1991
- ***************
- *** 1024,1028 ****
-
- add_info ("values", value_history_info,
- "Elements of value history (around item number IDX, or last ten).");
- ! add_info_alias ("history", value_history_info, 0);
- }
- --- 1024,1028 ----
-
- add_info ("values", value_history_info,
- "Elements of value history (around item number IDX, or last ten).");
- ! /* add_info_alias ("history", value_history_info, 0); */
- }
- *** 3.5/x386dbx.c
- --- x386dbx.c Thu Aug 1 18:01:50 1991
- ***************
- *** 0 ****
- --- 1,481 ----
- + #include <stdio.h>
- + #include <a.out.h>
- + #include <fcntl.h>
- + #include <sys/types.h>
- + #include <sys/relsym.h>
- + #include <sys/param.h>
- + #include <sys/file.h>
- + #include "defs.h"
- + #include "param.h"
- + #include "symtab.h"
- + #include "gas-nlist.h"
- +
- +
- + /* XENIX symbol segment shape definitions */
- +
- + struct section2 { /* File info table shape */
- + short segment; /* segment number */
- + CORE_ADDR address; /* start address for this file */
- + unsigned short textsize; /* size of the text for this file */
- + long type3off; /* offset to type3 records, psym tab */
- + long type4off; /* offset to type4 records, nlist tab */
- + long type5off; /* offset to type5 records, str tab */
- + long type6off; /* offset to type6 records */
- + unsigned short type3sz; /* size of type3 records */
- + unsigned short type4sz; /* size of type4 records */
- + unsigned short type5sz; /* size of type5 records */
- + unsigned short type6sz; /* size of type6 records */
- + char filelen; /* length of filename */
- + };
- +
- + /* psymtable (attribute 3) symbol segment shape */
- +
- + struct psymbol_seg {
- + long address; /* core address */
- + short segid; /* segment number */
- + short typeid; /* variable's type */
- + char varlen; /* variable's length */
- + /* char name[0]; trailing name varlen long */
- + } record3;
- +
- + /* Info maintenance structures */
- +
- + struct fileinfo { /* per file info */
- + CORE_ADDR address; /* start address for this file */
- + unsigned short textsize; /* size of text for this file */
- + long psymoff; /* psyms table */
- + long strtaboff; /* string table aka $$TYPES */
- + long ntaboff; /* nlist table aka $$SYMBOLS */
- + unsigned short psymsz; /* size of psyms table */
- + unsigned short strtabsz; /* size of string table */
- + unsigned short ntabsz; /* size of nlist table */
- + int mscdebuginfo; /* compiled with cc -g not gcc -g */
- + char *filename; /* name of this file */
- + struct fileinfo *next;
- + };
- +
- + static struct fileinfo *fi_table = 0;
- + struct xseg *seg_table;
- + long num_seg_table_entries;
- +
- + #ifdef __GNUC__
- + #define alloca __builtin_alloca
- + #endif
- +
- + #define IGNORE_ATTR (-1)
- +
- + static read_fileinfo_table(fp, segsize, name)
- + FILE *fp;
- + int segsize;
- + char *name;
- + {
- + extern char *strrchr(), *xmalloc();
- + char *fi_name;
- + char *filename;
- + struct section2 fi_entry;
- + struct fileinfo *fi;
- +
- + fi_table = fi = (struct fileinfo *)xmalloc(sizeof(struct fileinfo));
- + while (segsize > 0)
- + {
- + if ((fread((char *)&fi_entry.segment, sizeof(short), 1, fp) != 1)
- + || (fread((char *)&fi_entry.address, sizeof(CORE_ADDR), 1, fp) != 1)
- + || (fread((char *)&fi_entry.textsize, sizeof(unsigned short),1,fp) != 1)
- + || (fread((char *)&fi_entry.type3off, sizeof(long), 1, fp) != 1)
- + || (fread((char *)&fi_entry.type4off, sizeof(long), 1, fp) != 1)
- + || (fread((char *)&fi_entry.type5off, sizeof(long), 1, fp) != 1)
- + || (fread((char *)&fi_entry.type6off, sizeof(long), 1, fp) != 1)
- + || (fread((char *)&fi_entry.type3sz, sizeof(unsigned short),1,fp) != 1)
- + || (fread((char *)&fi_entry.type4sz, sizeof(unsigned short),1,fp) != 1)
- + || (fread((char *)&fi_entry.type5sz, sizeof(unsigned short),1,fp) != 1)
- + || (fread((char *)&fi_entry.type6sz, sizeof(unsigned short),1,fp) != 1)
- + || (fread((char *)&fi_entry.filelen, sizeof(char), 1, fp) != 1))
- + perror_with_name(name);
- +
- + segsize -= sizeof(short) + sizeof(CORE_ADDR) + 5 * sizeof(unsigned short)
- + + 4 * sizeof(long) + sizeof(char);
- +
- + fi_name = alloca(fi_entry.filelen + 1);
- + if (fread(fi_name, fi_entry.filelen, 1, fp) != 1)
- + perror_with_name(name);
- + fi_name[fi_entry.filelen] = '\0';
- + segsize -= fi_entry.filelen;
- +
- + if ((filename = strrchr(fi_name, '/')) != (char *)0)
- + fi_name = filename + 1;
- +
- + if ((filename = strrchr(fi_name, '(')) != (char *)0)
- + fi_name = filename + 1;
- +
- + if ((filename = strrchr(fi_name, ')')) != (char *)0)
- + *filename = '\0';
- +
- + {
- + int len = strlen(fi_name);
- +
- + if (len > 2 && fi_name[len - 1] == 'o' && fi_name[len - 2] == '.')
- + fi_name[len - 1] = 'c';
- + }
- +
- + fi_name = savestring(fi_name, strlen(fi_name) + 1);
- +
- + fi->next = (struct fileinfo *)xmalloc(sizeof(struct fileinfo));
- + fi = fi->next;
- +
- + fi->address = fi_entry.address;
- + fi->textsize = fi_entry.textsize;
- + fi->psymoff = fi_entry.type3off;
- + fi->psymsz = fi_entry.type3sz;
- + fi->strtaboff = fi_entry.type4off;
- + fi->strtabsz = fi_entry.type4sz;
- + fi->ntaboff = fi_entry.type5off;
- + fi->ntabsz = fi_entry.type5sz;
- + fi->mscdebuginfo = (fi_entry.type6sz != 0);
- + fi->filename = fi_name;
- + }
- + fi->next = 0; fi = fi_table; fi_table = fi_table->next; free(fi);
- +
- + #ifdef X_DEBUG
- + printf("\naddress textsz symoff symsz stroff strsz taboff tabsz name\n\n");
- + for (fi = fi_table; fi != 0; fi = fi->next)
- + {
- + printf("% 8x % 6d % 6d % 6d % 6d % 6d % 6d %6d %s\n", fi->address, fi->textsize, fi->psymoff, fi->psymsz, fi->strtaboff, fi->strtabsz, fi->ntaboff, fi->ntabsz, fi->filename);
- + }
- + printf("\n");
- + #endif /* X_DEBUG */
- + }
- +
- + static read_seg_table(fp, pos, size, name)
- + FILE *fp;
- + long pos, size;
- + {
- + seg_table = (struct xseg *) xmalloc(size);
- + fseek(fp, pos, 0);
- + if (fread((char *)seg_table, size, 1, fp) != 1)
- + perror_with_name(name);
- + num_seg_table_entries = size / sizeof (struct xseg);
- + }
- +
- +
- + struct xseg *find_segment(type, attr)
- + int type, attr;
- + {
- + struct xseg *cseg;
- +
- + for (cseg = seg_table; cseg < seg_table + num_seg_table_entries; ++cseg)
- + if (cseg->xs_type == type &&
- + (attr == IGNORE_ATTR || attr == cseg->xs_attr))
- + return cseg;
- + return NULL;
- + }
- +
- + static int compare_misc_functions (fn1, fn2)
- + struct misc_function *fn1, *fn2;
- + {
- + /* Return a signed result based on unsigned comparisons
- + so that we sort into unsigned numeric order. */
- +
- + if (fn1->address < fn2->address)
- + return -1;
- + if (fn1->address > fn2->address)
- + return 1;
- + return 0;
- + }
- +
- + static int read_misc_functions(fp, segsize, name)
- + FILE *fp;
- + int segsize;
- + char *name;
- + {
- + char *symdata, *p, *str_buff;
- + long sym_count = 0, str_count = 0, i;
- + struct misc_function *miscp;
- + struct sym symb;
- +
- + /* grab the symbol table */
- +
- + symdata = alloca(segsize + 1);
- + if (fread(symdata, segsize, 1, fp) != 1)
- + perror_with_name(name);
- +
- + /* first pass, work out how many symbols there are and the size of the
- + * strings
- + */
- +
- + p = symdata;
- + while (p < symdata + segsize)
- + {
- + int len;
- +
- + p += sizeof(struct sym);
- + len = strlen(p) + 1;
- + str_count += len; p += len; sym_count++;
- + }
- +
- + /* Now build the misc function vector */
- +
- + str_buff = xmalloc(str_count+1);
- + misc_function_vector =
- + (struct misc_function *) xmalloc (sym_count * sizeof(struct misc_function));
- + misc_function_count = sym_count;
- +
- + p = symdata; miscp = misc_function_vector;
- + while (p < symdata + segsize)
- + {
- + int len;
- +
- + symb = *((struct sym *)p);
- + p += sizeof(struct sym);
- +
- + if (*p == '_')
- + strcpy(str_buff, p+1);
- + else
- + strcpy(str_buff, p);
- +
- + /* the following will result in a garbage byte every time a symbol
- + * starts with a _, I can'y be bothered to fix it.
- + */
- +
- + miscp->name = str_buff;
- + len = strlen(p) + 1;
- + str_buff += len; p += len;
- + miscp->address = symb.s_value;
- + switch(symb.s_type & S_TYPE)
- + {
- + case S_UNDEF: miscp->type = mf_unknown; break;
- + case S_ABS: miscp->type = mf_abs; break;
- + case S_TEXT: miscp->type = mf_text; break;
- + case S_DATA: miscp->type = mf_data; break;
- + case S_BSS: miscp->type = mf_bss; break;
- + case S_COMM: miscp->type = mf_data; break;
- + case S_REG: miscp->type = mf_unknown; break;
- + case S_COMB: miscp->type = mf_unknown; break;
- + case S_SEG: miscp->type = mf_unknown; break;
- + case S_FN: miscp->type = mf_unknown; break;
- + dewfault: miscp->type = mf_unknown; break;
- + }
- + miscp++;
- + }
- +
- + qsort (misc_function_vector, misc_function_count,
- + sizeof (struct misc_function), compare_misc_functions);
- +
- + #ifdef X_DEBUG
- + {
- + struct misc_function *miscp;
- + int i;
- +
- + printf("type address name\n\n");
- + for (i = 0; i < misc_function_count; i++)
- + {
- + miscp = &misc_function_vector[i];
- + switch (miscp->type)
- + {
- + case mf_unknown: printf("%-9s","unknown"); break;
- + case mf_text: printf("%-9s","text"); break;
- + case mf_data: printf("%-9s","data"); break;
- + case mf_bss: printf("%-9s","bss"); break;
- + case mf_abs: printf("%-9s","abs"); break;
- + default: printf("%-9s","UNKNOWN"); break;
- + }
- + printf("% 8x ", miscp->address);
- + printf("%s\n", miscp->name);
- + }
- + }
- + #endif /* X_DEBUG */
- + return misc_function_count;
- + }
- +
- + process_a_out(desc, name)
- + int desc;
- + char *name;
- + {
- + struct xexec exec_aouthdr;
- + struct xext *xext;
- + struct xseg *cseg;
- + FILE *fp;
- +
- + lseek(desc, 0L, 0);
- + if ((fp = fdopen(dup(desc), "r")) == NULL)
- + perror_with_name(name);
- +
- + if (fread((char *)&exec_aouthdr, sizeof(struct xexec), 1, fp) != 1)
- + perror_with_name(name);
- +
- + xext = (struct xext *) alloca(exec_aouthdr.x_ext);
- + if (fread((char *)xext, exec_aouthdr.x_ext, 1, fp) != 1)
- + perror_with_name(name);
- +
- + read_seg_table(fp, xext->xe_segpos, xext->xe_segsize, name);
- +
- + if (cseg = find_segment(XS_TSYMS, 2))
- + {
- + fseek(fp, cseg->xs_filpos, 0);
- + read_fileinfo_table(fp, cseg->xs_psize, name);
- + }
- +
- + fclose(fp);
- + }
- +
- + process_global_symbol_table(desc, name)
- + int desc;
- + char *name;
- + {
- + struct xseg *cseg;
- + FILE *fp;
- +
- + if ((fp = fdopen(dup(desc), "r")) == NULL)
- + perror_with_name(name);
- +
- + if (cseg = find_segment(XS_TSYMS, 1))
- + {
- + fseek(fp, cseg->xs_filpos, 0);
- + read_misc_functions(fp, cseg->xs_psize, name);
- + }
- + fclose(fp);
- + }
- +
- + static struct fileinfo *current_fi;
- + static int first_get_fileinfo_call = 1;
- +
- + init_fileinfo_processing() /* start processing the list of files */
- + {
- + first_get_fileinfo_call = 1;
- + }
- +
- + long get_next_fileinfo(stroff, nsyms, address, symtaboff, textsize)
- + long *stroff, *nsyms, *address, *symtaboff, *textsize;
- + {
- + struct xseg *cseg;
- +
- + if (first_get_fileinfo_call)
- + {
- + current_fi = fi_table;
- + first_get_fileinfo_call = 0;
- + }
- + else
- + current_fi = current_fi->next;
- +
- + if (current_fi == 0)
- + return 0;
- +
- + if (current_fi->mscdebuginfo)
- + {
- + *stroff = 0;
- + *nsyms = 0;
- + *address = current_fi->address;
- + *textsize = current_fi->textsize;
- + }
- + else if (cseg = find_segment(XS_TSYMS, 5))
- + {
- + *symtaboff = cseg->xs_filpos + current_fi->ntaboff;
- + *stroff = current_fi->strtaboff;
- + *nsyms = current_fi->ntabsz / sizeof(struct gas_nlist);
- + *address = current_fi->address;
- + *textsize = current_fi->textsize;
- + return 1;
- + }
- + else
- + {
- + *symtaboff = 0;
- + *stroff = 0;
- + *nsyms = 0;
- + *address = 0;
- + *textsize = 0;
- + }
- + }
- +
- + #ifdef TEST
- +
- + main()
- + {
- + char *stab;
- + long str_offset, nsyms, address, ntaboff, textsize;
- + int desc;
- + struct xseg *cseg;
- +
- + process_a_out((desc = open("a.out", O_RDONLY, 0)), "a.out");
- +
- + printf("\n");
- +
- + if (cseg = find_segment(XS_TSYMS, 4))
- + {
- + lseek(desc, cseg->xs_filpos, 0);
- + stab = alloca(cseg->xs_psize);
- + read(desc, stab, cseg->xs_psize);
- + }
- + else
- + stab = 0;
- +
- + init_fileinfo_processing();
- + while (get_next_fileinfo(&str_offset,&nsyms,&address,&ntaboff,&textsize))
- + {
- + lseek(desc, ntaboff, 0);
- + printf("\n type desc value stroff string tsize (%#x)\n", address);
- + while (nsyms--)
- + {
- + struct gas_nlist nl;
- +
- + read(desc, &nl, sizeof(nl));
- + printf("% 6x % 6x % 8x % 6x % 6x %s\n",
- + (unsigned char)nl.n_type,
- + (unsigned short)nl.n_desc,
- + (unsigned int)nl.n_value,
- + nl.n_un.n_strx ? stab + str_offset + nl.n_un.n_strx : "");
- + }
- + lseek(desc, 0L, 0);
- + }
- + }
- +
- + perror_with_name (string)
- + char *string;
- + {
- + extern int sys_nerr;
- + extern char *sys_errlist[];
- + extern int errno;
- + char *err;
- + char *combined;
- +
- + if (errno < sys_nerr)
- + err = sys_errlist[errno];
- + else
- + err = "unknown error";
- +
- + combined = (char *) alloca (strlen (err) + strlen (string) + 3);
- + strcpy (combined, string);
- + strcat (combined, ": ");
- + strcat (combined, err);
- +
- + error ("%s.", combined);
- + }
- +
- + error (string, arg1, arg2, arg3)
- + char *string;
- + int arg1, arg2, arg3;
- + {
- + fflush (stdout);
- + fprintf (stderr, string, arg1, arg2, arg3);
- + fprintf (stderr, "\n");
- + exit(1);
- + }
- +
- + char * xmalloc (size)
- + long size;
- + {
- + register char *val = (char *) malloc (size);
- + if (!val)
- + error ("virtual memory exhausted.");
- + return val;
- + }
- +
- + char *savestring (ptr, size)
- + char *ptr;
- + int size;
- + {
- + register char *p = (char *) xmalloc (size + 1);
- + memcpy(p, ptr, size);
- + p[size] = 0;
- + return p;
- + }
- +
- + #endif /* TEST */
- *** gdbspace.asm
- --- gdbspace.asm Thu Aug 22 20:27:38 1991
- ***************
- *** 0 ****
- --- 1,14 ----
- + ; GDB likes to poke calling sequences beyond _end -- in the padding
- + ; space up to the end of the page.
- + ; But XENIX doesn't let it use this space, so we have to add the space
- + ; manually. Assemble and install this file with the command
- + ; /usr/lib/storel gdbspace.asm && mv gdbspace.o /usr/local/lib/libgdb.a
- + ; and use it by specifying -lgdb when you're debugging.
- + ; e.g. gcc -g foo.c -o foo -lgdb
- + ; This will enable you to do things like call functions from within gdb
- + .386
- + C_ETEXT SEGMENT DWORD USE32 PUBLIC 'ENDCODE'
- + PUBLIC SPACE_FOR_GDB_TO_USE
- + SPACE_FOR_GDB_TO_USE DB 512 DUP (0)
- + C_ETEXT ENDS
- + END
- --
- Steve.Bleazard@RoboBar.Co.Uk | Phone: +44 81 991 1142 x153
- Snr Software Engineer, Robobar Ltd. | Fax: +44 81 998 8343 (G3)
- 22 Wadsworth Road, Perivale. |
- Middx., UB6 7JD ENGLAND. | ...!ukc!robobar!steve
-