in places where they help prevent leaks.
llvm-svn: 281288
StructuredData::ObjectSP SerializeToStructuredData();
- static CommandData *
- CreateFromStructuredData(StructuredData::Dictionary &options_dict,
+ static std::unique_ptr<CommandData>
+ CreateFromStructuredData(const StructuredData::Dictionary &options_dict,
Error &error);
StringList user_source;
virtual ~BreakpointOptions();
- static BreakpointOptions *
- CreateFromStructuredData(StructuredData::Dictionary &data_dict, Error &error);
+ static std::unique_ptr<BreakpointOptions>
+ CreateFromStructuredData(const StructuredData::Dictionary &data_dict,
+ Error &error);
virtual StructuredData::ObjectSP SerializeToStructuredData();
/// objects.
static lldb::BreakpointResolverSP
- CreateFromStructuredData(StructuredData::Dictionary &resolver_dict,
+ CreateFromStructuredData(const StructuredData::Dictionary &resolver_dict,
Error &error);
virtual StructuredData::ObjectSP SerializeToStructuredData() {
~BreakpointResolverAddress() override;
- static BreakpointResolver *CreateFromStructuredData(
- Breakpoint *bkpt, StructuredData::Dictionary &options_dict, Error &error);
+ static BreakpointResolver *
+ CreateFromStructuredData(Breakpoint *bkpt,
+ const StructuredData::Dictionary &options_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
static BreakpointResolver *
CreateFromStructuredData(Breakpoint *bkpt,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
Breakpoint *bkpt, RegularExpression ®ex,
const std::unordered_set<std::string> &func_name_set, bool exact_match);
- static BreakpointResolver *CreateFromStructuredData(
- Breakpoint *bkpt, StructuredData::Dictionary &options_dict, Error &error);
+ static BreakpointResolver *
+ CreateFromStructuredData(Breakpoint *bkpt,
+ const StructuredData::Dictionary &options_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
static BreakpointResolver *
CreateFromStructuredData(Breakpoint *bkpt,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint);
- static SearchFilter *
+ static lldb::SearchFilterSP
CreateFromStructuredData(Target &target,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
virtual StructuredData::ObjectSP SerializeToStructuredData() {
return StructuredData::ObjectSP();
bool ModulePasses(const lldb::ModuleSP &module_sp) override;
- static SearchFilter *
+ static lldb::SearchFilterSP
CreateFromStructuredData(Target &target,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
void Search(Searcher &searcher) override;
- static SearchFilter *
+ static lldb::SearchFilterSP
CreateFromStructuredData(Target &target,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
void Search(Searcher &searcher) override;
- static SearchFilter *
+ static lldb::SearchFilterSP
CreateFromStructuredData(Target &target,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
void Search(Searcher &searcher) override;
- static SearchFilter *
+ static lldb::SearchFilterSP
CreateFromStructuredData(Target &target,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
static SearchFilter *
CreateFromStructuredData(Target &target,
- StructuredData::Dictionary &data_dict, Error &error);
+ const StructuredData::Dictionary &data_dict,
+ Error &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
filter_sp.reset(
new SearchFilterForUnconstrainedSearches(target.shared_from_this()));
else {
- filter_sp.reset(SearchFilter::CreateFromStructuredData(target, *filter_dict,
- create_error));
+ filter_sp = SearchFilter::CreateFromStructuredData(target, *filter_dict,
+ create_error);
if (create_error.Fail()) {
error.SetErrorStringWithFormat(
"Error creating breakpoint filter from data: %s.",
}
}
- BreakpointOptions *options = nullptr;
+ std::unique_ptr<BreakpointOptions> options_up;
StructuredData::Dictionary *options_dict;
success = breakpoint_dict->GetValueForKeyAsDictionary(
BreakpointOptions::GetSerializationKey(), options_dict);
if (success) {
- options = BreakpointOptions::CreateFromStructuredData(*options_dict,
- create_error);
+ options_up = BreakpointOptions::CreateFromStructuredData(*options_dict,
+ create_error);
if (create_error.Fail()) {
error.SetErrorStringWithFormat(
"Error creating breakpoint options from data: %s.",
}
result_sp =
target.CreateBreakpoint(filter_sp, resolver_sp, false, false, true);
- if (result_sp && options) {
- result_sp->m_options_up.reset(options);
+ if (result_sp && options_up) {
+ result_sp->m_options_up = std::move(options_up);
}
return result_sp;
}
stop_on_error);
StructuredData::ArraySP user_source_sp(new StructuredData::Array());
- if (num_strings > 0) {
- for (size_t i = 0; i < num_strings; i++) {
- StructuredData::StringSP item_sp(
- new StructuredData::String(user_source[i]));
- user_source_sp->AddItem(item_sp);
- options_dict_sp->AddItem(GetKey(OptionNames::UserSource), user_source_sp);
- }
+ for (size_t i = 0; i < num_strings; i++) {
+ StructuredData::StringSP item_sp(
+ new StructuredData::String(user_source[i]));
+ user_source_sp->AddItem(item_sp);
+ options_dict_sp->AddItem(GetKey(OptionNames::UserSource), user_source_sp);
}
if (!script_source.empty()) {
return options_dict_sp;
}
-BreakpointOptions::CommandData *
+std::unique_ptr<BreakpointOptions::CommandData>
BreakpointOptions::CommandData::CreateFromStructuredData(
- StructuredData::Dictionary &options_dict, Error &error) {
+ const StructuredData::Dictionary &options_dict, Error &error) {
std::string script_source;
CommandData *data = new CommandData();
bool success = options_dict.GetValueForKeyAsBoolean(
data->user_source.AppendString(elem_string);
}
}
- return data;
+ return std::unique_ptr<BreakpointOptions::CommandData>(data);
}
const char *BreakpointOptions::g_option_names
//----------------------------------------------------------------------
BreakpointOptions::~BreakpointOptions() = default;
-BreakpointOptions *BreakpointOptions::CreateFromStructuredData(
- StructuredData::Dictionary &options_dict, Error &error) {
+std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
+ const StructuredData::Dictionary &options_dict, Error &error) {
bool enabled = true;
bool one_shot = false;
int32_t ignore_count = 0;
return nullptr;
}
- BreakpointOptions::CommandData *cmd_data = nullptr;
+ std::unique_ptr<CommandData> cmd_data;
StructuredData::Dictionary *cmds_dict;
success = options_dict.GetValueForKeyAsDictionary(
CommandData::GetSerializationKey(), cmds_dict);
BreakpointOptions *bp_options = new BreakpointOptions(
condition_text.c_str(), enabled, ignore_count, one_shot);
if (cmd_data)
- bp_options->SetCommandDataCallback(cmd_data);
- return bp_options;
+ bp_options->SetCommandDataCallback(cmd_data.release());
+ return std::unique_ptr<BreakpointOptions>(bp_options);
}
StructuredData::ObjectSP BreakpointOptions::SerializeToStructuredData() {
BreakpointResolver::~BreakpointResolver() {}
BreakpointResolverSP BreakpointResolver::CreateFromStructuredData(
- StructuredData::Dictionary &resolver_dict, Error &error) {
+ const StructuredData::Dictionary &resolver_dict, Error &error) {
BreakpointResolverSP result_sp;
if (!resolver_dict.IsValid()) {
error.SetErrorString("Can't deserialize from an invalid data object.");
BreakpointResolverAddress::~BreakpointResolverAddress() {}
BreakpointResolver *BreakpointResolverAddress::CreateFromStructuredData(
- Breakpoint *bkpt, StructuredData::Dictionary &options_dict, Error &error) {
+ Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ Error &error) {
std::string module_name;
lldb::addr_t addr_offset;
FileSpec module_filespec;
BreakpointResolverFileLine::~BreakpointResolverFileLine() {}
BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
- Breakpoint *bkpt, StructuredData::Dictionary &options_dict, Error &error) {
+ Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ Error &error) {
std::string filename;
uint32_t line_no;
bool check_inlines;
BreakpointResolverFileRegex::~BreakpointResolverFileRegex() {}
BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
- Breakpoint *bkpt, StructuredData::Dictionary &options_dict, Error &error) {
+ Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ Error &error) {
bool success;
std::string regex_string;
m_language(rhs.m_language), m_skip_prologue(rhs.m_skip_prologue) {}
BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
- Breakpoint *bkpt, StructuredData::Dictionary &options_dict, Error &error) {
+ Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ Error &error) {
LanguageType language = eLanguageTypeUnknown;
std::string language_name;
bool success = options_dict.GetValueForKeyAsString(
SearchFilter::~SearchFilter() = default;
-SearchFilter *SearchFilter::CreateFromStructuredData(
- Target &target, StructuredData::Dictionary &filter_dict, Error &error) {
- SearchFilter *result = nullptr;
+SearchFilterSP SearchFilter::CreateFromStructuredData(
+ Target &target, const StructuredData::Dictionary &filter_dict,
+ Error &error) {
+ SearchFilterSP result_sp;
if (!filter_dict.IsValid()) {
error.SetErrorString("Can't deserialize from an invalid data object.");
- return result;
+ return result_sp;
}
std::string subclass_name;
GetSerializationSubclassKey(), subclass_name);
if (!success) {
error.SetErrorStringWithFormat("Filter data missing subclass key");
- return result;
+ return result_sp;
}
FilterTy filter_type = NameToFilterTy(subclass_name.c_str());
if (filter_type == UnknownFilter) {
error.SetErrorStringWithFormat("Unknown filter type: %s.",
subclass_name.c_str());
- return result;
+ return result_sp;
}
StructuredData::Dictionary *subclass_options = nullptr;
GetSerializationSubclassOptionsKey(), subclass_options);
if (!success || !subclass_options || !subclass_options->IsValid()) {
error.SetErrorString("Filter data missing subclass options key.");
- return result;
+ return result_sp;
}
switch (filter_type) {
case Unconstrained:
- result = SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
+ result_sp = SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
target, *subclass_options, error);
break;
case ByModule:
- result = SearchFilterByModule::CreateFromStructuredData(
+ result_sp = SearchFilterByModule::CreateFromStructuredData(
target, *subclass_options, error);
break;
case ByModules:
- result = SearchFilterByModuleList::CreateFromStructuredData(
+ result_sp = SearchFilterByModuleList::CreateFromStructuredData(
target, *subclass_options, error);
break;
case ByModulesAndCU:
- result = SearchFilterByModuleListAndCU::CreateFromStructuredData(
+ result_sp = SearchFilterByModuleListAndCU::CreateFromStructuredData(
target, *subclass_options, error);
break;
case Exception:
llvm_unreachable("Should never get an uresolvable filter type.");
}
- return result;
+ return result_sp;
}
bool SearchFilter::ModulePasses(const FileSpec &spec) { return true; }
// Selects a shared library matching a given file spec, consulting the targets
// "black list".
//----------------------------------------------------------------------
-SearchFilter *SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
- Target &target, StructuredData::Dictionary &data_dict, Error &error) {
+SearchFilterSP SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
+ Target &target, const StructuredData::Dictionary &data_dict, Error &error) {
// No options for an unconstrained search.
- return new SearchFilterForUnconstrainedSearches(target.shared_from_this());
+ return SearchFilterSP(
+ new SearchFilterForUnconstrainedSearches(target.shared_from_this()));
}
StructuredData::ObjectSP
return ret_sp;
}
-SearchFilter *SearchFilterByModule::CreateFromStructuredData(
- Target &target, StructuredData::Dictionary &data_dict, Error &error) {
+SearchFilterSP SearchFilterByModule::CreateFromStructuredData(
+ Target &target, const StructuredData::Dictionary &data_dict, Error &error) {
StructuredData::Array *modules_array;
bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
modules_array);
}
FileSpec module_spec(module.c_str(), false);
- return new SearchFilterByModule(target.shared_from_this(), module_spec);
+ return SearchFilterSP(
+ new SearchFilterByModule(target.shared_from_this(), module_spec));
}
StructuredData::ObjectSP SearchFilterByModule::SerializeToStructuredData() {
return ret_sp;
}
-SearchFilter *SearchFilterByModuleList::CreateFromStructuredData(
- Target &target, StructuredData::Dictionary &data_dict, Error &error) {
+SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
+ Target &target, const StructuredData::Dictionary &data_dict, Error &error) {
StructuredData::Array *modules_array;
bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
modules_array);
modules.Append(FileSpec(module.c_str(), false));
}
- return new SearchFilterByModuleList(target.shared_from_this(), modules);
+ return SearchFilterSP(
+ new SearchFilterByModuleList(target.shared_from_this(), modules));
}
void SearchFilterByModuleList::SerializeUnwrapped(
SearchFilterByModuleListAndCU::~SearchFilterByModuleListAndCU() = default;
-SearchFilter *SearchFilterByModuleListAndCU::CreateFromStructuredData(
- Target &target, StructuredData::Dictionary &data_dict, Error &error) {
+lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
+ Target &target, const StructuredData::Dictionary &data_dict, Error &error) {
StructuredData::Array *modules_array;
+ SearchFilterSP result_sp;
bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
modules_array);
if (!success) {
error.SetErrorString("SFBM::CFSD: Could not find the module list key.");
- return nullptr;
+ return result_sp;
}
size_t num_modules = modules_array->GetSize();
if (!success) {
error.SetErrorStringWithFormat(
"SFBM::CFSD: filter module item %zu not a string.", i);
- return nullptr;
+ return result_sp;
}
modules.Append(FileSpec(module.c_str(), false));
}
data_dict.GetValueForKeyAsArray(GetKey(OptionNames::CUList), cus_array);
if (!success) {
error.SetErrorString("SFBM::CFSD: Could not find the CU list key.");
- return nullptr;
+ return result_sp;
}
size_t num_cus = cus_array->GetSize();
cus.Append(FileSpec(cu.c_str(), false));
}
- return new SearchFilterByModuleListAndCU(target.shared_from_this(), modules,
- cus);
+ return SearchFilterSP(new SearchFilterByModuleListAndCU(
+ target.shared_from_this(), modules, cus));
}
StructuredData::ObjectSP
}
SearchFilter *ExceptionSearchFilter::CreateFromStructuredData(
- Target &target, StructuredData::Dictionary &data_dict, Error &error) {
+ Target &target, const StructuredData::Dictionary &data_dict, Error &error) {
SearchFilter *result = nullptr;
return result;
}