summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Target.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2016-09-22 23:42:42 +0000
committerJim Ingham <jingham@apple.com>2016-09-22 23:42:42 +0000
commit2d3628e1f0c52db37d53061f2113e90e52ca0200 (patch)
treee2e551b2572b96b30b5fc7c89963e91375bdc013 /lldb/source/Target/Target.cpp
parentbe0ed59cdc9b765869b0a2355b185809507a02db (diff)
downloadbcm5719-llvm-2d3628e1f0c52db37d53061f2113e90e52ca0200.tar.gz
bcm5719-llvm-2d3628e1f0c52db37d53061f2113e90e52ca0200.zip
Add the ability to append breakpoints to the save file.
llvm-svn: 282212
Diffstat (limited to 'lldb/source/Target/Target.cpp')
-rw-r--r--lldb/source/Target/Target.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index d73cc84a156..1fcc4660853 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -796,7 +796,8 @@ bool Target::EnableBreakpointByID(break_id_t break_id) {
}
Error Target::SerializeBreakpointsToFile(const FileSpec &file,
- const BreakpointIDList &bp_ids) {
+ const BreakpointIDList &bp_ids,
+ bool append) {
Error error;
if (!file) {
@@ -805,6 +806,28 @@ Error Target::SerializeBreakpointsToFile(const FileSpec &file,
}
std::string path(file.GetPath());
+ StructuredData::ObjectSP input_data_sp;
+
+ StructuredData::ArraySP break_store_sp;
+ StructuredData::Array *break_store_ptr = nullptr;
+
+ if (append) {
+ input_data_sp = StructuredData::ParseJSONFromFile(file, error);
+ if (error.Success()) {
+ break_store_ptr = input_data_sp->GetAsArray();
+ if (!break_store_ptr) {
+ error.SetErrorStringWithFormat(
+ "Tried to append to invalid input file %s", path.c_str());
+ return error;
+ }
+ }
+ }
+
+ if (!break_store_ptr) {
+ break_store_sp.reset(new StructuredData::Array());
+ break_store_ptr = break_store_sp.get();
+ }
+
StreamFile out_file(path.c_str(),
File::OpenOptions::eOpenOptionTruncate |
File::OpenOptions::eOpenOptionWrite |
@@ -820,7 +843,6 @@ Error Target::SerializeBreakpointsToFile(const FileSpec &file,
std::unique_lock<std::recursive_mutex> lock;
GetBreakpointList().GetListMutex(lock);
- StructuredData::ArraySP break_store_sp(new StructuredData::Array());
if (bp_ids.GetSize() == 0) {
const BreakpointList &breakpoints = GetBreakpointList();
@@ -830,7 +852,7 @@ Error Target::SerializeBreakpointsToFile(const FileSpec &file,
StructuredData::ObjectSP bkpt_save_sp = bp->SerializeToStructuredData();
// If a breakpoint can't serialize it, just ignore it for now:
if (bkpt_save_sp)
- break_store_sp->AddItem(bkpt_save_sp);
+ break_store_ptr->AddItem(bkpt_save_sp);
}
} else {
@@ -857,12 +879,12 @@ Error Target::SerializeBreakpointsToFile(const FileSpec &file,
bp_id);
return error;
}
- break_store_sp->AddItem(bkpt_save_sp);
+ break_store_ptr->AddItem(bkpt_save_sp);
}
}
}
- break_store_sp->Dump(out_file, false);
+ break_store_ptr->Dump(out_file, false);
out_file.PutChar('\n');
return error;
}
OpenPOWER on IntegriCloud