@@ -1321,38 +1321,30 @@ void DAP::StartEventThreads() {
13211321 StartEventThread ();
13221322}
13231323
1324- llvm::Error DAP::InitializeDebugger (std::optional<int > debugger_id,
1325- std::optional<lldb::user_id_t > target_id) {
1326- // Validate that both debugger_id and target_id are provided together.
1327- if (debugger_id.has_value () != target_id.has_value ()) {
1324+ llvm::Error DAP::InitializeDebugger (int debugger_id,
1325+ lldb::user_id_t target_id) {
1326+ // Find the existing debugger by ID
1327+ debugger = lldb::SBDebugger::FindDebuggerWithID (debugger_id);
1328+ if (!debugger.IsValid ()) {
13281329 return llvm::createStringError (
1329- " Both debuggerId and targetId must be specified together for debugger "
1330- " reuse, or both must be omitted to create a new debugger" );
1330+ " Unable to find existing debugger for debugger ID" );
13311331 }
13321332
1333- // Initialize debugger instance (shared or individual).
1334- if (debugger_id && target_id) {
1335- // Find the existing debugger by ID
1336- debugger = lldb::SBDebugger::FindDebuggerWithID (*debugger_id);
1337- if (!debugger.IsValid ()) {
1338- return llvm::createStringError (
1339- " Unable to find existing debugger for debugger ID" );
1340- }
1341-
1342- // Find the target within the debugger by its globally unique ID
1343- lldb::SBTarget shared_target =
1344- debugger.FindTargetByGloballyUniqueID (*target_id);
1345- if (!shared_target.IsValid ()) {
1346- return llvm::createStringError (
1347- " Unable to find existing target for target ID" );
1348- }
1349-
1350- // Set the target for this DAP session.
1351- SetTarget (shared_target);
1352- StartEventThreads ();
1353- return llvm::Error::success ();
1333+ // Find the target within the debugger by its globally unique ID
1334+ lldb::SBTarget shared_target =
1335+ debugger.FindTargetByGloballyUniqueID (target_id);
1336+ if (!shared_target.IsValid ()) {
1337+ return llvm::createStringError (
1338+ " Unable to find existing target for target ID" );
13541339 }
13551340
1341+ // Set the target for this DAP session.
1342+ SetTarget (shared_target);
1343+ StartEventThreads ();
1344+ return llvm::Error::success ();
1345+ }
1346+
1347+ llvm::Error DAP::InitializeDebugger () {
13561348 debugger = lldb::SBDebugger::Create (/* argument_name=*/ false );
13571349
13581350 // Configure input/output/error file descriptors.
0 commit comments