Add some more tests for breakpoint serialization.
Serialize breakpoint names & the hardware_requested attributes.
Also added a few missing affordances to SBBreakpoint whose absence
writing the tests pointed out.
<rdar://problem/12611863>
llvm-svn: 282036
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 7276713..7194101 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -448,6 +448,31 @@
return num_locs;
}
+void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
+ if (!m_opaque_sp)
+ return;
+ if (commands.GetSize() == 0)
+ return;
+
+ std::lock_guard<std::recursive_mutex> guard(
+ m_opaque_sp->GetTarget().GetAPIMutex());
+ std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
+ new BreakpointOptions::CommandData(*commands));
+
+ m_opaque_sp->GetOptions()->SetCommandDataCallback(cmd_data_up);
+}
+
+bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
+ if (!m_opaque_sp)
+ return false;
+ StringList command_list;
+ bool has_commands =
+ m_opaque_sp->GetOptions()->GetCommandLineCallbacks(command_list);
+ if (has_commands)
+ commands.AppendList(command_list);
+ return has_commands;
+}
+
bool SBBreakpoint::GetDescription(SBStream &s) {
return GetDescription(s, true);
}
diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp
index 34465f7..075ee0d 100644
--- a/lldb/source/API/SBStringList.cpp
+++ b/lldb/source/API/SBStringList.cpp
@@ -75,6 +75,12 @@
}
}
+void SBStringList::AppendList(const StringList &strings) {
+ if (!IsValid())
+ m_opaque_ap.reset(new lldb_private::StringList());
+ m_opaque_ap->AppendList(strings);
+}
+
uint32_t SBStringList::GetSize() const {
if (IsValid()) {
return m_opaque_ap->GetSize();
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 66d375a..7cf9215 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -661,6 +661,14 @@
SBBreakpoint
SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
uint32_t line, lldb::addr_t offset) {
+ SBFileSpecList empty_list;
+ return BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list);
+}
+
+SBBreakpoint
+SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
+ uint32_t line, lldb::addr_t offset,
+ SBFileSpecList &sb_module_list) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
@@ -673,9 +681,13 @@
const bool internal = false;
const bool hardware = false;
const LazyBool move_to_nearest_code = eLazyBoolCalculate;
- *sb_bp = target_sp->CreateBreakpoint(NULL, *sb_file_spec, line, offset,
- check_inlines, skip_prologue, internal,
- hardware, move_to_nearest_code);
+ const FileSpecList *module_list = nullptr;
+ if (sb_module_list.GetSize() > 0) {
+ module_list = sb_module_list.get();
+ }
+ *sb_bp = target_sp->CreateBreakpoint(
+ module_list, *sb_file_spec, line, offset, check_inlines, skip_prologue,
+ internal, hardware, move_to_nearest_code);
}
if (log) {