File: dwarf_errmsg_list.c

package info (click to toggle)
dwarfutils 20161124-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,800 kB
  • ctags: 5,982
  • sloc: ansic: 60,119; cpp: 3,753; python: 639; makefile: 618; sh: 590; awk: 11
file content (699 lines) | stat: -rw-r--r-- 28,238 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
/*

  Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
  Portions Copyright (C) 2008-2016 David Anderson.  All Rights Reserved.

  This program is free software; you can redistribute it and/or modify it
  under the terms of version 2.1 of the GNU Lesser General Public License
  as published by the Free Software Foundation.

  This program is distributed in the hope that it would be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  Further, this software is distributed without any warranty that it is
  free of the rightful claim of any third person regarding infringement
  or the like.  Any license provided herein, whether implied or
  otherwise, applies only to this software file.  Patent licenses, if
  any, provided herein do not apply to combinations of this program with
  other software, or any other product whatsoever.

  You should have received a copy of the GNU Lesser General Public
  License along with this program; if not, write the Free Software
  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
  USA.

*/

#ifdef TESTING
#include "config.h"
#include "dwarf_incl.h"
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>  /* For exit(), strtoul() declaration etc. */
#endif
#endif  /* TESTING */

/* Array to hold string representation of errors. Any time a
   define is added to the list in libdwarf.h, a string should be
   added to this Array

   Errors in the list (missing a comma, for example)
   happen too often. Making this a separate little file
   simplfies testing for missing-commas/extra-strings.

   String count should match DW_DLE_LAST+1
*/

