Changeset 265
- Timestamp:
- 11/22/09 19:52:11 (15 years ago)
- Files:
-
- branches/dmd-1.x/src/backend/dwarf.c (modified) (2 diffs)
- trunk/src/backend/dwarf.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/backend/dwarf.c
r220 r265 619 619 ; 620 620 } 621 621 } 622 622 linebuf->writeByte(0); // end of file_names 623 623 624 624 debugline.prologue_length = linebuf->size() - 10; 625 625 626 626 for (unsigned seg = 1; seg <= seg_count; seg++) 627 627 { 628 628 seg_data *sd = SegData[seg]; 629 629 unsigned addressmax = 0; 630 630 unsigned linestart = ~0; 631 631 632 632 if (!sd->SDlinnum_count) 633 633 continue; 634 634 #if ELFOBJ 635 635 if (!sd->SDsym) // gdb ignores line number data without a DW_AT_name 636 636 continue; 637 637 #endif 638 638 639 // Set address to start of segment with DW_LNE_set_address640 linebuf->writeByte(0);641 linebuf->writeByte(5);642 linebuf->writeByte(2);643 dwarf_addrel(lineseg,linebuf->size(),seg);644 linebuf->write32(0);645 646 639 //printf("sd = %x, SDlinnum_count = %d\n", sd, sd->SDlinnum_count); 647 640 for (int i = 0; i < sd->SDlinnum_count; i++) 648 641 { linnum_data *ld = &sd->SDlinnum_data[i]; 642 643 // Set address to start of segment with DW_LNE_set_address 644 linebuf->writeByte(0); 645 linebuf->writeByte(5); 646 linebuf->writeByte(2); 647 dwarf_addrel(lineseg,linebuf->size(),seg); 648 linebuf->write32(0); 649 649 650 650 // Dwarf2 6.2.2 State machine registers 651 651 unsigned address = 0; // instruction address 652 652 unsigned file = ld->filenumber; 653 653 unsigned line = 1; // line numbers beginning with 1 654 654 unsigned column = 0; // column number, leftmost column is 1 655 655 int is_stmt = debugline.default_is_stmt; // TRUE if beginning of a statement 656 656 int basic_block = FALSE; // TRUE if start of basic block 657 657 int end_sequence = FALSE; // TRUE if address is after end of sequence 658 658 659 659 linebuf->writeByte(DW_LNS_set_file); 660 660 linebuf->writeuLEB128(file); 661 661 662 662 for (int j = 0; j < ld->linoff_count; j++) 663 663 { int lininc = ld->linoff[j][0] - line; 664 664 int addinc = ld->linoff[j][1] - address; 665 665 666 666 //printf("\tld[%d] line = %d offset = x%x lininc = %d addinc = %d\n", j, ld->linoff[j][0], ld->linoff[j][1], lininc, addinc); 667 667 668 668 //assert(addinc >= 0); … … 682 682 debugline.opcode_base; 683 683 684 684 if (opcode <= 255) 685 685 { linebuf->writeByte(opcode); 686 686 continue; 687 687 } 688 688 } 689 689 if (lininc) 690 690 { 691 691 linebuf->writeByte(DW_LNS_advance_line); 692 692 linebuf->writesLEB128((long)lininc); 693 693 } 694 694 if (addinc) 695 695 { 696 696 linebuf->writeByte(DW_LNS_advance_pc); 697 697 linebuf->writeuLEB128((unsigned long)addinc); 698 698 } 699 699 if (lininc || addinc) 700 700 linebuf->writeByte(DW_LNS_copy); 701 701 } 702 703 // Write DW_LNE_end_sequence 704 linebuf->writeByte(0); 705 linebuf->writeByte(1); 706 linebuf->writeByte(1); 702 707 } 703 704 // Write DW_LNE_end_sequence705 linebuf->writeByte(0);706 linebuf->writeByte(1);707 linebuf->writeByte(1);708 708 } 709 709 710 710 debugline.total_length = linebuf->size() - 4; 711 711 memcpy(linebuf->buf, &debugline, sizeof(debugline)); 712 712 713 713 /* ================================================= */ 714 714 715 715 abbrevbuf->writeByte(0); 716 716 717 717 /* ================================================= */ 718 718 719 719 infobuf->writeByte(0); // ending abbreviation code 720 720 721 721 debuginfo.total_length = infobuf->size() - 4; 722 722 memcpy(infobuf->buf, &debuginfo, sizeof(debuginfo)); 723 723 724 724 /* ================================================= */ 725 725 726 726 // Terminate by offset field containing 0 727 727 debug_pubnames_buf->write32(0); trunk/src/backend/dwarf.c
r218 r265 619 619 ; 620 620 } 621 621 } 622 622 linebuf->writeByte(0); // end of file_names 623 623 624 624 debugline.prologue_length = linebuf->size() - 10; 625 625 626 626 for (unsigned seg = 1; seg <= seg_count; seg++) 627 627 { 628 628 seg_data *sd = SegData[seg]; 629 629 unsigned addressmax = 0; 630 630 unsigned linestart = ~0; 631 631 632 632 if (!sd->SDlinnum_count) 633 633 continue; 634 634 #if ELFOBJ 635 635 if (!sd->SDsym) // gdb ignores line number data without a DW_AT_name 636 636 continue; 637 637 #endif 638 638 639 // Set address to start of segment with DW_LNE_set_address640 linebuf->writeByte(0);641 linebuf->writeByte(5);642 linebuf->writeByte(2);643 dwarf_addrel(lineseg,linebuf->size(),seg);644 linebuf->write32(0);645 646 639 //printf("sd = %x, SDlinnum_count = %d\n", sd, sd->SDlinnum_count); 647 640 for (int i = 0; i < sd->SDlinnum_count; i++) 648 641 { linnum_data *ld = &sd->SDlinnum_data[i]; 642 643 // Set address to start of segment with DW_LNE_set_address 644 linebuf->writeByte(0); 645 linebuf->writeByte(5); 646 linebuf->writeByte(2); 647 dwarf_addrel(lineseg,linebuf->size(),seg); 648 linebuf->write32(0); 649 649 650 650 // Dwarf2 6.2.2 State machine registers 651 651 unsigned address = 0; // instruction address 652 652 unsigned file = ld->filenumber; 653 653 unsigned line = 1; // line numbers beginning with 1 654 654 unsigned column = 0; // column number, leftmost column is 1 655 655 int is_stmt = debugline.default_is_stmt; // TRUE if beginning of a statement 656 656 int basic_block = FALSE; // TRUE if start of basic block 657 657 int end_sequence = FALSE; // TRUE if address is after end of sequence 658 658 659 659 linebuf->writeByte(DW_LNS_set_file); 660 660 linebuf->writeuLEB128(file); 661 661 662 662 for (int j = 0; j < ld->linoff_count; j++) 663 663 { int lininc = ld->linoff[j][0] - line; 664 664 int addinc = ld->linoff[j][1] - address; 665 665 666 666 //printf("\tld[%d] line = %d offset = x%x lininc = %d addinc = %d\n", j, ld->linoff[j][0], ld->linoff[j][1], lininc, addinc); 667 667 668 668 //assert(addinc >= 0); … … 682 682 debugline.opcode_base; 683 683 684 684 if (opcode <= 255) 685 685 { linebuf->writeByte(opcode); 686 686 continue; 687 687 } 688 688 } 689 689 if (lininc) 690 690 { 691 691 linebuf->writeByte(DW_LNS_advance_line); 692 692 linebuf->writesLEB128((long)lininc); 693 693 } 694 694 if (addinc) 695 695 { 696 696 linebuf->writeByte(DW_LNS_advance_pc); 697 697 linebuf->writeuLEB128((unsigned long)addinc); 698 698 } 699 699 if (lininc || addinc) 700 700 linebuf->writeByte(DW_LNS_copy); 701 701 } 702 703 // Write DW_LNE_end_sequence 704 linebuf->writeByte(0); 705 linebuf->writeByte(1); 706 linebuf->writeByte(1); 702 707 } 703 704 // Write DW_LNE_end_sequence705 linebuf->writeByte(0);706 linebuf->writeByte(1);707 linebuf->writeByte(1);708 708 } 709 709 710 710 debugline.total_length = linebuf->size() - 4; 711 711 memcpy(linebuf->buf, &debugline, sizeof(debugline)); 712 712 713 713 /* ================================================= */ 714 714 715 715 abbrevbuf->writeByte(0); 716 716 717 717 /* ================================================= */ 718 718 719 719 infobuf->writeByte(0); // ending abbreviation code 720 720 721 721 debuginfo.total_length = infobuf->size() - 4; 722 722 memcpy(infobuf->buf, &debuginfo, sizeof(debuginfo)); 723 723 724 724 /* ================================================= */ 725 725 726 726 // Terminate by offset field containing 0 727 727 debug_pubnames_buf->write32(0);
