Skip to content

Commit 3a0a962

Browse files
committed
fix wrong assembly line number when debugging assembly with different sized instructions
1 parent 11d5c4d commit 3a0a962

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "lldb/API/SBFileSpec.h"
2020
#include "lldb/API/SBFrame.h"
2121
#include "lldb/API/SBFunction.h"
22+
#include "lldb/API/SBInstructionList.h"
2223
#include "lldb/API/SBLineEntry.h"
2324
#include "lldb/API/SBModule.h"
2425
#include "lldb/API/SBQueue.h"
@@ -776,10 +777,11 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame,
776777

777778
// Calculate the line of the current PC from the start of the current
778779
// symbol.
779-
lldb::addr_t inst_offset = frame.GetPCAddress().GetOffset() -
780-
frame.GetSymbol().GetStartAddress().GetOffset();
781-
lldb::addr_t inst_line =
782-
inst_offset / (frame.GetThread().GetProcess().GetAddressByteSize() / 2);
780+
lldb::SBTarget target = frame.GetThread().GetProcess().GetTarget();
781+
lldb::SBInstructionList inst_list = target.ReadInstructions(
782+
frame.GetSymbol().GetStartAddress(), frame.GetPCAddress(), nullptr);
783+
size_t inst_line = inst_list.GetSize();
784+
783785
// Line numbers are 1-based.
784786
object.try_emplace("line", inst_line + 1);
785787
object.try_emplace("column", 1);

0 commit comments

Comments
 (0)