[lldb/Process] Populate queues in Scripted Process

This patch enhances queue support in Scripted Processes.

Scripted Threads could already report their queue name if they had one,
but this information was only surfaced when getting the process and
thread status.

However, no queue was create and added to the scripted process queue
list. This patch improves that by creating a queue from the scripted
thread queue name. For now, it uses an invalid queue id, since the
scripted thread doesn't expose this capability yet, but this could
easily be supported if the queue id information is available.

rdar://98844004

Differential Revision: https://reviews.llvm.org/D139853

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
Med Ismail Bennani 2023-01-12 15:27:45 -08:00
parent 6b26e1dad9
commit 44b81f621c
3 changed files with 15 additions and 1 deletions

View File

@ -2116,7 +2116,7 @@ public:
// Queue Queries
void UpdateQueueListIfNeeded();
virtual void UpdateQueueListIfNeeded();
QueueList &GetQueueList() {
UpdateQueueListIfNeeded();

View File

@ -20,6 +20,7 @@
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Interpreter/ScriptedMetadata.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Queue.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/State.h"
@ -497,6 +498,17 @@ lldb_private::StructuredData::DictionarySP ScriptedProcess::GetMetadata() {
return metadata_sp;
}
void ScriptedProcess::UpdateQueueListIfNeeded() {
CheckInterpreterAndScriptObject();
for (ThreadSP thread_sp : Threads()) {
if (const char *queue_name = thread_sp->GetQueueName()) {
QueueSP queue_sp = std::make_shared<Queue>(
m_process->shared_from_this(), thread_sp->GetQueueID(), queue_name);
m_queue_list.AddQueue(queue_sp);
}
}
}
ScriptedProcessInterface &ScriptedProcess::GetInterface() const {
return m_interpreter->GetScriptedProcessInterface();
}

View File

@ -72,6 +72,8 @@ public:
lldb_private::StructuredData::DictionarySP GetMetadata() override;
void UpdateQueueListIfNeeded() override;
protected:
ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
const ScriptedMetadata &scripted_metadata, Status &error);