diff options
| author | Ebuka Ezike <yerimyah1@gmail.com> | 2025-10-30 21:43:53 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-30 21:43:53 +0000 |
| commit | c46bfed1a484d30cd251a9a225649d74e3bf0af5 (patch) | |
| tree | 6b1beefe494e0e518a2eaee28e9f87526c565b19 /lldb/test/API/lua_api/TestThreadAPI.lua | |
| parent | 6c1678abce2c31b0db22634aa19368095a75ca77 (diff) | |
| download | llvm-c46bfed1a484d30cd251a9a225649d74e3bf0af5.zip llvm-c46bfed1a484d30cd251a9a225649d74e3bf0af5.tar.gz llvm-c46bfed1a484d30cd251a9a225649d74e3bf0af5.tar.bz2 | |
[lldb] Add alternative SBThread::GetStopDescription (#165379)
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.
Diffstat (limited to 'lldb/test/API/lua_api/TestThreadAPI.lua')
| -rw-r--r-- | lldb/test/API/lua_api/TestThreadAPI.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lldb/test/API/lua_api/TestThreadAPI.lua b/lldb/test/API/lua_api/TestThreadAPI.lua new file mode 100644 index 0000000..5a38d0b --- /dev/null +++ b/lldb/test/API/lua_api/TestThreadAPI.lua @@ -0,0 +1,25 @@ +_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()) |
