@@ -31,7 +31,18 @@ MakeArgv(const llvm::ArrayRef<std::string> &strs) {
3131 return argv;
3232}
3333
34- // Both attach and launch take a either a sourcePath or sourceMap
34+ static uint32_t SetLaunchFlag (uint32_t flags, const llvm::json::Object *obj,
35+ llvm::StringRef key, lldb::LaunchFlags mask,
36+ bool default_value) {
37+ if (GetBoolean (obj, key).value_or (default_value))
38+ flags |= mask;
39+ else
40+ flags &= ~mask;
41+
42+ return flags;
43+ }
44+
45+ // Both attach and launch take either a sourcePath or a sourceMap
3546// argument (or neither), from which we need to set the target.source-map.
3647void RequestHandler::SetSourceMapFromArguments (
3748 const llvm::json::Object &arguments) const {
@@ -173,12 +184,13 @@ RequestHandler::LaunchProcess(const llvm::json::Object &request) const {
173184
174185 auto flags = launch_info.GetLaunchFlags ();
175186
176- if (GetBoolean (arguments, " disableASLR" ).value_or (true ))
177- flags |= lldb::eLaunchFlagDisableASLR;
178- if (GetBoolean (arguments, " disableSTDIO" ).value_or (false ))
179- flags |= lldb::eLaunchFlagDisableSTDIO;
180- if (GetBoolean (arguments, " shellExpandArguments" ).value_or (false ))
181- flags |= lldb::eLaunchFlagShellExpandArguments;
187+ flags = SetLaunchFlag (flags, arguments, " disableASLR" ,
188+ lldb::eLaunchFlagDisableASLR, true );
189+ flags = SetLaunchFlag (flags, arguments, " disableSTDIO" ,
190+ lldb::eLaunchFlagDisableSTDIO, false );
191+ flags = SetLaunchFlag (flags, arguments, " shellExpandArguments" ,
192+ lldb::eLaunchFlagShellExpandArguments, false );
193+
182194 const bool detachOnError =
183195 GetBoolean (arguments, " detachOnError" ).value_or (false );
184196 launch_info.SetDetachOnError (detachOnError);
0 commit comments