summaryrefslogtreecommitdiffstats
path: root/lldb/source/Breakpoint/BreakpointOptions.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2010-10-14 23:45:03 +0000
committerJim Ingham <jingham@apple.com>2010-10-14 23:45:03 +0000
commit36f3b369d2632e6898166c0e697f85e2ab458ece (patch)
tree62bfedb1bc23100bdf34b43673fa90dbc0f38d5e /lldb/source/Breakpoint/BreakpointOptions.cpp
parent3f1cf0f373ab9915d4f7dff04c57017c62869386 (diff)
downloadbcm5719-llvm-36f3b369d2632e6898166c0e697f85e2ab458ece.tar.gz
bcm5719-llvm-36f3b369d2632e6898166c0e697f85e2ab458ece.zip
Added support for breakpoint conditions. I also had to separate the "run the expression" part of ClangFunction::Execute from the "Gather the expression result" so that in the case of the Breakpoint condition I can move the condition evaluation into the normal thread plan processing.
Also added support for remembering the "last set breakpoint" so that "break modify" will act on the last set breakpoint. llvm-svn: 116542
Diffstat (limited to 'lldb/source/Breakpoint/BreakpointOptions.cpp')
-rw-r--r--lldb/source/Breakpoint/BreakpointOptions.cpp89
1 files changed, 86 insertions, 3 deletions
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 9054f3b89a6..b3aa1152761 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -15,8 +15,11 @@
// Project includes
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
+#include "lldb/Core/Value.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
+#include "lldb/Target/Process.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Target/ThreadPlanTestCondition.h"
using namespace lldb;
using namespace lldb_private;
@@ -36,7 +39,8 @@ BreakpointOptions::BreakpointOptions() :
m_callback_is_synchronous (false),
m_enabled (true),
m_ignore_count (0),
- m_thread_spec_ap (NULL)
+ m_thread_spec_ap (NULL),
+ m_condition_ap()
{
}
@@ -49,10 +53,13 @@ BreakpointOptions::BreakpointOptions(const BreakpointOptions& rhs) :
m_callback_is_synchronous (rhs.m_callback_is_synchronous),
m_enabled (rhs.m_enabled),
m_ignore_count (rhs.m_ignore_count),
- m_thread_spec_ap (NULL)
+ m_thread_spec_ap (NULL),
+ m_condition_ap (NULL)
{
if (rhs.m_thread_spec_ap.get() != NULL)
m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ if (rhs.m_condition_ap.get())
+ m_condition_ap.reset (new ClangUserExpression (rhs.m_condition_ap->GetUserText()));
}
//----------------------------------------------------------------------
@@ -68,6 +75,8 @@ BreakpointOptions::operator=(const BreakpointOptions& rhs)
m_ignore_count = rhs.m_ignore_count;
if (rhs.m_thread_spec_ap.get() != NULL)
m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ if (rhs.m_condition_ap.get())
+ m_condition_ap.reset (new ClangUserExpression (rhs.m_condition_ap->GetUserText()));
return *this;
}
@@ -107,7 +116,8 @@ BreakpointOptions::SetCallback (BreakpointHitCallback callback, const BatonSP &c
void
BreakpointOptions::ClearCallback ()
{
- m_callback = NULL;
+ m_callback = BreakpointOptions::NullCallback;
+ m_callback_is_synchronous = false;
m_callback_baton_sp.reset();
}
@@ -145,6 +155,71 @@ BreakpointOptions::HasCallback ()
return m_callback != BreakpointOptions::NullCallback;
}
+void
+BreakpointOptions::SetCondition (const char *condition)
+{
+ if (condition == NULL || condition[0] == '\0')
+ {
+ if (m_condition_ap.get())
+ m_condition_ap.reset();
+ }
+ else
+ {
+ m_condition_ap.reset(new ClangUserExpression (condition));
+ }
+}
+
+ThreadPlan *
+BreakpointOptions::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx,
+ lldb::BreakpointLocationSP break_loc_sp,
+ Stream &error_stream)
+{
+ // No condition means we should stop, so return NULL.
+ if (!m_condition_ap.get())
+ return NULL;
+
+ // FIXME: I shouldn't have to do this, the process should handle it for me:
+ if (!exe_ctx.process->GetDynamicCheckers())
+ {
+ DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
+
+ StreamString install_errors;
+
+ if (!dynamic_checkers->Install(install_errors, exe_ctx))
+ {
+ error_stream.Printf("Couldn't install dynamic checkers into the execution context: %s\n", install_errors.GetData());
+ return NULL;
+ }
+
+ exe_ctx.process->SetDynamicCheckers(dynamic_checkers);
+ }
+
+ if (!m_condition_ap->Parse (error_stream, exe_ctx))
+ {
+ // Errors mean we should stop.
+ return NULL;
+ }
+ // FIXME: When we can execute static expressions without running the target, we should check that here,
+ // and return something to indicate we should stop or just continue.
+
+ ThreadPlan *new_plan = new ThreadPlanTestCondition (*exe_ctx.thread,
+ exe_ctx,
+ m_condition_ap.get(),
+ break_loc_sp,
+ true);
+
+ return new_plan;
+}
+
+const char *
+BreakpointOptions::GetConditionText ()
+{
+ if (m_condition_ap.get())
+ return m_condition_ap->GetUserText();
+ else
+ return "<No Condition>";
+}
+
//------------------------------------------------------------------
// Enabled/Ignore Count
//------------------------------------------------------------------
@@ -234,6 +309,14 @@ BreakpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) cons
if (level != eDescriptionLevelBrief)
s->EOL();
m_callback_baton_sp->GetDescription (s, level);
+ }
+ if (m_condition_ap.get())
+ {
+ if (level != eDescriptionLevelBrief)
+ {
+ s->EOL();
+ s->Printf("Condition: %s\n", m_condition_ap->GetUserText());
+ }
}
}
OpenPOWER on IntegriCloud