[Lldb-commits] [lldb] r228938 - Add an -A option to "break set -p" to search all files for matches. Also add the version of
Jim Ingham
jingham at apple.com
Thu Feb 12 09:37:46 PST 2015
Author: jingham
Date: Thu Feb 12 11:37:46 2015
New Revision: 228938
URL: http://llvm.org/viewvc/llvm-project?rev=228938&view=rev
Log:
Add an -A option to "break set -p" to search all files for matches. Also add the version of
SBTarget::BreakpointCreateBySourceRegex that takes file spec lists to the Python interface,
and add a test for this.
<rdar://problem/19805037>
Modified:
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/scripts/Python/interface/SBTarget.i
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=228938&r1=228937&r2=228938&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Thu Feb 12 11:37:46 2015
@@ -764,13 +764,13 @@ public:
lldb::SBBreakpoint
BreakpointCreateBySourceRegex (const char *source_regex,
- const lldb::SBFileSpec &source_file,
+ const SBFileSpec &source_file,
const char *module_name = NULL);
lldb::SBBreakpoint
- BreakpointCreateBySourceRegex (const char *source_regex,
- const SBFileSpecList &module_list,
- const lldb::SBFileSpecList &source_file);
+ BreakpointCreateBySourceRegex (const char *source_regex,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &source_file);
lldb::SBBreakpoint
BreakpointCreateForException (lldb::LanguageType language,
Modified: lldb/trunk/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=228938&r1=228937&r2=228938&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTarget.i Thu Feb 12 11:37:46 2015
@@ -695,6 +695,9 @@ public:
BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
lldb::SBBreakpoint
+ BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list);
+
+ lldb::SBBreakpoint
BreakpointCreateForException (lldb::LanguageType language,
bool catch_bp,
bool throw_bp);
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=228938&r1=228937&r2=228938&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Thu Feb 12 11:37:46 2015
@@ -1277,9 +1277,9 @@ SBTarget::BreakpointCreateBySourceRegex
}
lldb::SBBreakpoint
-SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
- const SBFileSpecList &module_list,
- const lldb::SBFileSpecList &source_file_list)
+SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
+ const SBFileSpecList &module_list,
+ const lldb::SBFileSpecList &source_file_list)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=228938&r1=228937&r2=228938&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Thu Feb 12 11:37:46 2015
@@ -112,7 +112,8 @@ public:
m_hardware (false),
m_language (eLanguageTypeUnknown),
m_skip_prologue (eLazyBoolCalculate),
- m_one_shot (false)
+ m_one_shot (false),
+ m_all_files (false)
{
}
@@ -135,6 +136,10 @@ public:
}
break;
+ case 'A':
+ m_all_files = true;
+ break;
+
case 'b':
m_func_names.push_back (option_arg);
m_func_name_type_mask |= eFunctionNameTypeBase;
@@ -339,6 +344,7 @@ public:
m_one_shot = false;
m_use_dummy = false;
m_breakpoint_names.clear();
+ m_all_files = false;
}
const OptionDefinition*
@@ -376,6 +382,7 @@ public:
LazyBool m_skip_prologue;
bool m_one_shot;
bool m_use_dummy;
+ bool m_all_files;
};
@@ -505,7 +512,7 @@ protected:
{
const size_t num_files = m_options.m_filenames.GetSize();
- if (num_files == 0)
+ if (num_files == 0 && !m_options.m_all_files)
{
FileSpec file;
if (!GetDefaultFile (target, file, result))
@@ -729,6 +736,9 @@ CommandObjectBreakpointSet::CommandOptio
"specified with the -f option. The -f option can be specified more than once. "
"If no source files are specified, uses the current \"default source file\"" },
+ { LLDB_OPT_SET_9, false, "all-files", 'A', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ "All files are searched for source pattern matches." },
+
{ LLDB_OPT_SET_10, true, "language-exception", 'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage,
"Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" },
Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py?rev=228938&r1=228937&r2=228938&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py Thu Feb 12 11:37:46 2015
@@ -48,6 +48,25 @@ class PythonBreakpointCommandSettingTest
func_bkpt = self.target.BreakpointCreateBySourceRegex("Set break point at this line.", self.main_source_spec)
self.assertTrue(func_bkpt, VALID_BREAKPOINT)
+ # Also test that setting a source regex breakpoint with an empty file spec list sets it on all files:
+ no_files_bkpt = self.target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(no_files_bkpt, VALID_BREAKPOINT)
+ num_locations = no_files_bkpt.GetNumLocations()
+ self.assertTrue(num_locations >= 2, "Got at least two breakpoint locations")
+ got_one_in_A = False
+ got_one_in_B = False
+ for idx in range(0, num_locations):
+ comp_unit = no_files_bkpt.GetLocationAtIndex(idx).GetAddress().GetSymbolContext(lldb.eSymbolContextCompUnit).GetCompileUnit().GetFileSpec()
+ print "Got comp unit: ", comp_unit.GetFilename()
+ if comp_unit.GetFilename() == "a.c":
+ got_one_in_A = True
+ elif comp_unit.GetFilename() == "b.c":
+ got_one_in_B = True
+
+ self.assertTrue(got_one_in_A, "Failed to match the pattern in A")
+ self.assertTrue(got_one_in_B, "Failed to match the pattern in B")
+ self.target.BreakpointDelete(no_files_bkpt.GetID())
+
PythonBreakpointCommandSettingTestCase.my_var = 10
error = lldb.SBError()
error = body_bkpt.SetScriptCallbackBody("\
More information about the lldb-commits
mailing list