const char *_dwarf_errmsgs[] = {
    "No error (0)\n",
    "DW_DLE_VMM (1) dwarf format/library version mismatch",
    "DW_DLE_MAP (2) memory map failure",
    "DW_DLE_LEE (3) libelf error",
    "DW_DLE_NDS (4) no debug section",
    "DW_DLE_NLS (5) no line section ",
    "DW_DLE_ID (6) invalid descriptor for query ",
    "DW_DLE_IOF (7) I/O failure ",
    "DW_DLE_MAF (8) memory allocation failure ",
    "DW_DLE_IA (9) invalid argument ",
    "DW_DLE_MDE (10) mangled debugging entry:libelf detected error",
    "DW_DLE_MLE (11) mangled line number entry ",
    "DW_DLE_FNO (12) file not open ",
    "DW_DLE_FNR (13) file not a regular file ",
    "DW_DLE_FWA (14) file open with wrong access ",
    "DW_DLE_NOB (15) not an object file ",
    "DW_DLE_MOF (16) mangled object file header ",
    "DW_DLE_EOLL (17) end of location list entries ",
    "DW_DLE_NOLL (18) no location list section ",
    "DW_DLE_BADOFF (19) Invalid offset ",
    "DW_DLE_EOS (20) end of section  ",
    "DW_DLE_ATRUNC (21) abbreviations section appears truncated",
    "DW_DLE_BADBITC (22)  Address size passed to dwarf bad",

    "DW_DLE_DBG_ALLOC (23) Unable to malloc a Dwarf_Debug structure",
    "DW_DLE_FSTAT_ERROR (24) The file fd passed to dwarf_init "
        "cannot be fstat()ed",
    "DW_DLE_FSTAT_MODE_ERROR (25) The file mode bits do not "
        "indicate that the file being opened via "
        "dwarf_init() is a normal file",
    "DW_DLE_INIT_ACCESS_WRONG (26) A call to dwarf_init had an "
        "access of other than DW_DLC_READ",
    "DW_DLE_ELF_BEGIN_ERROR (27) a call to "
        "elf_begin(... ELF_C_READ_MMAP... ) failed",
    "DW_DLE_ELF_GETEHDR_ERROR (28) a call to "
        "elf32_getehdr() or elf64_getehdr() failed",
    "DW_DLE_ELF_GETSHDR_ERROR (29) a call to "
        "elf32_getshdr() or elf64_getshdr() failed",
    "DW_DLE_ELF_STRPTR_ERROR (30) a call to "
        "elf_strptr() failed trying to get a section name",
    "DW_DLE_DEBUG_INFO_DUPLICATE (31)  Only one .debug_info  "
        "section is allowed",
    "DW_DLE_DEBUG_INFO_NULL (32) .debug_info section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_ABBREV_DUPLICATE (33) Only one .debug_abbrev  "
        "section is allowed",
    "DW_DLE_DEBUG_ABBREV_NULL (34) .debug_abbrev section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_ARANGES_DUPLICATE (35) Only one .debug_aranges  "
        "section is allowed",
    "DW_DLE_DEBUG_ARANGES_NULL (36) .debug_aranges section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_LINE_DUPLICATE (37) Only one .debug_line  "
        "section is allowed",
    "DW_DLE_DEBUG_LINE_NULL (38) .debug_line section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_LOC_DUPLICATE (39) Only one .debug_loc  "
        "section is allowed",
    "DW_DLE_DEBUG_LOC_NULL (40) .debug_loc section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_MACINFO_DUPLICATE (41) Only one .debug_macinfo  "
        "section is allowed",
    "DW_DLE_DEBUG_MACINFO_NULL (42) .debug_macinfo section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_PUBNAMES_DUPLICATE (43) Only one .debug_pubnames  "
        "section is allowed",
    "DW_DLE_DEBUG_PUBNAMES_NULL (44) .debug_pubnames section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_STR_DUPLICATE (45)  Only one .debug_str  "
        "section is allowed",
    "DW_DLE_DEBUG_STR_NULL (46) .debug_str section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_CU_LENGTH_ERROR (47)",
    "DW_DLE_VERSION_STAMP_ERROR (48)",
    "DW_DLE_ABBREV_OFFSET_ERROR (49)",
    "DW_DLE_ADDRESS_SIZE_ERROR (50) Either too large or zero",
    "DW_DLE_DEBUG_INFO_PTR_NULL (51)",
    "DW_DLE_DIE_NULL (52)",
    "DW_DLE_STRING_OFFSET_BAD (53)",
    "DW_DLE_DEBUG_LINE_LENGTH_BAD (54)",
    "DW_DLE_LINE_PROLOG_LENGTH_BAD (55)",
    "DW_DLE_LINE_NUM_OPERANDS_BAD (56)",
    "DW_DLE_LINE_SET_ADDR_ERROR (57)",
    "DW_DLE_LINE_EXT_OPCODE_BAD (58)",
    "DW_DLE_DWARF_LINE_NULL (59)",
    "DW_DLE_INCL_DIR_NUM_BAD (60)",
    "DW_DLE_LINE_FILE_NUM_BAD (61)",
    "DW_DLE_ALLOC_FAIL (62)",
    "DW_DLE_NO_CALLBACK_FUNC (63)",
    "DW_DLE_SECT_ALLOC (64)",
    "DW_DLE_FILE_ENTRY_ALLOC (65)",
    "DW_DLE_LINE_ALLOC (66)",
    "DW_DLE_FPGM_ALLOC (67)",
    "DW_DLE_INCDIR_ALLOC (68)",
    "DW_DLE_STRING_ALLOC (69)",
    "DW_DLE_CHUNK_ALLOC (70)",
    "DW_DLE_BYTEOFF_ERR (71)",
    "DW_DLE_CIE_ALLOC (72)",
    "DW_DLE_FDE_ALLOC (73)",
    "DW_DLE_REGNO_OVFL (74)",
    "DW_DLE_CIE_OFFS_ALLOC (75)",
    "DW_DLE_WRONG_ADDRESS (76)",
    "DW_DLE_EXTRA_NEIGHBORS (77)",
    "DW_DLE_WRONG_TAG (78)",
    "DW_DLE_DIE_ALLOC (79)",
    "DW_DLE_PARENT_EXISTS (80)",
    "DW_DLE_DBG_NULL (81)",
    "DW_DLE_DEBUGLINE_ERROR (82)",
    "DW_DLE_DEBUGFRAME_ERROR (83)",
    "DW_DLE_DEBUGINFO_ERROR (84)",
    "DW_DLE_ATTR_ALLOC (85)",
    "DW_DLE_ABBREV_ALLOC (86)",
    "DW_DLE_OFFSET_UFLW (87)",
    "DW_DLE_ELF_SECT_ERR (88)",
    "DW_DLE_DEBUG_FRAME_LENGTH_BAD (89)",
    "DW_DLE_FRAME_VERSION_BAD (90)",
    "DW_DLE_CIE_RET_ADDR_REG_ERROR (91)",
    "DW_DLE_FDE_NULL (92)",
    "DW_DLE_FDE_DBG_NULL (93)",
    "DW_DLE_CIE_NULL (94)",
    "DW_DLE_CIE_DBG_NULL (95)",
    "DW_DLE_FRAME_TABLE_COL_BAD (96)",
    "DW_DLE_PC_NOT_IN_FDE_RANGE (97)",
    "DW_DLE_CIE_INSTR_EXEC_ERROR (98)",
    "DW_DLE_FRAME_INSTR_EXEC_ERROR (99)",
    "DW_DLE_FDE_PTR_NULL (100)",
    "DW_DLE_RET_OP_LIST_NULL (101)",
    "DW_DLE_LINE_CONTEXT_NULL (102)",
    "DW_DLE_DBG_NO_CU_CONTEXT (103)",
    "DW_DLE_DIE_NO_CU_CONTEXT (104)",
    "DW_DLE_FIRST_DIE_NOT_CU (105)",
    "DW_DLE_NEXT_DIE_PTR_NULL (106)",
    "DW_DLE_DEBUG_FRAME_DUPLICATE  (107) Only one .debug_frame  "
        "section is allowed",
    "DW_DLE_DEBUG_FRAME_NULL (108) .debug_frame section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_ABBREV_DECODE_ERROR (109)",
    "DW_DLE_DWARF_ABBREV_NULL (110)",
    "DW_DLE_ATTR_NULL (111)",
    "DW_DLE_DIE_BAD (112)",
    "DW_DLE_DIE_ABBREV_BAD (113)",
    "DW_DLE_ATTR_FORM_BAD (114)",
    "DW_DLE_ATTR_NO_CU_CONTEXT (115)",
    "DW_DLE_ATTR_FORM_SIZE_BAD (116)",
    "DW_DLE_ATTR_DBG_NULL (117)",
    "DW_DLE_BAD_REF_FORM (118)",
    "DW_DLE_ATTR_FORM_OFFSET_BAD (119)",
    "DW_DLE_LINE_OFFSET_BAD (120)",
    "DW_DLE_DEBUG_STR_OFFSET_BAD (121)",
    "DW_DLE_STRING_PTR_NULL (122)",
    "DW_DLE_PUBNAMES_VERSION_ERROR (123)",
    "DW_DLE_PUBNAMES_LENGTH_BAD (124)",
    "DW_DLE_GLOBAL_NULL (125)",
    "DW_DLE_GLOBAL_CONTEXT_NULL (126)",
    "DW_DLE_DIR_INDEX_BAD (127)",
    "DW_DLE_LOC_EXPR_BAD (128)",
    "DW_DLE_DIE_LOC_EXPR_BAD (129)",
    "DW_DLE_ADDR_ALLOC (130)",
    "DW_DLE_OFFSET_BAD (131)",
    "DW_DLE_MAKE_CU_CONTEXT_FAIL (132)",
    "DW_DLE_REL_ALLOC (133)",
    "DW_DLE_ARANGE_OFFSET_BAD (134)",
    "DW_DLE_SEGMENT_SIZE_BAD (135) Size of a segment selector should usually be less than 8 (bytes).",
    "DW_DLE_ARANGE_LENGTH_BAD (136)",
    "DW_DLE_ARANGE_DECODE_ERROR (137)",
    "DW_DLE_ARANGES_NULL (138)",
    "DW_DLE_ARANGE_NULL (139)",
    "DW_DLE_NO_FILE_NAME (140)",
    "DW_DLE_NO_COMP_DIR (141)",
    "DW_DLE_CU_ADDRESS_SIZE_BAD (142)",
    "DW_DLE_INPUT_ATTR_BAD (143)",
    "DW_DLE_EXPR_NULL (144)",
    "DW_DLE_BAD_EXPR_OPCODE (145)",
    "DW_DLE_EXPR_LENGTH_BAD (146)",
    "DW_DLE_MULTIPLE_RELOC_IN_EXPR (147)",
    "DW_DLE_ELF_GETIDENT_ERROR (148)",
    "DW_DLE_NO_AT_MIPS_FDE (149)",
    "DW_DLE_NO_CIE_FOR_FDE (150)",
    "DW_DLE_DIE_ABBREV_LIST_NULL (151)",
    "DW_DLE_DEBUG_FUNCNAMES_DUPLICATE (152)",
    "DW_DLE_DEBUG_FUNCNAMES_NULL (153) .debug_funcnames section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_FUNCNAMES_VERSION_ERROR (154)",
    "DW_DLE_DEBUG_FUNCNAMES_LENGTH_BAD (155)",
    "DW_DLE_FUNC_NULL (156)",
    "DW_DLE_FUNC_CONTEXT_NULL (157)",
    "DW_DLE_DEBUG_TYPENAMES_DUPLICATE (158)",
    "DW_DLE_DEBUG_TYPENAMES_NULL (159) .debug_typenames section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_TYPENAMES_VERSION_ERROR (160)",
    "DW_DLE_DEBUG_TYPENAMES_LENGTH_BAD (161)",
    "DW_DLE_TYPE_NULL (162)",
    "DW_DLE_TYPE_CONTEXT_NULL (163)",
    "DW_DLE_DEBUG_VARNAMES_DUPLICATE (164)",
    "DW_DLE_DEBUG_VARNAMES_NULL (165) .debug_varnames section present but "
        "elf_getdata() failed or section is zero-length",
    "DW_DLE_DEBUG_VARNAMES_VERSION_ERROR (166)",
    "DW_DLE_DEBUG_VARNAMES_LENGTH_BAD (167)",
    "DW_DLE_VAR_NULL (168)",
    "DW_DLE_VAR_CONTEXT_NULL (169)",
    "DW_DLE_DEBUG_WEAKNAMES_DUPLICATE (170)",
    "DW_DLE_DEBUG_WEAKNAMES_NULL (171) .debug_weaknames section present but "
        "elf_getdata() failed or section is zero-length",

    "DW_DLE_DEBUG_WEAKNAMES_VERSION_ERROR (172)",
    "DW_DLE_DEBUG_WEAKNAMES_LENGTH_BAD (173)",
    "DW_DLE_WEAK_NULL (174)",
    "DW_DLE_WEAK_CONTEXT_NULL (175)",
    "DW_DLE_LOCDESC_COUNT_WRONG (176)",
    "DW_DLE_MACINFO_STRING_NULL (177)",
    "DW_DLE_MACINFO_STRING_EMPTY (178)",
    "DW_DLE_MACINFO_INTERNAL_ERROR_SPACE (179)",
    "DW_DLE_MACINFO_MALLOC_FAIL (180)",
    "DW_DLE_DEBUGMACINFO_ERROR (181)",
    "DW_DLE_DEBUG_MACRO_LENGTH_BAD (182) in .debug_macinfo",
    "DW_DLE_DEBUG_MACRO_MAX_BAD (183) in .debug_macinfo",
    "DW_DLE_DEBUG_MACRO_INTERNAL_ERR (184) in .debug_macinfo",
    "DW_DLE_DEBUG_MACRO_MALLOC_SPACE (185) in .debug_macinfo",
    "DW_DLE_DEBUG_MACRO_INCONSISTENT (186) in .debug_macinfo",
    "DW_DLE_DF_NO_CIE_AUGMENTATION(187)",
    "DW_DLE_DF_REG_NUM_TOO_HIGH(188)",
    "DW_DLE_DF_MAKE_INSTR_NO_INIT(189)",
    "DW_DLE_DF_NEW_LOC_LESS_OLD_LOC(190)",
    "DW_DLE_DF_POP_EMPTY_STACK(191)",
    "DW_DLE_DF_ALLOC_FAIL(192)",
    "DW_DLE_DF_FRAME_DECODING_ERROR(193)",
    "DW_DLE_DEBUG_LOC_SECTION_SHORT(194)",
    "DW_DLE_FRAME_AUGMENTATION_UNKNOWN(195)",
    "DW_DLE_PUBTYPE_CONTEXT(196)",
    "DW_DLE_DEBUG_PUBTYPES_LENGTH_BAD(197)",
    "DW_DLE_DEBUG_PUBTYPES_VERSION_ERROR(198)",
    "DW_DLE_DEBUG_PUBTYPES_DUPLICATE(199)",
    "DW_DLE_FRAME_CIE_DECODE_ERROR(200)",
    "DW_DLE_FRAME_REGISTER_UNREPRESENTABLE(201)",
    "DW_DLE_FRAME_REGISTER_COUNT_MISMATCH(202)",
    "DW_DLE_LINK_LOOP(203)",
    "DW_DLE_STRP_OFFSET_BAD(204)",
    "DW_DLE_DEBUG_RANGES_DUPLICATE(205)",
    "DW_DLE_DEBUG_RANGES_OFFSET_BAD(206)",
    "DW_DLE_DEBUG_RANGES_MISSING_END(207)",
    "DW_DLE_DEBUG_RANGES_OUT_OF_MEM(208)",
    "DW_DLE_DEBUG_SYMTAB_ERR(209)",
    "DW_DLE_DEBUG_STRTAB_ERR(210)",
    "DW_DLE_RELOC_MISMATCH_INDEX(211)",
    "DW_DLE_RELOC_MISMATCH_RELOC_INDEX(212)",
    "DW_DLE_RELOC_MISMATCH_STRTAB_INDEX(213)",
    "DW_DLE_RELOC_SECTION_MISMATCH(214)",
    "DW_DLE_RELOC_SECTION_MISSING_INDEX(215)",
    "DW_DLE_RELOC_SECTION_LENGTH_ODD(216)",
    "DW_DLE_RELOC_SECTION_PTR_NULL(217)",
    "DW_DLE_RELOC_SECTION_MALLOC_FAIL(218)",
    "DW_DLE_NO_ELF64_SUPPORT(219)",
    "DW_DLE_MISSING_ELF64_SUPPORT(220)",
    "DW_DLE_ORPHAN_FDE(221)",
    "DW_DLE_DUPLICATE_INST_BLOCK(222)",
    "DW_DLE_BAD_REF_SIG8_FORM(223)",
    "DW_DLE_ATTR_EXPRLOC_FORM_BAD(224)",
    "DW_DLE_FORM_SEC_OFFSET_LENGTH_BAD(225)",
    "DW_DLE_NOT_REF_FORM(226)",
    "DW_DLE_DEBUG_FRAME_LENGTH_NOT_MULTIPLE(227)",
    "DW_DLE_REF_SIG8_NOT_HANDLED (228)",
    "DW_DLE_DEBUG_FRAME_POSSIBLE_ADDRESS_BOTCH (229)",
    "DW_DLE_LOC_BAD_TERMINATION (230) the last location operator in an expression is missing some associated data, an operator ended too soon",
    "DW_DLE_SYMTAB_SECTION_LENGTH_ODD (231) so doing relocations seems unsafe",
    "DW_DLE_RELOC_SECTION_SYMBOL_INDEX_BAD (232) so doing a relocation seems unsafe",
    "DW_DLE_RELOC_SECTION_RELOC_TARGET_SIZE_UNKNOWN (233) so doing a relocation is unsafe",
    "DW_DLE_SYMTAB_SECTION_ENTRYSIZE_ZERO(234)",
    "DW_DLE_LINE_NUMBER_HEADER_ERROR (235), a line number program header seems incomplete (perhaps the header_length is wrong?).",
    "DW_DLE_DEBUG_TYPES_NULL (236)",
    "DW_DLE_DEBUG_TYPES_DUPLICATE (237)",
    "DW_DLE_DEBUG_TYPES_ONLY_DWARF4 (238) DW4 and DW5 have types CUs",
    "DW_DLE_DEBUG_TYPEOFFSET_BAD (239)",
    "DW_DLE_GNU_OPCODE_ERROR (240)",
    "DW_DLE_DEBUGPUBTYPES_ERROR (241), could not create pubtypes section",
    "DW_DLE_AT_FIXUP_NULL (242)",
    "DW_DLE_AT_FIXUP_DUP (243)",
    "DW_DLE_BAD_ABINAME (244)",
    "DW_DLE_TOO_MANY_DEBUG(245), too many .debug_* sections present somehow",
    "DW_DLE_DEBUG_STR_OFFSETS_DUPLICATE(246)",
    "DW_DLE_SECTION_DUPLICATION(247)",
    "DW_DLE_SECTION_ERROR(248)",
    "DW_DLE_DEBUG_ADDR_DUPLICATE(249)",
    "DW_DLE_DEBUG_CU_UNAVAILABLE_FOR_FORM(250)",
    "DW_DLE_DEBUG_FORM_HANDLING_INCOMPLETE(251)",
    "DW_DLE_NEXT_DIE_PAST_END(252)",
    "DW_DLE_NEXT_DIE_WRONG_FORM(253)",
    "DW_DLE_NEXT_DIE_NO_ABBREV_LIST(254)",
    "DW_DLE_NESTED_FORM_INDIRECT_ERROR(255)",
    "DW_DLE_CU_DIE_NO_ABBREV_LIST(256)",
    "DW_DLE_MISSING_NEEDED_DEBUG_ADDR_SECTION(257)",
    "DW_DLE_ATTR_FORM_NOT_ADDR_INDEX(258)",
    "DW_DLE_ATTR_FORM_NOT_STR_INDEX(259)",
    "DW_DLE_DUPLICATE_GDB_INDEX(260)",
    "DW_DLE_ERRONEOUS_GDB_INDEX_SECTION(261) The section is too small",
    "DW_DLE_GDB_INDEX_COUNT_ERROR(262)",
    "DW_DLE_GDB_INDEX_COUNT_ADDR_ERROR(263)",
    "DW_DLE_GDB_INDEX_CUVEC_ERROR(264)",
    "DW_DLE_GDB_INDEX_INDEX_ERROR(265)",
    "DW_DLE_DUPLICATE_CU_INDEX(266)",
    "DW_DLE_DUPLICATE_TU_INDEX(267)",
    "DW_DLE_XU_TYPE_ARG_ERROR(268) XU means dwarf_cu_ or tu_ index section",
    "DW_DLE_XU_IMPOSSIBLE_ERROR(269) XU means dwarf_cu_ or tu_ index section",
    "DW_DLE_XU_NAME_COL_ERROR(270) XU means dwarf_cu_ or tu_ index section",
    "DW_DLE_XU_HASH_ROW_ERROR(271) XU means dwarf_cu_ or tu_ index section",
    "DW_DLE_XU_HASH_INDEX_ERROR(272) XU means dwarf_cu_ or tu_ index section",
    "DW_DLE_FAILSAFE_ERRVAL(273)",
    "DW_DLE_ARANGE_ERROR(274) producer problem in object generation",
    "DW_DLE_PUBNAMES_ERROR(275) producer problem in object generation",
    "DW_DLE_FUNCNAMES_ERROR(276) producer problem in object generation",
    "DW_DLE_TYPENAMES_ERROR(277) producer problem in object generation",
    "DW_DLE_VARNAMES_ERROR(278) producer problem in object generation",
    "DW_DLE_WEAKNAMES_ERROR(279) producer problem in object generation",
    "DW_DLE_RELOCS_ERROR(280) producer problem in object generation",
    "DW_DLE_DW_DLE_ATTR_OUTSIDE_SECTION(281)",
    "DW_DLE_FISSION_INDEX_WRONG(282)",
    "DW_DLE_FISSION_VERSION_ERROR(283)",
    "DW_DLE_NEXT_DIE_LOW_ERROR(284) corrupted DIE tree",
    "DW_DLE_CU_UT_TYPE_ERROR(285) not a valid DW_UT_* value",
    "DW_DLE_NO_SUCH_SIGNATURE_FOUND(286) CU signature not in the index",
    "DW_DLE_SIGNATURE_SECTION_NUMBER_WRONG(287) libdwarf software error",
    "DW_DLE_ATTR_FORM_NOT_DATA8(288) wanted an 8 byte signature",
    "DW_DLE_SIG_TYPE_WRONG_STRING (289) expected tu or cu",
    "DW_DLE_MISSING_REQUIRED_TU_OFFSET_HASH(290) is a broken dwp package file",
    "DW_DLE_MISSING_REQUIRED_CU_OFFSET_HASH(291) is a broken dwp package file",
    "DW_DLE_DWP_MISSING_DWO_ID(292)",
    "DW_DLE_DWP_SIBLING_ERROR(293)",
    "DW_DLE_DEBUG_FISSION_INCOMPLETE(294)",
    "DW_DLE_FISSION_SECNUM_ERR(295) internal libdwarf error",
    "DW_DLE_DEBUG_MACRO_DUPLICATE(296)",
    "DW_DLE_DEBUG_NAMES_DUPLICATE(297)",
    "DW_DLE_DEBUG_LINE_STR_DUPLICATE(298)",
    "DW_DLE_DEBUG_SUP_DUPLICATE(299)",
    "DW_DLE_NO_SIGNATURE_TO_LOOKUP(300)",
    "DW_DLE_NO_TIED_ADDR_AVAILABLE(301)",
    "DW_DLE_NO_TIED_SIG_AVAILABLE(302)",
    "DW_DLE_STRING_NOT_TERMINATED(303) section data may be corrupted",
    "DW_DLE_BAD_LINE_TABLE_OPERATION(304) two-level line table botch",
    "DW_DLE_LINE_CONTEXT_BOTCH(305) call is wrong or memory corruption",
    "DW_DLE_LINE_CONTEXT_INDEX_WRONG(306)",
    "DW_DLE_NO_TIED_STRING_AVAILABLE(307) tied file does not have the string",
    "DW_DLE_NO_TIED_FILE_AVAILABLE(308) see dwarf_set_tied_dbg()",
    "DW_DLE_CU_TYPE_MISSING(309) libdwarf bug or data corruption",
    "DW_DLE_LLE_CODE_UNKNOWN (310) libdwarf bug or data corruption",
    "DW_DLE_LOCLIST_INTERFACE_ERROR (311) interface cannot do location or DW_OP*",
    "DW_DLE_LOCLIST_INDEX_ERROR (312)",
    "DW_DLE_INTERFACE_NOT_SUPPORTED (313)",
    "DW_DLE_ZDEBUG_REQUIRES_ZLIB (314) Unable to decompress .zdebug as zlib missing",
    "DW_DLE_ZDEBUG_INPUT_FORMAT_ODD(315)",
    "DW_DLE_ZLIB_BUF_ERROR (316) Z_BUF_ERROR buffer size small",
    "DW_DLE_ZLIB_DATA_ERROR (317) Z_DATA_ERROR compressed data corrupted",
    "DW_DLE_MACRO_OFFSET_BAD (318)",
    "DW_DLE_MACRO_OPCODE_BAD (319)",
    "DW_DLE_MACRO_OPCODE_FORM_BAD (320)",
    "DW_DLE_UNKNOWN_FORM (321) Possibly corrupt DWARF data",
    "DW_DLE_BAD_MACRO_HEADER_POINTER(322)",
    "DW_DLE_BAD_MACRO_INDEX(323)",
    "DW_DLE_MACRO_OP_UNHANDLED(324) Possibly an implementation extension",
    "DW_DLE_MACRO_PAST_END(325)",
    "DW_DLE_LINE_STRP_OFFSET_BAD(326)",
    "DW_DLE_STRING_FORM_IMPROPER(327) An internal libdwarf logic error",
    "DW_DLE_ELF_FLAGS_NOT_AVAILABLE(328) elf/non-elf object confusion?",
    "DW_DLE_LEB_IMPROPER (329) Runs off end of section or CU",
    "DW_DLE_DEBUG_LINE_RANGE_ZERO (330) Corrupted line section",
    "DW_DLE_READ_LITTLEENDIAN_ERROR (331) Corrupted dwarfdata littleendian host",
    "DW_DLE_READ_BIGENDIAN_ERROR (332) Corrupted dwarf data bigendian host",
    "DW_DLE_RELOC_INVALID (333) relocation corruption",
    "DW_DLE_INFO_HEADER_ERROR(334) Corrupt dwarf",
    "DW_DLE_ARANGES_HEADER_ERROR(335) Corrupt dwarf",
    "DW_DLE_LINE_OFFSET_WRONG_FORM(336) Corrupt dwarf",
    "DW_DLE_FORM_BLOCK_LENGTH_ERROR(337) Corrupt dwarf",
    "DW_DLE_ZLIB_SECTION_SHORT (338) Corrupt dwarf",
    "DW_DLE_CIE_INSTR_PTR_ERROR (339)",
    "DW_DLE_FDE_INSTR_PTR_ERROR (340)",
    "DW_DLE_FISSION_ADDITION_ERROR (341) Corrupt dwarf",
    "DW_DLE_HEADER_LEN_BIGGER_THAN_SECSIZE (342) Corrupt dwarf",
    "DW_DLE_LOCEXPR_OFF_SECTION_END (343) Corrupt dwarf",
    "DW_DLE_POINTER_SECTION_UNKNOWN (344)",
    "DW_DLE_ERRONEOUS_XU_INDEX_SECTION(345) XU means cu_ or tu_ index",
    "DW_DLE_DIRECTORY_FORMAT_COUNT_VS_DIRECTORIES_MISMATCH(346) Inconsistent line table, corrupted.",
    "DW_DLE_COMPRESSED_EMPTY_SECTION(347) corrupt section data",
    "DW_DLE_SIZE_WRAPAROUND(348) Impossible string length",
    "DW_DLE_ILLOGICAL_TSEARCH(349) Impossible sitauation. Corrupted data?",
    "DW_DLE_BAD_STRING_FORM(350) Not a currently allowed form",
    "DW_DLE_DEBUGSTR_ERROR(351) problem generating .debug_str section",
    "DW_DLE_DEBUGSTR_UNEXPECTED_REL(352) string relocation will be wrong.",
    "DW_DLE_DISCR_ARRAY_ERROR(353) Internal error in dwarf_discr_list()",
    "DW_DLE_LEB_OUT_ERROR(354) Insufficient buffer to turn integer to leb",
    "DW_DLE_SIBLING_LIST_IMPROPER(355) Corrupt dwarf",
    "DW_DLE_LOCLIST_OFFSET_BAD(356) Corrupt dwarf",
    "DW_DLE_LINE_TABLE_BAD(357) Corrupt line table",
    "DW_DLE_DEBUG_LOClISTS_DUPLICATE(358)",
    "DW_DLE_DEBUG_RNGLISTS_DUPLICATE(359)",
    "DW_DLE_ABBREV_OFF_END(360)",
    "DW_DLE_FORM_STRING_BAD_STRING(361) string runs off end of data",
    "DW_DLE_AUGMENTATION_STRING_OFF_END(362) augmenation runs off of its section",
    "DW_DLE_STRING_OFF_END_PUBNAMES_LIKE(363) one of the global sections, string bad",
    "DW_DLE_LINE_STRING_BAD(364)  runs off end of line data",
    "DW_DLE_DEFINE_FILE_STRING_BAD(365) runs off end of section",
    "DW_DLE_MACRO_STRING_BAD(366) DWARF5 macro def/undef string runs off section data",
    "DW_DLE_MACINFO_STRING_BAD(367) DWARF2..4 macro def/undef string runs off section data",
    "DW_DLE_ZLIB_UNCOMPRESS_ERROR(368) Surely an invalid uncompress length",
};

