llvm-project/lldb/source/Core/UserSettingsController.cpp

115 lines
3.8 KiB
C++
Raw Normal View History

//====-- 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 "lldb/Core/UserSettingsController.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
#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;
}
Added new target instance settings for execution settings: Targets can now specify some additional parameters for when we debug executables that can help with plug-in selection: target.execution-level = auto | user | kernel target.execution-mode = auto | dynamic | static target.execution-os-type = auto | none | halted | live On some systems, the binaries that are created are the same wether you use them to debug a kernel, or a user space program. Many times inspecting an object file can reveal what an executable should be. For these cases we can now be a little more complete by specifying wether to detect all of these things automatically (inspect the main executable file and select a plug-in accordingly), or manually to force the selection of certain plug-ins. To do this we now allow the specficifation of wether one is debugging a user space program (target.execution-level = user) or a kernel program (target.execution-level = kernel). We can also specify if we want to debug a program where shared libraries are dynamically loaded using a DynamicLoader plug-in (target.execution-mode = dynamic), or wether we will treat all symbol files as already linked at the correct address (target.execution-mode = static). We can also specify if the inferior we are debugging is being debugged on a bare board (target.execution-os-type = none), or debugging an OS where we have a JTAG or other direct connection to the inferior stops the entire OS (target.execution-os-type = halted), or if we are debugging a program on something that has live debug services (target.execution-os-type = live). For the "target.execution-os-type = halted" mode, we will need to create ProcessHelper plug-ins that allow us to extract the process/thread and other OS information by reading/writing memory. This should allow LLDB to be used for a wide variety of debugging tasks and handle them all correctly. llvm-svn: 125815
2011-02-18 09:44:25 +08:00
using namespace lldb;
using namespace lldb_private;
lldb::OptionValueSP
Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
llvm::StringRef path, bool will_modify,
Status &error) const {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
return lldb::OptionValueSP();
}
Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
VarSetOperationType op,
llvm::StringRef path,
llvm::StringRef value) {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->SetSubValue(exe_ctx, op, path, value);
Status error;
error.SetErrorString("no properties");
return error;
}
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);
}
void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
Stream &strm) const {
strm.PutCString("Top level variables:\n\n");
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->DumpAllDescriptions(interpreter, strm);
}
Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
Stream &strm,
llvm::StringRef property_path,
uint32_t dump_mask) {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp) {
return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
dump_mask);
}
Status error;
error.SetErrorString("empty property list");
return error;
}
size_t
Properties::Apropos(llvm::StringRef keyword,
std::vector<const Property *> &matching_properties) const {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp) {
properties_sp->Apropos(keyword, matching_properties);
}
return matching_properties.size();
}
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();
}
const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
bool Properties::IsSettingExperimental(llvm::StringRef setting) {
if (setting.empty())
return false;
llvm::StringRef experimental = GetExperimentalSettingsName();
size_t dot_pos = setting.find_first_of('.');
return setting.take_front(dot_pos) == experimental;
}