diff options
author | Chuck Ries <chuckr@microsoft.com> | 2016-04-08 22:17:53 +0000 |
---|---|---|
committer | Chuck Ries <chuckr@microsoft.com> | 2016-04-08 22:17:53 +0000 |
commit | da21e98932d5b31375b9b934ad8e322e4c76c74c (patch) | |
tree | ea927e0dd330f76c4710c1067a2b3f25764b6548 /lldb/packages/Python/lldbsuite/test | |
parent | f144b54a91e5fc567ad0d087bead77bfe3e0b36d (diff) | |
download | bcm5719-llvm-da21e98932d5b31375b9b934ad8e322e4c76c74c.tar.gz bcm5719-llvm-da21e98932d5b31375b9b934ad8e322e4c76c74c.zip |
-thread-info in lldbmi does not conform to protocol. Should end with current thread id
-thread-info in lldbmi does not conform to protocol. Should end with
current thread id as described here:
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Thread-Commands.html#GDB_002fMI-Thread-Commands
When printing all threads, the current thread id should be printed
afterwards.
Example:
-thread-info
^done,threads=[
{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",
args=[]},state="running"},
{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
frame={level="0",addr="0x0804891f",func="foo",
args=[{name="i",value="10"}],
file="/tmp/a.c",fullname="/tmp/a.c",line="158"},
state="running"}],
current-thread-id="1"
(gdb)
Patch from jacdavis@microsoft.com
Reviewers: zturner, chuckr
Differential Revision: http://reviews.llvm.org/differential/revision/edit/18880/
llvm-svn: 265858
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
3 files changed, 67 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/Makefile b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/Makefile new file mode 100644 index 00000000000..2796efd60eb --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +LDFLAGS=-pthread + +CXX_SOURCES := test_threadinfo.cpp + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py new file mode 100644 index 00000000000..7226f2e8d32 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py @@ -0,0 +1,39 @@ +""" +Test lldb-mi -thread-info command. +""" + +from __future__ import print_function + +import lldbmi_testcase +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class MiThreadInfoTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows # pthreads not supported on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_thread_info(self): + """Test that -thread-info prints thread info and the current-thread-id""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + self.runCmd("-break-insert ThreadProc") + self.expect("\^done") + + # Run to the breakpoint + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + self.runCmd("-thread-info") + self.expect("\^done,threads=\[\{id=\"1\",(.*)\},\{id=\"2\",(.*)\],current-thread-id=\"2\"") + + self.runCmd("-gdb-quit") + diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/test_threadinfo.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/test_threadinfo.cpp new file mode 100644 index 00000000000..1f444ece8c2 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/test_threadinfo.cpp @@ -0,0 +1,21 @@ +#include <cstdlib> +#include <iostream> +#include <thread> + +using namespace std; + +void +ThreadProc() +{ + int i = 0; + i++; +} + +int +main() +{ + thread t(ThreadProc); + t.join(); + + return 0; +} |