home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3919 < prev    next >
Encoding:
Text File  |  1991-08-28  |  46.3 KB  |  1,706 lines

  1. Xref: wupost comp.unix.xenix.sco:4109 alt.sources:3919
  2. Path: wupost!uunet!mcsun!ukc!stl!robobar!ronald
  3. From: Steve.Bleazard@robobar.Co.Uk
  4. Newsgroups: comp.unix.xenix.sco,alt.sources
  5. Subject: Xenix Patch Kit for GAS 1.38.1/GCC 1.40/GDB 3.5 (part 4/4)
  6. Message-ID: <Xenix/gdb-3.5b.pch@robobar.co.uk>
  7. Date: 27 Aug 91 14:27:51 GMT
  8. Sender: ronald@robobar.co.uk (Ronald S H Khoo)
  9. Organization: Robobar Ltd., Perivale, Middx., ENGLAND.
  10. Lines: 1693
  11. X-Md4-Signature: a6cfb1be7b3d046df8f61c52489a12fe
  12.  
  13. Archive-Name: Xenix/gdb-3.5b.pch
  14.  
  15. This is part 4 of a 4 part posting.
  16. Part 1 (the README) describes this package
  17.  
  18. *** 3.5/Makefile.dist    Wed Jan 31 03:42:57 1990
  19. --- Makefile.dist    Thu Aug  1 18:01:18 1991
  20. ***************
  21. *** 124,130 ****
  22.        kdb-start.c main.c printcmd.c \
  23.        remote.c source.c stack.c standalone.c stuff.c symmisc.c symtab.c \
  24.        utils.c valarith.c valops.c valprint.c values.c version.c expread.y \
  25. !      xgdb.c
  26.   
  27.   DEPFILES = umax-dep.c gould-dep.c default-dep.c sun3-dep.c \
  28.          sparc-dep.c hp9k320-dep.c hp300bsd-dep.c news-dep.c i386-dep.c \
  29. --- 124,130 ----
  30.        kdb-start.c main.c printcmd.c \
  31.        remote.c source.c stack.c standalone.c stuff.c symmisc.c symtab.c \
  32.        utils.c valarith.c valops.c valprint.c values.c version.c expread.y \
  33. !      x386dbx.c xgdb.c
  34.   
  35.   DEPFILES = umax-dep.c gould-dep.c default-dep.c sun3-dep.c \
  36.          sparc-dep.c hp9k320-dep.c hp300bsd-dep.c news-dep.c i386-dep.c \
  37. ***************
  38. *** 173,179 ****
  39.   
  40.   OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \
  41.       values.o eval.o valops.o valarith.o valprint.o printcmd.o \
  42. !     symtab.o symmisc.o coffread.o dbxread.o infcmd.o infrun.o remote.o \
  43.       command.o utils.o expread.o expprint.o pinsn.o environ.o version.o \
  44.       copying.o ${READLINEOBS}
  45.   
  46. --- 173,179 ----
  47.   
  48.   OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \
  49.       values.o eval.o valops.o valarith.o valprint.o printcmd.o \
  50. !     symtab.o symmisc.o coffread.o dbxread.o x386dbx.o infcmd.o infrun.o remote.o \
  51.       command.o utils.o expread.o expprint.o pinsn.o environ.o version.o \
  52.       copying.o ${READLINEOBS}
  53.   
  54. *** 3.5/config.gdb    Tue Jan 30 21:35:46 1990
  55. --- config.gdb    Thu Aug  1 19:36:23 1991
  56. ***************
  57. *** 326,331 ****
  58. --- 326,337 ----
  59.       pinsnfile=three
  60.       opcodefile=four
  61.       ;;
  62. + xenix386)
  63. +     makedefine="-DM_CLIBS=-lx -DM_REGEX=regex.o -Dcc=gcc -DM_CFLAGS=-traditional"
  64. +     pinsnfile=i386-pinsn.c
  65. +     opcodefile=m-xenix386.h
  66. +     depfile=i386-dep.c    # patched with #ifdef M_XENIX
  67. +     ;;
  68.   *)
  69.       echo "Unknown machine type: \`$machine'"
  70.       echo "Available types:"
  71. ***************
  72. *** 369,375 ****
  73.   # edit the makefile
  74.   echo "Editing Makefile"
  75.   cp Makefile.dist tmp.c
  76. ! cc -E >Makefile tmp.c $makedefine -DM_MAKEDEFINE="$makedefine"
  77.   rm -f tmp.c
  78.   
  79.   echo "GDB is now set up for use with a $machine." \
  80. --- 375,381 ----
  81.   # edit the makefile
  82.   echo "Editing Makefile"
  83.   cp Makefile.dist tmp.c
  84. ! gcc -Ui386 -E >Makefile $makedefine -DM_MAKEDEFINE="$makedefine" tmp.c
  85.   rm -f tmp.c
  86.   
  87.   echo "GDB is now set up for use with a $machine." \
  88. *** 3.5/core.c    Thu Jan 11 00:55:17 1990
  89. --- core.c    Thu Aug  1 18:01:22 1991
  90. ***************
  91. *** 49,54 ****
  92. --- 49,59 ----
  93.   #ifdef UMAX_CORE
  94.   #include <sys/ptrace.h>
  95.   #else
  96. + #ifdef M_XENIX
  97. + struct user; struct buf; struct inode; struct proc;    /* inhibit warnings */
  98. + #include <sys/page.h>
  99. + #include <sys/seg.h>
  100. + #endif
  101.   #include <sys/user.h>
  102.   #endif
  103.   
  104. ***************
  105. *** 62,70 ****
  106. --- 67,79 ----
  107.   
  108.   #ifndef COFF_FORMAT
  109.   #ifndef AOUTHDR
  110. + #ifdef M_XENIX
  111. + #define AOUTHDR        struct xexec
  112. + #else
  113.   #define AOUTHDR        struct exec
  114.   #endif
  115.   #endif
  116. + #endif
  117.   
  118.   extern char *sys_siglist[];
  119.   
  120. ***************
  121. *** 200,209 ****
  122.          the core file, (s)he'll find out soon enough.  */
  123.       return;
  124.   
  125.         if (N_MAGIC (core_aouthdr) != 0
  126.         && bcmp (&core_aouthdr, &exec_aouthdr, sizeof core_aouthdr))
  127.       printf ("Warning: core file does not match specified executable file.\n");
  128. !       else if (exec_mtime > st_core.st_mtime)
  129.       printf ("Warning: exec file is newer than core file.\n");
  130.       }
  131.   }
  132. --- 209,222 ----
  133.          the core file, (s)he'll find out soon enough.  */
  134.       return;
  135.   
  136. + /* cannot validate core file against executable file on xenix */
  137. + #ifndef M_XENIX
  138.         if (N_MAGIC (core_aouthdr) != 0
  139.         && bcmp (&core_aouthdr, &exec_aouthdr, sizeof core_aouthdr))
  140.       printf ("Warning: core file does not match specified executable file.\n");
  141. !       else
  142. ! #endif
  143. !       if (exec_mtime > st_core.st_mtime)
  144.       printf ("Warning: exec file is newer than core file.\n");
  145.       }
  146.   }
  147. *** 3.5/dbxread.c    Sat Jan 27 08:30:54 1990
  148. --- dbxread.c    Thu Aug  1 19:25:46 1991
  149. ***************
  150. *** 40,45 ****
  151. --- 40,60 ----
  152.   #define L_INCR 1
  153.   #endif
  154.   
  155. + #ifdef M_XENIX
  156. + #include <sys/relsym.h>
  157. + #define nlist xenix_nlist    /* the system nlist is broken */
  158. + #include <a.out.h>
  159. + #undef nlist
  160. + #define nlist gas_nlist
  161. + #include "stab.gnu.h"
  162. + #include "gas-nlist.h"
  163. + #define STRING_SEG 4
  164. + #define SYMS_SEG   5
  165. + #define AOUTHDR    struct xexec
  166. + #else /* M_XENIX */
  167.   #ifdef COFF_ENCAPSULATE
  168.   #include "a.out.encap.h"
  169.   #include "stab.gnu.h"
  170. ***************
  171. *** 47,52 ****
  172. --- 62,69 ----
  173.   #include <a.out.h>
  174.   #include <stab.h>
  175.   #endif
  176. + #endif /* M_XENIX */
  177.   #include <ctype.h>
  178.   
  179.   #ifndef NO_GNU_STABS
  180. ***************
  181. *** 167,172 ****
  182. --- 184,222 ----
  183.   /* C++ */
  184.   static struct type **read_args ();
  185.   
  186. + #ifdef M_XENIX
  187. + extern struct xseg *find_segment();
  188. + #define NUMBER_OF_SYMBOLS \
  189. +   ({ struct xseg *cseg; long z;\
  190. +      cseg = find_segment(XS_TSYMS, SYMS_SEG); \
  191. +      z = cseg ? cseg->xs_psize / sizeof(struct nlist) : 0; z;})
  192. + #define SYMBOL_TABLE_OFFSET \
  193. +   ({ struct xseg *cseg; long z;\
  194. +      cseg = find_segment(XS_TSYMS, SYMS_SEG); \
  195. +      z = cseg ? cseg->xs_filpos : 0; z;})
  196. + #define STRING_TABLE_OFFSET \
  197. +   ({ struct xseg *cseg; long z;\
  198. +      cseg = find_segment(XS_TSYMS, STRING_SEG); \
  199. +      z = cseg ? cseg->xs_filpos : 0; z; })
  200. + #define READ_STRING_TABLE_SIZE(INTO)        \
  201. +   { struct xseg *cseg; \
  202. +      cseg = find_segment(XS_TSYMS, STRING_SEG); \
  203. +      INTO = cseg ? cseg->xs_psize : 0; }
  204. + #define N_BADMAG(hdr)\
  205. +   (hdr.x_magic != X_MAGIC && (hdr.x_cpu & XC_CPU) != XC_386 \
  206. +    && (hdr.x_renv & XE_SEG) == 0  && (hdr.x_renv & XE_EXEC) == 0)
  207. + #define READ_FILE_HEADERS(DESC, NAME)        \
  208. + { val = myread (DESC, &hdr, sizeof hdr);    \
  209. +   if (val < 0) perror_with_name (NAME);        \
  210. +   if (N_BADMAG (hdr))                \
  211. +     error ("File \"%s\" not in executable format.", NAME);\
  212. +   process_a_out(DESC, NAME); }
  213. + #define IS_OBJECT_FILE 0
  214. + #define SIZE_OF_TEXT_SEGMENT hdr.x_text
  215. + #define ADDR_OF_TEXT_SEGMENT 0
  216. + #define ENTRY_POINT hdr.x_entry
  217. + #endif
  218.   /* Macro to determine which symbols to ignore when reading the first symbol
  219.      of a file.  Some machines override this definition. */
  220.   #ifdef N_NSYMS
  221. ***************
  222. *** 336,341 ****
  223. --- 386,394 ----
  224.   /* Count symbols as they are processed, for error messages.  */
  225.   
  226.   static int symnum;
  227. + #ifdef M_XENIX
  228. + static long lsym_count = 0;
  229. + #endif /* M_XENIX */
  230.   
  231.   /* Vector of types defined so far, indexed by their dbx type numbers.
  232.      (In newer sun systems, dbx uses a pair of numbers in parens,
  233. ***************
  234. *** 1627,1632 ****
  235. --- 1680,1691 ----
  236.     old_chain = make_cleanup (close, desc);
  237.     make_cleanup (free_current_contents, &name);
  238.   
  239. + #ifdef M_XENIX
  240. + /* On xenix (with gcc) READ_FILE_HEADER reads the segment table,
  241. +  * fileinfo table and global symbol table as well. 
  242. +  */
  243. + #endif /* M_XENIX */
  244.     READ_FILE_HEADERS (desc, name);
  245.   
  246.     entry_point = ENTRY_POINT;
  247. ***************
  248. *** 1676,1681 ****
  249. --- 1735,1744 ----
  250.     val = myread (desc, stringtab, buffer);
  251.     if (val < 0)
  252.       perror_with_name (name);
  253. + #ifdef X_DEBUG
  254. +     printf("\nstring table offset = %d, size = %d, start = %s\n",
  255. +         STRING_TABLE_OFFSET, buffer, stringtab);
  256. + #endif
  257.     
  258.     /* Throw away the old symbol table.  */
  259.   
  260. ***************
  261. *** 1720,1726 ****
  262. --- 1783,1793 ----
  263.   
  264.     /* Go over the misc functions and install them in vector.  */
  265.   
  266. + #ifndef M_XENIX /* This has already been done at header read time */
  267.     condense_misc_bunches (0);
  268. + #else
  269. +   process_global_symbol_table(desc, name);
  270. + #endif /* M_XENIX */
  271.   
  272.     /* Don't allow char * to have a typename (else would get caddr_t.)  */
  273.   
  274. ***************
  275. *** 1799,1805 ****
  276.   {
  277.     if (symbuf_idx == symbuf_end)
  278.       fill_symbuf ();
  279. !   symnum++;
  280.     return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global;
  281.   }
  282.   
  283. --- 1866,1872 ----
  284.   {
  285.     if (symbuf_idx == symbuf_end)
  286.       fill_symbuf ();
  287. !   symnum++;  lsym_count--;
  288.     return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global;
  289.   }
  290.   
  291. ***************
  292. *** 1937,1942 ****
  293. --- 2004,2019 ----
  294.     int global_funs = 0;
  295.   #endif
  296.   
  297. + #ifdef M_XENIX
  298. +   long flsym_count = 0;
  299. +   long file_string_base = 0;
  300. +   long stringtab_offset = 0;
  301. +   long symtab_pos = 0;
  302. +   long filadd = 0;
  303. +   long textsize = 0;
  304. +   int file_count = 0;
  305. + #endif /* M_XENIX */
  306.     /* Current partial symtab */
  307.     struct partial_symtab *pst;
  308.   
  309. ***************
  310. *** 1989,1998 ****
  311. --- 2066,2123 ----
  312.     symtab_input_desc = desc;    /* This is needed for fill_symbuf below */
  313.     symbuf_end = symbuf_idx = 0;
  314.   
  315. + #ifdef M_XENIX
  316. +   init_fileinfo_processing();   /* start processing the list of files */
  317. +   nlistlen += 10;         /* force the hack code to terminate the loop */
  318. +   lsym_count = 0;
  319. + #endif /* M_XENIX */
  320.     for (symnum = 0; symnum < nlistlen; symnum++)
  321.       {
  322.         /* Get the symbol for this run and pull out some info */
  323.         QUIT;    /* allow this to be interruptable */
  324. + #ifdef M_XENIX
  325. +       /* This is a gross hack.  Xenix places pointers to each files $$SYMBOLS
  326. +        * (containing the symbols for DBX) and $$TYPES (containing the strings
  327. +        * for DBX) in the file name table.  There is also a partial symbol
  328. +        * table record for each file produced by the loader - this is ignored
  329. +        * at present.
  330. +        */
  331. +        if (lsym_count == 0)
  332. +        {
  333. +      try_next_file:
  334. +      if (!get_next_fileinfo(&stringtab_offset, &flsym_count, &filadd,
  335. +                             &symtab_pos, &textsize))
  336. +      {            /* all files proccessed */
  337. +        symnum = nlistlen;
  338. +        continue;
  339. +      }
  340. +      else
  341. +      {
  342. +        lseek(desc, symtab_pos, 0);
  343. +          stringtab_global = stringtab + stringtab_offset;
  344. +        symbuf_idx = symbuf_end;  /* force symbol reading */
  345. +        lsym_count = flsym_count;
  346. +      }
  347. +      
  348. +      file_count++;
  349. +      if (file_count == 2)
  350. +            startup_file_start = filadd;
  351. +      if (file_count == 3)
  352. +            startup_file_end = filadd;
  353. +          if (lsym_count == 0)    /* skip this file if no symbols in it */
  354. +        goto try_next_file;
  355. +        }
  356. +        
  357. +        lsym_count--;
  358. + #endif /* M_XENIX */
  359.         if (symbuf_idx == symbuf_end)
  360.       fill_symbuf ();
  361.         bufp = &symbuf[symbuf_idx++];
  362. ***************
  363. *** 2023,2029 ****
  364.     if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)  \
  365.       error ("Invalid symbol data: bad string table offset: %d",       \
  366.          bufp->n_un.n_strx);                                       \
  367. !   namestring = bufp->n_un.n_strx + stringtab
  368.   
  369.   #define    ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE)\
  370.     do {                                        \
  371. --- 2148,2154 ----
  372.     if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)  \
  373.       error ("Invalid symbol data: bad string table offset: %d",       \
  374.          bufp->n_un.n_strx);                                       \
  375. !   namestring = bufp->n_un.n_strx + stringtab + stringtab_offset
  376.   
  377.   #define    ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE)\
  378.     do {                                        \
  379. ***************
  380. *** 2051,2062 ****
  381.       SYMBOL_VALUE (psym) = (VALUE);                     \
  382.     } while (0);
  383.   
  384.   
  385. !       switch (bufp->n_type)
  386.       {
  387.         /*
  388.          * Standard, non-debugger, symbols
  389.          */
  390.   
  391.       case N_TEXT | N_EXT:
  392.         /* Catch etext */
  393. --- 2176,2193 ----
  394.       SYMBOL_VALUE (psym) = (VALUE);                     \
  395.     } while (0);
  396.   
  397. + #ifdef X_DEBUG
  398. + printf("%s = (%#x, %d, %#x)\n",
  399. +   bufp->n_un.n_strx ? bufp->n_un.n_strx+stringtab+stringtab_offset : "<NONE>",
  400. +   (unsigned char)bufp->n_type, bufp->n_desc, bufp->n_value);
  401. + #endif /* X_DEBUG */
  402.   
  403. !       switch ((unsigned char)bufp->n_type)
  404.       {
  405.         /*
  406.          * Standard, non-debugger, symbols
  407.          */
  408. + #ifndef M_XENIX            /* these are not present with Xenix / GCC */
  409.   
  410.       case N_TEXT | N_EXT:
  411.         /* Catch etext */
  412. ***************
  413. *** 2176,2181 ****
  414. --- 2307,2314 ----
  415.       case N_NBBSS:
  416.   #endif
  417.   
  418. + #endif /* M_XENIX */
  419.         /* Keep going . . .*/
  420.   
  421.         /*
  422. ***************
  423. *** 2209,2218 ****
  424. --- 2342,2358 ----
  425.   
  426.         if (pst && past_first_source_file)
  427.           {
  428. + #ifndef M_XENIX
  429.             end_psymtab (pst, psymtab_include_list, includes_used,
  430.                  symnum * sizeof (struct nlist), bufp->n_value,
  431.                  dependency_list, dependencies_used,
  432.                  global_psymbols.next, static_psymbols.next);
  433. + #else
  434. +           end_psymtab (pst, psymtab_include_list, includes_used,
  435. +                symtab_pos + flsym_count * sizeof (struct nlist),
  436. +                bufp->n_value, dependency_list, dependencies_used,
  437. +                global_psymbols.next, static_psymbols.next);
  438. + #endif
  439.             pst = (struct partial_symtab *) 0;
  440.             includes_used = 0;
  441.             dependencies_used = 0;
  442. ***************
  443. *** 2220,2228 ****
  444. --- 2360,2374 ----
  445.         else
  446.           past_first_source_file = 1;
  447.   
  448. + #ifndef M_XENIX
  449.         pst = start_psymtab (namestring, bufp->n_value,
  450.                      symnum * sizeof (struct nlist),
  451.                      global_psymbols.next, static_psymbols.next);
  452. + #else
  453. +       pst = start_psymtab (namestring, bufp->n_value, symtab_pos,
  454. +                    global_psymbols.next, static_psymbols.next,
  455. +                    stringtab_offset, flsym_count, textsize);
  456. + #endif /* M_XENIX */
  457.   
  458.         continue;
  459.   
  460. ***************
  461. *** 2591,2596 ****
  462. --- 2737,2743 ----
  463.       }
  464.   
  465.     /* If there's stuff to be cleaned up, clean it up.  */
  466. + #ifndef M_XENIX
  467.     if (entry_point < bufp->n_value
  468.         && entry_point >= last_o_file_start)
  469.       {
  470. ***************
  471. *** 2597,2609 ****
  472. --- 2744,2764 ----
  473.         startup_file_start = last_o_file_start;
  474.         startup_file_end = bufp->n_value;
  475.       }
  476. + #endif /* M_XENIX */
  477.   
  478.     if (pst)
  479.       {
  480. + #ifndef M_XENIX
  481.         end_psymtab (pst, psymtab_include_list, includes_used,
  482.              symnum * sizeof (struct nlist), end_of_text_addr,
  483.              dependency_list, dependencies_used,
  484.              global_psymbols.next, static_psymbols.next);
  485. + #else /* M_XENIX */
  486. +       end_psymtab (pst, psymtab_include_list, includes_used,
  487. +            symtab_pos + flsym_count * sizeof (struct nlist),
  488. +            end_of_text_addr, dependency_list, dependencies_used,
  489. +            global_psymbols.next, static_psymbols.next);
  490. + #endif /* M_XENIX */
  491.         includes_used = 0;
  492.         dependencies_used = 0;
  493.         pst = (struct partial_symtab *) 0;
  494. ***************
  495. *** 2653,2658 ****
  496. --- 2808,2814 ----
  497.    * completely filled at the end of the symbol list.
  498.    */
  499.   static struct partial_symtab *
  500. + #ifndef M_XENIX
  501.   start_psymtab (filename, textlow, ldsymoff, global_syms, static_syms)
  502.        char *filename;
  503.        int textlow;
  504. ***************
  505. *** 2659,2664 ****
  506. --- 2815,2832 ----
  507.        int ldsymoff;
  508.        struct partial_symbol *global_syms;
  509.        struct partial_symbol *static_syms;
  510. + #else
  511. + start_psymtab (filename, textlow, ldsymoff, global_syms, static_syms, stroffset,
  512. +            symcount, textsize)
  513. +      char *filename;
  514. +      int textlow;
  515. +      int ldsymoff;
  516. +      struct partial_symbol *global_syms;
  517. +      struct partial_symbol *static_syms;
  518. +      int stroffset;
  519. +      int symcount;
  520. +      long textsize;
  521. + #endif
  522.   {
  523.     struct partial_symtab *result =
  524.       (struct partial_symtab *) obstack_alloc (psymbol_obstack,
  525. ***************
  526. *** 2671,2677 ****
  527.   
  528.     result->textlow = textlow;
  529.     result->ldsymoff = ldsymoff;
  530.     result->readin = 0;
  531.   
  532.     result->globals_offset = global_syms - global_psymbols.list;
  533. --- 2839,2848 ----
  534.   
  535.     result->textlow = textlow;
  536.     result->ldsymoff = ldsymoff;
  537. ! #ifdef M_XENIX
  538. !   result->texthigh = textlow + textsize;
  539. !   result->ldsymlen = symcount * sizeof(struct nlist);
  540. ! #endif
  541.     result->readin = 0;
  542.   
  543.     result->globals_offset = global_syms - global_psymbols.list;
  544. ***************
  545. *** 2679,2684 ****
  546. --- 2850,2856 ----
  547.   
  548.     result->n_global_syms = 0;
  549.     result->n_static_syms = 0;
  550. +   result->stringtab_off = stroffset;
  551.   
  552.     return result;
  553.   }
  554. ***************
  555. *** 2722,2729 ****
  556. --- 2894,2903 ----
  557.   {
  558.     int i;
  559.   
  560. + #ifndef M_XENIX
  561.     pst->ldsymlen = capping_symbol_offset - pst->ldsymoff;
  562.     pst->texthigh = capping_text;
  563. + #endif /* M_XENIX */
  564.   
  565.     pst->n_global_syms =
  566.       capping_global - (global_psymbols.list + pst->globals_offset);
  567. ***************
  568. *** 2830,2840 ****
  569. --- 3004,3023 ----
  570.         old_chain = make_cleanup (really_free_pendings, 0);
  571.   
  572.         /* Read in this files symbols */
  573. + #ifndef M_XENIX
  574.         lseek (desc, sym_offset, L_SET);
  575.         read_ofile_symtab (desc, stringtab, stringtab_size,
  576.                pst->ldsymoff,
  577.                pst->ldsymlen, pst->textlow,
  578.                pst->texthigh - pst->textlow, 0);
  579. + #else  /* M_XENIX */
  580. +       read_ofile_symtab (desc, stringtab + pst->stringtab_off,
  581. +              stringtab_size - pst->stringtab_off,
  582. +              pst->ldsymoff,
  583. +              pst->ldsymlen, pst->textlow,
  584. +              pst->texthigh - pst->textlow, 0);
  585. + #endif  /* M_XENIX */
  586.         sort_symtab_syms (symtab_list); /* At beginning since just added */
  587.   
  588.         do_cleanups (old_chain);
  589. ***************
  590. *** 2903,2909 ****
  591. --- 3086,3094 ----
  592.         if (desc < 0)
  593.       error("Symbol file not readable");
  594.   
  595. + #ifndef M_XENIX    
  596.         READ_FILE_HEADERS (desc, name);
  597. + #endif /* M_XENIX */
  598.   
  599.         /* Read in the string table */
  600.         lseek (desc, STRING_TABLE_OFFSET, L_SET);
  601. ***************
  602. *** 3058,3063 ****
  603. --- 3243,3249 ----
  604.     symtab_input_desc = desc;
  605.     symbuf_end = symbuf_idx = 0;
  606.   
  607. + #ifndef M_XENIX
  608.     /* It is necessary to actually read one symbol *before* the start
  609.        of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
  610.        occurs before the N_SO symbol.
  611. ***************
  612. *** 3087,3092 ****
  613. --- 3273,3285 ----
  614.         lseek(desc, sym_offset, L_INCR);
  615.         processing_gcc_compilation = 0;
  616.       }
  617. + #else /* M_XENIX */
  618. +     lseek(desc, sym_offset, L_SET);
  619. +     processing_gcc_compilation = 0;
  620. + #ifdef X_DEBUG
  621. +     printf("sym_offset = %d,  sym_size = %d\n", sym_offset, sym_size);
  622. + #endif /* X_DEBUG */
  623. + #endif /* M_XENIX */
  624.   
  625.     if (symbuf_idx == symbuf_end)
  626.       fill_symbuf();
  627. ***************
  628. *** 3094,3099 ****
  629. --- 3287,3298 ----
  630.     if ((unsigned char) bufp->n_type != N_SO)
  631.       fatal("First symbol in segment of executable not a source symbol");
  632.   
  633. + #ifdef X_DEBUG
  634. + printf("%s = (%#x, %d, %#x)\n",
  635. +   bufp->n_un.n_strx ? bufp->n_un.n_strx+stringtab : "<NONE>",
  636. +   (unsigned char)bufp->n_type, bufp->n_desc, bufp->n_value);
  637. + #endif /* X_DEBUG */
  638.     for (symnum = 0;
  639.          symnum < sym_size / sizeof(struct nlist);
  640.          symnum++)
  641. ***************
  642. *** 3103,3108 ****
  643. --- 3302,3312 ----
  644.       fill_symbuf();
  645.         bufp = &symbuf[symbuf_idx++];
  646.         type = bufp->n_type;
  647. + #ifdef X_DEBUG
  648. + printf("%s = (%#x, %d, %#x)\n",
  649. +   bufp->n_un.n_strx ? bufp->n_un.n_strx+stringtab : "<NONE>",
  650. +   (unsigned char)bufp->n_type, bufp->n_desc, bufp->n_value);
  651. + #endif /* X_DEBUG */
  652.   
  653.         if (offset &&
  654.         (type == N_TEXT || type == N_DATA || type == N_BSS))
  655. ***************
  656. *** 3476,3481 ****
  657. --- 3680,3687 ----
  658.   
  659.   /* Read in another .o file and create a symtab entry for it.*/
  660.   
  661. + #ifndef M_XENIX /* Xenix can't do incremental loads */
  662.   static void
  663.   read_addl_syms (desc, stringtab, nlistlen, text_addr, text_size)
  664.        int desc;
  665. ***************
  666. *** 3772,3777 ****
  667. --- 3978,3984 ----
  668.     printf ("done.\n");
  669.     fflush (stdout);
  670.   }
  671. + #endif /* M_XENIX */
  672.   
  673.   /* Read a number by which a type is referred to in dbx data,
  674.      or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
  675. ***************
  676. *** 5469,5476 ****
  677. --- 5676,5685 ----
  678.     add_com ("symbol-file", class_files, symbol_file_command,
  679.          "Load symbol table (in dbx format) from executable file FILE.");
  680.   
  681. + #ifndef M_XENIX
  682.     add_com ("add-file", class_files, add_file_command,
  683.              "Load the symbols from FILE, assuming its code is at TEXT_START.") ;
  684. + #endif /* M_XENIX */
  685.   }
  686.   
  687.   #endif /* READ_DBX_FORMAT */
  688. *** 3.5/gas-nlist.h
  689. --- gas-nlist.h    Thu Aug  1 18:01:31 1991
  690. ***************
  691. *** 0 ****
  692. --- 1,13 ----
  693. + #define N_STAB 0340
  694. + struct gas_nlist {
  695. +     union {
  696. +         char    *n_name;
  697. +         struct gas_nlist *n_next;
  698. +         long    n_strx;
  699. +     } n_un;
  700. +     char    n_type;
  701. +     char    n_other;
  702. +     short    n_desc;
  703. +     unsigned n_value;
  704. + };
  705. *** 3.5/i386-dep.c    Thu Jan 11 00:58:05 1990
  706. --- i386-dep.c    Thu Aug  1 18:01:33 1991
  707. ***************
  708. *** 30,35 ****
  709. --- 30,49 ----
  710.   #include <sys/param.h>
  711.   #include <sys/dir.h>
  712.   #include <signal.h>
  713. + #ifdef M_XENIX
  714. + struct user; struct buf; struct inode; struct proc;    /* inhibit warnings */
  715. + #include <sys/page.h>
  716. + #include <sys/seg.h>
  717. + #define a_magic xa_magic
  718. + #define a_text xa_text
  719. + #define exec xexec
  720. + #undef U_FPSTATE
  721. + #define U_FPSTATE(u)    u.u_fps
  722. + #define fpstate u_fps
  723. + #define u_fpvalid u_fpsaved
  724. + unsigned short text_segid;    /* segment number of text segment */
  725. + unsigned short data_segid;    /* segment number of data segment */
  726. + #endif
  727.   #include <sys/user.h>
  728.   #include <sys/ioctl.h>
  729.   #include <fcntl.h>
  730. ***************
  731. *** 37,44 ****
  732. --- 51,60 ----
  733.   #ifdef COFF_ENCAPSULATE
  734.   #include "a.out.encap.h"
  735.   #else
  736. + #ifndef M_XENIX            /* already included by sys/user.h */
  737.   #include <a.out.h>
  738.   #endif
  739. + #endif
  740.   
  741.   #ifndef N_SET_MAGIC
  742.   #ifdef COFF_FORMAT
  743. ***************
  744. *** 50,57 ****
  745. --- 66,94 ----
  746.   
  747.   #include <sys/file.h>
  748.   #include <sys/stat.h>
  749. + #ifdef M_XENIX
  750. + #include <sys/proc.h>
  751. + #endif
  752.   
  753.   #include <sys/reg.h>
  754. + #ifdef M_XENIX
  755. + #define SS    RSS
  756. + #define UESP    RESP
  757. + #define EFL    REFL
  758. + #define CS    RCS
  759. + #define EIP    REIP
  760. + #define EAX    REAX
  761. + #define ECX    RECX
  762. + #define EDX    REDX
  763. + #define EBX    REBX
  764. + #define EBP    REBP
  765. + #define ESI    RESI
  766. + #define EDI    REDI
  767. + #define DS    RDS
  768. + #define ES    RES
  769. + #define FS    RFS
  770. + #define GS    RGS
  771. + #endif
  772.   
  773.   extern int errno;
  774.   
  775. ***************
  776. *** 62,68 ****
  777. --- 99,120 ----
  778.   call_ptrace (request, pid, arg3, arg4)
  779.        int request, pid, arg3, arg4;
  780.   {
  781. + #ifdef M_XENIX
  782. +     extern CORE_ADDR text_end;
  783. +     int addr_in_data_segment = arg3 > text_end;
  784. + #ifdef PTRACE_ADDR_ARG_STRUCT
  785. +     struct saddr addr;
  786. +     addr.sa_seg = addr_in_data_segment ? data_segid : text_segid;
  787. +     if (request == 7 || request == 9) addr.sa_seg = 0;
  788. +     addr.sa_off = arg3;
  789. +     arg3 = (int) &addr;
  790. + #endif
  791. +   if (addr_in_data_segment && (request == 1 || request == 4)) request++;
  792. +   return ptrace (request, pid, arg3, arg4);
  793. + #define ptrace(a, b, c, d) call_ptrace(a, b, c, d)
  794. + #else
  795.     return ptrace (request, pid, arg3, arg4);
  796. + #endif /* M_XENIX */
  797.   }
  798.   
  799.   kill_inferior ()
  800. ***************
  801. *** 157,163 ****
  802. --- 209,220 ----
  803.         perror_with_name (buf);
  804.       }
  805.       }
  806. + #ifdef M_XENIX
  807. + /* HACK: Xenix ptrace() disallows writing to where es, fs and gs are kept */
  808. +   else for (regno = 0; regno < (NUM_REGS - 3); regno++)
  809. + #else
  810.     else for (regno = 0; regno < NUM_REGS; regno++)
  811. + #endif
  812.       {
  813.         regaddr = register_addr (regno, offset);
  814.         errno = 0;
  815. ***************
  816. *** 382,389 ****
  817. --- 439,451 ----
  818.   
  819.     data_start = 0;
  820.     data_end = 0;
  821. + #ifdef M_XENIX
  822. +   stack_start = 0;
  823. +   stack_end = 0;
  824. + #else
  825.     stack_start = STACK_END_ADDR;
  826.     stack_end = STACK_END_ADDR;
  827. + #endif
  828.   
  829.     /* Now, if a new core file was specified, open it and digest it.  */
  830.   
  831. ***************
  832. *** 406,411 ****
  833. --- 468,474 ----
  834.       val = myread (corechan, &u, sizeof u);
  835.       if (val < 0)
  836.         perror_with_name (filename);
  837. + #ifndef M_XENIX
  838.       data_start = exec_data_start;
  839.   
  840.       data_end = data_start + NBPG * u.u_dsize;
  841. ***************
  842. *** 412,417 ****
  843. --- 475,490 ----
  844.       stack_start = stack_end - NBPG * u.u_ssize;
  845.       data_offset = NBPG * UPAGES;
  846.       stack_offset = NBPG * (UPAGES + u.u_dsize);
  847. + #else
  848. +     data_start = (CORE_ADDR)u.u_sdata;
  849. +     data_end = (CORE_ADDR)u.u_edatau;
  850. +     stack_start = (CORE_ADDR)u.u_stktop;
  851. +     stack_end = (CORE_ADDR)u.u_stkbotu;
  852. +     data_offset = lseek(corechan, 0L, 2) - u.u_dsize;
  853. +     stack_offset = (((sizeof u + (u.u_ldtlimit-1)*sizeof(struct descriptor)
  854. +             + NBPC - 1) / NBPC) * NBPC);
  855. + #endif
  856.       reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR;
  857.   
  858.       /* I don't know where to find this info.
  859. ***************
  860. *** 523,529 ****
  861. --- 596,651 ----
  862.       exec_mtime = file_hdr.f_timdat;
  863.         }
  864.   #else /* not COFF_FORMAT */
  865. + #ifdef M_XENIX
  866.         {
  867. +     char *extended_header;
  868. +     struct xext *xext;
  869. +     struct stat st_exec;
  870. +     struct xseg xseg;
  871. +     extern char *malloc();
  872. +     val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR));
  873. +     if (val < 0)
  874. +       perror_with_name (filename);
  875. +         if (exec_aouthdr.x_magic != X_MAGIC)
  876. +       error ("\"%s\": not in executable format.", execfile);
  877. +     if ( (exec_aouthdr.x_cpu & XC_CPU) != XC_386 )
  878. +       error ("\"%s\": not a 386 executable.", execfile);
  879. +     if ( (exec_aouthdr.x_renv & XE_SEG) == 0)
  880. +       error ("\"%s\": not a segmented executable.", execfile);
  881. +     if ( (exec_aouthdr.x_renv & XE_EXEC) == 0)
  882. +       error ("\"%s\": not executable.", execfile);
  883. +     extended_header = malloc(exec_aouthdr.x_ext);
  884. +     val = myread (execchan, extended_header, exec_aouthdr.x_ext);
  885. +     if (val < 0)
  886. +       perror_with_name (filename);
  887. +     xext = (struct xext *)extended_header;
  888. +     lseek(execchan, xext->xe_segpos, 0);
  889. +     if (myread (execchan, (char *)&xseg, sizeof(xseg)) < 0)
  890. +       perror_with_name (filename);
  891. +     if ( xseg.xs_type != XS_TTEXT )
  892. +       error ("\"%s\": Text segment isn't first (huh?).", execfile);
  893. +     text_segid = xseg.xs_seg;
  894. +     text_start = xseg.xs_rbase;
  895. +     text_end = text_start + xseg.xs_vsize;
  896. +     text_offset = xseg.xs_filpos;
  897. +     if (myread (execchan, (char *)&xseg, sizeof(xseg)) < 0)
  898. +       perror_with_name (filename);
  899. +     if ( xseg.xs_type != XS_TDATA )
  900. +       error ("\"%s\": Data segment isn't second (huh?).", execfile);
  901. +     data_segid = xseg.xs_seg;
  902. +     exec_data_start = xseg.xs_rbase;
  903. +     exec_data_end = exec_data_start + xseg.xs_psize;
  904. +     exec_data_offset = xseg.xs_filpos;
  905. +     data_start = exec_data_start;
  906. +     data_end += exec_data_start;
  907. +     
  908. +     fstat (execchan, &st_exec);
  909. +     exec_mtime = st_exec.st_mtime;
  910. +     free(extended_header);
  911. +       }
  912. + #else    /* not M_XENIX */
  913.       struct stat st_exec;
  914.   
  915.   #ifdef HEADER_SEEK_FD
  916. ***************
  917. *** 549,554 ****
  918. --- 671,677 ----
  919.       fstat (execchan, &st_exec);
  920.       exec_mtime = st_exec.st_mtime;
  921.         }
  922. + #endif /* not M_XENIX */
  923.   #endif /* not COFF_FORMAT */
  924.   
  925.         validate_files ();
  926. ***************
  927. *** 1056,1061 ****
  928. --- 1179,1195 ----
  929.   
  930.   struct env387 
  931.   {
  932. + #ifdef M_XENIX
  933. +   unsigned int control;
  934. +   unsigned int status;
  935. +   unsigned int tag;
  936. +   unsigned long eip;
  937. +   unsigned short code_seg;
  938. +   unsigned short operand_seg;
  939. +   unsigned long opcode;
  940. +   unsigned long operand;
  941. +   unsigned char regs[8][10];
  942. + #else
  943.     unsigned short control;
  944.     unsigned short r0;
  945.     unsigned short status;
  946. ***************
  947. *** 1069,1074 ****
  948. --- 1203,1209 ----
  949.     unsigned short operand_seg;
  950.     unsigned short r3;
  951.     unsigned char regs[8][10];
  952. + #endif
  953.   };
  954.   
  955.   static
  956. ***************
  957. *** 1145,1150 ****
  958. --- 1280,1289 ----
  959.     int fpreg;
  960.     unsigned char *p;
  961.     
  962. + #ifdef M_XENIX
  963. +   if (ep->status != 0) 
  964. +       print_387_status_word (ep->status);
  965. + #else
  966.     bothstatus = ((status != 0) && (ep->status != 0));
  967.     if (status != 0) 
  968.       {
  969. ***************
  970. *** 1159,1164 ****
  971. --- 1298,1304 ----
  972.       printf ("e: ");
  973.         print_387_status_word (ep->status);
  974.       }
  975. + #endif
  976.     
  977.     print_387_control_word (ep->control);
  978.     printf ("last exception: ");
  979. ***************
  980. *** 1188,1193 ****
  981. --- 1328,1334 ----
  982.         i387_to_double (ep->regs[fpreg], (char *)&val);
  983.         printf ("  %g\n", val);
  984.       }
  985. + #ifndef M_XENIX
  986.     if (ep->r0)
  987.       printf ("warning: reserved0 is 0x%x\n", ep->r0);
  988.     if (ep->r1)
  989. ***************
  990. *** 1196,1201 ****
  991. --- 1337,1343 ----
  992.       printf ("warning: reserved2 is 0x%x\n", ep->r2);
  993.     if (ep->r3)
  994.       printf ("warning: reserved3 is 0x%x\n", ep->r3);
  995. + #endif
  996.   }
  997.   
  998.   #ifndef U_FPSTATE
  999. ***************
  1000. *** 1270,1275 ****
  1001. --- 1412,1421 ----
  1002.       }
  1003.     
  1004.     fpstatep = (struct fpstate *)(buf + skip);
  1005. + #ifdef M_XENIX
  1006. +   print_387_status (0, (struct env387 *)fpstatep);
  1007. + #else
  1008.     print_387_status (fpstatep->status, (struct env387 *)fpstatep->state);
  1009. + #endif
  1010.   }
  1011.   
  1012. *** 3.5/infrun.c    Wed Jan 24 00:10:35 1990
  1013. --- infrun.c    Thu Aug  1 18:01:35 1991
  1014. ***************
  1015. *** 146,151 ****
  1016. --- 146,156 ----
  1017.   /* Needed by IN_SIGTRAMP on some machines (e.g. vax).  */
  1018.   #include <sys/param.h>
  1019.   /* Needed by IN_SIGTRAMP on some machines (e.g. vax).  */
  1020. + #ifdef M_XENIX
  1021. + struct user; struct buf; struct inode; struct proc;    /* inhibit warnings */
  1022. + #include <sys/page.h>
  1023. + #include <sys/seg.h>
  1024. + #endif
  1025.   #include <sys/user.h>
  1026.   
  1027.   extern char *sys_siglist[];
  1028. *** 3.5/m-xenix386.h
  1029. --- m-xenix386.h    Thu Aug  1 18:01:35 1991
  1030. ***************
  1031. *** 0 ****
  1032. --- 1,30 ----
  1033. + /* SCO XENIX 386 version.  Mostly like System V/386 3.2 */
  1034. + #include "m-i386-sv32.h"
  1035. + /* define this if your DEVELOPMENT system is older than 2.3 */
  1036. + /* #define PTRACE_ADDR_ARG_STRUCT */
  1037. + #define const    /* workaround for SCO's include files */
  1038. + /* This machine doesn't have the siginterrupt call.  */
  1039. + #define NO_SIGINTERRUPT
  1040. + #define NAMES_HAVE_UNDERSCORE
  1041. + /* support dbx-style debugging in x.out executables produced by
  1042. +    the accompanying port of GCC */
  1043. + #undef COFF_FORMAT
  1044. + #define READ_DBX_FORMAT
  1045. + #undef START_INFERIOR_TRAPS_EXPECTED
  1046. + #define START_INFERIOR_TRAPS_EXPECTED 2
  1047. + #undef KERNEL_U_ADDR
  1048. + #define KERNEL_U_ADDR 0x06000000
  1049. + #undef FIX_CALL_DUMMY
  1050. + #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type)   \
  1051. + { \
  1052. +     extern CORE_ADDR text_end; \
  1053. +     int from, to, delta, loc; \
  1054. +     loc = text_end - CALL_DUMMY_LENGTH; \
  1055. +     from = loc + 5; \
  1056. +     to = (int)(fun); \
  1057. +     delta = to - from; \
  1058. +     *(int *)((char *)(dummyname) + 1) = delta; \
  1059. + }
  1060. + #define CANNOT_EXECUTE_STACK
  1061. *** 3.5/munch    Wed Jul  5 20:46:28 1989
  1062. --- munch    Thu Aug  1 18:01:35 1991
  1063. ***************
  1064. *** 5,17 ****
  1065.   echo '/* Do not modify this file.  It is created automatically by "munch". */'
  1066.   echo 'void initialize_all_files () {'
  1067.   
  1068. ! if test "$1" = "-DSYSV" ; then
  1069.       shift;
  1070.       nm $* | egrep '^(.*[^a-zA-Z_]_|_)initialize_' | \
  1071.       sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\)[^a-zA-Z0-9_].*$/   \1 ();/'
  1072.   else
  1073.       nm -p $* | egrep 'T *__initialize_' | \
  1074.       sed -e 's/^.*T *_*\(.*\)/    _\1 ();/'
  1075.   fi
  1076.   
  1077.   echo '}'
  1078. --- 5,22 ----
  1079.   echo '/* Do not modify this file.  It is created automatically by "munch". */'
  1080.   echo 'void initialize_all_files () {'
  1081.   
  1082. ! if [ -f /xenix ]; then
  1083.       shift;
  1084. +     nm $* | egrep 'A *__initialize_' | \
  1085. +     sed -e 's/^.*A *_*\(.*\)/    _\1 ();/'
  1086. + else if test "$1" = "-DSYSV" ; then
  1087. +     shift;
  1088.       nm $* | egrep '^(.*[^a-zA-Z_]_|_)initialize_' | \
  1089.       sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\)[^a-zA-Z0-9_].*$/   \1 ();/'
  1090.   else
  1091.       nm -p $* | egrep 'T *__initialize_' | \
  1092.       sed -e 's/^.*T *_*\(.*\)/    _\1 ();/'
  1093. + fi
  1094.   fi
  1095.   
  1096.   echo '}'
  1097. *** 3.5/readline/Makefile    Thu Feb  8 07:05:33 1990
  1098. --- readline/Makefile    Thu Aug  1 18:01:43 1991
  1099. ***************
  1100. *** 38,44 ****
  1101.   # A good alternative is gcc -traditional.
  1102.   #CC = gcc -traditional
  1103.   CC = cc
  1104. ! RANLIB = /usr/bin/ranlib
  1105.   AR = ar
  1106.   RM = rm
  1107.   CP = cp
  1108. --- 38,44 ----
  1109.   # A good alternative is gcc -traditional.
  1110.   #CC = gcc -traditional
  1111.   CC = cc
  1112. ! RANLIB = /bin/ranlib
  1113.   AR = ar
  1114.   RM = rm
  1115.   CP = cp
  1116. *** 3.5/readline/readline.c    Sun Nov 26 22:31:36 1989
  1117. --- readline/readline.c    Thu Aug  1 18:01:45 1991
  1118. ***************
  1119. *** 68,73 ****
  1120. --- 68,77 ----
  1121.   
  1122.   #define HACK_TERMCAP_MOTION
  1123.   
  1124. + #ifdef M_XENIX
  1125. + #include <sys/ttold.h>
  1126. + #include <sys/ndir.h>
  1127. + #else
  1128.   #ifndef SYSV
  1129.   #include <sys/dir.h>
  1130.   #else  /* SYSV */
  1131. ***************
  1132. *** 79,84 ****
  1133. --- 83,89 ----
  1134.   #define d_namlen d_reclen
  1135.   #endif  /* hpux */
  1136.   #endif  /* SYSV */
  1137. + #endif
  1138.   
  1139.   /* Some standard library routines. */
  1140.   #include "readline.h"
  1141. *** 3.5/symtab.h    Fri Sep  8 01:59:14 1989
  1142. --- symtab.h    Thu Aug  1 18:01:46 1991
  1143. ***************
  1144. *** 149,154 ****
  1145. --- 149,157 ----
  1146.        to take a *lot* of time; check) or an error (and we don't care
  1147.        how long errors take). */
  1148.     int statics_offset, n_static_syms;
  1149. + #ifdef M_XENIX
  1150. +   int stringtab_off;
  1151. + #endif /* M_XENIX */
  1152.   };
  1153.   
  1154.   /* This is the list of struct symtab's that gdb considers current.  */
  1155. *** 3.5/values.c    Sun Sep 10 04:39:19 1989
  1156. --- values.c    Thu Aug  1 18:01:48 1991
  1157. ***************
  1158. *** 1024,1028 ****
  1159.   
  1160.     add_info ("values", value_history_info,
  1161.           "Elements of value history (around item number IDX, or last ten).");
  1162. !   add_info_alias ("history", value_history_info, 0);
  1163.   }
  1164. --- 1024,1028 ----
  1165.   
  1166.     add_info ("values", value_history_info,
  1167.           "Elements of value history (around item number IDX, or last ten).");
  1168. ! /*  add_info_alias ("history", value_history_info, 0); */
  1169.   }
  1170. *** 3.5/x386dbx.c
  1171. --- x386dbx.c    Thu Aug  1 18:01:50 1991
  1172. ***************
  1173. *** 0 ****
  1174. --- 1,481 ----
  1175. + #include <stdio.h>
  1176. + #include <a.out.h>
  1177. + #include <fcntl.h>
  1178. + #include <sys/types.h>
  1179. + #include <sys/relsym.h>
  1180. + #include <sys/param.h>
  1181. + #include <sys/file.h>
  1182. + #include "defs.h"
  1183. + #include "param.h"
  1184. + #include "symtab.h"
  1185. + #include "gas-nlist.h"
  1186. + /* XENIX symbol segment shape definitions */
  1187. + struct section2 {            /* File info table shape */
  1188. +     short        segment;    /* segment number */
  1189. +     CORE_ADDR    address;    /* start address for this file */
  1190. +     unsigned short    textsize;    /* size of the text for this file */
  1191. +     long        type3off;    /* offset to type3 records, psym tab */
  1192. +     long        type4off;    /* offset to type4 records, nlist tab */
  1193. +     long        type5off;    /* offset to type5 records, str tab */
  1194. +     long        type6off;    /* offset to type6 records */
  1195. +     unsigned short    type3sz;    /* size of type3 records */
  1196. +     unsigned short    type4sz;    /* size of type4 records */
  1197. +     unsigned short    type5sz;    /* size of type5 records */
  1198. +     unsigned short    type6sz;    /* size of type6 records */
  1199. +     char        filelen;    /* length of filename */
  1200. + };
  1201. + /* psymtable (attribute 3) symbol segment shape */
  1202. + struct psymbol_seg {
  1203. +     long        address;    /* core address */
  1204. +     short        segid;        /* segment number */
  1205. +     short        typeid;        /* variable's type */
  1206. +     char        varlen;        /* variable's length */
  1207. + /*    char        name[0];    trailing name varlen long */
  1208. + } record3;
  1209. + /*  Info maintenance structures */
  1210. + struct fileinfo {        /* per file info */
  1211. +     CORE_ADDR    address;    /* start address for this file */
  1212. +     unsigned short    textsize;    /* size of text for this file */
  1213. +     long        psymoff;    /* psyms table */
  1214. +     long        strtaboff;    /* string table aka $$TYPES */
  1215. +     long        ntaboff;    /* nlist table aka $$SYMBOLS */
  1216. +     unsigned short    psymsz;        /* size of psyms table */
  1217. +     unsigned short    strtabsz;    /* size of string table */
  1218. +     unsigned short    ntabsz;        /* size of nlist table */
  1219. +     int        mscdebuginfo;    /* compiled with cc -g not gcc -g */
  1220. +     char        *filename;    /* name of this file */
  1221. +     struct fileinfo *next;
  1222. + };
  1223. + static struct fileinfo *fi_table = 0;
  1224. + struct xseg *seg_table;
  1225. + long num_seg_table_entries;
  1226. + #ifdef __GNUC__
  1227. + #define alloca __builtin_alloca
  1228. + #endif
  1229. + #define IGNORE_ATTR (-1)
  1230. + static read_fileinfo_table(fp, segsize, name)
  1231. + FILE *fp;
  1232. + int segsize;
  1233. + char *name;
  1234. + {
  1235. +   extern char *strrchr(), *xmalloc();
  1236. +   char *fi_name;
  1237. +   char *filename;
  1238. +   struct section2 fi_entry;
  1239. +   struct fileinfo *fi;
  1240. +   fi_table = fi = (struct fileinfo *)xmalloc(sizeof(struct fileinfo));
  1241. +   while (segsize > 0)
  1242. +   {
  1243. +     if ((fread((char *)&fi_entry.segment, sizeof(short), 1, fp) != 1)
  1244. +       || (fread((char *)&fi_entry.address, sizeof(CORE_ADDR), 1, fp) != 1)
  1245. +       || (fread((char *)&fi_entry.textsize, sizeof(unsigned short),1,fp) != 1)
  1246. +       || (fread((char *)&fi_entry.type3off, sizeof(long), 1, fp) != 1)
  1247. +       || (fread((char *)&fi_entry.type4off, sizeof(long), 1, fp) != 1)
  1248. +       || (fread((char *)&fi_entry.type5off, sizeof(long), 1, fp) != 1)
  1249. +       || (fread((char *)&fi_entry.type6off, sizeof(long), 1, fp) != 1)
  1250. +       || (fread((char *)&fi_entry.type3sz, sizeof(unsigned short),1,fp) != 1)
  1251. +       || (fread((char *)&fi_entry.type4sz, sizeof(unsigned short),1,fp) != 1)
  1252. +       || (fread((char *)&fi_entry.type5sz, sizeof(unsigned short),1,fp) != 1)
  1253. +       || (fread((char *)&fi_entry.type6sz, sizeof(unsigned short),1,fp) != 1)
  1254. +       || (fread((char *)&fi_entry.filelen, sizeof(char), 1, fp) != 1))
  1255. +       perror_with_name(name);
  1256. +     segsize -= sizeof(short) + sizeof(CORE_ADDR) + 5 * sizeof(unsigned short)
  1257. +            + 4 * sizeof(long) + sizeof(char);
  1258. +     fi_name = alloca(fi_entry.filelen + 1);
  1259. +     if (fread(fi_name, fi_entry.filelen, 1, fp) != 1)
  1260. +       perror_with_name(name);
  1261. +     fi_name[fi_entry.filelen] = '\0';
  1262. +     segsize -= fi_entry.filelen;
  1263. +     if ((filename = strrchr(fi_name, '/')) != (char *)0)
  1264. +       fi_name = filename + 1;
  1265. +     if ((filename = strrchr(fi_name, '(')) != (char *)0)
  1266. +       fi_name = filename + 1;
  1267. +     if ((filename = strrchr(fi_name, ')')) != (char *)0)
  1268. +         *filename = '\0';
  1269. +    
  1270. +     {
  1271. +       int len = strlen(fi_name);
  1272. +       if (len > 2 && fi_name[len - 1] == 'o' && fi_name[len - 2] == '.')
  1273. +       fi_name[len - 1] = 'c';
  1274. +     }
  1275. +     fi_name = savestring(fi_name, strlen(fi_name) + 1);
  1276. +     fi->next = (struct fileinfo *)xmalloc(sizeof(struct fileinfo));
  1277. +     fi = fi->next;
  1278. +     fi->address = fi_entry.address;
  1279. +     fi->textsize = fi_entry.textsize;
  1280. +     fi->psymoff = fi_entry.type3off;
  1281. +     fi->psymsz = fi_entry.type3sz;
  1282. +     fi->strtaboff = fi_entry.type4off;
  1283. +     fi->strtabsz = fi_entry.type4sz;
  1284. +     fi->ntaboff = fi_entry.type5off;
  1285. +     fi->ntabsz = fi_entry.type5sz;
  1286. +     fi->mscdebuginfo = (fi_entry.type6sz != 0);
  1287. +     fi->filename = fi_name;
  1288. +   }
  1289. +   fi->next = 0;  fi = fi_table;  fi_table = fi_table->next;  free(fi);
  1290. + #ifdef X_DEBUG
  1291. +     printf("\naddress   textsz  symoff   symsz  stroff   strsz  taboff   tabsz  name\n\n");
  1292. +   for (fi = fi_table; fi != 0; fi = fi->next)
  1293. +   {
  1294. +     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);
  1295. +   }
  1296. +   printf("\n");
  1297. + #endif /* X_DEBUG */
  1298. + }
  1299. + static read_seg_table(fp, pos, size, name)
  1300. + FILE *fp;
  1301. + long pos, size;
  1302. + {
  1303. +   seg_table = (struct xseg *) xmalloc(size);
  1304. +   fseek(fp, pos, 0);
  1305. +   if (fread((char *)seg_table, size, 1, fp) != 1)
  1306. +     perror_with_name(name);
  1307. +   num_seg_table_entries = size / sizeof (struct xseg);
  1308. + }
  1309. + struct xseg *find_segment(type, attr)
  1310. + int type, attr;
  1311. + {
  1312. +   struct xseg *cseg;
  1313. +   for (cseg = seg_table; cseg < seg_table + num_seg_table_entries; ++cseg)
  1314. +   if (cseg->xs_type == type &&
  1315. +     (attr == IGNORE_ATTR || attr == cseg->xs_attr))
  1316. +     return cseg;
  1317. +   return NULL;
  1318. + }
  1319. + static int compare_misc_functions (fn1, fn2)
  1320. + struct misc_function *fn1, *fn2;
  1321. + {
  1322. +   /* Return a signed result based on unsigned comparisons
  1323. +      so that we sort into unsigned numeric order.  */
  1324. +   if (fn1->address < fn2->address)
  1325. +     return -1;
  1326. +   if (fn1->address > fn2->address)
  1327. +     return 1;
  1328. +   return 0;
  1329. + }
  1330. + static int read_misc_functions(fp, segsize, name)
  1331. + FILE *fp;
  1332. + int segsize;
  1333. + char *name;
  1334. + {
  1335. +   char *symdata, *p, *str_buff;
  1336. +   long sym_count = 0, str_count = 0, i;
  1337. +   struct misc_function *miscp;
  1338. +   struct sym symb;
  1339. +   /* grab the symbol table */
  1340. +   symdata = alloca(segsize + 1);
  1341. +   if (fread(symdata, segsize, 1, fp) != 1)
  1342. +       perror_with_name(name);
  1343. +   /* first pass, work out how many symbols there are and the size of the
  1344. +    * strings
  1345. +    */
  1346. +   p = symdata;
  1347. +   while (p < symdata + segsize)
  1348. +   {
  1349. +     int len;
  1350. +     p += sizeof(struct sym);
  1351. +     len = strlen(p) + 1;
  1352. +     str_count += len;  p += len;  sym_count++;
  1353. +   }
  1354. +   /* Now build the misc function vector */
  1355. +   str_buff = xmalloc(str_count+1);
  1356. +   misc_function_vector =
  1357. +     (struct misc_function *) xmalloc (sym_count * sizeof(struct misc_function));
  1358. +   misc_function_count = sym_count;
  1359. +   p = symdata;  miscp = misc_function_vector;
  1360. +   while (p < symdata + segsize)
  1361. +   {
  1362. +     int len;
  1363. +     symb = *((struct sym *)p);
  1364. +     p += sizeof(struct sym);
  1365. +     if (*p == '_')
  1366. +       strcpy(str_buff, p+1);
  1367. +     else
  1368. +       strcpy(str_buff, p);
  1369. +     /* the following will result in a garbage byte every time a symbol
  1370. +      * starts with a _, I can'y be bothered to fix it.
  1371. +      */
  1372. +     miscp->name = str_buff;
  1373. +     len = strlen(p) + 1;
  1374. +     str_buff += len;  p += len;
  1375. +     miscp->address = symb.s_value;
  1376. +     switch(symb.s_type & S_TYPE)
  1377. +     {
  1378. +     case S_UNDEF:  miscp->type = mf_unknown;  break;
  1379. +     case S_ABS:    miscp->type = mf_abs;  break;
  1380. +     case S_TEXT:   miscp->type = mf_text;  break;
  1381. +     case S_DATA:   miscp->type = mf_data;  break;
  1382. +     case S_BSS:    miscp->type = mf_bss;  break;
  1383. +     case S_COMM:   miscp->type = mf_data;  break;
  1384. +     case S_REG:    miscp->type = mf_unknown;  break;
  1385. +     case S_COMB:   miscp->type = mf_unknown;  break;
  1386. +     case S_SEG:    miscp->type = mf_unknown;  break;
  1387. +     case S_FN:     miscp->type = mf_unknown;  break;
  1388. +     dewfault:      miscp->type = mf_unknown;  break;
  1389. +     }
  1390. +     miscp++;
  1391. +   }
  1392. +   qsort (misc_function_vector, misc_function_count,
  1393. +     sizeof (struct misc_function), compare_misc_functions);
  1394. + #ifdef X_DEBUG
  1395. +   {
  1396. +     struct misc_function *miscp;
  1397. +     int i;
  1398. +     printf("type      address  name\n\n");
  1399. +     for (i = 0; i < misc_function_count; i++)
  1400. +     {
  1401. +       miscp = &misc_function_vector[i];
  1402. +       switch (miscp->type)
  1403. +       {
  1404. +       case mf_unknown: printf("%-9s","unknown");  break;
  1405. +       case mf_text:    printf("%-9s","text");  break;
  1406. +       case mf_data:    printf("%-9s","data");  break;
  1407. +       case mf_bss:     printf("%-9s","bss");  break;
  1408. +       case mf_abs:     printf("%-9s","abs");  break;
  1409. +       default:         printf("%-9s","UNKNOWN");  break;
  1410. +       }
  1411. +       printf("% 8x  ", miscp->address);
  1412. +       printf("%s\n", miscp->name);
  1413. +     }
  1414. +   }
  1415. + #endif /* X_DEBUG */
  1416. +   return misc_function_count;
  1417. + }
  1418. + process_a_out(desc, name)
  1419. + int desc;
  1420. + char *name;
  1421. + {
  1422. +   struct xexec exec_aouthdr;
  1423. +   struct xext *xext;
  1424. +   struct xseg *cseg;
  1425. +   FILE *fp;
  1426. +   lseek(desc, 0L, 0);
  1427. +   if ((fp = fdopen(dup(desc), "r")) == NULL)
  1428. +         perror_with_name(name);
  1429. +   if (fread((char *)&exec_aouthdr, sizeof(struct xexec), 1, fp) != 1)
  1430. +     perror_with_name(name);
  1431. +   
  1432. +   xext = (struct xext *) alloca(exec_aouthdr.x_ext);
  1433. +   if (fread((char *)xext, exec_aouthdr.x_ext, 1, fp) != 1)
  1434. +     perror_with_name(name);
  1435. +   
  1436. +   read_seg_table(fp, xext->xe_segpos, xext->xe_segsize, name);
  1437. +   if (cseg = find_segment(XS_TSYMS, 2))
  1438. +   {
  1439. +     fseek(fp, cseg->xs_filpos, 0);
  1440. +     read_fileinfo_table(fp, cseg->xs_psize, name);
  1441. +   }
  1442. +   fclose(fp);
  1443. + }
  1444. + process_global_symbol_table(desc, name)
  1445. + int desc;
  1446. + char *name;
  1447. + {
  1448. +   struct xseg *cseg;
  1449. +   FILE *fp;
  1450. +   if ((fp = fdopen(dup(desc), "r")) == NULL)
  1451. +         perror_with_name(name);
  1452. +   if (cseg = find_segment(XS_TSYMS, 1))
  1453. +   {
  1454. +     fseek(fp, cseg->xs_filpos, 0);
  1455. +     read_misc_functions(fp, cseg->xs_psize, name);
  1456. +   }
  1457. +   fclose(fp);
  1458. + }
  1459. + static struct fileinfo *current_fi;
  1460. + static int first_get_fileinfo_call = 1;
  1461. + init_fileinfo_processing()  /* start processing the list of files */
  1462. + {
  1463. +   first_get_fileinfo_call = 1;
  1464. + }
  1465. + long get_next_fileinfo(stroff, nsyms, address, symtaboff, textsize)
  1466. + long *stroff, *nsyms, *address, *symtaboff, *textsize;
  1467. + {
  1468. +   struct xseg *cseg;
  1469. +   if (first_get_fileinfo_call)
  1470. +   {
  1471. +     current_fi = fi_table;
  1472. +     first_get_fileinfo_call = 0;
  1473. +   }
  1474. +   else
  1475. +     current_fi = current_fi->next;
  1476. +   
  1477. +   if (current_fi == 0)
  1478. +     return 0;
  1479. +   if (current_fi->mscdebuginfo)
  1480. +   {
  1481. +     *stroff = 0;
  1482. +     *nsyms = 0;
  1483. +     *address = current_fi->address;
  1484. +     *textsize = current_fi->textsize;
  1485. +   }
  1486. +   else if (cseg = find_segment(XS_TSYMS, 5))
  1487. +   {
  1488. +     *symtaboff = cseg->xs_filpos + current_fi->ntaboff;
  1489. +     *stroff = current_fi->strtaboff;
  1490. +     *nsyms = current_fi->ntabsz / sizeof(struct gas_nlist);
  1491. +     *address = current_fi->address;
  1492. +     *textsize = current_fi->textsize;
  1493. +     return 1;
  1494. +   }
  1495. +   else
  1496. +   {
  1497. +     *symtaboff = 0;
  1498. +     *stroff = 0;
  1499. +     *nsyms = 0;
  1500. +     *address = 0;
  1501. +     *textsize = 0;
  1502. +   }
  1503. + }
  1504. + #ifdef TEST
  1505. + main()
  1506. + {
  1507. +     char *stab;
  1508. +     long str_offset, nsyms, address, ntaboff, textsize;
  1509. +      int desc;
  1510. +     struct xseg *cseg;
  1511. +     process_a_out((desc = open("a.out", O_RDONLY, 0)), "a.out");
  1512. +     printf("\n");
  1513. +            if (cseg = find_segment(XS_TSYMS, 4))
  1514. +            {
  1515. +         lseek(desc, cseg->xs_filpos, 0);
  1516. +         stab = alloca(cseg->xs_psize);
  1517. +         read(desc, stab, cseg->xs_psize);
  1518. +       }
  1519. +       else
  1520. +         stab = 0;
  1521. +           init_fileinfo_processing();
  1522. +       while (get_next_fileinfo(&str_offset,&nsyms,&address,&ntaboff,&textsize))
  1523. +       {
  1524. +         lseek(desc, ntaboff, 0);
  1525. +         printf("\n  type    desc     value  stroff  string   tsize  (%#x)\n", address);
  1526. +         while (nsyms--)
  1527. +         {
  1528. +           struct gas_nlist nl;
  1529. +           read(desc, &nl, sizeof(nl));
  1530. +           printf("% 6x  % 6x  % 8x  % 6x  % 6x %s\n",
  1531. +              (unsigned char)nl.n_type,
  1532. +              (unsigned short)nl.n_desc,
  1533. +              (unsigned int)nl.n_value,
  1534. +              nl.n_un.n_strx ? stab + str_offset + nl.n_un.n_strx : "");
  1535. +         }
  1536. +         lseek(desc, 0L, 0);
  1537. +       }
  1538. + }
  1539. + perror_with_name (string)
  1540. +      char *string;
  1541. + {
  1542. +   extern int sys_nerr;
  1543. +   extern char *sys_errlist[];
  1544. +   extern int errno;
  1545. +   char *err;
  1546. +   char *combined;
  1547. +   if (errno < sys_nerr)
  1548. +     err = sys_errlist[errno];
  1549. +   else
  1550. +     err = "unknown error";
  1551. +   combined = (char *) alloca (strlen (err) + strlen (string) + 3);
  1552. +   strcpy (combined, string);
  1553. +   strcat (combined, ": ");
  1554. +   strcat (combined, err);
  1555. +   error ("%s.", combined);
  1556. + }
  1557. + error (string, arg1, arg2, arg3)
  1558. +      char *string;
  1559. +      int arg1, arg2, arg3;
  1560. + {
  1561. +   fflush (stdout);
  1562. +   fprintf (stderr, string, arg1, arg2, arg3);
  1563. +   fprintf (stderr, "\n");
  1564. +   exit(1);
  1565. + }
  1566. + char * xmalloc (size)
  1567. +      long size;
  1568. + {
  1569. +   register char *val = (char *) malloc (size);
  1570. +   if (!val)
  1571. +     error ("virtual memory exhausted.");
  1572. +   return val;
  1573. + }
  1574. + char *savestring (ptr, size)
  1575. +      char *ptr;
  1576. +      int size;
  1577. + {
  1578. +   register char *p = (char *) xmalloc (size + 1);
  1579. +   memcpy(p, ptr, size);
  1580. +   p[size] = 0;
  1581. +   return p;
  1582. + }
  1583. + #endif /* TEST */
  1584. *** gdbspace.asm
  1585. --- gdbspace.asm    Thu Aug 22 20:27:38 1991
  1586. ***************
  1587. *** 0 ****
  1588. --- 1,14 ----
  1589. + ; GDB likes to poke calling sequences beyond _end -- in the padding
  1590. + ; space up to the end of the page.
  1591. + ; But XENIX doesn't let it use this space, so we have to add the space
  1592. + ; manually.  Assemble and install this file with the command
  1593. + ;    /usr/lib/storel gdbspace.asm && mv gdbspace.o /usr/local/lib/libgdb.a
  1594. + ; and use it by specifying -lgdb when you're debugging.
  1595. + ; e.g. gcc -g foo.c -o foo -lgdb
  1596. + ; This will enable you to do things like call functions from within gdb
  1597. +     .386
  1598. + C_ETEXT    SEGMENT DWORD USE32 PUBLIC 'ENDCODE'
  1599. +     PUBLIC    SPACE_FOR_GDB_TO_USE
  1600. + SPACE_FOR_GDB_TO_USE    DB    512    DUP    (0)
  1601. + C_ETEXT ENDS
  1602. +     END
  1603. -- 
  1604. Steve.Bleazard@RoboBar.Co.Uk        | Phone:  +44 81 991 1142 x153
  1605. Snr Software Engineer, Robobar Ltd. | Fax:    +44 81 998 8343 (G3)
  1606. 22 Wadsworth Road, Perivale.        |
  1607. Middx., UB6 7JD ENGLAND.            | ...!ukc!robobar!steve
  1608.