File: print_lines.c

package info (click to toggle)
dwarfutils 20210528-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,924 kB
  • sloc: ansic: 110,023; sh: 5,663; cpp: 4,809; makefile: 654; python: 639; awk: 11
file content (1228 lines) | stat: -rw-r--r-- 45,674 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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
/*
Copyright (C) 2000-2006 Silicon Graphics, Inc.  All Rights Reserved.
Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
Portions Copyright 2009-2018 SN Systems Ltd. All rights reserved.
Portions Copyright 2008-2020 David Anderson. All rights reserved.
Portions Copyright 2015-2015 Google, Inc. All Rights Reserved

  This program is free software; you can redistribute it and/or
  modify it under the terms of version 2 of the GNU 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 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.
*/

#include "globals.h"
#include "naming.h"
#include "esb.h"
#include "esb_using_functions.h"
#include "sanitized.h"
#include "uri.h"
#include <ctype.h>
#include <time.h>

#include "print_sections.h"

/*
    Print line number information:
        [line] [address] <new statement>
        new basic-block
        filename
*/

#define DW_LINE_VERSION5 5


static void
print_source_intro(Dwarf_Debug dbg,Dwarf_Die cu_die)
{
    int         ores = 0;
    Dwarf_Off   off = 0;
    Dwarf_Error src_err = 0;

    ores = dwarf_dieoffset(cu_die, &off, &src_err);
    if (ores == DW_DLV_OK) {
        int lres = 0;
        const char *sec_name = 0;

        lres = dwarf_get_die_section_name_b(cu_die,
            &sec_name,&src_err);
        if (lres != DW_DLV_OK ||  !sec_name || !strlen(sec_name)) {
            sec_name = ".debug_info";
        }
        printf("Source lines (from CU-DIE at %s offset 0x%"
            DW_PR_XZEROS DW_PR_DUx "):\n",
            sec_name,
            (Dwarf_Unsigned) off);
        DROP_ERROR_INSTANCE(dbg,lres,src_err);
    } else {
        DROP_ERROR_INSTANCE(dbg,ores,src_err);
        printf("Source lines (for the CU-DIE at unknown"
            " location):\n");
    }
}

static void
record_line_error(const char *where, Dwarf_Error line_err)
{
    if (glflags.gf_check_lines && checking_this_compiler()) {
        struct esb_s  tmp_buff;
        char buftmp[ESB_FIXED_ALLOC_SIZE];

        esb_constructor_fixed(&tmp_buff,buftmp,sizeof(buftmp));
        esb_append_printf_s(&tmp_buff,
            "Error getting line details calling %s",
            where);
        esb_append_printf_s(&tmp_buff,
            " dwarf error is %s",
            dwarf_errmsg(line_err));
        DWARF_CHECK_ERROR(lines_result,esb_get_string(&tmp_buff));
        esb_destructor(&tmp_buff);
    }
}

