2010-09-04 08:03:46 +08:00
|
|
|
//====-- UserSettingsController.cpp ------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "lldb/Core/UserSettingsController.h"
|
|
|
|
#include "lldb/Core/Error.h"
|
2010-12-19 11:41:24 +08:00
|
|
|
#include "lldb/Core/RegularExpression.h"
|
2010-09-04 08:03:46 +08:00
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/StreamString.h"
|
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2015-03-04 09:58:01 +08:00
|
|
|
#include "lldb/Interpreter/OptionValueProperties.h"
|
2012-08-23 01:17:09 +08:00
|
|
|
#include "lldb/Interpreter/OptionValueString.h"
|
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
|
|
|
|
Properties::GetPropertyValue (const ExecutionContext *exe_ctx,
|
|
|
|
const char *path,
|
|
|
|
bool will_modify,
|
|
|
|
Error &error) const
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
Error
|
2012-08-23 01:17:09 +08:00
|
|
|
Properties::SetPropertyValue (const ExecutionContext *exe_ctx,
|
|
|
|
VarSetOperationType op,
|
|
|
|
const char *path,
|
|
|
|
const char *value)
|
|
|
|
{
|
|
|
|
OptionValuePropertiesSP properties_sp (GetValueProperties ());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->SetSubValue(exe_ctx, op, path, value);
|
2011-04-23 10:04:55 +08:00
|
|
|
Error error;
|
2012-08-23 01:17:09 +08:00
|
|
|
error.SetErrorString ("no properties");
|
2011-04-23 10:04:55 +08:00
|
|
|
return error;
|
|
|
|
}
|
2010-09-04 08:03:46 +08:00
|
|
|
|
|
|
|
void
|
2012-08-23 01:17:09 +08:00
|
|
|
Properties::DumpAllPropertyValues (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
|
2010-09-04 08:03:46 +08:00
|
|
|
{
|
2012-08-23 01:17:09 +08:00
|
|
|
OptionValuePropertiesSP properties_sp (GetValueProperties ());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->DumpValue (exe_ctx, strm, dump_mask);
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-23 01:17:09 +08:00
|
|
|
Properties::DumpAllDescriptions (CommandInterpreter &interpreter,
|
|
|
|
Stream &strm) const
|
2010-09-04 08:03:46 +08:00
|
|
|
{
|
2012-08-23 01:17:09 +08:00
|
|
|
strm.PutCString("Top level variables:\n\n");
|
2010-09-04 08:03:46 +08:00
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
OptionValuePropertiesSP properties_sp (GetValueProperties ());
|
|
|
|
if (properties_sp)
|
|
|
|
return properties_sp->DumpAllDescriptions (interpreter, strm);
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
Error
|
|
|
|
Properties::DumpPropertyValue (const ExecutionContext *exe_ctx, Stream &strm, const char *property_path, uint32_t dump_mask)
|
2010-09-15 13:35:14 +08:00
|
|
|
{
|
2012-08-23 01:17:09 +08:00
|
|
|
OptionValuePropertiesSP properties_sp (GetValueProperties ());
|
|
|
|
if (properties_sp)
|
2010-09-15 13:35:14 +08:00
|
|
|
{
|
2012-08-23 01:17:09 +08:00
|
|
|
return properties_sp->DumpPropertyValue (exe_ctx,
|
|
|
|
strm,
|
|
|
|
property_path,
|
|
|
|
dump_mask);
|
2010-09-15 13:35:14 +08:00
|
|
|
}
|
2012-08-23 01:17:09 +08:00
|
|
|
Error error;
|
|
|
|
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
|
|
|
|
Properties::Apropos (const char *keyword, std::vector<const Property *> &matching_properties) const
|
2010-09-04 08:03:46 +08:00
|
|
|
{
|
2012-08-23 01:17:09 +08:00
|
|
|
OptionValuePropertiesSP properties_sp (GetValueProperties ());
|
|
|
|
if (properties_sp)
|
2012-01-30 15:41:31 +08:00
|
|
|
{
|
2012-08-23 01:17:09 +08:00
|
|
|
properties_sp->Apropos (keyword, matching_properties);
|
2012-01-30 15:41:31 +08:00
|
|
|
}
|
2012-08-23 01:17:09 +08:00
|
|
|
return matching_properties.size();
|
2012-01-28 05:27:39 +08:00
|
|
|
}
|
2012-10-20 02:02:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|