diff options
| author | Janet Yang <qxy11@meta.com> | 2025-10-07 15:36:47 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-07 15:36:47 -0400 |
| commit | 7546bd38041612e8b768f4b315e491cd549d608c (patch) | |
| tree | 1f3a2d5968b76943957bf34aca49120dad272b64 /lldb/source/API/SBDebugger.cpp | |
| parent | 981dadcd60481939bdc8917c6f15cb6232313bc1 (diff) | |
| download | llvm-7546bd38041612e8b768f4b315e491cd549d608c.zip llvm-7546bd38041612e8b768f4b315e491cd549d608c.tar.gz llvm-7546bd38041612e8b768f4b315e491cd549d608c.tar.bz2 | |
[lldb] Add support for unique target ids (#160736)
### Summary
Add support for unique target ids per Target instance. This is needed
for upcoming changes to allow debugger instances to be shared across
separate DAP instances for child process debugging. We want the IDE to
be able to attach to existing targets in an already runny lldb-dap
session, and having a unique ID per target would make that easier.
Each Target instance will have its own unique id, and uses a
function-local counter in `TargetList::CreateTargetInternal` to assign
incremental unique ids.
### Tests
Added several unit tests to test basic functionality, uniqueness of
targets, and target deletion doesn't affect the uniqueness.
```
bin/lldb-dotest -p TestDebuggerAPI
```
Diffstat (limited to 'lldb/source/API/SBDebugger.cpp')
| -rw-r--r-- | lldb/source/API/SBDebugger.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 603e306..5c4c653 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -983,6 +983,17 @@ uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP()); } +SBTarget SBDebugger::FindTargetByGloballyUniqueID(lldb::user_id_t id) { + LLDB_INSTRUMENT_VA(this, id); + SBTarget sb_target; + if (m_opaque_sp) { + // No need to lock, the target list is thread safe + sb_target.SetSP( + m_opaque_sp->GetTargetList().FindTargetByGloballyUniqueID(id)); + } + return sb_target; +} + SBTarget SBDebugger::FindTargetWithProcessID(lldb::pid_t pid) { LLDB_INSTRUMENT_VA(this, pid); |
