Skip to content

Commit 2f773de

Browse files
committed
[lldb-dap] Fix: disableASLR launch argument not working.
1 parent 5c375c3 commit 2f773de

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lldb/tools/lldb-dap/Handler/RequestHandler.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
3647
void 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

Comments
 (0)