#ifdef TESTING
#define FALSE 0
#define TRUE 1
/* This is just to help localize the error. */
static void
printone(int i)
{
    int arraysize = sizeof(_dwarf_errmsgs) / sizeof(char *);
    if ( i >= arraysize) {
        printf("%d is outside the array! Missing something!\n",i);
    } else {
        printf("%d is: %s\n",i,_dwarf_errmsgs[i]);
    }
}

/* Arbitrary. A much smaller max length value would work. */
#define MAX_NUM_LENGTH 12

/* return TRUE on error */
static int
check_errnum_mismatches(unsigned i)
{
    unsigned nextstop = 0;
    const char *sp = _dwarf_errmsgs[i];
    const char *cp = sp;
    unsigned innit = FALSE;
    unsigned prevchar = 0;
    unsigned value = 0;

    for( ; *cp; cp++) {
        unsigned c = 0;
        c = 0xff & *cp;
        if ( c >= '0' && c <= '9' && !innit
            && prevchar != '(') {
            /* Skip. number part of macro name. */
            prevchar = c;
            continue;
        }
        if ( c >= '0' && c <= '9') {
            value = value * 10;
            value += (c - '0');
            nextstop++;
            if (nextstop > MAX_NUM_LENGTH) {
                break;
            }
            innit = TRUE;
        } else {
            if (innit) {
                break;
            }
            prevchar= c;
        }
    }
    if (innit) {
        if (i != value) {
            return TRUE;
        }
        return FALSE;
    }
    /* There is no number to check. Ignore it. */
    printf("mismatch value %d has no errnum to check %s\n",i,_dwarf_errmsgs[i]);
    return TRUE;
}

