|
53 | 53 | #include <thread> |
54 | 54 | #include <vector> |
55 | 55 |
|
| 56 | +#include "lldb/API/SBEnvironment.h" |
56 | 57 | #include "lldb/API/SBStream.h" |
57 | 58 | #include "lldb/Host/Config.h" |
58 | 59 | #include "llvm/ADT/ArrayRef.h" |
@@ -610,25 +611,32 @@ void SetSourceMapFromArguments(const llvm::json::Object &arguments) { |
610 | 611 | std::string sourceMapCommand; |
611 | 612 | llvm::raw_string_ostream strm(sourceMapCommand); |
612 | 613 | strm << "settings set target.source-map "; |
613 | | - auto sourcePath = GetString(arguments, "sourcePath"); |
| 614 | + const auto sourcePath = GetString(arguments, "sourcePath"); |
614 | 615 |
|
615 | 616 | // sourceMap is the new, more general form of sourcePath and overrides it. |
616 | | - auto sourceMap = arguments.getArray("sourceMap"); |
617 | | - if (sourceMap) { |
618 | | - for (const auto &value : *sourceMap) { |
619 | | - auto mapping = value.getAsArray(); |
| 617 | + constexpr llvm::StringRef sourceMapKey = "sourceMap"; |
| 618 | + |
| 619 | + if (const auto *sourceMapArray = arguments.getArray(sourceMapKey)) { |
| 620 | + for (const auto &value : *sourceMapArray) { |
| 621 | + const auto *mapping = value.getAsArray(); |
620 | 622 | if (mapping == nullptr || mapping->size() != 2 || |
621 | 623 | (*mapping)[0].kind() != llvm::json::Value::String || |
622 | 624 | (*mapping)[1].kind() != llvm::json::Value::String) { |
623 | 625 | g_dap.SendOutput(OutputType::Console, llvm::StringRef(sourceMapHelp)); |
624 | 626 | return; |
625 | 627 | } |
626 | | - auto mapFrom = GetAsString((*mapping)[0]); |
627 | | - auto mapTo = GetAsString((*mapping)[1]); |
| 628 | + const auto mapFrom = GetAsString((*mapping)[0]); |
| 629 | + const auto mapTo = GetAsString((*mapping)[1]); |
628 | 630 | strm << "\"" << mapFrom << "\" \"" << mapTo << "\" "; |
629 | 631 | } |
| 632 | + } else if (const auto *sourceMapObj = arguments.getObject(sourceMapKey)) { |
| 633 | + for (const auto &[key, value] : *sourceMapObj) { |
| 634 | + if (value.kind() == llvm::json::Value::String) { |
| 635 | + strm << "\"" << key.str() << "\" \"" << GetAsString(value) << "\" "; |
| 636 | + } |
| 637 | + } |
630 | 638 | } else { |
631 | | - if (ObjectContainsKey(arguments, "sourceMap")) { |
| 639 | + if (ObjectContainsKey(arguments, sourceMapKey)) { |
632 | 640 | g_dap.SendOutput(OutputType::Console, llvm::StringRef(sourceMapHelp)); |
633 | 641 | return; |
634 | 642 | } |
@@ -2069,9 +2077,8 @@ lldb::SBError LaunchProcess(const llvm::json::Object &request) { |
2069 | 2077 | launch_info.SetArguments(MakeArgv(args).data(), true); |
2070 | 2078 |
|
2071 | 2079 | // Pass any environment variables along that the user specified. |
2072 | | - auto envs = GetStrings(arguments, "env"); |
2073 | | - if (!envs.empty()) |
2074 | | - launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true); |
| 2080 | + const auto envs = GetEnvironmentFromArguments(*arguments); |
| 2081 | + launch_info.SetEnvironment(envs, true); |
2075 | 2082 |
|
2076 | 2083 | auto flags = launch_info.GetLaunchFlags(); |
2077 | 2084 |
|
|
0 commit comments