@@ -1323,38 +1323,29 @@ void DAP::StartEventThreads() {
13231323 StartEventThread ();
13241324}
13251325
1326- llvm::Error DAP::InitializeDebugger (std::optional<int > debugger_id,
1327- std::optional<lldb::user_id_t > target_id) {
1328- // Validate that both debugger_id and target_id are provided together.
1329- if (debugger_id.has_value () != target_id.has_value ()) {
1326+ llvm::Error DAP::InitializeDebugger (int debugger_id,
1327+ lldb::user_id_t target_id) {
1328+ // Find the existing debugger by ID
1329+ debugger = lldb::SBDebugger::FindDebuggerWithID (debugger_id);
1330+ if (!debugger.IsValid ()) {
13301331 return llvm::createStringError (
1331- " Both debuggerId and targetId must be specified together for debugger "
1332- " reuse, or both must be omitted to create a new debugger" );
1332+ " Unable to find existing debugger for debugger ID" );
13331333 }
13341334
1335- // Initialize debugger instance (shared or individual).
1336- if (debugger_id && target_id) {
1337- // Find the existing debugger by ID
1338- debugger = lldb::SBDebugger::FindDebuggerWithID (*debugger_id);
1339- if (!debugger.IsValid ()) {
1340- return llvm::createStringError (
1341- " Unable to find existing debugger for debugger ID" );
1342- }
1343-
1344- // Find the target within the debugger by its globally unique ID
1345- lldb::SBTarget shared_target =
1346- debugger.FindTargetByGloballyUniqueID (*target_id);
1347- if (!shared_target.IsValid ()) {
1348- return llvm::createStringError (
1349- " Unable to find existing target for target ID" );
1350- }
1351-
1352- // Set the target for this DAP session.
1353- SetTarget (shared_target);
1354- StartEventThreads ();
1355- return llvm::Error::success ();
1335+ // Find the target within the debugger by its globally unique ID
1336+ lldb::SBTarget target = debugger.FindTargetByGloballyUniqueID (target_id);
1337+ if (!target.IsValid ()) {
1338+ return llvm::createStringError (
1339+ " Unable to find existing target for target ID" );
13561340 }
13571341
1342+ // Set the target for this DAP session.
1343+ SetTarget (target);
1344+ StartEventThreads ();
1345+ return llvm::Error::success ();
1346+ }
1347+
1348+ llvm::Error DAP::InitializeDebugger () {
13581349 debugger = lldb::SBDebugger::Create (/* argument_name=*/ false );
13591350
13601351 // Configure input/output/error file descriptors.
0 commit comments