home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / xenix-gnu / part02 / gdb-3.5b.pch
Encoding:
Text File  |  1991-09-27  |  45.5 KB  |  1,685 lines

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