#include <algorithm>
#include "llvm/ADT/Optional.h"
-
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/ScopedPrinter.h"
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBBreakpointLocation.h"
// Gets a string from a JSON object using the key, or returns an empty string.
llvm::StringRef GetString(const llvm::json::Object &obj, llvm::StringRef key) {
- if (auto value = obj.getString(key))
- return GetAsString(*value);
+ if (llvm::Optional<llvm::StringRef> value = obj.getString(key))
+ return *value;
return llvm::StringRef();
}
strs.push_back(value.getAsString()->str());
break;
case llvm::json::Value::Number:
- case llvm::json::Value::Boolean: {
- std::string s;
- llvm::raw_string_ostream strm(s);
- strm << value;
- strs.push_back(strm.str());
+ case llvm::json::Value::Boolean:
+ strs.push_back(llvm::to_string(value));
break;
- }
case llvm::json::Value::Null:
case llvm::json::Value::Object:
case llvm::json::Value::Array:
g_vsc.exit_commands = GetStrings(arguments, "exitCommands");
auto attachCommands = GetStrings(arguments, "attachCommands");
g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
- const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+ const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot");
// This is a hack for loading DWARF in .o files on Mac where the .o files
// in the debug map of the main executable have relative paths which require
// the lldb-vscode binary to have its working directory set to that relative
// root for the .o files in order to be able to load debug info.
- if (!debuggerRoot.empty()) {
- llvm::sys::fs::set_current_path(debuggerRoot.data());
- }
+ if (!debuggerRoot.empty())
+ llvm::sys::fs::set_current_path(debuggerRoot);
// Run any initialize LLDB commands the user specified in the launch.json
g_vsc.RunInitCommands();
g_vsc.exit_commands = GetStrings(arguments, "exitCommands");
auto launchCommands = GetStrings(arguments, "launchCommands");
g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
- const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+ const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot");
// This is a hack for loading DWARF in .o files on Mac where the .o files
// in the debug map of the main executable have relative paths which require
// the lldb-vscode binary to have its working directory set to that relative
// root for the .o files in order to be able to load debug info.
- if (!debuggerRoot.empty()) {
- llvm::sys::fs::set_current_path(debuggerRoot.data());
- }
+ if (!debuggerRoot.empty())
+ llvm::sys::fs::set_current_path(debuggerRoot);
// Run any initialize LLDB commands the user specified in the launch.json.
// This is run before target is created, so commands can't do anything with