53 lines · plain
1_T = require('lua_lldb_test').create_test('TestBreakpointAPI')2 3function _T:TestBreakpointIsValid()4 local target = self:create_target()5 local breakpoint = target:BreakpointCreateByName('AFunction', 'a.out')6 assertTrue(breakpoint:IsValid() and breakpoint:GetNumLocations() == 1)7 local did_delete = target:BreakpointDelete(breakpoint:GetID())8 assertTrue(did_delete)9 local del_bkpt = target:FindBreakpointByID(breakpoint:GetID())10 assertFalse(del_bkpt:IsValid())11 assertFalse(breakpoint:IsValid())12end13 14function _T:TestTargetDelete()15 local target = self:create_target()16 local breakpoint = target:BreakpointCreateByName('AFunction', 'a.out')17 assertTrue(breakpoint:IsValid() and breakpoint:GetNumLocations() == 1)18 local location = breakpoint:GetLocationAtIndex(0)19 assertTrue(location:IsValid())20 assertEqual(target, breakpoint:GetTarget())21 assertTrue(self.debugger:DeleteTarget(target))22 assertFalse(breakpoint:IsValid())23 assertFalse(location:IsValid())24end25 26function _T:TestBreakpointHitCount()27 local target = self:create_target()28 local breakpoint = target:BreakpointCreateByName('BFunction', 'a.out')29 assertTrue(breakpoint:IsValid() and breakpoint:GetNumLocations() == 1)30 breakpoint:SetAutoContinue(true)31 target:LaunchSimple(nil, nil, nil)32 assertEqual(breakpoint:GetHitCount(), 100)33end34 35function _T:TestBreakpointFrame()36 local target = self:create_target()37 local breakpoint = target:BreakpointCreateByName('main', 'a.out')38 assertTrue(breakpoint:IsValid() and breakpoint:GetNumLocations() == 1)39 local process = target:LaunchSimple({ 'arg1', 'arg2' }, nil, nil)40 local thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)41 assertNotNil(thread)42 assertTrue(thread:IsValid())43 local frame = thread:GetFrameAtIndex(0)44 assertTrue(frame:IsValid())45 local error = lldb.SBError()46 local var_argc = frame:FindVariable('argc')47 local var_argc_value = var_argc:GetValueAsSigned(error, 0)48 assertTrue(error:Success())49 assertEqual(var_argc_value, 3)50end51 52os.exit(_T:run())53