[Lldb-commits] [PATCH] D140368: [lldb] Consider all breakpoints in breakpoint detection
kpdev42 updated this revision to Diff 485434. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140368/new/ https://reviews.llvm.org/D140368 Files: lldb/source/Target/StopInfo.cpp lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/Makefile lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/TestThreadPlanUserBreakpoint.py lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/main.cpp Index: lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/main.cpp @@ -0,0 +1,11 @@ +int func_1() { return 1; } + +int func_2() { + func_1(); // breakpoint_1 + return 1 + func_1(); // breakpoint_2 +} + +int main(int argc, char const *argv[]) { + func_2(); // breakpoint_0 + return 0; +} Index: lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/TestThreadPlanUserBreakpoint.py === --- /dev/null +++ lldb/test/API/functionalities/breakpoint/thread_plan_user_breakpoint/TestThreadPlanUserBreakpoint.py @@ -0,0 +1,130 @@ +""" +Test that breakpoints (reason = breakpoint) have more priority than +plan completion (reason = step in/out/over) when reporting stop reason after step, +in particular 'step out' and 'step over', and in addition 'step in'. +Check for correct StopReason when stepping to the line with breakpoint, +which should be eStopReasonBreakpoint in general, +and eStopReasonPlanComplete when breakpoint's condition fails or it is disabled. +""" + + +import unittest2 +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class ThreadPlanUserBreakpointsTestCase(TestBase): + +def setUp(self): +TestBase.setUp(self) + +self.build() +exe = self.getBuildArtifact("a.out") +src = lldb.SBFileSpec("main.cpp") + +# Create a target by the debugger. +self.target = self.dbg.CreateTarget(exe) +self.assertTrue(self.target, VALID_TARGET) + +# Setup three breakpoints +self.lines = [line_number('main.cpp', "breakpoint_%i" % i) for i in range(3)] + +self.breakpoints = [self.target.BreakpointCreateByLocation(src, line) for line in self.lines] +self.assertTrue( +self.breakpoints[0] and self.breakpoints[0].GetNumLocations() == 1, +VALID_BREAKPOINT) + +# Start debugging +self.process = self.target.LaunchSimple( +None, None, self.get_process_working_directory()) +self.assertIsNotNone(self.process, PROCESS_IS_VALID) +self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoints[0]) +self.assertIsNotNone(self.thread, "Didn't stop at breakpoint 0.") + +def check_correct_stop_reason(self, breakpoint_idx, condition): +self.assertState(self.process.GetState(), lldb.eStateStopped) +if condition: +# All breakpoints active, stop reason is breakpoint +thread1 = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoints[breakpoint_idx]) +self.assertEquals(self.thread, thread1, "Didn't stop at breakpoint %i." % breakpoint_idx) +else: +# Breakpoints are inactive, stop reason is plan complete +self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete, +"Expected stop reason to be step into/over/out for inactive breakpoint %i line." % breakpoint_idx) + +def change_breakpoints(self, action): +for i in range(1, len(self.breakpoints)): +action(self.breakpoints[i]) + +def check_thread_plan_user_breakpoint(self, condition, set_up_breakpoint_func): +# Make breakpoints active/inactive in different ways +self.change_breakpoints(lambda bp: set_up_breakpoint_func(condition, bp)) + +self.thread.StepInto() +# We should be stopped at the breakpoint_1 line with the correct stop reason +self.check_correct_stop_reason(1, condition) + +# This step-over creates a step-out from `func_1` plan +self.thread.StepOver() +# We should be stopped at the breakpoint_2 line with the correct stop reason +self.check_correct_stop_reason(2, condition) + +# Check explicit step-out +# Make sure we install the breakpoint at the right address: +# on some architectures (e.g, aarch64), step-out stops before the next source line +return_addr = self.thread.GetFrameAtIndex(1).GetPC() +step_out_breakpoint = self.target.BreakpointCreateByAddress(return_addr) +set_up_breakpoint_func(condition, step_out_breakpoint) +self.breakpoints.append(step_out_breakpoint) + +sel
[Lldb-commits] [PATCH] D140368: [lldb] Consider all breakpoints in breakpoint detection
kpdev42 added a comment. Fix test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140368/new/ https://reviews.llvm.org/D140368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3473c10 - [LLDB][LoongArch] Optimize EmulateInstructionLoongArch related code
Author: Hui Li Date: 2022-12-28T09:13:05+08:00 New Revision: 3473c1093aa03eb51fb756e05f7ed48907187ae0 URL: https://github.com/llvm/llvm-project/commit/3473c1093aa03eb51fb756e05f7ed48907187ae0 DIFF: https://github.com/llvm/llvm-project/commit/3473c1093aa03eb51fb756e05f7ed48907187ae0.diff LOG: [LLDB][LoongArch] Optimize EmulateInstructionLoongArch related code This is a code optimization patch that does not include feature additions or deletions. Reviewed By: SixWeining Differential Revision: https://reviews.llvm.org/D140616 Added: Modified: lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp Removed: diff --git a/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp b/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp index b37bb860254eb..a17d8609b0d55 100644 --- a/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp +++ b/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp @@ -199,80 +199,47 @@ bool EmulateInstructionLoongArch::SupportsThisArch(const ArchSpec &arch) { } bool EmulateInstructionLoongArch::EmulateBEQZ(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBEQZ64(inst); - else -return false; + return IsLoongArch64() ? EmulateBEQZ64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBNEZ(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBNEZ64(inst); - else -return false; + return IsLoongArch64() ? EmulateBNEZ64(inst) : false; } bool EmulateInstructionLoongArch::EmulateJIRL(uint32_t inst) { - if (IsLoongArch64()) -return EmulateJIRL64(inst); - else -return false; + return IsLoongArch64() ? EmulateJIRL64(inst) : false; } bool EmulateInstructionLoongArch::EmulateB(uint32_t inst) { - if (IsLoongArch64()) -return EmulateB64(inst); - else -return false; + return IsLoongArch64() ? EmulateB64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBL(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBL64(inst); - else -return false; + return IsLoongArch64() ? EmulateBL64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBEQ(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBEQ64(inst); - else -return false; + return IsLoongArch64() ? EmulateBEQ64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBNE(uint32_t inst) { - if (IsLoongArch64()) -return EmulateJIRL64(inst); - else -return false; + return IsLoongArch64() ? EmulateBNE64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBLT(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBLT64(inst); - else -return false; + return IsLoongArch64() ? EmulateBLT64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBGE(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBGE64(inst); - else -return false; + return IsLoongArch64() ? EmulateBGE64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBLTU(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBLTU64(inst); - else -return false; + return IsLoongArch64() ? EmulateBLTU64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBGEU(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBGEU64(inst); - else -return false; + return IsLoongArch64() ? EmulateBGEU64(inst) : false; } bool EmulateInstructionLoongArch::EmulateNonJMP(uint32_t inst) { return false; } @@ -281,20 +248,17 @@ bool EmulateInstructionLoongArch::EmulateNonJMP(uint32_t inst) { return false; } // if GR[rj] == 0: // PC = PC + SignExtend({offs21, 2'b0}, GRLEN) bool EmulateInstructionLoongArch::EmulateBEQZ64(uint32_t inst) { - uint64_t next_pc, imm_sign_extend; bool success = false; uint32_t rj = Bits32(inst, 9, 5); - uint64_t rj_val; uint64_t pc = ReadPC(&success); if (!success) return false; uint32_t offs21 = Bits32(inst, 25, 10) + (Bits32(inst, 4, 0) << 16); - rj_val = ReadRegisterUnsigned(eRegisterKindLLDB, rj, 0, &success); + uint64_t rj_val = ReadRegisterUnsigned(eRegisterKindLLDB, rj, 0, &success); if (!success) return false; if (rj_val == 0) { -imm_sign_extend = llvm::SignExtend64<23>(offs21 << 2); -next_pc = pc + imm_sign_extend; +uint64_t next_pc = pc + llvm::SignExtend64<23>(offs21 << 2); return WritePC(next_pc); } else return WritePC(pc + 4); @@ -304,20 +268,17 @@ bool EmulateInstructionLoongArch::EmulateBEQZ64(uint32_t inst) { // if GR[rj] != 0: // PC = PC + SignExtend({offs21, 2'b0}, GRLEN) bool EmulateInstructionLoongArch::EmulateBNEZ64(uint32_t inst) { - uint64_t next_pc, imm_sign_extend; bool success = false; uint32_t rj = Bits32(inst, 9, 5); - uint64_t rj_val; uint64_t pc = ReadPC(&success); if (!success) return false; uint32_t offs21 = Bits32(inst, 25, 10) + (Bits32(inst, 4, 0)
[Lldb-commits] [PATCH] D140616: [LLDB][LoongArch] Optimize EmulateInstructionLoongArch related code
This revision was automatically updated to reflect the committed changes. Closed by commit rG3473c1093aa0: [LLDB][LoongArch] Optimize EmulateInstructionLoongArch related code (authored by lh03061238, committed by SixWeining). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140616/new/ https://reviews.llvm.org/D140616 Files: lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp Index: lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp === --- lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp +++ lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp @@ -199,80 +199,47 @@ } bool EmulateInstructionLoongArch::EmulateBEQZ(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBEQZ64(inst); - else -return false; + return IsLoongArch64() ? EmulateBEQZ64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBNEZ(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBNEZ64(inst); - else -return false; + return IsLoongArch64() ? EmulateBNEZ64(inst) : false; } bool EmulateInstructionLoongArch::EmulateJIRL(uint32_t inst) { - if (IsLoongArch64()) -return EmulateJIRL64(inst); - else -return false; + return IsLoongArch64() ? EmulateJIRL64(inst) : false; } bool EmulateInstructionLoongArch::EmulateB(uint32_t inst) { - if (IsLoongArch64()) -return EmulateB64(inst); - else -return false; + return IsLoongArch64() ? EmulateB64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBL(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBL64(inst); - else -return false; + return IsLoongArch64() ? EmulateBL64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBEQ(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBEQ64(inst); - else -return false; + return IsLoongArch64() ? EmulateBEQ64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBNE(uint32_t inst) { - if (IsLoongArch64()) -return EmulateJIRL64(inst); - else -return false; + return IsLoongArch64() ? EmulateBNE64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBLT(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBLT64(inst); - else -return false; + return IsLoongArch64() ? EmulateBLT64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBGE(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBGE64(inst); - else -return false; + return IsLoongArch64() ? EmulateBGE64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBLTU(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBLTU64(inst); - else -return false; + return IsLoongArch64() ? EmulateBLTU64(inst) : false; } bool EmulateInstructionLoongArch::EmulateBGEU(uint32_t inst) { - if (IsLoongArch64()) -return EmulateBGEU64(inst); - else -return false; + return IsLoongArch64() ? EmulateBGEU64(inst) : false; } bool EmulateInstructionLoongArch::EmulateNonJMP(uint32_t inst) { return false; } @@ -281,20 +248,17 @@ // if GR[rj] == 0: // PC = PC + SignExtend({offs21, 2'b0}, GRLEN) bool EmulateInstructionLoongArch::EmulateBEQZ64(uint32_t inst) { - uint64_t next_pc, imm_sign_extend; bool success = false; uint32_t rj = Bits32(inst, 9, 5); - uint64_t rj_val; uint64_t pc = ReadPC(&success); if (!success) return false; uint32_t offs21 = Bits32(inst, 25, 10) + (Bits32(inst, 4, 0) << 16); - rj_val = ReadRegisterUnsigned(eRegisterKindLLDB, rj, 0, &success); + uint64_t rj_val = ReadRegisterUnsigned(eRegisterKindLLDB, rj, 0, &success); if (!success) return false; if (rj_val == 0) { -imm_sign_extend = llvm::SignExtend64<23>(offs21 << 2); -next_pc = pc + imm_sign_extend; +uint64_t next_pc = pc + llvm::SignExtend64<23>(offs21 << 2); return WritePC(next_pc); } else return WritePC(pc + 4); @@ -304,20 +268,17 @@ // if GR[rj] != 0: // PC = PC + SignExtend({offs21, 2'b0}, GRLEN) bool EmulateInstructionLoongArch::EmulateBNEZ64(uint32_t inst) { - uint64_t next_pc, imm_sign_extend; bool success = false; uint32_t rj = Bits32(inst, 9, 5); - uint64_t rj_val; uint64_t pc = ReadPC(&success); if (!success) return false; uint32_t offs21 = Bits32(inst, 25, 10) + (Bits32(inst, 4, 0) << 16); - rj_val = ReadRegisterUnsigned(eRegisterKindLLDB, rj, 0, &success); + uint64_t rj_val = ReadRegisterUnsigned(eRegisterKindLLDB, rj, 0, &success); if (!success) return false; if (rj_val != 0) { -imm_sign_extend = llvm::SignExtend64<23>(offs21 << 2); -next_pc = pc + imm_sign_extend; +uint64_t next_pc = pc + llvm::SignExtend64<23>(offs21 << 2); return WritePC(next_pc); } else return WritePC(pc + 4); @@ -327,8 +288,6 @@ // GR[rd] = PC + 4 // PC = GR[rj] + SignExtend({offs16, 2'b0}, GRLEN) bool EmulateInstructionLoongArch::E