* elfcore.h (elf_core_file_p): Ensure we have a backend match
[deliverable/binutils-gdb.git] / binutils / dwarf.c
CommitLineData
19e6b90e 1/* dwarf.c -- display DWARF contents of a BFD binary file
fe4eaaf4 2 Copyright 2005, 2006, 2007, 2008
19e6b90e
L
3 Free Software Foundation, Inc.
4
5 This file is part of GNU Binutils.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
32866df7 9 the Free Software Foundation; either version 3 of the License, or
19e6b90e
L
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
21
3db64b00 22#include "sysdep.h"
19e6b90e 23#include "libiberty.h"
3db64b00
AM
24#include "bfd.h"
25#include "bucomm.h"
2dc4cec1 26#include "elf/common.h"
3db64b00
AM
27#include "elf/dwarf2.h"
28#include "dwarf.h"
19e6b90e
L
29
30static int have_frame_base;
31static int need_base_address;
32
33static unsigned int last_pointer_size = 0;
34static int warned_about_missing_comp_units = FALSE;
35
36static unsigned int num_debug_info_entries = 0;
37static debug_info *debug_information = NULL;
cc86f28f
NC
38/* Special value for num_debug_info_entries to indicate
39 that the .debug_info section could not be loaded/parsed. */
40#define DEBUG_INFO_UNAVAILABLE (unsigned int) -1
19e6b90e 41
2dc4cec1 42int eh_addr_size;
19e6b90e
L
43
44int do_debug_info;
45int do_debug_abbrevs;
46int do_debug_lines;
a262ae96 47int do_debug_lines_decoded;
19e6b90e
L
48int do_debug_pubnames;
49int do_debug_aranges;
50int do_debug_ranges;
51int do_debug_frames;
52int do_debug_frames_interp;
53int do_debug_macinfo;
54int do_debug_str;
55int do_debug_loc;
a262ae96 56int do_wide;
19e6b90e
L
57
58dwarf_vma (*byte_get) (unsigned char *, int);
59
60dwarf_vma
61byte_get_little_endian (unsigned char *field, int size)
62{
63 switch (size)
64 {
65 case 1:
66 return *field;
67
68 case 2:
69 return ((unsigned int) (field[0]))
70 | (((unsigned int) (field[1])) << 8);
71
72 case 4:
73 return ((unsigned long) (field[0]))
74 | (((unsigned long) (field[1])) << 8)
75 | (((unsigned long) (field[2])) << 16)
76 | (((unsigned long) (field[3])) << 24);
77
78 case 8:
79 if (sizeof (dwarf_vma) == 8)
80 return ((dwarf_vma) (field[0]))
81 | (((dwarf_vma) (field[1])) << 8)
82 | (((dwarf_vma) (field[2])) << 16)
83 | (((dwarf_vma) (field[3])) << 24)
84 | (((dwarf_vma) (field[4])) << 32)
85 | (((dwarf_vma) (field[5])) << 40)
86 | (((dwarf_vma) (field[6])) << 48)
87 | (((dwarf_vma) (field[7])) << 56);
88 else if (sizeof (dwarf_vma) == 4)
89 /* We want to extract data from an 8 byte wide field and
90 place it into a 4 byte wide field. Since this is a little
91 endian source we can just use the 4 byte extraction code. */
92 return ((unsigned long) (field[0]))
93 | (((unsigned long) (field[1])) << 8)
94 | (((unsigned long) (field[2])) << 16)
95 | (((unsigned long) (field[3])) << 24);
96
97 default:
98 error (_("Unhandled data length: %d\n"), size);
99 abort ();
100 }
101}
102
103dwarf_vma
104byte_get_big_endian (unsigned char *field, int size)
105{
106 switch (size)
107 {
108 case 1:
109 return *field;
110
111 case 2:
112 return ((unsigned int) (field[1])) | (((int) (field[0])) << 8);
113
114 case 4:
115 return ((unsigned long) (field[3]))
116 | (((unsigned long) (field[2])) << 8)
117 | (((unsigned long) (field[1])) << 16)
118 | (((unsigned long) (field[0])) << 24);
119
120 case 8:
121 if (sizeof (dwarf_vma) == 8)
122 return ((dwarf_vma) (field[7]))
123 | (((dwarf_vma) (field[6])) << 8)
124 | (((dwarf_vma) (field[5])) << 16)
125 | (((dwarf_vma) (field[4])) << 24)
126 | (((dwarf_vma) (field[3])) << 32)
127 | (((dwarf_vma) (field[2])) << 40)
128 | (((dwarf_vma) (field[1])) << 48)
129 | (((dwarf_vma) (field[0])) << 56);
130 else if (sizeof (dwarf_vma) == 4)
131 {
132 /* Although we are extracing data from an 8 byte wide field,
133 we are returning only 4 bytes of data. */
134 field += 4;
135 return ((unsigned long) (field[3]))
136 | (((unsigned long) (field[2])) << 8)
137 | (((unsigned long) (field[1])) << 16)
138 | (((unsigned long) (field[0])) << 24);
139 }
140
141 default:
142 error (_("Unhandled data length: %d\n"), size);
143 abort ();
144 }
145}
146
147static dwarf_vma
148byte_get_signed (unsigned char *field, int size)
149{
150 dwarf_vma x = byte_get (field, size);
151
152 switch (size)
153 {
154 case 1:
155 return (x ^ 0x80) - 0x80;
156 case 2:
157 return (x ^ 0x8000) - 0x8000;
158 case 4:
159 return (x ^ 0x80000000) - 0x80000000;
160 case 8:
161 return x;
162 default:
163 abort ();
164 }
165}
166
2d9472a2
NC
167/* Print a dwarf_vma value (typically an address, offset or length) in
168 hexadecimal format, followed by a space. The length of the value (and
169 hence the precision displayed) is determined by the byte_size parameter. */
cecf136e 170
2d9472a2
NC
171static void
172print_dwarf_vma (dwarf_vma val, unsigned byte_size)
173{
174 static char buff[18];
175
176 /* Printf does not have a way of specifiying a maximum field width for an
177 integer value, so we print the full value into a buffer and then select
178 the precision we need. */
179#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
2e14fae2 180#ifndef __MSVCRT__
2d9472a2 181 snprintf (buff, sizeof (buff), "%16.16llx ", val);
2e14fae2
NC
182#else
183 snprintf (buff, sizeof (buff), "%016I64x ", val);
184#endif
2d9472a2
NC
185#else
186 snprintf (buff, sizeof (buff), "%16.16lx ", val);
187#endif
188
189 printf (buff + (byte_size == 4 ? 8 : 0));
190}
191
19e6b90e
L
192static unsigned long int
193read_leb128 (unsigned char *data, unsigned int *length_return, int sign)
194{
195 unsigned long int result = 0;
196 unsigned int num_read = 0;
197 unsigned int shift = 0;
198 unsigned char byte;
199
200 do
201 {
202 byte = *data++;
203 num_read++;
204
205 result |= ((unsigned long int) (byte & 0x7f)) << shift;
206
207 shift += 7;
208
209 }
210 while (byte & 0x80);
211
212 if (length_return != NULL)
213 *length_return = num_read;
214
215 if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
216 result |= -1L << shift;
217
218 return result;
219}
220
221typedef struct State_Machine_Registers
222{
223 unsigned long address;
224 unsigned int file;
225 unsigned int line;
226 unsigned int column;
227 int is_stmt;
228 int basic_block;
229 int end_sequence;
230/* This variable hold the number of the last entry seen
231 in the File Table. */
232 unsigned int last_file_entry;
233} SMR;
234
235static SMR state_machine_regs;
236
237static void
238reset_state_machine (int is_stmt)
239{
240 state_machine_regs.address = 0;
241 state_machine_regs.file = 1;
242 state_machine_regs.line = 1;
243 state_machine_regs.column = 0;
244 state_machine_regs.is_stmt = is_stmt;
245 state_machine_regs.basic_block = 0;
246 state_machine_regs.end_sequence = 0;
247 state_machine_regs.last_file_entry = 0;
248}
249
250/* Handled an extend line op.
251 Returns the number of bytes read. */
252
253static int
1617e571 254process_extended_line_op (unsigned char *data, int is_stmt)
19e6b90e
L
255{
256 unsigned char op_code;
257 unsigned int bytes_read;
258 unsigned int len;
259 unsigned char *name;
260 unsigned long adr;
261
262 len = read_leb128 (data, & bytes_read, 0);
263 data += bytes_read;
264
265 if (len == 0)
266 {
267 warn (_("badly formed extended line op encountered!\n"));
268 return bytes_read;
269 }
270
271 len += bytes_read;
272 op_code = *data++;
273
274 printf (_(" Extended opcode %d: "), op_code);
275
276 switch (op_code)
277 {
278 case DW_LNE_end_sequence:
279 printf (_("End of Sequence\n\n"));
280 reset_state_machine (is_stmt);
281 break;
282
283 case DW_LNE_set_address:
1617e571 284 adr = byte_get (data, len - bytes_read - 1);
19e6b90e
L
285 printf (_("set Address to 0x%lx\n"), adr);
286 state_machine_regs.address = adr;
287 break;
288
289 case DW_LNE_define_file:
290 printf (_(" define new File Table entry\n"));
291 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
292
293 printf (_(" %d\t"), ++state_machine_regs.last_file_entry);
294 name = data;
295 data += strlen ((char *) data) + 1;
296 printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
297 data += bytes_read;
298 printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
299 data += bytes_read;
300 printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
301 printf (_("%s\n\n"), name);
302 break;
303
e2a0d921
NC
304 /* HP extensions. */
305 case DW_LNE_HP_negate_is_UV_update:
306 printf ("DW_LNE_HP_negate_is_UV_update");
307 break;
308 case DW_LNE_HP_push_context:
309 printf ("DW_LNE_HP_push_context");
310 break;
311 case DW_LNE_HP_pop_context:
312 printf ("DW_LNE_HP_pop_context");
313 break;
314 case DW_LNE_HP_set_file_line_column:
315 printf ("DW_LNE_HP_set_file_line_column");
316 break;
317 case DW_LNE_HP_set_routine_name:
318 printf ("DW_LNE_HP_set_routine_name");
319 break;
320 case DW_LNE_HP_set_sequence:
321 printf ("DW_LNE_HP_set_sequence");
322 break;
323 case DW_LNE_HP_negate_post_semantics:
324 printf ("DW_LNE_HP_negate_post_semantics");
325 break;
326 case DW_LNE_HP_negate_function_exit:
327 printf ("DW_LNE_HP_negate_function_exit");
328 break;
329 case DW_LNE_HP_negate_front_end_logical:
330 printf ("DW_LNE_HP_negate_front_end_logical");
331 break;
332 case DW_LNE_HP_define_proc:
333 printf ("DW_LNE_HP_define_proc");
334 break;
cecf136e 335
19e6b90e 336 default:
e2a0d921
NC
337 if (op_code >= DW_LNE_lo_user
338 /* The test against DW_LNW_hi_user is redundant due to
339 the limited range of the unsigned char data type used
340 for op_code. */
341 /*&& op_code <= DW_LNE_hi_user*/)
342 printf (_("user defined: length %d\n"), len - bytes_read);
343 else
344 printf (_("UNKNOWN: length %d\n"), len - bytes_read);
19e6b90e
L
345 break;
346 }
347
348 return len;
349}
350
351static const char *
352fetch_indirect_string (unsigned long offset)
353{
354 struct dwarf_section *section = &debug_displays [str].section;
355
356 if (section->start == NULL)
357 return _("<no .debug_str section>");
358
bfe2612a
L
359 /* DWARF sections under Mach-O have non-zero addresses. */
360 offset -= section->address;
19e6b90e
L
361 if (offset > section->size)
362 {
363 warn (_("DW_FORM_strp offset too big: %lx\n"), offset);
364 return _("<offset is too big>");
365 }
366
367 return (const char *) section->start + offset;
368}
369
370/* FIXME: There are better and more efficient ways to handle
371 these structures. For now though, I just want something that
372 is simple to implement. */
373typedef struct abbrev_attr
374{
375 unsigned long attribute;
376 unsigned long form;
377 struct abbrev_attr *next;
378}
379abbrev_attr;
380
381typedef struct abbrev_entry
382{
383 unsigned long entry;
384 unsigned long tag;
385 int children;
386 struct abbrev_attr *first_attr;
387 struct abbrev_attr *last_attr;
388 struct abbrev_entry *next;
389}
390abbrev_entry;
391
392static abbrev_entry *first_abbrev = NULL;
393static abbrev_entry *last_abbrev = NULL;
394
395static void
396free_abbrevs (void)
397{
398 abbrev_entry *abbrev;
399
400 for (abbrev = first_abbrev; abbrev;)
401 {
402 abbrev_entry *next = abbrev->next;
403 abbrev_attr *attr;
404
405 for (attr = abbrev->first_attr; attr;)
406 {
407 abbrev_attr *next = attr->next;
408
409 free (attr);
410 attr = next;
411 }
412
413 free (abbrev);
414 abbrev = next;
415 }
416
417 last_abbrev = first_abbrev = NULL;
418}
419
420static void
421add_abbrev (unsigned long number, unsigned long tag, int children)
422{
423 abbrev_entry *entry;
424
425 entry = malloc (sizeof (*entry));
426
427 if (entry == NULL)
428 /* ugg */
429 return;
430
431 entry->entry = number;
432 entry->tag = tag;
433 entry->children = children;
434 entry->first_attr = NULL;
435 entry->last_attr = NULL;
436 entry->next = NULL;
437
438 if (first_abbrev == NULL)
439 first_abbrev = entry;
440 else
441 last_abbrev->next = entry;
442
443 last_abbrev = entry;
444}
445
446static void
447add_abbrev_attr (unsigned long attribute, unsigned long form)
448{
449 abbrev_attr *attr;
450
451 attr = malloc (sizeof (*attr));
452
453 if (attr == NULL)
454 /* ugg */
455 return;
456
457 attr->attribute = attribute;
458 attr->form = form;
459 attr->next = NULL;
460
461 if (last_abbrev->first_attr == NULL)
462 last_abbrev->first_attr = attr;
463 else
464 last_abbrev->last_attr->next = attr;
465
466 last_abbrev->last_attr = attr;
467}
468
469/* Processes the (partial) contents of a .debug_abbrev section.
470 Returns NULL if the end of the section was encountered.
471 Returns the address after the last byte read if the end of
472 an abbreviation set was found. */
473
474static unsigned char *
475process_abbrev_section (unsigned char *start, unsigned char *end)
476{
477 if (first_abbrev != NULL)
478 return NULL;
479
480 while (start < end)
481 {
482 unsigned int bytes_read;
483 unsigned long entry;
484 unsigned long tag;
485 unsigned long attribute;
486 int children;
487
488 entry = read_leb128 (start, & bytes_read, 0);
489 start += bytes_read;
490
491 /* A single zero is supposed to end the section according
492 to the standard. If there's more, then signal that to
493 the caller. */
494 if (entry == 0)
495 return start == end ? NULL : start;
496
497 tag = read_leb128 (start, & bytes_read, 0);
498 start += bytes_read;
499
500 children = *start++;
501
502 add_abbrev (entry, tag, children);
503
504 do
505 {
506 unsigned long form;
507
508 attribute = read_leb128 (start, & bytes_read, 0);
509 start += bytes_read;
510
511 form = read_leb128 (start, & bytes_read, 0);
512 start += bytes_read;
513
514 if (attribute != 0)
515 add_abbrev_attr (attribute, form);
516 }
517 while (attribute != 0);
518 }
519
520 return NULL;
521}
522
523static char *
524get_TAG_name (unsigned long tag)
525{
526 switch (tag)
527 {
528 case DW_TAG_padding: return "DW_TAG_padding";
529 case DW_TAG_array_type: return "DW_TAG_array_type";
530 case DW_TAG_class_type: return "DW_TAG_class_type";
531 case DW_TAG_entry_point: return "DW_TAG_entry_point";
532 case DW_TAG_enumeration_type: return "DW_TAG_enumeration_type";
533 case DW_TAG_formal_parameter: return "DW_TAG_formal_parameter";
534 case DW_TAG_imported_declaration: return "DW_TAG_imported_declaration";
535 case DW_TAG_label: return "DW_TAG_label";
536 case DW_TAG_lexical_block: return "DW_TAG_lexical_block";
537 case DW_TAG_member: return "DW_TAG_member";
538 case DW_TAG_pointer_type: return "DW_TAG_pointer_type";
539 case DW_TAG_reference_type: return "DW_TAG_reference_type";
540 case DW_TAG_compile_unit: return "DW_TAG_compile_unit";
541 case DW_TAG_string_type: return "DW_TAG_string_type";
542 case DW_TAG_structure_type: return "DW_TAG_structure_type";
543 case DW_TAG_subroutine_type: return "DW_TAG_subroutine_type";
544 case DW_TAG_typedef: return "DW_TAG_typedef";
545 case DW_TAG_union_type: return "DW_TAG_union_type";
546 case DW_TAG_unspecified_parameters: return "DW_TAG_unspecified_parameters";
547 case DW_TAG_variant: return "DW_TAG_variant";
548 case DW_TAG_common_block: return "DW_TAG_common_block";
549 case DW_TAG_common_inclusion: return "DW_TAG_common_inclusion";
550 case DW_TAG_inheritance: return "DW_TAG_inheritance";
551 case DW_TAG_inlined_subroutine: return "DW_TAG_inlined_subroutine";
552 case DW_TAG_module: return "DW_TAG_module";
553 case DW_TAG_ptr_to_member_type: return "DW_TAG_ptr_to_member_type";
554 case DW_TAG_set_type: return "DW_TAG_set_type";
555 case DW_TAG_subrange_type: return "DW_TAG_subrange_type";
556 case DW_TAG_with_stmt: return "DW_TAG_with_stmt";
557 case DW_TAG_access_declaration: return "DW_TAG_access_declaration";
558 case DW_TAG_base_type: return "DW_TAG_base_type";
559 case DW_TAG_catch_block: return "DW_TAG_catch_block";
560 case DW_TAG_const_type: return "DW_TAG_const_type";
561 case DW_TAG_constant: return "DW_TAG_constant";
562 case DW_TAG_enumerator: return "DW_TAG_enumerator";
563 case DW_TAG_file_type: return "DW_TAG_file_type";
564 case DW_TAG_friend: return "DW_TAG_friend";
565 case DW_TAG_namelist: return "DW_TAG_namelist";
566 case DW_TAG_namelist_item: return "DW_TAG_namelist_item";
567 case DW_TAG_packed_type: return "DW_TAG_packed_type";
568 case DW_TAG_subprogram: return "DW_TAG_subprogram";
569 case DW_TAG_template_type_param: return "DW_TAG_template_type_param";
570 case DW_TAG_template_value_param: return "DW_TAG_template_value_param";
571 case DW_TAG_thrown_type: return "DW_TAG_thrown_type";
572 case DW_TAG_try_block: return "DW_TAG_try_block";
573 case DW_TAG_variant_part: return "DW_TAG_variant_part";
574 case DW_TAG_variable: return "DW_TAG_variable";
575 case DW_TAG_volatile_type: return "DW_TAG_volatile_type";
576 case DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop";
577 case DW_TAG_format_label: return "DW_TAG_format_label";
578 case DW_TAG_function_template: return "DW_TAG_function_template";
579 case DW_TAG_class_template: return "DW_TAG_class_template";
580 /* DWARF 2.1 values. */
581 case DW_TAG_dwarf_procedure: return "DW_TAG_dwarf_procedure";
582 case DW_TAG_restrict_type: return "DW_TAG_restrict_type";
583 case DW_TAG_interface_type: return "DW_TAG_interface_type";
584 case DW_TAG_namespace: return "DW_TAG_namespace";
585 case DW_TAG_imported_module: return "DW_TAG_imported_module";
586 case DW_TAG_unspecified_type: return "DW_TAG_unspecified_type";
587 case DW_TAG_partial_unit: return "DW_TAG_partial_unit";
588 case DW_TAG_imported_unit: return "DW_TAG_imported_unit";
589 /* UPC values. */
590 case DW_TAG_upc_shared_type: return "DW_TAG_upc_shared_type";
591 case DW_TAG_upc_strict_type: return "DW_TAG_upc_strict_type";
592 case DW_TAG_upc_relaxed_type: return "DW_TAG_upc_relaxed_type";
593 default:
594 {
595 static char buffer[100];
596
597 snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %lx"), tag);
598 return buffer;
599 }
600 }
601}
602
603static char *
604get_FORM_name (unsigned long form)
605{
606 switch (form)
607 {
608 case DW_FORM_addr: return "DW_FORM_addr";
609 case DW_FORM_block2: return "DW_FORM_block2";
610 case DW_FORM_block4: return "DW_FORM_block4";
611 case DW_FORM_data2: return "DW_FORM_data2";
612 case DW_FORM_data4: return "DW_FORM_data4";
613 case DW_FORM_data8: return "DW_FORM_data8";
614 case DW_FORM_string: return "DW_FORM_string";
615 case DW_FORM_block: return "DW_FORM_block";
616 case DW_FORM_block1: return "DW_FORM_block1";
617 case DW_FORM_data1: return "DW_FORM_data1";
618 case DW_FORM_flag: return "DW_FORM_flag";
619 case DW_FORM_sdata: return "DW_FORM_sdata";
620 case DW_FORM_strp: return "DW_FORM_strp";
621 case DW_FORM_udata: return "DW_FORM_udata";
622 case DW_FORM_ref_addr: return "DW_FORM_ref_addr";
623 case DW_FORM_ref1: return "DW_FORM_ref1";
624 case DW_FORM_ref2: return "DW_FORM_ref2";
625 case DW_FORM_ref4: return "DW_FORM_ref4";
626 case DW_FORM_ref8: return "DW_FORM_ref8";
627 case DW_FORM_ref_udata: return "DW_FORM_ref_udata";
628 case DW_FORM_indirect: return "DW_FORM_indirect";
629 default:
630 {
631 static char buffer[100];
632
633 snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form);
634 return buffer;
635 }
636 }
637}
638
639static unsigned char *
640display_block (unsigned char *data, unsigned long length)
641{
642 printf (_(" %lu byte block: "), length);
643
644 while (length --)
645 printf ("%lx ", (unsigned long) byte_get (data++, 1));
646
647 return data;
648}
649
650static int
651decode_location_expression (unsigned char * data,
652 unsigned int pointer_size,
653 unsigned long length,
654 unsigned long cu_offset)
655{
656 unsigned op;
657 unsigned int bytes_read;
658 unsigned long uvalue;
659 unsigned char *end = data + length;
660 int need_frame_base = 0;
661
662 while (data < end)
663 {
664 op = *data++;
665
666 switch (op)
667 {
668 case DW_OP_addr:
669 printf ("DW_OP_addr: %lx",
670 (unsigned long) byte_get (data, pointer_size));
671 data += pointer_size;
672 break;
673 case DW_OP_deref:
674 printf ("DW_OP_deref");
675 break;
676 case DW_OP_const1u:
677 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data++, 1));
678 break;
679 case DW_OP_const1s:
680 printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data++, 1));
681 break;
682 case DW_OP_const2u:
683 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data, 2));
684 data += 2;
685 break;
686 case DW_OP_const2s:
687 printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data, 2));
688 data += 2;
689 break;
690 case DW_OP_const4u:
691 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data, 4));
692 data += 4;
693 break;
694 case DW_OP_const4s:
695 printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data, 4));
696 data += 4;
697 break;
698 case DW_OP_const8u:
699 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data, 4),
700 (unsigned long) byte_get (data + 4, 4));
701 data += 8;
702 break;
703 case DW_OP_const8s:
704 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data, 4),
705 (long) byte_get (data + 4, 4));
706 data += 8;
707 break;
708 case DW_OP_constu:
709 printf ("DW_OP_constu: %lu", read_leb128 (data, &bytes_read, 0));
710 data += bytes_read;
711 break;
712 case DW_OP_consts:
713 printf ("DW_OP_consts: %ld", read_leb128 (data, &bytes_read, 1));
714 data += bytes_read;
715 break;
716 case DW_OP_dup:
717 printf ("DW_OP_dup");
718 break;
719 case DW_OP_drop:
720 printf ("DW_OP_drop");
721 break;
722 case DW_OP_over:
723 printf ("DW_OP_over");
724 break;
725 case DW_OP_pick:
726 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data++, 1));
727 break;
728 case DW_OP_swap:
729 printf ("DW_OP_swap");
730 break;
731 case DW_OP_rot:
732 printf ("DW_OP_rot");
733 break;
734 case DW_OP_xderef:
735 printf ("DW_OP_xderef");
736 break;
737 case DW_OP_abs:
738 printf ("DW_OP_abs");
739 break;
740 case DW_OP_and:
741 printf ("DW_OP_and");
742 break;
743 case DW_OP_div:
744 printf ("DW_OP_div");
745 break;
746 case DW_OP_minus:
747 printf ("DW_OP_minus");
748 break;
749 case DW_OP_mod:
750 printf ("DW_OP_mod");
751 break;
752 case DW_OP_mul:
753 printf ("DW_OP_mul");
754 break;
755 case DW_OP_neg:
756 printf ("DW_OP_neg");
757 break;
758 case DW_OP_not:
759 printf ("DW_OP_not");
760 break;
761 case DW_OP_or:
762 printf ("DW_OP_or");
763 break;
764 case DW_OP_plus:
765 printf ("DW_OP_plus");
766 break;
767 case DW_OP_plus_uconst:
768 printf ("DW_OP_plus_uconst: %lu",
769 read_leb128 (data, &bytes_read, 0));
770 data += bytes_read;
771 break;
772 case DW_OP_shl:
773 printf ("DW_OP_shl");
774 break;
775 case DW_OP_shr:
776 printf ("DW_OP_shr");
777 break;
778 case DW_OP_shra:
779 printf ("DW_OP_shra");
780 break;
781 case DW_OP_xor:
782 printf ("DW_OP_xor");
783 break;
784 case DW_OP_bra:
785 printf ("DW_OP_bra: %ld", (long) byte_get_signed (data, 2));
786 data += 2;
787 break;
788 case DW_OP_eq:
789 printf ("DW_OP_eq");
790 break;
791 case DW_OP_ge:
792 printf ("DW_OP_ge");
793 break;
794 case DW_OP_gt:
795 printf ("DW_OP_gt");
796 break;
797 case DW_OP_le:
798 printf ("DW_OP_le");
799 break;
800 case DW_OP_lt:
801 printf ("DW_OP_lt");
802 break;
803 case DW_OP_ne:
804 printf ("DW_OP_ne");
805 break;
806 case DW_OP_skip:
807 printf ("DW_OP_skip: %ld", (long) byte_get_signed (data, 2));
808 data += 2;
809 break;
810
811 case DW_OP_lit0:
812 case DW_OP_lit1:
813 case DW_OP_lit2:
814 case DW_OP_lit3:
815 case DW_OP_lit4:
816 case DW_OP_lit5:
817 case DW_OP_lit6:
818 case DW_OP_lit7:
819 case DW_OP_lit8:
820 case DW_OP_lit9:
821 case DW_OP_lit10:
822 case DW_OP_lit11:
823 case DW_OP_lit12:
824 case DW_OP_lit13:
825 case DW_OP_lit14:
826 case DW_OP_lit15:
827 case DW_OP_lit16:
828 case DW_OP_lit17:
829 case DW_OP_lit18:
830 case DW_OP_lit19:
831 case DW_OP_lit20:
832 case DW_OP_lit21:
833 case DW_OP_lit22:
834 case DW_OP_lit23:
835 case DW_OP_lit24:
836 case DW_OP_lit25:
837 case DW_OP_lit26:
838 case DW_OP_lit27:
839 case DW_OP_lit28:
840 case DW_OP_lit29:
841 case DW_OP_lit30:
842 case DW_OP_lit31:
843 printf ("DW_OP_lit%d", op - DW_OP_lit0);
844 break;
845
846 case DW_OP_reg0:
847 case DW_OP_reg1:
848 case DW_OP_reg2:
849 case DW_OP_reg3:
850 case DW_OP_reg4:
851 case DW_OP_reg5:
852 case DW_OP_reg6:
853 case DW_OP_reg7:
854 case DW_OP_reg8:
855 case DW_OP_reg9:
856 case DW_OP_reg10:
857 case DW_OP_reg11:
858 case DW_OP_reg12:
859 case DW_OP_reg13:
860 case DW_OP_reg14:
861 case DW_OP_reg15:
862 case DW_OP_reg16:
863 case DW_OP_reg17:
864 case DW_OP_reg18:
865 case DW_OP_reg19:
866 case DW_OP_reg20:
867 case DW_OP_reg21:
868 case DW_OP_reg22:
869 case DW_OP_reg23:
870 case DW_OP_reg24:
871 case DW_OP_reg25:
872 case DW_OP_reg26:
873 case DW_OP_reg27:
874 case DW_OP_reg28:
875 case DW_OP_reg29:
876 case DW_OP_reg30:
877 case DW_OP_reg31:
878 printf ("DW_OP_reg%d", op - DW_OP_reg0);
879 break;
880
881 case DW_OP_breg0:
882 case DW_OP_breg1:
883 case DW_OP_breg2:
884 case DW_OP_breg3:
885 case DW_OP_breg4:
886 case DW_OP_breg5:
887 case DW_OP_breg6:
888 case DW_OP_breg7:
889 case DW_OP_breg8:
890 case DW_OP_breg9:
891 case DW_OP_breg10:
892 case DW_OP_breg11:
893 case DW_OP_breg12:
894 case DW_OP_breg13:
895 case DW_OP_breg14:
896 case DW_OP_breg15:
897 case DW_OP_breg16:
898 case DW_OP_breg17:
899 case DW_OP_breg18:
900 case DW_OP_breg19:
901 case DW_OP_breg20:
902 case DW_OP_breg21:
903 case DW_OP_breg22:
904 case DW_OP_breg23:
905 case DW_OP_breg24:
906 case DW_OP_breg25:
907 case DW_OP_breg26:
908 case DW_OP_breg27:
909 case DW_OP_breg28:
910 case DW_OP_breg29:
911 case DW_OP_breg30:
912 case DW_OP_breg31:
913 printf ("DW_OP_breg%d: %ld", op - DW_OP_breg0,
914 read_leb128 (data, &bytes_read, 1));
915 data += bytes_read;
916 break;
917
918 case DW_OP_regx:
919 printf ("DW_OP_regx: %lu", read_leb128 (data, &bytes_read, 0));
920 data += bytes_read;
921 break;
922 case DW_OP_fbreg:
923 need_frame_base = 1;
924 printf ("DW_OP_fbreg: %ld", read_leb128 (data, &bytes_read, 1));
925 data += bytes_read;
926 break;
927 case DW_OP_bregx:
928 uvalue = read_leb128 (data, &bytes_read, 0);
929 data += bytes_read;
930 printf ("DW_OP_bregx: %lu %ld", uvalue,
931 read_leb128 (data, &bytes_read, 1));
932 data += bytes_read;
933 break;
934 case DW_OP_piece:
935 printf ("DW_OP_piece: %lu", read_leb128 (data, &bytes_read, 0));
936 data += bytes_read;
937 break;
938 case DW_OP_deref_size:
939 printf ("DW_OP_deref_size: %ld", (long) byte_get (data++, 1));
940 break;
941 case DW_OP_xderef_size:
942 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data++, 1));
943 break;
944 case DW_OP_nop:
945 printf ("DW_OP_nop");
946 break;
947
948 /* DWARF 3 extensions. */
949 case DW_OP_push_object_address:
950 printf ("DW_OP_push_object_address");
951 break;
952 case DW_OP_call2:
953 /* XXX: Strictly speaking for 64-bit DWARF3 files
954 this ought to be an 8-byte wide computation. */
955 printf ("DW_OP_call2: <%lx>", (long) byte_get (data, 2) + cu_offset);
956 data += 2;
957 break;
958 case DW_OP_call4:
959 /* XXX: Strictly speaking for 64-bit DWARF3 files
960 this ought to be an 8-byte wide computation. */
961 printf ("DW_OP_call4: <%lx>", (long) byte_get (data, 4) + cu_offset);
962 data += 4;
963 break;
964 case DW_OP_call_ref:
e2a0d921
NC
965 /* XXX: Strictly speaking for 64-bit DWARF3 files
966 this ought to be an 8-byte wide computation. */
967 printf ("DW_OP_call_ref: <%lx>", (long) byte_get (data, 4) + cu_offset);
968 data += 4;
19e6b90e 969 break;
a87b0a59
NS
970 case DW_OP_form_tls_address:
971 printf ("DW_OP_form_tls_address");
972 break;
e2a0d921
NC
973 case DW_OP_call_frame_cfa:
974 printf ("DW_OP_call_frame_cfa");
975 break;
976 case DW_OP_bit_piece:
977 printf ("DW_OP_bit_piece: ");
978 printf ("size: %lu ", read_leb128 (data, &bytes_read, 0));
979 data += bytes_read;
980 printf ("offset: %lu ", read_leb128 (data, &bytes_read, 0));
981 data += bytes_read;
982 break;
19e6b90e
L
983
984 /* GNU extensions. */
985 case DW_OP_GNU_push_tls_address:
e2a0d921
NC
986 printf ("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown");
987 break;
988 case DW_OP_GNU_uninit:
989 printf ("DW_OP_GNU_uninit");
990 /* FIXME: Is there data associated with this OP ? */
991 break;
992
993 /* HP extensions. */
994 case DW_OP_HP_is_value:
995 printf ("DW_OP_HP_is_value");
996 /* FIXME: Is there data associated with this OP ? */
997 break;
998 case DW_OP_HP_fltconst4:
999 printf ("DW_OP_HP_fltconst4");
1000 /* FIXME: Is there data associated with this OP ? */
1001 break;
1002 case DW_OP_HP_fltconst8:
1003 printf ("DW_OP_HP_fltconst8");
1004 /* FIXME: Is there data associated with this OP ? */
1005 break;
1006 case DW_OP_HP_mod_range:
1007 printf ("DW_OP_HP_mod_range");
1008 /* FIXME: Is there data associated with this OP ? */
1009 break;
1010 case DW_OP_HP_unmod_range:
1011 printf ("DW_OP_HP_unmod_range");
1012 /* FIXME: Is there data associated with this OP ? */
1013 break;
1014 case DW_OP_HP_tls:
1015 printf ("DW_OP_HP_tls");
1016 /* FIXME: Is there data associated with this OP ? */
19e6b90e
L
1017 break;
1018
35d60fe4
NC
1019 /* PGI (STMicroelectronics) extensions. */
1020 case DW_OP_PGI_omp_thread_num:
1021 /* Pushes the thread number for the current thread as it would be
1022 returned by the standard OpenMP library function:
1023 omp_get_thread_num(). The "current thread" is the thread for
1024 which the expression is being evaluated. */
1025 printf ("DW_OP_PGI_omp_thread_num");
1026 break;
1027
19e6b90e
L
1028 default:
1029 if (op >= DW_OP_lo_user
1030 && op <= DW_OP_hi_user)
1031 printf (_("(User defined location op)"));
1032 else
1033 printf (_("(Unknown location op)"));
1034 /* No way to tell where the next op is, so just bail. */
1035 return need_frame_base;
1036 }
1037
1038 /* Separate the ops. */
1039 if (data < end)
1040 printf ("; ");
1041 }
1042
1043 return need_frame_base;
1044}
1045
1046static unsigned char *
6e3d6dc1
NC
1047read_and_display_attr_value (unsigned long attribute,
1048 unsigned long form,
ec4d4525 1049 unsigned char * data,
6e3d6dc1
NC
1050 unsigned long cu_offset,
1051 unsigned long pointer_size,
1052 unsigned long offset_size,
1053 int dwarf_version,
1054 debug_info * debug_info_p,
1055 int do_loc,
1056 struct dwarf_section * section)
19e6b90e
L
1057{
1058 unsigned long uvalue = 0;
1059 unsigned char *block_start = NULL;
6e3d6dc1 1060 unsigned char * orig_data = data;
19e6b90e
L
1061 unsigned int bytes_read;
1062
1063 switch (form)
1064 {
1065 default:
1066 break;
1067
1068 case DW_FORM_ref_addr:
1069 if (dwarf_version == 2)
1070 {
1071 uvalue = byte_get (data, pointer_size);
1072 data += pointer_size;
1073 }
1074 else if (dwarf_version == 3)
1075 {
1076 uvalue = byte_get (data, offset_size);
1077 data += offset_size;
1078 }
1079 else
1080 {
1081 error (_("Internal error: DWARF version is not 2 or 3.\n"));
1082 }
1083 break;
1084
1085 case DW_FORM_addr:
1086 uvalue = byte_get (data, pointer_size);
1087 data += pointer_size;
1088 break;
1089
1090 case DW_FORM_strp:
1091 uvalue = byte_get (data, offset_size);
1092 data += offset_size;
1093 break;
1094
1095 case DW_FORM_ref1:
1096 case DW_FORM_flag:
1097 case DW_FORM_data1:
1098 uvalue = byte_get (data++, 1);
1099 break;
1100
1101 case DW_FORM_ref2:
1102 case DW_FORM_data2:
1103 uvalue = byte_get (data, 2);
1104 data += 2;
1105 break;
1106
1107 case DW_FORM_ref4:
1108 case DW_FORM_data4:
1109 uvalue = byte_get (data, 4);
1110 data += 4;
1111 break;
1112
1113 case DW_FORM_sdata:
1114 uvalue = read_leb128 (data, & bytes_read, 1);
1115 data += bytes_read;
1116 break;
1117
1118 case DW_FORM_ref_udata:
1119 case DW_FORM_udata:
1120 uvalue = read_leb128 (data, & bytes_read, 0);
1121 data += bytes_read;
1122 break;
1123
1124 case DW_FORM_indirect:
1125 form = read_leb128 (data, & bytes_read, 0);
1126 data += bytes_read;
1127 if (!do_loc)
1128 printf (" %s", get_FORM_name (form));
1129 return read_and_display_attr_value (attribute, form, data,
1130 cu_offset, pointer_size,
1131 offset_size, dwarf_version,
ec4d4525 1132 debug_info_p, do_loc,
6e3d6dc1 1133 section);
19e6b90e
L
1134 }
1135
1136 switch (form)
1137 {
1138 case DW_FORM_ref_addr:
1139 if (!do_loc)
ec4d4525 1140 printf (" <0x%lx>", uvalue);
19e6b90e
L
1141 break;
1142
1143 case DW_FORM_ref1:
1144 case DW_FORM_ref2:
1145 case DW_FORM_ref4:
1146 case DW_FORM_ref_udata:
1147 if (!do_loc)
ec4d4525 1148 printf (" <0x%lx>", uvalue + cu_offset);
19e6b90e
L
1149 break;
1150
1151 case DW_FORM_data4:
1152 case DW_FORM_addr:
1153 if (!do_loc)
ec4d4525 1154 printf (" 0x%lx", uvalue);
19e6b90e
L
1155 break;
1156
1157 case DW_FORM_flag:
1158 case DW_FORM_data1:
1159 case DW_FORM_data2:
1160 case DW_FORM_sdata:
1161 case DW_FORM_udata:
1162 if (!do_loc)
1163 printf (" %ld", uvalue);
1164 break;
1165
1166 case DW_FORM_ref8:
1167 case DW_FORM_data8:
1168 if (!do_loc)
1169 {
1170 uvalue = byte_get (data, 4);
ec4d4525
NC
1171 printf (" 0x%lx", uvalue);
1172 printf (" 0x%lx", (unsigned long) byte_get (data + 4, 4));
19e6b90e
L
1173 }
1174 if ((do_loc || do_debug_loc || do_debug_ranges)
1175 && num_debug_info_entries == 0)
1176 {
1177 if (sizeof (uvalue) == 8)
1178 uvalue = byte_get (data, 8);
1179 else
1180 error (_("DW_FORM_data8 is unsupported when sizeof (unsigned long) != 8\n"));
1181 }
1182 data += 8;
1183 break;
1184
1185 case DW_FORM_string:
1186 if (!do_loc)
1187 printf (" %s", data);
1188 data += strlen ((char *) data) + 1;
1189 break;
1190
1191 case DW_FORM_block:
1192 uvalue = read_leb128 (data, & bytes_read, 0);
1193 block_start = data + bytes_read;
1194 if (do_loc)
1195 data = block_start + uvalue;
1196 else
1197 data = display_block (block_start, uvalue);
1198 break;
1199
1200 case DW_FORM_block1:
1201 uvalue = byte_get (data, 1);
1202 block_start = data + 1;
1203 if (do_loc)
1204 data = block_start + uvalue;
1205 else
1206 data = display_block (block_start, uvalue);
1207 break;
1208
1209 case DW_FORM_block2:
1210 uvalue = byte_get (data, 2);
1211 block_start = data + 2;
1212 if (do_loc)
1213 data = block_start + uvalue;
1214 else
1215 data = display_block (block_start, uvalue);
1216 break;
1217
1218 case DW_FORM_block4:
1219 uvalue = byte_get (data, 4);
1220 block_start = data + 4;
1221 if (do_loc)
1222 data = block_start + uvalue;
1223 else
1224 data = display_block (block_start, uvalue);
1225 break;
1226
1227 case DW_FORM_strp:
1228 if (!do_loc)
1229 printf (_(" (indirect string, offset: 0x%lx): %s"),
1230 uvalue, fetch_indirect_string (uvalue));
1231 break;
1232
1233 case DW_FORM_indirect:
1234 /* Handled above. */
1235 break;
1236
1237 default:
1238 warn (_("Unrecognized form: %lu\n"), form);
1239 break;
1240 }
1241
19e6b90e
L
1242 if ((do_loc || do_debug_loc || do_debug_ranges)
1243 && num_debug_info_entries == 0)
1244 {
1245 switch (attribute)
1246 {
1247 case DW_AT_frame_base:
1248 have_frame_base = 1;
1249 case DW_AT_location:
e2a0d921
NC
1250 case DW_AT_string_length:
1251 case DW_AT_return_addr:
19e6b90e
L
1252 case DW_AT_data_member_location:
1253 case DW_AT_vtable_elem_location:
e2a0d921
NC
1254 case DW_AT_segment:
1255 case DW_AT_static_link:
1256 case DW_AT_use_location:
1257 if (form == DW_FORM_data4 || form == DW_FORM_data8)
19e6b90e
L
1258 {
1259 /* Process location list. */
1260 unsigned int max = debug_info_p->max_loc_offsets;
1261 unsigned int num = debug_info_p->num_loc_offsets;
1262
1263 if (max == 0 || num >= max)
1264 {
1265 max += 1024;
1266 debug_info_p->loc_offsets
1267 = xcrealloc (debug_info_p->loc_offsets,
1268 max, sizeof (*debug_info_p->loc_offsets));
1269 debug_info_p->have_frame_base
1270 = xcrealloc (debug_info_p->have_frame_base,
1271 max, sizeof (*debug_info_p->have_frame_base));
1272 debug_info_p->max_loc_offsets = max;
1273 }
1274 debug_info_p->loc_offsets [num] = uvalue;
1275 debug_info_p->have_frame_base [num] = have_frame_base;
1276 debug_info_p->num_loc_offsets++;
1277 }
1278 break;
e2a0d921 1279
19e6b90e
L
1280 case DW_AT_low_pc:
1281 if (need_base_address)
1282 debug_info_p->base_address = uvalue;
1283 break;
1284
1285 case DW_AT_ranges:
1286 if (form == DW_FORM_data4 || form == DW_FORM_data8)
1287 {
1288 /* Process range list. */
1289 unsigned int max = debug_info_p->max_range_lists;
1290 unsigned int num = debug_info_p->num_range_lists;
1291
1292 if (max == 0 || num >= max)
1293 {
1294 max += 1024;
1295 debug_info_p->range_lists
1296 = xcrealloc (debug_info_p->range_lists,
1297 max, sizeof (*debug_info_p->range_lists));
1298 debug_info_p->max_range_lists = max;
1299 }
1300 debug_info_p->range_lists [num] = uvalue;
1301 debug_info_p->num_range_lists++;
1302 }
1303 break;
1304
1305 default:
1306 break;
1307 }
1308 }
1309
1310 if (do_loc)
1311 return data;
1312
ec4d4525 1313 /* For some attributes we can display further information. */
19e6b90e
L
1314 printf ("\t");
1315
1316 switch (attribute)
1317 {
1318 case DW_AT_inline:
1319 switch (uvalue)
1320 {
1321 case DW_INL_not_inlined:
1322 printf (_("(not inlined)"));
1323 break;
1324 case DW_INL_inlined:
1325 printf (_("(inlined)"));
1326 break;
1327 case DW_INL_declared_not_inlined:
1328 printf (_("(declared as inline but ignored)"));
1329 break;
1330 case DW_INL_declared_inlined:
1331 printf (_("(declared as inline and inlined)"));
1332 break;
1333 default:
1334 printf (_(" (Unknown inline attribute value: %lx)"), uvalue);
1335 break;
1336 }
1337 break;
1338
1339 case DW_AT_language:
1340 switch (uvalue)
1341 {
4b78141a 1342 /* Ordered by the numeric value of these constants. */
19e6b90e 1343 case DW_LANG_C89: printf ("(ANSI C)"); break;
4b78141a
NC
1344 case DW_LANG_C: printf ("(non-ANSI C)"); break;
1345 case DW_LANG_Ada83: printf ("(Ada)"); break;
19e6b90e 1346 case DW_LANG_C_plus_plus: printf ("(C++)"); break;
4b78141a
NC
1347 case DW_LANG_Cobol74: printf ("(Cobol 74)"); break;
1348 case DW_LANG_Cobol85: printf ("(Cobol 85)"); break;
19e6b90e
L
1349 case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break;
1350 case DW_LANG_Fortran90: printf ("(Fortran 90)"); break;
19e6b90e 1351 case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break;
4b78141a 1352 case DW_LANG_Modula2: printf ("(Modula 2)"); break;
19e6b90e 1353 /* DWARF 2.1 values. */
4b78141a 1354 case DW_LANG_Java: printf ("(Java)"); break;
19e6b90e
L
1355 case DW_LANG_C99: printf ("(ANSI C99)"); break;
1356 case DW_LANG_Ada95: printf ("(ADA 95)"); break;
1357 case DW_LANG_Fortran95: printf ("(Fortran 95)"); break;
4b78141a
NC
1358 /* DWARF 3 values. */
1359 case DW_LANG_PLI: printf ("(PLI)"); break;
1360 case DW_LANG_ObjC: printf ("(Objective C)"); break;
1361 case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break;
1362 case DW_LANG_UPC: printf ("(Unified Parallel C)"); break;
1363 case DW_LANG_D: printf ("(D)"); break;
19e6b90e
L
1364 /* MIPS extension. */
1365 case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break;
1366 /* UPC extension. */
1367 case DW_LANG_Upc: printf ("(Unified Parallel C)"); break;
1368 default:
4b78141a
NC
1369 if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user)
1370 printf ("(implementation defined: %lx)", uvalue);
1371 else
1372 printf ("(Unknown: %lx)", uvalue);
19e6b90e
L
1373 break;
1374 }
1375 break;
1376
1377 case DW_AT_encoding:
1378 switch (uvalue)
1379 {
1380 case DW_ATE_void: printf ("(void)"); break;
1381 case DW_ATE_address: printf ("(machine address)"); break;
1382 case DW_ATE_boolean: printf ("(boolean)"); break;
1383 case DW_ATE_complex_float: printf ("(complex float)"); break;
1384 case DW_ATE_float: printf ("(float)"); break;
1385 case DW_ATE_signed: printf ("(signed)"); break;
1386 case DW_ATE_signed_char: printf ("(signed char)"); break;
1387 case DW_ATE_unsigned: printf ("(unsigned)"); break;
1388 case DW_ATE_unsigned_char: printf ("(unsigned char)"); break;
e2a0d921 1389 /* DWARF 2.1 values: */
19e6b90e
L
1390 case DW_ATE_imaginary_float: printf ("(imaginary float)"); break;
1391 case DW_ATE_decimal_float: printf ("(decimal float)"); break;
e2a0d921
NC
1392 /* DWARF 3 values: */
1393 case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break;
1394 case DW_ATE_numeric_string: printf ("(numeric_string)"); break;
1395 case DW_ATE_edited: printf ("(edited)"); break;
1396 case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break;
1397 case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break;
1398 /* HP extensions: */
1399 case DW_ATE_HP_float80: printf ("(HP_float80)"); break;
1400 case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break;
1401 case DW_ATE_HP_float128: printf ("(HP_float128)"); break;
1402 case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break;
1403 case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break;
1404 case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break;
1405 case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break;
1406
19e6b90e
L
1407 default:
1408 if (uvalue >= DW_ATE_lo_user
1409 && uvalue <= DW_ATE_hi_user)
1410 printf ("(user defined type)");
1411 else
1412 printf ("(unknown type)");
1413 break;
1414 }
1415 break;
1416
1417 case DW_AT_accessibility:
1418 switch (uvalue)
1419 {
1420 case DW_ACCESS_public: printf ("(public)"); break;
1421 case DW_ACCESS_protected: printf ("(protected)"); break;
1422 case DW_ACCESS_private: printf ("(private)"); break;
1423 default:
1424 printf ("(unknown accessibility)");
1425 break;
1426 }
1427 break;
1428
1429 case DW_AT_visibility:
1430 switch (uvalue)
1431 {
1432 case DW_VIS_local: printf ("(local)"); break;
1433 case DW_VIS_exported: printf ("(exported)"); break;
1434 case DW_VIS_qualified: printf ("(qualified)"); break;
1435 default: printf ("(unknown visibility)"); break;
1436 }
1437 break;
1438
1439 case DW_AT_virtuality:
1440 switch (uvalue)
1441 {
1442 case DW_VIRTUALITY_none: printf ("(none)"); break;
1443 case DW_VIRTUALITY_virtual: printf ("(virtual)"); break;
1444 case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break;
1445 default: printf ("(unknown virtuality)"); break;
1446 }
1447 break;
1448
1449 case DW_AT_identifier_case:
1450 switch (uvalue)
1451 {
1452 case DW_ID_case_sensitive: printf ("(case_sensitive)"); break;
1453 case DW_ID_up_case: printf ("(up_case)"); break;
1454 case DW_ID_down_case: printf ("(down_case)"); break;
1455 case DW_ID_case_insensitive: printf ("(case_insensitive)"); break;
1456 default: printf ("(unknown case)"); break;
1457 }
1458 break;
1459
1460 case DW_AT_calling_convention:
1461 switch (uvalue)
1462 {
1463 case DW_CC_normal: printf ("(normal)"); break;
1464 case DW_CC_program: printf ("(program)"); break;
1465 case DW_CC_nocall: printf ("(nocall)"); break;
1466 default:
1467 if (uvalue >= DW_CC_lo_user
1468 && uvalue <= DW_CC_hi_user)
1469 printf ("(user defined)");
1470 else
1471 printf ("(unknown convention)");
1472 }
1473 break;
1474
1475 case DW_AT_ordering:
1476 switch (uvalue)
1477 {
1478 case -1: printf ("(undefined)"); break;
1479 case 0: printf ("(row major)"); break;
1480 case 1: printf ("(column major)"); break;
1481 }
1482 break;
1483
1484 case DW_AT_frame_base:
1485 have_frame_base = 1;
1486 case DW_AT_location:
e2a0d921
NC
1487 case DW_AT_string_length:
1488 case DW_AT_return_addr:
19e6b90e
L
1489 case DW_AT_data_member_location:
1490 case DW_AT_vtable_elem_location:
e2a0d921
NC
1491 case DW_AT_segment:
1492 case DW_AT_static_link:
1493 case DW_AT_use_location:
1494 if (form == DW_FORM_data4 || form == DW_FORM_data8)
1495 printf (_("(location list)"));
1496 /* Fall through. */
19e6b90e
L
1497 case DW_AT_allocated:
1498 case DW_AT_associated:
1499 case DW_AT_data_location:
1500 case DW_AT_stride:
1501 case DW_AT_upper_bound:
cecf136e 1502 case DW_AT_lower_bound:
19e6b90e
L
1503 if (block_start)
1504 {
1505 int need_frame_base;
1506
1507 printf ("(");
1508 need_frame_base = decode_location_expression (block_start,
1509 pointer_size,
1510 uvalue,
1511 cu_offset);
1512 printf (")");
1513 if (need_frame_base && !have_frame_base)
1514 printf (_(" [without DW_AT_frame_base]"));
1515 }
19e6b90e
L
1516 break;
1517
ec4d4525
NC
1518 case DW_AT_import:
1519 {
ec4d4525
NC
1520 if (form == DW_FORM_ref1
1521 || form == DW_FORM_ref2
1522 || form == DW_FORM_ref4)
1523 uvalue += cu_offset;
1524
6e3d6dc1
NC
1525 if (uvalue >= section->size)
1526 warn (_("Offset %lx used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"),
0af1713e 1527 uvalue, (unsigned long) (orig_data - section->start));
6e3d6dc1
NC
1528 else
1529 {
1530 unsigned long abbrev_number;
1531 abbrev_entry * entry;
1532
1533 abbrev_number = read_leb128 (section->start + uvalue, NULL, 0);
cecf136e 1534
6e3d6dc1
NC
1535 printf ("[Abbrev Number: %ld", abbrev_number);
1536 for (entry = first_abbrev; entry != NULL; entry = entry->next)
1537 if (entry->entry == abbrev_number)
1538 break;
1539 if (entry != NULL)
1540 printf (" (%s)", get_TAG_name (entry->tag));
1541 printf ("]");
1542 }
ec4d4525
NC
1543 }
1544 break;
1545
19e6b90e
L
1546 default:
1547 break;
1548 }
1549
1550 return data;
1551}
1552
1553static char *
1554get_AT_name (unsigned long attribute)
1555{
1556 switch (attribute)
1557 {
1558 case DW_AT_sibling: return "DW_AT_sibling";
1559 case DW_AT_location: return "DW_AT_location";
1560 case DW_AT_name: return "DW_AT_name";
1561 case DW_AT_ordering: return "DW_AT_ordering";
1562 case DW_AT_subscr_data: return "DW_AT_subscr_data";
1563 case DW_AT_byte_size: return "DW_AT_byte_size";
1564 case DW_AT_bit_offset: return "DW_AT_bit_offset";
1565 case DW_AT_bit_size: return "DW_AT_bit_size";
1566 case DW_AT_element_list: return "DW_AT_element_list";
1567 case DW_AT_stmt_list: return "DW_AT_stmt_list";
1568 case DW_AT_low_pc: return "DW_AT_low_pc";
1569 case DW_AT_high_pc: return "DW_AT_high_pc";
1570 case DW_AT_language: return "DW_AT_language";
1571 case DW_AT_member: return "DW_AT_member";
1572 case DW_AT_discr: return "DW_AT_discr";
1573 case DW_AT_discr_value: return "DW_AT_discr_value";
1574 case DW_AT_visibility: return "DW_AT_visibility";
1575 case DW_AT_import: return "DW_AT_import";
1576 case DW_AT_string_length: return "DW_AT_string_length";
1577 case DW_AT_common_reference: return "DW_AT_common_reference";
1578 case DW_AT_comp_dir: return "DW_AT_comp_dir";
1579 case DW_AT_const_value: return "DW_AT_const_value";
1580 case DW_AT_containing_type: return "DW_AT_containing_type";
1581 case DW_AT_default_value: return "DW_AT_default_value";
1582 case DW_AT_inline: return "DW_AT_inline";
1583 case DW_AT_is_optional: return "DW_AT_is_optional";
1584 case DW_AT_lower_bound: return "DW_AT_lower_bound";
1585 case DW_AT_producer: return "DW_AT_producer";
1586 case DW_AT_prototyped: return "DW_AT_prototyped";
1587 case DW_AT_return_addr: return "DW_AT_return_addr";
1588 case DW_AT_start_scope: return "DW_AT_start_scope";
1589 case DW_AT_stride_size: return "DW_AT_stride_size";
1590 case DW_AT_upper_bound: return "DW_AT_upper_bound";
1591 case DW_AT_abstract_origin: return "DW_AT_abstract_origin";
1592 case DW_AT_accessibility: return "DW_AT_accessibility";
1593 case DW_AT_address_class: return "DW_AT_address_class";
1594 case DW_AT_artificial: return "DW_AT_artificial";
1595 case DW_AT_base_types: return "DW_AT_base_types";
1596 case DW_AT_calling_convention: return "DW_AT_calling_convention";
1597 case DW_AT_count: return "DW_AT_count";
1598 case DW_AT_data_member_location: return "DW_AT_data_member_location";
1599 case DW_AT_decl_column: return "DW_AT_decl_column";
1600 case DW_AT_decl_file: return "DW_AT_decl_file";
1601 case DW_AT_decl_line: return "DW_AT_decl_line";
1602 case DW_AT_declaration: return "DW_AT_declaration";
1603 case DW_AT_discr_list: return "DW_AT_discr_list";
1604 case DW_AT_encoding: return "DW_AT_encoding";
1605 case DW_AT_external: return "DW_AT_external";
1606 case DW_AT_frame_base: return "DW_AT_frame_base";
1607 case DW_AT_friend: return "DW_AT_friend";
1608 case DW_AT_identifier_case: return "DW_AT_identifier_case";
1609 case DW_AT_macro_info: return "DW_AT_macro_info";
1610 case DW_AT_namelist_items: return "DW_AT_namelist_items";
1611 case DW_AT_priority: return "DW_AT_priority";
1612 case DW_AT_segment: return "DW_AT_segment";
1613 case DW_AT_specification: return "DW_AT_specification";
1614 case DW_AT_static_link: return "DW_AT_static_link";
1615 case DW_AT_type: return "DW_AT_type";
1616 case DW_AT_use_location: return "DW_AT_use_location";
1617 case DW_AT_variable_parameter: return "DW_AT_variable_parameter";
1618 case DW_AT_virtuality: return "DW_AT_virtuality";
1619 case DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location";
1620 /* DWARF 2.1 values. */
1621 case DW_AT_allocated: return "DW_AT_allocated";
1622 case DW_AT_associated: return "DW_AT_associated";
1623 case DW_AT_data_location: return "DW_AT_data_location";
1624 case DW_AT_stride: return "DW_AT_stride";
1625 case DW_AT_entry_pc: return "DW_AT_entry_pc";
1626 case DW_AT_use_UTF8: return "DW_AT_use_UTF8";
1627 case DW_AT_extension: return "DW_AT_extension";
1628 case DW_AT_ranges: return "DW_AT_ranges";
1629 case DW_AT_trampoline: return "DW_AT_trampoline";
1630 case DW_AT_call_column: return "DW_AT_call_column";
1631 case DW_AT_call_file: return "DW_AT_call_file";
1632 case DW_AT_call_line: return "DW_AT_call_line";
e2a0d921
NC
1633 case DW_AT_description: return "DW_AT_description";
1634 case DW_AT_binary_scale: return "DW_AT_binary_scale";
1635 case DW_AT_decimal_scale: return "DW_AT_decimal_scale";
1636 case DW_AT_small: return "DW_AT_small";
1637 case DW_AT_decimal_sign: return "DW_AT_decimal_sign";
1638 case DW_AT_digit_count: return "DW_AT_digit_count";
1639 case DW_AT_picture_string: return "DW_AT_picture_string";
1640 case DW_AT_mutable: return "DW_AT_mutable";
1641 case DW_AT_threads_scaled: return "DW_AT_threads_scaled";
1642 case DW_AT_explicit: return "DW_AT_explicit";
1643 case DW_AT_object_pointer: return "DW_AT_object_pointer";
1644 case DW_AT_endianity: return "DW_AT_endianity";
1645 case DW_AT_elemental: return "DW_AT_elemental";
1646 case DW_AT_pure: return "DW_AT_pure";
1647 case DW_AT_recursive: return "DW_AT_recursive";
1648
1649 /* HP and SGI/MIPS extensions. */
1650 case DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin";
1651 case DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin";
1652 case DW_AT_MIPS_epilog_begin: return "DW_AT_MIPS_epilog_begin";
1653 case DW_AT_MIPS_loop_unroll_factor: return "DW_AT_MIPS_loop_unroll_factor";
1654 case DW_AT_MIPS_software_pipeline_depth: return "DW_AT_MIPS_software_pipeline_depth";
1655 case DW_AT_MIPS_linkage_name: return "DW_AT_MIPS_linkage_name";
1656 case DW_AT_MIPS_stride: return "DW_AT_MIPS_stride";
1657 case DW_AT_MIPS_abstract_name: return "DW_AT_MIPS_abstract_name";
1658 case DW_AT_MIPS_clone_origin: return "DW_AT_MIPS_clone_origin";
1659 case DW_AT_MIPS_has_inlines: return "DW_AT_MIPS_has_inlines";
1660
1661 /* HP Extensions. */
cecf136e 1662 case DW_AT_HP_block_index: return "DW_AT_HP_block_index";
e2a0d921
NC
1663 case DW_AT_HP_actuals_stmt_list: return "DW_AT_HP_actuals_stmt_list";
1664 case DW_AT_HP_proc_per_section: return "DW_AT_HP_proc_per_section";
1665 case DW_AT_HP_raw_data_ptr: return "DW_AT_HP_raw_data_ptr";
1666 case DW_AT_HP_pass_by_reference: return "DW_AT_HP_pass_by_reference";
1667 case DW_AT_HP_opt_level: return "DW_AT_HP_opt_level";
1668 case DW_AT_HP_prof_version_id: return "DW_AT_HP_prof_version_id";
1669 case DW_AT_HP_opt_flags: return "DW_AT_HP_opt_flags";
1670 case DW_AT_HP_cold_region_low_pc: return "DW_AT_HP_cold_region_low_pc";
1671 case DW_AT_HP_cold_region_high_pc: return "DW_AT_HP_cold_region_high_pc";
1672 case DW_AT_HP_all_variables_modifiable: return "DW_AT_HP_all_variables_modifiable";
1673 case DW_AT_HP_linkage_name: return "DW_AT_HP_linkage_name";
1674 case DW_AT_HP_prof_flags: return "DW_AT_HP_prof_flags";
1675
1676 /* One value is shared by the MIPS and HP extensions: */
1677 case DW_AT_MIPS_fde: return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
cecf136e 1678
19e6b90e
L
1679 /* GNU extensions. */
1680 case DW_AT_sf_names: return "DW_AT_sf_names";
1681 case DW_AT_src_info: return "DW_AT_src_info";
1682 case DW_AT_mac_info: return "DW_AT_mac_info";
1683 case DW_AT_src_coords: return "DW_AT_src_coords";
1684 case DW_AT_body_begin: return "DW_AT_body_begin";
1685 case DW_AT_body_end: return "DW_AT_body_end";
1686 case DW_AT_GNU_vector: return "DW_AT_GNU_vector";
e2a0d921 1687
19e6b90e
L
1688 /* UPC extension. */
1689 case DW_AT_upc_threads_scaled: return "DW_AT_upc_threads_scaled";
e2a0d921
NC
1690
1691 /* PGI (STMicroelectronics) extensions. */
1692 case DW_AT_PGI_lbase: return "DW_AT_PGI_lbase";
1693 case DW_AT_PGI_soffset: return "DW_AT_PGI_soffset";
1694 case DW_AT_PGI_lstride: return "DW_AT_PGI_lstride";
1695
19e6b90e
L
1696 default:
1697 {
1698 static char buffer[100];
1699
1700 snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"),
1701 attribute);
1702 return buffer;
1703 }
1704 }
1705}
1706
1707static unsigned char *
6e3d6dc1
NC
1708read_and_display_attr (unsigned long attribute,
1709 unsigned long form,
ec4d4525 1710 unsigned char * data,
6e3d6dc1
NC
1711 unsigned long cu_offset,
1712 unsigned long pointer_size,
1713 unsigned long offset_size,
1714 int dwarf_version,
1715 debug_info * debug_info_p,
1716 int do_loc,
1717 struct dwarf_section * section)
19e6b90e
L
1718{
1719 if (!do_loc)
750f03b7 1720 printf (" %-18s:", get_AT_name (attribute));
19e6b90e
L
1721 data = read_and_display_attr_value (attribute, form, data, cu_offset,
1722 pointer_size, offset_size,
1723 dwarf_version, debug_info_p,
6e3d6dc1 1724 do_loc, section);
19e6b90e
L
1725 if (!do_loc)
1726 printf ("\n");
1727 return data;
1728}
1729
1730
1731/* Process the contents of a .debug_info section. If do_loc is non-zero
1732 then we are scanning for location lists and we do not want to display
1733 anything to the user. */
1734
1735static int
6e3d6dc1
NC
1736process_debug_info (struct dwarf_section *section,
1737 void *file,
19e6b90e
L
1738 int do_loc)
1739{
1740 unsigned char *start = section->start;
1741 unsigned char *end = start + section->size;
1742 unsigned char *section_begin;
1743 unsigned int unit;
1744 unsigned int num_units = 0;
1745
1746 if ((do_loc || do_debug_loc || do_debug_ranges)
1747 && num_debug_info_entries == 0)
1748 {
1749 unsigned long length;
1750
1751 /* First scan the section to get the number of comp units. */
1752 for (section_begin = start, num_units = 0; section_begin < end;
1753 num_units ++)
1754 {
1755 /* Read the first 4 bytes. For a 32-bit DWARF section, this
1756 will be the length. For a 64-bit DWARF section, it'll be
1757 the escape code 0xffffffff followed by an 8 byte length. */
1758 length = byte_get (section_begin, 4);
1759
1760 if (length == 0xffffffff)
1761 {
1762 length = byte_get (section_begin + 4, 8);
1763 section_begin += length + 12;
1764 }
ec4d4525
NC
1765 else if (length >= 0xfffffff0 && length < 0xffffffff)
1766 {
1767 warn (_("Reserved length value (%lx) found in section %s\n"), length, section->name);
1768 return 0;
1769 }
19e6b90e
L
1770 else
1771 section_begin += length + 4;
aca88567
NC
1772
1773 /* Negative values are illegal, they may even cause infinite
1774 looping. This can happen if we can't accurately apply
1775 relocations to an object file. */
1776 if ((signed long) length <= 0)
1777 {
1778 warn (_("Corrupt unit length (%lx) found in section %s\n"), length, section->name);
1779 return 0;
1780 }
19e6b90e
L
1781 }
1782
1783 if (num_units == 0)
1784 {
1785 error (_("No comp units in %s section ?"), section->name);
1786 return 0;
1787 }
1788
1789 /* Then allocate an array to hold the information. */
1790 debug_information = cmalloc (num_units,
1791 sizeof (* debug_information));
1792 if (debug_information == NULL)
1793 {
1794 error (_("Not enough memory for a debug info array of %u entries"),
1795 num_units);
1796 return 0;
1797 }
1798 }
1799
1800 if (!do_loc)
1801 {
1802 printf (_("The section %s contains:\n\n"), section->name);
1803
1804 load_debug_section (str, file);
1805 }
1806
1807 load_debug_section (abbrev, file);
1808 if (debug_displays [abbrev].section.start == NULL)
1809 {
1810 warn (_("Unable to locate %s section!\n"),
1811 debug_displays [abbrev].section.name);
1812 return 0;
1813 }
1814
1815 for (section_begin = start, unit = 0; start < end; unit++)
1816 {
1817 DWARF2_Internal_CompUnit compunit;
1818 unsigned char *hdrptr;
1819 unsigned char *cu_abbrev_offset_ptr;
1820 unsigned char *tags;
1821 int level;
1822 unsigned long cu_offset;
1823 int offset_size;
1824 int initial_length_size;
1825
1826 hdrptr = start;
1827
1828 compunit.cu_length = byte_get (hdrptr, 4);
1829 hdrptr += 4;
1830
1831 if (compunit.cu_length == 0xffffffff)
1832 {
1833 compunit.cu_length = byte_get (hdrptr, 8);
1834 hdrptr += 8;
1835 offset_size = 8;
1836 initial_length_size = 12;
1837 }
1838 else
1839 {
1840 offset_size = 4;
1841 initial_length_size = 4;
1842 }
1843
1844 compunit.cu_version = byte_get (hdrptr, 2);
1845 hdrptr += 2;
1846
1847 cu_offset = start - section_begin;
19e6b90e
L
1848
1849 cu_abbrev_offset_ptr = hdrptr;
1850 compunit.cu_abbrev_offset = byte_get (hdrptr, offset_size);
1851 hdrptr += offset_size;
1852
1853 compunit.cu_pointer_size = byte_get (hdrptr, 1);
1854 hdrptr += 1;
1855 if ((do_loc || do_debug_loc || do_debug_ranges)
1856 && num_debug_info_entries == 0)
1857 {
1858 debug_information [unit].cu_offset = cu_offset;
1859 debug_information [unit].pointer_size
1860 = compunit.cu_pointer_size;
1861 debug_information [unit].base_address = 0;
1862 debug_information [unit].loc_offsets = NULL;
1863 debug_information [unit].have_frame_base = NULL;
1864 debug_information [unit].max_loc_offsets = 0;
1865 debug_information [unit].num_loc_offsets = 0;
1866 debug_information [unit].range_lists = NULL;
1867 debug_information [unit].max_range_lists= 0;
1868 debug_information [unit].num_range_lists = 0;
1869 }
1870
19e6b90e
L
1871 if (!do_loc)
1872 {
1873 printf (_(" Compilation Unit @ offset 0x%lx:\n"), cu_offset);
cc86f28f
NC
1874 printf (_(" Length: 0x%lx (%s)\n"), compunit.cu_length,
1875 initial_length_size == 8 ? "64-bit" : "32-bit");
19e6b90e
L
1876 printf (_(" Version: %d\n"), compunit.cu_version);
1877 printf (_(" Abbrev Offset: %ld\n"), compunit.cu_abbrev_offset);
1878 printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size);
1879 }
1880
460c89ff
NS
1881 if (cu_offset + compunit.cu_length + initial_length_size
1882 > section->size)
1883 {
ec4d4525
NC
1884 warn (_("Debug info is corrupted, length of CU at %lx extends beyond end of section (length = %lx)\n"),
1885 cu_offset, compunit.cu_length);
460c89ff
NS
1886 break;
1887 }
1888 tags = hdrptr;
1889 start += compunit.cu_length + initial_length_size;
1890
19e6b90e
L
1891 if (compunit.cu_version != 2 && compunit.cu_version != 3)
1892 {
1febe64d
NC
1893 warn (_("CU at offset %lx contains corrupt or unsupported version number: %d.\n"),
1894 cu_offset, compunit.cu_version);
19e6b90e
L
1895 continue;
1896 }
1897
1898 free_abbrevs ();
1899
bfe2612a
L
1900 /* Process the abbrevs used by this compilation unit. DWARF
1901 sections under Mach-O have non-zero addresses. */
460c89ff 1902 if (compunit.cu_abbrev_offset >= debug_displays [abbrev].section.size)
ec4d4525
NC
1903 warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
1904 (unsigned long) compunit.cu_abbrev_offset,
1905 (unsigned long) debug_displays [abbrev].section.size);
460c89ff
NS
1906 else
1907 process_abbrev_section
1908 ((unsigned char *) debug_displays [abbrev].section.start
1909 + compunit.cu_abbrev_offset - debug_displays [abbrev].section.address,
1910 (unsigned char *) debug_displays [abbrev].section.start
1911 + debug_displays [abbrev].section.size);
19e6b90e
L
1912
1913 level = 0;
1914 while (tags < start)
1915 {
1916 unsigned int bytes_read;
1917 unsigned long abbrev_number;
ec4d4525 1918 unsigned long die_offset;
19e6b90e
L
1919 abbrev_entry *entry;
1920 abbrev_attr *attr;
1921
ec4d4525
NC
1922 die_offset = tags - section_begin;
1923
19e6b90e
L
1924 abbrev_number = read_leb128 (tags, & bytes_read, 0);
1925 tags += bytes_read;
1926
ec4d4525 1927 /* A null DIE marks the end of a list of siblings. */
19e6b90e
L
1928 if (abbrev_number == 0)
1929 {
1930 --level;
ec4d4525
NC
1931 if (level < 0)
1932 {
1933 static unsigned num_bogus_warns = 0;
1934
1935 if (num_bogus_warns < 3)
1936 {
1937 warn (_("Bogus end-of-siblings marker detected at offset %lx in .debug_info section\n"),
1938 die_offset);
1939 num_bogus_warns ++;
1940 if (num_bogus_warns == 3)
1941 warn (_("Further warnings about bogus end-of-sibling markers suppressed\n"));
1942 }
1943 }
19e6b90e
L
1944 continue;
1945 }
1946
4b78141a
NC
1947 if (!do_loc)
1948 printf (_(" <%d><%lx>: Abbrev Number: %lu"),
ec4d4525 1949 level, die_offset, abbrev_number);
cecf136e 1950
19e6b90e
L
1951 /* Scan through the abbreviation list until we reach the
1952 correct entry. */
1953 for (entry = first_abbrev;
1954 entry && entry->entry != abbrev_number;
1955 entry = entry->next)
1956 continue;
1957
1958 if (entry == NULL)
1959 {
4b78141a
NC
1960 if (!do_loc)
1961 {
1962 printf ("\n");
1963 fflush (stdout);
1964 }
cc86f28f
NC
1965 warn (_("DIE at offset %lx refers to abbreviation number %lu which does not exist\n"),
1966 die_offset, abbrev_number);
19e6b90e
L
1967 return 0;
1968 }
1969
1970 if (!do_loc)
4b78141a 1971 printf (_(" (%s)\n"), get_TAG_name (entry->tag));
cecf136e 1972
19e6b90e
L
1973 switch (entry->tag)
1974 {
1975 default:
1976 need_base_address = 0;
1977 break;
1978 case DW_TAG_compile_unit:
1979 need_base_address = 1;
1980 break;
1981 case DW_TAG_entry_point:
19e6b90e
L
1982 case DW_TAG_subprogram:
1983 need_base_address = 0;
1984 /* Assuming that there is no DW_AT_frame_base. */
1985 have_frame_base = 0;
1986 break;
1987 }
1988
1989 for (attr = entry->first_attr; attr; attr = attr->next)
4b78141a
NC
1990 {
1991 if (! do_loc)
1992 /* Show the offset from where the tag was extracted. */
750f03b7 1993 printf (" <%2lx>", (unsigned long)(tags - section_begin));
4b78141a
NC
1994
1995 tags = read_and_display_attr (attr->attribute,
1996 attr->form,
1997 tags, cu_offset,
1998 compunit.cu_pointer_size,
1999 offset_size,
2000 compunit.cu_version,
ec4d4525 2001 debug_information + unit,
6e3d6dc1 2002 do_loc, section);
4b78141a 2003 }
cecf136e 2004
19e6b90e
L
2005 if (entry->children)
2006 ++level;
2007 }
2008 }
cecf136e 2009
19e6b90e
L
2010 /* Set num_debug_info_entries here so that it can be used to check if
2011 we need to process .debug_loc and .debug_ranges sections. */
2012 if ((do_loc || do_debug_loc || do_debug_ranges)
2013 && num_debug_info_entries == 0)
2014 num_debug_info_entries = num_units;
cecf136e 2015
19e6b90e
L
2016 if (!do_loc)
2017 {
2018 printf ("\n");
2019 }
cecf136e 2020
19e6b90e
L
2021 return 1;
2022}
2023
2024/* Locate and scan the .debug_info section in the file and record the pointer
2025 sizes and offsets for the compilation units in it. Usually an executable
2026 will have just one pointer size, but this is not guaranteed, and so we try
2027 not to make any assumptions. Returns zero upon failure, or the number of
2028 compilation units upon success. */
2029
2030static unsigned int
2031load_debug_info (void * file)
2032{
2033 /* Reset the last pointer size so that we can issue correct error
2034 messages if we are displaying the contents of more than one section. */
2035 last_pointer_size = 0;
2036 warned_about_missing_comp_units = FALSE;
2037
1febe64d
NC
2038 /* If we have already tried and failed to load the .debug_info
2039 section then do not bother to repear the task. */
cc86f28f 2040 if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE)
1febe64d
NC
2041 return 0;
2042
19e6b90e
L
2043 /* If we already have the information there is nothing else to do. */
2044 if (num_debug_info_entries > 0)
2045 return num_debug_info_entries;
2046
2047 if (load_debug_section (info, file)
2048 && process_debug_info (&debug_displays [info].section, file, 1))
2049 return num_debug_info_entries;
1febe64d 2050
cc86f28f 2051 num_debug_info_entries = DEBUG_INFO_UNAVAILABLE;
1febe64d 2052 return 0;
19e6b90e
L
2053}
2054
19e6b90e 2055static int
a262ae96
NC
2056display_debug_lines_raw (struct dwarf_section *section,
2057 unsigned char *data,
2058 unsigned char *end)
19e6b90e
L
2059{
2060 unsigned char *start = section->start;
19e6b90e 2061
a262ae96
NC
2062 printf (_("Raw dump of debug contents of section %s:\n\n"),
2063 section->name);
19e6b90e
L
2064
2065 while (data < end)
2066 {
2067 DWARF2_Internal_LineInfo info;
2068 unsigned char *standard_opcodes;
2069 unsigned char *end_of_sequence;
2070 unsigned char *hdrptr;
6523721c 2071 unsigned long hdroff;
19e6b90e
L
2072 int initial_length_size;
2073 int offset_size;
2074 int i;
2075
2076 hdrptr = data;
6523721c 2077 hdroff = hdrptr - start;
19e6b90e
L
2078
2079 /* Check the length of the block. */
2080 info.li_length = byte_get (hdrptr, 4);
2081 hdrptr += 4;
2082
2083 if (info.li_length == 0xffffffff)
2084 {
2085 /* This section is 64-bit DWARF 3. */
2086 info.li_length = byte_get (hdrptr, 8);
2087 hdrptr += 8;
2088 offset_size = 8;
2089 initial_length_size = 12;
2090 }
2091 else
2092 {
2093 offset_size = 4;
2094 initial_length_size = 4;
2095 }
2096
2097 if (info.li_length + initial_length_size > section->size)
2098 {
2099 warn
2100 (_("The line info appears to be corrupt - the section is too small\n"));
2101 return 0;
2102 }
2103
2104 /* Check its version number. */
2105 info.li_version = byte_get (hdrptr, 2);
2106 hdrptr += 2;
2107 if (info.li_version != 2 && info.li_version != 3)
2108 {
2109 warn (_("Only DWARF version 2 and 3 line info is currently supported.\n"));
2110 return 0;
2111 }
2112
2113 info.li_prologue_length = byte_get (hdrptr, offset_size);
2114 hdrptr += offset_size;
2115 info.li_min_insn_length = byte_get (hdrptr, 1);
2116 hdrptr++;
2117 info.li_default_is_stmt = byte_get (hdrptr, 1);
2118 hdrptr++;
2119 info.li_line_base = byte_get (hdrptr, 1);
2120 hdrptr++;
2121 info.li_line_range = byte_get (hdrptr, 1);
2122 hdrptr++;
2123 info.li_opcode_base = byte_get (hdrptr, 1);
2124 hdrptr++;
2125
2126 /* Sign extend the line base field. */
2127 info.li_line_base <<= 24;
2128 info.li_line_base >>= 24;
2129
6523721c 2130 printf (_(" Offset: 0x%lx\n"), hdroff);
19e6b90e
L
2131 printf (_(" Length: %ld\n"), info.li_length);
2132 printf (_(" DWARF Version: %d\n"), info.li_version);
2133 printf (_(" Prologue Length: %d\n"), info.li_prologue_length);
2134 printf (_(" Minimum Instruction Length: %d\n"), info.li_min_insn_length);
2135 printf (_(" Initial value of 'is_stmt': %d\n"), info.li_default_is_stmt);
2136 printf (_(" Line Base: %d\n"), info.li_line_base);
2137 printf (_(" Line Range: %d\n"), info.li_line_range);
2138 printf (_(" Opcode Base: %d\n"), info.li_opcode_base);
19e6b90e
L
2139
2140 end_of_sequence = data + info.li_length + initial_length_size;
2141
2142 reset_state_machine (info.li_default_is_stmt);
2143
2144 /* Display the contents of the Opcodes table. */
2145 standard_opcodes = hdrptr;
2146
2147 printf (_("\n Opcodes:\n"));
2148
2149 for (i = 1; i < info.li_opcode_base; i++)
2150 printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]);
2151
2152 /* Display the contents of the Directory table. */
2153 data = standard_opcodes + info.li_opcode_base - 1;
2154
2155 if (*data == 0)
2156 printf (_("\n The Directory Table is empty.\n"));
2157 else
2158 {
2159 printf (_("\n The Directory Table:\n"));
2160
2161 while (*data != 0)
2162 {
2163 printf (_(" %s\n"), data);
2164
2165 data += strlen ((char *) data) + 1;
2166 }
2167 }
2168
2169 /* Skip the NUL at the end of the table. */
2170 data++;
2171
2172 /* Display the contents of the File Name table. */
2173 if (*data == 0)
2174 printf (_("\n The File Name Table is empty.\n"));
2175 else
2176 {
2177 printf (_("\n The File Name Table:\n"));
2178 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
2179
2180 while (*data != 0)
2181 {
2182 unsigned char *name;
2183 unsigned int bytes_read;
2184
2185 printf (_(" %d\t"), ++state_machine_regs.last_file_entry);
2186 name = data;
2187
2188 data += strlen ((char *) data) + 1;
2189
2190 printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
2191 data += bytes_read;
2192 printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
2193 data += bytes_read;
2194 printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0));
2195 data += bytes_read;
2196 printf (_("%s\n"), name);
2197 }
2198 }
2199
2200 /* Skip the NUL at the end of the table. */
2201 data++;
2202
2203 /* Now display the statements. */
2204 printf (_("\n Line Number Statements:\n"));
2205
2206 while (data < end_of_sequence)
2207 {
2208 unsigned char op_code;
2209 int adv;
2210 unsigned long int uladv;
2211 unsigned int bytes_read;
2212
2213 op_code = *data++;
2214
2215 if (op_code >= info.li_opcode_base)
2216 {
2217 op_code -= info.li_opcode_base;
2218 uladv = (op_code / info.li_line_range) * info.li_min_insn_length;
2219 state_machine_regs.address += uladv;
2220 printf (_(" Special opcode %d: advance Address by %lu to 0x%lx"),
2221 op_code, uladv, state_machine_regs.address);
2222 adv = (op_code % info.li_line_range) + info.li_line_base;
2223 state_machine_regs.line += adv;
2224 printf (_(" and Line by %d to %d\n"),
2225 adv, state_machine_regs.line);
2226 }
2227 else switch (op_code)
2228 {
2229 case DW_LNS_extended_op:
1617e571 2230 data += process_extended_line_op (data, info.li_default_is_stmt);
19e6b90e
L
2231 break;
2232
2233 case DW_LNS_copy:
2234 printf (_(" Copy\n"));
2235 break;
2236
2237 case DW_LNS_advance_pc:
2238 uladv = read_leb128 (data, & bytes_read, 0);
2239 uladv *= info.li_min_insn_length;
2240 data += bytes_read;
2241 state_machine_regs.address += uladv;
2242 printf (_(" Advance PC by %lu to 0x%lx\n"), uladv,
2243 state_machine_regs.address);
2244 break;
2245
2246 case DW_LNS_advance_line:
2247 adv = read_leb128 (data, & bytes_read, 1);
2248 data += bytes_read;
2249 state_machine_regs.line += adv;
2250 printf (_(" Advance Line by %d to %d\n"), adv,
2251 state_machine_regs.line);
2252 break;
2253
2254 case DW_LNS_set_file:
2255 adv = read_leb128 (data, & bytes_read, 0);
2256 data += bytes_read;
2257 printf (_(" Set File Name to entry %d in the File Name Table\n"),
2258 adv);
2259 state_machine_regs.file = adv;
2260 break;
2261
2262 case DW_LNS_set_column:
2263 uladv = read_leb128 (data, & bytes_read, 0);
2264 data += bytes_read;
2265 printf (_(" Set column to %lu\n"), uladv);
2266 state_machine_regs.column = uladv;
2267 break;
2268
2269 case DW_LNS_negate_stmt:
2270 adv = state_machine_regs.is_stmt;
2271 adv = ! adv;
2272 printf (_(" Set is_stmt to %d\n"), adv);
2273 state_machine_regs.is_stmt = adv;
2274 break;
2275
2276 case DW_LNS_set_basic_block:
2277 printf (_(" Set basic block\n"));
2278 state_machine_regs.basic_block = 1;
2279 break;
2280
2281 case DW_LNS_const_add_pc:
2282 uladv = (((255 - info.li_opcode_base) / info.li_line_range)
2283 * info.li_min_insn_length);
2284 state_machine_regs.address += uladv;
2285 printf (_(" Advance PC by constant %lu to 0x%lx\n"), uladv,
2286 state_machine_regs.address);
2287 break;
2288
2289 case DW_LNS_fixed_advance_pc:
2290 uladv = byte_get (data, 2);
2291 data += 2;
2292 state_machine_regs.address += uladv;
2293 printf (_(" Advance PC by fixed size amount %lu to 0x%lx\n"),
2294 uladv, state_machine_regs.address);
2295 break;
2296
2297 case DW_LNS_set_prologue_end:
2298 printf (_(" Set prologue_end to true\n"));
2299 break;
2300
2301 case DW_LNS_set_epilogue_begin:
2302 printf (_(" Set epilogue_begin to true\n"));
2303 break;
2304
2305 case DW_LNS_set_isa:
2306 uladv = read_leb128 (data, & bytes_read, 0);
2307 data += bytes_read;
2308 printf (_(" Set ISA to %lu\n"), uladv);
2309 break;
2310
2311 default:
2312 printf (_(" Unknown opcode %d with operands: "), op_code);
2313
2314 for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
2315 {
2316 printf ("0x%lx%s", read_leb128 (data, &bytes_read, 0),
2317 i == 1 ? "" : ", ");
2318 data += bytes_read;
2319 }
2320 putchar ('\n');
2321 break;
2322 }
2323 }
2324 putchar ('\n');
2325 }
2326
2327 return 1;
2328}
2329
a262ae96
NC
2330typedef struct
2331{
2332 unsigned char *name;
2333 unsigned int directory_index;
2334 unsigned int modification_date;
2335 unsigned int length;
2336} File_Entry;
2337
2338/* Output a decoded representation of the .debug_line section. */
2339
2340static int
2341display_debug_lines_decoded (struct dwarf_section *section,
2342 unsigned char *data,
2343 unsigned char *end)
2344{
2345 printf (_("Decoded dump of debug contents of section %s:\n\n"),
2346 section->name);
2347
2348 while (data < end)
2349 {
2350 /* This loop amounts to one iteration per compilation unit. */
2351 DWARF2_Internal_LineInfo info;
2352 unsigned char *standard_opcodes;
2353 unsigned char *end_of_sequence;
2354 unsigned char *hdrptr;
2355 int initial_length_size;
2356 int offset_size;
2357 int i;
2358 File_Entry *file_table = NULL;
2359 unsigned char **directory_table = NULL;
2360 unsigned int prev_line = 0;
2361
2362 hdrptr = data;
2363
2364 /* Extract information from the Line Number Program Header.
2365 (section 6.2.4 in the Dwarf3 doc). */
2366
2367 /* Get the length of this CU's line number information block. */
2368 info.li_length = byte_get (hdrptr, 4);
2369 hdrptr += 4;
2370
2371 if (info.li_length == 0xffffffff)
2372 {
2373 /* This section is 64-bit DWARF 3. */
2374 info.li_length = byte_get (hdrptr, 8);
2375 hdrptr += 8;
2376 offset_size = 8;
2377 initial_length_size = 12;
2378 }
2379 else
2380 {
2381 offset_size = 4;
2382 initial_length_size = 4;
2383 }
2384
2385 if (info.li_length + initial_length_size > section->size)
2386 {
2387 warn (_("The line info appears to be corrupt - "
2388 "the section is too small\n"));
2389 return 0;
2390 }
2391
2392 /* Get this CU's Line Number Block version number. */
2393 info.li_version = byte_get (hdrptr, 2);
2394 hdrptr += 2;
2395 if (info.li_version != 2 && info.li_version != 3)
2396 {
2397 warn (_("Only DWARF version 2 and 3 line info is currently "
2398 "supported.\n"));
2399 return 0;
2400 }
2401
2402 info.li_prologue_length = byte_get (hdrptr, offset_size);
2403 hdrptr += offset_size;
2404 info.li_min_insn_length = byte_get (hdrptr, 1);
2405 hdrptr++;
2406 info.li_default_is_stmt = byte_get (hdrptr, 1);
2407 hdrptr++;
2408 info.li_line_base = byte_get (hdrptr, 1);
2409 hdrptr++;
2410 info.li_line_range = byte_get (hdrptr, 1);
2411 hdrptr++;
2412 info.li_opcode_base = byte_get (hdrptr, 1);
2413 hdrptr++;
2414
2415 /* Sign extend the line base field. */
2416 info.li_line_base <<= 24;
2417 info.li_line_base >>= 24;
2418
2419 /* Find the end of this CU's Line Number Information Block. */
2420 end_of_sequence = data + info.li_length + initial_length_size;
2421
2422 reset_state_machine (info.li_default_is_stmt);
2423
2424 /* Save a pointer to the contents of the Opcodes table. */
2425 standard_opcodes = hdrptr;
2426
2427 /* Traverse the Directory table just to count entries. */
2428 data = standard_opcodes + info.li_opcode_base - 1;
2429 if (*data != 0)
2430 {
2431 unsigned int n_directories = 0;
2432 unsigned char *ptr_directory_table = data;
2433 int i;
2434
2435 while (*data != 0)
2436 {
2437 data += strlen ((char *) data) + 1;
2438 n_directories++;
2439 }
2440
2441 /* Go through the directory table again to save the directories. */
2442 directory_table = xmalloc (n_directories * sizeof (unsigned char *));
2443
2444 i = 0;
2445 while (*ptr_directory_table != 0)
2446 {
2447 directory_table[i] = ptr_directory_table;
2448 ptr_directory_table += strlen ((char *) ptr_directory_table) + 1;
2449 i++;
2450 }
2451 }
2452 /* Skip the NUL at the end of the table. */
2453 data++;
2454
2455 /* Traverse the File Name table just to count the entries. */
2456 if (*data != 0)
2457 {
2458 unsigned int n_files = 0;
2459 unsigned char *ptr_file_name_table = data;
2460 int i;
2461
2462 while (*data != 0)
2463 {
2464 unsigned int bytes_read;
2465
2466 /* Skip Name, directory index, last modification time and length
2467 of file. */
2468 data += strlen ((char *) data) + 1;
2469 read_leb128 (data, & bytes_read, 0);
2470 data += bytes_read;
2471 read_leb128 (data, & bytes_read, 0);
2472 data += bytes_read;
2473 read_leb128 (data, & bytes_read, 0);
2474 data += bytes_read;
2475
2476 n_files++;
2477 }
2478
2479 /* Go through the file table again to save the strings. */
2480 file_table = xmalloc (n_files * sizeof (File_Entry));
2481
2482 i = 0;
2483 while (*ptr_file_name_table != 0)
2484 {
2485 unsigned int bytes_read;
2486
2487 file_table[i].name = ptr_file_name_table;
2488 ptr_file_name_table += strlen ((char *) ptr_file_name_table) + 1;
2489
2490 /* We are not interested in directory, time or size. */
2491 file_table[i].directory_index = read_leb128 (ptr_file_name_table,
2492 & bytes_read, 0);
2493 ptr_file_name_table += bytes_read;
2494 file_table[i].modification_date = read_leb128 (ptr_file_name_table,
2495 & bytes_read, 0);
2496 ptr_file_name_table += bytes_read;
2497 file_table[i].length = read_leb128 (ptr_file_name_table, & bytes_read, 0);
2498 ptr_file_name_table += bytes_read;
2499 i++;
2500 }
2501 i = 0;
2502
2503 /* Print the Compilation Unit's name and a header. */
2504 if (directory_table == NULL)
2505 {
2506 printf (_("CU: %s:\n"), file_table[0].name);
2507 printf (_("File name Line number Starting address\n"));
2508 }
2509 else
2510 {
2511 if (do_wide || strlen ((char *) directory_table[0]) < 76)
2512 {
2513 printf (_("CU: %s/%s:\n"), directory_table[0],
2514 file_table[0].name);
2515 }
2516 else
2517 {
2518 printf (_("%s:\n"), file_table[0].name);
2519 }
2520 printf (_("File name Line number Starting address\n"));
2521 }
2522 }
2523
2524 /* Skip the NUL at the end of the table. */
2525 data++;
2526
2527 /* This loop iterates through the Dwarf Line Number Program. */
2528 while (data < end_of_sequence)
2529 {
2530 unsigned char op_code;
2531 int adv;
2532 unsigned long int uladv;
2533 unsigned int bytes_read;
2534 int is_special_opcode = 0;
2535
2536 op_code = *data++;
2537 prev_line = state_machine_regs.line;
2538
2539 if (op_code >= info.li_opcode_base)
2540 {
2541 op_code -= info.li_opcode_base;
2542 uladv = (op_code / info.li_line_range) * info.li_min_insn_length;
2543 state_machine_regs.address += uladv;
2544
2545 adv = (op_code % info.li_line_range) + info.li_line_base;
2546 state_machine_regs.line += adv;
2547 is_special_opcode = 1;
2548 }
2549 else switch (op_code)
2550 {
2551 case DW_LNS_extended_op:
2552 {
2553 unsigned int ext_op_code_len;
2554 unsigned int bytes_read;
2555 unsigned char ext_op_code;
2556 unsigned char *op_code_data = data;
2557
2558 ext_op_code_len = read_leb128 (op_code_data, &bytes_read, 0);
2559 op_code_data += bytes_read;
2560
2561 if (ext_op_code_len == 0)
2562 {
2563 warn (_("badly formed extended line op encountered!\n"));
2564 break;
2565 }
2566 ext_op_code_len += bytes_read;
2567 ext_op_code = *op_code_data++;
2568
2569 switch (ext_op_code)
2570 {
2571 case DW_LNE_end_sequence:
2572 reset_state_machine (info.li_default_is_stmt);
2573 break;
2574 case DW_LNE_set_address:
2575 state_machine_regs.address =
2576 byte_get (op_code_data, ext_op_code_len - bytes_read - 1);
2577 break;
2578 case DW_LNE_define_file:
2579 {
2580 unsigned int dir_index = 0;
2581
2582 ++state_machine_regs.last_file_entry;
2583 op_code_data += strlen ((char *) op_code_data) + 1;
2584 dir_index = read_leb128 (op_code_data, & bytes_read, 0);
2585 op_code_data += bytes_read;
2586 read_leb128 (op_code_data, & bytes_read, 0);
2587 op_code_data += bytes_read;
2588 read_leb128 (op_code_data, & bytes_read, 0);
2589
2590 printf (_("%s:\n"), directory_table[dir_index]);
2591 break;
2592 }
2593 default:
2594 printf (_("UNKNOWN: length %d\n"), ext_op_code_len - bytes_read);
2595 break;
2596 }
2597 data += ext_op_code_len;
2598 break;
2599 }
2600 case DW_LNS_copy:
2601 break;
2602
2603 case DW_LNS_advance_pc:
2604 uladv = read_leb128 (data, & bytes_read, 0);
2605 uladv *= info.li_min_insn_length;
2606 data += bytes_read;
2607 state_machine_regs.address += uladv;
2608 break;
2609
2610 case DW_LNS_advance_line:
2611 adv = read_leb128 (data, & bytes_read, 1);
2612 data += bytes_read;
2613 state_machine_regs.line += adv;
2614 break;
2615
2616 case DW_LNS_set_file:
2617 adv = read_leb128 (data, & bytes_read, 0);
2618 data += bytes_read;
2619 state_machine_regs.file = adv;
2620 if (file_table[state_machine_regs.file - 1].directory_index == 0)
2621 {
2622 /* If directory index is 0, that means current directory. */
2623 printf (_("\n./%s:[++]\n"),
2624 file_table[state_machine_regs.file - 1].name);
2625 }
2626 else
2627 {
2628 /* The directory index starts counting at 1. */
2629 printf (_("\n%s/%s:\n"),
2630 directory_table[file_table[state_machine_regs.file - 1].directory_index - 1],
2631 file_table[state_machine_regs.file - 1].name);
2632 }
2633 break;
2634
2635 case DW_LNS_set_column:
2636 uladv = read_leb128 (data, & bytes_read, 0);
2637 data += bytes_read;
2638 state_machine_regs.column = uladv;
2639 break;
2640
2641 case DW_LNS_negate_stmt:
2642 adv = state_machine_regs.is_stmt;
2643 adv = ! adv;
2644 state_machine_regs.is_stmt = adv;
2645 break;
2646
2647 case DW_LNS_set_basic_block:
2648 state_machine_regs.basic_block = 1;
2649 break;
2650
2651 case DW_LNS_const_add_pc:
2652 uladv = (((255 - info.li_opcode_base) / info.li_line_range)
2653 * info.li_min_insn_length);
2654 state_machine_regs.address += uladv;
2655 break;
2656
2657 case DW_LNS_fixed_advance_pc:
2658 uladv = byte_get (data, 2);
2659 data += 2;
2660 state_machine_regs.address += uladv;
2661 break;
2662
2663 case DW_LNS_set_prologue_end:
2664 break;
2665
2666 case DW_LNS_set_epilogue_begin:
2667 break;
2668
2669 case DW_LNS_set_isa:
2670 uladv = read_leb128 (data, & bytes_read, 0);
2671 data += bytes_read;
2672 printf (_(" Set ISA to %lu\n"), uladv);
2673 break;
2674
2675 default:
2676 printf (_(" Unknown opcode %d with operands: "), op_code);
2677
2678 for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
2679 {
2680 printf ("0x%lx%s", read_leb128 (data, &bytes_read, 0),
2681 i == 1 ? "" : ", ");
2682 data += bytes_read;
2683 }
2684 putchar ('\n');
2685 break;
2686 }
2687
2688 /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row
2689 to the DWARF address/line matrix. */
2690 if ((is_special_opcode) || (op_code == DW_LNE_end_sequence)
2691 || (op_code == DW_LNS_copy))
2692 {
2693 const unsigned int MAX_FILENAME_LENGTH = 35;
2694 char *fileName = (char *)file_table[state_machine_regs.file - 1].name;
2695 char *newFileName = NULL;
2696 size_t fileNameLength = strlen (fileName);
2697
2698 if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide))
2699 {
2700 newFileName = xmalloc (MAX_FILENAME_LENGTH + 1);
2701 /* Truncate file name */
2702 strncpy (newFileName,
2703 fileName + fileNameLength - MAX_FILENAME_LENGTH,
2704 MAX_FILENAME_LENGTH + 1);
2705 }
2706 else
2707 {
2708 newFileName = xmalloc (fileNameLength + 1);
2709 strncpy (newFileName, fileName, fileNameLength + 1);
2710 }
2711
2712 if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
2713 {
2714 printf (_("%-35s %11d %#18lx\n"), newFileName,
2715 state_machine_regs.line, state_machine_regs.address);
2716 }
2717 else
2718 {
2719 printf (_("%s %11d %#18lx\n"), newFileName,
2720 state_machine_regs.line, state_machine_regs.address);
2721 }
2722
2723 if (op_code == DW_LNE_end_sequence)
2724 printf ("\n");
2725
2726 free (newFileName);
2727 }
2728 }
2729 free (file_table);
2730 file_table = NULL;
2731 free (directory_table);
2732 directory_table = NULL;
2733 putchar ('\n');
2734 }
2735
2736 return 1;
2737}
2738
2739static int
2740display_debug_lines (struct dwarf_section *section, void *file)
2741{
2742 unsigned char *data = section->start;
2743 unsigned char *end = data + section->size;
2744 int retValRaw = 0;
2745 int retValDecoded = 0;
2746
2747 if (load_debug_info (file) == 0)
2748 {
2749 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
2750 section->name);
2751 return 0;
2752 }
2753
2754 if (do_debug_lines)
2755 retValRaw = display_debug_lines_raw (section, data, end);
2756
2757 if (do_debug_lines_decoded)
2758 retValDecoded = display_debug_lines_decoded (section, data, end);
2759
2760 if ((do_debug_lines && !retValRaw)
2761 || (do_debug_lines_decoded && !retValDecoded))
2762 return 0;
2763
2764 return 1;
2765}
2766
6e3d6dc1
NC
2767static debug_info *
2768find_debug_info_for_offset (unsigned long offset)
2769{
2770 unsigned int i;
2771
2772 if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE)
2773 return NULL;
2774
2775 for (i = 0; i < num_debug_info_entries; i++)
2776 if (debug_information[i].cu_offset == offset)
2777 return debug_information + i;
2778
2779 return NULL;
2780}
2781
19e6b90e
L
2782static int
2783display_debug_pubnames (struct dwarf_section *section,
2784 void *file ATTRIBUTE_UNUSED)
2785{
2786 DWARF2_Internal_PubNames pubnames;
2787 unsigned char *start = section->start;
2788 unsigned char *end = start + section->size;
2789
6e3d6dc1
NC
2790 /* It does not matter if this load fails,
2791 we test for that later on. */
2792 load_debug_info (file);
2793
19e6b90e
L
2794 printf (_("Contents of the %s section:\n\n"), section->name);
2795
2796 while (start < end)
2797 {
2798 unsigned char *data;
2799 unsigned long offset;
2800 int offset_size, initial_length_size;
2801
2802 data = start;
2803
2804 pubnames.pn_length = byte_get (data, 4);
2805 data += 4;
2806 if (pubnames.pn_length == 0xffffffff)
2807 {
2808 pubnames.pn_length = byte_get (data, 8);
2809 data += 8;
2810 offset_size = 8;
2811 initial_length_size = 12;
2812 }
2813 else
2814 {
2815 offset_size = 4;
2816 initial_length_size = 4;
2817 }
2818
2819 pubnames.pn_version = byte_get (data, 2);
2820 data += 2;
6e3d6dc1 2821
19e6b90e
L
2822 pubnames.pn_offset = byte_get (data, offset_size);
2823 data += offset_size;
6e3d6dc1
NC
2824
2825 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
2826 && num_debug_info_entries > 0
2827 && find_debug_info_for_offset (pubnames.pn_offset) == NULL)
2828 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
2829 pubnames.pn_offset, section->name);
cecf136e 2830
19e6b90e
L
2831 pubnames.pn_size = byte_get (data, offset_size);
2832 data += offset_size;
2833
2834 start += pubnames.pn_length + initial_length_size;
2835
2836 if (pubnames.pn_version != 2 && pubnames.pn_version != 3)
2837 {
2838 static int warned = 0;
2839
2840 if (! warned)
2841 {
2842 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
2843 warned = 1;
2844 }
2845
2846 continue;
2847 }
2848
2849 printf (_(" Length: %ld\n"),
2850 pubnames.pn_length);
2851 printf (_(" Version: %d\n"),
2852 pubnames.pn_version);
6e3d6dc1 2853 printf (_(" Offset into .debug_info section: 0x%lx\n"),
19e6b90e
L
2854 pubnames.pn_offset);
2855 printf (_(" Size of area in .debug_info section: %ld\n"),
2856 pubnames.pn_size);
2857
2858 printf (_("\n Offset\tName\n"));
2859
2860 do
2861 {
2862 offset = byte_get (data, offset_size);
2863
2864 if (offset != 0)
2865 {
2866 data += offset_size;
2867 printf (" %-6ld\t\t%s\n", offset, data);
2868 data += strlen ((char *) data) + 1;
2869 }
2870 }
2871 while (offset != 0);
2872 }
2873
2874 printf ("\n");
2875 return 1;
2876}
2877
2878static int
2879display_debug_macinfo (struct dwarf_section *section,
2880 void *file ATTRIBUTE_UNUSED)
2881{
2882 unsigned char *start = section->start;
2883 unsigned char *end = start + section->size;
2884 unsigned char *curr = start;
2885 unsigned int bytes_read;
2886 enum dwarf_macinfo_record_type op;
2887
2888 printf (_("Contents of the %s section:\n\n"), section->name);
2889
2890 while (curr < end)
2891 {
2892 unsigned int lineno;
2893 const char *string;
2894
2895 op = *curr;
2896 curr++;
2897
2898 switch (op)
2899 {
2900 case DW_MACINFO_start_file:
2901 {
2902 unsigned int filenum;
2903
2904 lineno = read_leb128 (curr, & bytes_read, 0);
2905 curr += bytes_read;
2906 filenum = read_leb128 (curr, & bytes_read, 0);
2907 curr += bytes_read;
2908
2909 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"),
2910 lineno, filenum);
2911 }
2912 break;
2913
2914 case DW_MACINFO_end_file:
2915 printf (_(" DW_MACINFO_end_file\n"));
2916 break;
2917
2918 case DW_MACINFO_define:
2919 lineno = read_leb128 (curr, & bytes_read, 0);
2920 curr += bytes_read;
2921 string = (char *) curr;
2922 curr += strlen (string) + 1;
2923 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"),
2924 lineno, string);
2925 break;
2926
2927 case DW_MACINFO_undef:
2928 lineno = read_leb128 (curr, & bytes_read, 0);
2929 curr += bytes_read;
2930 string = (char *) curr;
2931 curr += strlen (string) + 1;
2932 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"),
2933 lineno, string);
2934 break;
2935
2936 case DW_MACINFO_vendor_ext:
2937 {
2938 unsigned int constant;
2939
2940 constant = read_leb128 (curr, & bytes_read, 0);
2941 curr += bytes_read;
2942 string = (char *) curr;
2943 curr += strlen (string) + 1;
2944 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"),
2945 constant, string);
2946 }
2947 break;
2948 }
2949 }
2950
2951 return 1;
2952}
2953
2954static int
2955display_debug_abbrev (struct dwarf_section *section,
2956 void *file ATTRIBUTE_UNUSED)
2957{
2958 abbrev_entry *entry;
2959 unsigned char *start = section->start;
2960 unsigned char *end = start + section->size;
2961
2962 printf (_("Contents of the %s section:\n\n"), section->name);
2963
2964 do
2965 {
2966 free_abbrevs ();
2967
2968 start = process_abbrev_section (start, end);
2969
2970 if (first_abbrev == NULL)
2971 continue;
2972
2973 printf (_(" Number TAG\n"));
2974
2975 for (entry = first_abbrev; entry; entry = entry->next)
2976 {
2977 abbrev_attr *attr;
2978
2979 printf (_(" %ld %s [%s]\n"),
2980 entry->entry,
2981 get_TAG_name (entry->tag),
2982 entry->children ? _("has children") : _("no children"));
2983
2984 for (attr = entry->first_attr; attr; attr = attr->next)
2985 printf (_(" %-18s %s\n"),
2986 get_AT_name (attr->attribute),
2987 get_FORM_name (attr->form));
2988 }
2989 }
2990 while (start);
2991
2992 printf ("\n");
2993
2994 return 1;
2995}
2996
2997static int
2998display_debug_loc (struct dwarf_section *section, void *file)
2999{
3000 unsigned char *start = section->start;
3001 unsigned char *section_end;
3002 unsigned long bytes;
3003 unsigned char *section_begin = start;
3004 unsigned int num_loc_list = 0;
3005 unsigned long last_offset = 0;
3006 unsigned int first = 0;
3007 unsigned int i;
3008 unsigned int j;
3009 int seen_first_offset = 0;
3010 int use_debug_info = 1;
3011 unsigned char *next;
3012
3013 bytes = section->size;
3014 section_end = start + bytes;
3015
3016 if (bytes == 0)
3017 {
3018 printf (_("\nThe %s section is empty.\n"), section->name);
3019 return 0;
3020 }
3021
1febe64d
NC
3022 if (load_debug_info (file) == 0)
3023 {
3024 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3025 section->name);
3026 return 0;
3027 }
19e6b90e
L
3028
3029 /* Check the order of location list in .debug_info section. If
3030 offsets of location lists are in the ascending order, we can
3031 use `debug_information' directly. */
3032 for (i = 0; i < num_debug_info_entries; i++)
3033 {
3034 unsigned int num;
3035
3036 num = debug_information [i].num_loc_offsets;
3037 num_loc_list += num;
3038
3039 /* Check if we can use `debug_information' directly. */
3040 if (use_debug_info && num != 0)
3041 {
3042 if (!seen_first_offset)
3043 {
3044 /* This is the first location list. */
3045 last_offset = debug_information [i].loc_offsets [0];
3046 first = i;
3047 seen_first_offset = 1;
3048 j = 1;
3049 }
3050 else
3051 j = 0;
3052
3053 for (; j < num; j++)
3054 {
3055 if (last_offset >
3056 debug_information [i].loc_offsets [j])
3057 {
3058 use_debug_info = 0;
3059 break;
3060 }
3061 last_offset = debug_information [i].loc_offsets [j];
3062 }
3063 }
3064 }
3065
3066 if (!use_debug_info)
3067 /* FIXME: Should we handle this case? */
3068 error (_("Location lists in .debug_info section aren't in ascending order!\n"));
3069
3070 if (!seen_first_offset)
3071 error (_("No location lists in .debug_info section!\n"));
3072
bfe2612a 3073 /* DWARF sections under Mach-O have non-zero addresses. */
d4bfc77b
AS
3074 if (debug_information [first].num_loc_offsets > 0
3075 && debug_information [first].loc_offsets [0] != section->address)
19e6b90e
L
3076 warn (_("Location lists in %s section start at 0x%lx\n"),
3077 section->name, debug_information [first].loc_offsets [0]);
3078
3079 printf (_("Contents of the %s section:\n\n"), section->name);
3080 printf (_(" Offset Begin End Expression\n"));
3081
3082 seen_first_offset = 0;
3083 for (i = first; i < num_debug_info_entries; i++)
3084 {
2d9472a2
NC
3085 dwarf_vma begin;
3086 dwarf_vma end;
19e6b90e
L
3087 unsigned short length;
3088 unsigned long offset;
3089 unsigned int pointer_size;
3090 unsigned long cu_offset;
3091 unsigned long base_address;
3092 int need_frame_base;
3093 int has_frame_base;
3094
3095 pointer_size = debug_information [i].pointer_size;
3096 cu_offset = debug_information [i].cu_offset;
3097
3098 for (j = 0; j < debug_information [i].num_loc_offsets; j++)
3099 {
3100 has_frame_base = debug_information [i].have_frame_base [j];
bfe2612a 3101 /* DWARF sections under Mach-O have non-zero addresses. */
cecf136e 3102 offset = debug_information [i].loc_offsets [j] - section->address;
19e6b90e
L
3103 next = section_begin + offset;
3104 base_address = debug_information [i].base_address;
3105
3106 if (!seen_first_offset)
3107 seen_first_offset = 1;
3108 else
3109 {
3110 if (start < next)
3111 warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
0af1713e
AM
3112 (unsigned long) (start - section_begin),
3113 (unsigned long) (next - section_begin));
19e6b90e
L
3114 else if (start > next)
3115 warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
0af1713e
AM
3116 (unsigned long) (start - section_begin),
3117 (unsigned long) (next - section_begin));
19e6b90e
L
3118 }
3119 start = next;
3120
3121 if (offset >= bytes)
3122 {
3123 warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
3124 offset);
3125 continue;
3126 }
3127
3128 while (1)
3129 {
3130 if (start + 2 * pointer_size > section_end)
3131 {
3132 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3133 offset);
3134 break;
3135 }
3136
2d9472a2
NC
3137 /* Note: we use sign extension here in order to be sure that
3138 we can detect the -1 escape value. Sign extension into the
3139 top 32 bits of a 32-bit address will not affect the values
3140 that we display since we always show hex values, and always
cecf136e 3141 the bottom 32-bits. */
2d9472a2 3142 begin = byte_get_signed (start, pointer_size);
19e6b90e 3143 start += pointer_size;
2d9472a2 3144 end = byte_get_signed (start, pointer_size);
19e6b90e
L
3145 start += pointer_size;
3146
2d9472a2
NC
3147 printf (" %8.8lx ", offset);
3148
19e6b90e
L
3149 if (begin == 0 && end == 0)
3150 {
2d9472a2 3151 printf (_("<End of list>\n"));
19e6b90e
L
3152 break;
3153 }
3154
3155 /* Check base address specifiers. */
2d9472a2 3156 if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
19e6b90e
L
3157 {
3158 base_address = end;
2d9472a2
NC
3159 print_dwarf_vma (begin, pointer_size);
3160 print_dwarf_vma (end, pointer_size);
3161 printf (_("(base address)\n"));
19e6b90e
L
3162 continue;
3163 }
3164
3165 if (start + 2 > section_end)
3166 {
3167 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3168 offset);
3169 break;
3170 }
3171
3172 length = byte_get (start, 2);
3173 start += 2;
3174
3175 if (start + length > section_end)
3176 {
3177 warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
3178 offset);
3179 break;
3180 }
3181
2d9472a2
NC
3182 print_dwarf_vma (begin + base_address, pointer_size);
3183 print_dwarf_vma (end + base_address, pointer_size);
3184
3185 putchar ('(');
19e6b90e
L
3186 need_frame_base = decode_location_expression (start,
3187 pointer_size,
3188 length,
3189 cu_offset);
3190 putchar (')');
3191
3192 if (need_frame_base && !has_frame_base)
3193 printf (_(" [without DW_AT_frame_base]"));
3194
3195 if (begin == end)
3196 fputs (_(" (start == end)"), stdout);
3197 else if (begin > end)
3198 fputs (_(" (start > end)"), stdout);
3199
3200 putchar ('\n');
3201
3202 start += length;
3203 }
3204 }
3205 }
031cd65f
NC
3206
3207 if (start < section_end)
3208 warn (_("There are %ld unused bytes at the end of section %s\n"),
0eb090cb 3209 (long) (section_end - start), section->name);
19e6b90e
L
3210 return 1;
3211}
3212
3213static int
3214display_debug_str (struct dwarf_section *section,
3215 void *file ATTRIBUTE_UNUSED)
3216{
3217 unsigned char *start = section->start;
3218 unsigned long bytes = section->size;
3219 dwarf_vma addr = section->address;
3220
3221 if (bytes == 0)
3222 {
3223 printf (_("\nThe %s section is empty.\n"), section->name);
3224 return 0;
3225 }
3226
3227 printf (_("Contents of the %s section:\n\n"), section->name);
3228
3229 while (bytes)
3230 {
3231 int j;
3232 int k;
3233 int lbytes;
3234
3235 lbytes = (bytes > 16 ? 16 : bytes);
3236
3237 printf (" 0x%8.8lx ", (unsigned long) addr);
3238
3239 for (j = 0; j < 16; j++)
3240 {
3241 if (j < lbytes)
3242 printf ("%2.2x", start[j]);
3243 else
3244 printf (" ");
3245
3246 if ((j & 3) == 3)
3247 printf (" ");
3248 }
3249
3250 for (j = 0; j < lbytes; j++)
3251 {
3252 k = start[j];
3253 if (k >= ' ' && k < 0x80)
3254 printf ("%c", k);
3255 else
3256 printf (".");
3257 }
3258
3259 putchar ('\n');
3260
3261 start += lbytes;
3262 addr += lbytes;
3263 bytes -= lbytes;
3264 }
3265
3266 putchar ('\n');
3267
3268 return 1;
3269}
3270
19e6b90e
L
3271static int
3272display_debug_info (struct dwarf_section *section, void *file)
3273{
3274 return process_debug_info (section, file, 0);
3275}
3276
3277
3278static int
3279display_debug_aranges (struct dwarf_section *section,
3280 void *file ATTRIBUTE_UNUSED)
3281{
3282 unsigned char *start = section->start;
3283 unsigned char *end = start + section->size;
3284
3285 printf (_("The section %s contains:\n\n"), section->name);
3286
6e3d6dc1
NC
3287 /* It does not matter if this load fails,
3288 we test for that later on. */
3289 load_debug_info (file);
3290
19e6b90e
L
3291 while (start < end)
3292 {
3293 unsigned char *hdrptr;
3294 DWARF2_Internal_ARange arange;
3295 unsigned char *ranges;
2d9472a2
NC
3296 dwarf_vma length;
3297 dwarf_vma address;
53b8873b 3298 unsigned char address_size;
19e6b90e
L
3299 int excess;
3300 int offset_size;
3301 int initial_length_size;
3302
3303 hdrptr = start;
3304
3305 arange.ar_length = byte_get (hdrptr, 4);
3306 hdrptr += 4;
3307
3308 if (arange.ar_length == 0xffffffff)
3309 {
3310 arange.ar_length = byte_get (hdrptr, 8);
3311 hdrptr += 8;
3312 offset_size = 8;
3313 initial_length_size = 12;
3314 }
3315 else
3316 {
3317 offset_size = 4;
3318 initial_length_size = 4;
3319 }
3320
3321 arange.ar_version = byte_get (hdrptr, 2);
3322 hdrptr += 2;
3323
3324 arange.ar_info_offset = byte_get (hdrptr, offset_size);
3325 hdrptr += offset_size;
3326
6e3d6dc1
NC
3327 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
3328 && num_debug_info_entries > 0
3329 && find_debug_info_for_offset (arange.ar_info_offset) == NULL)
3330 warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
3331 arange.ar_info_offset, section->name);
3332
19e6b90e
L
3333 arange.ar_pointer_size = byte_get (hdrptr, 1);
3334 hdrptr += 1;
3335
3336 arange.ar_segment_size = byte_get (hdrptr, 1);
3337 hdrptr += 1;
3338
3339 if (arange.ar_version != 2 && arange.ar_version != 3)
3340 {
3341 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
3342 break;
3343 }
3344
3345 printf (_(" Length: %ld\n"), arange.ar_length);
3346 printf (_(" Version: %d\n"), arange.ar_version);
6e3d6dc1 3347 printf (_(" Offset into .debug_info: 0x%lx\n"), arange.ar_info_offset);
19e6b90e
L
3348 printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size);
3349 printf (_(" Segment Size: %d\n"), arange.ar_segment_size);
3350
53b8873b
NC
3351 address_size = arange.ar_pointer_size + arange.ar_segment_size;
3352
3353 /* The DWARF spec does not require that the address size be a power
3354 of two, but we do. This will have to change if we ever encounter
3355 an uneven architecture. */
3356 if ((address_size & (address_size - 1)) != 0)
3357 {
3358 warn (_("Pointer size + Segment size is not a power of two.\n"));
3359 break;
3360 }
cecf136e 3361
209c9a13
NC
3362 if (address_size > 4)
3363 printf (_("\n Address Length\n"));
3364 else
3365 printf (_("\n Address Length\n"));
19e6b90e
L
3366
3367 ranges = hdrptr;
3368
53b8873b
NC
3369 /* Must pad to an alignment boundary that is twice the address size. */
3370 excess = (hdrptr - start) % (2 * address_size);
19e6b90e 3371 if (excess)
53b8873b 3372 ranges += (2 * address_size) - excess;
19e6b90e 3373
1617e571
AM
3374 start += arange.ar_length + initial_length_size;
3375
53b8873b 3376 while (ranges + 2 * address_size <= start)
19e6b90e 3377 {
53b8873b 3378 address = byte_get (ranges, address_size);
19e6b90e 3379
53b8873b 3380 ranges += address_size;
19e6b90e 3381
53b8873b 3382 length = byte_get (ranges, address_size);
19e6b90e 3383
53b8873b 3384 ranges += address_size;
19e6b90e 3385
2d9472a2
NC
3386 print_dwarf_vma (address, address_size);
3387 print_dwarf_vma (length, address_size);
3388 putchar ('\n');
19e6b90e 3389 }
19e6b90e
L
3390 }
3391
3392 printf ("\n");
3393
3394 return 1;
3395}
3396
3397static int
3398display_debug_ranges (struct dwarf_section *section,
3399 void *file ATTRIBUTE_UNUSED)
3400{
3401 unsigned char *start = section->start;
3402 unsigned char *section_end;
3403 unsigned long bytes;
3404 unsigned char *section_begin = start;
3405 unsigned int num_range_list = 0;
3406 unsigned long last_offset = 0;
3407 unsigned int first = 0;
3408 unsigned int i;
3409 unsigned int j;
3410 int seen_first_offset = 0;
3411 int use_debug_info = 1;
3412 unsigned char *next;
3413
3414 bytes = section->size;
3415 section_end = start + bytes;
3416
3417 if (bytes == 0)
3418 {
3419 printf (_("\nThe %s section is empty.\n"), section->name);
3420 return 0;
3421 }
3422
1febe64d
NC
3423 if (load_debug_info (file) == 0)
3424 {
3425 warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
3426 section->name);
3427 return 0;
3428 }
19e6b90e
L
3429
3430 /* Check the order of range list in .debug_info section. If
3431 offsets of range lists are in the ascending order, we can
3432 use `debug_information' directly. */
3433 for (i = 0; i < num_debug_info_entries; i++)
3434 {
3435 unsigned int num;
3436
3437 num = debug_information [i].num_range_lists;
3438 num_range_list += num;
3439
3440 /* Check if we can use `debug_information' directly. */
3441 if (use_debug_info && num != 0)
3442 {
3443 if (!seen_first_offset)
3444 {
3445 /* This is the first range list. */
3446 last_offset = debug_information [i].range_lists [0];
3447 first = i;
3448 seen_first_offset = 1;
3449 j = 1;
3450 }
3451 else
3452 j = 0;
3453
3454 for (; j < num; j++)
3455 {
3456 if (last_offset >
3457 debug_information [i].range_lists [j])
3458 {
3459 use_debug_info = 0;
3460 break;
3461 }
3462 last_offset = debug_information [i].range_lists [j];
3463 }
3464 }
3465 }
3466
3467 if (!use_debug_info)
3468 /* FIXME: Should we handle this case? */
3469 error (_("Range lists in .debug_info section aren't in ascending order!\n"));
3470
3471 if (!seen_first_offset)
3472 error (_("No range lists in .debug_info section!\n"));
3473
bfe2612a 3474 /* DWARF sections under Mach-O have non-zero addresses. */
d4bfc77b
AS
3475 if (debug_information [first].num_range_lists > 0
3476 && debug_information [first].range_lists [0] != section->address)
19e6b90e
L
3477 warn (_("Range lists in %s section start at 0x%lx\n"),
3478 section->name, debug_information [first].range_lists [0]);
3479
3480 printf (_("Contents of the %s section:\n\n"), section->name);
3481 printf (_(" Offset Begin End\n"));
3482
3483 seen_first_offset = 0;
3484 for (i = first; i < num_debug_info_entries; i++)
3485 {
2d9472a2
NC
3486 dwarf_vma begin;
3487 dwarf_vma end;
19e6b90e
L
3488 unsigned long offset;
3489 unsigned int pointer_size;
3490 unsigned long base_address;
3491
3492 pointer_size = debug_information [i].pointer_size;
cecf136e 3493
19e6b90e
L
3494 for (j = 0; j < debug_information [i].num_range_lists; j++)
3495 {
bfe2612a
L
3496 /* DWARF sections under Mach-O have non-zero addresses. */
3497 offset = debug_information [i].range_lists [j] - section->address;
19e6b90e
L
3498 next = section_begin + offset;
3499 base_address = debug_information [i].base_address;
3500
3501 if (!seen_first_offset)
3502 seen_first_offset = 1;
3503 else
3504 {
3505 if (start < next)
3506 warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
0af1713e
AM
3507 (unsigned long) (start - section_begin),
3508 (unsigned long) (next - section_begin), section->name);
19e6b90e
L
3509 else if (start > next)
3510 warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
0af1713e
AM
3511 (unsigned long) (start - section_begin),
3512 (unsigned long) (next - section_begin), section->name);
19e6b90e
L
3513 }
3514 start = next;
3515
3516 while (1)
3517 {
2d9472a2
NC
3518 /* Note: we use sign extension here in order to be sure that
3519 we can detect the -1 escape value. Sign extension into the
3520 top 32 bits of a 32-bit address will not affect the values
3521 that we display since we always show hex values, and always
cecf136e 3522 the bottom 32-bits. */
2d9472a2 3523 begin = byte_get_signed (start, pointer_size);
19e6b90e 3524 start += pointer_size;
2d9472a2 3525 end = byte_get_signed (start, pointer_size);
19e6b90e
L
3526 start += pointer_size;
3527
2d9472a2
NC
3528 printf (" %8.8lx ", offset);
3529
19e6b90e
L
3530 if (begin == 0 && end == 0)
3531 {
2d9472a2 3532 printf (_("<End of list>\n"));
19e6b90e
L
3533 break;
3534 }
3535
2d9472a2
NC
3536 print_dwarf_vma (begin, pointer_size);
3537 print_dwarf_vma (end, pointer_size);
3538
19e6b90e 3539 /* Check base address specifiers. */
2d9472a2 3540 if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
19e6b90e
L
3541 {
3542 base_address = end;
2d9472a2 3543 printf ("(base address)\n");
19e6b90e
L
3544 continue;
3545 }
3546
19e6b90e 3547 if (begin == end)
2d9472a2 3548 fputs (_("(start == end)"), stdout);
19e6b90e 3549 else if (begin > end)
2d9472a2 3550 fputs (_("(start > end)"), stdout);
19e6b90e
L
3551
3552 putchar ('\n');
3553 }
3554 }
3555 }
3556 putchar ('\n');
3557 return 1;
3558}
3559
3560typedef struct Frame_Chunk
3561{
3562 struct Frame_Chunk *next;
3563 unsigned char *chunk_start;
3564 int ncols;
3565 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
3566 short int *col_type;
3567 int *col_offset;
3568 char *augmentation;
3569 unsigned int code_factor;
3570 int data_factor;
3571 unsigned long pc_begin;
3572 unsigned long pc_range;
3573 int cfa_reg;
3574 int cfa_offset;
3575 int ra;
3576 unsigned char fde_encoding;
3577 unsigned char cfa_exp;
3578}
3579Frame_Chunk;
3580
3581/* A marker for a col_type that means this column was never referenced
3582 in the frame info. */
3583#define DW_CFA_unreferenced (-1)
3584
3585static void
3586frame_need_space (Frame_Chunk *fc, int reg)
3587{
3588 int prev = fc->ncols;
3589
3590 if (reg < fc->ncols)
3591 return;
3592
3593 fc->ncols = reg + 1;
3594 fc->col_type = xcrealloc (fc->col_type, fc->ncols, sizeof (short int));
3595 fc->col_offset = xcrealloc (fc->col_offset, fc->ncols, sizeof (int));
3596
3597 while (prev < fc->ncols)
3598 {
3599 fc->col_type[prev] = DW_CFA_unreferenced;
3600 fc->col_offset[prev] = 0;
3601 prev++;
3602 }
3603}
3604
2dc4cec1
L
3605static const char *const dwarf_regnames_i386[] =
3606{
3607 "eax", "ecx", "edx", "ebx",
3608 "esp", "ebp", "esi", "edi",
3609 "eip", "eflags", NULL,
3610 "st0", "st1", "st2", "st3",
3611 "st4", "st5", "st6", "st7",
3612 NULL, NULL,
3613 "xmm0", "xmm1", "xmm2", "xmm3",
3614 "xmm4", "xmm5", "xmm6", "xmm7",
3615 "mm0", "mm1", "mm2", "mm3",
3616 "mm4", "mm5", "mm6", "mm7",
3617 "fcw", "fsw", "mxcsr",
3618 "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL,
c0f3af97
L
3619 "tr", "ldtr",
3620 NULL, NULL, NULL,
3621 "ymm0", "ymm1", "ymm2", "ymm3",
3622 "ymm4", "ymm5", "ymm6", "ymm7"
2dc4cec1
L
3623};
3624
3625static const char *const dwarf_regnames_x86_64[] =
3626{
3627 "rax", "rdx", "rcx", "rbx",
3628 "rsi", "rdi", "rbp", "rsp",
3629 "r8", "r9", "r10", "r11",
3630 "r12", "r13", "r14", "r15",
3631 "rip",
3632 "xmm0", "xmm1", "xmm2", "xmm3",
3633 "xmm4", "xmm5", "xmm6", "xmm7",
3634 "xmm8", "xmm9", "xmm10", "xmm11",
3635 "xmm12", "xmm13", "xmm14", "xmm15",
3636 "st0", "st1", "st2", "st3",
3637 "st4", "st5", "st6", "st7",
3638 "mm0", "mm1", "mm2", "mm3",
3639 "mm4", "mm5", "mm6", "mm7",
3640 "rflags",
3641 "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL,
3642 "fs.base", "gs.base", NULL, NULL,
3643 "tr", "ldtr",
c0f3af97
L
3644 "mxcsr", "fcw", "fsw",
3645 NULL, NULL, NULL,
3646 "ymm0", "ymm1", "ymm2", "ymm3",
3647 "ymm4", "ymm5", "ymm6", "ymm7",
3648 "ymm8", "ymm9", "ymm10", "ymm11",
3649 "ymm12", "ymm13", "ymm14", "ymm15"
2dc4cec1
L
3650};
3651
3652static const char *const *dwarf_regnames;
3653static unsigned int dwarf_regnames_count;
3654
3655void
3656init_dwarf_regnames (unsigned int e_machine)
3657{
3658 switch (e_machine)
3659 {
3660 case EM_386:
3661 case EM_486:
3662 dwarf_regnames = dwarf_regnames_i386;
3663 dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386);
3664 break;
3665
3666 case EM_X86_64:
3667 dwarf_regnames = dwarf_regnames_x86_64;
3668 dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);
3669 break;
3670
3671 default:
3672 break;
3673 }
3674}
3675
3676static const char *
3677regname (unsigned int regno, int row)
3678{
3679 static char reg[64];
3680 if (dwarf_regnames
3681 && regno < dwarf_regnames_count
3682 && dwarf_regnames [regno] != NULL)
3683 {
3684 if (row)
3685 return dwarf_regnames [regno];
3686 snprintf (reg, sizeof (reg), "r%d (%s)", regno,
3687 dwarf_regnames [regno]);
3688 }
3689 else
3690 snprintf (reg, sizeof (reg), "r%d", regno);
3691 return reg;
3692}
3693
19e6b90e
L
3694static void
3695frame_display_row (Frame_Chunk *fc, int *need_col_headers, int *max_regs)
3696{
3697 int r;
3698 char tmp[100];
3699
3700 if (*max_regs < fc->ncols)
3701 *max_regs = fc->ncols;
3702
3703 if (*need_col_headers)
3704 {
2dc4cec1
L
3705 static const char *loc = " LOC";
3706
19e6b90e
L
3707 *need_col_headers = 0;
3708
2dc4cec1 3709 printf ("%-*s CFA ", eh_addr_size * 2, loc);
19e6b90e
L
3710
3711 for (r = 0; r < *max_regs; r++)
3712 if (fc->col_type[r] != DW_CFA_unreferenced)
3713 {
3714 if (r == fc->ra)
2dc4cec1 3715 printf ("ra ");
19e6b90e 3716 else
2dc4cec1 3717 printf ("%-5s ", regname (r, 1));
19e6b90e
L
3718 }
3719
3720 printf ("\n");
3721 }
3722
2dc4cec1 3723 printf ("%0*lx ", eh_addr_size * 2, fc->pc_begin);
19e6b90e
L
3724 if (fc->cfa_exp)
3725 strcpy (tmp, "exp");
3726 else
2dc4cec1 3727 sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), fc->cfa_offset);
19e6b90e
L
3728 printf ("%-8s ", tmp);
3729
3730 for (r = 0; r < fc->ncols; r++)
3731 {
3732 if (fc->col_type[r] != DW_CFA_unreferenced)
3733 {
3734 switch (fc->col_type[r])
3735 {
3736 case DW_CFA_undefined:
3737 strcpy (tmp, "u");
3738 break;
3739 case DW_CFA_same_value:
3740 strcpy (tmp, "s");
3741 break;
3742 case DW_CFA_offset:
3743 sprintf (tmp, "c%+d", fc->col_offset[r]);
3744 break;
12eae2d3
JJ
3745 case DW_CFA_val_offset:
3746 sprintf (tmp, "v%+d", fc->col_offset[r]);
3747 break;
19e6b90e 3748 case DW_CFA_register:
2dc4cec1 3749 sprintf (tmp, "%s", regname (fc->col_offset[r], 0));
19e6b90e
L
3750 break;
3751 case DW_CFA_expression:
3752 strcpy (tmp, "exp");
3753 break;
12eae2d3
JJ
3754 case DW_CFA_val_expression:
3755 strcpy (tmp, "vexp");
3756 break;
19e6b90e
L
3757 default:
3758 strcpy (tmp, "n/a");
3759 break;
3760 }
2dc4cec1 3761 printf ("%-5s ", tmp);
19e6b90e
L
3762 }
3763 }
3764 printf ("\n");
3765}
3766
3767static int
3768size_of_encoded_value (int encoding)
3769{
3770 switch (encoding & 0x7)
3771 {
3772 default: /* ??? */
3773 case 0: return eh_addr_size;
3774 case 2: return 2;
3775 case 3: return 4;
3776 case 4: return 8;
3777 }
3778}
3779
3780static dwarf_vma
3781get_encoded_value (unsigned char *data, int encoding)
3782{
3783 int size = size_of_encoded_value (encoding);
53b8873b 3784
19e6b90e
L
3785 if (encoding & DW_EH_PE_signed)
3786 return byte_get_signed (data, size);
3787 else
3788 return byte_get (data, size);
3789}
3790
3791#define GET(N) byte_get (start, N); start += N
3792#define LEB() read_leb128 (start, & length_return, 0); start += length_return
3793#define SLEB() read_leb128 (start, & length_return, 1); start += length_return
3794
3795static int
3796display_debug_frames (struct dwarf_section *section,
3797 void *file ATTRIBUTE_UNUSED)
3798{
3799 unsigned char *start = section->start;
3800 unsigned char *end = start + section->size;
3801 unsigned char *section_start = start;
3802 Frame_Chunk *chunks = 0;
3803 Frame_Chunk *remembered_state = 0;
3804 Frame_Chunk *rs;
3805 int is_eh = strcmp (section->name, ".eh_frame") == 0;
3806 unsigned int length_return;
3807 int max_regs = 0;
3808
3809 printf (_("The section %s contains:\n"), section->name);
3810
3811 while (start < end)
3812 {
3813 unsigned char *saved_start;
3814 unsigned char *block_end;
3815 unsigned long length;
3816 unsigned long cie_id;
3817 Frame_Chunk *fc;
3818 Frame_Chunk *cie;
3819 int need_col_headers = 1;
3820 unsigned char *augmentation_data = NULL;
3821 unsigned long augmentation_data_len = 0;
3822 int encoded_ptr_size = eh_addr_size;
3823 int offset_size;
3824 int initial_length_size;
3825
3826 saved_start = start;
3827 length = byte_get (start, 4); start += 4;
3828
3829 if (length == 0)
3830 {
3831 printf ("\n%08lx ZERO terminator\n\n",
3832 (unsigned long)(saved_start - section_start));
b758e50f 3833 continue;
19e6b90e
L
3834 }
3835
3836 if (length == 0xffffffff)
3837 {
3838 length = byte_get (start, 8);
3839 start += 8;
3840 offset_size = 8;
3841 initial_length_size = 12;
3842 }
3843 else
3844 {
3845 offset_size = 4;
3846 initial_length_size = 4;
3847 }
3848
3849 block_end = saved_start + length + initial_length_size;
53b8873b
NC
3850 if (block_end > end)
3851 {
3852 warn ("Invalid length %#08lx in FDE at %#08lx\n",
3853 length, (unsigned long)(saved_start - section_start));
3854 block_end = end;
3855 }
19e6b90e
L
3856 cie_id = byte_get (start, offset_size); start += offset_size;
3857
3858 if (is_eh ? (cie_id == 0) : (cie_id == DW_CIE_ID))
3859 {
3860 int version;
3861
3862 fc = xmalloc (sizeof (Frame_Chunk));
3863 memset (fc, 0, sizeof (Frame_Chunk));
3864
3865 fc->next = chunks;
3866 chunks = fc;
3867 fc->chunk_start = saved_start;
3868 fc->ncols = 0;
3869 fc->col_type = xmalloc (sizeof (short int));
3870 fc->col_offset = xmalloc (sizeof (int));
cc86f28f 3871 frame_need_space (fc, max_regs - 1);
19e6b90e
L
3872
3873 version = *start++;
3874
3875 fc->augmentation = (char *) start;
3876 start = (unsigned char *) strchr ((char *) start, '\0') + 1;
3877
3878 if (fc->augmentation[0] == 'z')
3879 {
3880 fc->code_factor = LEB ();
3881 fc->data_factor = SLEB ();
3882 if (version == 1)
3883 {
3884 fc->ra = GET (1);
3885 }
3886 else
3887 {
3888 fc->ra = LEB ();
3889 }
3890 augmentation_data_len = LEB ();
3891 augmentation_data = start;
3892 start += augmentation_data_len;
3893 }
3894 else if (strcmp (fc->augmentation, "eh") == 0)
3895 {
3896 start += eh_addr_size;
3897 fc->code_factor = LEB ();
3898 fc->data_factor = SLEB ();
3899 if (version == 1)
3900 {
3901 fc->ra = GET (1);
3902 }
3903 else
3904 {
3905 fc->ra = LEB ();
3906 }
3907 }
3908 else
3909 {
3910 fc->code_factor = LEB ();
3911 fc->data_factor = SLEB ();
3912 if (version == 1)
3913 {
3914 fc->ra = GET (1);
3915 }
3916 else
3917 {
3918 fc->ra = LEB ();
3919 }
3920 }
3921 cie = fc;
3922
3923 if (do_debug_frames_interp)
3924 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
3925 (unsigned long)(saved_start - section_start), length, cie_id,
3926 fc->augmentation, fc->code_factor, fc->data_factor,
3927 fc->ra);
3928 else
3929 {
3930 printf ("\n%08lx %08lx %08lx CIE\n",
3931 (unsigned long)(saved_start - section_start), length, cie_id);
3932 printf (" Version: %d\n", version);
3933 printf (" Augmentation: \"%s\"\n", fc->augmentation);
3934 printf (" Code alignment factor: %u\n", fc->code_factor);
3935 printf (" Data alignment factor: %d\n", fc->data_factor);
3936 printf (" Return address column: %d\n", fc->ra);
3937
3938 if (augmentation_data_len)
3939 {
3940 unsigned long i;
3941 printf (" Augmentation data: ");
3942 for (i = 0; i < augmentation_data_len; ++i)
3943 printf (" %02x", augmentation_data[i]);
3944 putchar ('\n');
3945 }
3946 putchar ('\n');
3947 }
3948
3949 if (augmentation_data_len)
3950 {
3951 unsigned char *p, *q;
3952 p = (unsigned char *) fc->augmentation + 1;
3953 q = augmentation_data;
3954
3955 while (1)
3956 {
3957 if (*p == 'L')
3958 q++;
3959 else if (*p == 'P')
3960 q += 1 + size_of_encoded_value (*q);
3961 else if (*p == 'R')
3962 fc->fde_encoding = *q++;
3963 else
3964 break;
3965 p++;
3966 }
3967
3968 if (fc->fde_encoding)
3969 encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
3970 }
3971
3972 frame_need_space (fc, fc->ra);
3973 }
3974 else
3975 {
3976 unsigned char *look_for;
3977 static Frame_Chunk fde_fc;
3978
3979 fc = & fde_fc;
3980 memset (fc, 0, sizeof (Frame_Chunk));
3981
3982 look_for = is_eh ? start - 4 - cie_id : section_start + cie_id;
3983
3984 for (cie = chunks; cie ; cie = cie->next)
3985 if (cie->chunk_start == look_for)
3986 break;
3987
3988 if (!cie)
3989 {
53b8873b 3990 warn ("Invalid CIE pointer %#08lx in FDE at %#08lx\n",
1617e571 3991 cie_id, (unsigned long)(saved_start - section_start));
19e6b90e
L
3992 fc->ncols = 0;
3993 fc->col_type = xmalloc (sizeof (short int));
3994 fc->col_offset = xmalloc (sizeof (int));
3995 frame_need_space (fc, max_regs - 1);
3996 cie = fc;
3997 fc->augmentation = "";
3998 fc->fde_encoding = 0;
3999 }
4000 else
4001 {
4002 fc->ncols = cie->ncols;
4003 fc->col_type = xcmalloc (fc->ncols, sizeof (short int));
4004 fc->col_offset = xcmalloc (fc->ncols, sizeof (int));
4005 memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int));
4006 memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int));
4007 fc->augmentation = cie->augmentation;
4008 fc->code_factor = cie->code_factor;
4009 fc->data_factor = cie->data_factor;
4010 fc->cfa_reg = cie->cfa_reg;
4011 fc->cfa_offset = cie->cfa_offset;
4012 fc->ra = cie->ra;
cc86f28f 4013 frame_need_space (fc, max_regs - 1);
19e6b90e
L
4014 fc->fde_encoding = cie->fde_encoding;
4015 }
4016
4017 if (fc->fde_encoding)
4018 encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
4019
4020 fc->pc_begin = get_encoded_value (start, fc->fde_encoding);
41e92641 4021 if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel)
19e6b90e
L
4022 fc->pc_begin += section->address + (start - section_start);
4023 start += encoded_ptr_size;
4024 fc->pc_range = byte_get (start, encoded_ptr_size);
4025 start += encoded_ptr_size;
4026
4027 if (cie->augmentation[0] == 'z')
4028 {
4029 augmentation_data_len = LEB ();
4030 augmentation_data = start;
4031 start += augmentation_data_len;
4032 }
4033
4034 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=%08lx..%08lx\n",
4035 (unsigned long)(saved_start - section_start), length, cie_id,
4036 (unsigned long)(cie->chunk_start - section_start),
4037 fc->pc_begin, fc->pc_begin + fc->pc_range);
4038 if (! do_debug_frames_interp && augmentation_data_len)
4039 {
4040 unsigned long i;
4041
4042 printf (" Augmentation data: ");
4043 for (i = 0; i < augmentation_data_len; ++i)
4044 printf (" %02x", augmentation_data[i]);
4045 putchar ('\n');
4046 putchar ('\n');
4047 }
4048 }
4049
4050 /* At this point, fc is the current chunk, cie (if any) is set, and
4051 we're about to interpret instructions for the chunk. */
4052 /* ??? At present we need to do this always, since this sizes the
4053 fc->col_type and fc->col_offset arrays, which we write into always.
4054 We should probably split the interpreted and non-interpreted bits
4055 into two different routines, since there's so much that doesn't
4056 really overlap between them. */
4057 if (1 || do_debug_frames_interp)
4058 {
4059 /* Start by making a pass over the chunk, allocating storage
4060 and taking note of what registers are used. */
4061 unsigned char *tmp = start;
4062
4063 while (start < block_end)
4064 {
4065 unsigned op, opa;
4066 unsigned long reg, tmp;
4067
4068 op = *start++;
4069 opa = op & 0x3f;
4070 if (op & 0xc0)
4071 op &= 0xc0;
4072
4073 /* Warning: if you add any more cases to this switch, be
4074 sure to add them to the corresponding switch below. */
4075 switch (op)
4076 {
4077 case DW_CFA_advance_loc:
4078 break;
4079 case DW_CFA_offset:
4080 LEB ();
4081 frame_need_space (fc, opa);
4082 fc->col_type[opa] = DW_CFA_undefined;
4083 break;
4084 case DW_CFA_restore:
4085 frame_need_space (fc, opa);
4086 fc->col_type[opa] = DW_CFA_undefined;
4087 break;
4088 case DW_CFA_set_loc:
4089 start += encoded_ptr_size;
4090 break;
4091 case DW_CFA_advance_loc1:
4092 start += 1;
4093 break;
4094 case DW_CFA_advance_loc2:
4095 start += 2;
4096 break;
4097 case DW_CFA_advance_loc4:
4098 start += 4;
4099 break;
4100 case DW_CFA_offset_extended:
12eae2d3 4101 case DW_CFA_val_offset:
19e6b90e
L
4102 reg = LEB (); LEB ();
4103 frame_need_space (fc, reg);
4104 fc->col_type[reg] = DW_CFA_undefined;
4105 break;
4106 case DW_CFA_restore_extended:
4107 reg = LEB ();
4108 frame_need_space (fc, reg);
4109 fc->col_type[reg] = DW_CFA_undefined;
4110 break;
4111 case DW_CFA_undefined:
4112 reg = LEB ();
4113 frame_need_space (fc, reg);
4114 fc->col_type[reg] = DW_CFA_undefined;
4115 break;
4116 case DW_CFA_same_value:
4117 reg = LEB ();
4118 frame_need_space (fc, reg);
4119 fc->col_type[reg] = DW_CFA_undefined;
4120 break;
4121 case DW_CFA_register:
4122 reg = LEB (); LEB ();
4123 frame_need_space (fc, reg);
4124 fc->col_type[reg] = DW_CFA_undefined;
4125 break;
4126 case DW_CFA_def_cfa:
4127 LEB (); LEB ();
4128 break;
4129 case DW_CFA_def_cfa_register:
4130 LEB ();
4131 break;
4132 case DW_CFA_def_cfa_offset:
4133 LEB ();
4134 break;
4135 case DW_CFA_def_cfa_expression:
4136 tmp = LEB ();
4137 start += tmp;
4138 break;
4139 case DW_CFA_expression:
12eae2d3 4140 case DW_CFA_val_expression:
19e6b90e
L
4141 reg = LEB ();
4142 tmp = LEB ();
4143 start += tmp;
4144 frame_need_space (fc, reg);
4145 fc->col_type[reg] = DW_CFA_undefined;
4146 break;
4147 case DW_CFA_offset_extended_sf:
12eae2d3 4148 case DW_CFA_val_offset_sf:
19e6b90e
L
4149 reg = LEB (); SLEB ();
4150 frame_need_space (fc, reg);
4151 fc->col_type[reg] = DW_CFA_undefined;
4152 break;
4153 case DW_CFA_def_cfa_sf:
4154 LEB (); SLEB ();
4155 break;
4156 case DW_CFA_def_cfa_offset_sf:
4157 SLEB ();
4158 break;
4159 case DW_CFA_MIPS_advance_loc8:
4160 start += 8;
4161 break;
4162 case DW_CFA_GNU_args_size:
4163 LEB ();
4164 break;
4165 case DW_CFA_GNU_negative_offset_extended:
4166 reg = LEB (); LEB ();
4167 frame_need_space (fc, reg);
4168 fc->col_type[reg] = DW_CFA_undefined;
4169
4170 default:
4171 break;
4172 }
4173 }
4174 start = tmp;
4175 }
4176
4177 /* Now we know what registers are used, make a second pass over
4178 the chunk, this time actually printing out the info. */
4179
4180 while (start < block_end)
4181 {
4182 unsigned op, opa;
4183 unsigned long ul, reg, roffs;
4184 long l, ofs;
4185 dwarf_vma vma;
4186
4187 op = *start++;
4188 opa = op & 0x3f;
4189 if (op & 0xc0)
4190 op &= 0xc0;
4191
4192 /* Warning: if you add any more cases to this switch, be
4193 sure to add them to the corresponding switch above. */
4194 switch (op)
4195 {
4196 case DW_CFA_advance_loc:
4197 if (do_debug_frames_interp)
4198 frame_display_row (fc, &need_col_headers, &max_regs);
4199 else
4200 printf (" DW_CFA_advance_loc: %d to %08lx\n",
4201 opa * fc->code_factor,
4202 fc->pc_begin + opa * fc->code_factor);
4203 fc->pc_begin += opa * fc->code_factor;
4204 break;
4205
4206 case DW_CFA_offset:
4207 roffs = LEB ();
4208 if (! do_debug_frames_interp)
2dc4cec1
L
4209 printf (" DW_CFA_offset: %s at cfa%+ld\n",
4210 regname (opa, 0), roffs * fc->data_factor);
19e6b90e
L
4211 fc->col_type[opa] = DW_CFA_offset;
4212 fc->col_offset[opa] = roffs * fc->data_factor;
4213 break;
4214
4215 case DW_CFA_restore:
4216 if (! do_debug_frames_interp)
2dc4cec1 4217 printf (" DW_CFA_restore: %s\n", regname (opa, 0));
19e6b90e
L
4218 fc->col_type[opa] = cie->col_type[opa];
4219 fc->col_offset[opa] = cie->col_offset[opa];
4220 break;
4221
4222 case DW_CFA_set_loc:
4223 vma = get_encoded_value (start, fc->fde_encoding);
41e92641 4224 if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel)
19e6b90e
L
4225 vma += section->address + (start - section_start);
4226 start += encoded_ptr_size;
4227 if (do_debug_frames_interp)
4228 frame_display_row (fc, &need_col_headers, &max_regs);
4229 else
4230 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma);
4231 fc->pc_begin = vma;
4232 break;
4233
4234 case DW_CFA_advance_loc1:
4235 ofs = byte_get (start, 1); start += 1;
4236 if (do_debug_frames_interp)
4237 frame_display_row (fc, &need_col_headers, &max_regs);
4238 else
4239 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
4240 ofs * fc->code_factor,
4241 fc->pc_begin + ofs * fc->code_factor);
4242 fc->pc_begin += ofs * fc->code_factor;
4243 break;
4244
4245 case DW_CFA_advance_loc2:
4246 ofs = byte_get (start, 2); start += 2;
4247 if (do_debug_frames_interp)
4248 frame_display_row (fc, &need_col_headers, &max_regs);
4249 else
4250 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
4251 ofs * fc->code_factor,
4252 fc->pc_begin + ofs * fc->code_factor);
4253 fc->pc_begin += ofs * fc->code_factor;
4254 break;
4255
4256 case DW_CFA_advance_loc4:
4257 ofs = byte_get (start, 4); start += 4;
4258 if (do_debug_frames_interp)
4259 frame_display_row (fc, &need_col_headers, &max_regs);
4260 else
4261 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
4262 ofs * fc->code_factor,
4263 fc->pc_begin + ofs * fc->code_factor);
4264 fc->pc_begin += ofs * fc->code_factor;
4265 break;
4266
4267 case DW_CFA_offset_extended:
4268 reg = LEB ();
4269 roffs = LEB ();
4270 if (! do_debug_frames_interp)
2dc4cec1
L
4271 printf (" DW_CFA_offset_extended: %s at cfa%+ld\n",
4272 regname (reg, 0), roffs * fc->data_factor);
19e6b90e
L
4273 fc->col_type[reg] = DW_CFA_offset;
4274 fc->col_offset[reg] = roffs * fc->data_factor;
4275 break;
4276
12eae2d3
JJ
4277 case DW_CFA_val_offset:
4278 reg = LEB ();
4279 roffs = LEB ();
4280 if (! do_debug_frames_interp)
2dc4cec1
L
4281 printf (" DW_CFA_val_offset: %s at cfa%+ld\n",
4282 regname (reg, 0), roffs * fc->data_factor);
12eae2d3
JJ
4283 fc->col_type[reg] = DW_CFA_val_offset;
4284 fc->col_offset[reg] = roffs * fc->data_factor;
4285 break;
4286
19e6b90e
L
4287 case DW_CFA_restore_extended:
4288 reg = LEB ();
4289 if (! do_debug_frames_interp)
2dc4cec1
L
4290 printf (" DW_CFA_restore_extended: %s\n",
4291 regname (reg, 0));
19e6b90e
L
4292 fc->col_type[reg] = cie->col_type[reg];
4293 fc->col_offset[reg] = cie->col_offset[reg];
4294 break;
4295
4296 case DW_CFA_undefined:
4297 reg = LEB ();
4298 if (! do_debug_frames_interp)
2dc4cec1 4299 printf (" DW_CFA_undefined: %s\n", regname (reg, 0));
19e6b90e
L
4300 fc->col_type[reg] = DW_CFA_undefined;
4301 fc->col_offset[reg] = 0;
4302 break;
4303
4304 case DW_CFA_same_value:
4305 reg = LEB ();
4306 if (! do_debug_frames_interp)
2dc4cec1 4307 printf (" DW_CFA_same_value: %s\n", regname (reg, 0));
19e6b90e
L
4308 fc->col_type[reg] = DW_CFA_same_value;
4309 fc->col_offset[reg] = 0;
4310 break;
4311
4312 case DW_CFA_register:
4313 reg = LEB ();
4314 roffs = LEB ();
4315 if (! do_debug_frames_interp)
2dc4cec1
L
4316 {
4317 printf (" DW_CFA_register: %s in ",
4318 regname (reg, 0));
4319 puts (regname (roffs, 0));
4320 }
19e6b90e
L
4321 fc->col_type[reg] = DW_CFA_register;
4322 fc->col_offset[reg] = roffs;
4323 break;
4324
4325 case DW_CFA_remember_state:
4326 if (! do_debug_frames_interp)
4327 printf (" DW_CFA_remember_state\n");
4328 rs = xmalloc (sizeof (Frame_Chunk));
4329 rs->ncols = fc->ncols;
4330 rs->col_type = xcmalloc (rs->ncols, sizeof (short int));
4331 rs->col_offset = xcmalloc (rs->ncols, sizeof (int));
4332 memcpy (rs->col_type, fc->col_type, rs->ncols);
4333 memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (int));
4334 rs->next = remembered_state;
4335 remembered_state = rs;
4336 break;
4337
4338 case DW_CFA_restore_state:
4339 if (! do_debug_frames_interp)
4340 printf (" DW_CFA_restore_state\n");
4341 rs = remembered_state;
4342 if (rs)
4343 {
4344 remembered_state = rs->next;
cc86f28f 4345 frame_need_space (fc, rs->ncols - 1);
19e6b90e
L
4346 memcpy (fc->col_type, rs->col_type, rs->ncols);
4347 memcpy (fc->col_offset, rs->col_offset,
4348 rs->ncols * sizeof (int));
4349 free (rs->col_type);
4350 free (rs->col_offset);
4351 free (rs);
4352 }
4353 else if (do_debug_frames_interp)
4354 printf ("Mismatched DW_CFA_restore_state\n");
4355 break;
4356
4357 case DW_CFA_def_cfa:
4358 fc->cfa_reg = LEB ();
4359 fc->cfa_offset = LEB ();
4360 fc->cfa_exp = 0;
4361 if (! do_debug_frames_interp)
2dc4cec1
L
4362 printf (" DW_CFA_def_cfa: %s ofs %d\n",
4363 regname (fc->cfa_reg, 0), fc->cfa_offset);
19e6b90e
L
4364 break;
4365
4366 case DW_CFA_def_cfa_register:
4367 fc->cfa_reg = LEB ();
4368 fc->cfa_exp = 0;
4369 if (! do_debug_frames_interp)
2dc4cec1
L
4370 printf (" DW_CFA_def_cfa_register: %s\n",
4371 regname (fc->cfa_reg, 0));
19e6b90e
L
4372 break;
4373
4374 case DW_CFA_def_cfa_offset:
4375 fc->cfa_offset = LEB ();
4376 if (! do_debug_frames_interp)
4377 printf (" DW_CFA_def_cfa_offset: %d\n", fc->cfa_offset);
4378 break;
4379
4380 case DW_CFA_nop:
4381 if (! do_debug_frames_interp)
4382 printf (" DW_CFA_nop\n");
4383 break;
4384
4385 case DW_CFA_def_cfa_expression:
4386 ul = LEB ();
4387 if (! do_debug_frames_interp)
4388 {
4389 printf (" DW_CFA_def_cfa_expression (");
4390 decode_location_expression (start, eh_addr_size, ul, 0);
4391 printf (")\n");
4392 }
4393 fc->cfa_exp = 1;
4394 start += ul;
4395 break;
4396
4397 case DW_CFA_expression:
4398 reg = LEB ();
4399 ul = LEB ();
4400 if (! do_debug_frames_interp)
4401 {
2dc4cec1
L
4402 printf (" DW_CFA_expression: %s (",
4403 regname (reg, 0));
4404 decode_location_expression (start, eh_addr_size,
4405 ul, 0);
19e6b90e
L
4406 printf (")\n");
4407 }
4408 fc->col_type[reg] = DW_CFA_expression;
4409 start += ul;
4410 break;
4411
12eae2d3
JJ
4412 case DW_CFA_val_expression:
4413 reg = LEB ();
4414 ul = LEB ();
4415 if (! do_debug_frames_interp)
4416 {
2dc4cec1
L
4417 printf (" DW_CFA_val_expression: %s (",
4418 regname (reg, 0));
12eae2d3
JJ
4419 decode_location_expression (start, eh_addr_size, ul, 0);
4420 printf (")\n");
4421 }
4422 fc->col_type[reg] = DW_CFA_val_expression;
4423 start += ul;
4424 break;
4425
19e6b90e
L
4426 case DW_CFA_offset_extended_sf:
4427 reg = LEB ();
4428 l = SLEB ();
4429 frame_need_space (fc, reg);
4430 if (! do_debug_frames_interp)
2dc4cec1
L
4431 printf (" DW_CFA_offset_extended_sf: %s at cfa%+ld\n",
4432 regname (reg, 0), l * fc->data_factor);
19e6b90e
L
4433 fc->col_type[reg] = DW_CFA_offset;
4434 fc->col_offset[reg] = l * fc->data_factor;
4435 break;
4436
12eae2d3
JJ
4437 case DW_CFA_val_offset_sf:
4438 reg = LEB ();
4439 l = SLEB ();
4440 frame_need_space (fc, reg);
4441 if (! do_debug_frames_interp)
2dc4cec1
L
4442 printf (" DW_CFA_val_offset_sf: %s at cfa%+ld\n",
4443 regname (reg, 0), l * fc->data_factor);
12eae2d3
JJ
4444 fc->col_type[reg] = DW_CFA_val_offset;
4445 fc->col_offset[reg] = l * fc->data_factor;
4446 break;
4447
19e6b90e
L
4448 case DW_CFA_def_cfa_sf:
4449 fc->cfa_reg = LEB ();
4450 fc->cfa_offset = SLEB ();
4451 fc->cfa_offset = fc->cfa_offset * fc->data_factor;
4452 fc->cfa_exp = 0;
4453 if (! do_debug_frames_interp)
2dc4cec1
L
4454 printf (" DW_CFA_def_cfa_sf: %s ofs %d\n",
4455 regname (fc->cfa_reg, 0), fc->cfa_offset);
19e6b90e
L
4456 break;
4457
4458 case DW_CFA_def_cfa_offset_sf:
4459 fc->cfa_offset = SLEB ();
4460 fc->cfa_offset = fc->cfa_offset * fc->data_factor;
4461 if (! do_debug_frames_interp)
4462 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc->cfa_offset);
4463 break;
4464
4465 case DW_CFA_MIPS_advance_loc8:
4466 ofs = byte_get (start, 8); start += 8;
4467 if (do_debug_frames_interp)
4468 frame_display_row (fc, &need_col_headers, &max_regs);
4469 else
4470 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
4471 ofs * fc->code_factor,
4472 fc->pc_begin + ofs * fc->code_factor);
4473 fc->pc_begin += ofs * fc->code_factor;
4474 break;
4475
4476 case DW_CFA_GNU_window_save:
4477 if (! do_debug_frames_interp)
4478 printf (" DW_CFA_GNU_window_save\n");
4479 break;
4480
4481 case DW_CFA_GNU_args_size:
4482 ul = LEB ();
4483 if (! do_debug_frames_interp)
4484 printf (" DW_CFA_GNU_args_size: %ld\n", ul);
4485 break;
4486
4487 case DW_CFA_GNU_negative_offset_extended:
4488 reg = LEB ();
4489 l = - LEB ();
4490 frame_need_space (fc, reg);
4491 if (! do_debug_frames_interp)
2dc4cec1
L
4492 printf (" DW_CFA_GNU_negative_offset_extended: %s at cfa%+ld\n",
4493 regname (reg, 0), l * fc->data_factor);
19e6b90e
L
4494 fc->col_type[reg] = DW_CFA_offset;
4495 fc->col_offset[reg] = l * fc->data_factor;
4496 break;
4497
4498 default:
53b8873b
NC
4499 if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user)
4500 printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op);
4501 else
cecf136e 4502 warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op);
19e6b90e
L
4503 start = block_end;
4504 }
4505 }
4506
4507 if (do_debug_frames_interp)
4508 frame_display_row (fc, &need_col_headers, &max_regs);
4509
4510 start = block_end;
4511 }
4512
4513 printf ("\n");
4514
4515 return 1;
4516}
4517
4518#undef GET
4519#undef LEB
4520#undef SLEB
4521
4522static int
4523display_debug_not_supported (struct dwarf_section *section,
4524 void *file ATTRIBUTE_UNUSED)
4525{
4526 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
4527 section->name);
4528
4529 return 1;
4530}
4531
4532void *
4533cmalloc (size_t nmemb, size_t size)
4534{
4535 /* Check for overflow. */
4536 if (nmemb >= ~(size_t) 0 / size)
4537 return NULL;
4538 else
4539 return malloc (nmemb * size);
4540}
4541
4542void *
4543xcmalloc (size_t nmemb, size_t size)
4544{
4545 /* Check for overflow. */
4546 if (nmemb >= ~(size_t) 0 / size)
4547 return NULL;
4548 else
4549 return xmalloc (nmemb * size);
4550}
4551
4552void *
4553xcrealloc (void *ptr, size_t nmemb, size_t size)
4554{
4555 /* Check for overflow. */
4556 if (nmemb >= ~(size_t) 0 / size)
4557 return NULL;
4558 else
4559 return xrealloc (ptr, nmemb * size);
4560}
4561
4562void
4563error (const char *message, ...)
4564{
4565 va_list args;
4566
4567 va_start (args, message);
4568 fprintf (stderr, _("%s: Error: "), program_name);
4569 vfprintf (stderr, message, args);
4570 va_end (args);
4571}
4572
4573void
4574warn (const char *message, ...)
4575{
4576 va_list args;
4577
4578 va_start (args, message);
4579 fprintf (stderr, _("%s: Warning: "), program_name);
4580 vfprintf (stderr, message, args);
4581 va_end (args);
4582}
4583
4584void
4585free_debug_memory (void)
4586{
4587 enum dwarf_section_display_enum i;
4588
4589 free_abbrevs ();
4590
4591 for (i = 0; i < max; i++)
4592 free_debug_section (i);
4593
cc86f28f 4594 if (debug_information != NULL)
19e6b90e 4595 {
cc86f28f 4596 if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE)
19e6b90e 4597 {
cc86f28f 4598 for (i = 0; i < num_debug_info_entries; i++)
19e6b90e 4599 {
cc86f28f
NC
4600 if (!debug_information [i].max_loc_offsets)
4601 {
4602 free (debug_information [i].loc_offsets);
4603 free (debug_information [i].have_frame_base);
4604 }
4605 if (!debug_information [i].max_range_lists)
4606 free (debug_information [i].range_lists);
19e6b90e 4607 }
19e6b90e 4608 }
cc86f28f 4609
19e6b90e
L
4610 free (debug_information);
4611 debug_information = NULL;
4612 num_debug_info_entries = 0;
4613 }
19e6b90e
L
4614}
4615
4616struct dwarf_section_display debug_displays[] =
4617{
1b315056 4618 { { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0 },
19e6b90e 4619 display_debug_abbrev, 0, 0 },
1b315056 4620 { { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0 },
19e6b90e 4621 display_debug_aranges, 0, 0 },
1b315056 4622 { { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0 },
19e6b90e 4623 display_debug_frames, 1, 0 },
1b315056 4624 { { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0 },
19e6b90e 4625 display_debug_info, 1, 0 },
1b315056 4626 { { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0 },
19e6b90e 4627 display_debug_lines, 0, 0 },
1b315056 4628 { { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0 },
19e6b90e 4629 display_debug_pubnames, 0, 0 },
1b315056 4630 { { ".eh_frame", "", NULL, NULL, 0, 0 },
19e6b90e 4631 display_debug_frames, 1, 1 },
1b315056 4632 { { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0 },
19e6b90e 4633 display_debug_macinfo, 0, 0 },
1b315056 4634 { { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0 },
19e6b90e 4635 display_debug_str, 0, 0 },
1b315056 4636 { { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0 },
19e6b90e 4637 display_debug_loc, 0, 0 },
1b315056 4638 { { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0 },
19e6b90e 4639 display_debug_pubnames, 0, 0 },
1b315056 4640 { { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0 },
19e6b90e 4641 display_debug_ranges, 0, 0 },
1b315056 4642 { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0 },
19e6b90e 4643 display_debug_not_supported, 0, 0 },
1b315056 4644 { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0 },
19e6b90e 4645 display_debug_not_supported, 0, 0 },
1b315056 4646 { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 },
19e6b90e 4647 display_debug_not_supported, 0, 0 },
1b315056 4648 { { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0 },
19e6b90e
L
4649 display_debug_not_supported, 0, 0 }
4650};
This page took 0.348527 seconds and 4 git commands to generate.