[lldb/Properties] Move OSPluginReportsAllThreads from Target to Process

This is what Jim wanted originally.

rdar://problem/61236293

Differential revision: https://reviews.llvm.org/D80159
This commit is contained in:
Jonas Devlieghere 2020-05-19 11:16:57 -07:00
parent 5fae613a4f
commit 018e5a96ee
6 changed files with 74 additions and 45 deletions

View File

@ -58,7 +58,11 @@ namespace lldb_private {
template <typename B, typename S> struct Range;
// ProcessProperties
class ProcessExperimentalProperties : public Properties {
public:
ProcessExperimentalProperties();
};
class ProcessProperties : public Properties {
public:
// Pass nullptr for "process" if the ProcessProperties are to be the global
@ -84,9 +88,12 @@ public:
bool GetWarningsOptimization() const;
bool GetStopOnExec() const;
std::chrono::seconds GetUtilityExpressionTimeout() const;
bool GetOSPluginReportsAllThreads() const;
void SetOSPluginReportsAllThreads(bool does_report);
protected:
Process *m_process; // Can be nullptr for global ProcessProperties
std::unique_ptr<ProcessExperimentalProperties> m_experimental_properties_up;
};
typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;

View File

@ -64,7 +64,6 @@ enum LoadDependentFiles {
eLoadDependentsNo,
};
// TargetProperties
class TargetExperimentalProperties : public Properties {
public:
TargetExperimentalProperties();
@ -207,10 +206,6 @@ public:
void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
bool GetOSPluginReportsAllThreads() const;
void SetOSPluginReportsAllThreads(bool does_report);
void SetRequireHardwareBreakpoints(bool b);
bool GetRequireHardwareBreakpoints() const;

View File

@ -120,8 +120,30 @@ public:
enum {
#define LLDB_PROPERTIES_process
#include "TargetPropertiesEnum.inc"
ePropertyExperimental,
};
#define LLDB_PROPERTIES_process_experimental
#include "TargetProperties.inc"
enum {
#define LLDB_PROPERTIES_process_experimental
#include "TargetPropertiesEnum.inc"
};
class ProcessExperimentalOptionValueProperties : public OptionValueProperties {
public:
ProcessExperimentalOptionValueProperties()
: OptionValueProperties(
ConstString(Properties::GetExperimentalSettingsName())) {}
};
ProcessExperimentalProperties::ProcessExperimentalProperties()
: Properties(OptionValuePropertiesSP(
new ProcessExperimentalOptionValueProperties())) {
m_collection_sp->Initialize(g_process_experimental_properties);
}
ProcessProperties::ProcessProperties(lldb_private::Process *process)
: Properties(),
m_process(process) // Can be nullptr for global ProcessProperties
@ -141,6 +163,13 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
ePropertyPythonOSPluginPath,
[this] { m_process->LoadOperatingSystemPlugin(true); });
}
m_experimental_properties_up.reset(new ProcessExperimentalProperties());
m_collection_sp->AppendProperty(
ConstString(Properties::GetExperimentalSettingsName()),
ConstString("Experimental settings - setting these won't produce "
"errors if the setting is not present."),
true, m_experimental_properties_up->GetValueProperties());
}
ProcessProperties::~ProcessProperties() = default;
@ -242,6 +271,29 @@ std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const {
return std::chrono::seconds(value);
}
bool ProcessProperties::GetOSPluginReportsAllThreads() const {
const bool fail_value = true;
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (!exp_values)
return fail_value;
return exp_values->GetPropertyAtIndexAsBoolean(
nullptr, ePropertyOSPluginReportsAllThreads, fail_value);
}
void ProcessProperties::SetOSPluginReportsAllThreads(bool does_report) {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
exp_values->SetPropertyAtIndexAsBoolean(
nullptr, ePropertyOSPluginReportsAllThreads, does_report);
}
Status ProcessLaunchCommandOptions::SetOptionValue(
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
@ -1213,7 +1265,7 @@ void Process::UpdateThreadListIfNeeded() {
// See if the OS plugin reports all threads. If it does, then
// it is safe to clear unseen thread's plans here. Otherwise we
// should preserve them in case they show up again:
clear_unused_threads = GetTarget().GetOSPluginReportsAllThreads();
clear_unused_threads = GetOSPluginReportsAllThreads();
// Turn off dynamic types to ensure we don't run any expressions.
// Objective-C can run an expression to determine if a SBValue is a

View File

@ -3373,11 +3373,11 @@ public:
};
// TargetProperties
#define LLDB_PROPERTIES_experimental
#define LLDB_PROPERTIES_target_experimental
#include "TargetProperties.inc"
enum {
#define LLDB_PROPERTIES_experimental
#define LLDB_PROPERTIES_target_experimental
#include "TargetPropertiesEnum.inc"
};
@ -3391,7 +3391,7 @@ public:
TargetExperimentalProperties::TargetExperimentalProperties()
: Properties(OptionValuePropertiesSP(
new TargetExperimentalOptionValueProperties())) {
m_collection_sp->Initialize(g_experimental_properties);
m_collection_sp->Initialize(g_target_experimental_properties);
}
// TargetProperties
@ -3487,34 +3487,6 @@ void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
true);
}
bool TargetProperties::GetOSPluginReportsAllThreads() const {
const bool fail_value = true;
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (!exp_values)
return fail_value;
return
exp_values->GetPropertyAtIndexAsBoolean(nullptr,
ePropertyOSPluginReportsAllThreads,
fail_value);
}
void TargetProperties::SetOSPluginReportsAllThreads(bool does_report) {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
exp_values->SetPropertyAtIndexAsBoolean(nullptr,
ePropertyOSPluginReportsAllThreads,
does_report);
}
ArchSpec TargetProperties::GetDefaultArchitecture() const {
OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(
nullptr, ePropertyDefaultArch);
@ -4084,7 +4056,7 @@ Target::TargetEventData::GetModuleListFromEvent(const Event *event_ptr) {
return module_list;
}
std::recursive_mutex &Target::GetAPIMutex() {
std::recursive_mutex &Target::GetAPIMutex() {
if (GetProcessSP() && GetProcessSP()->CurrentThreadIsPrivateStateThread())
return m_private_mutex;
else

View File

@ -1,13 +1,9 @@
include "../../include/lldb/Core/PropertiesBase.td"
let Definition = "experimental" in {
let Definition = "target_experimental" in {
def InjectLocalVars : Property<"inject-local-vars", "Boolean">,
Global, DefaultTrue,
Desc<"If true, inject local variables explicitly into the expression text. This will fix symbol resolution when there are name collisions between ivars and local variables. But it can make expressions run much more slowly.">;
def OSPluginReportsAllThreads: Property<"os-plugin-reports-all-threads", "Boolean">,
Global,
DefaultTrue,
Desc<"Set to False if your OS Plugins doesn't report all threads on each stop.">;
}
let Definition = "target" in {
@ -169,6 +165,13 @@ let Definition = "target" in {
Desc<"Always install the main executable when connected to a remote platform.">;
}
let Definition = "process_experimental" in {
def OSPluginReportsAllThreads: Property<"os-plugin-reports-all-threads", "Boolean">,
Global,
DefaultTrue,
Desc<"Set to False if your OS Plugins doesn't report all threads on each stop.">;
}
let Definition = "process" in {
def DisableMemCache: Property<"disable-memory-cache", "Boolean">,
DefaultFalse,

View File

@ -44,7 +44,7 @@ class TestOSPluginStepping(TestBase):
"""Test that the Python operating system plugin works correctly"""
# Our OS plugin does NOT report all threads:
result = self.dbg.HandleCommand("settings set target.experimental.os-plugin-reports-all-threads false")
result = self.dbg.HandleCommand("settings set process.experimental.os-plugin-reports-all-threads false")
python_os_plugin_path = os.path.join(self.getSourceDir(),
"operating_system.py")