@@ -31,7 +31,18 @@ MakeArgv(const llvm::ArrayRef<std::string> &strs) {
31
31
return argv;
32
32
}
33
33
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
35
46
// argument (or neither), from which we need to set the target.source-map.
36
47
void RequestHandler::SetSourceMapFromArguments (
37
48
const llvm::json::Object &arguments) const {
@@ -173,12 +184,13 @@ RequestHandler::LaunchProcess(const llvm::json::Object &request) const {
173
184
174
185
auto flags = launch_info.GetLaunchFlags ();
175
186
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
+
182
194
const bool detachOnError =
183
195
GetBoolean (arguments, " detachOnError" ).value_or (false );
184
196
launch_info.SetDetachOnError (detachOnError);
0 commit comments