Open llvmbot opened 10 years ago
Also: the ellipsis in the template example should be read as literal text. So, to match an indirect call from f to g through zero or more frames, use:
(lldb) stackpat fg
g ... f DONE
Then break in direct callees of g() with:
(lldb) br set -n helper_bar --stackpat=fg (lldb) br set -n helper_baz --stackpat=fg
Extended Description
Suppose a future lldb provides a built-in command, 'stackpat', which takes a name argument that can later be used to refer to a pattern---given as a multi-line sequence when the command is entered---that matches zero or more stacks.
As a convenience, stackpat would also take an option, -b, that causes the topmost frame of the pattern to be implicitly passed either to 'br set' or to _regexp-break.
Example session:
% cat -n foo.c 1 void h() {} 2 void g() { h(); } 3 void f() { h(); g(); } 4 int main(int argc, char *argv[]) 5 { 6 h(); 7 g(); 8 f(); 9 return 0; 10 } % cc -g foo.c -o a.out % lldb -x ./a.out Current executable set to './a.out' (x86_64). (lldb) stackpat x -b Enter frame patterns (just like args to 'breakpoint set' or 'b'). Type DONE to end.
Here's an example with C++, where it isn't always clear which template arguments you want to use in the function name regex. Example:
% cat -n foo.cpp 1 2 namespace Some_lib_impl 3 { 4 struct apparently_unrelated_class {}; 5 } 6 7 namespace N 8 { 9 template
10 struct stuff { typedef Some_lib_impl::apparently_unrelated_class U; };
11 } / N /
12
13
14 template void tn() {}
15 template void t2() { tn< typename N::stuff::U >(); }
16 template void t1() { t2(); }
17 template void t0() { t1(); }
18 int main(int argc, char *argv[])
19 {
20 tn();
21 t0();
22 return 0;
23 }
% cc -g foo.cpp
% lldb -x ./a.out
Current executable set to './a.out' (x86_64).
(lldb) stackpat y -b
Enter frame patterns (just like args to 'breakpoint set' or 'b'). Type DONE to end.
The stackpat name ("x", "y" above) could then be re-used in other 'br set' commands or in other stackpat commands.