the function signature for `GetStopDescription` is `lldb::SBThread::GetStopDescription(char *dst_or_null, size_t len)`. To get a description you need to call the function first time to get the buffer size. a second time to get the description. This is little worse from the python size as the signature is `lldb.SBThread.GetStopDescription(int: len) -> list[str]` the user has to pass the max size as possible with no way of checking if it is enough. This patch adds a new api `lldb.SBThread.GetStopDescription(desc: lldb.SBStream()) -> bool` `bool lldb::SBThread::GetStopDescription(lldb::SBStream &description)` which handles this case. Adds new Test case for lua.
26 lines
1.0 KiB
Lua
26 lines
1.0 KiB
Lua
_T = require('lua_lldb_test').create_test('TestThreadAPI')
|
|
|
|
function _T:TestGetStopDescription()
|
|
local target = self:create_target()
|
|
local breakpoint = target:BreakpointCreateByName("main", "a.out")
|
|
assertTrue(breakpoint:IsValid() and breakpoint:GetNumLocations() == 1)
|
|
|
|
local process = target:LaunchSimple({ 'arg1', 'arg2' }, nil, nil)
|
|
local thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
|
|
assertNotNil(thread)
|
|
assertTrue(thread:IsValid())
|
|
|
|
assertEqual("breakpoint", thread:GetStopDescription(string.len("breakpoint") + 1))
|
|
assertEqual("break", thread:GetStopDescription(string.len("break") + 1))
|
|
assertEqual("b", thread:GetStopDescription(string.len("b") + 1))
|
|
assertEqual("breakpoint 1.1", thread:GetStopDescription(string.len("breakpoint 1.1") + 100))
|
|
|
|
-- Test stream variation
|
|
local stream = lldb.SBStream()
|
|
assertTrue(thread:GetStopDescription(stream))
|
|
assertNotNil(stream)
|
|
assertEqual("breakpoint 1.1", stream:GetData())
|
|
end
|
|
|
|
os.exit(_T:run())
|