1 _T
= require('lua_lldb_test').create_test('TestComprehensive')
3 function _T
:Test0_CreateTarget()
4 self
.target
= self
:create_target()
5 assertTrue(self
.target
:IsValid())
8 function _T
:Test1_Breakpoint()
9 self
.main_bp
= self
.target
:BreakpointCreateByName('main', 'a.out')
10 self
.loop_bp
= self
.target
:BreakpointCreateByLocation('main.c', 28)
11 assertTrue(self
.main_bp
:IsValid() and self
.main_bp
:GetNumLocations() == 1)
12 assertTrue(self
.loop_bp
:IsValid() and self
.loop_bp
:GetNumLocations() == 1)
15 function _T
:Test2_Launch()
16 local error = lldb
.SBError()
18 self
.process
= self
.target
:Launch(
19 self
.debugger
:GetListener(),
30 assertTrue(error:Success())
31 assertTrue(self
.process
:IsValid())
34 function _T
:Test3_BreakpointFindVariables()
35 -- checking "argc" value
36 local thread
= get_stopped_thread(self
.process
, lldb
.eStopReasonBreakpoint
)
38 assertTrue(thread
:IsValid())
39 local frame
= thread
:GetFrameAtIndex(0)
40 assertTrue(frame
:IsValid())
41 local error = lldb
.SBError()
42 local var_argc
= frame
:FindVariable('argc')
43 assertTrue(var_argc
:IsValid())
44 local var_argc_value
= var_argc
:GetValueAsSigned(error, 0)
45 assertTrue(error:Success())
46 assertEquals(var_argc_value
, 2)
48 -- checking "inited" value
49 local continue
= self
.process
:Continue()
50 assertTrue(continue
:Success())
51 thread
= get_stopped_thread(self
.process
, lldb
.eStopReasonBreakpoint
)
53 assertTrue(thread
:IsValid())
54 frame
= thread
:GetFrameAtIndex(0)
55 assertTrue(frame
:IsValid())
56 error = lldb
.SBError()
57 local var_inited
= frame
:FindVariable('inited')
58 assertTrue(var_inited
:IsValid())
59 self
.var_inited
= var_inited
60 local var_inited_value
= var_inited
:GetValueAsUnsigned(error, 0)
61 assertTrue(error:Success())
62 assertEquals(var_inited_value
, 0xDEADBEEF)
65 function _T
:Test3_RawData()
66 local error = lldb
.SBError()
67 local address
= self
.var_inited
:GetAddress()
68 assertTrue(address
:IsValid())
69 local size
= self
.var_inited
:GetByteSize()
70 local raw_data
= self
.process
:ReadMemory(address
:GetOffset(), size
, error)
71 assertTrue(error:Success())
72 local data_le
= lldb
.SBData
.CreateDataFromUInt32Array(lldb
.eByteOrderLittle
, 1, {0xDEADBEEF})
73 local data_be
= lldb
.SBData
.CreateDataFromUInt32Array(lldb
.eByteOrderBig
, 1, {0xDEADBEEF})
74 assertTrue(data_le
:GetUnsignedInt32(error, 0) == 0xDEADBEEF or data_be
:GetUnsignedInt32(error, 0) == 0xDEADBEEF)
75 assertTrue(raw_data
== "\xEF\xBE\xAD\xDE" or raw_data
== "\xDE\xAD\xBE\xEF")
78 function _T
:Test4_ProcessExit()
79 self
.loop_bp
:SetAutoContinue(true)
80 local continue
= self
.process
:Continue()
81 assertTrue(continue
:Success())
82 assertTrue(self
.process
:GetExitStatus() == 0)
85 function _T
:Test5_FileOutput()
86 local f
= io
.open(self
.output
, 'r')
88 read_file_non_empty_lines(f
),
91 table.unpack(self
.args
),