diff options
author | Jim Ingham <jingham@apple.com> | 2016-04-28 01:40:57 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2016-04-28 01:40:57 +0000 |
commit | 76bb8d6719c2f664a69c4e2e89664c230f807a3b (patch) | |
tree | 23cecaf99000645d1da0f8027fa7b2cd61e843ae /lldb/source/Breakpoint | |
parent | 8bdcd522510f923185cdfaec66c4a78d0a0d38c0 (diff) | |
download | bcm5719-llvm-76bb8d6719c2f664a69c4e2e89664c230f807a3b.tar.gz bcm5719-llvm-76bb8d6719c2f664a69c4e2e89664c230f807a3b.zip |
Add the ability to limit "source regexp" breakpoints to a particular function
within a source file.
This isn't done, I need to make the name match smarter (right now it requires an
exact match which is annoying for methods of a class in a namespace.
Also, though we use it in tests all over the place, it doesn't look like we have
a test for Source Regexp breakpoints by themselves, I'll add that in a follow-on patch.
llvm-svn: 267834
Diffstat (limited to 'lldb/source/Breakpoint')
-rw-r--r-- | lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp index e7bce0524c5..ae7f58acb91 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -30,11 +30,13 @@ BreakpointResolverFileRegex::BreakpointResolverFileRegex ( Breakpoint *bkpt, RegularExpression ®ex, + const std::unordered_set<std::string> &func_names, bool exact_match ) : BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver), m_regex (regex), - m_exact_match (exact_match) + m_exact_match (exact_match), + m_function_names(func_names) { } @@ -68,6 +70,32 @@ BreakpointResolverFileRegex::SearchCallback const bool search_inlines = false; cu->ResolveSymbolContext (cu_file_spec, line_matches[i], search_inlines, m_exact_match, eSymbolContextEverything, sc_list); + // Find all the function names: + if (!m_function_names.empty()) + { + std::vector<size_t> sc_to_remove; + for (size_t i = 0; i < sc_list.GetSize(); i++) + { + SymbolContext sc_ctx; + sc_list.GetContextAtIndex(i, sc_ctx); + std::string name(sc_ctx.GetFunctionName(Mangled::NamePreference::ePreferDemangledWithoutArguments).AsCString()); + if (!m_function_names.count(name)) + { + sc_to_remove.push_back(i); + } + } + + if (!sc_to_remove.empty()) + { + std::vector<size_t>::reverse_iterator iter; + std::vector<size_t>::reverse_iterator rend = sc_to_remove.rend(); + for (iter = sc_to_remove.rbegin(); iter != rend; iter++) + { + sc_list.RemoveContextAtIndex(*iter); + } + } + } + const bool skip_prologue = true; BreakpointResolver::SetSCMatchesByLine (filter, sc_list, skip_prologue, m_regex.GetText()); @@ -98,7 +126,13 @@ BreakpointResolverFileRegex::Dump (Stream *s) const lldb::BreakpointResolverSP BreakpointResolverFileRegex::CopyForBreakpoint (Breakpoint &breakpoint) { - lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(&breakpoint, m_regex, m_exact_match)); + lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(&breakpoint, m_regex, m_function_names, m_exact_match)); return ret_sp; } +void +BreakpointResolverFileRegex::AddFunctionName(const char *func_name) +{ + m_function_names.insert(func_name); +} + |