[Lldb-commits] [lldb] r228577 - Fix test case for data-disassemble instruction in lldb-mi.
Hafiz Abid Qadeer
hafiz_abid at mentor.com
Mon Feb 9 06:34:12 PST 2015
Author: abidh
Date: Mon Feb 9 08:34:12 2015
New Revision: 228577
URL: http://llvm.org/viewvc/llvm-project?rev=228577&view=rev
Log:
Fix test case for data-disassemble instruction in lldb-mi.
Previously the offset field showed the offset from the section base.
I have fixed it so that first disassembled instruction has offset of 0.
Also made a little modification in the test case to match the output coming
form the lldb-mi.
Modified:
lldb/trunk/test/tools/lldb-mi/TestMiData.py
lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
Modified: lldb/trunk/test/tools/lldb-mi/TestMiData.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiData.py?rev=228577&r1=228576&r2=228577&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiData.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiData.py Mon Feb 9 08:34:12 2015
@@ -33,7 +33,7 @@ class MiDataTestCase(lldbmi_testcase.MiT
# Test -data-disassemble: try to disassemble some address
self.runCmd("-data-disassemble -s %#x -e %#x -- 0" % (addr, addr + 0x10))
- self.expect("\^done,asm_insns=\[{address=\"%#x\",func-name=\"main\",offset=\"0x0\",size=\"[1-9]\",inst=\".+\"}," % addr)
+ self.expect("\^done,asm_insns=\[{address=\"0x%08x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+\"}," % addr)
@lldbmi_test
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp?rev=228577&r1=228576&r2=228577&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp Mon Feb 9 08:34:12 2015
@@ -408,6 +408,11 @@ CMICmdCmdDataDisassemble::Execute(void)
lldb::addr_t lldbStartAddr = static_cast<lldb::addr_t>(nAddrStart);
lldb::SBInstructionList instructions = sbTarget.ReadInstructions(lldb::SBAddress(lldbStartAddr, sbTarget), nAddrEnd - nAddrStart);
const MIuint nInstructions = instructions.GetSize();
+ // Calculate the offset of first instruction so that we can generate offset starting at 0
+ lldb::addr_t start_offset = 0;
+ if(nInstructions > 0)
+ start_offset = instructions.GetInstructionAtIndex(0).GetAddress().GetOffset();
+
for (size_t i = 0; i < nInstructions; i++)
{
const MIchar *pUnknown = "??";
@@ -418,7 +423,7 @@ CMICmdCmdDataDisassemble::Execute(void)
lldb::addr_t addr = address.GetLoadAddress(sbTarget);
const MIchar *pFnName = address.GetFunction().GetName();
pFnName = (pFnName != nullptr) ? pFnName : pUnknown;
- lldb::addr_t addrOffSet = address.GetOffset();
+ lldb::addr_t addrOffSet = address.GetOffset() - start_offset;
const MIchar *pStrOperands = instrt.GetOperands(sbTarget);
pStrOperands = (pStrOperands != nullptr) ? pStrOperands : pUnknown;
const size_t instrtSize = instrt.GetByteSize();
@@ -430,7 +435,7 @@ CMICmdCmdDataDisassemble::Execute(void)
const CMICmnMIValueConst miValueConst2(pFnName);
const CMICmnMIValueResult miValueResult2("func-name", miValueConst2);
miValueTuple.Add(miValueResult2);
- const CMICmnMIValueConst miValueConst3(CMIUtilString::Format("0x%lld", addrOffSet));
+ const CMICmnMIValueConst miValueConst3(CMIUtilString::Format("%lld", addrOffSet));
const CMICmnMIValueResult miValueResult3("offset", miValueConst3);
miValueTuple.Add(miValueResult3);
const CMICmnMIValueConst miValueConst4(CMIUtilString::Format("%d", instrtSize));
More information about the lldb-commits
mailing list