This revision was automatically updated to reflect the committed changes. jj10306 marked an inline comment as done. Closed by commit rG6cbc6e9a6d5f: [LLDB] Add SBInstruction::GetControlFlowKind() (authored by jj10306).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131005/new/ https://reviews.llvm.org/D131005 Files: lldb/bindings/interface/SBInstruction.i lldb/include/lldb/API/SBInstruction.h lldb/source/API/SBInstruction.cpp lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py =================================================================== --- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -52,16 +52,26 @@ self.assertEqual(inst.GetMnemonic(target), "move") self.assertEqual(inst.GetOperands(target), '$' + "fp, " + '$' + "sp") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) elif re.match("powerpc64le", arch): self.assertEqual(inst.GetMnemonic(target), "li") self.assertEqual(inst.GetOperands(target), "4, 0") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) elif arch in ("aarch64", "arm64"): self.assertEqual(inst.GetMnemonic(target), "mov") self.assertEqual(inst.GetOperands(target), "w0, #0x63") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) elif arch == "arm": self.assertEqual(inst.GetMnemonic(target), "mov") self.assertEqual(inst.GetOperands(target), "r3, #99") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) else: self.assertEqual(inst.GetMnemonic(target), "movq") self.assertEqual(inst.GetOperands(target), '%' + "rsp, " + '%' + "rbp") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindOther) Index: lldb/source/API/SBInstruction.cpp =================================================================== --- lldb/source/API/SBInstruction.cpp +++ lldb/source/API/SBInstruction.cpp @@ -164,6 +164,25 @@ return nullptr; } +lldb::InstructionControlFlowKind SBInstruction::GetControlFlowKind(lldb::SBTarget target) { + LLDB_INSTRUMENT_VA(this, target); + + lldb::InstructionSP inst_sp(GetOpaque()); + if (inst_sp) { + ExecutionContext exe_ctx; + TargetSP target_sp(target.GetSP()); + std::unique_lock<std::recursive_mutex> lock; + if (target_sp) { + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); + + target_sp->CalculateExecutionContext(exe_ctx); + exe_ctx.SetProcessSP(target_sp->GetProcessSP()); + } + return inst_sp->GetControlFlowKind(&exe_ctx); + } + return lldb::eInstructionControlFlowKindUnknown; +} + size_t SBInstruction::GetByteSize() { LLDB_INSTRUMENT_VA(this); Index: lldb/include/lldb/API/SBInstruction.h =================================================================== --- lldb/include/lldb/API/SBInstruction.h +++ lldb/include/lldb/API/SBInstruction.h @@ -43,6 +43,8 @@ const char *GetComment(lldb::SBTarget target); + lldb::InstructionControlFlowKind GetControlFlowKind(lldb::SBTarget target); + lldb::SBData GetData(lldb::SBTarget target); size_t GetByteSize(); Index: lldb/bindings/interface/SBInstruction.i =================================================================== --- lldb/bindings/interface/SBInstruction.i +++ lldb/bindings/interface/SBInstruction.i @@ -44,6 +44,9 @@ const char * GetComment (lldb::SBTarget target); + lldb::InstructionControlFlowKind + GetControlFlowKind(lldb::SBTarget target); + lldb::SBData GetData (lldb::SBTarget target);
Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py =================================================================== --- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -52,16 +52,26 @@ self.assertEqual(inst.GetMnemonic(target), "move") self.assertEqual(inst.GetOperands(target), '$' + "fp, " + '$' + "sp") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) elif re.match("powerpc64le", arch): self.assertEqual(inst.GetMnemonic(target), "li") self.assertEqual(inst.GetOperands(target), "4, 0") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) elif arch in ("aarch64", "arm64"): self.assertEqual(inst.GetMnemonic(target), "mov") self.assertEqual(inst.GetOperands(target), "w0, #0x63") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) elif arch == "arm": self.assertEqual(inst.GetMnemonic(target), "mov") self.assertEqual(inst.GetOperands(target), "r3, #99") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindUnknown) else: self.assertEqual(inst.GetMnemonic(target), "movq") self.assertEqual(inst.GetOperands(target), '%' + "rsp, " + '%' + "rbp") + self.assertEqual(inst.GetControlFlowKind(target), + lldb.eInstructionControlFlowKindOther) Index: lldb/source/API/SBInstruction.cpp =================================================================== --- lldb/source/API/SBInstruction.cpp +++ lldb/source/API/SBInstruction.cpp @@ -164,6 +164,25 @@ return nullptr; } +lldb::InstructionControlFlowKind SBInstruction::GetControlFlowKind(lldb::SBTarget target) { + LLDB_INSTRUMENT_VA(this, target); + + lldb::InstructionSP inst_sp(GetOpaque()); + if (inst_sp) { + ExecutionContext exe_ctx; + TargetSP target_sp(target.GetSP()); + std::unique_lock<std::recursive_mutex> lock; + if (target_sp) { + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); + + target_sp->CalculateExecutionContext(exe_ctx); + exe_ctx.SetProcessSP(target_sp->GetProcessSP()); + } + return inst_sp->GetControlFlowKind(&exe_ctx); + } + return lldb::eInstructionControlFlowKindUnknown; +} + size_t SBInstruction::GetByteSize() { LLDB_INSTRUMENT_VA(this); Index: lldb/include/lldb/API/SBInstruction.h =================================================================== --- lldb/include/lldb/API/SBInstruction.h +++ lldb/include/lldb/API/SBInstruction.h @@ -43,6 +43,8 @@ const char *GetComment(lldb::SBTarget target); + lldb::InstructionControlFlowKind GetControlFlowKind(lldb::SBTarget target); + lldb::SBData GetData(lldb::SBTarget target); size_t GetByteSize(); Index: lldb/bindings/interface/SBInstruction.i =================================================================== --- lldb/bindings/interface/SBInstruction.i +++ lldb/bindings/interface/SBInstruction.i @@ -44,6 +44,9 @@ const char * GetComment (lldb::SBTarget target); + lldb::InstructionControlFlowKind + GetControlFlowKind(lldb::SBTarget target); + lldb::SBData GetData (lldb::SBTarget target);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits