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

112 lines
3.4 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/lldb-python.h"
#include <string.h>
#include <algorithm>
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValueString.h"
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,
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();
}
Error
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);
Error 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);
}
Error
Properties::DumpPropertyValue (const ExecutionContext *exe_ctx, Stream &strm, const char *property_path, uint32_t dump_mask)
{
OptionValuePropertiesSP properties_sp (GetValueProperties ());
if (properties_sp)
{
return properties_sp->DumpPropertyValue (exe_ctx,
strm,
property_path,
dump_mask);
}
Error error;
error.SetErrorString("empty property list");
return error;
}
size_t
Properties::Apropos (const char *keyword, std::vector<const Property *> &matching_properties) const
{
OptionValuePropertiesSP properties_sp (GetValueProperties ());
if (properties_sp)
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
{
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,
const ConstString &name)
{
OptionValuePropertiesSP properties_sp (GetValueProperties ());
if (properties_sp)
return properties_sp->GetSubProperty (exe_ctx, name);
return lldb::OptionValuePropertiesSP();
}