/* We don't allow arbitrary DW_DLE line length. */
#define MAXDEFINELINE 200

static int
splmatches(char *base, unsigned baselen,char *test)
{
    if (baselen != strlen(test) ) {
        return FALSE;
    }
    for ( ; *test; ++test,++base) {
        if (*test != *base) {
            return FALSE;
        }
    }
    return TRUE;
}

static void
check_dle_list(const char *path)
{
    /*  The format should be
        #define<space>name<spaces>number<spaces>optional-c-comment
        and we are intentionally quite rigid about it all except
        that the number of spaces before any comment is allowed. */
    char buffer[MAXDEFINELINE];
    unsigned linenum = 0;
    unsigned long prevdefval = 0;
    unsigned foundlast = 0;
    unsigned foundlouser = 0;
    FILE*fin = 0;

    fin = fopen(path, "r");
    if(!fin) {
        printf("Unable to open define list %s\n",path);
        exit(1);
    }
    for(;;++linenum) {
        char *line = 0;
        unsigned linelen = 0;
        char *  curdefname = 0;
        char *  pastname = 0;
        unsigned curdefname_len = 0;
        char *numstart = 0;
        char * endptr = 0;
        unsigned long v = 0;

        line = fgets(buffer,MAXDEFINELINE,fin);
        if(!line) {
            break;
        }
        linelen = strlen(line);
        if (linelen >= (unsigned)(MAXDEFINELINE-1)) {
            printf("define line %u is too long!\n",linenum);
            exit(1);
        }
        if(strncmp(line,"#define DW_DLE_",15)) {
            printf("define line %u has wrong leading chars!\n",linenum);
            exit(1);
        }
        curdefname = line+8;
        /* ASSERT: line ends with NUL byte. */
        for( ; ; curdefname_len++) {
            if (foundlouser) {
                printf("define line %u has  stuff after DW_DLE_LO_USER!\n",
                    linenum);
                exit(1);
            }
            pastname = curdefname +curdefname_len;
            if (!*pastname) {
                /* At end of line. Missing value. */
                printf("define line %u has no number value!\n",linenum);
                exit(1);
            }
            if (*pastname == ' ') {
                /* Ok. Now look for value. */
                numstart = pastname + 1;
                break;
            }
        }
        /* strtoul skips leading whitespace. */
        v = strtoul(numstart,&endptr,0);
        /*  This test is a bit odd. But is valid till
            we decide it is inappropriate. */
        if (v > DW_DLE_LO_USER) {
            printf("define line %u: number value unreasonable. %lu\n",
                linenum,v);
            exit(1);
        }
        if (v == 0 && endptr == numstart) {
            printf("define line %u: number value missing.\n",
                linenum);
            exit(1);
        }
        if (*endptr != ' ' && *endptr != '\n') {
            printf("define line %u: number value terminates oddly\n",
                linenum);
            exit(1);
        }
        if (splmatches(curdefname,curdefname_len,"DW_DLE_LAST")) {
            if (foundlast) {
                printf("duplicated DW_DLE_LAST! line %u\n",linenum);
                exit(1);
            }
            foundlast = 1;
            if (v != prevdefval) {
                printf("Invalid: Last value mismatch! %lu vs %lu\n",
                    v,prevdefval);
            }
        } else if (splmatches(curdefname,curdefname_len,"DW_DLE_LO_USER")) {
            if (!foundlast) {
                printf("error:expected DW_DLE_LO_USER after LAST! line %u\n",
                    linenum);
                exit(1);
            }
            if (foundlouser) {
                printf("Error:duplicated DW_DLE_LO_USER! line %u\n",
                    linenum);
                exit(1);
            }
            foundlouser = 1;
            continue;
        } else {
            if (linenum > 0) {
                if (v != prevdefval+1) {
                    printf("Invalid: Missing value! %lu vs %lu\n",
                        prevdefval,v);
                    exit(1);
                }
            }
            prevdefval = v;
        }
        /* Ignoring rest of line for now. */
    }
    fclose(fin);
}

