Fixed an issue where if the operating system python plug-in is changed at runtime, it wouldn't cause the process to reload the new operating system plug-in, now it does.

This is currently controlled by a setting:

(lldb) settings set target.process.python-os-plugin-path <path>

Or clearing it with:

(lldb) settings clear target.process.python-os-plugin-path 

The process will now reload the OperatingSystem plug-in.

This was implemented by:
- adding the ability to set a notify callback for when an option value is changed
- added the ability for the process plug-in to load the operating system plug-in on the fly
- fixed bugs in the Process::GetStatus() so all threads are displayed if their thread IDs are larger than 32 bits
- adding a callback in ProcessProperties to tell when the "python-os-plugin-path" is changed by the user
- fixing a crasher in ProcessMachCore that happens when updating the thread list when the OS plugin is reloaded

llvm-svn: 225831
This commit is contained in:
Greg Clayton 2015-01-13 21:13:08 +00:00
parent 6a4848324b
commit 332e8b1cd4
23 changed files with 161 additions and 31 deletions

View File

@ -60,11 +60,15 @@ namespace lldb_private {
OptionValue () : OptionValue () :
m_callback (nullptr),
m_baton(nullptr),
m_value_was_set (false) m_value_was_set (false)
{ {
} }
OptionValue (const OptionValue &rhs) : OptionValue (const OptionValue &rhs) :
m_callback (rhs.m_callback),
m_baton (rhs.m_baton),
m_value_was_set (rhs.m_value_was_set) m_value_was_set (rhs.m_value_was_set)
{ {
} }
@ -381,8 +385,26 @@ namespace lldb_private {
{ {
m_parent_wp = parent_sp; m_parent_wp = parent_sp;
} }
void
SetValueChangedCallback (OptionValueChangedCallback callback,
void *baton)
{
assert (m_callback == NULL);
m_callback = callback;
m_baton = baton;
}
void
NotifyValueChanged ()
{
if (m_callback)
m_callback (m_baton, this);
}
protected: protected:
lldb::OptionValueWP m_parent_wp; lldb::OptionValueWP m_parent_wp;
OptionValueChangedCallback m_callback;
void *m_baton;
bool m_value_was_set; // This can be used to see if a value has been set bool m_value_was_set; // This can be used to see if a value has been set
// by a call to SetValueFromCString(). It is often // by a call to SetValueFromCString(). It is often
// handy to know if an option value was set from // handy to know if an option value was set from

View File

@ -243,8 +243,20 @@ public:
GetSubProperty (const ExecutionContext *exe_ctx, GetSubProperty (const ExecutionContext *exe_ctx,
const ConstString &name); const ConstString &name);
void
SetValueChangedCallback (uint32_t property_idx,
OptionValueChangedCallback callback,
void *baton);
protected: protected:
Property *
ProtectedGetPropertyAtIndex (uint32_t idx)
{
if (idx < m_properties.size())
return &m_properties[idx];
return NULL;
}
const Property * const Property *
ProtectedGetPropertyAtIndex (uint32_t idx) const ProtectedGetPropertyAtIndex (uint32_t idx) const
{ {

View File

@ -97,6 +97,9 @@ namespace lldb_private {
uint32_t output_width, uint32_t output_width,
bool display_qualified_name) const; bool display_qualified_name) const;
void
SetValueChangedCallback (OptionValueChangedCallback callback, void *baton);
protected: protected:
ConstString m_name; ConstString m_name;
ConstString m_description; ConstString m_description;

View File

@ -62,7 +62,8 @@ namespace lldb_private {
class ProcessProperties : public Properties class ProcessProperties : public Properties
{ {
public: public:
ProcessProperties(bool is_global); // Pass NULL for "process" if the ProcessProperties are to be the global copy
ProcessProperties (lldb_private::Process *process);
virtual virtual
~ProcessProperties(); ~ProcessProperties();
@ -108,6 +109,13 @@ public:
void void
SetDetachKeepsStopped (bool keep_stopped); SetDetachKeepsStopped (bool keep_stopped);
protected:
static void
OptionValueChangedCallback (void *baton, OptionValue *option_value);
Process * m_process; // Can be NULL for global ProcessProperties
}; };
typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP; typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;
@ -2814,6 +2822,7 @@ public:
Process &m_process; Process &m_process;
}; };
friend class ProcessEventHijacker; friend class ProcessEventHijacker;
friend class ProcessProperties;
//------------------------------------------------------------------ //------------------------------------------------------------------
/// If you need to ensure that you and only you will hear about some public /// If you need to ensure that you and only you will hear about some public
/// event, then make a new listener, set to listen to process events, and /// event, then make a new listener, set to listen to process events, and
@ -3279,6 +3288,8 @@ protected:
bool bool
StateChangedIsExternallyHijacked(); StateChangedIsExternallyHijacked();
void
LoadOperatingSystemPlugin(bool flush);
private: private:
//------------------------------------------------------------------ //------------------------------------------------------------------
// For Process only // For Process only

View File

@ -36,6 +36,7 @@ namespace lldb_private
typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm); // Module can be NULL for default system symbol vendor typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm); // Module can be NULL for default system symbol vendor
typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
typedef bool (*WatchpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id); typedef bool (*WatchpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id);
typedef void (*OptionValueChangedCallback) (void *baton, OptionValue *option_value);
typedef bool (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton); typedef bool (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton); typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
typedef UnwindAssembly* (*UnwindAssemblyCreateInstance) (const ArchSpec &arch); typedef UnwindAssembly* (*UnwindAssemblyCreateInstance) (const ArchSpec &arch);

View File

@ -50,6 +50,7 @@ OptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationTyp
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear(); Clear();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -57,7 +58,10 @@ OptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationTyp
if (value_cstr && value_cstr[0]) if (value_cstr && value_cstr[0])
{ {
if (m_current_value.SetTriple (value_cstr)) if (m_current_value.SetTriple (value_cstr))
{
m_value_was_set = true; m_value_was_set = true;
NotifyValueChanged();
}
else else
error.SetErrorStringWithFormat("unsupported architecture '%s'", value_cstr); error.SetErrorStringWithFormat("unsupported architecture '%s'", value_cstr);
} }

View File

@ -76,6 +76,7 @@ Error
OptionValueArray::SetValueFromCString (const char *value, VarSetOperationType op) OptionValueArray::SetValueFromCString (const char *value, VarSetOperationType op)
{ {
Args args(value); Args args(value);
NotifyValueChanged();
return SetArgs (args, op); return SetArgs (args, op);
} }

View File

@ -45,6 +45,7 @@ OptionValueBoolean::SetValueFromCString (const char *value_cstr,
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear(); Clear();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -56,6 +57,7 @@ OptionValueBoolean::SetValueFromCString (const char *value_cstr,
{ {
m_value_was_set = true; m_value_was_set = true;
m_current_value = value; m_current_value = value;
NotifyValueChanged();
} }
else else
{ {

View File

@ -221,7 +221,10 @@ Error
OptionValueDictionary::SetValueFromCString (const char *value_cstr, VarSetOperationType op) OptionValueDictionary::SetValueFromCString (const char *value_cstr, VarSetOperationType op)
{ {
Args args(value_cstr); Args args(value_cstr);
return SetArgs (args, op); Error error = SetArgs (args, op);
if (error.Success())
NotifyValueChanged();
return error;
} }
lldb::OptionValueSP lldb::OptionValueSP

View File

@ -62,6 +62,7 @@ OptionValueEnumeration::SetValueFromCString (const char *value, VarSetOperationT
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear (); Clear ();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -73,6 +74,7 @@ OptionValueEnumeration::SetValueFromCString (const char *value, VarSetOperationT
if (enumerator_entry) if (enumerator_entry)
{ {
m_current_value = enumerator_entry->value.value; m_current_value = enumerator_entry->value.value;
NotifyValueChanged();
} }
else else
{ {

View File

@ -78,6 +78,7 @@ OptionValueFileSpec::SetValueFromCString (const char *value_cstr,
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear (); Clear ();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -100,6 +101,7 @@ OptionValueFileSpec::SetValueFromCString (const char *value_cstr,
m_value_was_set = true; m_value_was_set = true;
m_current_value.SetFile(filepath.c_str(), true); m_current_value.SetFile(filepath.c_str(), true);
m_data_sp.reset(); m_data_sp.reset();
NotifyValueChanged();
} }
else else
{ {

View File

@ -51,6 +51,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear (); Clear ();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -72,6 +73,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
else else
m_current_value.Append(file); m_current_value.Append(file);
} }
NotifyValueChanged();
} }
} }
else else
@ -94,6 +96,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
FileSpec file (args.GetArgumentAtIndex(i), false); FileSpec file (args.GetArgumentAtIndex(i), false);
m_current_value.Append(file); m_current_value.Append(file);
} }
NotifyValueChanged();
} }
else else
{ {
@ -120,6 +123,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
FileSpec file (args.GetArgumentAtIndex(i), false); FileSpec file (args.GetArgumentAtIndex(i), false);
m_current_value.Insert (idx, file); m_current_value.Insert (idx, file);
} }
NotifyValueChanged();
} }
} }
else else
@ -155,6 +159,7 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
m_current_value.Remove (j); m_current_value.Remove (j);
} }
} }
NotifyValueChanged();
} }
else else
{ {

View File

@ -43,6 +43,7 @@ OptionValueFormat::SetValueFromCString (const char *value_cstr, VarSetOperationT
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear(); Clear();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -54,6 +55,7 @@ OptionValueFormat::SetValueFromCString (const char *value_cstr, VarSetOperationT
{ {
m_value_was_set = true; m_value_was_set = true;
m_current_value = new_format; m_current_value = new_format;
NotifyValueChanged();
} }
} }
break; break;

View File

@ -43,6 +43,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear (); Clear ();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -64,6 +65,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
if (!m_path_mappings.Replace (a, b, idx, m_notify_changes)) if (!m_path_mappings.Replace (a, b, idx, m_notify_changes))
m_path_mappings.Append(a, b, m_notify_changes); m_path_mappings.Append(a, b, m_notify_changes);
} }
NotifyValueChanged();
} }
} }
else else
@ -97,6 +99,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
m_path_mappings.Append(a, b, m_notify_changes); m_path_mappings.Append(a, b, m_notify_changes);
m_value_was_set = true; m_value_was_set = true;
} }
NotifyValueChanged();
} }
break; break;
@ -121,6 +124,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
ConstString b(args.GetArgumentAtIndex(i+1)); ConstString b(args.GetArgumentAtIndex(i+1));
m_path_mappings.Insert (a, b, idx, m_notify_changes); m_path_mappings.Insert (a, b, idx, m_notify_changes);
} }
NotifyValueChanged();
} }
} }
else else
@ -156,6 +160,7 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
m_path_mappings.Remove (j, m_notify_changes); m_path_mappings.Remove (j, m_notify_changes);
} }
} }
NotifyValueChanged();
} }
else else
{ {

View File

@ -80,6 +80,16 @@ OptionValueProperties::Initialize (const PropertyDefinition *defs)
m_name_to_index.Sort(); m_name_to_index.Sort();
} }
void
OptionValueProperties::SetValueChangedCallback (uint32_t property_idx,
OptionValueChangedCallback callback,
void *baton)
{
Property *property = ProtectedGetPropertyAtIndex (property_idx);
if (property)
property->SetValueChangedCallback (callback, baton);
}
void void
OptionValueProperties::AppendProperty(const ConstString &name, OptionValueProperties::AppendProperty(const ConstString &name,
const ConstString &desc, const ConstString &desc,

View File

@ -57,6 +57,7 @@ OptionValueRegex::SetValueFromCString (const char *value_cstr,
case eVarSetOperationClear: case eVarSetOperationClear:
Clear(); Clear();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -64,6 +65,7 @@ OptionValueRegex::SetValueFromCString (const char *value_cstr,
if (m_regex.Compile (value_cstr, m_regex.GetCompileFlags())) if (m_regex.Compile (value_cstr, m_regex.GetCompileFlags()))
{ {
m_value_was_set = true; m_value_was_set = true;
NotifyValueChanged();
} }
else else
{ {

View File

@ -44,6 +44,7 @@ OptionValueSInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear(); Clear();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -57,6 +58,7 @@ OptionValueSInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
{ {
m_value_was_set = true; m_value_was_set = true;
m_current_value = value; m_current_value = value;
NotifyValueChanged();
} }
else else
error.SetErrorStringWithFormat ("%" PRIi64 " is out of range, valid values must be between %" PRIi64 " and %" PRIi64 ".", error.SetErrorStringWithFormat ("%" PRIi64 " is out of range, valid values must be between %" PRIi64 " and %" PRIi64 ".",

View File

@ -94,30 +94,32 @@ OptionValueString::SetValueFromCString (const char *value_cstr,
case eVarSetOperationAppend: case eVarSetOperationAppend:
{ {
std::string new_value(m_current_value); std::string new_value(m_current_value);
if (value_cstr && value_cstr[0]) if (value_cstr && value_cstr[0])
{
if (m_options.Test (eOptionEncodeCharacterEscapeSequences))
{ {
std::string str; if (m_options.Test (eOptionEncodeCharacterEscapeSequences))
Args::EncodeEscapeSequences (value_cstr, str); {
new_value.append(str); std::string str;
Args::EncodeEscapeSequences (value_cstr, str);
new_value.append(str);
}
else
new_value.append(value_cstr);
} }
else if (m_validator)
new_value.append(value_cstr); {
} error = m_validator(new_value.c_str(),m_validator_baton);
if (m_validator) if (error.Fail())
{ return error;
error = m_validator(new_value.c_str(),m_validator_baton); }
if (error.Fail()) m_current_value.assign(new_value);
return error; NotifyValueChanged();
}
m_current_value.assign(new_value);
} }
break; break;
case eVarSetOperationClear: case eVarSetOperationClear:
Clear (); Clear ();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -137,6 +139,7 @@ OptionValueString::SetValueFromCString (const char *value_cstr,
{ {
SetCurrentValue (value_cstr); SetCurrentValue (value_cstr);
} }
NotifyValueChanged();
break; break;
} }
return error; return error;

View File

@ -51,6 +51,7 @@ OptionValueUInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear (); Clear ();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -62,6 +63,7 @@ OptionValueUInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
{ {
m_value_was_set = true; m_value_was_set = true;
m_current_value = value; m_current_value = value;
NotifyValueChanged();
} }
else else
{ {

View File

@ -45,6 +45,7 @@ OptionValueUUID::SetValueFromCString (const char *value_cstr,
{ {
case eVarSetOperationClear: case eVarSetOperationClear:
Clear(); Clear();
NotifyValueChanged();
break; break;
case eVarSetOperationReplace: case eVarSetOperationReplace:
@ -53,7 +54,10 @@ OptionValueUUID::SetValueFromCString (const char *value_cstr,
if (m_uuid.SetFromCString(value_cstr) == 0) if (m_uuid.SetFromCString(value_cstr) == 0)
error.SetErrorStringWithFormat ("invalid uuid string value '%s'", value_cstr); error.SetErrorStringWithFormat ("invalid uuid string value '%s'", value_cstr);
else else
{
m_value_was_set = true; m_value_was_set = true;
NotifyValueChanged();
}
} }
break; break;

View File

@ -277,3 +277,12 @@ Property::DumpDescription (CommandInterpreter &interpreter,
} }
} }
void
Property::SetValueChangedCallback (OptionValueChangedCallback callback, void *baton)
{
if (m_value_sp)
m_value_sp->SetValueChangedCallback (callback, baton);
}

View File

@ -397,7 +397,7 @@ ProcessMachCore::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_
{ {
const uint32_t num_threads = old_thread_list.GetSize(false); const uint32_t num_threads = old_thread_list.GetSize(false);
for (uint32_t i=0; i<num_threads; ++i) for (uint32_t i=0; i<num_threads; ++i)
new_thread_list.AddThread (old_thread_list.GetThreadAtIndex (i)); new_thread_list.AddThread (old_thread_list.GetThreadAtIndex (i, false));
} }
return new_thread_list.GetSize(false) > 0; return new_thread_list.GetSize(false) > 0;
} }

View File

@ -127,11 +127,13 @@ enum {
ePropertyMemCacheLineSize ePropertyMemCacheLineSize
}; };
ProcessProperties::ProcessProperties (bool is_global) : ProcessProperties::ProcessProperties (lldb_private::Process *process) :
Properties () Properties (),
m_process (process) // Can be NULL for global ProcessProperties
{ {
if (is_global) if (process == NULL)
{ {
// Global process properties, set them up one time
m_collection_sp.reset (new ProcessOptionValueProperties(ConstString("process"))); m_collection_sp.reset (new ProcessOptionValueProperties(ConstString("process")));
m_collection_sp->Initialize(g_properties); m_collection_sp->Initialize(g_properties);
m_collection_sp->AppendProperty(ConstString("thread"), m_collection_sp->AppendProperty(ConstString("thread"),
@ -140,13 +142,24 @@ ProcessProperties::ProcessProperties (bool is_global) :
Thread::GetGlobalProperties()->GetValueProperties()); Thread::GetGlobalProperties()->GetValueProperties());
} }
else else
{
m_collection_sp.reset (new ProcessOptionValueProperties(Process::GetGlobalProperties().get())); m_collection_sp.reset (new ProcessOptionValueProperties(Process::GetGlobalProperties().get()));
m_collection_sp->SetValueChangedCallback(ePropertyPythonOSPluginPath, ProcessProperties::OptionValueChangedCallback, this);
}
} }
ProcessProperties::~ProcessProperties() ProcessProperties::~ProcessProperties()
{ {
} }
void
ProcessProperties::OptionValueChangedCallback (void *baton, OptionValue *option_value)
{
ProcessProperties *properties = (ProcessProperties *)baton;
if (properties->m_process)
properties->m_process->LoadOperatingSystemPlugin(true);
}
bool bool
ProcessProperties::GetDisableMemoryCache() const ProcessProperties::GetDisableMemoryCache() const
{ {
@ -673,7 +686,7 @@ Process::Process(Target &target, Listener &listener) :
} }
Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_signals_sp) : Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_signals_sp) :
ProcessProperties (false), ProcessProperties (this),
UserID (LLDB_INVALID_PROCESS_ID), UserID (LLDB_INVALID_PROCESS_ID),
Broadcaster (&(target.GetDebugger()), "lldb.process"), Broadcaster (&(target.GetDebugger()), "lldb.process"),
m_target (target), m_target (target),
@ -786,7 +799,7 @@ Process::GetGlobalProperties()
{ {
static ProcessPropertiesSP g_settings_sp; static ProcessPropertiesSP g_settings_sp;
if (!g_settings_sp) if (!g_settings_sp)
g_settings_sp.reset (new ProcessProperties (true)); g_settings_sp.reset (new ProcessProperties (NULL));
return g_settings_sp; return g_settings_sp;
} }
@ -2994,6 +3007,16 @@ Process::WaitForProcessStopPrivate (const TimeValue *timeout, EventSP &event_sp)
return state; return state;
} }
void
Process::LoadOperatingSystemPlugin(bool flush)
{
if (flush)
m_thread_list.Clear();
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
if (flush)
Flush();
}
Error Error
Process::Launch (ProcessLaunchInfo &launch_info) Process::Launch (ProcessLaunchInfo &launch_info)
{ {
@ -3084,7 +3107,7 @@ Process::Launch (ProcessLaunchInfo &launch_info)
if (system_runtime) if (system_runtime)
system_runtime->DidLaunch(); system_runtime->DidLaunch();
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL)); LoadOperatingSystemPlugin(false);
// Note, the stop event was consumed above, but not handled. This was done // Note, the stop event was consumed above, but not handled. This was done
// to give DidLaunch a chance to run. The target is either stopped or crashed. // to give DidLaunch a chance to run. The target is either stopped or crashed.
@ -6142,21 +6165,21 @@ Process::GetThreadStatus (Stream &strm,
// ID's, and look them up one by one: // ID's, and look them up one by one:
uint32_t num_threads; uint32_t num_threads;
std::vector<uint32_t> thread_index_array; std::vector<lldb::tid_t> thread_id_array;
//Scope for thread list locker; //Scope for thread list locker;
{ {
Mutex::Locker locker (GetThreadList().GetMutex()); Mutex::Locker locker (GetThreadList().GetMutex());
ThreadList &curr_thread_list = GetThreadList(); ThreadList &curr_thread_list = GetThreadList();
num_threads = curr_thread_list.GetSize(); num_threads = curr_thread_list.GetSize();
uint32_t idx; uint32_t idx;
thread_index_array.resize(num_threads); thread_id_array.resize(num_threads);
for (idx = 0; idx < num_threads; ++idx) for (idx = 0; idx < num_threads; ++idx)
thread_index_array[idx] = curr_thread_list.GetThreadAtIndex(idx)->GetID(); thread_id_array[idx] = curr_thread_list.GetThreadAtIndex(idx)->GetID();
} }
for (uint32_t i = 0; i < num_threads; i++) for (uint32_t i = 0; i < num_threads; i++)
{ {
ThreadSP thread_sp(GetThreadList().FindThreadByID(thread_index_array[i])); ThreadSP thread_sp(GetThreadList().FindThreadByID(thread_id_array[i]));
if (thread_sp) if (thread_sp)
{ {
if (only_threads_with_stop_reason) if (only_threads_with_stop_reason)