Skip to content

Commit a1e7ec5

Browse files
author
Ryan Fleury
committed
rdi_from_pdb: fix line emitting rules in inline site symbol parsing; also fix non-application of code lengths to code offsets in inline lines
1 parent 5b7c366 commit a1e7ec5

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/rdi_from_pdb/rdi_from_pdb.c

+22-10
Original file line numberDiff line numberDiff line change
@@ -794,11 +794,9 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
794794
CV_InlineRangeKind range_kind = 0;
795795
U32 code_length = 0;
796796
U32 code_offset = 0;
797-
U32 last_code_offset = code_offset;
798797
String8 file_name = inlinee_lines_parsed->file_name;
799-
String8 last_file_name = file_name;
798+
String8 last_file_name = {0};
800799
S32 line = (S32)inlinee_lines_parsed->first_source_ln;
801-
S32 last_line = line;
802800
S32 column = 1;
803801
S32 last_column = column;
804802

@@ -821,6 +819,9 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
821819
CV_C13SubSectionNode *file_chksms = unit_c13->file_chksms_sub_section;
822820

823821
// rjf: decode loop
822+
B32 line_num_emitted = 0;
823+
B32 code_off_emitted = 0;
824+
B32 code_len_emitted = 0;
824825
U64 read_off = 0;
825826
U64 read_off_opl = binary_annots.size;
826827
for(B32 good = 1; read_off < read_off_opl && good;)
@@ -840,6 +841,7 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
840841
case CV_InlineBinaryAnnotation_CodeOffset:
841842
{
842843
read_off += cv_decode_inline_annot_u32(binary_annots, read_off, &code_offset);
844+
code_off_emitted = 1;
843845
}break;
844846
case CV_InlineBinaryAnnotation_ChangeCodeOffsetBase:
845847
{
@@ -857,11 +859,13 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
857859
U32 delta = 0;
858860
read_off += cv_decode_inline_annot_u32(binary_annots, read_off, &delta);
859861
code_offset += delta;
862+
code_off_emitted = 1;
860863
}break;
861864
case CV_InlineBinaryAnnotation_ChangeCodeLength:
862865
{
863866
code_length = 0;
864867
read_off += cv_decode_inline_annot_u32(binary_annots, read_off, &code_length);
868+
code_len_emitted = 1;
865869
}break;
866870
case CV_InlineBinaryAnnotation_ChangeFile:
867871
{
@@ -881,6 +885,7 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
881885
S32 delta = 0;
882886
read_off += cv_decode_inline_annot_s32(binary_annots, read_off, &delta);
883887
line += delta;
888+
line_num_emitted = 1;
884889
}break;
885890
case CV_InlineBinaryAnnotation_ChangeLineEndDelta:
886891
{
@@ -923,13 +928,17 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
923928
S32 line_delta = cv_inline_annot_signed_from_unsigned_operand(code_offset_and_line_offset >> 4);
924929
code_offset += code_delta;
925930
line += line_delta;
931+
code_off_emitted = 1;
932+
line_num_emitted = 1;
926933
}break;
927934
case CV_InlineBinaryAnnotation_ChangeCodeLengthAndCodeOffset:
928935
{
929936
U32 offset_delta = 0;
930937
read_off += cv_decode_inline_annot_u32(binary_annots, read_off, &code_length);
931938
read_off += cv_decode_inline_annot_u32(binary_annots, read_off, &offset_delta);
932939
code_offset += offset_delta;
940+
code_len_emitted = 1;
941+
code_off_emitted = 1;
933942
}break;
934943
case CV_InlineBinaryAnnotation_ChangeColumnEnd:
935944
{
@@ -941,7 +950,7 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
941950
}
942951

943952
// rjf: gather new lines
944-
if(!good || line != last_line || code_offset != last_code_offset)
953+
if(!good || (line_num_emitted && code_off_emitted && code_len_emitted))
945954
{
946955
LineChunk *chunk = last_line_chunk;
947956
if(chunk == 0 || chunk->count+1 >= chunk->cap)
@@ -957,6 +966,15 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
957966
chunk->line_nums[chunk->count] = (U32)line;
958967
chunk->count += 1;
959968
total_line_chunk_line_count += 1;
969+
line_num_emitted = 0;
970+
code_off_emitted = 0;
971+
code_len_emitted = 0;
972+
}
973+
974+
// rjf: advance code offset by the code length
975+
{
976+
code_offset += code_length;
977+
code_length = 0;
960978
}
961979

962980
// rjf: push line sequence to line table & source file
@@ -1029,12 +1047,6 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
10291047
first_line_chunk = last_line_chunk = 0;
10301048
total_line_chunk_line_count = 0;
10311049
}
1032-
1033-
// rjf: update prev/current states
1034-
last_file_name = file_name;
1035-
last_line = line;
1036-
last_column = column;
1037-
last_code_offset = code_offset;
10381050
}
10391051
}
10401052
}break;

0 commit comments

Comments
 (0)