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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
3.8 KiB
C++
Raw Normal View History

//===-- UserSettingsController.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
#include <memory>
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);
SBFrame is now threadsafe using some extra tricks. One issue is that stack frames might go away (the object itself, not the actual logical frame) when we are single stepping due to the way we currently sometimes end up flushing frames when stepping in/out/over. They later will come back to life represented by another object yet they have the same StackID. Now when you get a lldb::SBFrame object, it will track the frame it is initialized with until the thread goes away or the StackID no longer exists in the stack for the thread it was created on. It uses a weak_ptr to both the frame and thread and also stores the StackID. These three items allow us to determine when the stack frame object has gone away (the weak_ptr will be NULL) and allows us to find the correct frame again. In our test suite we had such cases where we were just getting lucky when something like this happened: 1 - stop at breakpoint 2 - get first frame in thread where we stopped 3 - run an expression that causes the program to JIT and run code 4 - run more expressions on the frame from step 2 which was very very luckily still around inside a shared pointer, yet, not part of the current thread (a new stack frame object had appeared with the same stack ID and depth). We now avoid all such issues and properly keep up to date, or we start returning errors when the frame doesn't exist and always responds with invalid answers. Also fixed the UserSettingsController (not going to rewrite this just yet) so that it doesn't crash on shutdown. Using weak_ptr's came in real handy to track when the master controller has already gone away and this allowed me to pull out the previous NotifyOwnerIsShuttingDown() patch as it is no longer needed. llvm-svn: 149231
2012-01-30 15:41:31 +08:00
}
return matching_properties.size();
}
lldb::OptionValuePropertiesSP
Properties::GetSubProperty(const ExecutionContext *exe_ctx,
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;
}