static int
process_line_table(Dwarf_Debug dbg,
    const char *sec_name,
    Dwarf_Line *linebuf, Dwarf_Signed linecount,
    Dwarf_Bool is_logicals_table, Dwarf_Bool is_actuals_table,
    Dwarf_Error *lt_err)
{
    char *padding = 0;
    Dwarf_Signed i = 0;
    Dwarf_Addr pc = 0;
    Dwarf_Unsigned lineno = 0;
    Dwarf_Unsigned logicalno = 0;
    Dwarf_Unsigned column = 0;
    Dwarf_Unsigned call_context = 0;
    char* subprog_name = 0;
    char* subprog_filename = 0;
    Dwarf_Unsigned subprog_line = 0;

    Dwarf_Bool newstatement = 0;
    Dwarf_Bool lineendsequence = 0;
    Dwarf_Bool new_basic_block = 0;
    int sres = 0;
    int ares = 0;
    int lires = 0;
    int cores = 0;
    char lastsrc_tmp[ESB_FIXED_ALLOC_SIZE];
    struct esb_s lastsrc;
    Dwarf_Addr elf_max_address = 0;
    Dwarf_Bool SkipRecord = FALSE;

    esb_constructor_fixed(&lastsrc,lastsrc_tmp,sizeof(lastsrc_tmp));
    glflags.current_section_id = DEBUG_LINE;
    /* line_flag is TRUE */
    get_address_size_and_max(dbg,0,&elf_max_address,lt_err);
    /* Padding for a nice layout */
    padding = glflags.gf_line_print_pc ? "            " : "";
    if (glflags.gf_do_print_dwarf) {
        /* Check if print of <pc> address is needed. */
        printf("\n");
        if (is_logicals_table) {
            printf("Logicals Table:\n");
            printf("%sNS new statement, PE prologue end, "
                "EB epilogue begin\n",padding);
            printf("%sDI=val discriminator value\n",
                padding);
            printf("%sCC=val context, SB=val subprogram\n",
                padding);
        } else if (is_actuals_table) {
            printf("Actuals Table:\n");
            printf("%sBB new basic block, ET end of text sequence\n"
                "%sIS=val ISA number\n",padding,padding);

        } else {
            /* Standard DWARF line table. */
            printf("%sNS new statement, BB new basic block, "
                "ET end of text sequence\n",padding);
            printf("%sPE prologue end, EB epilogue begin\n",padding);
            printf("%sIS=val ISA number, "
                "DI=val discriminator value\n",
                padding);
        }
        if (is_logicals_table || is_actuals_table) {
            printf("[ row]  ");
        }
        if (glflags.gf_line_print_pc) {
            printf("<pc>        ");
        }
        if (is_logicals_table) {
            printf("[lno,col] NS PE EB DI= CC= SB= uri:"
                " \"filepath\"\n");
        } else if (is_actuals_table) {
            printf("[logical] BB ET IS=\n");
        } else {
            printf("[lno,col] NS BB ET PE EB IS= DI= uri:"
                " \"filepath\"\n");
        }
    }
    for (i = 0; i < linecount; i++) {
        Dwarf_Line line = linebuf[i];
        char* lsrc_filename = 0;
        int nsres = 0;
        Dwarf_Bool found_line_error = FALSE;
        Dwarf_Bool has_is_addr_set = FALSE;
        char *where = NULL;

        if (glflags.gf_check_decl_file && checking_this_compiler()) {
            /* A line record with addr=0 was detected */
            if (SkipRecord) {
                /* Skip records that do not have is_addr_set */
                ares = dwarf_line_is_addr_set(line,
                    &has_is_addr_set, lt_err);
                if (ares == DW_DLV_OK && has_is_addr_set) {
                    SkipRecord = FALSE;
                }
                else {
                    /*  Keep ignoring records until we have
                        one with 'is_addr_set' */
                    continue;
                }
            }
        }

        if (glflags.gf_check_lines && checking_this_compiler()) {
            DWARF_CHECK_COUNT(lines_result,1);
        }

        /*  NO. lsrc_filename is a DW_DLA_STRING, do not assign
            a static string.
            lsrc_filename = "<unknown>";
        */
        if (!is_actuals_table) {
            Dwarf_Error aterr = 0;

            sres = dwarf_linesrc(line, &lsrc_filename, &aterr);
            if (sres == DW_DLV_ERROR) {
                /* Do not terminate processing */
                where = "dwarf_linesrc()";
                record_line_error(where,aterr);
                found_line_error = TRUE;
                DROP_ERROR_INSTANCE(dbg,sres,aterr);
            }
        }

        pc = 0;
        ares = dwarf_lineaddr(line, &pc, lt_err);

        if (ares == DW_DLV_ERROR) {
            /* Do not terminate processing */
            where = "dwarf_lineaddr()";
            record_line_error(where,*lt_err);
            found_line_error = TRUE;
            pc = 0;
            DROP_ERROR_INSTANCE(dbg,ares,*lt_err);
        }
        if (ares == DW_DLV_NO_ENTRY) {
            pc = 0;
        }

        if (is_actuals_table) {
            lires = dwarf_linelogical(line, &logicalno, lt_err);
            if (lires == DW_DLV_ERROR) {
                /* Do not terminate processing */
                where = "dwarf_linelogical()";
                record_line_error(where,*lt_err);
                found_line_error = TRUE;
                DROP_ERROR_INSTANCE(dbg,lires,*lt_err);
            }
            if (lires == DW_DLV_NO_ENTRY) {
                logicalno = 0;
            }
            column = 0;
        } else {
            lires = dwarf_lineno(line, &lineno, lt_err);
            if (lires == DW_DLV_ERROR) {
                /* Do not terminate processing */
                where = "dwarf_lineno()";
                record_line_error(where,*lt_err);
                found_line_error = TRUE;
                DROP_ERROR_INSTANCE(dbg,lires,*lt_err);
            }
            if (lires == DW_DLV_NO_ENTRY) {
                lineno = 0;
            }
            cores = dwarf_lineoff_b(line, &column, lt_err);
            if (cores == DW_DLV_ERROR) {
                /* Do not terminate processing */
                where = "dwarf_lineoff()";
                record_line_error(where,*lt_err);
                found_line_error = TRUE;
                DROP_ERROR_INSTANCE(dbg,cores,*lt_err);
            }
            if (cores == DW_DLV_NO_ENTRY) {
                /*  Zero was always the correct default, meaning
                    the left edge. DWARF2/3/4 spec sec 6.2.2 */
                column = 0;
            }
        }

        /*  Process any possible error condition, though
            we won't be at the first such error. */
        if (glflags.gf_check_decl_file && checking_this_compiler()) {
            DWARF_CHECK_COUNT(decl_file_result,1);
            if (found_line_error) {
                DWARF_CHECK_ERROR2(decl_file_result,where,
                    dwarf_errmsg(*lt_err));
            } else if (glflags.gf_do_check_dwarf) {
                /*  Check the address lies with a valid [lowPC:highPC]
                    in the .text section*/
                if (IsValidInBucketGroup(glflags.pRangesInfo,pc)) {
                    /* Valid values; do nothing */
                } else {
                    /*  At this point may be we are dealing with
                        a linkonce symbol. The problem we have here
                        is we have consumed the deug_info section
                        and we are dealing just with the records
                        from the .debug_line, so no PU_name is
                        available and no high_pc.
                        Traverse the linkonce table if try to
                        match the pc value with one of those ranges.
                    */
                    if (glflags.gf_check_lines &&
                        checking_this_compiler()) {
                        DWARF_CHECK_COUNT(lines_result,1);
                    }
                    if (FindAddressInBucketGroup(
                        glflags.pLinkonceInfo,pc)){
                        /* Valid values; do nothing */
                    } else {
                        /*  The SN Systems Linker generates
                            line records
                            with addr=0, when dealing with linkonce
                            symbols and no stripping */
                        if (pc) {
                            if (glflags.gf_check_lines &&
                                checking_this_compiler()) {
                                char abuf[50];
                                struct esb_s atm;

                                esb_constructor_fixed(&atm,
                                    abuf,sizeof(abuf));
                                esb_append_printf_s(&atm,
                                    "%s: Address",
                                    sanitized(sec_name));
                                esb_append_printf_u(&atm,
                                    " 0x%" DW_PR_XZEROS DW_PR_DUx
                                    " outside a valid .text range",
                                    pc);
                                DWARF_CHECK_ERROR(lines_result,
                                    esb_get_string(&atm));
                                esb_destructor(&atm);
                            }
                        } else {
                            SkipRecord = TRUE;
                        }
                    }
                }
                /*  Check the last record for the .debug_line,
                    the one created by DW_LNE_end_sequence,
                    is the same as the high_pc
                    address for the last known user program
                    unit (PU).
                    There is no real reason */
                if ((i + 1 == linecount) &&
                    glflags.seen_PU_high_address &&
                    !is_logicals_table) {
                    /*  Ignore those PU that have been stripped
                        by the linker; their low_pc values are
                        set to -1 (snc linker only) */
                    /*  It is perfectly sensible for a compiler
                        to leave a few bytes of NOP or other stuff
                        after the last instruction in a subprogram,
                        for cache-alignment or other purposes, so
                        a mismatch here is not necessarily
                        an error.  */

                    if (glflags.gf_check_lines &&
                        checking_this_compiler()) {
                        DWARF_CHECK_COUNT(lines_result,1);
                        if ((pc != glflags.PU_high_address) &&
                            (glflags.PU_base_address !=
                            elf_max_address)) {
                            char addr_tmp[140];
                            struct esb_s cm;

                            esb_constructor_fixed(&cm,addr_tmp,
                                sizeof(addr_tmp));
                            esb_append_printf_s(&cm,
                                "%s: Address",sanitized(sec_name));
                            esb_append_printf_u(&cm,
                                " 0x%" DW_PR_XZEROS DW_PR_DUx
                                " DW_LNE_end_sequence address"
                                " does not exactly match",pc);
                            esb_append_printf_u(&cm,
                                " high function addr: "
                                " 0x%" DW_PR_XZEROS DW_PR_DUx,
                                glflags.PU_high_address);
                            DWARF_CHECK_ERROR(lines_result,
                                esb_get_string(&cm));
                            esb_destructor(&cm);
                        }
                    }
                }
            }
        }

        /* Display the error information */
        if (found_line_error || glflags.gf_record_dwarf_error) {
            if (glflags.gf_check_verbose_mode && PRINTING_UNIQUE) {
                /*  Print the record number for better
                    error description */
                printf("Record = %"  DW_PR_DUu
                    " Addr = 0x%" DW_PR_XZEROS DW_PR_DUx
                    " [%4" DW_PR_DUu ",%2" DW_PR_DUu "] '%s'\n",
                    i, pc,lineno,column,
                    lsrc_filename?sanitized(lsrc_filename):"");
                /* The compilation unit was already printed */
                if (!glflags.gf_check_decl_file) {
                    PRINT_CU_INFO();
                }
            }
            glflags.gf_record_dwarf_error = FALSE;
            /* Due to a fatal error, skip current record */
            if (found_line_error) {
                dwarf_dealloc(dbg, lsrc_filename, DW_DLA_STRING);
                lsrc_filename = 0;
                continue;
            }
        }
        if (glflags.gf_do_print_dwarf) {
            if (is_logicals_table || is_actuals_table) {
                printf("[%4" DW_PR_DUu "]  ", i + 1);
            }
            /* Check if print of <pc> address is needed. */
            if (glflags.gf_line_print_pc) {
                printf("0x%" DW_PR_XZEROS DW_PR_DUx "  ", pc);
            }
            if (is_actuals_table) {
                printf("[%7" DW_PR_DUu "]", logicalno);
            } else {
                printf("[%4" DW_PR_DUu ",%2" DW_PR_DUu "]",
                    lineno, column);
            }
        }

        if (!is_actuals_table) {
            nsres = dwarf_linebeginstatement(line,
                &newstatement, lt_err);
            if (nsres == DW_DLV_OK) {
                if (newstatement && glflags.gf_do_print_dwarf) {
                    printf(" %s","NS");
                }
            } else if (nsres == DW_DLV_ERROR) {
                struct esb_s m;
                esb_constructor(&m);
                esb_append_printf_u(&m,
                    "\nERROR: dwarf_linebeginstatement failed"
                    " on linebuf index %u ",i);
                esb_append_printf_u(&m,
                    "of %u line records in the linebuf.",
                    linecount);
                simple_err_return_action(nsres,
                    esb_get_string(&m));
                esb_destructor(&m);
                dwarf_dealloc(dbg, lsrc_filename, DW_DLA_STRING);
                lsrc_filename = 0;
                return nsres;
            }
        }

        if (!is_logicals_table) {
            nsres = dwarf_lineblock(line,
                &new_basic_block, lt_err);
            if (nsres == DW_DLV_OK) {
                if (new_basic_block && glflags.gf_do_print_dwarf) {
                    printf(" %s","BB");
                }
            } else if (nsres == DW_DLV_ERROR) {
                struct esb_s m;
                esb_constructor(&m);
                esb_append_printf_u(&m,
                    "\nERROR: dwarf_lineblock failed"
                    " on linebuf index %u ",i);
                esb_append_printf_u(&m,
                    "of %u line records in the linebuf.",
                    linecount);
                simple_err_return_action(nsres,
                    esb_get_string(&m));
                esb_destructor(&m);
                dwarf_dealloc(dbg, lsrc_filename, DW_DLA_STRING);
                lsrc_filename = 0;
                return nsres;
            }
            nsres = dwarf_lineendsequence(line,
                &lineendsequence, lt_err);
            if (nsres == DW_DLV_OK) {
                if (lineendsequence &&
                    glflags.gf_do_print_dwarf) {
                    printf(" %s", "ET");
                }
            } else if (nsres == DW_DLV_ERROR) {
                struct esb_s m;
                esb_constructor(&m);
                esb_append_printf_u(&m,
                    "\nERROR: dwarf_lineendsequence failed"
                    " on linebuf index %u ",i);
                esb_append_printf_u(&m,
                    "of %u line records in the linebuf.",
                    linecount);
                simple_err_return_action(nsres,
                    esb_get_string(&m));
                esb_destructor(&m);
                dwarf_dealloc(dbg, lsrc_filename, DW_DLA_STRING);
                lsrc_filename = 0;
                return nsres;
            }
        }

        if (glflags.gf_do_print_dwarf) {
            Dwarf_Bool prologue_end = 0;
            Dwarf_Bool epilogue_begin = 0;
            Dwarf_Unsigned isa = 0;
            Dwarf_Unsigned discriminator = 0;
            int disres = dwarf_prologue_end_etc(line,
                &prologue_end,&epilogue_begin,
                &isa,&discriminator,lt_err);
            if (disres == DW_DLV_ERROR) {
                struct esb_s m;
                esb_constructor(&m);
                esb_append_printf_u(&m,
                    "\nERROR: dwarf_prologue_end_etc() failed"
                    " on linebuf index %u ",i);
                esb_append_printf_u(&m,
                    "of %u line records in the linebuf.",
                    linecount);
                simple_err_return_action(nsres,
                    esb_get_string(&m));
                esb_destructor(&m);
                dwarf_dealloc(dbg, lsrc_filename, DW_DLA_STRING);
                lsrc_filename = 0;
                return disres;
            }
            if (prologue_end && !is_actuals_table) {
                printf(" PE");
            }
            if (epilogue_begin && !is_actuals_table) {
                printf(" EB");
            }
            if (isa && !is_logicals_table) {
                printf(" IS=0x%" DW_PR_DUx, isa);
            }
            if (discriminator && !is_actuals_table) {
                printf(" DI=0x%" DW_PR_DUx, discriminator);
            }
            if (is_logicals_table) {
                call_context = 0;
                disres = dwarf_linecontext(line,
                    &call_context, lt_err);
                if (disres == DW_DLV_ERROR) {
                    struct esb_s m;
                    esb_constructor(&m);
                    esb_append_printf_u(&m,
                        "\nERROR: dwarf_linecontext() failed"
                        " on linebuf index %u ",i);
                    esb_append_printf_u(&m,
                        "of %u line records in the linebuf.",
                        linecount);
                        simple_err_return_action(nsres,
                        esb_get_string(&m));
                    esb_destructor(&m);
                    dwarf_dealloc(dbg, lsrc_filename, DW_DLA_STRING);
                    lsrc_filename = 0;
                    return disres;
                }
                if (call_context) {
                    printf(" CC=%" DW_PR_DUu, call_context);
                }
                subprog_name = 0;
                disres = dwarf_line_subprog(line,
                    &subprog_name,
                    &subprog_filename,
                    &subprog_line, lt_err);
                if (disres == DW_DLV_ERROR) {
                    struct esb_s m;
                    esb_constructor(&m);
                    esb_append_printf_u(&m,
                        "\nERROR: dwarf_line_subprog() failed"
                        " on linebuf index %u ",i);
                    esb_append_printf_u(&m,
                        "of %u line records in the linebuf.",
                        linecount);
                    simple_err_return_action(nsres,
                        esb_get_string(&m));
                    esb_destructor(&m);
                    dwarf_dealloc(dbg, lsrc_filename, DW_DLA_STRING);
                    lsrc_filename = 0;
                    return disres;
                }
                if (subprog_name && strlen(subprog_name)) {
                    /*  We do not print an empty name.
                        Clutters things up. */
                    printf(" SB=\"%s\"", sanitized(subprog_name));
                }
                dwarf_dealloc(dbg,subprog_filename, DW_DLA_STRING);
                subprog_filename = 0;
            }
        }

        if (!is_actuals_table) {
            if (i == 0  ||  glflags.verbose > 2 ||
                strcmp(lsrc_filename?lsrc_filename:"",
                    esb_get_string(&lastsrc))) {
                struct esb_s urs;
                char atmp2[ESB_FIXED_ALLOC_SIZE];

                esb_constructor_fixed(&urs,atmp2,sizeof(atmp2));
                esb_append(&urs, " uri: \"");
                translate_to_uri(lsrc_filename?
                    lsrc_filename:"",
                    &urs);
                esb_append(&urs,"\"");
                if (glflags.gf_do_print_dwarf) {
                    printf("%s",esb_get_string(&urs));
                }
                esb_destructor(&urs);
                esb_empty_string(&lastsrc);
                esb_append(&lastsrc,
                    lsrc_filename?lsrc_filename:"");
            } else {
                /*  Do not print name, it is the same
                    as the last name printed. */
            }
        }
        if (glflags.gf_do_print_dwarf) {
            printf("\n");
        }
        dwarf_dealloc(dbg,lsrc_filename, DW_DLA_STRING);
        lsrc_filename = 0;
    }
    esb_destructor(&lastsrc);
    return DW_DLV_OK;
}

