<rdar://problem/13009943>
Added a unique integer identifier to processes. Some systems, like JTAG or other simulators, might always assign the same process ID (pid) to the processes that are being debugged. In order for scripts and the APIs to uniquely identify the processes, there needs to be another ID. Now the SBProcess class has:
uint32_t SBProcess::GetUniqueID();
This integer ID will help to truly uniquely identify a process and help with appropriate caching that can be associated with a SBProcess object.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@172628 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 18493de..fc527e2 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -914,6 +914,8 @@
ProcessSP
Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener, const FileSpec *crash_file_path)
{
+ static uint32_t g_process_unique_id = 0;
+
ProcessSP process_sp;
ProcessCreateInstance create_callback = NULL;
if (plugin_name)
@@ -924,7 +926,11 @@
process_sp = create_callback(target, listener, crash_file_path);
if (process_sp)
{
- if (!process_sp->CanDebug(target, true))
+ if (process_sp->CanDebug(target, true))
+ {
+ process_sp->m_process_unique_id = ++g_process_unique_id;
+ }
+ else
process_sp.reset();
}
}
@@ -936,10 +942,13 @@
process_sp = create_callback(target, listener, crash_file_path);
if (process_sp)
{
- if (!process_sp->CanDebug(target, false))
- process_sp.reset();
- else
+ if (process_sp->CanDebug(target, false))
+ {
+ process_sp->m_process_unique_id = ++g_process_unique_id;
break;
+ }
+ else
+ process_sp.reset();
}
}
}
@@ -969,6 +978,7 @@
m_private_state_control_wait(),
m_private_state_thread (LLDB_INVALID_HOST_THREAD),
m_mod_id (),
+ m_process_unique_id(0),
m_thread_index_id (0),
m_thread_id_to_index_id_map (),
m_exit_status (-1),