| ... | @@ -372,18 +372,20 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres | ... | @@ -372,18 +372,20 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres |
| 372 | const frag_vaddr_start = coff_section.header.virtual_address + line_hdr.RelocOffset; | 372 | const frag_vaddr_start = coff_section.header.virtual_address + line_hdr.RelocOffset; |
| 373 | const frag_vaddr_end = frag_vaddr_start + line_hdr.CodeSize; | 373 | const frag_vaddr_end = frag_vaddr_start + line_hdr.CodeSize; |
| 374 | | 374 | |
| 375 | // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records) | 375 | if (relative_address >= frag_vaddr_start and relative_address < frag_vaddr_end) { |
| 376 | // from now on. We will iterate through them, and eventually find a LineInfo that we're interested in, | 376 | // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records) |
| 377 | // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection. | 377 | // from now on. We will iterate through them, and eventually find a LineInfo that we're interested in, |
| 378 | const subsection_end_index = sect_offset + subsect_hdr.Length; | 378 | // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection. |
| 379 | while (line_index < subsection_end_index) { | 379 | |
| 380 | const block_hdr = @ptrCast(*pdb.LineBlockFragmentHeader, &subsect_info[line_index]); | 380 | const subsection_end_index = sect_offset + subsect_hdr.Length; |
| 381 | line_index += @sizeOf(pdb.LineBlockFragmentHeader); | 381 | |
| 382 | const start_line_index = line_index; | 382 | while (line_index < subsection_end_index) { |
| 383 | | 383 | const block_hdr = @ptrCast(*pdb.LineBlockFragmentHeader, &subsect_info[line_index]); |
| 384 | const has_column = line_hdr.Flags.LF_HaveColumns; | 384 | line_index += @sizeOf(pdb.LineBlockFragmentHeader); |
| 385 | | 385 | const start_line_index = line_index; |
| 386 | if (relative_address >= frag_vaddr_start and relative_address < frag_vaddr_end) { | 386 | |
| | 387 | const has_column = line_hdr.Flags.LF_HaveColumns; |
| | 388 | |
| 387 | // All line entries are stored inside their line block by ascending start address. | 389 | // All line entries are stored inside their line block by ascending start address. |
| 388 | // Heuristic: we want to find the last line entry that has a vaddr_start <= relative_address. | 390 | // Heuristic: we want to find the last line entry that has a vaddr_start <= relative_address. |
| 389 | // This is done with a simple linear search. | 391 | // This is done with a simple linear search. |
| ... | @@ -427,11 +429,11 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres | ... | @@ -427,11 +429,11 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres |
| 427 | }; | 429 | }; |
| 428 | } | 430 | } |
| 429 | } | 431 | } |
| 430 | } | | |
| 431 | | 432 | |
| 432 | // Checking that we are not reading garbage after the (possibly) multiple block fragments. | 433 | // Checking that we are not reading garbage after the (possibly) multiple block fragments. |
| 433 | if (line_index != subsection_end_index) { | 434 | if (line_index != subsection_end_index) { |
| 434 | return error.InvalidDebugInfo; | 435 | return error.InvalidDebugInfo; |
| | 436 | } |
| 435 | } | 437 | } |
| 436 | }, | 438 | }, |
| 437 | else => {}, | 439 | else => {}, |