summaryrefslogtreecommitdiffstats
path: root/lldb/source/API
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBBreakpoint.cpp36
-rw-r--r--lldb/source/API/SBStructuredData.cpp31
-rw-r--r--lldb/source/API/SBTarget.cpp38
-rw-r--r--lldb/source/API/SystemInitializerFull.cpp15
4 files changed, 118 insertions, 2 deletions
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 6a0ff9536c2..6d580ec8f10 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -23,6 +23,8 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Breakpoint/BreakpointResolver.h"
+#include "lldb/Breakpoint/BreakpointResolverScripted.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Debugger.h"
@@ -487,6 +489,40 @@ bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
return false;
}
+SBError
+SBBreakpoint::AddLocation(SBAddress &address) {
+ BreakpointSP bkpt_sp = GetSP();
+ SBError error;
+
+ if (!address.IsValid()) {
+ error.SetErrorString("Can't add an invalid address.");
+ return error;
+ }
+
+ if (!bkpt_sp) {
+ error.SetErrorString("No breakpoint to add a location to.");
+ return error;
+ }
+
+ if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
+ error.SetErrorString("Only a scripted resolver can add locations.");
+ return error;
+ }
+
+ if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref()))
+ bkpt_sp->AddLocation(address.ref());
+ else
+ {
+ StreamString s;
+ address.get()->Dump(&s, &bkpt_sp->GetTarget(),
+ Address::DumpStyleModuleWithFileAddress);
+ error.SetErrorStringWithFormat("Address: %s didn't pass the filter.",
+ s.GetData());
+ }
+ return error;
+}
+
+
void SBBreakpoint
::SetCallback(SBBreakpointHitCallback callback,
void *baton) {
diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp
index d506410f6d8..d901f915dad 100644
--- a/lldb/source/API/SBStructuredData.cpp
+++ b/lldb/source/API/SBStructuredData.cpp
@@ -10,6 +10,7 @@
#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStringList.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Target/StructuredDataPlugin.h"
@@ -31,6 +32,9 @@ SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs)
SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp)
: m_impl_up(new StructuredDataImpl(event_sp)) {}
+SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl)
+ : m_impl_up(impl) {}
+
SBStructuredData::~SBStructuredData() {}
SBStructuredData &SBStructuredData::
@@ -76,6 +80,33 @@ size_t SBStructuredData::GetSize() const {
return (m_impl_up ? m_impl_up->GetSize() : 0);
}
+bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
+ if (!m_impl_up)
+ return false;
+
+ if (GetType() != eStructuredDataTypeDictionary)
+ return false;
+
+ StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP();
+ if (!obj_sp)
+ return false;
+
+ StructuredData::Dictionary *dict = obj_sp->GetAsDictionary();
+ // We claimed we were a dictionary, so this can't be null.
+ assert(dict);
+ // The return kind of GetKeys is an Array:
+ StructuredData::ObjectSP array_sp = dict->GetKeys();
+ StructuredData::Array *key_arr = array_sp->GetAsArray();
+ assert(key_arr);
+
+ key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool {
+ llvm::StringRef key = object->GetStringValue("");
+ keys.AppendString(key.str().c_str());
+ return true;
+ });
+ return true;
+}
+
lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const {
if (!m_impl_up)
return SBStructuredData();
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index b143d6ccdff..4d2417c711b 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1044,7 +1044,7 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language,
}
if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: "
+ log->Printf("SBTarget(%p)::BreakpointCreateForException (Language: %s, catch: "
"%s throw: %s) => SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()),
Language::GetNameForLanguageType(language),
@@ -1054,6 +1054,42 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language,
return sb_bp;
}
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateFromScript(const char *class_name,
+ SBStructuredData &extra_args,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &file_list,
+ bool request_hardware)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+
+ SBBreakpoint sb_bp;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ Status error;
+
+ StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP();
+ sb_bp =
+ target_sp->CreateScriptedBreakpoint(class_name,
+ module_list.get(),
+ file_list.get(),
+ false, /* internal */
+ request_hardware,
+ obj_sp,
+ &error);
+ }
+ if (log)
+ log->Printf("SBTarget(%p)::BreakpointCreateFromScript (class name: %s) "
+ " => SBBreakpoint(%p)",
+ static_cast<void *>(target_sp.get()),
+ class_name,
+ static_cast<void *>(sb_bp.GetSP().get()));
+
+ return sb_bp;
+}
+
+
uint32_t SBTarget::GetNumBreakpoints() const {
TargetSP target_sp(GetSP());
if (target_sp) {
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index 18de376183c..0a50381fc1d 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -176,6 +176,18 @@ extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
const char *method_name,
Event *event_sp, bool &got_error);
+
+extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver(
+ const char *python_class_name,
+ const char *session_dictionary_name,
+ lldb_private::StructuredDataImpl *args,
+ lldb::BreakpointSP &bkpt_sp);
+
+extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver(
+ void *implementor,
+ const char *method_name,
+ lldb_private::SymbolContext *sym_ctx
+);
extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
uint32_t max);
@@ -413,7 +425,8 @@ void SystemInitializerFull::InitializeSWIG() {
LLDBSWIGPythonRunScriptKeywordThread,
LLDBSWIGPythonRunScriptKeywordTarget, LLDBSWIGPythonRunScriptKeywordFrame,
LLDBSWIGPythonRunScriptKeywordValue, LLDBSWIGPython_GetDynamicSetting,
- LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan);
+ LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan,
+ LLDBSwigPythonCreateScriptedBreakpointResolver, LLDBSwigPythonCallBreakpointResolver);
#endif
}
OpenPOWER on IntegriCloud