[Lldb-commits] [lldb] r161723 - in /lldb/trunk: source/Commands/CommandObjectProcess.cpp test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py test/functionalities/breakpoint/breakpoint_ignore_count/main.c
Jim Ingham
jingham at apple.com
Fri Aug 10 18:27:55 PDT 2012
Author: jingham
Date: Fri Aug 10 20:27:55 2012
New Revision: 161723
URL: http://llvm.org/viewvc/llvm-project?rev=161723&view=rev
Log:
Add an option to "process continue" to ignore the next <N> crossings of the breakpoint under
the currently selected thread.
<rdar://problem/10458225>
Modified:
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/main.c
Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=161723&r1=161722&r2=161723&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Aug 10 20:27:55 2012
@@ -13,14 +13,18 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Args.h"
-#include "lldb/Interpreter/Options.h"
+#include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
@@ -670,7 +674,8 @@
"process continue",
"Continue execution of all threads in the current process.",
"process continue",
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ m_options(interpreter)
{
}
@@ -680,6 +685,62 @@
}
protected:
+
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options(interpreter)
+ {
+ // Keep default values of all options in one place: OptionParsingStarting ()
+ OptionParsingStarting ();
+ }
+
+ ~CommandOptions ()
+ {
+ }
+
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+ bool success = false;
+ switch (short_option)
+ {
+ case 'i':
+ m_ignore = Args::StringToUInt32 (option_arg, 0, 0, &success);
+ if (!success)
+ error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg);
+ break;
+
+ default:
+ error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+ break;
+ }
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_ignore = 0;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ uint32_t m_ignore;
+ };
+
bool
DoExecute (Args& command,
CommandReturnObject &result)
@@ -704,6 +765,32 @@
return false;
}
+ if (m_options.m_ignore > 0)
+ {
+ ThreadSP sel_thread_sp(process->GetThreadList().GetSelectedThread());
+ if (sel_thread_sp)
+ {
+ StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
+ if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
+ {
+ uint64_t bp_site_id = stop_info_sp->GetValue();
+ BreakpointSiteSP bp_site_sp(process->GetBreakpointSiteList().FindByID(bp_site_id));
+ if (bp_site_sp)
+ {
+ uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
+ for (uint32_t i = 0; i < num_owners; i++)
+ {
+ Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
+ if (!bp_ref.IsInternal())
+ {
+ bp_ref.SetIgnoreCount(m_options.m_ignore);
+ }
+ }
+ }
+ }
+ }
+ }
+
const uint32_t num_threads = process->GetThreadList().GetSize();
// Set the actions that the threads should each take when resuming
@@ -743,6 +830,23 @@
}
return result.Succeeded();
}
+
+ Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+ CommandOptions m_options;
+
+};
+
+OptionDefinition
+CommandObjectProcessContinue::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', required_argument, NULL, 0, eArgTypeUnsignedInteger,
+ "Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread."},
+{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
//-------------------------------------------------------------------------
Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=161723&r1=161722&r2=161723&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Fri Aug 10 20:27:55 2012
@@ -48,6 +48,7 @@
self.line2 = line_number('main.c', '// b(2) -> c(2) Find the call site of b(2).')
self.line3 = line_number('main.c', '// a(3) -> c(3) Find the call site of c(3).')
self.line4 = line_number('main.c', '// a(3) -> c(3) Find the call site of a(3).')
+ self.line5 = line_number('main.c', '// Find the call site of c in main.')
def breakpoint_ignore_count(self):
"""Exercise breakpoint ignore count with 'breakpoint set -i <count>'."""
@@ -78,6 +79,28 @@
patterns = ["frame #0.*main.c:%d" % self.line1,
"frame #2.*main.c:%d" % self.line2])
+ # continue -i 1 is the same as setting the ignore count to 1 again, try that:
+ # Now run the program.
+ self.runCmd("process continue -i 1", RUN_SUCCEEDED)
+
+ # The process should be stopped at this point.
+ self.expect("process status", PROCESS_STOPPED,
+ patterns = ['Process .* stopped'])
+
+ # Also check the hit count, which should be 2, due to ignore count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_THRICE,
+ substrs = ["resolved = 1",
+ "hit count = 4"])
+
+ # The frame #0 should correspond to main.c:37, the executable statement
+ # in function name 'c'. And frame #2 should point to main.c:45.
+ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT,
+ #substrs = ["stop reason = breakpoint"],
+ patterns = ["frame #0.*main.c:%d" % self.line1,
+ "frame #1.*main.c:%d" % self.line5])
+
+
+
def breakpoint_ignore_count_python(self):
"""Use Python APIs to set breakpoint ignore count."""
exe = os.path.join(os.getcwd(), "a.out")
Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/main.c?rev=161723&r1=161722&r2=161723&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/main.c (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_ignore_count/main.c Fri Aug 10 20:27:55 2012
@@ -48,5 +48,7 @@
int A3 = a(3); // a(3) -> c(3) Find the call site of a(3).
printf("a(3) returns %d\n", A3);
+ int C1 = c(5); // Find the call site of c in main.
+ printf ("c(5) returns %d\n", C1);
return 0;
}
More information about the lldb-commits
mailing list