/* Here we test the interfaces into Dwarf_Line_Context. */
static int
print_line_context_record(UNUSEDARG Dwarf_Debug dbg,
    Dwarf_Line_Context line_context,
    Dwarf_Error *err)
{
    int vres = 0;
    Dwarf_Unsigned lsecoff = 0;
    Dwarf_Unsigned version = 0;
    Dwarf_Signed dir_count = 0;
    Dwarf_Signed baseindex = 0;
    Dwarf_Signed file_count = 0;
    Dwarf_Signed endindex = 0;
    Dwarf_Signed i = 0;
    Dwarf_Signed subprog_count = 0;
    const char *name = 0;
    Dwarf_Small table_count = 0;
    struct esb_s bufr;
    int include_dir_base = 1; /* DWARF2.3,4 */
    int include_dir_limit = 0; /* set below */
    char bufr_tmp[ESB_FIXED_ALLOC_SIZE];

    esb_constructor_fixed(&bufr,bufr_tmp,sizeof(bufr_tmp));
    printf("Line Context data\n");
    vres = dwarf_srclines_table_offset(line_context,&lsecoff,
        err);
    if (vres != DW_DLV_OK) {
        simple_err_return_action(vres,
            "\nERROR: dwarf_srclines_table_offset() failed"
            ". Something broken");
        return vres;
    }
    printf(" Line Section Offset 0x%"
        DW_PR_XZEROS DW_PR_DUx "\n", lsecoff);
    vres = dwarf_srclines_version(line_context,&version,
        &table_count, err);
    if (vres != DW_DLV_OK) {
        simple_err_return_action(vres,
            "\nERROR: dwarf_srclines_version() failed"
            ". Something broken");
        return vres;
    }
    printf(" version number      0x%" DW_PR_DUx
        " %" DW_PR_DUu "\n",
        version,version);
    printf(" number of line tables  %d.\n", table_count);
    vres = dwarf_srclines_comp_dir(line_context,&name,err);
    if (vres != DW_DLV_OK) {
        simple_err_return_action(vres,
            "\nERROR: dwarf_srclines_comp_dir() failed"
            ". Something broken");
        return vres;
    }
    if (name) {
        printf(" Compilation directory: %s\n",name);
    } else {
        printf(" Compilation directory: <unknown"
            " no DW_AT_comp_dir>\n");
    }

    vres = dwarf_srclines_include_dir_count(line_context,
        &dir_count,err);
    if (vres != DW_DLV_OK) {
        simple_err_return_action(vres,
            "\nERROR: dwarf_srclines_comp_dir() failed"
            ". Something broken");
        return vres;
    }
    printf(" include directory count 0x%"
        DW_PR_DUx " %" DW_PR_DSd "\n",
        (Dwarf_Unsigned)dir_count,dir_count);
    if (version == DW_LINE_VERSION5) {
        include_dir_base = 0;
        include_dir_limit = dir_count;
    } else {
        include_dir_base = 1;
        include_dir_limit = dir_count+1;
    }
    for (i = include_dir_base; i < include_dir_limit; ++i) {
        vres = dwarf_srclines_include_dir_data(line_context,i,
            &name,err);
        if (vres != DW_DLV_OK) {
            struct esb_s m;

            esb_constructor(&m);
            esb_append_printf_i(&m,
                "\nERROR: Error accessing include directory "
                "  %d ",i);
            esb_append_printf_i(&m,
                "(max allowed index is %d).",dir_count);
            simple_err_return_action(vres,
                esb_get_string(&m));
            esb_destructor(&m);
            return vres;
        }
        printf("  [%2" DW_PR_DSd "]  \"%s\"\n",i,name);
    }

    vres = dwarf_srclines_files_indexes(line_context,
        &baseindex,&file_count,&endindex,err);
    if (vres != DW_DLV_OK) {
        simple_err_return_action(vres,
            "\nERROR: Error accessing files indexes");
        return vres;
    }
    printf( " files count 0x%"
        DW_PR_DUx " %" DW_PR_DUu "\n",
        file_count,file_count);
    /*  Set up so just one loop control needed
        for all versions of line tables. */
    for (i = baseindex; i < endindex; ++i) {
        Dwarf_Unsigned dirindex = 0;
        Dwarf_Unsigned modtime = 0;
        Dwarf_Unsigned flength = 0;
        Dwarf_Form_Data16 *md5data = 0;

        vres = dwarf_srclines_files_data_b(line_context,i,
            &name,&dirindex, &modtime,&flength,
            &md5data,err);
        if (vres != DW_DLV_OK) {
            struct esb_s m;

            esb_constructor(&m);
            esb_append_printf_i(&m,
                "\nERROR: Error accessing line_context "
                " calling  dwarf_srclines_files_data_b() "
                "with index %d ",i);
            esb_append_printf_i(&m,
                "(end index is %d).",endindex);
            simple_err_return_action(vres,
                esb_get_string(&m));
            esb_destructor(&m);
            return vres;
        }
        esb_empty_string(&bufr);
        if (name) {
            esb_empty_string(&bufr);
            esb_append(&bufr,"\"");
            esb_append(&bufr,name);
            esb_append(&bufr,"\"");
        } else {
            esb_append(&bufr,"<ERROR:NULL name in files list>");
        }
        printf("  [%2" DW_PR_DSd "]  %-24s ,",
            i,esb_get_string(&bufr));
        printf(" directory index  %2" DW_PR_DUu ,dirindex);
        printf(",  file length %2" DW_PR_DUu ,flength);
        if (md5data) {
            char *c = (char *)md5data;
            char *end = c+sizeof(*md5data);
            printf(", file md5 value 0x");
            while(c < end) {
                printf("%02x",0xff&*c);
                ++c;
            }
            printf(" ");
        }
        if (modtime) {
            time_t tt3 = (time_t)modtime;

            /* ctime supplies newline */
            printf(
                "file mod time 0x%x %s", (unsigned)tt3, ctime(&tt3));
        } else {
            printf("  file mod time 0\n");
        }
    }
    esb_destructor(&bufr);

    vres = dwarf_srclines_subprog_count(line_context,&subprog_count,
        err);
    if (vres != DW_DLV_OK) {
        simple_err_return_msg_either_action(vres,
            "ERROR: dwarf_srclines_subprog_count() on a "
            "line_context fails");
        return vres;
    }
    if (subprog_count == 0) {
        return DW_DLV_OK;
    }
    /*  The following is for the experimental table
        which is only DWARF4 so far, so no need for
        a dwarf_srclines_subprog_indexes() function. Yet. */
    printf(" subprograms count (experimental) 0x%"
        DW_PR_DUx " %" DW_PR_DUu "\n",
        subprog_count,subprog_count);
    for (i = 1; i <= subprog_count; ++i) {
        Dwarf_Unsigned decl_file = 0;
        Dwarf_Unsigned decl_line = 0;
        vres = dwarf_srclines_subprog_data(line_context,i,
            &name,&decl_file, &decl_line,err);
        if (vres != DW_DLV_OK) {
            struct esb_s m;

            esb_constructor(&m);
            esb_append_printf_i(&m,
                "\nERROR: Error accessing line_context "
                " calling  dwarf_srclines_subprog_data() "
                "with index %d ",i);
            esb_append_printf_i(&m,
                "(end index is %d).",subprog_count);
            simple_err_return_action(vres,
                esb_get_string(&m));
            esb_destructor(&m);
            return vres;
        }
        printf("  [%2" DW_PR_DSd "]  \"%s\""
            ", fileindex %2" DW_PR_DUu
            ", lineindex  %2" DW_PR_DUu
            "\n",
            i,name,decl_file,decl_line);
    }
    return DW_DLV_OK;
}

