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
This commit is contained in:
Jim Ingham
2016-04-28 01:40:57 +00:00
parent 8bdcd52251
commit 76bb8d6719
10 changed files with 118 additions and 34 deletions

View File

@@ -30,11 +30,13 @@ BreakpointResolverFileRegex::BreakpointResolverFileRegex
(
Breakpoint *bkpt,
RegularExpression &regex,
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);
}