* symtab.c (decode_line_1): If SKIP_PROLOGUE leaves us in
[deliverable/binutils-gdb.git] / gdb / dwarfread.c
CommitLineData
35f5886e
FF
1/* DWARF debugging format support for GDB.
2 Copyright (C) 1991 Free Software Foundation, Inc.
3 Written by Fred Fish at Cygnus Support, portions based on dbxread.c,
4 mipsread.c, coffread.c, and dwarfread.c from a Data General SVR4 gdb port.
5
6This file is part of GDB.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22/*
23
24FIXME: Figure out how to get the frame pointer register number in the
25execution environment of the target. Remove R_FP kludge
26
27FIXME: Add generation of dependencies list to partial symtab code.
28
29FIXME: Currently we ignore host/target byte ordering and integer size
30differences. Should remap data from external form to an internal form
31before trying to use it.
32
33FIXME: Resolve minor differences between what information we put in the
34partial symbol table and what dbxread puts in. For example, we don't yet
35put enum constants there. And dbxread seems to invent a lot of typedefs
36we never see. Use the new printpsym command to see the partial symbol table
37contents.
38
39FIXME: Change forward declarations of static functions to allow for compilers
40without prototypes.
41
42FIXME: Figure out a better way to tell gdb (all the debug reading routines)
43the names of the gccX_compiled flags.
44
45FIXME: Figure out a better way to tell gdb about the name of the function
46contain the user's entry point (I.E. main())
47
48FIXME: The current DWARF specification has a very strong bias towards
49machines with 32-bit integers, as it assumes that many attributes of the
50program (such as an address) will fit in such an integer. There are many
51references in the spec to things that are 2, 4, or 8 bytes long. Given that
52we will probably run into problems on machines where some of these assumptions
53are invalid (64-bit ints for example), we don't bother at this time to try to
54make this code more flexible and just use shorts, ints, and longs (and their
55sizes) where it seems appropriate. I.E. we use a short int to hold DWARF
56tags, and assume that the tag size in the file is the same as sizeof(short).
57
58FIXME: Figure out how to get the name of the symbol indicating that a module
59has been compiled with gcc (gcc_compiledXX) in a more portable way than
60hardcoding it into the object file readers.
61
62FIXME: See other FIXME's and "ifdef 0" scattered throughout the code for
63other things to work on, if you get bored. :-)
64
65*/
35f5886e 66#include <stdio.h>
58050209
DHW
67#ifdef __STDC__
68#include <stdarg.h>
69#else
313fdead 70#include <varargs.h>
58050209 71#endif
35f5886e
FF
72#include <fcntl.h>
73
74#include "defs.h"
35f5886e
FF
75#include "bfd.h"
76#include "symtab.h"
77#include "symfile.h"
f5f0679a 78#include "elf/dwarf.h"
35f5886e
FF
79#include "ansidecl.h"
80
81#ifdef MAINTENANCE /* Define to 1 to compile in some maintenance stuff */
82#define SQUAWK(stuff) dwarfwarn stuff
83#else
84#define SQUAWK(stuff)
85#endif
86
87#ifndef R_FP /* FIXME */
88#define R_FP 14 /* Kludge to get frame pointer register number */
89#endif
90
91typedef unsigned int DIEREF; /* Reference to a DIE */
92
93#define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled%" /* FIXME */
94#define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled%" /* FIXME */
95
96#define STREQ(a,b) (strcmp(a,b)==0)
97
768be6e1
FF
98/* The Amiga SVR4 header file <dwarf.h> defines AT_element_list as a
99 FORM_BLOCK2, and this is the value emitted by the AT&T compiler.
100 However, the Issue 2 DWARF specification from AT&T defines it as
101 a FORM_BLOCK4, as does the latest specification from UI/PLSIG.
102 For backwards compatibility with the AT&T compiler produced executables
103 we define AT_short_element_list for this variant. */
104
105#define AT_short_element_list (0x00f0|FORM_BLOCK2)
106
107/* External variables referenced. */
108
35f5886e
FF
109extern CORE_ADDR startup_file_start; /* From blockframe.c */
110extern CORE_ADDR startup_file_end; /* From blockframe.c */
111extern CORE_ADDR entry_scope_lowpc; /* From blockframe.c */
112extern CORE_ADDR entry_scope_highpc; /* From blockframc.c */
113extern CORE_ADDR main_scope_lowpc; /* From blockframe.c */
114extern CORE_ADDR main_scope_highpc; /* From blockframc.c */
115extern int info_verbose; /* From main.c; nonzero => verbose */
116
117
118/* The DWARF debugging information consists of two major pieces,
119 one is a block of DWARF Information Entries (DIE's) and the other
120 is a line number table. The "struct dieinfo" structure contains
121 the information for a single DIE, the one currently being processed.
122
123 In order to make it easier to randomly access the attribute fields
124 of the current DIE, which are specifically unordered within the DIE
125 each DIE is scanned and an instance of the "struct dieinfo"
126 structure is initialized.
127
128 Initialization is done in two levels. The first, done by basicdieinfo(),
129 just initializes those fields that are vital to deciding whether or not
130 to use this DIE, how to skip past it, etc. The second, done by the
131 function completedieinfo(), fills in the rest of the information.
132
133 Attributes which have block forms are not interpreted at the time
134 the DIE is scanned, instead we just save pointers to the start
135 of their value fields.
136
137 Some fields have a flag <name>_p that is set when the value of the
138 field is valid (I.E. we found a matching attribute in the DIE). Since
139 we may want to test for the presence of some attributes in the DIE,
2d6186f4 140 such as AT_low_pc, without restricting the values of the field,
35f5886e
FF
141 we need someway to note that we found such an attribute.
142
143 */
144
145typedef char BLOCK;
146
147struct dieinfo {
148 char * die; /* Pointer to the raw DIE data */
149 long dielength; /* Length of the raw DIE data */
150 DIEREF dieref; /* Offset of this DIE */
151 short dietag; /* Tag for this DIE */
152 long at_padding;
153 long at_sibling;
154 BLOCK * at_location;
155 char * at_name;
156 unsigned short at_fund_type;
157 BLOCK * at_mod_fund_type;
158 long at_user_def_type;
159 BLOCK * at_mod_u_d_type;
160 short at_ordering;
161 BLOCK * at_subscr_data;
162 long at_byte_size;
163 short at_bit_offset;
164 long at_bit_size;
35f5886e
FF
165 BLOCK * at_element_list;
166 long at_stmt_list;
167 long at_low_pc;
168 long at_high_pc;
169 long at_language;
170 long at_member;
171 long at_discr;
172 BLOCK * at_discr_value;
173 short at_visibility;
174 long at_import;
175 BLOCK * at_string_length;
176 char * at_comp_dir;
177 char * at_producer;
35f5886e 178 long at_frame_base;
35f5886e
FF
179 long at_start_scope;
180 long at_stride_size;
181 long at_src_info;
182 short at_prototyped;
2d6186f4
FF
183 unsigned int has_at_low_pc:1;
184 unsigned int has_at_stmt_list:1;
768be6e1 185 unsigned int short_element_list:1;
35f5886e
FF
186};
187
188static int diecount; /* Approximate count of dies for compilation unit */
189static struct dieinfo *curdie; /* For warnings and such */
190
191static char *dbbase; /* Base pointer to dwarf info */
192static int dbroff; /* Relative offset from start of .debug section */
193static char *lnbase; /* Base pointer to line section */
194static int isreg; /* Kludge to identify register variables */
195
196static CORE_ADDR baseaddr; /* Add to each symbol value */
197
198/* Each partial symbol table entry contains a pointer to private data for the
199 read_symtab() function to use when expanding a partial symbol table entry
200 to a full symbol table entry. For DWARF debugging info, this data is
201 contained in the following structure and macros are provided for easy
202 access to the members given a pointer to a partial symbol table entry.
203
204 dbfoff Always the absolute file offset to the start of the ".debug"
205 section for the file containing the DIE's being accessed.
206
207 dbroff Relative offset from the start of the ".debug" access to the
208 first DIE to be accessed. When building the partial symbol
209 table, this value will be zero since we are accessing the
210 entire ".debug" section. When expanding a partial symbol
211 table entry, this value will be the offset to the first
212 DIE for the compilation unit containing the symbol that
213 triggers the expansion.
214
215 dblength The size of the chunk of DIE's being examined, in bytes.
216
217 lnfoff The absolute file offset to the line table fragment. Ignored
218 when building partial symbol tables, but used when expanding
219 them, and contains the absolute file offset to the fragment
220 of the ".line" section containing the line numbers for the
221 current compilation unit.
222 */
223
224struct dwfinfo {
225 int dbfoff; /* Absolute file offset to start of .debug section */
226 int dbroff; /* Relative offset from start of .debug section */
227 int dblength; /* Size of the chunk of DIE's being examined */
228 int lnfoff; /* Absolute file offset to line table fragment */
229};
230
231#define DBFOFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->dbfoff)
232#define DBROFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->dbroff)
233#define DBLENGTH(p) (((struct dwfinfo *)((p)->read_symtab_private))->dblength)
234#define LNFOFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->lnfoff)
235
236/* Record the symbols defined for each context in a linked list. We don't
237 create a struct block for the context until we know how long to make it.
238 Global symbols for each file are maintained in the global_symbols list. */
239
240struct pending_symbol {
241 struct pending_symbol *next; /* Next pending symbol */
242 struct symbol *symbol; /* The actual symbol */
243};
244
245static struct pending_symbol *global_symbols; /* global funcs and vars */
246static struct block *global_symbol_block;
247
248/* Line number entries are read into a dynamically expandable vector before
249 being added to the symbol table section. Once we know how many there are
250 we can add them. */
251
252static struct linetable *line_vector; /* Vector of line numbers. */
253static int line_vector_index; /* Index of next entry. */
254static int line_vector_length; /* Current allocation limit */
255
256/* Scope information is kept in a scope tree, one node per scope. Each time
257 a new scope is started, a child node is created under the current node
258 and set to the current scope. Each time a scope is closed, the current
259 scope moves back up the tree to the parent of the current scope.
260
261 Each scope contains a pointer to the list of symbols defined in the scope,
262 a pointer to the block vector for the scope, a pointer to the symbol
263 that names the scope (if any), and the range of PC values that mark
264 the start and end of the scope. */
265
266struct scopenode {
267 struct scopenode *parent;
268 struct scopenode *child;
269 struct scopenode *sibling;
270 struct pending_symbol *symbols;
271 struct block *block;
272 struct symbol *namesym;
273 CORE_ADDR lowpc;
274 CORE_ADDR highpc;
275};
276
277static struct scopenode *scopetree;
278static struct scopenode *scope;
279
280/* DIES which have user defined types or modified user defined types refer to
281 other DIES for the type information. Thus we need to associate the offset
282 of a DIE for a user defined type with a pointer to the type information.
283
284 Originally this was done using a simple but expensive algorithm, with an
285 array of unsorted structures, each containing an offset/type-pointer pair.
286 This array was scanned linearly each time a lookup was done. The result
287 was that gdb was spending over half it's startup time munging through this
288 array of pointers looking for a structure that had the right offset member.
289
290 The second attempt used the same array of structures, but the array was
291 sorted using qsort each time a new offset/type was recorded, and a binary
292 search was used to find the type pointer for a given DIE offset. This was
293 even slower, due to the overhead of sorting the array each time a new
294 offset/type pair was entered.
295
296 The third attempt uses a fixed size array of type pointers, indexed by a
297 value derived from the DIE offset. Since the minimum DIE size is 4 bytes,
298 we can divide any DIE offset by 4 to obtain a unique index into this fixed
299 size array. Since each element is a 4 byte pointer, it takes exactly as
300 much memory to hold this array as to hold the DWARF info for a given
301 compilation unit. But it gets freed as soon as we are done with it. */
302
303static struct type **utypes; /* Pointer to array of user type pointers */
304static int numutypes; /* Max number of user type pointers */
305
306/* Forward declarations of static functions so we don't have to worry
307 about ordering within this file. The EXFUN macro may be slightly
308 misleading. Should probably be called DCLFUN instead, or something
309 more intuitive, since it can be used for both static and external
310 definitions. */
311
58050209
DHW
312static void
313EXFUN (dwarfwarn, (char *fmt DOTS));
35f5886e
FF
314
315static void
316EXFUN (scan_partial_symbols, (char *thisdie AND char *enddie));
317
318static void
319EXFUN (scan_compilation_units,
320 (char *filename AND CORE_ADDR addr AND char *thisdie AND char *enddie
a048c8f5
JG
321 AND unsigned int dbfoff AND unsigned int lnoffset
322 AND struct objfile *objfile));
35f5886e
FF
323
324static struct partial_symtab *
a048c8f5 325EXFUN(start_psymtab, (struct objfile *objfile AND CORE_ADDR addr
35f5886e
FF
326 AND char *filename AND CORE_ADDR textlow
327 AND CORE_ADDR texthigh AND int dbfoff
328 AND int curoff AND int culength AND int lnfoff
329 AND struct partial_symbol *global_syms
330 AND struct partial_symbol *static_syms));
331static void
332EXFUN(add_partial_symbol, (struct dieinfo *dip));
333
334static void
335EXFUN(add_psymbol_to_list,
336 (struct psymbol_allocation_list *listp AND char *name
337 AND enum namespace space AND enum address_class class
338 AND CORE_ADDR value));
339
340static void
341EXFUN(init_psymbol_list, (int total_symbols));
342
343static void
344EXFUN(basicdieinfo, (struct dieinfo *dip AND char *diep));
345
346static void
347EXFUN(completedieinfo, (struct dieinfo *dip));
348
349static void
350EXFUN(dwarf_psymtab_to_symtab, (struct partial_symtab *pst));
351
352static void
a048c8f5 353EXFUN(psymtab_to_symtab_1, (struct partial_symtab *pst));
35f5886e
FF
354
355static struct symtab *
a048c8f5 356EXFUN(read_ofile_symtab, (struct partial_symtab *pst));
35f5886e
FF
357
358static void
a048c8f5
JG
359EXFUN(process_dies,
360 (char *thisdie AND char *enddie AND struct objfile *objfile));
35f5886e
FF
361
362static void
363EXFUN(read_structure_scope,
8b5b6fae
FF
364 (struct dieinfo *dip AND char *thisdie AND char *enddie AND
365 struct objfile *objfile));
35f5886e
FF
366
367static struct type *
368EXFUN(decode_array_element_type, (char *scan AND char *end));
369
370static struct type *
371EXFUN(decode_subscr_data, (char *scan AND char *end));
372
373static void
374EXFUN(read_array_type, (struct dieinfo *dip));
375
376static void
377EXFUN(read_subroutine_type,
378 (struct dieinfo *dip AND char *thisdie AND char *enddie));
379
380static void
381EXFUN(read_enumeration,
382 (struct dieinfo *dip AND char *thisdie AND char *enddie));
383
384static struct type *
385EXFUN(struct_type,
8b5b6fae
FF
386 (struct dieinfo *dip AND char *thisdie AND char *enddie AND
387 struct objfile *objfile));
35f5886e
FF
388
389static struct type *
390EXFUN(enum_type, (struct dieinfo *dip));
391
35f5886e
FF
392static void
393EXFUN(start_symtab, (void));
394
395static void
a048c8f5
JG
396EXFUN(end_symtab,
397 (char *filename AND long language AND struct objfile *objfile));
35f5886e
FF
398
399static int
400EXFUN(scopecount, (struct scopenode *node));
401
402static void
403EXFUN(openscope,
404 (struct symbol *namesym AND CORE_ADDR lowpc AND CORE_ADDR highpc));
405
406static void
407EXFUN(freescope, (struct scopenode *node));
408
409static struct block *
410EXFUN(buildblock, (struct pending_symbol *syms));
411
412static void
413EXFUN(closescope, (void));
414
415static void
416EXFUN(record_line, (int line AND CORE_ADDR pc));
417
418static void
419EXFUN(decode_line_numbers, (char *linetable));
420
421static struct type *
422EXFUN(decode_die_type, (struct dieinfo *dip));
423
424static struct type *
425EXFUN(decode_mod_fund_type, (char *typedata));
426
427static struct type *
428EXFUN(decode_mod_u_d_type, (char *typedata));
429
430static struct type *
431EXFUN(decode_modified_type,
432 (unsigned char *modifiers AND unsigned short modcount AND int mtype));
433
434static struct type *
435EXFUN(decode_fund_type, (unsigned short fundtype));
436
437static char *
438EXFUN(create_name, (char *name AND struct obstack *obstackp));
439
440static void
441EXFUN(add_symbol_to_list,
442 (struct symbol *symbol AND struct pending_symbol **listhead));
443
444static struct block **
445EXFUN(gatherblocks, (struct block **dest AND struct scopenode *node));
446
447static struct blockvector *
448EXFUN(make_blockvector, (void));
449
450static struct type *
451EXFUN(lookup_utype, (DIEREF dieref));
452
453static struct type *
454EXFUN(alloc_utype, (DIEREF dieref AND struct type *usetype));
455
456static struct symbol *
457EXFUN(new_symbol, (struct dieinfo *dip));
458
459static int
460EXFUN(locval, (char *loc));
461
462static void
a7446af6
FF
463EXFUN(record_misc_function, (char *name AND CORE_ADDR address AND
464 enum misc_function_type));
35f5886e
FF
465
466static int
467EXFUN(compare_psymbols,
468 (struct partial_symbol *s1 AND struct partial_symbol *s2));
469
470
471/*
472
473GLOBAL FUNCTION
474
475 dwarf_build_psymtabs -- build partial symtabs from DWARF debug info
476
477SYNOPSIS
478
479 void dwarf_build_psymtabs (int desc, char *filename, CORE_ADDR addr,
480 int mainline, unsigned int dbfoff, unsigned int dbsize,
a048c8f5
JG
481 unsigned int lnoffset, unsigned int lnsize,
482 struct objfile *objfile)
35f5886e
FF
483
484DESCRIPTION
485
486 This function is called upon to build partial symtabs from files
487 containing DIE's (Dwarf Information Entries) and DWARF line numbers.
488
489 It is passed a file descriptor for an open file containing the DIES
490 and line number information, the corresponding filename for that
491 file, a base address for relocating the symbols, a flag indicating
492 whether or not this debugging information is from a "main symbol
493 table" rather than a shared library or dynamically linked file,
494 and file offset/size pairs for the DIE information and line number
495 information.
496
497RETURNS
498
499 No return value.
500
501 */
502
503void
504DEFUN(dwarf_build_psymtabs,
a048c8f5
JG
505 (desc, filename, addr, mainline, dbfoff, dbsize, lnoffset, lnsize,
506 objfile),
35f5886e
FF
507 int desc AND
508 char *filename AND
509 CORE_ADDR addr AND
510 int mainline AND
511 unsigned int dbfoff AND
512 unsigned int dbsize AND
513 unsigned int lnoffset AND
a048c8f5
JG
514 unsigned int lnsize AND
515 struct objfile *objfile)
35f5886e
FF
516{
517 struct cleanup *back_to;
518
519 dbbase = xmalloc (dbsize);
520 dbroff = 0;
521 if ((lseek (desc, dbfoff, 0) != dbfoff) ||
522 (read (desc, dbbase, dbsize) != dbsize))
523 {
524 free (dbbase);
525 error ("can't read DWARF data from '%s'", filename);
526 }
527 back_to = make_cleanup (free, dbbase);
528
529 /* If we are reinitializing, or if we have never loaded syms yet, init.
530 Since we have no idea how many DIES we are looking at, we just guess
531 some arbitrary value. */
532
533 if (mainline || global_psymbols.size == 0 || static_psymbols.size == 0)
534 {
535 init_psymbol_list (1024);
536 }
537
35f5886e
FF
538 /* Follow the compilation unit sibling chain, building a partial symbol
539 table entry for each one. Save enough information about each compilation
540 unit to locate the full DWARF information later. */
541
542 scan_compilation_units (filename, addr, dbbase, dbbase + dbsize,
a048c8f5 543 dbfoff, lnoffset, objfile);
35f5886e 544
35f5886e
FF
545 do_cleanups (back_to);
546}
547
548
549/*
550
551LOCAL FUNCTION
552
553 record_misc_function -- add entry to miscellaneous function vector
554
555SYNOPSIS
556
a7446af6
FF
557 static void record_misc_function (char *name, CORE_ADDR address,
558 enum misc_function_type mf_type)
35f5886e
FF
559
560DESCRIPTION
561
562 Given a pointer to the name of a symbol that should be added to the
563 miscellaneous function vector, and the address associated with that
564 symbol, records this information for later use in building the
565 miscellaneous function vector.
566
35f5886e
FF
567 */
568
569static void
a7446af6
FF
570DEFUN(record_misc_function, (name, address, mf_type),
571 char *name AND CORE_ADDR address AND enum misc_function_type mf_type)
35f5886e
FF
572{
573 prim_record_misc_function (obsavestring (name, strlen (name)), address,
a7446af6 574 mf_type);
35f5886e
FF
575}
576
577/*
578
579LOCAL FUNCTION
580
581 dwarfwarn -- issue a DWARF related warning
582
583DESCRIPTION
584
585 Issue warnings about DWARF related things that aren't serious enough
586 to warrant aborting with an error, but should not be ignored either.
587 This includes things like detectable corruption in DIE's, missing
588 DIE's, unimplemented features, etc.
589
590 In general, running across tags or attributes that we don't recognize
591 is not considered to be a problem and we should not issue warnings
592 about such.
593
594NOTES
595
596 We mostly follow the example of the error() routine, but without
597 returning to command level. It is arguable about whether warnings
598 should be issued at all, and if so, where they should go (stdout or
599 stderr).
600
601 We assume that curdie is valid and contains at least the basic
602 information for the DIE where the problem was noticed.
603*/
604
58050209
DHW
605#ifdef __STDC__
606static void
607DEFUN(dwarfwarn, (fmt), char *fmt DOTS)
608{
609 va_list ap;
610
611 va_start (ap, fmt);
612 warning_setup ();
613 fprintf (stderr, "DWARF warning (ref 0x%x): ", curdie -> dieref);
614 if (curdie -> at_name)
615 {
616 fprintf (stderr, "'%s': ", curdie -> at_name);
617 }
618 vfprintf (stderr, fmt, ap);
619 fprintf (stderr, "\n");
620 fflush (stderr);
621 va_end (ap);
622}
623#else
624
35f5886e 625static void
313fdead
JG
626dwarfwarn (va_alist)
627 va_dcl
35f5886e
FF
628{
629 va_list ap;
313fdead 630 char *fmt;
35f5886e 631
313fdead
JG
632 va_start (ap);
633 fmt = va_arg (ap, char *);
35f5886e
FF
634 warning_setup ();
635 fprintf (stderr, "DWARF warning (ref 0x%x): ", curdie -> dieref);
636 if (curdie -> at_name)
637 {
638 fprintf (stderr, "'%s': ", curdie -> at_name);
639 }
640 vfprintf (stderr, fmt, ap);
641 fprintf (stderr, "\n");
642 fflush (stderr);
643 va_end (ap);
644}
58050209 645#endif
35f5886e
FF
646/*
647
648LOCAL FUNCTION
649
650 compare_psymbols -- compare two partial symbols by name
651
652DESCRIPTION
653
654 Given pointer to two partial symbol table entries, compare
655 them by name and return -N, 0, or +N (ala strcmp). Typically
656 used by sorting routines like qsort().
657
658NOTES
659
660 This is a copy from dbxread.c. It should be moved to a generic
661 gdb file and made available for all psymtab builders (FIXME).
662
663 Does direct compare of first two characters before punting
664 and passing to strcmp for longer compares. Note that the
665 original version had a bug whereby two null strings or two
666 identically named one character strings would return the
667 comparison of memory following the null byte.
668
669 */
670
671static int
672DEFUN(compare_psymbols, (s1, s2),
673 struct partial_symbol *s1 AND
674 struct partial_symbol *s2)
675{
676 register char *st1 = SYMBOL_NAME (s1);
677 register char *st2 = SYMBOL_NAME (s2);
678
679 if ((st1[0] - st2[0]) || !st1[0])
680 {
681 return (st1[0] - st2[0]);
682 }
683 else if ((st1[1] - st2[1]) || !st1[1])
684 {
685 return (st1[1] - st2[1]);
686 }
687 else
688 {
689 return (strcmp (st1 + 2, st2 + 2));
690 }
691}
692
693/*
694
695LOCAL FUNCTION
696
697 read_lexical_block_scope -- process all dies in a lexical block
698
699SYNOPSIS
700
701 static void read_lexical_block_scope (struct dieinfo *dip,
702 char *thisdie, char *enddie)
703
704DESCRIPTION
705
706 Process all the DIES contained within a lexical block scope.
707 Start a new scope, process the dies, and then close the scope.
708
709 */
710
711static void
a048c8f5 712DEFUN(read_lexical_block_scope, (dip, thisdie, enddie, objfile),
35f5886e
FF
713 struct dieinfo *dip AND
714 char *thisdie AND
a048c8f5
JG
715 char *enddie AND
716 struct objfile *objfile)
35f5886e
FF
717{
718 openscope (NULL, dip -> at_low_pc, dip -> at_high_pc);
a048c8f5 719 process_dies (thisdie + dip -> dielength, enddie, objfile);
35f5886e
FF
720 closescope ();
721}
722
723/*
724
725LOCAL FUNCTION
726
727 lookup_utype -- look up a user defined type from die reference
728
729SYNOPSIS
730
731 static type *lookup_utype (DIEREF dieref)
732
733DESCRIPTION
734
735 Given a DIE reference, lookup the user defined type associated with
736 that DIE, if it has been registered already. If not registered, then
737 return NULL. Alloc_utype() can be called to register an empty
738 type for this reference, which will be filled in later when the
739 actual referenced DIE is processed.
740 */
741
742static struct type *
743DEFUN(lookup_utype, (dieref), DIEREF dieref)
744{
745 struct type *type = NULL;
746 int utypeidx;
747
748 utypeidx = (dieref - dbroff) / 4;
749 if ((utypeidx < 0) || (utypeidx >= numutypes))
750 {
751 dwarfwarn ("reference to DIE (0x%x) outside compilation unit", dieref);
752 }
753 else
754 {
755 type = *(utypes + utypeidx);
756 }
757 return (type);
758}
759
760
761/*
762
763LOCAL FUNCTION
764
765 alloc_utype -- add a user defined type for die reference
766
767SYNOPSIS
768
769 static type *alloc_utype (DIEREF dieref, struct type *utypep)
770
771DESCRIPTION
772
773 Given a die reference DIEREF, and a possible pointer to a user
774 defined type UTYPEP, register that this reference has a user
775 defined type and either use the specified type in UTYPEP or
776 make a new empty type that will be filled in later.
777
778 We should only be called after calling lookup_utype() to verify that
779 there is not currently a type registered for DIEREF.
780 */
781
782static struct type *
783DEFUN(alloc_utype, (dieref, utypep),
784 DIEREF dieref AND
785 struct type *utypep)
786{
787 struct type **typep;
788 int utypeidx;
789
790 utypeidx = (dieref - dbroff) / 4;
791 typep = utypes + utypeidx;
792 if ((utypeidx < 0) || (utypeidx >= numutypes))
793 {
794 utypep = builtin_type_int;
795 dwarfwarn ("reference to DIE (0x%x) outside compilation unit", dieref);
796 }
797 else if (*typep != NULL)
798 {
799 utypep = *typep;
800 SQUAWK (("internal error: dup user type allocation"));
801 }
802 else
803 {
804 if (utypep == NULL)
805 {
806 utypep = (struct type *)
807 obstack_alloc (symbol_obstack, sizeof (struct type));
808 (void) memset (utypep, 0, sizeof (struct type));
809 }
810 *typep = utypep;
811 }
812 return (utypep);
813}
814
815/*
816
817LOCAL FUNCTION
818
819 decode_die_type -- return a type for a specified die
820
821SYNOPSIS
822
823 static struct type *decode_die_type (struct dieinfo *dip)
824
825DESCRIPTION
826
827 Given a pointer to a die information structure DIP, decode the
828 type of the die and return a pointer to the decoded type. All
829 dies without specific types default to type int.
830 */
831
832static struct type *
833DEFUN(decode_die_type, (dip), struct dieinfo *dip)
834{
835 struct type *type = NULL;
836
837 if (dip -> at_fund_type != 0)
838 {
839 type = decode_fund_type (dip -> at_fund_type);
840 }
841 else if (dip -> at_mod_fund_type != NULL)
842 {
843 type = decode_mod_fund_type (dip -> at_mod_fund_type);
844 }
845 else if (dip -> at_user_def_type)
846 {
847 if ((type = lookup_utype (dip -> at_user_def_type)) == NULL)
848 {
849 type = alloc_utype (dip -> at_user_def_type, NULL);
850 }
851 }
852 else if (dip -> at_mod_u_d_type)
853 {
854 type = decode_mod_u_d_type (dip -> at_mod_u_d_type);
855 }
856 else
857 {
858 type = builtin_type_int;
859 }
860 return (type);
861}
862
863/*
864
865LOCAL FUNCTION
866
867 struct_type -- compute and return the type for a struct or union
868
869SYNOPSIS
870
871 static struct type *struct_type (struct dieinfo *dip, char *thisdie,
8b5b6fae 872 char *enddie, struct objfile *objfile)
35f5886e
FF
873
874DESCRIPTION
875
876 Given pointer to a die information structure for a die which
715cafcb
FF
877 defines a union or structure (and MUST define one or the other),
878 and pointers to the raw die data that define the range of dies which
879 define the members, compute and return the user defined type for the
880 structure or union.
35f5886e
FF
881 */
882
883static struct type *
8b5b6fae 884DEFUN(struct_type, (dip, thisdie, enddie, objfile),
35f5886e
FF
885 struct dieinfo *dip AND
886 char *thisdie AND
8b5b6fae
FF
887 char *enddie AND
888 struct objfile *objfile)
35f5886e
FF
889{
890 struct type *type;
891 struct nextfield {
892 struct nextfield *next;
893 struct field field;
894 };
895 struct nextfield *list = NULL;
896 struct nextfield *new;
897 int nfields = 0;
898 int n;
899 char *tpart1;
35f5886e 900 struct dieinfo mbr;
8b5b6fae 901 char *nextdie;
35f5886e
FF
902
903 if ((type = lookup_utype (dip -> dieref)) == NULL)
904 {
905 type = alloc_utype (dip -> dieref, NULL);
906 }
715cafcb
FF
907 TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
908 obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
909 (void) memset (TYPE_CPLUS_SPECIFIC (type), 0,
910 sizeof (struct cplus_struct_type));
911 switch (dip -> dietag)
35f5886e 912 {
715cafcb
FF
913 case TAG_structure_type:
914 TYPE_CODE (type) = TYPE_CODE_STRUCT;
915 tpart1 = "struct";
916 break;
917 case TAG_union_type:
918 TYPE_CODE (type) = TYPE_CODE_UNION;
919 tpart1 = "union";
920 break;
921 default:
922 /* Should never happen */
923 TYPE_CODE (type) = TYPE_CODE_UNDEF;
924 tpart1 = "???";
925 SQUAWK (("missing structure or union tag"));
926 break;
35f5886e 927 }
0db97eed 928 /* Some compilers try to be helpful by inventing "fake" names for anonymous
715cafcb
FF
929 enums, structures, and unions, like "~0fake" or ".0fake". Thanks, but
930 no thanks... */
931 if (dip -> at_name != NULL
932 && *dip -> at_name != '~'
933 && *dip -> at_name != '.')
35f5886e 934 {
715cafcb 935 TYPE_NAME (type) = obconcat (tpart1, " ", dip -> at_name);
35f5886e 936 }
715cafcb 937 if (dip -> at_byte_size != 0)
35f5886e 938 {
35f5886e 939 TYPE_LENGTH (type) = dip -> at_byte_size;
35f5886e 940 }
35f5886e
FF
941 thisdie += dip -> dielength;
942 while (thisdie < enddie)
943 {
944 basicdieinfo (&mbr, thisdie);
945 completedieinfo (&mbr);
946 if (mbr.dielength <= sizeof (long))
947 {
948 break;
949 }
8b5b6fae
FF
950 else if (mbr.at_sibling != 0)
951 {
952 nextdie = dbbase + mbr.at_sibling - dbroff;
953 }
954 else
955 {
956 nextdie = thisdie + mbr.dielength;
957 }
35f5886e
FF
958 switch (mbr.dietag)
959 {
960 case TAG_member:
961 /* Get space to record the next field's data. */
962 new = (struct nextfield *) alloca (sizeof (struct nextfield));
963 new -> next = list;
964 list = new;
965 /* Save the data. */
966 list -> field.name = savestring (mbr.at_name, strlen (mbr.at_name));
967 list -> field.type = decode_die_type (&mbr);
968 list -> field.bitpos = 8 * locval (mbr.at_location);
969 list -> field.bitsize = 0;
970 nfields++;
971 break;
972 default:
8b5b6fae 973 process_dies (thisdie, nextdie, objfile);
35f5886e
FF
974 break;
975 }
8b5b6fae 976 thisdie = nextdie;
35f5886e
FF
977 }
978 /* Now create the vector of fields, and record how big it is. */
979 TYPE_NFIELDS (type) = nfields;
980 TYPE_FIELDS (type) = (struct field *)
981 obstack_alloc (symbol_obstack, sizeof (struct field) * nfields);
982 /* Copy the saved-up fields into the field vector. */
983 for (n = nfields; list; list = list -> next)
984 {
985 TYPE_FIELD (type, --n) = list -> field;
986 }
987 return (type);
988}
989
990/*
991
992LOCAL FUNCTION
993
994 read_structure_scope -- process all dies within struct or union
995
996SYNOPSIS
997
998 static void read_structure_scope (struct dieinfo *dip,
8b5b6fae 999 char *thisdie, char *enddie, struct objfile *objfile)
35f5886e
FF
1000
1001DESCRIPTION
1002
1003 Called when we find the DIE that starts a structure or union
1004 scope (definition) to process all dies that define the members
1005 of the structure or union. DIP is a pointer to the die info
1006 struct for the DIE that names the structure or union.
1007
1008NOTES
1009
1010 Note that we need to call struct_type regardless of whether or not
1011 we have a symbol, since we might have a structure or union without
1012 a tag name (thus no symbol for the tagname).
1013 */
1014
1015static void
8b5b6fae 1016DEFUN(read_structure_scope, (dip, thisdie, enddie, objfile),
35f5886e
FF
1017 struct dieinfo *dip AND
1018 char *thisdie AND
8b5b6fae
FF
1019 char *enddie AND
1020 struct objfile *objfile)
35f5886e
FF
1021{
1022 struct type *type;
1023 struct symbol *sym;
1024
8b5b6fae 1025 type = struct_type (dip, thisdie, enddie, objfile);
35f5886e
FF
1026 if ((sym = new_symbol (dip)) != NULL)
1027 {
1028 SYMBOL_TYPE (sym) = type;
1029 }
1030}
1031
1032/*
1033
1034LOCAL FUNCTION
1035
1036 decode_array_element_type -- decode type of the array elements
1037
1038SYNOPSIS
1039
1040 static struct type *decode_array_element_type (char *scan, char *end)
1041
1042DESCRIPTION
1043
1044 As the last step in decoding the array subscript information for an
1045 array DIE, we need to decode the type of the array elements. We are
1046 passed a pointer to this last part of the subscript information and
1047 must return the appropriate type. If the type attribute is not
1048 recognized, just warn about the problem and return type int.
1049 */
1050
1051static struct type *
1052DEFUN(decode_array_element_type, (scan, end), char *scan AND char *end)
1053{
1054 struct type *typep;
1055 short attribute;
1056 DIEREF dieref;
1057 unsigned short fundtype;
1058
1059 (void) memcpy (&attribute, scan, sizeof (short));
1060 scan += sizeof (short);
1061 switch (attribute)
1062 {
1063 case AT_fund_type:
1064 (void) memcpy (&fundtype, scan, sizeof (short));
1065 typep = decode_fund_type (fundtype);
1066 break;
1067 case AT_mod_fund_type:
1068 typep = decode_mod_fund_type (scan);
1069 break;
1070 case AT_user_def_type:
1071 (void) memcpy (&dieref, scan, sizeof (DIEREF));
1072 if ((typep = lookup_utype (dieref)) == NULL)
1073 {
1074 typep = alloc_utype (dieref, NULL);
1075 }
1076 break;
1077 case AT_mod_u_d_type:
1078 typep = decode_mod_u_d_type (scan);
1079 break;
1080 default:
1081 SQUAWK (("bad array element type attribute 0x%x", attribute));
1082 typep = builtin_type_int;
1083 break;
1084 }
1085 return (typep);
1086}
1087
1088/*
1089
1090LOCAL FUNCTION
1091
1092 decode_subscr_data -- decode array subscript and element type data
1093
1094SYNOPSIS
1095
1096 static struct type *decode_subscr_data (char *scan, char *end)
1097
1098DESCRIPTION
1099
1100 The array subscripts and the data type of the elements of an
1101 array are described by a list of data items, stored as a block
1102 of contiguous bytes. There is a data item describing each array
1103 dimension, and a final data item describing the element type.
1104 The data items are ordered the same as their appearance in the
1105 source (I.E. leftmost dimension first, next to leftmost second,
1106 etc).
1107
1108 We are passed a pointer to the start of the block of bytes
1109 containing the data items, and a pointer to the first byte past
1110 the data. This function decodes the data and returns a type.
1111
1112BUGS
1113 FIXME: This code only implements the forms currently used
1114 by the AT&T and GNU C compilers.
1115
1116 The end pointer is supplied for error checking, maybe we should
1117 use it for that...
1118 */
1119
1120static struct type *
1121DEFUN(decode_subscr_data, (scan, end), char *scan AND char *end)
1122{
1123 struct type *typep = NULL;
1124 struct type *nexttype;
1125 int format;
1126 short fundtype;
1127 long lowbound;
1128 long highbound;
1129
1130 format = *scan++;
1131 switch (format)
1132 {
1133 case FMT_ET:
1134 typep = decode_array_element_type (scan, end);
1135 break;
1136 case FMT_FT_C_C:
1137 (void) memcpy (&fundtype, scan, sizeof (short));
1138 scan += sizeof (short);
1139 if (fundtype != FT_integer && fundtype != FT_signed_integer
1140 && fundtype != FT_unsigned_integer)
1141 {
1142 SQUAWK (("array subscripts must be integral types, not type 0x%x",
1143 fundtype));
1144 }
1145 else
1146 {
1147 (void) memcpy (&lowbound, scan, sizeof (long));
1148 scan += sizeof (long);
1149 (void) memcpy (&highbound, scan, sizeof (long));
1150 scan += sizeof (long);
1151 nexttype = decode_subscr_data (scan, end);
1152 if (nexttype != NULL)
1153 {
1154 typep = (struct type *)
1155 obstack_alloc (symbol_obstack, sizeof (struct type));
1156 (void) memset (typep, 0, sizeof (struct type));
1157 TYPE_CODE (typep) = TYPE_CODE_ARRAY;
1158 TYPE_LENGTH (typep) = TYPE_LENGTH (nexttype);
1159 TYPE_LENGTH (typep) *= lowbound + highbound + 1;
1160 TYPE_TARGET_TYPE (typep) = nexttype;
1161 }
1162 }
1163 break;
1164 case FMT_FT_C_X:
1165 case FMT_FT_X_C:
1166 case FMT_FT_X_X:
1167 case FMT_UT_C_C:
1168 case FMT_UT_C_X:
1169 case FMT_UT_X_C:
1170 case FMT_UT_X_X:
1171 SQUAWK (("array subscript format 0x%x not handled yet", format));
1172 break;
1173 default:
1174 SQUAWK (("unknown array subscript format %x", format));
1175 break;
1176 }
1177 return (typep);
1178}
1179
1180/*
1181
1182LOCAL FUNCTION
1183
1184 read_array_type -- read TAG_array_type DIE
1185
1186SYNOPSIS
1187
1188 static void read_array_type (struct dieinfo *dip)
1189
1190DESCRIPTION
1191
1192 Extract all information from a TAG_array_type DIE and add to
1193 the user defined type vector.
1194 */
1195
1196static void
1197DEFUN(read_array_type, (dip), struct dieinfo *dip)
1198{
1199 struct type *type;
1200 char *sub;
1201 char *subend;
1202 short temp;
1203
1204 if (dip -> at_ordering != ORD_row_major)
1205 {
1206 /* FIXME: Can gdb even handle column major arrays? */
1207 SQUAWK (("array not row major; not handled correctly"));
1208 }
1209 if ((sub = dip -> at_subscr_data) != NULL)
1210 {
1211 (void) memcpy (&temp, sub, sizeof (short));
1212 subend = sub + sizeof (short) + temp;
1213 sub += sizeof (short);
1214 type = decode_subscr_data (sub, subend);
1215 if (type == NULL)
1216 {
1217 type = alloc_utype (dip -> dieref, NULL);
1218 TYPE_CODE (type) = TYPE_CODE_ARRAY;
1219 TYPE_TARGET_TYPE (type) = builtin_type_int;
1220 TYPE_LENGTH (type) = 1 * TYPE_LENGTH (TYPE_TARGET_TYPE (type));
1221 }
1222 else
1223 {
1224 type = alloc_utype (dip -> dieref, type);
1225 }
1226 }
1227}
1228
1229/*
1230
1231LOCAL FUNCTION
1232
1233 read_subroutine_type -- process TAG_subroutine_type dies
1234
1235SYNOPSIS
1236
1237 static void read_subroutine_type (struct dieinfo *dip, char thisdie,
1238 char *enddie)
1239
1240DESCRIPTION
1241
1242 Handle DIES due to C code like:
1243
1244 struct foo {
1245 int (*funcp)(int a, long l); (Generates TAG_subroutine_type DIE)
1246 int b;
1247 };
1248
1249NOTES
1250
1251 The parameter DIES are currently ignored. See if gdb has a way to
1252 include this info in it's type system, and decode them if so. Is
1253 this what the type structure's "arg_types" field is for? (FIXME)
1254 */
1255
1256static void
1257DEFUN(read_subroutine_type, (dip, thisdie, enddie),
1258 struct dieinfo *dip AND
1259 char *thisdie AND
1260 char *enddie)
1261{
1262 struct type *type;
1263
1264 type = decode_die_type (dip);
1265 type = lookup_function_type (type);
1266 type = alloc_utype (dip -> dieref, type);
1267}
1268
1269/*
1270
1271LOCAL FUNCTION
1272
1273 read_enumeration -- process dies which define an enumeration
1274
1275SYNOPSIS
1276
1277 static void read_enumeration (struct dieinfo *dip, char *thisdie,
1278 char *enddie)
1279
1280DESCRIPTION
1281
1282 Given a pointer to a die which begins an enumeration, process all
1283 the dies that define the members of the enumeration.
1284
1285NOTES
1286
1287 Note that we need to call enum_type regardless of whether or not we
1288 have a symbol, since we might have an enum without a tag name (thus
1289 no symbol for the tagname).
1290 */
1291
1292static void
1293DEFUN(read_enumeration, (dip, thisdie, enddie),
1294 struct dieinfo *dip AND
1295 char *thisdie AND
1296 char *enddie)
1297{
1298 struct type *type;
1299 struct symbol *sym;
1300
1301 type = enum_type (dip);
1302 if ((sym = new_symbol (dip)) != NULL)
1303 {
1304 SYMBOL_TYPE (sym) = type;
1305 }
1306}
1307
1308/*
1309
1310LOCAL FUNCTION
1311
1312 enum_type -- decode and return a type for an enumeration
1313
1314SYNOPSIS
1315
1316 static type *enum_type (struct dieinfo *dip)
1317
1318DESCRIPTION
1319
1320 Given a pointer to a die information structure for the die which
1321 starts an enumeration, process all the dies that define the members
1322 of the enumeration and return a type pointer for the enumeration.
98618bf7 1323
715cafcb
FF
1324 At the same time, for each member of the enumeration, create a
1325 symbol for it with namespace VAR_NAMESPACE and class LOC_CONST,
1326 and give it the type of the enumeration itself.
1327
1328NOTES
1329
98618bf7
FF
1330 Note that the DWARF specification explicitly mandates that enum
1331 constants occur in reverse order from the source program order,
1332 for "consistency" and because this ordering is easier for many
1333 compilers to generate. (Draft 5, sec 3.9.5, Enumeration type
715cafcb
FF
1334 Entries). Because gdb wants to see the enum members in program
1335 source order, we have to ensure that the order gets reversed while
98618bf7 1336 we are processing them.
35f5886e
FF
1337 */
1338
1339static struct type *
1340DEFUN(enum_type, (dip), struct dieinfo *dip)
1341{
1342 struct type *type;
1343 struct nextfield {
1344 struct nextfield *next;
1345 struct field field;
1346 };
1347 struct nextfield *list = NULL;
1348 struct nextfield *new;
1349 int nfields = 0;
1350 int n;
35f5886e
FF
1351 char *scan;
1352 char *listend;
768be6e1
FF
1353 long ltemp;
1354 short stemp;
715cafcb 1355 struct symbol *sym;
35f5886e
FF
1356
1357 if ((type = lookup_utype (dip -> dieref)) == NULL)
1358 {
1359 type = alloc_utype (dip -> dieref, NULL);
1360 }
1361 TYPE_CODE (type) = TYPE_CODE_ENUM;
0db97eed 1362 /* Some compilers try to be helpful by inventing "fake" names for anonymous
715cafcb
FF
1363 enums, structures, and unions, like "~0fake" or ".0fake". Thanks, but
1364 no thanks... */
1365 if (dip -> at_name != NULL
1366 && *dip -> at_name != '~'
1367 && *dip -> at_name != '.')
35f5886e 1368 {
715cafcb 1369 TYPE_NAME (type) = obconcat ("enum", " ", dip -> at_name);
35f5886e 1370 }
715cafcb 1371 if (dip -> at_byte_size != 0)
35f5886e
FF
1372 {
1373 TYPE_LENGTH (type) = dip -> at_byte_size;
35f5886e 1374 }
35f5886e
FF
1375 if ((scan = dip -> at_element_list) != NULL)
1376 {
768be6e1
FF
1377 if (dip -> short_element_list)
1378 {
1379 (void) memcpy (&stemp, scan, sizeof (stemp));
1380 listend = scan + stemp + sizeof (stemp);
1381 scan += sizeof (stemp);
1382 }
1383 else
1384 {
1385 (void) memcpy (&ltemp, scan, sizeof (ltemp));
1386 listend = scan + ltemp + sizeof (ltemp);
1387 scan += sizeof (ltemp);
1388 }
35f5886e
FF
1389 while (scan < listend)
1390 {
1391 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1392 new -> next = list;
1393 list = new;
1394 list -> field.type = NULL;
1395 list -> field.bitsize = 0;
1396 (void) memcpy (&list -> field.bitpos, scan, sizeof (long));
1397 scan += sizeof (long);
1398 list -> field.name = savestring (scan, strlen (scan));
1399 scan += strlen (scan) + 1;
1400 nfields++;
715cafcb
FF
1401 /* Handcraft a new symbol for this enum member. */
1402 sym = (struct symbol *) obstack_alloc (symbol_obstack,
1403 sizeof (struct symbol));
1404 (void) memset (sym, 0, sizeof (struct symbol));
1405 SYMBOL_NAME (sym) = create_name (list -> field.name, symbol_obstack);
1406 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1407 SYMBOL_CLASS (sym) = LOC_CONST;
1408 SYMBOL_TYPE (sym) = type;
1409 SYMBOL_VALUE (sym) = list -> field.bitpos;
1410 add_symbol_to_list (sym, &scope -> symbols);
35f5886e
FF
1411 }
1412 }
98618bf7
FF
1413 /* Now create the vector of fields, and record how big it is. This is where
1414 we reverse the order, by pulling the members of the list in reverse order
1415 from how they were inserted. */
35f5886e
FF
1416 TYPE_NFIELDS (type) = nfields;
1417 TYPE_FIELDS (type) = (struct field *)
1418 obstack_alloc (symbol_obstack, sizeof (struct field) * nfields);
1419 /* Copy the saved-up fields into the field vector. */
98618bf7 1420 for (n = 0; (n < nfields) && (list != NULL); list = list -> next)
35f5886e 1421 {
98618bf7 1422 TYPE_FIELD (type, n++) = list -> field;
35f5886e
FF
1423 }
1424 return (type);
1425}
1426
1427/*
1428
1429LOCAL FUNCTION
1430
1431 read_func_scope -- process all dies within a function scope
1432
35f5886e
FF
1433DESCRIPTION
1434
1435 Process all dies within a given function scope. We are passed
1436 a die information structure pointer DIP for the die which
1437 starts the function scope, and pointers into the raw die data
1438 that define the dies within the function scope.
1439
1440 For now, we ignore lexical block scopes within the function.
1441 The problem is that AT&T cc does not define a DWARF lexical
1442 block scope for the function itself, while gcc defines a
1443 lexical block scope for the function. We need to think about
1444 how to handle this difference, or if it is even a problem.
1445 (FIXME)
1446 */
1447
1448static void
a048c8f5 1449DEFUN(read_func_scope, (dip, thisdie, enddie, objfile),
35f5886e
FF
1450 struct dieinfo *dip AND
1451 char *thisdie AND
a048c8f5
JG
1452 char *enddie AND
1453 struct objfile *objfile)
35f5886e
FF
1454{
1455 struct symbol *sym;
1456
1457 if (entry_point >= dip -> at_low_pc && entry_point < dip -> at_high_pc)
1458 {
1459 entry_scope_lowpc = dip -> at_low_pc;
1460 entry_scope_highpc = dip -> at_high_pc;
1461 }
1462 if (strcmp (dip -> at_name, "main") == 0) /* FIXME: hardwired name */
1463 {
1464 main_scope_lowpc = dip -> at_low_pc;
1465 main_scope_highpc = dip -> at_high_pc;
1466 }
1467 sym = new_symbol (dip);
1468 openscope (sym, dip -> at_low_pc, dip -> at_high_pc);
a048c8f5 1469 process_dies (thisdie + dip -> dielength, enddie, objfile);
35f5886e
FF
1470 closescope ();
1471}
1472
1473/*
1474
1475LOCAL FUNCTION
1476
1477 read_file_scope -- process all dies within a file scope
1478
35f5886e
FF
1479DESCRIPTION
1480
1481 Process all dies within a given file scope. We are passed a
1482 pointer to the die information structure for the die which
1483 starts the file scope, and pointers into the raw die data which
1484 mark the range of dies within the file scope.
1485
1486 When the partial symbol table is built, the file offset for the line
1487 number table for each compilation unit is saved in the partial symbol
1488 table entry for that compilation unit. As the symbols for each
1489 compilation unit are read, the line number table is read into memory
1490 and the variable lnbase is set to point to it. Thus all we have to
1491 do is use lnbase to access the line number table for the current
1492 compilation unit.
1493 */
1494
1495static void
a048c8f5 1496DEFUN(read_file_scope, (dip, thisdie, enddie, objfile),
35f5886e
FF
1497 struct dieinfo *dip AND
1498 char *thisdie AND
a048c8f5
JG
1499 char *enddie AND
1500 struct objfile *objfile)
35f5886e
FF
1501{
1502 struct cleanup *back_to;
1503
1504 if (entry_point >= dip -> at_low_pc && entry_point < dip -> at_high_pc)
1505 {
1506 startup_file_start = dip -> at_low_pc;
1507 startup_file_end = dip -> at_high_pc;
1508 }
1509 numutypes = (enddie - thisdie) / 4;
1510 utypes = (struct type **) xmalloc (numutypes * sizeof (struct type *));
1511 back_to = make_cleanup (free, utypes);
1512 (void) memset (utypes, 0, numutypes * sizeof (struct type *));
1513 start_symtab ();
1514 openscope (NULL, dip -> at_low_pc, dip -> at_high_pc);
1515 decode_line_numbers (lnbase);
a048c8f5 1516 process_dies (thisdie + dip -> dielength, enddie, objfile);
35f5886e 1517 closescope ();
a048c8f5 1518 end_symtab (dip -> at_name, dip -> at_language, objfile);
35f5886e
FF
1519 do_cleanups (back_to);
1520 utypes = NULL;
1521 numutypes = 0;
1522}
1523
1524/*
1525
1526LOCAL FUNCTION
1527
1528 start_symtab -- do initialization for starting new symbol table
1529
1530SYNOPSIS
1531
1532 static void start_symtab (void)
1533
1534DESCRIPTION
1535
1536 Called whenever we are starting to process dies for a new
1537 compilation unit, to perform initializations. Right now
1538 the only thing we really have to do is initialize storage
1539 space for the line number vector.
1540
1541 */
1542
1543static void
1544DEFUN_VOID (start_symtab)
1545{
1546 int nbytes;
1547
1548 line_vector_index = 0;
1549 line_vector_length = 1000;
1550 nbytes = sizeof (struct linetable);
1551 nbytes += line_vector_length * sizeof (struct linetable_entry);
1552 line_vector = (struct linetable *) xmalloc (nbytes);
1553}
1554
1555/*
1556
1557LOCAL FUNCTION
1558
1559 process_dies -- process a range of DWARF Information Entries
1560
1561SYNOPSIS
1562
8b5b6fae
FF
1563 static void process_dies (char *thisdie, char *enddie,
1564 struct objfile *objfile)
35f5886e
FF
1565
1566DESCRIPTION
1567
1568 Process all DIE's in a specified range. May be (and almost
1569 certainly will be) called recursively.
1570 */
1571
1572static void
a048c8f5
JG
1573DEFUN(process_dies, (thisdie, enddie, objfile),
1574 char *thisdie AND char *enddie AND struct objfile *objfile)
35f5886e
FF
1575{
1576 char *nextdie;
1577 struct dieinfo di;
1578
1579 while (thisdie < enddie)
1580 {
1581 basicdieinfo (&di, thisdie);
1582 if (di.dielength < sizeof (long))
1583 {
1584 break;
1585 }
1586 else if (di.dietag == TAG_padding)
1587 {
1588 nextdie = thisdie + di.dielength;
1589 }
1590 else
1591 {
1592 completedieinfo (&di);
1593 if (di.at_sibling != 0)
1594 {
1595 nextdie = dbbase + di.at_sibling - dbroff;
1596 }
1597 else
1598 {
1599 nextdie = thisdie + di.dielength;
1600 }
1601 switch (di.dietag)
1602 {
1603 case TAG_compile_unit:
a048c8f5 1604 read_file_scope (&di, thisdie, nextdie, objfile);
35f5886e
FF
1605 break;
1606 case TAG_global_subroutine:
1607 case TAG_subroutine:
2d6186f4 1608 if (di.has_at_low_pc)
35f5886e 1609 {
a048c8f5 1610 read_func_scope (&di, thisdie, nextdie, objfile);
35f5886e
FF
1611 }
1612 break;
1613 case TAG_lexical_block:
a048c8f5 1614 read_lexical_block_scope (&di, thisdie, nextdie, objfile);
35f5886e
FF
1615 break;
1616 case TAG_structure_type:
1617 case TAG_union_type:
8b5b6fae 1618 read_structure_scope (&di, thisdie, nextdie, objfile);
35f5886e
FF
1619 break;
1620 case TAG_enumeration_type:
1621 read_enumeration (&di, thisdie, nextdie);
1622 break;
1623 case TAG_subroutine_type:
1624 read_subroutine_type (&di, thisdie, nextdie);
1625 break;
1626 case TAG_array_type:
1627 read_array_type (&di);
1628 break;
1629 default:
1630 (void) new_symbol (&di);
1631 break;
1632 }
1633 }
1634 thisdie = nextdie;
1635 }
1636}
1637
1638/*
1639
1640LOCAL FUNCTION
1641
1642 end_symtab -- finish processing for a compilation unit
1643
1644SYNOPSIS
1645
1646 static void end_symtab (char *filename, long language)
1647
1648DESCRIPTION
1649
1650 Complete the symbol table entry for the current compilation
1651 unit. Make the struct symtab and put it on the list of all
1652 such symtabs.
1653
1654 */
1655
1656static void
a048c8f5
JG
1657DEFUN(end_symtab, (filename, language, objfile),
1658 char *filename AND long language AND struct objfile *objfile)
35f5886e
FF
1659{
1660 struct symtab *symtab;
1661 struct blockvector *blockvector;
1662 int nbytes;
1663
1664 /* Ignore a file that has no functions with real debugging info. */
1665 if (global_symbols == NULL && scopetree -> block == NULL)
1666 {
1667 free (line_vector);
1668 line_vector = NULL;
1669 line_vector_length = -1;
1670 freescope (scopetree);
1671 scope = scopetree = NULL;
1672 }
1673
1674 /* Create the blockvector that points to all the file's blocks. */
1675
1676 blockvector = make_blockvector ();
1677
1678 /* Now create the symtab object for this source file. */
1679
a048c8f5
JG
1680 symtab = allocate_symtab (savestring (filename, strlen (filename)),
1681 objfile);
35f5886e
FF
1682
1683 symtab -> free_ptr = 0;
1684
1685 /* Fill in its components. */
1686 symtab -> blockvector = blockvector;
1687 symtab -> free_code = free_linetable;
35f5886e
FF
1688
1689 /* Save the line number information. */
1690
1691 line_vector -> nitems = line_vector_index;
1692 nbytes = sizeof (struct linetable);
1693 if (line_vector_index > 1)
1694 {
1695 nbytes += (line_vector_index - 1) * sizeof (struct linetable_entry);
1696 }
1697 symtab -> linetable = (struct linetable *) xrealloc (line_vector, nbytes);
35f5886e
FF
1698
1699 /* FIXME: The following may need to be expanded for other languages */
545af6ce 1700 switch (language)
35f5886e 1701 {
545af6ce
PB
1702 case LANG_C89:
1703 case LANG_C:
1704 symtab -> language = language_c;
1705 break;
1706 case LANG_C_PLUS_PLUS:
1707 symtab -> language = language_cplus;
1708 break;
1709 default:
1710 ;
35f5886e 1711 }
545af6ce 1712
35f5886e
FF
1713 /* Link the new symtab into the list of such. */
1714 symtab -> next = symtab_list;
1715 symtab_list = symtab;
1716
1717 /* Recursively free the scope tree */
1718 freescope (scopetree);
1719 scope = scopetree = NULL;
1720
1721 /* Reinitialize for beginning of new file. */
1722 line_vector = 0;
1723 line_vector_length = -1;
1724}
1725
1726/*
1727
1728LOCAL FUNCTION
1729
1730 scopecount -- count the number of enclosed scopes
1731
1732SYNOPSIS
1733
1734 static int scopecount (struct scopenode *node)
1735
1736DESCRIPTION
1737
1738 Given pointer to a node, compute the size of the subtree which is
1739 rooted in this node, which also happens to be the number of scopes
1740 to the subtree.
1741 */
1742
1743static int
1744DEFUN(scopecount, (node), struct scopenode *node)
1745{
1746 int count = 0;
1747
1748 if (node != NULL)
1749 {
1750 count += scopecount (node -> child);
1751 count += scopecount (node -> sibling);
1752 count++;
1753 }
1754 return (count);
1755}
1756
1757/*
1758
1759LOCAL FUNCTION
1760
1761 openscope -- start a new lexical block scope
1762
1763SYNOPSIS
1764
1765 static void openscope (struct symbol *namesym, CORE_ADDR lowpc,
1766 CORE_ADDR highpc)
1767
1768DESCRIPTION
1769
1770 Start a new scope by allocating a new scopenode, adding it as the
1771 next child of the current scope (if any) or as the root of the
1772 scope tree, and then making the new node the current scope node.
1773 */
1774
1775static void
1776DEFUN(openscope, (namesym, lowpc, highpc),
1777 struct symbol *namesym AND
1778 CORE_ADDR lowpc AND
1779 CORE_ADDR highpc)
1780{
1781 struct scopenode *new;
1782 struct scopenode *child;
1783
1784 new = (struct scopenode *) xmalloc (sizeof (*new));
1785 (void) memset (new, 0, sizeof (*new));
1786 new -> namesym = namesym;
1787 new -> lowpc = lowpc;
1788 new -> highpc = highpc;
1789 if (scope == NULL)
1790 {
1791 scopetree = new;
1792 }
1793 else if ((child = scope -> child) == NULL)
1794 {
1795 scope -> child = new;
1796 new -> parent = scope;
1797 }
1798 else
1799 {
1800 while (child -> sibling != NULL)
1801 {
1802 child = child -> sibling;
1803 }
1804 child -> sibling = new;
1805 new -> parent = scope;
1806 }
1807 scope = new;
1808}
1809
1810/*
1811
1812LOCAL FUNCTION
1813
1814 freescope -- free a scope tree rooted at the given node
1815
1816SYNOPSIS
1817
1818 static void freescope (struct scopenode *node)
1819
1820DESCRIPTION
1821
1822 Given a pointer to a node in the scope tree, free the subtree
1823 rooted at that node. First free all the children and sibling
1824 nodes, and then the node itself. Used primarily for cleaning
1825 up after ourselves and returning memory to the system.
1826 */
1827
1828static void
1829DEFUN(freescope, (node), struct scopenode *node)
1830{
1831 if (node != NULL)
1832 {
1833 freescope (node -> child);
1834 freescope (node -> sibling);
1835 free (node);
1836 }
1837}
1838
1839/*
1840
1841LOCAL FUNCTION
1842
1843 buildblock -- build a new block from pending symbols list
1844
1845SYNOPSIS
1846
1847 static struct block *buildblock (struct pending_symbol *syms)
1848
1849DESCRIPTION
1850
1851 Given a pointer to a list of symbols, build a new block and free
1852 the symbol list structure. Also check each symbol to see if it
1853 is the special symbol that flags that this block was compiled by
1854 gcc, and if so, mark the block appropriately.
1855 */
1856
1857static struct block *
1858DEFUN(buildblock, (syms), struct pending_symbol *syms)
1859{
1860 struct pending_symbol *next, *next1;
1861 int i;
1862 struct block *newblock;
1863 int nbytes;
1864
1865 for (next = syms, i = 0 ; next ; next = next -> next, i++) {;}
1866
1867 /* Allocate a new block */
1868
1869 nbytes = sizeof (struct block);
1870 if (i > 1)
1871 {
1872 nbytes += (i - 1) * sizeof (struct symbol *);
1873 }
1874 newblock = (struct block *) obstack_alloc (symbol_obstack, nbytes);
1875 (void) memset (newblock, 0, nbytes);
1876
1877 /* Copy the symbols into the block. */
1878
1879 BLOCK_NSYMS (newblock) = i;
1880 for (next = syms ; next ; next = next -> next)
1881 {
1882 BLOCK_SYM (newblock, --i) = next -> symbol;
1883 if (STREQ (GCC_COMPILED_FLAG_SYMBOL, SYMBOL_NAME (next -> symbol)) ||
1884 STREQ (GCC2_COMPILED_FLAG_SYMBOL, SYMBOL_NAME (next -> symbol)))
1885 {
1886 BLOCK_GCC_COMPILED (newblock) = 1;
1887 }
1888 }
1889
1890 /* Now free the links of the list, and empty the list. */
1891
1892 for (next = syms ; next ; next = next1)
1893 {
1894 next1 = next -> next;
1895 free (next);
1896 }
1897
1898 return (newblock);
1899}
1900
1901/*
1902
1903LOCAL FUNCTION
1904
1905 closescope -- close a lexical block scope
1906
1907SYNOPSIS
1908
1909 static void closescope (void)
1910
1911DESCRIPTION
1912
1913 Close the current lexical block scope. Closing the current scope
1914 is as simple as moving the current scope pointer up to the parent
1915 of the current scope pointer. But we also take this opportunity
1916 to build the block for the current scope first, since we now have
1917 all of it's symbols.
1918 */
1919
1920static void
1921DEFUN_VOID(closescope)
1922{
1923 struct scopenode *child;
1924
1925 if (scope == NULL)
1926 {
1927 error ("DWARF parse error, too many close scopes");
1928 }
1929 else
1930 {
1931 if (scope -> parent == NULL)
1932 {
1933 global_symbol_block = buildblock (global_symbols);
1934 global_symbols = NULL;
1935 BLOCK_START (global_symbol_block) = scope -> lowpc + baseaddr;
1936 BLOCK_END (global_symbol_block) = scope -> highpc + baseaddr;
1937 }
1938 scope -> block = buildblock (scope -> symbols);
1939 scope -> symbols = NULL;
1940 BLOCK_START (scope -> block) = scope -> lowpc + baseaddr;
1941 BLOCK_END (scope -> block) = scope -> highpc + baseaddr;
1942
1943 /* Put the local block in as the value of the symbol that names it. */
1944
1945 if (scope -> namesym)
1946 {
1947 SYMBOL_BLOCK_VALUE (scope -> namesym) = scope -> block;
1948 BLOCK_FUNCTION (scope -> block) = scope -> namesym;
1949 }
1950
1951 /* Install this scope's local block as the superblock of all child
1952 scope blocks. */
1953
1954 for (child = scope -> child ; child ; child = child -> sibling)
1955 {
1956 BLOCK_SUPERBLOCK (child -> block) = scope -> block;
1957 }
1958
1959 scope = scope -> parent;
1960 }
1961}
1962
1963/*
1964
1965LOCAL FUNCTION
1966
1967 record_line -- record a line number entry in the line vector
1968
1969SYNOPSIS
1970
1971 static void record_line (int line, CORE_ADDR pc)
1972
1973DESCRIPTION
1974
1975 Given a line number and the corresponding pc value, record
1976 this pair in the line number vector, expanding the vector as
1977 necessary.
1978 */
1979
1980static void
1981DEFUN(record_line, (line, pc), int line AND CORE_ADDR pc)
1982{
1983 struct linetable_entry *e;
1984 int nbytes;
1985
1986 /* Make sure line vector is big enough. */
1987
1988 if (line_vector_index + 2 >= line_vector_length)
1989 {
1990 line_vector_length *= 2;
1991 nbytes = sizeof (struct linetable);
1992 nbytes += (line_vector_length * sizeof (struct linetable_entry));
1993 line_vector = (struct linetable *) xrealloc (line_vector, nbytes);
1994 }
1995 e = line_vector -> item + line_vector_index++;
1996 e -> line = line;
1997 e -> pc = pc;
1998}
1999
2000/*
2001
2002LOCAL FUNCTION
2003
2004 decode_line_numbers -- decode a line number table fragment
2005
2006SYNOPSIS
2007
2008 static void decode_line_numbers (char *tblscan, char *tblend,
2009 long length, long base, long line, long pc)
2010
2011DESCRIPTION
2012
2013 Translate the DWARF line number information to gdb form.
2014
2015 The ".line" section contains one or more line number tables, one for
2016 each ".line" section from the objects that were linked.
2017
2018 The AT_stmt_list attribute for each TAG_source_file entry in the
2019 ".debug" section contains the offset into the ".line" section for the
2020 start of the table for that file.
2021
2022 The table itself has the following structure:
2023
2024 <table length><base address><source statement entry>
2025 4 bytes 4 bytes 10 bytes
2026
2027 The table length is the total size of the table, including the 4 bytes
2028 for the length information.
2029
2030 The base address is the address of the first instruction generated
2031 for the source file.
2032
2033 Each source statement entry has the following structure:
2034
2035 <line number><statement position><address delta>
2036 4 bytes 2 bytes 4 bytes
2037
2038 The line number is relative to the start of the file, starting with
2039 line 1.
2040
2041 The statement position either -1 (0xFFFF) or the number of characters
2042 from the beginning of the line to the beginning of the statement.
2043
2044 The address delta is the difference between the base address and
2045 the address of the first instruction for the statement.
2046
2047 Note that we must copy the bytes from the packed table to our local
2048 variables before attempting to use them, to avoid alignment problems
2049 on some machines, particularly RISC processors.
2050
2051BUGS
2052
2053 Does gdb expect the line numbers to be sorted? They are now by
2054 chance/luck, but are not required to be. (FIXME)
2055
2056 The line with number 0 is unused, gdb apparently can discover the
2057 span of the last line some other way. How? (FIXME)
2058 */
2059
2060static void
2061DEFUN(decode_line_numbers, (linetable), char *linetable)
2062{
2063 char *tblscan;
2064 char *tblend;
2065 long length;
2066 long base;
2067 long line;
2068 long pc;
2069
2070 if (linetable != NULL)
2071 {
2072 tblscan = tblend = linetable;
2073 (void) memcpy (&length, tblscan, sizeof (long));
2074 tblscan += sizeof (long);
2075 tblend += length;
2076 (void) memcpy (&base, tblscan, sizeof (long));
2077 base += baseaddr;
2078 tblscan += sizeof (long);
2079 while (tblscan < tblend)
2080 {
2081 (void) memcpy (&line, tblscan, sizeof (long));
2082 tblscan += sizeof (long) + sizeof (short);
2083 (void) memcpy (&pc, tblscan, sizeof (long));
2084 tblscan += sizeof (long);
2085 pc += base;
2086 if (line > 0)
2087 {
2088 record_line (line, pc);
2089 }
2090 }
2091 }
2092}
2093
2094/*
2095
2096LOCAL FUNCTION
2097
2098 add_symbol_to_list -- add a symbol to head of current symbol list
2099
2100SYNOPSIS
2101
2102 static void add_symbol_to_list (struct symbol *symbol, struct
2103 pending_symbol **listhead)
2104
2105DESCRIPTION
2106
2107 Given a pointer to a symbol and a pointer to a pointer to a
2108 list of symbols, add this symbol as the current head of the
2109 list. Typically used for example to add a symbol to the
2110 symbol list for the current scope.
2111
2112 */
2113
2114static void
2115DEFUN(add_symbol_to_list, (symbol, listhead),
2116 struct symbol *symbol AND struct pending_symbol **listhead)
2117{
2118 struct pending_symbol *link;
2119
2120 if (symbol != NULL)
2121 {
2122 link = (struct pending_symbol *) xmalloc (sizeof (*link));
2123 link -> next = *listhead;
2124 link -> symbol = symbol;
2125 *listhead = link;
2126 }
2127}
2128
2129/*
2130
2131LOCAL FUNCTION
2132
2133 gatherblocks -- walk a scope tree and build block vectors
2134
2135SYNOPSIS
2136
2137 static struct block **gatherblocks (struct block **dest,
2138 struct scopenode *node)
2139
2140DESCRIPTION
2141
2142 Recursively walk a scope tree rooted in the given node, adding blocks
2143 to the array pointed to by DEST, in preorder. I.E., first we add the
2144 block for the current scope, then all the blocks for child scopes,
2145 and finally all the blocks for sibling scopes.
2146 */
2147
2148static struct block **
2149DEFUN(gatherblocks, (dest, node),
2150 struct block **dest AND struct scopenode *node)
2151{
2152 if (node != NULL)
2153 {
2154 *dest++ = node -> block;
2155 dest = gatherblocks (dest, node -> child);
2156 dest = gatherblocks (dest, node -> sibling);
2157 }
2158 return (dest);
2159}
2160
2161/*
2162
2163LOCAL FUNCTION
2164
2165 make_blockvector -- make a block vector from current scope tree
2166
2167SYNOPSIS
2168
2169 static struct blockvector *make_blockvector (void)
2170
2171DESCRIPTION
2172
2173 Make a blockvector from all the blocks in the current scope tree.
2174 The first block is always the global symbol block, followed by the
2175 block for the root of the scope tree which is the local symbol block,
2176 followed by all the remaining blocks in the scope tree, which are all
2177 local scope blocks.
2178
2179NOTES
2180
2181 Note that since the root node of the scope tree is created at the time
2182 each file scope is entered, there are always at least two blocks,
2183 neither of which may have any symbols, but always contribute a block
2184 to the block vector. So the test for number of blocks greater than 1
2185 below is unnecessary given bug free code.
2186
2187 The resulting block structure varies slightly from that produced
2188 by dbxread.c, in that block 0 and block 1 are sibling blocks while
2189 with dbxread.c, block 1 is a child of block 0. This does not
2190 seem to cause any problems, but probably should be fixed. (FIXME)
2191 */
2192
2193static struct blockvector *
2194DEFUN_VOID(make_blockvector)
2195{
2196 struct blockvector *blockvector = NULL;
2197 int i;
2198 int nbytes;
2199
2200 /* Recursively walk down the tree, counting the number of blocks.
2201 Then add one to account for the global's symbol block */
2202
2203 i = scopecount (scopetree) + 1;
2204 nbytes = sizeof (struct blockvector);
2205 if (i > 1)
2206 {
2207 nbytes += (i - 1) * sizeof (struct block *);
2208 }
2209 blockvector = (struct blockvector *)
2210 obstack_alloc (symbol_obstack, nbytes);
2211
2212 /* Copy the blocks into the blockvector. */
2213
2214 BLOCKVECTOR_NBLOCKS (blockvector) = i;
2215 BLOCKVECTOR_BLOCK (blockvector, 0) = global_symbol_block;
2216 gatherblocks (&BLOCKVECTOR_BLOCK (blockvector, 1), scopetree);
2217
2218 return (blockvector);
2219}
2220
2221/*
2222
2223LOCAL FUNCTION
2224
2225 locval -- compute the value of a location attribute
2226
2227SYNOPSIS
2228
2229 static int locval (char *loc)
2230
2231DESCRIPTION
2232
2233 Given pointer to a string of bytes that define a location, compute
2234 the location and return the value.
2235
2236 When computing values involving the current value of the frame pointer,
2237 the value zero is used, which results in a value relative to the frame
2238 pointer, rather than the absolute value. This is what GDB wants
2239 anyway.
2240
2241 When the result is a register number, the global isreg flag is set,
2242 otherwise it is cleared. This is a kludge until we figure out a better
2243 way to handle the problem. Gdb's design does not mesh well with the
2244 DWARF notion of a location computing interpreter, which is a shame
2245 because the flexibility goes unused.
2246
2247NOTES
2248
2249 Note that stack[0] is unused except as a default error return.
2250 Note that stack overflow is not yet handled.
2251 */
2252
2253static int
2254DEFUN(locval, (loc), char *loc)
2255{
2256 unsigned short nbytes;
2257 auto int stack[64];
2258 int stacki;
2259 char *end;
2260 long regno;
2261
2262 (void) memcpy (&nbytes, loc, sizeof (short));
2263 end = loc + sizeof (short) + nbytes;
2264 stacki = 0;
2265 stack[stacki] = 0;
2266 isreg = 0;
2267 for (loc += sizeof (short); loc < end; loc += sizeof (long))
2268 {
2269 switch (*loc++) {
2270 case 0:
2271 /* error */
2272 loc = end;
2273 break;
2274 case OP_REG:
2275 /* push register (number) */
2276 (void) memcpy (&stack[++stacki], loc, sizeof (long));
2277 isreg = 1;
2278 break;
2279 case OP_BASEREG:
2280 /* push value of register (number) */
2281 /* Actually, we compute the value as if register has 0 */
2282 (void) memcpy (&regno, loc, sizeof (long));
2283 if (regno == R_FP)
2284 {
2285 stack[++stacki] = 0;
2286 }
2287 else
2288 {
2289 stack[++stacki] = 0;
2290 SQUAWK (("BASEREG %d not handled!", regno));
2291 }
2292 break;
2293 case OP_ADDR:
2294 /* push address (relocated address) */
2295 (void) memcpy (&stack[++stacki], loc, sizeof (long));
2296 break;
2297 case OP_CONST:
2298 /* push constant (number) */
2299 (void) memcpy (&stack[++stacki], loc, sizeof (long));
2300 break;
2301 case OP_DEREF2:
2302 /* pop, deref and push 2 bytes (as a long) */
2303 SQUAWK (("OP_DEREF2 address %#x not handled", stack[stacki]));
2304 break;
2305 case OP_DEREF4: /* pop, deref and push 4 bytes (as a long) */
2306 SQUAWK (("OP_DEREF4 address %#x not handled", stack[stacki]));
2307 break;
2308 case OP_ADD: /* pop top 2 items, add, push result */
2309 stack[stacki - 1] += stack[stacki];
2310 stacki--;
2311 break;
2312 }
2313 }
2314 return (stack[stacki]);
2315}
2316
2317/*
2318
2319LOCAL FUNCTION
2320
2321 read_ofile_symtab -- build a full symtab entry from chunk of DIE's
2322
2323SYNOPSIS
2324
a048c8f5 2325 static struct symtab *read_ofile_symtab (struct partial_symtab *pst)
35f5886e
FF
2326
2327DESCRIPTION
2328
a048c8f5 2329 OFFSET is a relocation offset which gets added to each symbol (FIXME).
35f5886e
FF
2330 */
2331
2332static struct symtab *
a048c8f5
JG
2333DEFUN(read_ofile_symtab, (pst),
2334 struct partial_symtab *pst)
35f5886e
FF
2335{
2336 struct cleanup *back_to;
2337 long lnsize;
2338 int foffset;
a048c8f5 2339 bfd *abfd = pst->objfile->obfd;
35f5886e
FF
2340
2341 /* Allocate a buffer for the entire chunk of DIE's for this compilation
2342 unit, seek to the location in the file, and read in all the DIE's. */
2343
2344 diecount = 0;
2345 dbbase = xmalloc (DBLENGTH(pst));
2346 dbroff = DBROFF(pst);
2347 foffset = DBFOFF(pst) + dbroff;
a048c8f5
JG
2348 if (bfd_seek (abfd, foffset, 0) ||
2349 (bfd_read (dbbase, DBLENGTH(pst), 1, abfd) != DBLENGTH(pst)))
35f5886e
FF
2350 {
2351 free (dbbase);
2352 error ("can't read DWARF data");
2353 }
2354 back_to = make_cleanup (free, dbbase);
2355
2356 /* If there is a line number table associated with this compilation unit
2357 then read the first long word from the line number table fragment, which
2358 contains the size of the fragment in bytes (including the long word
2359 itself). Allocate a buffer for the fragment and read it in for future
2360 processing. */
2361
2362 lnbase = NULL;
2363 if (LNFOFF (pst))
2364 {
a048c8f5
JG
2365 if (bfd_seek (abfd, LNFOFF (pst), 0) ||
2366 (bfd_read (&lnsize, sizeof(long), 1, abfd) != sizeof(long)))
35f5886e
FF
2367 {
2368 error ("can't read DWARF line number table size");
2369 }
2370 lnbase = xmalloc (lnsize);
a048c8f5
JG
2371 if (bfd_seek (abfd, LNFOFF (pst), 0) ||
2372 (bfd_read (lnbase, lnsize, 1, abfd) != lnsize))
35f5886e
FF
2373 {
2374 free (lnbase);
2375 error ("can't read DWARF line numbers");
2376 }
2377 make_cleanup (free, lnbase);
2378 }
2379
a048c8f5 2380 process_dies (dbbase, dbbase + DBLENGTH(pst), pst->objfile);
35f5886e
FF
2381 do_cleanups (back_to);
2382 return (symtab_list);
2383}
2384
2385/*
2386
2387LOCAL FUNCTION
2388
2389 psymtab_to_symtab_1 -- do grunt work for building a full symtab entry
2390
2391SYNOPSIS
2392
a048c8f5 2393 static void psymtab_to_symtab_1 (struct partial_symtab *pst)
35f5886e
FF
2394
2395DESCRIPTION
2396
2397 Called once for each partial symbol table entry that needs to be
2398 expanded into a full symbol table entry.
2399
2400*/
2401
2402static void
2403DEFUN(psymtab_to_symtab_1,
a048c8f5
JG
2404 (pst),
2405 struct partial_symtab *pst)
35f5886e
FF
2406{
2407 int i;
2408
2409 if (!pst)
2410 {
2411 return;
2412 }
2413 if (pst->readin)
2414 {
2415 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
2416 pst -> filename);
2417 return;
2418 }
2419
2420 /* Read in all partial symtabs on which this one is dependent */
2421 for (i = 0; i < pst -> number_of_dependencies; i++)
2422 if (!pst -> dependencies[i] -> readin)
2423 {
2424 /* Inform about additional files that need to be read in. */
2425 if (info_verbose)
2426 {
2427 fputs_filtered (" ", stdout);
2428 wrap_here ("");
2429 fputs_filtered ("and ", stdout);
2430 wrap_here ("");
2431 printf_filtered ("%s...", pst -> dependencies[i] -> filename);
2432 wrap_here (""); /* Flush output */
2433 fflush (stdout);
2434 }
a048c8f5 2435 psymtab_to_symtab_1 (pst -> dependencies[i]);
35f5886e
FF
2436 }
2437
2438 if (DBLENGTH(pst)) /* Otherwise it's a dummy */
2439 {
2440 /* Init stuff necessary for reading in symbols */
a048c8f5 2441 pst -> symtab = read_ofile_symtab (pst);
35f5886e
FF
2442 if (info_verbose)
2443 {
2444 printf_filtered ("%d DIE's, sorting...", diecount);
2445 fflush (stdout);
2446 }
2447 sort_symtab_syms (pst -> symtab);
2448 }
2449 pst -> readin = 1;
2450}
2451
2452/*
2453
2454LOCAL FUNCTION
2455
2456 dwarf_psymtab_to_symtab -- build a full symtab entry from partial one
2457
2458SYNOPSIS
2459
2460 static void dwarf_psymtab_to_symtab (struct partial_symtab *pst)
2461
2462DESCRIPTION
2463
2464 This is the DWARF support entry point for building a full symbol
2465 table entry from a partial symbol table entry. We are passed a
2466 pointer to the partial symbol table entry that needs to be expanded.
2467
2468*/
2469
2470static void
2471DEFUN(dwarf_psymtab_to_symtab, (pst), struct partial_symtab *pst)
2472{
7d9884b9 2473
35f5886e
FF
2474 if (!pst)
2475 {
2476 return;
2477 }
2478 if (pst -> readin)
2479 {
2480 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
2481 pst -> filename);
2482 return;
2483 }
2484
2485 if (DBLENGTH(pst) || pst -> number_of_dependencies)
2486 {
2487 /* Print the message now, before starting serious work, to avoid
2488 disconcerting pauses. */
2489 if (info_verbose)
2490 {
2491 printf_filtered ("Reading in symbols for %s...", pst -> filename);
2492 fflush (stdout);
2493 }
2494
a048c8f5 2495 psymtab_to_symtab_1 (pst);
35f5886e
FF
2496
2497#if 0 /* FIXME: Check to see what dbxread is doing here and see if
2498 we need to do an equivalent or is this something peculiar to
2499 stabs/a.out format. */
2500 /* Match with global symbols. This only needs to be done once,
2501 after all of the symtabs and dependencies have been read in. */
2502 scan_file_globals ();
2503#endif
2504
35f5886e
FF
2505 /* Finish up the debug error message. */
2506 if (info_verbose)
2507 {
2508 printf_filtered ("done.\n");
2509 }
2510 }
2511}
2512
2513/*
2514
2515LOCAL FUNCTION
2516
2517 init_psymbol_list -- initialize storage for partial symbols
2518
2519SYNOPSIS
2520
2521 static void init_psymbol_list (int total_symbols)
2522
2523DESCRIPTION
2524
2525 Initializes storage for all of the partial symbols that will be
2526 created by dwarf_build_psymtabs and subsidiaries.
2527 */
2528
2529static void
2530DEFUN(init_psymbol_list, (total_symbols), int total_symbols)
2531{
2532 /* Free any previously allocated psymbol lists. */
2533
2534 if (global_psymbols.list)
2535 {
2536 free (global_psymbols.list);
2537 }
2538 if (static_psymbols.list)
2539 {
2540 free (static_psymbols.list);
2541 }
2542
2543 /* Current best guess is that there are approximately a twentieth
2544 of the total symbols (in a debugging file) are global or static
2545 oriented symbols */
2546
2547 global_psymbols.size = total_symbols / 10;
2548 static_psymbols.size = total_symbols / 10;
2549 global_psymbols.next = global_psymbols.list = (struct partial_symbol *)
2550 xmalloc (global_psymbols.size * sizeof (struct partial_symbol));
2551 static_psymbols.next = static_psymbols.list = (struct partial_symbol *)
2552 xmalloc (static_psymbols.size * sizeof (struct partial_symbol));
2553}
2554
2555/*
2556
2557LOCAL FUNCTION
2558
2559 start_psymtab -- allocate and partially fill a partial symtab entry
2560
2561DESCRIPTION
2562
2563 Allocate and partially fill a partial symtab. It will be completely
2564 filled at the end of the symbol list.
2565
2566 SYMFILE_NAME is the name of the symbol-file we are reading from, and
2567 ADDR is the address relative to which its symbols are (incremental)
2568 or 0 (normal). FILENAME is the name of the compilation unit that
2569 these symbols were defined in, and they appear starting a address
2570 TEXTLOW. DBROFF is the absolute file offset in SYMFILE_NAME where
2571 the full symbols can be read for compilation unit FILENAME.
2572 GLOBAL_SYMS and STATIC_SYMS are pointers to the current end of the
2573 psymtab vector.
2574
2575 */
2576
2577static struct partial_symtab *
2578DEFUN(start_psymtab,
a048c8f5 2579 (objfile, addr, filename, textlow, texthigh, dbfoff, curoff,
35f5886e 2580 culength, lnfoff, global_syms, static_syms),
a048c8f5 2581 struct objfile *objfile AND
35f5886e
FF
2582 CORE_ADDR addr AND
2583 char *filename AND
2584 CORE_ADDR textlow AND
2585 CORE_ADDR texthigh AND
2586 int dbfoff AND
2587 int curoff AND
2588 int culength AND
2589 int lnfoff AND
2590 struct partial_symbol *global_syms AND
2591 struct partial_symbol *static_syms)
2592{
2593 struct partial_symtab *result;
2594
2595 result = (struct partial_symtab *)
2596 obstack_alloc (psymbol_obstack, sizeof (struct partial_symtab));
2597 (void) memset (result, 0, sizeof (struct partial_symtab));
2598 result -> addr = addr;
a048c8f5 2599 result -> objfile = objfile;
35f5886e
FF
2600 result -> filename = create_name (filename, psymbol_obstack);
2601 result -> textlow = textlow;
2602 result -> texthigh = texthigh;
2603 result -> read_symtab_private = (char *) obstack_alloc (psymbol_obstack,
2604 sizeof (struct dwfinfo));
2605 DBFOFF (result) = dbfoff;
2606 DBROFF (result) = curoff;
2607 DBLENGTH (result) = culength;
2608 LNFOFF (result) = lnfoff;
2609 result -> readin = 0;
2610 result -> symtab = NULL;
2611 result -> read_symtab = dwarf_psymtab_to_symtab;
2612 result -> globals_offset = global_syms - global_psymbols.list;
2613 result -> statics_offset = static_syms - static_psymbols.list;
2614
2615 result->n_global_syms = 0;
2616 result->n_static_syms = 0;
2617
2618 return result;
2619}
2620
2621/*
2622
2623LOCAL FUNCTION
2624
2625 add_psymbol_to_list -- add a partial symbol to given list
2626
2627DESCRIPTION
2628
2629 Add a partial symbol to one of the partial symbol vectors (pointed to
2630 by listp). The vector is grown as necessary.
2631
2632 */
2633
2634static void
2635DEFUN(add_psymbol_to_list,
2636 (listp, name, space, class, value),
2637 struct psymbol_allocation_list *listp AND
2638 char *name AND
2639 enum namespace space AND
2640 enum address_class class AND
2641 CORE_ADDR value)
2642{
2643 struct partial_symbol *psym;
2644 int newsize;
2645
2646 if (listp -> next >= listp -> list + listp -> size)
2647 {
2648 newsize = listp -> size * 2;
2649 listp -> list = (struct partial_symbol *)
2650 xrealloc (listp -> list, (newsize * sizeof (struct partial_symbol)));
2651 /* Next assumes we only went one over. Should be good if program works
2652 correctly */
2653 listp -> next = listp -> list + listp -> size;
2654 listp -> size = newsize;
2655 }
2656 psym = listp -> next++;
2657 SYMBOL_NAME (psym) = create_name (name, psymbol_obstack);
2658 SYMBOL_NAMESPACE (psym) = space;
2659 SYMBOL_CLASS (psym) = class;
2660 SYMBOL_VALUE (psym) = value;
2661}
2662
2663/*
2664
715cafcb
FF
2665LOCAL FUNCTION
2666
2667 add_enum_psymbol -- add enumeration members to partial symbol table
2668
2669DESCRIPTION
2670
2671 Given pointer to a DIE that is known to be for an enumeration,
2672 extract the symbolic names of the enumeration members and add
2673 partial symbols for them.
2674*/
2675
2676static void
2677DEFUN(add_enum_psymbol, (dip), struct dieinfo *dip)
2678{
2679 char *scan;
2680 char *listend;
2681 long ltemp;
2682 short stemp;
2683
2684 if ((scan = dip -> at_element_list) != NULL)
2685 {
2686 if (dip -> short_element_list)
2687 {
2688 (void) memcpy (&stemp, scan, sizeof (stemp));
2689 listend = scan + stemp + sizeof (stemp);
2690 scan += sizeof (stemp);
2691 }
2692 else
2693 {
2694 (void) memcpy (&ltemp, scan, sizeof (ltemp));
2695 listend = scan + ltemp + sizeof (ltemp);
2696 scan += sizeof (ltemp);
2697 }
2698 while (scan < listend)
2699 {
2700 scan += sizeof (long);
2701 add_psymbol_to_list (&static_psymbols, scan, VAR_NAMESPACE,
2702 LOC_CONST, 0);
2703 scan += strlen (scan) + 1;
2704 }
2705 }
2706}
2707
2708/*
2709
35f5886e
FF
2710LOCAL FUNCTION
2711
2712 add_partial_symbol -- add symbol to partial symbol table
2713
2714DESCRIPTION
2715
2716 Given a DIE, if it is one of the types that we want to
2717 add to a partial symbol table, finish filling in the die info
2718 and then add a partial symbol table entry for it.
2719
2720*/
2721
2722static void
2723DEFUN(add_partial_symbol, (dip), struct dieinfo *dip)
2724{
2725 switch (dip -> dietag)
2726 {
2727 case TAG_global_subroutine:
a7446af6 2728 record_misc_function (dip -> at_name, dip -> at_low_pc, mf_text);
35f5886e
FF
2729 add_psymbol_to_list (&global_psymbols, dip -> at_name, VAR_NAMESPACE,
2730 LOC_BLOCK, dip -> at_low_pc);
2731 break;
2732 case TAG_global_variable:
a7446af6
FF
2733 record_misc_function (dip -> at_name, locval (dip -> at_location),
2734 mf_data);
35f5886e
FF
2735 add_psymbol_to_list (&global_psymbols, dip -> at_name, VAR_NAMESPACE,
2736 LOC_STATIC, 0);
2737 break;
2738 case TAG_subroutine:
2739 add_psymbol_to_list (&static_psymbols, dip -> at_name, VAR_NAMESPACE,
2740 LOC_BLOCK, dip -> at_low_pc);
2741 break;
2742 case TAG_local_variable:
2743 add_psymbol_to_list (&static_psymbols, dip -> at_name, VAR_NAMESPACE,
2744 LOC_STATIC, 0);
2745 break;
2746 case TAG_typedef:
2747 add_psymbol_to_list (&static_psymbols, dip -> at_name, VAR_NAMESPACE,
2748 LOC_TYPEDEF, 0);
2749 break;
2750 case TAG_structure_type:
2751 case TAG_union_type:
35f5886e
FF
2752 add_psymbol_to_list (&static_psymbols, dip -> at_name, STRUCT_NAMESPACE,
2753 LOC_TYPEDEF, 0);
2754 break;
715cafcb
FF
2755 case TAG_enumeration_type:
2756 if (dip -> at_name)
2757 {
2758 add_psymbol_to_list (&static_psymbols, dip -> at_name,
2759 STRUCT_NAMESPACE, LOC_TYPEDEF, 0);
2760 }
2761 add_enum_psymbol (dip);
2762 break;
35f5886e
FF
2763 }
2764}
2765
2766/*
2767
2768LOCAL FUNCTION
2769
2770 scan_partial_symbols -- scan DIE's within a single compilation unit
2771
2772DESCRIPTION
2773
2774 Process the DIE's within a single compilation unit, looking for
2775 interesting DIE's that contribute to the partial symbol table entry
2776 for this compilation unit. Since we cannot follow any sibling
2777 chains without reading the complete DIE info for every DIE,
2778 it is probably faster to just sequentially check each one to
715cafcb
FF
2779 see if it is one of the types we are interested in, and if so,
2780 then extract all the attributes info and generate a partial
2781 symbol table entry.
35f5886e 2782
2d6186f4
FF
2783NOTES
2784
715cafcb
FF
2785 Don't attempt to add anonymous structures or unions since they have
2786 no name. Anonymous enumerations however are processed, because we
2787 want to extract their member names (the check for a tag name is
2788 done later).
2d6186f4 2789
715cafcb
FF
2790 Also, for variables and subroutines, check that this is the place
2791 where the actual definition occurs, rather than just a reference
2792 to an external.
35f5886e
FF
2793 */
2794
2795static void
2796DEFUN(scan_partial_symbols, (thisdie, enddie), char *thisdie AND char *enddie)
2797{
2798 char *nextdie;
2799 struct dieinfo di;
2800
2801 while (thisdie < enddie)
2802 {
2803 basicdieinfo (&di, thisdie);
2804 if (di.dielength < sizeof (long))
2805 {
2806 break;
2807 }
2808 else
2809 {
2810 nextdie = thisdie + di.dielength;
715cafcb
FF
2811 /* To avoid getting complete die information for every die, we
2812 only do it (below) for the cases we are interested in. */
35f5886e
FF
2813 switch (di.dietag)
2814 {
2815 case TAG_global_subroutine:
35f5886e 2816 case TAG_subroutine:
2d6186f4 2817 case TAG_global_variable:
35f5886e 2818 case TAG_local_variable:
2d6186f4
FF
2819 completedieinfo (&di);
2820 if (di.at_name && (di.has_at_low_pc || di.at_location))
2821 {
2822 add_partial_symbol (&di);
2823 }
2824 break;
35f5886e
FF
2825 case TAG_typedef:
2826 case TAG_structure_type:
2827 case TAG_union_type:
35f5886e 2828 completedieinfo (&di);
2d6186f4 2829 if (di.at_name)
35f5886e
FF
2830 {
2831 add_partial_symbol (&di);
2832 }
2833 break;
715cafcb
FF
2834 case TAG_enumeration_type:
2835 completedieinfo (&di);
2836 add_partial_symbol (&di);
2837 break;
35f5886e
FF
2838 }
2839 }
2840 thisdie = nextdie;
2841 }
2842}
2843
2844/*
2845
2846LOCAL FUNCTION
2847
2848 scan_compilation_units -- build a psymtab entry for each compilation
2849
2850DESCRIPTION
2851
2852 This is the top level dwarf parsing routine for building partial
2853 symbol tables.
2854
2855 It scans from the beginning of the DWARF table looking for the first
2856 TAG_compile_unit DIE, and then follows the sibling chain to locate
2857 each additional TAG_compile_unit DIE.
2858
2859 For each TAG_compile_unit DIE it creates a partial symtab structure,
2860 calls a subordinate routine to collect all the compilation unit's
2861 global DIE's, file scope DIEs, typedef DIEs, etc, and then links the
2862 new partial symtab structure into the partial symbol table. It also
2863 records the appropriate information in the partial symbol table entry
2864 to allow the chunk of DIE's and line number table for this compilation
2865 unit to be located and re-read later, to generate a complete symbol
2866 table entry for the compilation unit.
2867
2868 Thus it effectively partitions up a chunk of DIE's for multiple
2869 compilation units into smaller DIE chunks and line number tables,
2870 and associates them with a partial symbol table entry.
2871
2872NOTES
2873
2874 If any compilation unit has no line number table associated with
2875 it for some reason (a missing at_stmt_list attribute, rather than
2876 just one with a value of zero, which is valid) then we ensure that
2877 the recorded file offset is zero so that the routine which later
2878 reads line number table fragments knows that there is no fragment
2879 to read.
2880
2881RETURNS
2882
2883 Returns no value.
2884
2885 */
2886
2887static void
2888DEFUN(scan_compilation_units,
a048c8f5 2889 (filename, addr, thisdie, enddie, dbfoff, lnoffset, objfile),
35f5886e
FF
2890 char *filename AND
2891 CORE_ADDR addr AND
2892 char *thisdie AND
2893 char *enddie AND
2894 unsigned int dbfoff AND
a048c8f5
JG
2895 unsigned int lnoffset AND
2896 struct objfile *objfile)
35f5886e
FF
2897{
2898 char *nextdie;
2899 struct dieinfo di;
2900 struct partial_symtab *pst;
2901 int culength;
2902 int curoff;
2903 int curlnoffset;
2904
2905 while (thisdie < enddie)
2906 {
2907 basicdieinfo (&di, thisdie);
2908 if (di.dielength < sizeof (long))
2909 {
2910 break;
2911 }
2912 else if (di.dietag != TAG_compile_unit)
2913 {
2914 nextdie = thisdie + di.dielength;
2915 }
2916 else
2917 {
2918 completedieinfo (&di);
2919 if (di.at_sibling != 0)
2920 {
2921 nextdie = dbbase + di.at_sibling - dbroff;
2922 }
2923 else
2924 {
2925 nextdie = thisdie + di.dielength;
2926 }
2927 curoff = thisdie - dbbase;
2928 culength = nextdie - thisdie;
2d6186f4 2929 curlnoffset = di.has_at_stmt_list ? lnoffset + di.at_stmt_list : 0;
a048c8f5 2930 pst = start_psymtab (objfile, addr, di.at_name,
35f5886e
FF
2931 di.at_low_pc, di.at_high_pc,
2932 dbfoff, curoff, culength, curlnoffset,
2933 global_psymbols.next,
2934 static_psymbols.next);
2935 scan_partial_symbols (thisdie + di.dielength, nextdie);
2936 pst -> n_global_syms = global_psymbols.next -
2937 (global_psymbols.list + pst -> globals_offset);
2938 pst -> n_static_syms = static_psymbols.next -
2939 (static_psymbols.list + pst -> statics_offset);
2940 /* Sort the global list; don't sort the static list */
2941 qsort (global_psymbols.list + pst -> globals_offset,
2942 pst -> n_global_syms, sizeof (struct partial_symbol),
2943 compare_psymbols);
2944 /* If there is already a psymtab or symtab for a file of this name,
2945 remove it. (If there is a symtab, more drastic things also
2946 happen.) This happens in VxWorks. */
2947 free_named_symtabs (pst -> filename);
2948 /* Place the partial symtab on the partial symtab list */
2949 pst -> next = partial_symtab_list;
2950 partial_symtab_list = pst;
2951 }
2952 thisdie = nextdie;
2953 }
2954}
2955
2956/*
2957
2958LOCAL FUNCTION
2959
2960 new_symbol -- make a symbol table entry for a new symbol
2961
2962SYNOPSIS
2963
2964 static struct symbol *new_symbol (struct dieinfo *dip)
2965
2966DESCRIPTION
2967
2968 Given a pointer to a DWARF information entry, figure out if we need
2969 to make a symbol table entry for it, and if so, create a new entry
2970 and return a pointer to it.
2971 */
2972
2973static struct symbol *
2974DEFUN(new_symbol, (dip), struct dieinfo *dip)
2975{
2976 struct symbol *sym = NULL;
2977
2978 if (dip -> at_name != NULL)
2979 {
2980 sym = (struct symbol *) obstack_alloc (symbol_obstack,
2981 sizeof (struct symbol));
2982 (void) memset (sym, 0, sizeof (struct symbol));
2983 SYMBOL_NAME (sym) = create_name (dip -> at_name, symbol_obstack);
2984 /* default assumptions */
2985 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2986 SYMBOL_CLASS (sym) = LOC_STATIC;
2987 SYMBOL_TYPE (sym) = decode_die_type (dip);
2988 switch (dip -> dietag)
2989 {
2990 case TAG_label:
2991 SYMBOL_VALUE (sym) = dip -> at_low_pc + baseaddr;
2992 SYMBOL_CLASS (sym) = LOC_LABEL;
2993 break;
2994 case TAG_global_subroutine:
2995 case TAG_subroutine:
2996 SYMBOL_VALUE (sym) = dip -> at_low_pc + baseaddr;
2997 SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
2998 SYMBOL_CLASS (sym) = LOC_BLOCK;
2999 if (dip -> dietag == TAG_global_subroutine)
3000 {
3001 add_symbol_to_list (sym, &global_symbols);
3002 }
3003 else
3004 {
3005 add_symbol_to_list (sym, &scope -> symbols);
3006 }
3007 break;
3008 case TAG_global_variable:
3009 case TAG_local_variable:
3010 if (dip -> at_location != NULL)
3011 {
3012 SYMBOL_VALUE (sym) = locval (dip -> at_location);
3013 }
3014 if (dip -> dietag == TAG_global_variable)
3015 {
3016 add_symbol_to_list (sym, &global_symbols);
3017 SYMBOL_CLASS (sym) = LOC_STATIC;
3018 SYMBOL_VALUE (sym) += baseaddr;
3019 }
3020 else
3021 {
3022 add_symbol_to_list (sym, &scope -> symbols);
3023 if (scope -> parent != NULL)
3024 {
3025 if (isreg)
3026 {
3027 SYMBOL_CLASS (sym) = LOC_REGISTER;
3028 }
3029 else
3030 {
3031 SYMBOL_CLASS (sym) = LOC_LOCAL;
3032 }
3033 }
3034 else
3035 {
3036 SYMBOL_CLASS (sym) = LOC_STATIC;
3037 SYMBOL_VALUE (sym) += baseaddr;
3038 }
3039 }
3040 break;
3041 case TAG_formal_parameter:
3042 if (dip -> at_location != NULL)
3043 {
3044 SYMBOL_VALUE (sym) = locval (dip -> at_location);
3045 }
3046 add_symbol_to_list (sym, &scope -> symbols);
3047 if (isreg)
3048 {
3049 SYMBOL_CLASS (sym) = LOC_REGPARM;
3050 }
3051 else
3052 {
3053 SYMBOL_CLASS (sym) = LOC_ARG;
3054 }
3055 break;
3056 case TAG_unspecified_parameters:
3057 /* From varargs functions; gdb doesn't seem to have any interest in
3058 this information, so just ignore it for now. (FIXME?) */
3059 break;
3060 case TAG_structure_type:
3061 case TAG_union_type:
3062 case TAG_enumeration_type:
3063 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
3064 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
3065 add_symbol_to_list (sym, &scope -> symbols);
3066 break;
3067 case TAG_typedef:
3068 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
3069 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
3070 add_symbol_to_list (sym, &scope -> symbols);
3071 break;
3072 default:
3073 /* Not a tag we recognize. Hopefully we aren't processing trash
3074 data, but since we must specifically ignore things we don't
3075 recognize, there is nothing else we should do at this point. */
3076 break;
3077 }
3078 }
3079 return (sym);
3080}
3081
3082/*
3083
3084LOCAL FUNCTION
3085
3086 decode_mod_fund_type -- decode a modified fundamental type
3087
3088SYNOPSIS
3089
3090 static struct type *decode_mod_fund_type (char *typedata)
3091
3092DESCRIPTION
3093
3094 Decode a block of data containing a modified fundamental
3095 type specification. TYPEDATA is a pointer to the block,
3096 which consists of a two byte length, containing the size
3097 of the rest of the block. At the end of the block is a
3098 two byte value that gives the fundamental type. Everything
3099 in between are type modifiers.
3100
3101 We simply compute the number of modifiers and call the general
3102 function decode_modified_type to do the actual work.
3103*/
3104
3105static struct type *
3106DEFUN(decode_mod_fund_type, (typedata), char *typedata)
3107{
3108 struct type *typep = NULL;
3109 unsigned short modcount;
3110 unsigned char *modifiers;
3111
3112 /* Get the total size of the block, exclusive of the size itself */
3113 (void) memcpy (&modcount, typedata, sizeof (short));
3114 /* Deduct the size of the fundamental type bytes at the end of the block. */
3115 modcount -= sizeof (short);
3116 /* Skip over the two size bytes at the beginning of the block. */
c8c0a2bd 3117 modifiers = (unsigned char *) typedata + sizeof (short);
35f5886e
FF
3118 /* Now do the actual decoding */
3119 typep = decode_modified_type (modifiers, modcount, AT_mod_fund_type);
3120 return (typep);
3121}
3122
3123/*
3124
3125LOCAL FUNCTION
3126
3127 decode_mod_u_d_type -- decode a modified user defined type
3128
3129SYNOPSIS
3130
3131 static struct type *decode_mod_u_d_type (char *typedata)
3132
3133DESCRIPTION
3134
3135 Decode a block of data containing a modified user defined
3136 type specification. TYPEDATA is a pointer to the block,
3137 which consists of a two byte length, containing the size
3138 of the rest of the block. At the end of the block is a
3139 four byte value that gives a reference to a user defined type.
3140 Everything in between are type modifiers.
3141
3142 We simply compute the number of modifiers and call the general
3143 function decode_modified_type to do the actual work.
3144*/
3145
3146static struct type *
3147DEFUN(decode_mod_u_d_type, (typedata), char *typedata)
3148{
3149 struct type *typep = NULL;
3150 unsigned short modcount;
3151 unsigned char *modifiers;
3152
3153 /* Get the total size of the block, exclusive of the size itself */
3154 (void) memcpy (&modcount, typedata, sizeof (short));
3155 /* Deduct the size of the reference type bytes at the end of the block. */
3156 modcount -= sizeof (long);
3157 /* Skip over the two size bytes at the beginning of the block. */
c8c0a2bd 3158 modifiers = (unsigned char *) typedata + sizeof (short);
35f5886e
FF
3159 /* Now do the actual decoding */
3160 typep = decode_modified_type (modifiers, modcount, AT_mod_u_d_type);
3161 return (typep);
3162}
3163
3164/*
3165
3166LOCAL FUNCTION
3167
3168 decode_modified_type -- decode modified user or fundamental type
3169
3170SYNOPSIS
3171
3172 static struct type *decode_modified_type (unsigned char *modifiers,
3173 unsigned short modcount, int mtype)
3174
3175DESCRIPTION
3176
3177 Decode a modified type, either a modified fundamental type or
3178 a modified user defined type. MODIFIERS is a pointer to the
3179 block of bytes that define MODCOUNT modifiers. Immediately
3180 following the last modifier is a short containing the fundamental
3181 type or a long containing the reference to the user defined
3182 type. Which one is determined by MTYPE, which is either
3183 AT_mod_fund_type or AT_mod_u_d_type to indicate what modified
3184 type we are generating.
3185
3186 We call ourself recursively to generate each modified type,`
3187 until MODCOUNT reaches zero, at which point we have consumed
3188 all the modifiers and generate either the fundamental type or
3189 user defined type. When the recursion unwinds, each modifier
3190 is applied in turn to generate the full modified type.
3191
3192NOTES
3193
3194 If we find a modifier that we don't recognize, and it is not one
3195 of those reserved for application specific use, then we issue a
3196 warning and simply ignore the modifier.
3197
3198BUGS
3199
3200 We currently ignore MOD_const and MOD_volatile. (FIXME)
3201
3202 */
3203
3204static struct type *
3205DEFUN(decode_modified_type,
3206 (modifiers, modcount, mtype),
3207 unsigned char *modifiers AND unsigned short modcount AND int mtype)
3208{
3209 struct type *typep = NULL;
3210 unsigned short fundtype;
3211 DIEREF dieref;
3212 unsigned char modifier;
3213
3214 if (modcount == 0)
3215 {
3216 switch (mtype)
3217 {
3218 case AT_mod_fund_type:
3219 (void) memcpy (&fundtype, modifiers, sizeof (short));
3220 typep = decode_fund_type (fundtype);
3221 break;
3222 case AT_mod_u_d_type:
3223 (void) memcpy (&dieref, modifiers, sizeof (DIEREF));
3224 if ((typep = lookup_utype (dieref)) == NULL)
3225 {
3226 typep = alloc_utype (dieref, NULL);
3227 }
3228 break;
3229 default:
3230 SQUAWK (("botched modified type decoding (mtype 0x%x)", mtype));
3231 typep = builtin_type_int;
3232 break;
3233 }
3234 }
3235 else
3236 {
3237 modifier = *modifiers++;
3238 typep = decode_modified_type (modifiers, --modcount, mtype);
3239 switch (modifier)
3240 {
3241 case MOD_pointer_to:
3242 typep = lookup_pointer_type (typep);
3243 break;
3244 case MOD_reference_to:
3245 typep = lookup_reference_type (typep);
3246 break;
3247 case MOD_const:
3248 SQUAWK (("type modifier 'const' ignored")); /* FIXME */
3249 break;
3250 case MOD_volatile:
3251 SQUAWK (("type modifier 'volatile' ignored")); /* FIXME */
3252 break;
3253 default:
3254 if (!(MOD_lo_user <= modifier && modifier <= MOD_hi_user))
3255 {
3256 SQUAWK (("unknown type modifier %u", modifier));
3257 }
3258 break;
3259 }
3260 }
3261 return (typep);
3262}
3263
3264/*
3265
3266LOCAL FUNCTION
3267
3268 decode_fund_type -- translate basic DWARF type to gdb base type
3269
3270DESCRIPTION
3271
3272 Given an integer that is one of the fundamental DWARF types,
3273 translate it to one of the basic internal gdb types and return
3274 a pointer to the appropriate gdb type (a "struct type *").
3275
3276NOTES
3277
3278 If we encounter a fundamental type that we are unprepared to
3279 deal with, and it is not in the range of those types defined
3280 as application specific types, then we issue a warning and
3281 treat the type as builtin_type_int.
3282*/
3283
3284static struct type *
3285DEFUN(decode_fund_type, (fundtype), unsigned short fundtype)
3286{
3287 struct type *typep = NULL;
3288
3289 switch (fundtype)
3290 {
3291
3292 case FT_void:
3293 typep = builtin_type_void;
3294 break;
3295
3296 case FT_pointer: /* (void *) */
3297 typep = lookup_pointer_type (builtin_type_void);
3298 break;
3299
3300 case FT_char:
3301 case FT_signed_char:
3302 typep = builtin_type_char;
3303 break;
3304
3305 case FT_short:
3306 case FT_signed_short:
3307 typep = builtin_type_short;
3308 break;
3309
3310 case FT_integer:
3311 case FT_signed_integer:
3312 case FT_boolean: /* Was FT_set in AT&T version */
3313 typep = builtin_type_int;
3314 break;
3315
3316 case FT_long:
3317 case FT_signed_long:
3318 typep = builtin_type_long;
3319 break;
3320
3321 case FT_float:
3322 typep = builtin_type_float;
3323 break;
3324
3325 case FT_dbl_prec_float:
3326 typep = builtin_type_double;
3327 break;
3328
3329 case FT_unsigned_char:
3330 typep = builtin_type_unsigned_char;
3331 break;
3332
3333 case FT_unsigned_short:
3334 typep = builtin_type_unsigned_short;
3335 break;
3336
3337 case FT_unsigned_integer:
3338 typep = builtin_type_unsigned_int;
3339 break;
3340
3341 case FT_unsigned_long:
3342 typep = builtin_type_unsigned_long;
3343 break;
3344
3345 case FT_ext_prec_float:
3346 typep = builtin_type_long_double;
3347 break;
3348
3349 case FT_complex:
3350 typep = builtin_type_complex;
3351 break;
3352
3353 case FT_dbl_prec_complex:
3354 typep = builtin_type_double_complex;
3355 break;
3356
3357 case FT_long_long:
3358 case FT_signed_long_long:
3359 typep = builtin_type_long_long;
3360 break;
3361
3362 case FT_unsigned_long_long:
3363 typep = builtin_type_unsigned_long_long;
3364 break;
3365
3366 }
3367
3368 if ((typep == NULL) && !(FT_lo_user <= fundtype && fundtype <= FT_hi_user))
3369 {
3370 SQUAWK (("unexpected fundamental type 0x%x", fundtype));
3371 typep = builtin_type_void;
3372 }
3373
3374 return (typep);
3375}
3376
3377/*
3378
3379LOCAL FUNCTION
3380
3381 create_name -- allocate a fresh copy of a string on an obstack
3382
3383DESCRIPTION
3384
3385 Given a pointer to a string and a pointer to an obstack, allocates
3386 a fresh copy of the string on the specified obstack.
3387
3388*/
3389
3390static char *
3391DEFUN(create_name, (name, obstackp), char *name AND struct obstack *obstackp)
3392{
3393 int length;
3394 char *newname;
3395
3396 length = strlen (name) + 1;
3397 newname = (char *) obstack_alloc (obstackp, length);
3398 (void) strcpy (newname, name);
3399 return (newname);
3400}
3401
3402/*
3403
3404LOCAL FUNCTION
3405
3406 basicdieinfo -- extract the minimal die info from raw die data
3407
3408SYNOPSIS
3409
3410 void basicdieinfo (char *diep, struct dieinfo *dip)
3411
3412DESCRIPTION
3413
3414 Given a pointer to raw DIE data, and a pointer to an instance of a
3415 die info structure, this function extracts the basic information
3416 from the DIE data required to continue processing this DIE, along
3417 with some bookkeeping information about the DIE.
3418
3419 The information we absolutely must have includes the DIE tag,
3420 and the DIE length. If we need the sibling reference, then we
3421 will have to call completedieinfo() to process all the remaining
3422 DIE information.
3423
3424 Note that since there is no guarantee that the data is properly
3425 aligned in memory for the type of access required (indirection
3426 through anything other than a char pointer), we use memcpy to
3427 shuffle data items larger than a char. Possibly inefficient, but
3428 quite portable.
3429
3430 We also take care of some other basic things at this point, such
3431 as ensuring that the instance of the die info structure starts
3432 out completely zero'd and that curdie is initialized for use
3433 in error reporting if we have a problem with the current die.
3434
3435NOTES
3436
3437 All DIE's must have at least a valid length, thus the minimum
3438 DIE size is sizeof (long). In order to have a valid tag, the
3439 DIE size must be at least sizeof (short) larger, otherwise they
3440 are forced to be TAG_padding DIES.
3441
3442 Padding DIES must be at least sizeof(long) in length, implying that
3443 if a padding DIE is used for alignment and the amount needed is less
3444 than sizeof(long) then the padding DIE has to be big enough to align
3445 to the next alignment boundry.
3446 */
3447
3448static void
3449DEFUN(basicdieinfo, (dip, diep), struct dieinfo *dip AND char *diep)
3450{
3451 curdie = dip;
3452 (void) memset (dip, 0, sizeof (struct dieinfo));
3453 dip -> die = diep;
3454 dip -> dieref = dbroff + (diep - dbbase);
3455 (void) memcpy (&dip -> dielength, diep, sizeof (long));
3456 if (dip -> dielength < sizeof (long))
3457 {
3458 dwarfwarn ("malformed DIE, bad length (%d bytes)", dip -> dielength);
3459 }
3460 else if (dip -> dielength < (sizeof (long) + sizeof (short)))
3461 {
3462 dip -> dietag = TAG_padding;
3463 }
3464 else
3465 {
3466 (void) memcpy (&dip -> dietag, diep + sizeof (long), sizeof (short));
3467 }
3468}
3469
3470/*
3471
3472LOCAL FUNCTION
3473
3474 completedieinfo -- finish reading the information for a given DIE
3475
3476SYNOPSIS
3477
3478 void completedieinfo (struct dieinfo *dip)
3479
3480DESCRIPTION
3481
3482 Given a pointer to an already partially initialized die info structure,
3483 scan the raw DIE data and finish filling in the die info structure
3484 from the various attributes found.
3485
3486 Note that since there is no guarantee that the data is properly
3487 aligned in memory for the type of access required (indirection
3488 through anything other than a char pointer), we use memcpy to
3489 shuffle data items larger than a char. Possibly inefficient, but
3490 quite portable.
3491
3492NOTES
3493
3494 Each time we are called, we increment the diecount variable, which
3495 keeps an approximate count of the number of dies processed for
3496 each compilation unit. This information is presented to the user
3497 if the info_verbose flag is set.
3498
3499 */
3500
3501static void
3502DEFUN(completedieinfo, (dip), struct dieinfo *dip)
3503{
3504 char *diep; /* Current pointer into raw DIE data */
3505 char *end; /* Terminate DIE scan here */
3506 unsigned short attr; /* Current attribute being scanned */
3507 unsigned short form; /* Form of the attribute */
3508 short block2sz; /* Size of a block2 attribute field */
3509 long block4sz; /* Size of a block4 attribute field */
3510
3511 diecount++;
3512 diep = dip -> die;
3513 end = diep + dip -> dielength;
3514 diep += sizeof (long) + sizeof (short);
3515 while (diep < end)
3516 {
3517 (void) memcpy (&attr, diep, sizeof (short));
3518 diep += sizeof (short);
3519 switch (attr)
3520 {
3521 case AT_fund_type:
3522 (void) memcpy (&dip -> at_fund_type, diep, sizeof (short));
3523 break;
3524 case AT_ordering:
3525 (void) memcpy (&dip -> at_ordering, diep, sizeof (short));
3526 break;
3527 case AT_bit_offset:
3528 (void) memcpy (&dip -> at_bit_offset, diep, sizeof (short));
3529 break;
3530 case AT_visibility:
3531 (void) memcpy (&dip -> at_visibility, diep, sizeof (short));
3532 break;
3533 case AT_sibling:
3534 (void) memcpy (&dip -> at_sibling, diep, sizeof (long));
3535 break;
3536 case AT_stmt_list:
3537 (void) memcpy (&dip -> at_stmt_list, diep, sizeof (long));
2d6186f4 3538 dip -> has_at_stmt_list = 1;
35f5886e
FF
3539 break;
3540 case AT_low_pc:
3541 (void) memcpy (&dip -> at_low_pc, diep, sizeof (long));
2d6186f4 3542 dip -> has_at_low_pc = 1;
35f5886e
FF
3543 break;
3544 case AT_high_pc:
3545 (void) memcpy (&dip -> at_high_pc, diep, sizeof (long));
3546 break;
3547 case AT_language:
3548 (void) memcpy (&dip -> at_language, diep, sizeof (long));
3549 break;
3550 case AT_user_def_type:
3551 (void) memcpy (&dip -> at_user_def_type, diep, sizeof (long));
3552 break;
3553 case AT_byte_size:
3554 (void) memcpy (&dip -> at_byte_size, diep, sizeof (long));
3555 break;
3556 case AT_bit_size:
3557 (void) memcpy (&dip -> at_bit_size, diep, sizeof (long));
3558 break;
3559 case AT_member:
3560 (void) memcpy (&dip -> at_member, diep, sizeof (long));
3561 break;
3562 case AT_discr:
3563 (void) memcpy (&dip -> at_discr, diep, sizeof (long));
3564 break;
3565 case AT_import:
3566 (void) memcpy (&dip -> at_import, diep, sizeof (long));
3567 break;
3568 case AT_location:
3569 dip -> at_location = diep;
3570 break;
3571 case AT_mod_fund_type:
3572 dip -> at_mod_fund_type = diep;
3573 break;
3574 case AT_subscr_data:
3575 dip -> at_subscr_data = diep;
3576 break;
3577 case AT_mod_u_d_type:
3578 dip -> at_mod_u_d_type = diep;
3579 break;
35f5886e
FF
3580 case AT_element_list:
3581 dip -> at_element_list = diep;
768be6e1
FF
3582 dip -> short_element_list = 0;
3583 break;
3584 case AT_short_element_list:
3585 dip -> at_element_list = diep;
3586 dip -> short_element_list = 1;
35f5886e
FF
3587 break;
3588 case AT_discr_value:
3589 dip -> at_discr_value = diep;
3590 break;
3591 case AT_string_length:
3592 dip -> at_string_length = diep;
3593 break;
3594 case AT_name:
3595 dip -> at_name = diep;
3596 break;
3597 case AT_comp_dir:
3598 dip -> at_comp_dir = diep;
3599 break;
3600 case AT_producer:
3601 dip -> at_producer = diep;
3602 break;
35f5886e
FF
3603 case AT_frame_base:
3604 (void) memcpy (&dip -> at_frame_base, diep, sizeof (long));
3605 break;
35f5886e
FF
3606 case AT_start_scope:
3607 (void) memcpy (&dip -> at_start_scope, diep, sizeof (long));
3608 break;
3609 case AT_stride_size:
3610 (void) memcpy (&dip -> at_stride_size, diep, sizeof (long));
3611 break;
3612 case AT_src_info:
3613 (void) memcpy (&dip -> at_src_info, diep, sizeof (long));
3614 break;
3615 case AT_prototyped:
3616 (void) memcpy (&dip -> at_prototyped, diep, sizeof (short));
3617 break;
35f5886e
FF
3618 default:
3619 /* Found an attribute that we are unprepared to handle. However
3620 it is specifically one of the design goals of DWARF that
3621 consumers should ignore unknown attributes. As long as the
3622 form is one that we recognize (so we know how to skip it),
3623 we can just ignore the unknown attribute. */
3624 break;
3625 }
3626 form = attr & 0xF;
3627 switch (form)
3628 {
3629 case FORM_DATA2:
3630 diep += sizeof (short);
3631 break;
3632 case FORM_DATA4:
3633 diep += sizeof (long);
3634 break;
3635 case FORM_DATA8:
3636 diep += 8 * sizeof (char); /* sizeof (long long) ? */
3637 break;
3638 case FORM_ADDR:
3639 case FORM_REF:
3640 diep += sizeof (long);
3641 break;
3642 case FORM_BLOCK2:
3643 (void) memcpy (&block2sz, diep, sizeof (short));
3644 block2sz += sizeof (short);
3645 diep += block2sz;
3646 break;
3647 case FORM_BLOCK4:
3648 (void) memcpy (&block4sz, diep, sizeof (long));
3649 block4sz += sizeof (long);
3650 diep += block4sz;
3651 break;
3652 case FORM_STRING:
3653 diep += strlen (diep) + 1;
3654 break;
3655 default:
3656 SQUAWK (("unknown attribute form (0x%x), skipped rest", form));
3657 diep = end;
3658 break;
3659 }
3660 }
3661}
This page took 0.29857 seconds and 4 git commands to generate.