From 76bb8d6719c2f664a69c4e2e89664c230f807a3b Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 28 Apr 2016 01:40:57 +0000 Subject: 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 --- lldb/source/API/SBTarget.cpp | 59 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'lldb/source/API/SBTarget.cpp') 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,48 +1125,36 @@ 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(target_sp.get()), source_regex, path, - module_name, static_cast(sb_bp.get())); - } + + return BreakpointCreateBySourceRegex (source_regex, module_spec_list, source_file_list); - return sb_bp; } lldb::SBBreakpoint 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)); @@ -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 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) -- cgit v1.2.3