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/API/SBTarget.cpp | |
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/API/SBTarget.cpp')
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2ef8bcdf39a..220e136430d 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBStringList.h" #include "lldb/API/SBSymbolContextList.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointIDList.h" @@ -1124,42 +1125,21 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name) { - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - SBBreakpoint sb_bp; - TargetSP target_sp(GetSP()); - if (target_sp && source_regex && source_regex[0]) - { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - RegularExpression regexp(source_regex); - FileSpecList source_file_spec_list; - const bool hardware = false; - const LazyBool move_to_nearest_code = eLazyBoolCalculate; - source_file_spec_list.Append (source_file.ref()); + SBFileSpecList module_spec_list; if (module_name && module_name[0]) { - FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - - *sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false, hardware, move_to_nearest_code); } - else + + SBFileSpecList source_file_list; + if (source_file.IsValid()) { - *sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false, hardware, move_to_nearest_code); + source_file_list.Append(source_file); } - } - - if (log) - { - char path[PATH_MAX]; - source_file->GetPath (path, sizeof(path)); - log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", - static_cast<void*>(target_sp.get()), source_regex, path, - module_name, static_cast<void*>(sb_bp.get())); - } + + return BreakpointCreateBySourceRegex (source_regex, module_spec_list, source_file_list); - return sb_bp; } lldb::SBBreakpoint @@ -1167,6 +1147,15 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const SBFileSpecList &module_list, const lldb::SBFileSpecList &source_file_list) { + return BreakpointCreateBySourceRegex(source_regex, module_list, source_file_list, SBStringList()); +} + +lldb::SBBreakpoint +SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, + const SBFileSpecList &module_list, + const lldb::SBFileSpecList &source_file_list, + const SBStringList &func_names) +{ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; @@ -1177,7 +1166,19 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const bool hardware = false; const LazyBool move_to_nearest_code = eLazyBoolCalculate; RegularExpression regexp(source_regex); - *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false, hardware, move_to_nearest_code); + std::unordered_set<std::string> func_names_set; + for (size_t i = 0; i < func_names.GetSize(); i++) + { + func_names_set.insert(func_names.GetStringAtIndex(i)); + } + + *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), + source_file_list.get(), + func_names_set, + regexp, + false, + hardware, + move_to_nearest_code); } if (log) |