Skip to content

Commit b7870f5

Browse files
committed
Handle out of order file lines
1 parent f10e4b6 commit b7870f5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,22 @@ public int Read(uint dwInstructions, enum_DISASSEMBLY_STREAM_FIELDS dwFields, ou
211211
bool isNewDocument = string.IsNullOrEmpty(_pLastDocument) || !_pLastDocument.Equals(currentFile, StringComparison.Ordinal);
212212
bool isNewLine = currentLine != _dwLastSourceLine;
213213

214-
if ((dwFields & enum_DISASSEMBLY_STREAM_FIELDS.DSF_POSITION) != 0 && currentLine != 0)
214+
/* GDB will return a lines of sources not in sequential order.
215+
* We ignore lines with lower line numbers and have it captured in a different group of source.
216+
*
217+
* Example MI Response:
218+
* src_and_asm_line={line="22",file="main.cpp",fullname="/home/waan/cpp/main.cpp",line_asm_insn=[
219+
* {address="0x00007fc4b52b54c5",func-name="main(int, char**)",offset="124",opcodes="48 8d 95 40 ff ff ff",inst="lea -0xc0(%rbp),%rdx" }
220+
* ]
221+
* },src_and_asm_line={line="21",file="main.cpp",fullname="/home/waan/cpp/main.cpp",line_asm_insn=[
222+
* {address="0x00007fc4b52b54df",func-name="main(int, char**)",offset="150",opcodes="c7 85 48 ff ff ff 02 00 00 00",inst="movl $0x2,-0xb8(%rbp)"}
223+
* ]
224+
* },src_and_asm_line={line="22",file="main.cpp",fullname="/home/waan/cpp/main.cpp",line_asm_insn=[
225+
* {address="0x00007fc4b52b54e9",func-name="main(int, char**)",offset="160",opcodes="48 8d 85 48 ff ff ff",inst="lea -0xb8(%rbp),%rax"}
226+
* }
227+
*/
228+
229+
if ((dwFields & enum_DISASSEMBLY_STREAM_FIELDS.DSF_POSITION) != 0 && currentLine != 0 && currentLine >= _dwLastSourceLine)
215230
{
216231
// If we have a new line and the current line is greater than the previously seen source line.
217232
// Try to grab the last seen source line + 1 and show a group of source code.

0 commit comments

Comments
 (0)