int
print_line_numbers_this_cu(Dwarf_Debug dbg, Dwarf_Die cu_die,
    char **srcfiles,
    Dwarf_Signed srcf_count,
    Dwarf_Error *err)
{
    Dwarf_Unsigned lineversion = 0;
    Dwarf_Signed linecount = 0;
    Dwarf_Line *linebuf = NULL;
    Dwarf_Signed linecount_actuals = 0;
    Dwarf_Line *linebuf_actuals = NULL;
    Dwarf_Small  table_count = 0;
    int lres = 0;
    int line_errs = 0;
    Dwarf_Line_Context line_context = 0;
    const char *sec_name = 0;
    Dwarf_Off cudie_local_offset = 0;
    Dwarf_Off dieprint_cu_goffset = 0;
    int atres = 0;

    glflags.current_section_id = DEBUG_LINE;

    /* line_flag is TRUE */

    lres = dwarf_get_line_section_name_from_die(cu_die,
        &sec_name,err);
    if (lres != DW_DLV_OK || !sec_name || !strlen(sec_name)) {
        sec_name = ".debug_line";
    }
    DROP_ERROR_INSTANCE(dbg,lres,*err);

    /* The offsets will be zero if it fails. Let it pass. */
    atres = dwarf_die_offsets(cu_die,&dieprint_cu_goffset,
        &cudie_local_offset,err);
    DROP_ERROR_INSTANCE(dbg,atres,*err);

    if (glflags.gf_do_print_dwarf) {
        struct esb_s truename;
        char buf[ESB_FIXED_ALLOC_SIZE];

        esb_constructor_fixed(&truename,buf,sizeof(buf));
        get_true_section_name(dbg,".debug_line",
            &truename,FALSE); /* Ignore the COMPRESSED flags */
        printf("\n%s: line number info for a single cu\n",
            sanitized(esb_get_string(&truename)));
        esb_destructor(&truename);
    } else {
        /* We are checking, not printing. */
        Dwarf_Half tag = 0;
        int tres = dwarf_tag(cu_die, &tag, err);
        if (tres != DW_DLV_OK) {
            /*  Something broken here. */
            struct esb_s m;
            esb_constructor(&m);
            esb_append(&m,
                "\nERROR: Unable to get CU DIE dwarf tag "
                "attempting to print line numbers for a CU ");
            if (tres == DW_DLV_ERROR) {
                esb_append(&m,dwarf_errmsg(*err));
            }
            simple_err_return_msg_either_action(tres,
                esb_get_string(&m));
            esb_destructor(&m);
            return tres;
        } else if (tag == DW_TAG_type_unit) {
            /*  Not checking since type units missing
                address or range in CU header. */
            return DW_DLV_NO_ENTRY;
        }
    }

    if (glflags.verbose > 1) {
        int errcount = 0;
        Dwarf_Bool attr_dup = FALSE;
        int lresv = 0;
        print_source_intro(dbg,cu_die);
        lresv = print_one_die(dbg, cu_die,
            dieprint_cu_goffset,
            /* print_information= */ 1,
            /* indent level */0,
            srcfiles,srcf_count,
            &attr_dup,
            /* ignore_die_stack= */TRUE,
            err);
        if (lresv == DW_DLV_ERROR) {
            return lresv;
        }
        DWARF_CHECK_COUNT(lines_result,1);
        lresv = dwarf_print_lines(cu_die, err,&errcount);
        if (errcount > 0) {
            DWARF_ERROR_COUNT(lines_result,errcount);
            DWARF_CHECK_COUNT(lines_result,(errcount-1));
        }
        if (lresv == DW_DLV_ERROR) {
            print_error_and_continue(dbg,
                "Failed to print CU lines", lresv, *err);
        }
        return lresv;
    }

    if (glflags.gf_check_lines && checking_this_compiler()) {
        int lres2 = 0;

        DWARF_CHECK_COUNT(lines_result,1);
        lres2 = dwarf_check_lineheader_b(cu_die,&line_errs,
            err);
        if (lres2 == DW_DLV_ERROR) {
            print_error_and_continue(dbg,
                "dwarf_check_lineheader_b found a serious error",
                lres2, *err);
            dwarf_dealloc(dbg,*err,DW_DLA_ERROR);
            *err = 0;
        }
        if (line_errs > 0) {
            DWARF_CHECK_ERROR_PRINT_CU();
            DWARF_ERROR_COUNT(lines_result,line_errs);
            DWARF_CHECK_COUNT(lines_result,(line_errs-1));
        }
    }
    /*  The following is complicated by a desire to test
        various line table interface functions.  Hence
        we test line_flag_selection.

        Normal code should pick an interface
        (for most  the best choice is what we here call
        glflags.gf_line_flag_selection ==  singledw5)
        and use just that interface set.

        Sorry about the length of the code that
        results from having so many interfaces.  */
    if (glflags.gf_line_flag_selection ==  singledw5) {
        lres = dwarf_srclines_b(cu_die,&lineversion,
            &table_count,&line_context,
            err);
        if (lres == DW_DLV_OK) {
            lres = dwarf_srclines_from_linecontext(line_context,
                &linebuf, &linecount,err);
        }
    } else if (glflags.gf_line_flag_selection == orig) {
        /* DWARF2,3,4, ok for 5. */
        /* Useless for experimental line tables */
        lres = dwarf_srclines(cu_die,
            &linebuf, &linecount, err);
        if (lres == DW_DLV_OK && linecount ){
            table_count++;
        }
    } else if (glflags.gf_line_flag_selection == orig2l) {
        lres = dwarf_srclines_two_level(cu_die,
            &lineversion,
            &linebuf, &linecount,
            &linebuf_actuals, &linecount_actuals,
            err);
        if (lres == DW_DLV_OK && linecount){
            table_count++;
        }
        if (lres == DW_DLV_OK && linecount_actuals){
            table_count++;
        }
    } else if (glflags.gf_line_flag_selection == s2l) {
        lres = dwarf_srclines_b(cu_die,&lineversion,
            &table_count,&line_context,
            err);
        if (lres == DW_DLV_OK) {
            lres = dwarf_srclines_two_level_from_linecontext(
                line_context,
                &linebuf, &linecount,
                &linebuf_actuals, &linecount_actuals,
                err);
        }
    }
    if (lres == DW_DLV_ERROR) {
        /* Do not terminate processing */
        if (glflags.gf_check_decl_file) {
            DWARF_CHECK_COUNT(decl_file_result,1);
            DWARF_CHECK_ERROR2(decl_file_result,"dwarf_srclines",
                dwarf_errmsg(*err));
            /* Clear error condition */
            glflags.gf_record_dwarf_error = FALSE;
        } else {
            print_error_and_continue(dbg,
                "dwarf_srclines", lres, *err);
        }
        DROP_ERROR_INSTANCE(dbg,lres,*err);
        return DW_DLV_OK;
    } else if (lres == DW_DLV_NO_ENTRY) {
        /* no line information is included */
    } else if (table_count > 0) {
        /* lres DW_DLV_OK */
        if (glflags.gf_do_print_dwarf) {
            if (line_context && glflags.verbose) {
                lres = print_line_context_record(dbg,
                    line_context,err);
                if (lres != DW_DLV_OK){
                    /*  Should we issue message
                        about this call? */
                    dwarf_srclines_dealloc_b(line_context);
                    return lres;
                }
            }
            print_source_intro(dbg,cu_die);
            if (glflags.verbose) {
                int dres = 0;
                Dwarf_Bool attr_dup = FALSE;
                /* FIXME */
                dres = print_one_die(dbg, cu_die,
                    dieprint_cu_goffset,
                    /* print_information= */ TRUE,
                    /* indent_level= */ 0,
                    /* srcfiles= */ 0, /* cnt= */ 0,

                    &attr_dup,
                    /* ignore_die_stack= */TRUE,err);
                if (dres == DW_DLV_ERROR) {
                    dwarf_srclines_dealloc_b(line_context);
                    return dres;
                }
            }
        }
        if (glflags.gf_line_flag_selection ==  singledw5 ||
            glflags.gf_line_flag_selection == s2l) {
            int ltres = 0;

            if (table_count == 0 || table_count == 1) {
                /* ASSERT: is_single_table == true */
                Dwarf_Bool is_logicals = FALSE;
                Dwarf_Bool is_actuals = FALSE;

                ltres = process_line_table(dbg,sec_name,
                    linebuf, linecount,
                    is_logicals,is_actuals,err);
                if (ltres == DW_DLV_ERROR) {
                    /* what if NO_ENTRY? */
                    dwarf_srclines_dealloc_b(line_context);
                    return ltres;
                }
            } else {
                Dwarf_Bool is_logicals = TRUE;
                Dwarf_Bool is_actuals = FALSE;

                ltres = process_line_table(dbg,sec_name,
                    linebuf, linecount,
                    is_logicals, is_actuals,err);
                if (ltres != DW_DLV_OK) {
                    dwarf_srclines_dealloc_b(line_context);
                    return ltres;
                    dwarf_srclines_dealloc_b(line_context);
                    return ltres;
                }
                ltres = process_line_table(dbg,sec_name,
                    linebuf_actuals,
                    linecount_actuals,
                    !is_logicals, !is_actuals,err);
                if (ltres != DW_DLV_OK) {
                    dwarf_srclines_dealloc_b(line_context);
                    return ltres;
                }
            }
            dwarf_srclines_dealloc_b(line_context);
            line_context = 0;
            linebuf = 0;
        } else if (glflags.gf_line_flag_selection == orig) {
            int ltres = 0;
            Dwarf_Bool is_logicals = FALSE;
            Dwarf_Bool is_actuals = FALSE;
            ltres= process_line_table(dbg,sec_name,
                linebuf, linecount,
                is_logicals, is_actuals,err);
            dwarf_srclines_dealloc(dbg,linebuf,linecount);
            linebuf = 0;
            if (ltres != DW_DLV_OK) {
                /* what if NO_ENTRY? */
                return ltres;
            }
        } else if (glflags.gf_line_flag_selection == orig2l) {
            int ltres = 0;
            if (table_count == 1 || table_count == 0) {
                Dwarf_Bool is_logicals = FALSE;
                Dwarf_Bool is_actuals = FALSE;

                ltres = process_line_table(dbg,sec_name,
                    linebuf, linecount,
                    is_logicals, is_actuals,err);
                dwarf_srclines_dealloc(dbg,linebuf,linecount);
                linebuf = 0;
                if (ltres != DW_DLV_OK) {
                    return ltres;
                }
            } else {
                Dwarf_Bool is_logicals = TRUE;
                Dwarf_Bool is_actuals = FALSE;
                ltres = process_line_table(dbg,sec_name,
                    linebuf, linecount,
                    is_logicals, is_actuals,err);
                ltres = process_line_table(dbg,sec_name,
                    linebuf_actuals, linecount_actuals,
                    !is_logicals, !is_actuals,err);
                dwarf_srclines_dealloc(dbg,linebuf,linecount);
                linebuf = 0;
                if (ltres != DW_DLV_OK) {
                    /* what if NO_ENTRY? */
                    return ltres;
                }
            }
        }
        /* end, table_count > 0 */
    } else {
        /* lres DW_DLV_OK */
        /*  table_count == 0. no lines in table.
            Just a line table header. */
        if (glflags.gf_do_print_dwarf) {
            int ores = 0;
            Dwarf_Unsigned off = 0;

            print_source_intro(dbg,cu_die);
            if (glflags.verbose) {
                int dpres = 0;
                Dwarf_Bool attr_dup = FALSE;

                /* FIXME */
                dpres = print_one_die(dbg, cu_die,
                    dieprint_cu_goffset,
                    /* print_information= */ TRUE,
                    /* indent_level= */ 0,
                    /* srcfiles= */ 0, /* cnt= */ 0,
                    &attr_dup,
                    /* ignore_die_stack= */TRUE,
                    err);
                if (dpres == DW_DLV_ERROR) {
                    dwarf_srclines_dealloc(dbg,linebuf,linecount);
                    return dpres;
                }
            }
            if (line_context) {
                if (glflags.verbose > 2) {
                    ores = print_line_context_record(dbg,
                        line_context,err);
                    if (ores != DW_DLV_OK) {
                        simple_err_return_msg_either_action(
                            ores,
                            "ERROR: line context record "
                            " where table count is 0 has a"
                            " problem");
                        dwarf_srclines_dealloc(dbg,linebuf,linecount);
                        return ores;
                    }
                }
                ores = dwarf_srclines_table_offset(
                    line_context,
                    &off,err);
                if (ores != DW_DLV_OK) {
                    simple_err_return_msg_either_action(
                        ores,
                        "ERROR: line context table_offset "
                        " where table count is 0 has a"
                        " problem");
                    dwarf_srclines_dealloc(dbg,linebuf,linecount);
                    return ores;
                } else {
                    printf(" Line table is present (offset 0x%"
                        DW_PR_XZEROS DW_PR_DUx
                        ") but no lines present\n", off);
                }
            } else {
                printf(" Line table is present but"
                    " no lines present\n");
            }
        }
        if (glflags.gf_line_flag_selection ==  singledw5 ||
            glflags.gf_line_flag_selection == s2l) {
            /* also deletes the linebuf... */
            dwarf_srclines_dealloc_b(line_context);
            line_context = 0;
            linebuf = 0;
        } else if (linebuf) {
            /* Original allocation. No context record. */
            dwarf_srclines_dealloc(dbg,linebuf,linecount);
            linebuf = 0;
        }
        /* end, linecounttotal == 0 */
    }
    if (line_context) {
        /* also deletes the linebuf... */
        dwarf_srclines_dealloc_b(line_context);
        line_context = 0;
        linebuf = 0;
    }
    if (linebuf) {
        dwarf_srclines_dealloc(dbg,linebuf,linecount);
        linebuf = 0;
    }
    return DW_DLV_OK;
}