@@ -508,13 +508,14 @@ void request_attach(const llvm::json::Object &request) {
508
508
llvm::json::Object response;
509
509
lldb::SBError error;
510
510
FillResponse (request, response);
511
+ lldb::SBAttachInfo attach_info;
511
512
auto arguments = request.getObject (" arguments" );
512
513
const lldb::pid_t pid =
513
514
GetUnsigned (arguments, " pid" , LLDB_INVALID_PROCESS_ID);
514
515
if (pid != LLDB_INVALID_PROCESS_ID)
515
- g_vsc. attach_info .SetProcessID (pid);
516
+ attach_info.SetProcessID (pid);
516
517
const auto wait_for = GetBoolean (arguments, " waitFor" , false );
517
- g_vsc. attach_info .SetWaitForLaunch (wait_for, false /* async*/ );
518
+ attach_info.SetWaitForLaunch (wait_for, false /* async*/ );
518
519
g_vsc.init_commands = GetStrings (arguments, " initCommands" );
519
520
g_vsc.pre_run_commands = GetStrings (arguments, " preRunCommands" );
520
521
g_vsc.stop_commands = GetStrings (arguments, " stopCommands" );
@@ -547,20 +548,19 @@ void request_attach(const llvm::json::Object &request) {
547
548
g_vsc.RunPreRunCommands ();
548
549
549
550
if (pid == LLDB_INVALID_PROCESS_ID && wait_for) {
550
- char attach_info[256 ];
551
- auto attach_info_len =
552
- snprintf (attach_info, sizeof (attach_info),
553
- " Waiting to attach to \" %s\" ..." ,
554
- g_vsc.target .GetExecutable ().GetFilename ());
555
- g_vsc.SendOutput (OutputType::Console, llvm::StringRef (attach_info,
556
- attach_info_len));
551
+ char attach_msg[256 ];
552
+ auto attach_msg_len = snprintf (attach_msg, sizeof (attach_msg),
553
+ " Waiting to attach to \" %s\" ..." ,
554
+ g_vsc.target .GetExecutable ().GetFilename ());
555
+ g_vsc.SendOutput (OutputType::Console,
556
+ llvm::StringRef (attach_msg, attach_msg_len));
557
557
}
558
558
if (attachCommands.empty ()) {
559
559
// No "attachCommands", just attach normally.
560
560
// Disable async events so the attach will be successful when we return from
561
561
// the launch call and the launch will happen synchronously
562
562
g_vsc.debugger .SetAsync (false );
563
- g_vsc.target .Attach (g_vsc. attach_info , error);
563
+ g_vsc.target .Attach (attach_info, error);
564
564
// Reenable async events
565
565
g_vsc.debugger .SetAsync (true );
566
566
} else {
@@ -1381,26 +1381,26 @@ void request_launch(const llvm::json::Object &request) {
1381
1381
}
1382
1382
1383
1383
// Instantiate a launch info instance for the target.
1384
- g_vsc. launch_info = g_vsc.target .GetLaunchInfo ();
1384
+ auto launch_info = g_vsc.target .GetLaunchInfo ();
1385
1385
1386
1386
// Grab the current working directory if there is one and set it in the
1387
1387
// launch info.
1388
1388
const auto cwd = GetString (arguments, " cwd" );
1389
1389
if (!cwd.empty ())
1390
- g_vsc. launch_info .SetWorkingDirectory (cwd.data ());
1390
+ launch_info.SetWorkingDirectory (cwd.data ());
1391
1391
1392
1392
// Extract any extra arguments and append them to our program arguments for
1393
1393
// when we launch
1394
1394
auto args = GetStrings (arguments, " args" );
1395
1395
if (!args.empty ())
1396
- g_vsc. launch_info .SetArguments (MakeArgv (args).data (), true );
1396
+ launch_info.SetArguments (MakeArgv (args).data (), true );
1397
1397
1398
1398
// Pass any environment variables along that the user specified.
1399
1399
auto envs = GetStrings (arguments, " env" );
1400
1400
if (!envs.empty ())
1401
- g_vsc. launch_info .SetEnvironmentEntries (MakeArgv (envs).data (), true );
1401
+ launch_info.SetEnvironmentEntries (MakeArgv (envs).data (), true );
1402
1402
1403
- auto flags = g_vsc. launch_info .GetLaunchFlags ();
1403
+ auto flags = launch_info.GetLaunchFlags ();
1404
1404
1405
1405
if (GetBoolean (arguments, " disableASLR" , true ))
1406
1406
flags |= lldb::eLaunchFlagDisableASLR;
@@ -1409,17 +1409,17 @@ void request_launch(const llvm::json::Object &request) {
1409
1409
if (GetBoolean (arguments, " shellExpandArguments" , false ))
1410
1410
flags |= lldb::eLaunchFlagShellExpandArguments;
1411
1411
const bool detatchOnError = GetBoolean (arguments, " detachOnError" , false );
1412
- g_vsc. launch_info .SetDetachOnError (detatchOnError);
1413
- g_vsc. launch_info .SetLaunchFlags (flags | lldb::eLaunchFlagDebug |
1414
- lldb::eLaunchFlagStopAtEntry);
1412
+ launch_info.SetDetachOnError (detatchOnError);
1413
+ launch_info.SetLaunchFlags (flags | lldb::eLaunchFlagDebug |
1414
+ lldb::eLaunchFlagStopAtEntry);
1415
1415
1416
1416
// Run any pre run LLDB commands the user specified in the launch.json
1417
1417
g_vsc.RunPreRunCommands ();
1418
1418
if (launchCommands.empty ()) {
1419
1419
// Disable async events so the launch will be successful when we return from
1420
1420
// the launch call and the launch will happen synchronously
1421
1421
g_vsc.debugger .SetAsync (false );
1422
- g_vsc.target .Launch (g_vsc. launch_info , error);
1422
+ g_vsc.target .Launch (launch_info, error);
1423
1423
g_vsc.debugger .SetAsync (true );
1424
1424
} else {
1425
1425
g_vsc.RunLLDBCommands (" Running launchCommands:" , launchCommands);
0 commit comments