1 // OBSOLETE /* Read os9/os9k symbol tables and convert to internal format, for GDB.
2 // OBSOLETE Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 // OBSOLETE 1996, 1997, 1998, 1999, 2000, 2001
4 // OBSOLETE Free Software Foundation, Inc.
6 // OBSOLETE This file is part of GDB.
8 // OBSOLETE This program is free software; you can redistribute it and/or modify
9 // OBSOLETE it under the terms of the GNU General Public License as published by
10 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
11 // OBSOLETE (at your option) any later version.
13 // OBSOLETE This program is distributed in the hope that it will be useful,
14 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // OBSOLETE GNU General Public License for more details.
18 // OBSOLETE You should have received a copy of the GNU General Public License
19 // OBSOLETE along with this program; if not, write to the Free Software
20 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
21 // OBSOLETE Boston, MA 02111-1307, USA. */
23 // OBSOLETE /* This module provides three functions: os9k_symfile_init,
24 // OBSOLETE which initializes to read a symbol file; os9k_new_init, which
25 // OBSOLETE discards existing cached information when all symbols are being
26 // OBSOLETE discarded; and os9k_symfile_read, which reads a symbol table
27 // OBSOLETE from a file.
29 // OBSOLETE os9k_symfile_read only does the minimum work necessary for letting the
30 // OBSOLETE user "name" things symbolically; it does not read the entire symtab.
31 // OBSOLETE Instead, it reads the external and static symbols and puts them in partial
32 // OBSOLETE symbol tables. When more extensive information is requested of a
33 // OBSOLETE file, the corresponding partial symbol table is mutated into a full
34 // OBSOLETE fledged symbol table by going back and reading the symbols
35 // OBSOLETE for real. os9k_psymtab_to_symtab() is the function that does this */
37 // OBSOLETE #include "defs.h"
38 // OBSOLETE #include "gdb_string.h"
39 // OBSOLETE #include "gdb_assert.h"
40 // OBSOLETE #include <stdio.h>
42 // OBSOLETE #if defined(USG) || defined(__CYGNUSCLIB__)
43 // OBSOLETE #include <sys/types.h>
44 // OBSOLETE #include <fcntl.h>
47 // OBSOLETE #include "obstack.h"
48 // OBSOLETE #include "gdb_stat.h"
49 // OBSOLETE #include "symtab.h"
50 // OBSOLETE #include "breakpoint.h"
51 // OBSOLETE #include "command.h"
52 // OBSOLETE #include "target.h"
53 // OBSOLETE #include "gdbcore.h" /* for bfd stuff */
54 // OBSOLETE #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
55 // OBSOLETE #include "symfile.h"
56 // OBSOLETE #include "objfiles.h"
57 // OBSOLETE #include "buildsym.h"
58 // OBSOLETE #include "gdb-stabs.h"
59 // OBSOLETE #include "demangle.h"
60 // OBSOLETE #include "language.h" /* Needed inside partial-stab.h */
61 // OBSOLETE #include "complaints.h"
62 // OBSOLETE #include "os9k.h"
63 // OBSOLETE #include "stabsread.h"
65 // OBSOLETE extern void _initialize_os9kread (void);
67 // OBSOLETE /* Each partial symbol table entry contains a pointer to private data for the
68 // OBSOLETE read_symtab() function to use when expanding a partial symbol table entry
69 // OBSOLETE to a full symbol table entry.
71 // OBSOLETE For dbxread this structure contains the offset within the file symbol table
72 // OBSOLETE of first local symbol for this file, and count of the section
73 // OBSOLETE of the symbol table devoted to this file's symbols (actually, the section
74 // OBSOLETE bracketed may contain more than just this file's symbols). It also contains
75 // OBSOLETE further information needed to locate the symbols if they are in an ELF file.
77 // OBSOLETE If ldsymcnt is 0, the only reason for this thing's existence is the
78 // OBSOLETE dependency list. Nothing else will happen when it is read in. */
80 // OBSOLETE #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
81 // OBSOLETE #define LDSYMCNT(p) (((struct symloc *)((p)->read_symtab_private))->ldsymnum)
83 // OBSOLETE struct symloc
85 // OBSOLETE int ldsymoff;
86 // OBSOLETE int ldsymnum;
89 // OBSOLETE /* Remember what we deduced to be the source language of this psymtab. */
90 // OBSOLETE static enum language psymtab_language = language_unknown;
92 // OBSOLETE /* keep partial symbol table file nested depth */
93 // OBSOLETE static int psymfile_depth = 0;
95 // OBSOLETE /* keep symbol table file nested depth */
96 // OBSOLETE static int symfile_depth = 0;
98 // OBSOLETE extern int previous_stab_code;
100 // OBSOLETE /* Name of last function encountered. Used in Solaris to approximate
101 // OBSOLETE object file boundaries. */
102 // OBSOLETE static char *last_function_name;
104 // OBSOLETE /* Complaints about the symbols we have encountered. */
105 // OBSOLETE extern struct complaint lbrac_complaint;
107 // OBSOLETE extern struct complaint unknown_symtype_complaint;
109 // OBSOLETE extern struct complaint unknown_symchar_complaint;
111 // OBSOLETE extern struct complaint lbrac_rbrac_complaint;
113 // OBSOLETE extern struct complaint repeated_header_complaint;
115 // OBSOLETE extern struct complaint repeated_header_name_complaint;
118 // OBSOLETE static struct complaint lbrac_unmatched_complaint =
119 // OBSOLETE {"unmatched Increment Block Entry before symtab pos %d", 0, 0};
121 // OBSOLETE static struct complaint lbrac_mismatch_complaint =
122 // OBSOLETE {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
125 // OBSOLETE /* Local function prototypes */
127 // OBSOLETE static void read_minimal_symbols (struct objfile *);
129 // OBSOLETE static void os9k_read_ofile_symtab (struct partial_symtab *);
131 // OBSOLETE static void os9k_psymtab_to_symtab (struct partial_symtab *);
133 // OBSOLETE static void os9k_psymtab_to_symtab_1 (struct partial_symtab *);
135 // OBSOLETE static void read_os9k_psymtab (struct objfile *, CORE_ADDR, int);
137 // OBSOLETE static int fill_sym (FILE *, bfd *);
139 // OBSOLETE static void os9k_symfile_init (struct objfile *);
141 // OBSOLETE static void os9k_new_init (struct objfile *);
143 // OBSOLETE static void os9k_symfile_read (struct objfile *, int);
145 // OBSOLETE static void os9k_symfile_finish (struct objfile *);
147 // OBSOLETE static void os9k_process_one_symbol (int, int, CORE_ADDR, char *,
148 // OBSOLETE struct section_offsets *,
149 // OBSOLETE struct objfile *);
151 // OBSOLETE static struct partial_symtab *os9k_start_psymtab (struct objfile *, char *,
152 // OBSOLETE CORE_ADDR, int, int,
153 // OBSOLETE struct partial_symbol **,
154 // OBSOLETE struct partial_symbol **);
156 // OBSOLETE static struct partial_symtab *os9k_end_psymtab (struct partial_symtab *,
157 // OBSOLETE char **, int, int, CORE_ADDR,
158 // OBSOLETE struct partial_symtab **,
161 // OBSOLETE static void record_minimal_symbol (char *, CORE_ADDR, int, struct objfile *);
163 // OBSOLETE #define HANDLE_RBRAC(val) \
164 // OBSOLETE if ((val) > pst->texthigh) pst->texthigh = (val);
166 // OBSOLETE #define SWAP_STBHDR(hdrp, abfd) \
168 // OBSOLETE (hdrp)->fmtno = bfd_get_16(abfd, (unsigned char *)&(hdrp)->fmtno); \
169 // OBSOLETE (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
170 // OBSOLETE (hdrp)->offset = bfd_get_32(abfd, (unsigned char *)&(hdrp)->offset); \
171 // OBSOLETE (hdrp)->nsym = bfd_get_32(abfd, (unsigned char *)&(hdrp)->nsym); \
173 // OBSOLETE #define SWAP_STBSYM(symp, abfd) \
175 // OBSOLETE (symp)->value = bfd_get_32(abfd, (unsigned char *)&(symp)->value); \
176 // OBSOLETE (symp)->type = bfd_get_16(abfd, (unsigned char *)&(symp)->type); \
177 // OBSOLETE (symp)->stroff = bfd_get_32(abfd, (unsigned char *)&(symp)->stroff); \
179 // OBSOLETE #define N_DATA 0
180 // OBSOLETE #define N_BSS 1
181 // OBSOLETE #define N_RDATA 2
182 // OBSOLETE #define N_IDATA 3
183 // OBSOLETE #define N_TEXT 4
184 // OBSOLETE #define N_ABS 6
186 // OBSOLETE static void
187 // OBSOLETE record_minimal_symbol (char *name, CORE_ADDR address, int type,
188 // OBSOLETE struct objfile *objfile)
190 // OBSOLETE enum minimal_symbol_type ms_type;
192 // OBSOLETE switch (type)
194 // OBSOLETE case N_TEXT:
195 // OBSOLETE ms_type = mst_text;
196 // OBSOLETE address += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
198 // OBSOLETE case N_DATA:
199 // OBSOLETE ms_type = mst_data;
201 // OBSOLETE case N_BSS:
202 // OBSOLETE ms_type = mst_bss;
204 // OBSOLETE case N_RDATA:
205 // OBSOLETE ms_type = mst_bss;
207 // OBSOLETE case N_IDATA:
208 // OBSOLETE ms_type = mst_data;
210 // OBSOLETE case N_ABS:
211 // OBSOLETE ms_type = mst_abs;
214 // OBSOLETE ms_type = mst_unknown;
218 // OBSOLETE prim_record_minimal_symbol (name, address, ms_type, objfile);
221 // OBSOLETE /* read and process .stb file and store in minimal symbol table */
222 // OBSOLETE typedef char mhhdr[80];
223 // OBSOLETE struct stbhdr
225 // OBSOLETE mhhdr comhdr;
226 // OBSOLETE char *name;
227 // OBSOLETE short fmtno;
229 // OBSOLETE int offset;
230 // OBSOLETE int nsym;
231 // OBSOLETE char *pad;
233 // OBSOLETE struct stbsymbol
235 // OBSOLETE int value;
236 // OBSOLETE short type;
237 // OBSOLETE int stroff;
239 // OBSOLETE #define STBSYMSIZE 10
241 // OBSOLETE static void
242 // OBSOLETE read_minimal_symbols (struct objfile *objfile)
244 // OBSOLETE FILE *fp;
245 // OBSOLETE bfd *abfd;
246 // OBSOLETE struct stbhdr hdr;
247 // OBSOLETE struct stbsymbol sym;
248 // OBSOLETE int ch, i, j, off;
249 // OBSOLETE char buf[64], buf1[128];
251 // OBSOLETE fp = objfile->auxf1;
252 // OBSOLETE if (fp == NULL)
254 // OBSOLETE abfd = objfile->obfd;
255 // OBSOLETE fread (&hdr.comhdr[0], sizeof (mhhdr), 1, fp);
257 // OBSOLETE ch = getc (fp);
258 // OBSOLETE while (ch != -1)
260 // OBSOLETE buf[i] = (char) ch;
262 // OBSOLETE if (ch == 0)
264 // OBSOLETE ch = getc (fp);
266 // OBSOLETE if (i % 2)
267 // OBSOLETE ch = getc (fp);
268 // OBSOLETE hdr.name = &buf[0];
270 // OBSOLETE fread (&hdr.fmtno, sizeof (hdr.fmtno), 1, fp);
271 // OBSOLETE fread (&hdr.crc, sizeof (hdr.crc), 1, fp);
272 // OBSOLETE fread (&hdr.offset, sizeof (hdr.offset), 1, fp);
273 // OBSOLETE fread (&hdr.nsym, sizeof (hdr.nsym), 1, fp);
274 // OBSOLETE SWAP_STBHDR (&hdr, abfd);
276 // OBSOLETE /* read symbols */
277 // OBSOLETE init_minimal_symbol_collection ();
278 // OBSOLETE off = hdr.offset;
279 // OBSOLETE for (i = hdr.nsym; i > 0; i--)
281 // OBSOLETE fseek (fp, (long) off, 0);
282 // OBSOLETE fread (&sym.value, sizeof (sym.value), 1, fp);
283 // OBSOLETE fread (&sym.type, sizeof (sym.type), 1, fp);
284 // OBSOLETE fread (&sym.stroff, sizeof (sym.stroff), 1, fp);
285 // OBSOLETE SWAP_STBSYM (&sym, abfd);
286 // OBSOLETE fseek (fp, (long) sym.stroff, 0);
288 // OBSOLETE ch = getc (fp);
289 // OBSOLETE while (ch != -1)
291 // OBSOLETE buf1[j] = (char) ch;
293 // OBSOLETE if (ch == 0)
295 // OBSOLETE ch = getc (fp);
297 // OBSOLETE record_minimal_symbol (buf1, sym.value, sym.type & 7, objfile);
298 // OBSOLETE off += STBSYMSIZE;
300 // OBSOLETE install_minimal_symbols (objfile);
304 // OBSOLETE /* Scan and build partial symbols for a symbol file.
305 // OBSOLETE We have been initialized by a call to os9k_symfile_init, which
306 // OBSOLETE put all the relevant info into a "struct os9k_symfile_info",
307 // OBSOLETE hung off the objfile structure.
309 // OBSOLETE MAINLINE is true if we are reading the main symbol
310 // OBSOLETE table (as opposed to a shared lib or dynamically loaded file). */
312 // OBSOLETE static void
313 // OBSOLETE os9k_symfile_read (struct objfile *objfile, int mainline)
315 // OBSOLETE bfd *sym_bfd;
316 // OBSOLETE struct cleanup *back_to;
318 // OBSOLETE sym_bfd = objfile->obfd;
319 // OBSOLETE /* If we are reinitializing, or if we have never loaded syms yet, init */
320 // OBSOLETE if (mainline
321 // OBSOLETE || (objfile->global_psymbols.size == 0
322 // OBSOLETE && objfile->static_psymbols.size == 0))
323 // OBSOLETE init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
325 // OBSOLETE free_pending_blocks ();
326 // OBSOLETE back_to = make_cleanup (really_free_pendings, 0);
328 // OBSOLETE make_cleanup_discard_minimal_symbols ();
329 // OBSOLETE read_minimal_symbols (objfile);
331 // OBSOLETE /* Now that the symbol table data of the executable file are all in core,
332 // OBSOLETE process them and define symbols accordingly. */
333 // OBSOLETE read_os9k_psymtab (objfile,
334 // OBSOLETE DBX_TEXT_ADDR (objfile),
335 // OBSOLETE DBX_TEXT_SIZE (objfile));
337 // OBSOLETE do_cleanups (back_to);
340 // OBSOLETE /* Initialize anything that needs initializing when a completely new
341 // OBSOLETE symbol file is specified (not just adding some symbols from another
342 // OBSOLETE file, e.g. a shared library). */
344 // OBSOLETE static void
345 // OBSOLETE os9k_new_init (struct objfile *ignore)
347 // OBSOLETE stabsread_new_init ();
348 // OBSOLETE buildsym_new_init ();
349 // OBSOLETE psymfile_depth = 0;
351 // OBSOLETE init_header_files ();
355 // OBSOLETE /* os9k_symfile_init ()
356 // OBSOLETE It is passed a struct objfile which contains, among other things,
357 // OBSOLETE the BFD for the file whose symbols are being read, and a slot for a pointer
358 // OBSOLETE to "private data" which we fill with goodies.
360 // OBSOLETE Since BFD doesn't know how to read debug symbols in a format-independent
361 // OBSOLETE way (and may never do so...), we have to do it ourselves. We will never
362 // OBSOLETE be called unless this is an a.out (or very similar) file.
363 // OBSOLETE FIXME, there should be a cleaner peephole into the BFD environment here. */
365 // OBSOLETE static void
366 // OBSOLETE os9k_symfile_init (struct objfile *objfile)
368 // OBSOLETE bfd *sym_bfd = objfile->obfd;
369 // OBSOLETE char *name = bfd_get_filename (sym_bfd);
370 // OBSOLETE char dbgname[512], stbname[512];
371 // OBSOLETE FILE *symfile = 0;
372 // OBSOLETE FILE *minfile = 0;
373 // OBSOLETE asection *text_sect;
375 // OBSOLETE strcpy (dbgname, name);
376 // OBSOLETE strcat (dbgname, ".dbg");
377 // OBSOLETE strcpy (stbname, name);
378 // OBSOLETE strcat (stbname, ".stb");
380 // OBSOLETE if ((symfile = fopen (dbgname, "r")) == NULL)
382 // OBSOLETE warning ("Symbol file %s not found", dbgname);
384 // OBSOLETE objfile->auxf2 = symfile;
386 // OBSOLETE if ((minfile = fopen (stbname, "r")) == NULL)
388 // OBSOLETE warning ("Symbol file %s not found", stbname);
390 // OBSOLETE objfile->auxf1 = minfile;
392 // OBSOLETE /* Allocate struct to keep track of the symfile */
393 // OBSOLETE objfile->sym_stab_info = (struct dbx_symfile_info *)
394 // OBSOLETE xmmalloc (objfile->md, sizeof (struct dbx_symfile_info));
395 // OBSOLETE DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;
397 // OBSOLETE text_sect = bfd_get_section_by_name (sym_bfd, ".text");
398 // OBSOLETE if (!text_sect)
399 // OBSOLETE error ("Can't find .text section in file");
400 // OBSOLETE DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect);
401 // OBSOLETE DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect);
403 // OBSOLETE DBX_SYMBOL_SIZE (objfile) = 0; /* variable size symbol */
404 // OBSOLETE DBX_SYMCOUNT (objfile) = 0; /* used to be bfd_get_symcount(sym_bfd) */
405 // OBSOLETE DBX_SYMTAB_OFFSET (objfile) = 0; /* used to be SYMBOL_TABLE_OFFSET */
408 // OBSOLETE /* Perform any local cleanups required when we are done with a particular
409 // OBSOLETE objfile. I.E, we are in the process of discarding all symbol information
410 // OBSOLETE for an objfile, freeing up all memory held for it, and unlinking the
411 // OBSOLETE objfile struct from the global list of known objfiles. */
413 // OBSOLETE static void
414 // OBSOLETE os9k_symfile_finish (struct objfile *objfile)
416 // OBSOLETE if (objfile->sym_stab_info != NULL)
418 // OBSOLETE xmfree (objfile->md, objfile->sym_stab_info);
421 // OBSOLETE free_header_files ();
426 // OBSOLETE struct st_dbghdr
428 // OBSOLETE int sync;
429 // OBSOLETE short rev;
431 // OBSOLETE short os;
432 // OBSOLETE short cpu;
434 // OBSOLETE #define SYNC (int)0xefbefeca
436 // OBSOLETE #define SWAP_DBGHDR(hdrp, abfd) \
438 // OBSOLETE (hdrp)->sync = bfd_get_32(abfd, (unsigned char *)&(hdrp)->sync); \
439 // OBSOLETE (hdrp)->rev = bfd_get_16(abfd, (unsigned char *)&(hdrp)->rev); \
440 // OBSOLETE (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
441 // OBSOLETE (hdrp)->os = bfd_get_16(abfd, (unsigned char *)&(hdrp)->os); \
442 // OBSOLETE (hdrp)->cpu = bfd_get_16(abfd, (unsigned char *)&(hdrp)->cpu); \
445 // OBSOLETE #define N_SYM_CMPLR 0
446 // OBSOLETE #define N_SYM_SLINE 1
447 // OBSOLETE #define N_SYM_SYM 2
448 // OBSOLETE #define N_SYM_LBRAC 3
449 // OBSOLETE #define N_SYM_RBRAC 4
450 // OBSOLETE #define N_SYM_SE 5
452 // OBSOLETE struct internal_symstruct
454 // OBSOLETE short n_type;
455 // OBSOLETE short n_desc;
456 // OBSOLETE long n_value;
457 // OBSOLETE char *n_strx;
459 // OBSOLETE static struct internal_symstruct symbol;
460 // OBSOLETE static struct internal_symstruct *symbuf = &symbol;
461 // OBSOLETE static char strbuf[4096];
462 // OBSOLETE static struct st_dbghdr dbghdr;
463 // OBSOLETE static short cmplrid;
465 // OBSOLETE #define VER_PRE_ULTRAC ((short)4)
466 // OBSOLETE #define VER_ULTRAC ((short)5)
468 // OBSOLETE static int
469 // OBSOLETE fill_sym (FILE *dbg_file, bfd *abfd)
471 // OBSOLETE short si, nmask;
476 // OBSOLETE int nbytes = fread (&si, sizeof (si), 1, dbg_file);
477 // OBSOLETE if (nbytes == 0)
478 // OBSOLETE return 0;
479 // OBSOLETE if (nbytes < 0)
480 // OBSOLETE perror_with_name ("reading .dbg file.");
481 // OBSOLETE symbuf->n_desc = 0;
482 // OBSOLETE symbuf->n_value = 0;
483 // OBSOLETE symbuf->n_strx = NULL;
484 // OBSOLETE symbuf->n_type = bfd_get_16 (abfd, (unsigned char *) &si);
485 // OBSOLETE symbuf->n_type = 0xf & symbuf->n_type;
486 // OBSOLETE switch (symbuf->n_type)
488 // OBSOLETE case N_SYM_CMPLR:
489 // OBSOLETE fread (&si, sizeof (si), 1, dbg_file);
490 // OBSOLETE symbuf->n_desc = bfd_get_16 (abfd, (unsigned char *) &si);
491 // OBSOLETE cmplrid = symbuf->n_desc & 0xff;
493 // OBSOLETE case N_SYM_SLINE:
494 // OBSOLETE fread (&li, sizeof (li), 1, dbg_file);
495 // OBSOLETE symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
496 // OBSOLETE fread (&li, sizeof (li), 1, dbg_file);
497 // OBSOLETE li = bfd_get_32 (abfd, (unsigned char *) &li);
498 // OBSOLETE symbuf->n_strx = (char *) (li >> 12);
499 // OBSOLETE symbuf->n_desc = li & 0xfff;
501 // OBSOLETE case N_SYM_SYM:
502 // OBSOLETE fread (&li, sizeof (li), 1, dbg_file);
503 // OBSOLETE symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
507 // OBSOLETE ii = getc (dbg_file);
508 // OBSOLETE strbuf[si++] = (char) ii;
510 // OBSOLETE while (ii != 0 || si % 2 != 0);
511 // OBSOLETE symbuf->n_strx = strbuf;
512 // OBSOLETE p = (char *) strchr (strbuf, ':');
515 // OBSOLETE if ((p[1] == 'F' || p[1] == 'f') && cmplrid == VER_PRE_ULTRAC)
517 // OBSOLETE fread (&si, sizeof (si), 1, dbg_file);
518 // OBSOLETE nmask = bfd_get_16 (abfd, (unsigned char *) &si);
519 // OBSOLETE for (ii = 0; ii < nmask; ii++)
520 // OBSOLETE fread (&si, sizeof (si), 1, dbg_file);
523 // OBSOLETE case N_SYM_LBRAC:
524 // OBSOLETE fread (&li, sizeof (li), 1, dbg_file);
525 // OBSOLETE symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
527 // OBSOLETE case N_SYM_RBRAC:
528 // OBSOLETE fread (&li, sizeof (li), 1, dbg_file);
529 // OBSOLETE symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li);
531 // OBSOLETE case N_SYM_SE:
534 // OBSOLETE return 1;
537 // OBSOLETE /* Given pointers to an a.out symbol table in core containing dbx
538 // OBSOLETE style data, setup partial_symtab's describing each source file for
539 // OBSOLETE which debugging information is available.
540 // OBSOLETE SYMFILE_NAME is the name of the file we are reading from. */
542 // OBSOLETE static void
543 // OBSOLETE read_os9k_psymtab (struct objfile *objfile, CORE_ADDR text_addr, int text_size)
545 // OBSOLETE register struct internal_symstruct *bufp = 0; /* =0 avoids gcc -Wall glitch */
546 // OBSOLETE register char *namestring;
547 // OBSOLETE int past_first_source_file = 0;
548 // OBSOLETE CORE_ADDR last_o_file_start = 0;
550 // OBSOLETE struct cleanup *back_to;
552 // OBSOLETE bfd *abfd;
553 // OBSOLETE FILE *fp;
555 // OBSOLETE /* End of the text segment of the executable file. */
556 // OBSOLETE static CORE_ADDR end_of_text_addr;
558 // OBSOLETE /* Current partial symtab */
559 // OBSOLETE static struct partial_symtab *pst = 0;
561 // OBSOLETE /* List of current psymtab's include files */
562 // OBSOLETE char **psymtab_include_list;
563 // OBSOLETE int includes_allocated;
564 // OBSOLETE int includes_used;
566 // OBSOLETE /* Index within current psymtab dependency list */
567 // OBSOLETE struct partial_symtab **dependency_list;
568 // OBSOLETE int dependencies_used, dependencies_allocated;
570 // OBSOLETE includes_allocated = 30;
571 // OBSOLETE includes_used = 0;
572 // OBSOLETE psymtab_include_list = (char **) alloca (includes_allocated *
573 // OBSOLETE sizeof (char *));
575 // OBSOLETE dependencies_allocated = 30;
576 // OBSOLETE dependencies_used = 0;
577 // OBSOLETE dependency_list =
578 // OBSOLETE (struct partial_symtab **) alloca (dependencies_allocated *
579 // OBSOLETE sizeof (struct partial_symtab *));
581 // OBSOLETE last_source_file = NULL;
583 // OBSOLETE #ifdef END_OF_TEXT_DEFAULT
584 // OBSOLETE end_of_text_addr = END_OF_TEXT_DEFAULT;
586 // OBSOLETE end_of_text_addr = text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))
587 // OBSOLETE + text_size; /* Relocate */
590 // OBSOLETE abfd = objfile->obfd;
591 // OBSOLETE fp = objfile->auxf2;
595 // OBSOLETE fread (&dbghdr.sync, sizeof (dbghdr.sync), 1, fp);
596 // OBSOLETE fread (&dbghdr.rev, sizeof (dbghdr.rev), 1, fp);
597 // OBSOLETE fread (&dbghdr.crc, sizeof (dbghdr.crc), 1, fp);
598 // OBSOLETE fread (&dbghdr.os, sizeof (dbghdr.os), 1, fp);
599 // OBSOLETE fread (&dbghdr.cpu, sizeof (dbghdr.cpu), 1, fp);
600 // OBSOLETE SWAP_DBGHDR (&dbghdr, abfd);
602 // OBSOLETE symnum = 0;
603 // OBSOLETE while (1)
606 // OBSOLETE long cursymoffset;
608 // OBSOLETE /* Get the symbol for this run and pull out some info */
609 // OBSOLETE QUIT; /* allow this to be interruptable */
610 // OBSOLETE cursymoffset = ftell (objfile->auxf2);
611 // OBSOLETE ret = fill_sym (objfile->auxf2, abfd);
612 // OBSOLETE if (ret <= 0)
615 // OBSOLETE symnum++;
616 // OBSOLETE bufp = symbuf;
618 // OBSOLETE /* Special case to speed up readin. */
619 // OBSOLETE if (bufp->n_type == (short) N_SYM_SLINE)
620 // OBSOLETE continue;
622 // OBSOLETE #define CUR_SYMBOL_VALUE bufp->n_value
623 // OBSOLETE /* partial-stab.h */
625 // OBSOLETE switch (bufp->n_type)
629 // OBSOLETE case N_SYM_CMPLR:
630 // OBSOLETE continue;
632 // OBSOLETE case N_SYM_SE:
633 // OBSOLETE CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
634 // OBSOLETE if (psymfile_depth == 1 && pst)
636 // OBSOLETE os9k_end_psymtab (pst, psymtab_include_list, includes_used,
637 // OBSOLETE symnum, CUR_SYMBOL_VALUE,
638 // OBSOLETE dependency_list, dependencies_used);
639 // OBSOLETE pst = (struct partial_symtab *) 0;
640 // OBSOLETE includes_used = 0;
641 // OBSOLETE dependencies_used = 0;
643 // OBSOLETE psymfile_depth--;
644 // OBSOLETE continue;
646 // OBSOLETE case N_SYM_SYM: /* Typedef or automatic variable. */
647 // OBSOLETE namestring = bufp->n_strx;
648 // OBSOLETE p = (char *) strchr (namestring, ':');
650 // OBSOLETE continue; /* Not a debugging symbol. */
652 // OBSOLETE /* Main processing section for debugging symbols which
653 // OBSOLETE the initial read through the symbol tables needs to worry
654 // OBSOLETE about. If we reach this point, the symbol which we are
655 // OBSOLETE considering is definitely one we are interested in.
656 // OBSOLETE p must also contain the (valid) index into the namestring
657 // OBSOLETE which indicates the debugging type symbol. */
659 // OBSOLETE switch (p[1])
661 // OBSOLETE case 'S':
663 // OBSOLETE unsigned long valu;
664 // OBSOLETE enum language tmp_language;
665 // OBSOLETE char *str, *p;
668 // OBSOLETE valu = CUR_SYMBOL_VALUE;
669 // OBSOLETE if (valu)
670 // OBSOLETE valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
671 // OBSOLETE past_first_source_file = 1;
673 // OBSOLETE p = strchr (namestring, ':');
675 // OBSOLETE n = p - namestring;
677 // OBSOLETE n = strlen (namestring);
678 // OBSOLETE str = alloca (n + 1);
679 // OBSOLETE strncpy (str, namestring, n);
680 // OBSOLETE str[n] = '\0';
682 // OBSOLETE if (psymfile_depth == 0)
684 // OBSOLETE if (!pst)
685 // OBSOLETE pst = os9k_start_psymtab (objfile,
686 // OBSOLETE str, valu,
687 // OBSOLETE cursymoffset,
688 // OBSOLETE symnum - 1,
689 // OBSOLETE objfile->global_psymbols.next,
690 // OBSOLETE objfile->static_psymbols.next);
693 // OBSOLETE { /* this is a include file */
694 // OBSOLETE tmp_language = deduce_language_from_filename (str);
695 // OBSOLETE if (tmp_language != language_unknown
696 // OBSOLETE && (tmp_language != language_c
697 // OBSOLETE || psymtab_language != language_cplus))
698 // OBSOLETE psymtab_language = tmp_language;
701 // OBSOLETE if (pst && STREQ (str, pst->filename))
702 // OBSOLETE continue;
704 // OBSOLETE register int i;
705 // OBSOLETE for (i = 0; i < includes_used; i++)
706 // OBSOLETE if (STREQ (str, psymtab_include_list[i]))
711 // OBSOLETE if (i == -1)
712 // OBSOLETE continue;
716 // OBSOLETE psymtab_include_list[includes_used++] = str;
717 // OBSOLETE if (includes_used >= includes_allocated)
719 // OBSOLETE char **orig = psymtab_include_list;
721 // OBSOLETE psymtab_include_list = (char **)
722 // OBSOLETE alloca ((includes_allocated *= 2) * sizeof (char *));
723 // OBSOLETE memcpy ((PTR) psymtab_include_list, (PTR) orig,
724 // OBSOLETE includes_used * sizeof (char *));
728 // OBSOLETE psymfile_depth++;
729 // OBSOLETE continue;
732 // OBSOLETE case 'v':
733 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
734 // OBSOLETE VAR_NAMESPACE, LOC_STATIC,
735 // OBSOLETE &objfile->static_psymbols,
736 // OBSOLETE 0, CUR_SYMBOL_VALUE,
737 // OBSOLETE psymtab_language, objfile);
738 // OBSOLETE continue;
739 // OBSOLETE case 'V':
740 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
741 // OBSOLETE VAR_NAMESPACE, LOC_STATIC,
742 // OBSOLETE &objfile->global_psymbols,
743 // OBSOLETE 0, CUR_SYMBOL_VALUE,
744 // OBSOLETE psymtab_language, objfile);
745 // OBSOLETE continue;
747 // OBSOLETE case 'T':
748 // OBSOLETE if (p != namestring) /* a name is there, not just :T... */
750 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
751 // OBSOLETE STRUCT_NAMESPACE, LOC_TYPEDEF,
752 // OBSOLETE &objfile->static_psymbols,
753 // OBSOLETE CUR_SYMBOL_VALUE, 0,
754 // OBSOLETE psymtab_language, objfile);
755 // OBSOLETE if (p[2] == 't')
757 // OBSOLETE /* Also a typedef with the same name. */
758 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
759 // OBSOLETE VAR_NAMESPACE, LOC_TYPEDEF,
760 // OBSOLETE &objfile->static_psymbols,
761 // OBSOLETE CUR_SYMBOL_VALUE, 0, psymtab_language,
762 // OBSOLETE objfile);
765 // OBSOLETE /* The semantics of C++ state that "struct foo { ... }"
766 // OBSOLETE also defines a typedef for "foo". Unfortuantely, cfront
767 // OBSOLETE never makes the typedef when translating from C++ to C.
768 // OBSOLETE We make the typedef here so that "ptype foo" works as
769 // OBSOLETE expected for cfront translated code. */
770 // OBSOLETE else if (psymtab_language == language_cplus)
772 // OBSOLETE /* Also a typedef with the same name. */
773 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
774 // OBSOLETE VAR_NAMESPACE, LOC_TYPEDEF,
775 // OBSOLETE &objfile->static_psymbols,
776 // OBSOLETE CUR_SYMBOL_VALUE, 0, psymtab_language,
777 // OBSOLETE objfile);
780 // OBSOLETE goto check_enum;
781 // OBSOLETE case 't':
782 // OBSOLETE if (p != namestring) /* a name is there, not just :T... */
784 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
785 // OBSOLETE VAR_NAMESPACE, LOC_TYPEDEF,
786 // OBSOLETE &objfile->static_psymbols,
787 // OBSOLETE CUR_SYMBOL_VALUE, 0,
788 // OBSOLETE psymtab_language, objfile);
790 // OBSOLETE check_enum:
791 // OBSOLETE /* If this is an enumerated type, we need to
792 // OBSOLETE add all the enum constants to the partial symbol
793 // OBSOLETE table. This does not cover enums without names, e.g.
794 // OBSOLETE "enum {a, b} c;" in C, but fortunately those are
795 // OBSOLETE rare. There is no way for GDB to find those from the
796 // OBSOLETE enum type without spending too much time on it. Thus
797 // OBSOLETE to solve this problem, the compiler needs to put out the
798 // OBSOLETE enum in a nameless type. GCC2 does this. */
800 // OBSOLETE /* We are looking for something of the form
801 // OBSOLETE <name> ":" ("t" | "T") [<number> "="] "e" <size>
802 // OBSOLETE {<constant> ":" <value> ","} ";". */
804 // OBSOLETE /* Skip over the colon and the 't' or 'T'. */
806 // OBSOLETE /* This type may be given a number. Also, numbers can come
807 // OBSOLETE in pairs like (0,26). Skip over it. */
808 // OBSOLETE while ((*p >= '0' && *p <= '9')
809 // OBSOLETE || *p == '(' || *p == ',' || *p == ')'
810 // OBSOLETE || *p == '=')
813 // OBSOLETE if (*p++ == 'e')
815 // OBSOLETE /* We have found an enumerated type. skip size */
816 // OBSOLETE while (*p >= '0' && *p <= '9')
818 // OBSOLETE /* According to comments in read_enum_type
819 // OBSOLETE a comma could end it instead of a semicolon.
820 // OBSOLETE I don't know where that happens.
821 // OBSOLETE Accept either. */
822 // OBSOLETE while (*p && *p != ';' && *p != ',')
826 // OBSOLETE /* Check for and handle cretinous dbx symbol name
827 // OBSOLETE continuation!
828 // OBSOLETE if (*p == '\\')
829 // OBSOLETE p = next_symbol_text (objfile);
832 // OBSOLETE /* Point to the character after the name
833 // OBSOLETE of the enum constant. */
834 // OBSOLETE for (q = p; *q && *q != ':'; q++)
836 // OBSOLETE /* Note that the value doesn't matter for
837 // OBSOLETE enum constants in psymtabs, just in symtabs. */
838 // OBSOLETE add_psymbol_to_list (p, q - p,
839 // OBSOLETE VAR_NAMESPACE, LOC_CONST,
840 // OBSOLETE &objfile->static_psymbols, 0,
841 // OBSOLETE 0, psymtab_language, objfile);
842 // OBSOLETE /* Point past the name. */
844 // OBSOLETE /* Skip over the value. */
845 // OBSOLETE while (*p && *p != ',')
847 // OBSOLETE /* Advance past the comma. */
852 // OBSOLETE continue;
853 // OBSOLETE case 'c':
854 // OBSOLETE /* Constant, e.g. from "const" in Pascal. */
855 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
856 // OBSOLETE VAR_NAMESPACE, LOC_CONST,
857 // OBSOLETE &objfile->static_psymbols, CUR_SYMBOL_VALUE,
858 // OBSOLETE 0, psymtab_language, objfile);
859 // OBSOLETE continue;
861 // OBSOLETE case 'f':
862 // OBSOLETE CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
863 // OBSOLETE if (pst && pst->textlow == 0)
864 // OBSOLETE pst->textlow = CUR_SYMBOL_VALUE;
866 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
867 // OBSOLETE VAR_NAMESPACE, LOC_BLOCK,
868 // OBSOLETE &objfile->static_psymbols, CUR_SYMBOL_VALUE,
869 // OBSOLETE 0, psymtab_language, objfile);
870 // OBSOLETE continue;
872 // OBSOLETE case 'F':
873 // OBSOLETE CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
874 // OBSOLETE if (pst && pst->textlow == 0)
875 // OBSOLETE pst->textlow = CUR_SYMBOL_VALUE;
877 // OBSOLETE add_psymbol_to_list (namestring, p - namestring,
878 // OBSOLETE VAR_NAMESPACE, LOC_BLOCK,
879 // OBSOLETE &objfile->global_psymbols, CUR_SYMBOL_VALUE,
880 // OBSOLETE 0, psymtab_language, objfile);
881 // OBSOLETE continue;
883 // OBSOLETE case 'p':
884 // OBSOLETE case 'l':
885 // OBSOLETE case 's':
886 // OBSOLETE continue;
888 // OBSOLETE case ':':
889 // OBSOLETE /* It is a C++ nested symbol. We don't need to record it
890 // OBSOLETE (I don't think); if we try to look up foo::bar::baz,
891 // OBSOLETE then symbols for the symtab containing foo should get
892 // OBSOLETE read in, I think. */
893 // OBSOLETE /* Someone says sun cc puts out symbols like
894 // OBSOLETE /foo/baz/maclib::/usr/local/bin/maclib,
895 // OBSOLETE which would get here with a symbol type of ':'. */
896 // OBSOLETE continue;
899 // OBSOLETE /* Unexpected symbol descriptor. The second and subsequent stabs
900 // OBSOLETE of a continued stab can show up here. The question is
901 // OBSOLETE whether they ever can mimic a normal stab--it would be
902 // OBSOLETE nice if not, since we certainly don't want to spend the
903 // OBSOLETE time searching to the end of every string looking for
904 // OBSOLETE a backslash. */
906 // OBSOLETE complain (&unknown_symchar_complaint, p[1]);
907 // OBSOLETE continue;
910 // OBSOLETE case N_SYM_RBRAC:
911 // OBSOLETE CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
912 // OBSOLETE #ifdef HANDLE_RBRAC
913 // OBSOLETE HANDLE_RBRAC (CUR_SYMBOL_VALUE);
914 // OBSOLETE continue;
916 // OBSOLETE case N_SYM_LBRAC:
917 // OBSOLETE continue;
920 // OBSOLETE /* If we haven't found it yet, ignore it. It's probably some
921 // OBSOLETE new type we don't know about yet. */
922 // OBSOLETE complain (&unknown_symtype_complaint,
923 // OBSOLETE local_hex_string ((unsigned long) bufp->n_type));
924 // OBSOLETE continue;
928 // OBSOLETE DBX_SYMCOUNT (objfile) = symnum;
930 // OBSOLETE /* If there's stuff to be cleaned up, clean it up. */
931 // OBSOLETE if (DBX_SYMCOUNT (objfile) > 0
932 // OBSOLETE /*FIXME, does this have a bug at start address 0? */
933 // OBSOLETE && last_o_file_start
934 // OBSOLETE && objfile->ei.entry_point < bufp->n_value
935 // OBSOLETE && objfile->ei.entry_point >= last_o_file_start)
937 // OBSOLETE objfile->ei.entry_file_lowpc = last_o_file_start;
938 // OBSOLETE objfile->ei.entry_file_highpc = bufp->n_value;
943 // OBSOLETE os9k_end_psymtab (pst, psymtab_include_list, includes_used,
944 // OBSOLETE symnum, end_of_text_addr,
945 // OBSOLETE dependency_list, dependencies_used);
948 // OBSOLETE do_cleanups (back_to);
952 // OBSOLETE /* Allocate and partially fill a partial symtab. It will be
953 // OBSOLETE completely filled at the end of the symbol list.
955 // OBSOLETE SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
956 // OBSOLETE is the address relative to which its symbols are (incremental) or 0
957 // OBSOLETE (normal). */
960 // OBSOLETE static struct partial_symtab *
961 // OBSOLETE os9k_start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow,
962 // OBSOLETE int ldsymoff, int ldsymcnt,
963 // OBSOLETE struct partial_symbol **global_syms,
964 // OBSOLETE struct partial_symbol **static_syms)
966 // OBSOLETE struct partial_symtab *result =
967 // OBSOLETE start_psymtab_common (objfile, objfile->section_offsets,
968 // OBSOLETE filename, textlow, global_syms, static_syms);
970 // OBSOLETE result->read_symtab_private = (char *)
971 // OBSOLETE obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc));
973 // OBSOLETE LDSYMOFF (result) = ldsymoff;
974 // OBSOLETE LDSYMCNT (result) = ldsymcnt;
975 // OBSOLETE result->read_symtab = os9k_psymtab_to_symtab;
977 // OBSOLETE /* Deduce the source language from the filename for this psymtab. */
978 // OBSOLETE psymtab_language = deduce_language_from_filename (filename);
979 // OBSOLETE return result;
982 // OBSOLETE /* Close off the current usage of PST.
983 // OBSOLETE Returns PST or NULL if the partial symtab was empty and thrown away.
984 // OBSOLETE FIXME: List variables and peculiarities of same. */
986 // OBSOLETE static struct partial_symtab *
987 // OBSOLETE os9k_end_psymtab (struct partial_symtab *pst, char **include_list,
988 // OBSOLETE int num_includes, int capping_symbol_cnt,
989 // OBSOLETE CORE_ADDR capping_text,
990 // OBSOLETE struct partial_symtab **dependency_list,
991 // OBSOLETE int number_dependencies)
994 // OBSOLETE struct partial_symtab *p1;
995 // OBSOLETE struct objfile *objfile = pst->objfile;
997 // OBSOLETE if (capping_symbol_cnt != -1)
998 // OBSOLETE LDSYMCNT (pst) = capping_symbol_cnt - LDSYMCNT (pst);
1000 // OBSOLETE /* Under Solaris, the N_SO symbols always have a value of 0,
1001 // OBSOLETE instead of the usual address of the .o file. Therefore,
1002 // OBSOLETE we have to do some tricks to fill in texthigh and textlow.
1003 // OBSOLETE The first trick is in partial-stab.h: if we see a static
1004 // OBSOLETE or global function, and the textlow for the current pst
1005 // OBSOLETE is still 0, then we use that function's address for
1006 // OBSOLETE the textlow of the pst.
1008 // OBSOLETE Now, to fill in texthigh, we remember the last function seen
1009 // OBSOLETE in the .o file (also in partial-stab.h). Also, there's a hack in
1010 // OBSOLETE bfd/elf.c and gdb/elfread.c to pass the ELF st_size field
1011 // OBSOLETE to here via the misc_info field. Therefore, we can fill in
1012 // OBSOLETE a reliable texthigh by taking the address plus size of the
1013 // OBSOLETE last function in the file.
1015 // OBSOLETE Unfortunately, that does not cover the case where the last function
1016 // OBSOLETE in the file is static. See the paragraph below for more comments
1017 // OBSOLETE on this situation.
1019 // OBSOLETE Finally, if we have a valid textlow for the current file, we run
1020 // OBSOLETE down the partial_symtab_list filling in previous texthighs that
1021 // OBSOLETE are still unknown. */
1023 // OBSOLETE if (pst->texthigh == 0 && last_function_name)
1025 // OBSOLETE char *p;
1027 // OBSOLETE struct minimal_symbol *minsym;
1029 // OBSOLETE p = strchr (last_function_name, ':');
1030 // OBSOLETE if (p == NULL)
1031 // OBSOLETE p = last_function_name;
1032 // OBSOLETE n = p - last_function_name;
1033 // OBSOLETE p = alloca (n + 1);
1034 // OBSOLETE strncpy (p, last_function_name, n);
1035 // OBSOLETE p[n] = 0;
1037 // OBSOLETE minsym = lookup_minimal_symbol (p, NULL, objfile);
1039 // OBSOLETE if (minsym)
1041 // OBSOLETE pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) + (long) MSYMBOL_INFO (minsym);
1045 // OBSOLETE /* This file ends with a static function, and it's
1046 // OBSOLETE difficult to imagine how hard it would be to track down
1047 // OBSOLETE the elf symbol. Luckily, most of the time no one will notice,
1048 // OBSOLETE since the next file will likely be compiled with -g, so
1049 // OBSOLETE the code below will copy the first fuction's start address
1050 // OBSOLETE back to our texthigh variable. (Also, if this file is the
1051 // OBSOLETE last one in a dynamically linked program, texthigh already
1052 // OBSOLETE has the right value.) If the next file isn't compiled
1053 // OBSOLETE with -g, then the last function in this file winds up owning
1054 // OBSOLETE all of the text space up to the next -g file, or the end (minus
1055 // OBSOLETE shared libraries). This only matters for single stepping,
1056 // OBSOLETE and even then it will still work, except that it will single
1057 // OBSOLETE step through all of the covered functions, instead of setting
1058 // OBSOLETE breakpoints around them as it usualy does. This makes it
1059 // OBSOLETE pretty slow, but at least it doesn't fail.
1061 // OBSOLETE We can fix this with a fairly big change to bfd, but we need
1062 // OBSOLETE to coordinate better with Cygnus if we want to do that. FIXME. */
1064 // OBSOLETE last_function_name = NULL;
1067 // OBSOLETE /* this test will be true if the last .o file is only data */
1068 // OBSOLETE if (pst->textlow == 0)
1069 // OBSOLETE pst->textlow = pst->texthigh;
1071 // OBSOLETE /* If we know our own starting text address, then walk through all other
1072 // OBSOLETE psymtabs for this objfile, and if any didn't know their ending text
1073 // OBSOLETE address, set it to our starting address. Take care to not set our
1074 // OBSOLETE own ending address to our starting address, nor to set addresses on
1075 // OBSOLETE `dependency' files that have both textlow and texthigh zero. */
1076 // OBSOLETE if (pst->textlow)
1078 // OBSOLETE ALL_OBJFILE_PSYMTABS (objfile, p1)
1080 // OBSOLETE if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst)
1082 // OBSOLETE p1->texthigh = pst->textlow;
1083 // OBSOLETE /* if this file has only data, then make textlow match texthigh */
1084 // OBSOLETE if (p1->textlow == 0)
1085 // OBSOLETE p1->textlow = p1->texthigh;
1090 // OBSOLETE /* End of kludge for patching Solaris textlow and texthigh. */
1092 // OBSOLETE pst->n_global_syms =
1093 // OBSOLETE objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
1094 // OBSOLETE pst->n_static_syms =
1095 // OBSOLETE objfile->static_psymbols.next - (objfile->static_psymbols.list + pst->statics_offset);
1097 // OBSOLETE pst->number_of_dependencies = number_dependencies;
1098 // OBSOLETE if (number_dependencies)
1100 // OBSOLETE pst->dependencies = (struct partial_symtab **)
1101 // OBSOLETE obstack_alloc (&objfile->psymbol_obstack,
1102 // OBSOLETE number_dependencies * sizeof (struct partial_symtab *));
1103 // OBSOLETE memcpy (pst->dependencies, dependency_list,
1104 // OBSOLETE number_dependencies * sizeof (struct partial_symtab *));
1107 // OBSOLETE pst->dependencies = 0;
1109 // OBSOLETE for (i = 0; i < num_includes; i++)
1111 // OBSOLETE struct partial_symtab *subpst =
1112 // OBSOLETE allocate_psymtab (include_list[i], objfile);
1114 // OBSOLETE subpst->section_offsets = pst->section_offsets;
1115 // OBSOLETE subpst->read_symtab_private =
1116 // OBSOLETE (char *) obstack_alloc (&objfile->psymbol_obstack,
1117 // OBSOLETE sizeof (struct symloc));
1118 // OBSOLETE LDSYMOFF (subpst) =
1119 // OBSOLETE LDSYMCNT (subpst) =
1120 // OBSOLETE subpst->textlow =
1121 // OBSOLETE subpst->texthigh = 0;
1123 // OBSOLETE /* We could save slight bits of space by only making one of these,
1124 // OBSOLETE shared by the entire set of include files. FIXME-someday. */
1125 // OBSOLETE subpst->dependencies = (struct partial_symtab **)
1126 // OBSOLETE obstack_alloc (&objfile->psymbol_obstack,
1127 // OBSOLETE sizeof (struct partial_symtab *));
1128 // OBSOLETE subpst->dependencies[0] = pst;
1129 // OBSOLETE subpst->number_of_dependencies = 1;
1131 // OBSOLETE subpst->globals_offset =
1132 // OBSOLETE subpst->n_global_syms =
1133 // OBSOLETE subpst->statics_offset =
1134 // OBSOLETE subpst->n_static_syms = 0;
1136 // OBSOLETE subpst->readin = 0;
1137 // OBSOLETE subpst->symtab = 0;
1138 // OBSOLETE subpst->read_symtab = pst->read_symtab;
1141 // OBSOLETE sort_pst_symbols (pst);
1143 // OBSOLETE /* If there is already a psymtab or symtab for a file of this name,
1144 // OBSOLETE remove it.
1145 // OBSOLETE (If there is a symtab, more drastic things also happen.)
1146 // OBSOLETE This happens in VxWorks. */
1147 // OBSOLETE free_named_symtabs (pst->filename);
1149 // OBSOLETE if (num_includes == 0
1150 // OBSOLETE && number_dependencies == 0
1151 // OBSOLETE && pst->n_global_syms == 0
1152 // OBSOLETE && pst->n_static_syms == 0)
1154 // OBSOLETE /* Throw away this psymtab, it's empty. We can't deallocate it, since
1155 // OBSOLETE it is on the obstack, but we can forget to chain it on the list. */
1156 // OBSOLETE /* Indicate that psymtab was thrown away. */
1158 // OBSOLETE discard_psymtab (pst);
1160 // OBSOLETE pst = (struct partial_symtab *) NULL;
1162 // OBSOLETE return pst;
1165 // OBSOLETE static void
1166 // OBSOLETE os9k_psymtab_to_symtab_1 (struct partial_symtab *pst)
1168 // OBSOLETE struct cleanup *old_chain;
1171 // OBSOLETE if (!pst)
1174 // OBSOLETE if (pst->readin)
1176 // OBSOLETE fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
1177 // OBSOLETE pst->filename);
1181 // OBSOLETE /* Read in all partial symtabs on which this one is dependent */
1182 // OBSOLETE for (i = 0; i < pst->number_of_dependencies; i++)
1183 // OBSOLETE if (!pst->dependencies[i]->readin)
1185 // OBSOLETE /* Inform about additional files that need to be read in. */
1186 // OBSOLETE if (info_verbose)
1188 // OBSOLETE fputs_filtered (" ", gdb_stdout);
1189 // OBSOLETE wrap_here ("");
1190 // OBSOLETE fputs_filtered ("and ", gdb_stdout);
1191 // OBSOLETE wrap_here ("");
1192 // OBSOLETE printf_filtered ("%s...", pst->dependencies[i]->filename);
1193 // OBSOLETE wrap_here (""); /* Flush output */
1194 // OBSOLETE gdb_flush (gdb_stdout);
1196 // OBSOLETE os9k_psymtab_to_symtab_1 (pst->dependencies[i]);
1199 // OBSOLETE if (LDSYMCNT (pst)) /* Otherwise it's a dummy */
1201 // OBSOLETE /* Init stuff necessary for reading in symbols */
1202 // OBSOLETE stabsread_init ();
1203 // OBSOLETE buildsym_init ();
1204 // OBSOLETE old_chain = make_cleanup (really_free_pendings, 0);
1206 // OBSOLETE /* Read in this file's symbols */
1207 // OBSOLETE os9k_read_ofile_symtab (pst);
1208 // OBSOLETE sort_symtab_syms (pst->symtab);
1209 // OBSOLETE do_cleanups (old_chain);
1212 // OBSOLETE pst->readin = 1;
1215 // OBSOLETE /* Read in all of the symbols for a given psymtab for real.
1216 // OBSOLETE Be verbose about it if the user wants that. */
1218 // OBSOLETE static void
1219 // OBSOLETE os9k_psymtab_to_symtab (struct partial_symtab *pst)
1221 // OBSOLETE bfd *sym_bfd;
1223 // OBSOLETE if (!pst)
1226 // OBSOLETE if (pst->readin)
1228 // OBSOLETE fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
1229 // OBSOLETE pst->filename);
1233 // OBSOLETE if (LDSYMCNT (pst) || pst->number_of_dependencies)
1235 // OBSOLETE /* Print the message now, before reading the string table,
1236 // OBSOLETE to avoid disconcerting pauses. */
1237 // OBSOLETE if (info_verbose)
1239 // OBSOLETE printf_filtered ("Reading in symbols for %s...", pst->filename);
1240 // OBSOLETE gdb_flush (gdb_stdout);
1243 // OBSOLETE sym_bfd = pst->objfile->obfd;
1244 // OBSOLETE os9k_psymtab_to_symtab_1 (pst);
1246 // OBSOLETE /* Match with global symbols. This only needs to be done once,
1247 // OBSOLETE after all of the symtabs and dependencies have been read in. */
1248 // OBSOLETE scan_file_globals (pst->objfile);
1250 // OBSOLETE /* Finish up the debug error message. */
1251 // OBSOLETE if (info_verbose)
1252 // OBSOLETE printf_filtered ("done.\n");
1256 // OBSOLETE /* Read in a defined section of a specific object file's symbols. */
1257 // OBSOLETE static void
1258 // OBSOLETE os9k_read_ofile_symtab (struct partial_symtab *pst)
1260 // OBSOLETE register struct internal_symstruct *bufp;
1261 // OBSOLETE unsigned char type;
1262 // OBSOLETE unsigned max_symnum;
1263 // OBSOLETE register bfd *abfd;
1264 // OBSOLETE struct objfile *objfile;
1265 // OBSOLETE int sym_offset; /* Offset to start of symbols to read */
1266 // OBSOLETE CORE_ADDR text_offset; /* Start of text segment for symbols */
1267 // OBSOLETE int text_size; /* Size of text segment for symbols */
1268 // OBSOLETE FILE *dbg_file;
1270 // OBSOLETE objfile = pst->objfile;
1271 // OBSOLETE sym_offset = LDSYMOFF (pst);
1272 // OBSOLETE max_symnum = LDSYMCNT (pst);
1273 // OBSOLETE text_offset = pst->textlow;
1274 // OBSOLETE text_size = pst->texthigh - pst->textlow;
1276 // OBSOLETE current_objfile = objfile;
1277 // OBSOLETE subfile_stack = NULL;
1278 // OBSOLETE last_source_file = NULL;
1280 // OBSOLETE abfd = objfile->obfd;
1281 // OBSOLETE dbg_file = objfile->auxf2;
1284 // OBSOLETE /* It is necessary to actually read one symbol *before* the start
1285 // OBSOLETE of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
1286 // OBSOLETE occurs before the N_SO symbol.
1287 // OBSOLETE Detecting this in read_dbx_symtab
1288 // OBSOLETE would slow down initial readin, so we look for it here instead. */
1289 // OBSOLETE if (!processing_acc_compilation && sym_offset >= (int) symbol_size)
1291 // OBSOLETE fseek (objefile->auxf2, sym_offset, SEEK_CUR);
1292 // OBSOLETE fill_sym (objfile->auxf2, abfd);
1293 // OBSOLETE bufp = symbuf;
1295 // OBSOLETE processing_gcc_compilation = 0;
1296 // OBSOLETE if (bufp->n_type == N_TEXT)
1298 // OBSOLETE if (STREQ (namestring, GCC_COMPILED_FLAG_SYMBOL))
1299 // OBSOLETE processing_gcc_compilation = 1;
1300 // OBSOLETE else if (STREQ (namestring, GCC2_COMPILED_FLAG_SYMBOL))
1301 // OBSOLETE processing_gcc_compilation = 2;
1304 // OBSOLETE /* Try to select a C++ demangling based on the compilation unit
1305 // OBSOLETE producer. */
1307 // OBSOLETE if (processing_gcc_compilation)
1309 // OBSOLETE if (AUTO_DEMANGLING)
1311 // OBSOLETE set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
1317 // OBSOLETE /* The N_SO starting this symtab is the first symbol, so we
1318 // OBSOLETE better not check the symbol before it. I'm not this can
1319 // OBSOLETE happen, but it doesn't hurt to check for it. */
1320 // OBSOLETE bfd_seek (symfile_bfd, sym_offset, SEEK_CUR);
1321 // OBSOLETE processing_gcc_compilation = 0;
1323 // OBSOLETE #endif /* 0 */
1325 // OBSOLETE fseek (dbg_file, (long) sym_offset, 0);
1327 // OBSOLETE if (bufp->n_type != (unsigned char)N_SYM_SYM)
1328 // OBSOLETE error("First symbol in segment of executable not a source symbol");
1331 // OBSOLETE for (symnum = 0; symnum < max_symnum; symnum++)
1333 // OBSOLETE QUIT; /* Allow this to be interruptable */
1334 // OBSOLETE fill_sym (dbg_file, abfd);
1335 // OBSOLETE bufp = symbuf;
1336 // OBSOLETE type = bufp->n_type;
1338 // OBSOLETE os9k_process_one_symbol ((int) type, (int) bufp->n_desc,
1339 // OBSOLETE (CORE_ADDR) bufp->n_value, bufp->n_strx, pst->section_offsets, objfile);
1341 // OBSOLETE /* We skip checking for a new .o or -l file; that should never
1342 // OBSOLETE happen in this routine. */
1345 // OBSOLETE if (type == N_TEXT)
1347 // OBSOLETE /* I don't think this code will ever be executed, because
1348 // OBSOLETE the GCC_COMPILED_FLAG_SYMBOL usually is right before
1349 // OBSOLETE the N_SO symbol which starts this source file.
1350 // OBSOLETE However, there is no reason not to accept
1351 // OBSOLETE the GCC_COMPILED_FLAG_SYMBOL anywhere. */
1353 // OBSOLETE if (STREQ (namestring, GCC_COMPILED_FLAG_SYMBOL))
1354 // OBSOLETE processing_gcc_compilation = 1;
1355 // OBSOLETE else if (STREQ (namestring, GCC2_COMPILED_FLAG_SYMBOL))
1356 // OBSOLETE processing_gcc_compilation = 2;
1358 // OBSOLETE if (AUTO_DEMANGLING)
1360 // OBSOLETE set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
1363 // OBSOLETE else if (type & N_EXT || type == (unsigned char) N_TEXT
1364 // OBSOLETE || type == (unsigned char) N_NBTEXT
1367 // OBSOLETE /* Global symbol: see if we came across a dbx defintion for
1368 // OBSOLETE a corresponding symbol. If so, store the value. Remove
1369 // OBSOLETE syms from the chain when their values are stored, but
1370 // OBSOLETE search the whole chain, as there may be several syms from
1371 // OBSOLETE different files with the same name. */
1372 // OBSOLETE /* This is probably not true. Since the files will be read
1373 // OBSOLETE in one at a time, each reference to a global symbol will
1374 // OBSOLETE be satisfied in each file as it appears. So we skip this
1375 // OBSOLETE section. */
1378 // OBSOLETE #endif /* 0 */
1381 // OBSOLETE current_objfile = NULL;
1383 // OBSOLETE /* In a Solaris elf file, this variable, which comes from the
1384 // OBSOLETE value of the N_SO symbol, will still be 0. Luckily, text_offset,
1385 // OBSOLETE which comes from pst->textlow is correct. */
1386 // OBSOLETE if (last_source_start_addr == 0)
1387 // OBSOLETE last_source_start_addr = text_offset;
1388 // OBSOLETE pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
1389 // OBSOLETE end_stabs ();
1393 // OBSOLETE /* This handles a single symbol from the symbol-file, building symbols
1394 // OBSOLETE into a GDB symtab. It takes these arguments and an implicit argument.
1396 // OBSOLETE TYPE is the type field of the ".stab" symbol entry.
1397 // OBSOLETE DESC is the desc field of the ".stab" entry.
1398 // OBSOLETE VALU is the value field of the ".stab" entry.
1399 // OBSOLETE NAME is the symbol name, in our address space.
1400 // OBSOLETE SECTION_OFFSETS is a set of amounts by which the sections of this object
1401 // OBSOLETE file were relocated when it was loaded into memory.
1402 // OBSOLETE All symbols that refer
1403 // OBSOLETE to memory locations need to be offset by these amounts.
1404 // OBSOLETE OBJFILE is the object file from which we are reading symbols.
1405 // OBSOLETE It is used in end_symtab. */
1407 // OBSOLETE static void
1408 // OBSOLETE os9k_process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
1409 // OBSOLETE struct section_offsets *section_offsets,
1410 // OBSOLETE struct objfile *objfile)
1412 // OBSOLETE register struct context_stack *new;
1413 // OBSOLETE /* The stab type used for the definition of the last function.
1414 // OBSOLETE N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */
1415 // OBSOLETE static int function_stab_type = 0;
1418 // OBSOLETE /* Something is wrong if we see real data before
1419 // OBSOLETE seeing a source file name. */
1420 // OBSOLETE if (last_source_file == NULL && type != (unsigned char) N_SO)
1422 // OBSOLETE /* Ignore any symbols which appear before an N_SO symbol.
1423 // OBSOLETE Currently no one puts symbols there, but we should deal
1424 // OBSOLETE gracefully with the case. A complain()t might be in order,
1425 // OBSOLETE but this should not be an error (). */
1428 // OBSOLETE #endif /* 0 */
1430 // OBSOLETE switch (type)
1432 // OBSOLETE case N_SYM_LBRAC:
1433 // OBSOLETE /* On most machines, the block addresses are relative to the
1434 // OBSOLETE N_SO, the linker did not relocate them (sigh). */
1435 // OBSOLETE valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
1436 // OBSOLETE new = push_context (desc, valu);
1439 // OBSOLETE case N_SYM_RBRAC:
1440 // OBSOLETE valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
1441 // OBSOLETE new = pop_context ();
1443 // OBSOLETE #if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
1444 // OBSOLETE #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1
1447 // OBSOLETE if (!OS9K_VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation))
1448 // OBSOLETE local_symbols = new->locals;
1450 // OBSOLETE if (context_stack_depth > 1)
1452 // OBSOLETE /* This is not the outermost LBRAC...RBRAC pair in the function,
1453 // OBSOLETE its local symbols preceded it, and are the ones just recovered
1454 // OBSOLETE from the context stack. Define the block for them (but don't
1455 // OBSOLETE bother if the block contains no symbols. Should we complain
1456 // OBSOLETE on blocks without symbols? I can't think of any useful purpose
1457 // OBSOLETE for them). */
1458 // OBSOLETE if (local_symbols != NULL)
1460 // OBSOLETE /* Muzzle a compiler bug that makes end < start. (which
1461 // OBSOLETE compilers? Is this ever harmful?). */
1462 // OBSOLETE if (new->start_addr > valu)
1464 // OBSOLETE complain (&lbrac_rbrac_complaint);
1465 // OBSOLETE new->start_addr = valu;
1467 // OBSOLETE /* Make a block for the local symbols within. */
1468 // OBSOLETE finish_block (0, &local_symbols, new->old_blocks,
1469 // OBSOLETE new->start_addr, valu, objfile);
1474 // OBSOLETE if (context_stack_depth == 0)
1476 // OBSOLETE within_function = 0;
1477 // OBSOLETE /* Make a block for the local symbols within. */
1478 // OBSOLETE finish_block (new->name, &local_symbols, new->old_blocks,
1479 // OBSOLETE new->start_addr, valu, objfile);
1483 // OBSOLETE /* attach local_symbols to the end of new->locals */
1484 // OBSOLETE if (!new->locals)
1485 // OBSOLETE new->locals = local_symbols;
1488 // OBSOLETE struct pending *p;
1490 // OBSOLETE p = new->locals;
1491 // OBSOLETE while (p->next)
1492 // OBSOLETE p = p->next;
1493 // OBSOLETE p->next = local_symbols;
1498 // OBSOLETE if (OS9K_VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation))
1499 // OBSOLETE /* Now pop locals of block just finished. */
1500 // OBSOLETE local_symbols = new->locals;
1504 // OBSOLETE case N_SYM_SLINE:
1505 // OBSOLETE /* This type of "symbol" really just records
1506 // OBSOLETE one line-number -- core-address correspondence.
1507 // OBSOLETE Enter it in the line list for this symbol table. */
1508 // OBSOLETE /* Relocate for dynamic loading and for ELF acc fn-relative syms. */
1509 // OBSOLETE valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
1510 // OBSOLETE /* FIXME: loses if sizeof (char *) > sizeof (int) */
1511 // OBSOLETE gdb_assert (sizeof (name) <= sizeof (int));
1512 // OBSOLETE record_line (current_subfile, (int) name, valu);
1515 // OBSOLETE /* The following symbol types need to have the appropriate offset added
1516 // OBSOLETE to their value; then we process symbol definitions in the name. */
1517 // OBSOLETE case N_SYM_SYM:
1519 // OBSOLETE if (name)
1521 // OBSOLETE char deftype;
1522 // OBSOLETE char *dirn, *n;
1523 // OBSOLETE char *p = strchr (name, ':');
1524 // OBSOLETE if (p == NULL)
1525 // OBSOLETE deftype = '\0';
1527 // OBSOLETE deftype = p[1];
1530 // OBSOLETE switch (deftype)
1532 // OBSOLETE case 'S':
1533 // OBSOLETE valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
1534 // OBSOLETE n = strrchr (name, '/');
1535 // OBSOLETE if (n != NULL)
1537 // OBSOLETE *n = '\0';
1539 // OBSOLETE dirn = name;
1543 // OBSOLETE n = name;
1544 // OBSOLETE dirn = NULL;
1546 // OBSOLETE *p = '\0';
1547 // OBSOLETE if (symfile_depth++ == 0)
1549 // OBSOLETE if (last_source_file)
1551 // OBSOLETE end_symtab (valu, objfile, SECT_OFF_TEXT (objfile));
1552 // OBSOLETE end_stabs ();
1554 // OBSOLETE start_stabs ();
1555 // OBSOLETE os9k_stabs = 1;
1556 // OBSOLETE start_symtab (n, dirn, valu);
1557 // OBSOLETE record_debugformat ("OS9");
1561 // OBSOLETE push_subfile ();
1562 // OBSOLETE start_subfile (n, dirn != NULL ? dirn : current_subfile->dirname);
1566 // OBSOLETE case 'f':
1567 // OBSOLETE case 'F':
1568 // OBSOLETE valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
1569 // OBSOLETE function_stab_type = type;
1571 // OBSOLETE within_function = 1;
1572 // OBSOLETE new = push_context (0, valu);
1573 // OBSOLETE new->name = define_symbol (valu, name, desc, type, objfile);
1576 // OBSOLETE case 'V':
1577 // OBSOLETE case 'v':
1578 // OBSOLETE valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
1579 // OBSOLETE define_symbol (valu, name, desc, type, objfile);
1582 // OBSOLETE default:
1583 // OBSOLETE define_symbol (valu, name, desc, type, objfile);
1589 // OBSOLETE case N_SYM_SE:
1590 // OBSOLETE if (--symfile_depth != 0)
1591 // OBSOLETE start_subfile (pop_subfile (), current_subfile->dirname);
1594 // OBSOLETE default:
1595 // OBSOLETE complain (&unknown_symtype_complaint,
1596 // OBSOLETE local_hex_string ((unsigned long) type));
1597 // OBSOLETE /* FALLTHROUGH */
1600 // OBSOLETE case N_SYM_CMPLR:
1603 // OBSOLETE previous_stab_code = type;
1606 // OBSOLETE static struct sym_fns os9k_sym_fns =
1608 // OBSOLETE bfd_target_os9k_flavour,
1609 // OBSOLETE os9k_new_init, /* sym_new_init: init anything gbl to entire symtab */
1610 // OBSOLETE os9k_symfile_init, /* sym_init: read initial info, setup for sym_read() */
1611 // OBSOLETE os9k_symfile_read, /* sym_read: read a symbol file into symtab */
1612 // OBSOLETE os9k_symfile_finish, /* sym_finish: finished with file, cleanup */
1613 // OBSOLETE default_symfile_offsets, /* sym_offsets: parse user's offsets to internal form */
1614 // OBSOLETE NULL /* next: pointer to next struct sym_fns */
1618 // OBSOLETE _initialize_os9kread (void)
1620 // OBSOLETE add_symtab_fns (&os9k_sym_fns);
This page took 0.062532 seconds and 4 git commands to generate.