@@ -31,7 +31,19 @@ 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+ if (const auto opt_value = GetBoolean (obj, key)) {
37+ if (*opt_value)
38+ flags |= mask;
39+ else
40+ flags &= ~mask;
41+ }
42+
43+ return flags;
44+ }
45+
46+ // Both attach and launch take either a sourcePath or a sourceMap
3547// argument (or neither), from which we need to set the target.source-map.
3648void RequestHandler::SetSourceMapFromArguments (
3749 const llvm::json::Object &arguments) const {
@@ -173,12 +185,13 @@ RequestHandler::LaunchProcess(const llvm::json::Object &request) const {
173185
174186 auto flags = launch_info.GetLaunchFlags ();
175187
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;
188+ flags = SetLaunchFlag (flags, arguments, " disableASLR" ,
189+ lldb::eLaunchFlagDisableASLR);
190+ flags = SetLaunchFlag (flags, arguments, " disableSTDIO" ,
191+ lldb::eLaunchFlagDisableSTDIO);
192+ flags = SetLaunchFlag (flags, arguments, " shellExpandArguments" ,
193+ lldb::eLaunchFlagShellExpandArguments);
194+
182195 const bool detachOnError =
183196 GetBoolean (arguments, " detachOnError" ).value_or (false );
184197 launch_info.SetDetachOnError (detachOnError);
0 commit comments