Reputation: 162
I'm trying to step through a big project >100k loc but only care about interactions with lib. Is there a way to get lldb to break on all functions declarations in once source file?
So far I've tried doing
br s -f <file> --func-regex .*
with info from gdb to lldb and gdb solution but that appears to be breaking on all function calls in the file which causes 5129 matches for a 4911 line source file.
A possible solution could be to do source regex matching to find function calls via
br s -f --source-pattern-regexp
but given C++'s ridiculous parsing rules, a regex that matches all cases is impossible.
Upvotes: 3
Views: 2351
Reputation: 27110
The -f
specification really limits the breakpoint search to the Compilation Unit defined by <file>
and so it ends up including all the template instantiations that that Compilation Unit contains, which if you use any std::
stuff is generally a lot, as you have discovered.
The debugger generally does know where a function was declared (it is part of the debug info) so we could add an option to treat -f as "file of declaration" not "comp unit name". Then you could say something like:
(lldb) break set -f foo.h -f foo.cpp --match-declaration-file --func-regex .*
That would be pretty straight forward to add. If you're so inclined, please file an enhancement request to this effect to http://bugreporter.apple.com.
If you follow the convention of writing your functions like:
void A::foo()
{
...
}
Then you can do a source regex on "^{". That was the primary reason for this coding convention, it made the beginnings of functions really easy to pick out.
If the template instantiations are mostly coming from std, you could find the .o file and do something like (this is on OS X):
$ nm <file-basename>.o -s __TEXT __text -j | c++filt | grep -v std
That will produce a list of the non-std functions in this .o file, and then you could add break set -n
to the beginning of each line and source that in.
Upvotes: 3