Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions lldb/tools/lldb-dap/Handler/RequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ MakeArgv(const llvm::ArrayRef<std::string> &strs) {
return argv;
}

// Both attach and launch take a either a sourcePath or sourceMap
static uint32_t SetLaunchFlag(uint32_t flags, const llvm::json::Object *obj,
llvm::StringRef key, lldb::LaunchFlags mask,
bool default_value) {
if (GetBoolean(obj, key).value_or(default_value))
flags |= mask;
else
flags &= ~mask;

return flags;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't distinguish between the value not being set and the value being set to true or false. Here's what I was suggesting:

Suggested change
static uint32_t SetLaunchFlag(uint32_t flags, const llvm::json::Object *obj,
llvm::StringRef key, lldb::LaunchFlags mask,
bool default_value) {
if (GetBoolean(obj, key).value_or(default_value))
flags |= mask;
else
flags &= ~mask;
return flags;
}
static uint32_t SetLaunchFlag(uint32_t flags, const llvm::json::Object *obj,
llvm::StringRef key, lldb::LaunchFlags mask) {
if (auto b = GetBoolean(obj, key)) {
if (*b)
flags |= mask;
else
flags &= ~mask;
}
return flags;
}


// Both attach and launch take either a sourcePath or a sourceMap
// argument (or neither), from which we need to set the target.source-map.
void RequestHandler::SetSourceMapFromArguments(
const llvm::json::Object &arguments) const {
Expand Down Expand Up @@ -173,12 +184,13 @@ RequestHandler::LaunchProcess(const llvm::json::Object &request) const {

auto flags = launch_info.GetLaunchFlags();

if (GetBoolean(arguments, "disableASLR").value_or(true))
flags |= lldb::eLaunchFlagDisableASLR;
if (GetBoolean(arguments, "disableSTDIO").value_or(false))
flags |= lldb::eLaunchFlagDisableSTDIO;
if (GetBoolean(arguments, "shellExpandArguments").value_or(false))
flags |= lldb::eLaunchFlagShellExpandArguments;
flags = SetLaunchFlag(flags, arguments, "disableASLR",
lldb::eLaunchFlagDisableASLR, true);
flags = SetLaunchFlag(flags, arguments, "disableSTDIO",
lldb::eLaunchFlagDisableSTDIO, false);
flags = SetLaunchFlag(flags, arguments, "shellExpandArguments",
lldb::eLaunchFlagShellExpandArguments, false);

const bool detachOnError =
GetBoolean(arguments, "detachOnError").value_or(false);
launch_info.SetDetachOnError(detachOnError);
Expand Down