int
main(int argc, char **argv)
{
    unsigned arraysize = sizeof(_dwarf_errmsgs) / sizeof(char *);
    unsigned i = 0;
    const char *path = 0;

    if (argc != 3) {
        printf("Expected -f <filename> of DW_DLE lines from libdwarf.h");
        exit(1);
    }
    if (strcmp(argv[1],"-f")) {
        printf("Expected -f");
        exit(1);
    }
    path = argv[2];
    check_dle_list(path);


    if (arraysize != (DW_DLE_LAST + 1)) {
        printf("Missing or extra entry in dwarf error strings array"
            " %u expected DW_DLE_LAST+1 %d\n",arraysize, DW_DLE_LAST+1);
        printone(1);
        printone(100);
        printone(200);
        printone(250);
        printone(260);
        printone(262);
        printone(263);
        printone(264);
        printone(265);
        printone(273);
        printone(274);
        printone(275);
        printone(300);
        printone(328);
        exit(1);
    }
    for ( i = 0; i <= DW_DLE_LAST; ++i) {
        if(check_errnum_mismatches(i)) {
            printf("mismatch value %d is: %s\n",i,_dwarf_errmsgs[i]);
            exit(1);
        }
    }
    /* OK. */
    exit(0);
}
#endif /* TESTING */