diff --git a/src/resource.qrc b/src/resource.qrc index e0ee15e..0b59f41 100644 --- a/src/resource.qrc +++ b/src/resource.qrc @@ -87,6 +87,7 @@ resources/mi-python/MICheckpoint.py resources/mi-python/MICatchpoint.py resources/mi-python/MIObjectiveC.py + resources/mi-python/MIFrames.py diff --git a/tests/hellothreads2/.gitignore b/tests/hellothreads2/.gitignore index 3c4c320..f642e25 100644 --- a/tests/hellothreads2/.gitignore +++ b/tests/hellothreads2/.gitignore @@ -1,2 +1,3 @@ hellothreads2 Digraph.* +DirectedGraph.* diff --git a/tests/hellothreads2/Makefile b/tests/hellothreads2/Makefile index 8077b3a..113930c 100644 --- a/tests/hellothreads2/Makefile +++ b/tests/hellothreads2/Makefile @@ -17,5 +17,5 @@ install: # This rule tells make to delete hellothreads2 and hellothreads2.o .PHONY: clean clean: - rm -f hellothreads2 hellothreads2.o + rm -f hellothreads2 hellothreads2.o Digraph.* diff --git a/tests/hellothreads2/README b/tests/hellothreads2/README new file mode 100644 index 0000000..c6b140b --- /dev/null +++ b/tests/hellothreads2/README @@ -0,0 +1,119 @@ + +This test plays around with the "parallel-stacks" program that generates a PDF file +that contains a graph of threads, including their trace back. + +Run the test program. + + $ cd /nas/erniep/Development/seer/tests/hellothreads2 + $ seergdb --project project.seer + +After continuing and breaking at the first breakpoint that 'joins', run this command +in Seer's gdb command input. + + pipe thread apply all bt | python3 parallel-stacks.py + +It will run the script and view the parallel-stacks pdf. + + +Parsed output from gdb from the 'pipe' command. + + + $ python3 parallel-stacks.py -p 22900 + Thread 10 + level: 0, address: '0x00007f84094f0f05', function: 'clock_nanosleep@GLIBC_2.2.5', parameters: '', filename: '/lib64/libc.so.6' + level: 1, address: '0x00007f8409503b13', function: 'nanosleep', parameters: '', filename: '/lib64/libc.so.6' + level: 2, address: '0x00007f840951517a', function: 'sleep', parameters: '', filename: '/lib64/libc.so.6' + level: 3, address: '0x0000562f5846609f', function: 'operator()', parameters: '__closure=0x562f8e11c1c8, x=3', filename: 'hellothreads2.cpp:55' + level: 4, address: '0x0000562f584667ec', function: 'std::__invoke_impl, int>(std::__invoke_other, struct {...} &&)', parameters: '__f=...', filename: '/usr/include/c++/13/bits/invoke.h:61' + level: 5, address: '0x0000562f58466785', function: 'std::__invoke, int>(struct {...} &&)', parameters: '__fn=...', filename: '/usr/include/c++/13/bits/invoke.h:96' + level: 6, address: '0x0000562f584666f5', function: 'std::thread::_Invoker, int> >::_M_invoke<0, 1>(std::_Index_tuple<0, 1>)', parameters: 'this=0x562f8e11c1c8', filename: '/usr/include/c++/13/bits/std_thread.h:292' + level: 7, address: '0x0000562f584666ae', function: 'std::thread::_Invoker, int> >::operator()(void)', parameters: 'this=0x562f8e11c1c8', filename: '/usr/include/c++/13/bits/std_thread.h:299' + level: 8, address: '0x0000562f58466692', function: 'std::thread::_State_impl, int> > >::_M_run(void)', parameters: 'this=0x562f8e11c1c0', filename: '/usr/include/c++/13/bits/std_thread.h:244' + level: 9, address: '0x00007f84098e8964', function: '??', parameters: '', filename: '/usr/local/lib64/libstdc++.so.6' + level: 10, address: '0x00007f84094a6f6c', function: 'start_thread', parameters: '', filename: '/lib64/libc.so.6' + level: 11, address: '0x00007f840952e388', function: 'clone3', parameters: '', filename: '/lib64/libc.so.6' + Thread 9 + level: 0, address: '0x00007f84094f0f05', function: 'clock_nanosleep@GLIBC_2.2.5', parameters: '', filename: '/lib64/libc.so.6' + level: 1, address: '0x00007f8409503b13', function: 'nanosleep', parameters: '', filename: '/lib64/libc.so.6' + level: 2, address: '0x00007f840951517a', function: 'sleep', parameters: '', filename: '/lib64/libc.so.6' + level: 3, address: '0x0000562f584668fb', function: 'thread_obj::operator()', parameters: 'this=0x562f8e11c068, x=3', filename: 'hellothreads2.cpp:25' + level: 4, address: '0x0000562f58467490', function: 'std::__invoke_impl', parameters: '__f=...', filename: '/usr/include/c++/13/bits/invoke.h:61' + level: 5, address: '0x0000562f5846738d', function: 'std::__invoke', parameters: '__fn=...', filename: '/usr/include/c++/13/bits/invoke.h:96' + level: 6, address: '0x0000562f584672b3', function: 'std::thread::_Invoker >::_M_invoke<0ul, 1ul>', parameters: 'this=0x562f8e11c068', filename: '/usr/include/c++/13/bits/std_thread.h:292' + level: 7, address: '0x0000562f58467250', function: 'std::thread::_Invoker >::operator()', parameters: 'this=0x562f8e11c068', filename: '/usr/include/c++/13/bits/std_thread.h:299' + level: 8, address: '0x0000562f58467214', function: 'std::thread::_State_impl > >::_M_run', parameters: 'this=0x562f8e11c060', filename: '/usr/include/c++/13/bits/std_thread.h:244' + level: 9, address: '0x00007f84098e8964', function: '??', parameters: '', filename: '/usr/local/lib64/libstdc++.so.6' + level: 10, address: '0x00007f84094a6f6c', function: 'start_thread', parameters: '', filename: '/lib64/libc.so.6' + level: 11, address: '0x00007f840952e388', function: 'clone3', parameters: '', filename: '/lib64/libc.so.6' + +Output from '-thread-info' command doesn't cut it. Only the first frame. + + ^done,threads=[ + {id="1",target-id="Thread 0x7ffff7e7d740 (LWP 23678)",name="hellothreads2", + frame={level="0",addr="0x00005555555551f6",func="main",args=[],file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="64",arch="i386:x86-64"},state="stopped",core="1"}, + {id="2",target-id="Thread 0x7ffff77ff6c0 (LWP 23681)",name="hellothreads2", + frame={level="0",addr="0x00007ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",args=[],from="/lib64/libc.so.6",arch="i386:x86-64"},state="stopped",core="3"}, + +Output from 'thread apply all bt' + + thread apply all bt + + Thread 9 (Thread 0x7ffff3ff86c0 (LWP 24364) "hellothreads2"): + #0 0x00007ffff78f0f05 in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6 + #1 0x00007ffff7903b13 in nanosleep () from /lib64/libc.so.6 + #2 0x00007ffff791517a in sleep () from /lib64/libc.so.6 + #3 0x00005555555558fb in thread_obj::operator() (this=0x55555556d068, x=3) at hellothreads2.cpp:25 + #4 0x0000555555556490 in std::__invoke_impl (__f=...) at /usr/include/c++/13/bits/invoke.h:61 + #5 0x000055555555638d in std::__invoke (__fn=...) at /usr/include/c++/13/bits/invoke.h:96 + #6 0x00005555555562b3 in std::thread::_Invoker >::_M_invoke<0ul, 1ul> (this=0x55555556d068) at /usr/include/c++/13/bits/std_thread.h:292 + #7 0x0000555555556250 in std::thread::_Invoker >::operator() (this=0x55555556d068) at /usr/include/c++/13/bits/std_thread.h:299 + #8 0x0000555555556214 in std::thread::_State_impl > >::_M_run (this=0x55555556d060) at /usr/include/c++/13/bits/std_thread.h:244 + #9 0x00007ffff7ce8964 in ?? () from /usr/local/lib64/libstdc++.so.6 + #10 0x00007ffff78a6f6c in start_thread () from /lib64/libc.so.6 + #11 0x00007ffff792e388 in clone3 () from /lib64/libc.so.6 + + Thread 8 (Thread 0x7ffff47f96c0 (LWP 24363) "hellothreads2"): + #0 0x00007ffff78f0f05 in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6 + #1 0x00007ffff7903b13 in nanosleep () from /lib64/libc.so.6 + #2 0x00007ffff791517a in sleep () from /lib64/libc.so.6 + #3 0x00005555555558fb in thread_obj::operator() (this=0x55555556cf08, x=3) at hellothreads2.cpp:25 + #4 0x0000555555556490 in std::__invoke_impl (__f=...) at /usr/include/c++/13/bits/invoke.h:61 + #5 0x000055555555638d in std::__invoke (__fn=...) at /usr/include/c++/13/bits/invoke.h:96 + #6 0x00005555555562b3 in std::thread::_Invoker >::_M_invoke<0ul, 1ul> (this=0x55555556cf08) at /usr/include/c++/13/bits/std_thread.h:292 + #7 0x0000555555556250 in std::thread::_Invoker >::operator() (this=0x55555556cf08) at /usr/include/c++/13/bits/std_thread.h:299 + #8 0x0000555555556214 in std::thread::_State_impl > >::_M_run (this=0x55555556cf00) at /usr/include/c++/13/bits/std_thread.h:244 + #9 0x00007ffff7ce8964 in ?? () from /usr/local/lib64/libstdc++.so.6 + #10 0x00007ffff78a6f6c in start_thread () from /lib64/libc.so.6 + #11 0x00007ffff792e388 in clone3 () from /lib64/libc.so.6 + +Output from 'frames-list' + + ^done,threads=[ + {id="10",target-id="(28429, 28440, 0)",name="hellothreads2",state="stopped",current="0",frames=[ + {level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}, + {level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}, + {level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}, + {level="3",addr="0x555555555089",func="operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="53",type="normal"}, + {level="4",addr="0x5555555557ec",func="std::__invoke_impl, int>(std::__invoke_other, struct {...} &&)",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"}, + {level="5",addr="0x555555555785",func="std::__invoke, int>(struct {...} &&)",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"}, + {level="6",addr="0x5555555556f5",func="std::thread::_Invoker, int> >::_M_invoke<0, 1>(std::_Index_tuple<0, 1>)",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"}, + {level="7",addr="0x5555555556ae",func="std::thread::_Invoker, int> >::operator()(void)",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"}, + {level="8",addr="0x555555555692",func="std::thread::_State_impl, int> > >::_M_run(void)",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"}, + {level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"}, + {level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}, + {level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="8",target-id="(28429, 28438, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x5555555558fb",func="thread_obj::operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="25",type="normal"},{level="4",addr="0x555555556490",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555638d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562b3",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x555555556250",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556214",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="7",target-id="(28429, 28437, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x5555555558fb",func="thread_obj::operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="25",type="normal"},{level="4",addr="0x555555556490",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555638d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562b3",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x555555556250",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556214",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="6",target-id="(28429, 28436, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x5555555558fb",func="thread_obj::operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="25",type="normal"},{level="4",addr="0x555555556490",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555638d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562b3",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x555555556250",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556214",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="5",target-id="(28429, 28435, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x5555555558fb",func="thread_obj::operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="25",type="normal"},{level="4",addr="0x555555556490",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555638d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562b3",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x555555556250",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556214",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="9",target-id="(28429, 28439, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x5555555558fb",func="thread_obj::operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="25",type="normal"},{level="4",addr="0x555555556490",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555638d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562b3",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x555555556250",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556214",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="4",target-id="(28429, 28434, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x5555555558fb",func="thread_obj::operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="25",type="normal"},{level="4",addr="0x555555556490",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555638d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562b3",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x555555556250",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556214",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="3",target-id="(28429, 28433, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x5555555558fb",func="thread_obj::operator()",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="25",type="normal"},{level="4",addr="0x555555556490",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555638d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562b3",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x555555556250",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556214",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="2",target-id="(28429, 28432, 0)",name="hellothreads2",state="stopped",current="0",frames=[{level="0",addr="0x7ffff78f0f05",func="clock_nanosleep@GLIBC_2.2.5",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="1",addr="0x7ffff7903b13",func="nanosleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="2",addr="0x7ffff791517a",func="sleep",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="3",addr="0x555555555023",func="foo",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="14",type="normal"},{level="4",addr="0x5555555564f1",func="std::__invoke_impl",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="61",type="normal"},{level="5",addr="0x55555555641d",func="std::__invoke",arch="i386:x86-64",file="/usr/include/c++/13/bits/invoke.h",fullname="/usr/include/c++/13/bits/invoke.h",line="96",type="normal"},{level="6",addr="0x5555555562fd",func="std::thread::_Invoker >::_M_invoke<0ul, 1ul>",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="292",type="normal"},{level="7",addr="0x55555555626c",func="std::thread::_Invoker >::operator()",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="299",type="normal"},{level="8",addr="0x555555556234",func="std::thread::_State_impl > >::_M_run",arch="i386:x86-64",file="/usr/include/c++/13/bits/std_thread.h",fullname="/usr/include/c++/13/bits/std_thread.h",line="244",type="normal"},{level="9",addr="0x7ffff7ce8964",func="??",arch="i386:x86-64",from="/usr/local/lib64/libstdc++.so.6",type="normal"},{level="10",addr="0x7ffff78a6f6c",func="start_thread",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"},{level="11",addr="0x7ffff792e388",func="clone3",arch="i386:x86-64",from="/lib64/libc.so.6",type="normal"}]}, + {id="1",target-id="(28429, 28429, 0)",name="hellothreads2",state="stopped",current="1",frames=[{level="0",addr="0x5555555551f6",func="main",arch="i386:x86-64",file="hellothreads2.cpp",fullname="/nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp",line="64",type="normal"}]} + ], + current_thread_id="1", + current_frame_level="0", + total_threads="10", + total_frames="109" + diff --git a/tests/hellothreads2/breakpoints.seer b/tests/hellothreads2/breakpoints.seer new file mode 100644 index 0000000..d3c28e5 --- /dev/null +++ b/tests/hellothreads2/breakpoints.seer @@ -0,0 +1 @@ +break -source /nas/erniep/Development/seer/tests/hellothreads2/hellothreads2.cpp -line 64 diff --git a/tests/hellothreads2/hellothreads2.cpp b/tests/hellothreads2/hellothreads2.cpp index b7ab645..27c28a1 100644 --- a/tests/hellothreads2/hellothreads2.cpp +++ b/tests/hellothreads2/hellothreads2.cpp @@ -11,7 +11,7 @@ void foo(int Z) { for (int i = 0; i < Z; i++) { std::cout << "Thread using function pointer as callable" << std::endl; - sleep(2); + sleep(20); } sleep(5); } @@ -22,9 +22,9 @@ class thread_obj { void operator()(int x) { for (int i = 0; i < x; i++) { std::cout << "Thread using function object as callable" << std::endl; - sleep(3); + sleep(30); } - sleep(1); + sleep(5); } }; diff --git a/tests/hellothreads2/parallel-stacks.py b/tests/hellothreads2/parallel-stacks.py index 537cb74..1b2154e 100644 --- a/tests/hellothreads2/parallel-stacks.py +++ b/tests/hellothreads2/parallel-stacks.py @@ -109,10 +109,10 @@ def print_parallel_stack(node, first_node=True, indent='', last_node=False): function_indent = indent + ('' if last_node else '│') + base_indent if first_node: thread_count = len(node.threads) - print(before_thread_indent) - print('{}Threads: {}'.format(thread_indent, thread_count)) + print(before_thread_indent, file=sys.stderr) + print('{}Threads: {}'.format(thread_indent, thread_count, file=sys.stderr)) if node.function: - print('{}{}'.format(function_indent, node.function)) + print('{}{}'.format(function_indent, node.function, file=sys.stderr)) if len(node.nodes) == 1: print_parallel_stack(node.nodes[0], False, indent, last_node) return @@ -178,11 +178,9 @@ def get_graph(node): def main(): - arg_parser = argparse.ArgumentParser(description='Shows Parallel Stacks of a Process', - epilog='Data sources are a process, a log file or standard input.') + arg_parser = argparse.ArgumentParser(description='Shows Parallel Stacks of a Process', epilog='Data sources are a process, a log file or standard input.') data_source_group = arg_parser.add_mutually_exclusive_group() - data_source_group.add_argument('-l', '--log_file', metavar='filename', help='a GDB log file with backtraces', - type=argparse.FileType('r'), default=sys.stdin) + data_source_group.add_argument('-l', '--log_file', metavar='filename', help='a GDB log file with backtraces', type=argparse.FileType('r'), default=sys.stdin) data_source_group.add_argument('-p', '--pid', type=int, required=False, help='a process ID') args = arg_parser.parse_args() @@ -197,12 +195,12 @@ def main(): gdb_output = input_file.read().splitlines() threads = parse_gdb_output(gdb_output) for thread in threads: - print(thread) + print(thread, file=sys.stderr) tree = get_parallel_stacks(threads) print_parallel_stack(tree) - get_graph(tree).render(view=True) - #print(get_graph(tree).source) + get_graph(tree).render('DirectedGraph.gv', view=True, format='png') + print(get_graph(tree).source, file=sys.stderr) if __name__ == "__main__": diff --git a/tests/hellothreads2/project.seer b/tests/hellothreads2/project.seer new file mode 100644 index 0000000..c0756a8 --- /dev/null +++ b/tests/hellothreads2/project.seer @@ -0,0 +1,24 @@ +{ + "seerproject": { + "executable": "hellothreads2", + "postgdbcommands": [ + "" + ], + "pregdbcommands": [ + "" + ], + "startmode": { + "arguments": "", + "breakinfunction": false, + "breakinfunctionname": "", + "breakinmain": true, + "breakpointsfile": "/nas/erniep/Development/seer/tests/hellothreads2/breakpoints.seer", + "nobreak": false, + "nonstopmode": false, + "randomizestartaddress": false, + "showassemblytabmode": "auto" + }, + "symbolfile": "", + "workingdirectory": "" + } +}