summaryrefslogtreecommitdiffstats
path: root/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp')
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 8d08908f9a3..da8b7b3ed1a 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -36,6 +36,70 @@ BreakpointResolverFileRegex::BreakpointResolverFileRegex(
BreakpointResolverFileRegex::~BreakpointResolverFileRegex() {}
+BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
+ Breakpoint *bkpt, StructuredData::Dictionary &options_dict, Error &error) {
+ bool success;
+
+ std::string regex_string;
+ success = options_dict.GetValueForKeyAsString(
+ GetKey(OptionNames::RegexString), regex_string);
+ if (!success) {
+ error.SetErrorString("BRFR::CFSD: Couldn't find regex entry.");
+ return nullptr;
+ }
+ RegularExpression regex(regex_string.c_str());
+
+ bool exact_match;
+ success = options_dict.GetValueForKeyAsBoolean(
+ GetKey(OptionNames::ExactMatch), exact_match);
+ if (!success) {
+ error.SetErrorString("BRFL::CFSD: Couldn't find exact match entry.");
+ return nullptr;
+ }
+
+ // The names array is optional:
+ std::unordered_set<std::string> names_set;
+ StructuredData::Array *names_array;
+ success = options_dict.GetValueForKeyAsArray(
+ GetKey(OptionNames::SymbolNameArray), names_array);
+ if (success && names_array) {
+ size_t num_names = names_array->GetSize();
+ for (size_t i = 0; i < num_names; i++) {
+ std::string name;
+ success = names_array->GetItemAtIndexAsString(i, name);
+ if (!success) {
+ error.SetErrorStringWithFormat(
+ "BRFR::CFSD: Malformed element %zu in the names array.", i);
+ return nullptr;
+ }
+ names_set.insert(name);
+ }
+ }
+
+ return new BreakpointResolverFileRegex(bkpt, regex, names_set, exact_match);
+}
+
+StructuredData::ObjectSP
+BreakpointResolverFileRegex::SerializeToStructuredData() {
+ StructuredData::DictionarySP options_dict_sp(
+ new StructuredData::Dictionary());
+
+ options_dict_sp->AddStringItem(GetKey(OptionNames::RegexString),
+ m_regex.GetText());
+ options_dict_sp->AddBooleanItem(GetKey(OptionNames::ExactMatch),
+ m_exact_match);
+ if (!m_function_names.empty()) {
+ StructuredData::ArraySP names_array_sp(new StructuredData::Array());
+ for (std::string name : m_function_names) {
+ StructuredData::StringSP item(new StructuredData::String(name));
+ names_array_sp->AddItem(item);
+ }
+ options_dict_sp->AddItem(GetKey(OptionNames::LineNumber), names_array_sp);
+ }
+
+ return WrapOptionsDict(options_dict_sp);
+}
+
Searcher::CallbackReturn
BreakpointResolverFileRegex::SearchCallback(SearchFilter &filter,
SymbolContext &context,
OpenPOWER on IntegriCloud