2017-04-07 05:28:29 +08:00
|
|
|
//====-- UserSettingsController.cpp ------------------------------*- C++-*-===//
|
2010-09-04 08:03:46 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/Core/UserSettingsController.h"
|
2017-04-07 05:28:29 +08:00
|
|
|
|
2015-03-04 09:58:01 +08:00
|
|
|
#include "lldb/Interpreter/OptionValueProperties.h"
|
2017-05-12 12:51:55 +08:00
|
|
|
#include "lldb/Utility/Status.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2017-04-07 05:28:29 +08:00
|
|
|
|
|
|
|
#include <memory> // for shared_ptr
|
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
class CommandInterpreter;
|
|
|
|
}
|
|
|
|
namespace lldb_private {
|
|
|
|
class ConstString;
|
|
|
|
}
|
|
|
|
namespace lldb_private {
|
|
|
|
class ExecutionContext;
|
|
|
|
}
|
|
|
|
namespace lldb_private {
|
|
|
|
class Property;
|
|
|
|
}
|
2010-09-04 08:03:46 +08:00
|
|
|
|
2011-02-18 09:44:25 +08:00
|
|
|
using namespace lldb;
|
2010-09-04 08:03:46 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
lldb::OptionValueSP
|
2017-05-12 12:51:55 +08:00
|
|
|
Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
|
|
|
|
llvm::StringRef path, bool will_modify,
|
|
|
|
Status &error) const {
|
2016-09-07 04:57:50 +08:00
|
|
|
OptionValuePropertiesSP properties_sp(GetValueProperties());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
|
|
|
|
return lldb::OptionValueSP();
|
2011-04-23 10:04:55 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
|
|
|
|
VarSetOperationType op,
|
|
|
|
llvm::StringRef path,
|
|
|
|
llvm::StringRef value) {
|
2016-09-07 04:57:50 +08:00
|
|
|
OptionValuePropertiesSP properties_sp(GetValueProperties());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->SetSubValue(exe_ctx, op, path, value);
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2016-09-07 04:57:50 +08:00
|
|
|
error.SetErrorString("no properties");
|
|
|
|
return error;
|
2011-04-23 10:04:55 +08:00
|
|
|
}
|
2010-09-04 08:03:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx,
|
|
|
|
Stream &strm, uint32_t dump_mask) {
|
|
|
|
OptionValuePropertiesSP properties_sp(GetValueProperties());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->DumpValue(exe_ctx, strm, dump_mask);
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
|
|
|
|
Stream &strm) const {
|
|
|
|
strm.PutCString("Top level variables:\n\n");
|
2010-09-04 08:03:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
OptionValuePropertiesSP properties_sp(GetValueProperties());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->DumpAllDescriptions(interpreter, strm);
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
|
|
|
|
Stream &strm,
|
|
|
|
llvm::StringRef property_path,
|
|
|
|
uint32_t dump_mask) {
|
2016-09-07 04:57:50 +08:00
|
|
|
OptionValuePropertiesSP properties_sp(GetValueProperties());
|
|
|
|
if (properties_sp) {
|
|
|
|
return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
|
|
|
|
dump_mask);
|
|
|
|
}
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2016-09-07 04:57:50 +08:00
|
|
|
error.SetErrorString("empty property list");
|
|
|
|
return error;
|
2010-09-15 13:35:14 +08:00
|
|
|
}
|
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
size_t
|
2016-11-17 05:45:04 +08:00
|
|
|
Properties::Apropos(llvm::StringRef keyword,
|
2016-09-07 04:57:50 +08:00
|
|
|
std::vector<const Property *> &matching_properties) const {
|
|
|
|
OptionValuePropertiesSP properties_sp(GetValueProperties());
|
|
|
|
if (properties_sp) {
|
|
|
|
properties_sp->Apropos(keyword, matching_properties);
|
|
|
|
}
|
|
|
|
return matching_properties.size();
|
2012-01-28 05:27:39 +08:00
|
|
|
}
|
2012-10-20 02:02:49 +08:00
|
|
|
|
|
|
|
lldb::OptionValuePropertiesSP
|
2016-09-07 04:57:50 +08:00
|
|
|
Properties::GetSubProperty(const ExecutionContext *exe_ctx,
|
|
|
|
const ConstString &name) {
|
|
|
|
OptionValuePropertiesSP properties_sp(GetValueProperties());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->GetSubProperty(exe_ctx, name);
|
|
|
|
return lldb::OptionValuePropertiesSP();
|
2012-10-20 02:02:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
|
2016-07-06 09:27:33 +08:00
|
|
|
|
2016-11-18 02:08:12 +08:00
|
|
|
bool Properties::IsSettingExperimental(llvm::StringRef setting) {
|
|
|
|
if (setting.empty())
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2016-07-06 09:27:33 +08:00
|
|
|
|
2016-11-18 02:08:12 +08:00
|
|
|
llvm::StringRef experimental = GetExperimentalSettingsName();
|
|
|
|
size_t dot_pos = setting.find_first_of('.');
|
|
|
|
return setting.take_front(dot_pos) == experimental;
|
2016-07-06 09:27:33 +08:00
|
|
|
}
|