aboutsummaryrefslogtreecommitdiffstats
path: root/source/Interpreter
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
commit5f29bb8a675e8f96452b632e7129113f7dec850e (patch)
tree3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Interpreter
parent88c643b6fec27eec436c8d138fee6346e92337d6 (diff)
downloadsrc-5f29bb8a675e8f96452b632e7129113f7dec850e.tar.gz
src-5f29bb8a675e8f96452b632e7129113f7dec850e.zip
Vendor import of stripped lldb trunk r366426 (just before the release_90
Notes
Notes: svn path=/vendor/lldb/dist/; revision=351290
Diffstat (limited to 'source/Interpreter')
-rw-r--r--source/Interpreter/CommandAlias.cpp9
-rw-r--r--source/Interpreter/CommandHistory.cpp7
-rw-r--r--source/Interpreter/CommandInterpreter.cpp714
-rw-r--r--source/Interpreter/CommandObject.cpp28
-rw-r--r--source/Interpreter/CommandObjectRegexCommand.cpp11
-rw-r--r--source/Interpreter/CommandObjectScript.cpp11
-rw-r--r--source/Interpreter/CommandObjectScript.h9
-rw-r--r--source/Interpreter/CommandOptionValidators.cpp7
-rw-r--r--source/Interpreter/CommandReturnObject.cpp7
-rw-r--r--source/Interpreter/OptionArgParser.cpp7
-rw-r--r--source/Interpreter/OptionGroupArchitecture.cpp7
-rw-r--r--source/Interpreter/OptionGroupBoolean.cpp7
-rw-r--r--source/Interpreter/OptionGroupFile.cpp7
-rw-r--r--source/Interpreter/OptionGroupFormat.cpp7
-rw-r--r--source/Interpreter/OptionGroupOutputFile.cpp7
-rw-r--r--source/Interpreter/OptionGroupPlatform.cpp7
-rw-r--r--source/Interpreter/OptionGroupString.cpp7
-rw-r--r--source/Interpreter/OptionGroupUInt64.cpp7
-rw-r--r--source/Interpreter/OptionGroupUUID.cpp7
-rw-r--r--source/Interpreter/OptionGroupValueObjectDisplay.cpp7
-rw-r--r--source/Interpreter/OptionGroupVariable.cpp7
-rw-r--r--source/Interpreter/OptionGroupWatchpoint.cpp7
-rw-r--r--source/Interpreter/OptionValue.cpp15
-rw-r--r--source/Interpreter/OptionValueArch.cpp7
-rw-r--r--source/Interpreter/OptionValueArgs.cpp7
-rw-r--r--source/Interpreter/OptionValueArray.cpp7
-rw-r--r--source/Interpreter/OptionValueBoolean.cpp7
-rw-r--r--source/Interpreter/OptionValueChar.cpp7
-rw-r--r--source/Interpreter/OptionValueDictionary.cpp13
-rw-r--r--source/Interpreter/OptionValueEnumeration.cpp7
-rw-r--r--source/Interpreter/OptionValueFileSpec.cpp7
-rw-r--r--source/Interpreter/OptionValueFileSpecLIst.cpp12
-rw-r--r--source/Interpreter/OptionValueFormat.cpp7
-rw-r--r--source/Interpreter/OptionValueFormatEntity.cpp7
-rw-r--r--source/Interpreter/OptionValueLanguage.cpp7
-rw-r--r--source/Interpreter/OptionValuePathMappings.cpp7
-rw-r--r--source/Interpreter/OptionValueProperties.cpp24
-rw-r--r--source/Interpreter/OptionValueRegex.cpp7
-rw-r--r--source/Interpreter/OptionValueSInt64.cpp7
-rw-r--r--source/Interpreter/OptionValueString.cpp7
-rw-r--r--source/Interpreter/OptionValueUInt64.cpp7
-rw-r--r--source/Interpreter/OptionValueUUID.cpp7
-rw-r--r--source/Interpreter/Options.cpp129
-rw-r--r--source/Interpreter/Property.cpp64
-rw-r--r--source/Interpreter/ScriptInterpreter.cpp15
-rw-r--r--source/Interpreter/embedded_interpreter.py1
46 files changed, 624 insertions, 655 deletions
diff --git a/source/Interpreter/CommandAlias.cpp b/source/Interpreter/CommandAlias.cpp
index 078eb73a7a87..8c40574ee50e 100644
--- a/source/Interpreter/CommandAlias.cpp
+++ b/source/Interpreter/CommandAlias.cpp
@@ -1,9 +1,8 @@
//===-- CommandAlias.cpp -----------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,6 +30,8 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
Args args(options_args);
std::string options_string(options_args);
+ // TODO: Find a way to propagate errors in this CommandReturnObject up the
+ // stack.
CommandReturnObject result;
// Check to see if the command being aliased can take any command options.
Options *options = cmd_obj_sp->GetOptions();
diff --git a/source/Interpreter/CommandHistory.cpp b/source/Interpreter/CommandHistory.cpp
index ca5c90692b6a..0be61f836e00 100644
--- a/source/Interpreter/CommandHistory.cpp
+++ b/source/Interpreter/CommandHistory.cpp
@@ -1,9 +1,8 @@
//===-- CommandHistory.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index 6d75ec57c83b..8948037a6307 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -1,12 +1,12 @@
//===-- CommandInterpreter.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include <memory>
#include <stdlib.h>
#include <string>
#include <vector>
@@ -81,6 +81,17 @@ static constexpr bool NoGlobalSetting = true;
static constexpr uintptr_t DefaultValueTrue = true;
static constexpr uintptr_t DefaultValueFalse = false;
static constexpr const char *NoCStrDefault = nullptr;
+static constexpr const char *InitFileWarning =
+ "There is a .lldbinit file in the current directory which is not being "
+ "read.\n"
+ "To silence this warning without sourcing in the local .lldbinit,\n"
+ "add the following to the lldbinit file in your home directory:\n"
+ " settings set target.load-cwd-lldbinit false\n"
+ "To allow lldb to source .lldbinit files in the current working "
+ "directory,\n"
+ "set the value of this variable to true. Only do so if you understand "
+ "and\n"
+ "accept the security risk.";
static constexpr PropertyDefinition g_properties[] = {
{"expand-regex-aliases", OptionValue::eTypeBoolean, NoGlobalSetting,
@@ -122,7 +133,6 @@ ConstString &CommandInterpreter::GetStaticBroadcasterClass() {
}
CommandInterpreter::CommandInterpreter(Debugger &debugger,
- ScriptLanguage script_language,
bool synchronous_execution)
: Broadcaster(debugger.GetBroadcasterManager(),
CommandInterpreter::GetStaticBroadcasterClass().AsCString()),
@@ -131,11 +141,10 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
m_debugger(debugger), m_synchronous_execution(synchronous_execution),
m_skip_lldbinit_files(false), m_skip_app_init_files(false),
- m_script_interpreter_sp(), m_command_io_handler_sp(), m_comment_char('#'),
+ m_command_io_handler_sp(), m_comment_char('#'),
m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
m_command_source_depth(0), m_num_errors(0), m_quit_requested(false),
m_stopped_for_crash(false) {
- debugger.SetScriptLanguage(script_language);
SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
SetEventName(eBroadcastBitQuitCommandReceived, "quit");
@@ -367,7 +376,7 @@ void CommandInterpreter::Initialize() {
if (cmd_obj_sp)
AddAlias("image", cmd_obj_sp);
- alias_arguments_vector_sp.reset(new OptionArgVector);
+ alias_arguments_vector_sp = std::make_shared<OptionArgVector>();
cmd_obj_sp = GetCommandSPExact("expression", false);
if (cmd_obj_sp) {
@@ -393,7 +402,7 @@ void CommandInterpreter::Initialize() {
cmd_obj_sp = GetCommandSPExact("process launch", false);
if (cmd_obj_sp) {
- alias_arguments_vector_sp.reset(new OptionArgVector);
+ alias_arguments_vector_sp = std::make_shared<OptionArgVector>();
#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
AddAlias("r", cmd_obj_sp, "--");
AddAlias("run", cmd_obj_sp, "--");
@@ -431,13 +440,15 @@ void CommandInterpreter::Initialize() {
AddAlias("var", cmd_obj_sp);
AddAlias("vo", cmd_obj_sp, "--object-description");
}
+
+ cmd_obj_sp = GetCommandSPExact("register", false);
+ if (cmd_obj_sp) {
+ AddAlias("re", cmd_obj_sp);
+ }
}
void CommandInterpreter::Clear() {
m_command_io_handler_sp.reset();
-
- if (m_script_interpreter_sp)
- m_script_interpreter_sp->Clear();
}
const char *CommandInterpreter::ProcessEmbeddedScriptCommands(const char *arg) {
@@ -522,7 +533,7 @@ void CommandInterpreter::LoadCommandDictionary() {
size_t num_regexes = llvm::array_lengthof(break_regexes);
- std::unique_ptr<CommandObjectRegexCommand> break_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> break_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-break",
"Set a breakpoint using one of several shorthand formats.",
@@ -550,28 +561,29 @@ void CommandInterpreter::LoadCommandDictionary() {
"current file\n"
" // containing text 'break "
"here'.\n",
- 2, CommandCompletions::eSymbolCompletion |
- CommandCompletions::eSourceFileCompletion,
+ 2,
+ CommandCompletions::eSymbolCompletion |
+ CommandCompletions::eSourceFileCompletion,
false));
- if (break_regex_cmd_ap.get()) {
+ if (break_regex_cmd_up) {
bool success = true;
for (size_t i = 0; i < num_regexes; i++) {
- success = break_regex_cmd_ap->AddRegexCommand(break_regexes[i][0],
+ success = break_regex_cmd_up->AddRegexCommand(break_regexes[i][0],
break_regexes[i][1]);
if (!success)
break;
}
success =
- break_regex_cmd_ap->AddRegexCommand("^$", "breakpoint list --full");
+ break_regex_cmd_up->AddRegexCommand("^$", "breakpoint list --full");
if (success) {
- CommandObjectSP break_regex_cmd_sp(break_regex_cmd_ap.release());
+ CommandObjectSP break_regex_cmd_sp(break_regex_cmd_up.release());
m_command_dict[break_regex_cmd_sp->GetCommandName()] = break_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> tbreak_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> tbreak_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-tbreak",
"Set a one-shot breakpoint using one of several shorthand formats.",
@@ -599,11 +611,12 @@ void CommandInterpreter::LoadCommandDictionary() {
"current file\n"
" // containing text 'break "
"here'.\n",
- 2, CommandCompletions::eSymbolCompletion |
- CommandCompletions::eSourceFileCompletion,
+ 2,
+ CommandCompletions::eSymbolCompletion |
+ CommandCompletions::eSourceFileCompletion,
false));
- if (tbreak_regex_cmd_ap.get()) {
+ if (tbreak_regex_cmd_up) {
bool success = true;
for (size_t i = 0; i < num_regexes; i++) {
// If you add a resultant command string longer than 1024 characters be
@@ -614,155 +627,160 @@ void CommandInterpreter::LoadCommandDictionary() {
lldbassert(num_printed < 1024);
UNUSED_IF_ASSERT_DISABLED(num_printed);
success =
- tbreak_regex_cmd_ap->AddRegexCommand(break_regexes[i][0], buffer);
+ tbreak_regex_cmd_up->AddRegexCommand(break_regexes[i][0], buffer);
if (!success)
break;
}
success =
- tbreak_regex_cmd_ap->AddRegexCommand("^$", "breakpoint list --full");
+ tbreak_regex_cmd_up->AddRegexCommand("^$", "breakpoint list --full");
if (success) {
- CommandObjectSP tbreak_regex_cmd_sp(tbreak_regex_cmd_ap.release());
+ CommandObjectSP tbreak_regex_cmd_sp(tbreak_regex_cmd_up.release());
m_command_dict[tbreak_regex_cmd_sp->GetCommandName()] =
tbreak_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> attach_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> attach_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-attach", "Attach to process by ID or name.",
"_regexp-attach <pid> | <process-name>", 2, 0, false));
- if (attach_regex_cmd_ap.get()) {
- if (attach_regex_cmd_ap->AddRegexCommand("^([0-9]+)[[:space:]]*$",
+ if (attach_regex_cmd_up) {
+ if (attach_regex_cmd_up->AddRegexCommand("^([0-9]+)[[:space:]]*$",
"process attach --pid %1") &&
- attach_regex_cmd_ap->AddRegexCommand(
+ attach_regex_cmd_up->AddRegexCommand(
"^(-.*|.* -.*)$", "process attach %1") && // Any options that are
// specified get passed to
// 'process attach'
- attach_regex_cmd_ap->AddRegexCommand("^(.+)$",
+ attach_regex_cmd_up->AddRegexCommand("^(.+)$",
"process attach --name '%1'") &&
- attach_regex_cmd_ap->AddRegexCommand("^$", "process attach")) {
- CommandObjectSP attach_regex_cmd_sp(attach_regex_cmd_ap.release());
+ attach_regex_cmd_up->AddRegexCommand("^$", "process attach")) {
+ CommandObjectSP attach_regex_cmd_sp(attach_regex_cmd_up.release());
m_command_dict[attach_regex_cmd_sp->GetCommandName()] =
attach_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> down_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> down_regex_cmd_up(
new CommandObjectRegexCommand(*this, "_regexp-down",
"Select a newer stack frame. Defaults to "
"moving one frame, a numeric argument can "
"specify an arbitrary number.",
"_regexp-down [<count>]", 2, 0, false));
- if (down_regex_cmd_ap.get()) {
- if (down_regex_cmd_ap->AddRegexCommand("^$", "frame select -r -1") &&
- down_regex_cmd_ap->AddRegexCommand("^([0-9]+)$",
+ if (down_regex_cmd_up) {
+ if (down_regex_cmd_up->AddRegexCommand("^$", "frame select -r -1") &&
+ down_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"frame select -r -%1")) {
- CommandObjectSP down_regex_cmd_sp(down_regex_cmd_ap.release());
+ CommandObjectSP down_regex_cmd_sp(down_regex_cmd_up.release());
m_command_dict[down_regex_cmd_sp->GetCommandName()] = down_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> up_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> up_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-up",
"Select an older stack frame. Defaults to moving one "
"frame, a numeric argument can specify an arbitrary number.",
"_regexp-up [<count>]", 2, 0, false));
- if (up_regex_cmd_ap.get()) {
- if (up_regex_cmd_ap->AddRegexCommand("^$", "frame select -r 1") &&
- up_regex_cmd_ap->AddRegexCommand("^([0-9]+)$", "frame select -r %1")) {
- CommandObjectSP up_regex_cmd_sp(up_regex_cmd_ap.release());
+ if (up_regex_cmd_up) {
+ if (up_regex_cmd_up->AddRegexCommand("^$", "frame select -r 1") &&
+ up_regex_cmd_up->AddRegexCommand("^([0-9]+)$", "frame select -r %1")) {
+ CommandObjectSP up_regex_cmd_sp(up_regex_cmd_up.release());
m_command_dict[up_regex_cmd_sp->GetCommandName()] = up_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> display_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> display_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-display",
"Evaluate an expression at every stop (see 'help target stop-hook'.)",
"_regexp-display expression", 2, 0, false));
- if (display_regex_cmd_ap.get()) {
- if (display_regex_cmd_ap->AddRegexCommand(
+ if (display_regex_cmd_up) {
+ if (display_regex_cmd_up->AddRegexCommand(
"^(.+)$", "target stop-hook add -o \"expr -- %1\"")) {
- CommandObjectSP display_regex_cmd_sp(display_regex_cmd_ap.release());
+ CommandObjectSP display_regex_cmd_sp(display_regex_cmd_up.release());
m_command_dict[display_regex_cmd_sp->GetCommandName()] =
display_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> undisplay_regex_cmd_ap(
- new CommandObjectRegexCommand(
- *this, "_regexp-undisplay", "Stop displaying expression at every "
- "stop (specified by stop-hook index.)",
- "_regexp-undisplay stop-hook-number", 2, 0, false));
- if (undisplay_regex_cmd_ap.get()) {
- if (undisplay_regex_cmd_ap->AddRegexCommand("^([0-9]+)$",
+ std::unique_ptr<CommandObjectRegexCommand> undisplay_regex_cmd_up(
+ new CommandObjectRegexCommand(*this, "_regexp-undisplay",
+ "Stop displaying expression at every "
+ "stop (specified by stop-hook index.)",
+ "_regexp-undisplay stop-hook-number", 2, 0,
+ false));
+ if (undisplay_regex_cmd_up) {
+ if (undisplay_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"target stop-hook delete %1")) {
- CommandObjectSP undisplay_regex_cmd_sp(undisplay_regex_cmd_ap.release());
+ CommandObjectSP undisplay_regex_cmd_sp(undisplay_regex_cmd_up.release());
m_command_dict[undisplay_regex_cmd_sp->GetCommandName()] =
undisplay_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> connect_gdb_remote_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> connect_gdb_remote_cmd_up(
new CommandObjectRegexCommand(
- *this, "gdb-remote", "Connect to a process via remote GDB server. "
- "If no host is specifed, localhost is assumed.",
+ *this, "gdb-remote",
+ "Connect to a process via remote GDB server. "
+ "If no host is specifed, localhost is assumed.",
"gdb-remote [<hostname>:]<portnum>", 2, 0, false));
- if (connect_gdb_remote_cmd_ap.get()) {
- if (connect_gdb_remote_cmd_ap->AddRegexCommand(
+ if (connect_gdb_remote_cmd_up) {
+ if (connect_gdb_remote_cmd_up->AddRegexCommand(
"^([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)$",
"process connect --plugin gdb-remote connect://%1:%2") &&
- connect_gdb_remote_cmd_ap->AddRegexCommand(
+ connect_gdb_remote_cmd_up->AddRegexCommand(
"^([[:digit:]]+)$",
"process connect --plugin gdb-remote connect://localhost:%1")) {
- CommandObjectSP command_sp(connect_gdb_remote_cmd_ap.release());
+ CommandObjectSP command_sp(connect_gdb_remote_cmd_up.release());
m_command_dict[command_sp->GetCommandName()] = command_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> connect_kdp_remote_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> connect_kdp_remote_cmd_up(
new CommandObjectRegexCommand(
- *this, "kdp-remote", "Connect to a process via remote KDP server. "
- "If no UDP port is specified, port 41139 is "
- "assumed.",
+ *this, "kdp-remote",
+ "Connect to a process via remote KDP server. "
+ "If no UDP port is specified, port 41139 is "
+ "assumed.",
"kdp-remote <hostname>[:<portnum>]", 2, 0, false));
- if (connect_kdp_remote_cmd_ap.get()) {
- if (connect_kdp_remote_cmd_ap->AddRegexCommand(
+ if (connect_kdp_remote_cmd_up) {
+ if (connect_kdp_remote_cmd_up->AddRegexCommand(
"^([^:]+:[[:digit:]]+)$",
"process connect --plugin kdp-remote udp://%1") &&
- connect_kdp_remote_cmd_ap->AddRegexCommand(
+ connect_kdp_remote_cmd_up->AddRegexCommand(
"^(.+)$", "process connect --plugin kdp-remote udp://%1:41139")) {
- CommandObjectSP command_sp(connect_kdp_remote_cmd_ap.release());
+ CommandObjectSP command_sp(connect_kdp_remote_cmd_up.release());
m_command_dict[command_sp->GetCommandName()] = command_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> bt_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> bt_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-bt",
"Show the current thread's call stack. Any numeric argument "
"displays at most that many "
- "frames. The argument 'all' displays all threads.",
+ "frames. The argument 'all' displays all threads. Use 'settings"
+ " set frame-format' to customize the printing of individual frames "
+ "and 'settings set thread-format' to customize the thread header.",
"bt [<digit> | all]", 2, 0, false));
- if (bt_regex_cmd_ap.get()) {
+ if (bt_regex_cmd_up) {
// accept but don't document "bt -c <number>" -- before bt was a regex
// command if you wanted to backtrace three frames you would do "bt -c 3"
// but the intention is to have this emulate the gdb "bt" command and so
// now "bt 3" is the preferred form, in line with gdb.
- if (bt_regex_cmd_ap->AddRegexCommand("^([[:digit:]]+)$",
+ if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)[[:space:]]*$",
"thread backtrace -c %1") &&
- bt_regex_cmd_ap->AddRegexCommand("^-c ([[:digit:]]+)$",
+ bt_regex_cmd_up->AddRegexCommand("^-c ([[:digit:]]+)[[:space:]]*$",
"thread backtrace -c %1") &&
- bt_regex_cmd_ap->AddRegexCommand("^all$", "thread backtrace all") &&
- bt_regex_cmd_ap->AddRegexCommand("^$", "thread backtrace")) {
- CommandObjectSP command_sp(bt_regex_cmd_ap.release());
+ bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") &&
+ bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) {
+ CommandObjectSP command_sp(bt_regex_cmd_up.release());
m_command_dict[command_sp->GetCommandName()] = command_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> list_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> list_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-list",
"List relevant source code using one of several shorthand formats.",
@@ -775,48 +793,48 @@ void CommandInterpreter::LoadCommandDictionary() {
"_regexp-list -[<count>] // List previous <count> lines\n"
"_regexp-list // List subsequent lines",
2, CommandCompletions::eSourceFileCompletion, false));
- if (list_regex_cmd_ap.get()) {
- if (list_regex_cmd_ap->AddRegexCommand("^([0-9]+)[[:space:]]*$",
+ if (list_regex_cmd_up) {
+ if (list_regex_cmd_up->AddRegexCommand("^([0-9]+)[[:space:]]*$",
"source list --line %1") &&
- list_regex_cmd_ap->AddRegexCommand(
+ list_regex_cmd_up->AddRegexCommand(
"^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]"
"]*$",
"source list --file '%1' --line %2") &&
- list_regex_cmd_ap->AddRegexCommand(
+ list_regex_cmd_up->AddRegexCommand(
"^\\*?(0x[[:xdigit:]]+)[[:space:]]*$",
"source list --address %1") &&
- list_regex_cmd_ap->AddRegexCommand("^-[[:space:]]*$",
+ list_regex_cmd_up->AddRegexCommand("^-[[:space:]]*$",
"source list --reverse") &&
- list_regex_cmd_ap->AddRegexCommand(
+ list_regex_cmd_up->AddRegexCommand(
"^-([[:digit:]]+)[[:space:]]*$",
"source list --reverse --count %1") &&
- list_regex_cmd_ap->AddRegexCommand("^(.+)$",
+ list_regex_cmd_up->AddRegexCommand("^(.+)$",
"source list --name \"%1\"") &&
- list_regex_cmd_ap->AddRegexCommand("^$", "source list")) {
- CommandObjectSP list_regex_cmd_sp(list_regex_cmd_ap.release());
+ list_regex_cmd_up->AddRegexCommand("^$", "source list")) {
+ CommandObjectSP list_regex_cmd_sp(list_regex_cmd_up.release());
m_command_dict[list_regex_cmd_sp->GetCommandName()] = list_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> env_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> env_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-env",
"Shorthand for viewing and setting environment variables.",
"\n"
- "_regexp-env // Show enrivonment\n"
+ "_regexp-env // Show environment\n"
"_regexp-env <name>=<value> // Set an environment variable",
2, 0, false));
- if (env_regex_cmd_ap.get()) {
- if (env_regex_cmd_ap->AddRegexCommand("^$",
+ if (env_regex_cmd_up) {
+ if (env_regex_cmd_up->AddRegexCommand("^$",
"settings show target.env-vars") &&
- env_regex_cmd_ap->AddRegexCommand("^([A-Za-z_][A-Za-z_0-9]*=.*)$",
+ env_regex_cmd_up->AddRegexCommand("^([A-Za-z_][A-Za-z_0-9]*=.*)$",
"settings set target.env-vars %1")) {
- CommandObjectSP env_regex_cmd_sp(env_regex_cmd_ap.release());
+ CommandObjectSP env_regex_cmd_sp(env_regex_cmd_up.release());
m_command_dict[env_regex_cmd_sp->GetCommandName()] = env_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> jump_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> jump_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-jump", "Set the program counter to a new address.",
"\n"
@@ -825,16 +843,16 @@ void CommandInterpreter::LoadCommandDictionary() {
"_regexp-jump <file>:<line>\n"
"_regexp-jump *<addr>\n",
2, 0, false));
- if (jump_regex_cmd_ap.get()) {
- if (jump_regex_cmd_ap->AddRegexCommand("^\\*(.*)$",
+ if (jump_regex_cmd_up) {
+ if (jump_regex_cmd_up->AddRegexCommand("^\\*(.*)$",
"thread jump --addr %1") &&
- jump_regex_cmd_ap->AddRegexCommand("^([0-9]+)$",
+ jump_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"thread jump --line %1") &&
- jump_regex_cmd_ap->AddRegexCommand("^([^:]+):([0-9]+)$",
+ jump_regex_cmd_up->AddRegexCommand("^([^:]+):([0-9]+)$",
"thread jump --file %1 --line %2") &&
- jump_regex_cmd_ap->AddRegexCommand("^([+\\-][0-9]+)$",
+ jump_regex_cmd_up->AddRegexCommand("^([+\\-][0-9]+)$",
"thread jump --by %1")) {
- CommandObjectSP jump_regex_cmd_sp(jump_regex_cmd_ap.release());
+ CommandObjectSP jump_regex_cmd_sp(jump_regex_cmd_up.release());
m_command_dict[jump_regex_cmd_sp->GetCommandName()] = jump_regex_cmd_sp;
}
}
@@ -1721,7 +1739,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
log->Printf("HandleCommand, (revised) command_string: '%s'",
command_string.c_str());
const bool wants_raw_input =
- (cmd_obj != NULL) ? cmd_obj->WantsRawCommandString() : false;
+ (cmd_obj != nullptr) ? cmd_obj->WantsRawCommandString() : false;
log->Printf("HandleCommand, wants_raw_input:'%s'",
wants_raw_input ? "True" : "False");
}
@@ -2084,106 +2102,119 @@ int CommandInterpreter::GetOptionArgumentPosition(const char *in_string) {
return position;
}
-void CommandInterpreter::SourceInitFile(bool in_cwd,
- CommandReturnObject &result) {
- FileSpec init_file;
- if (in_cwd) {
- ExecutionContext exe_ctx(GetExecutionContext());
- Target *target = exe_ctx.GetTargetPtr();
- if (target) {
- // In the current working directory we don't load any program specific
- // .lldbinit files, we only look for a ".lldbinit" file.
- if (m_skip_lldbinit_files)
- return;
+static void GetHomeInitFile(llvm::SmallVectorImpl<char> &init_file,
+ llvm::StringRef suffix = {}) {
+ std::string init_file_name = ".lldbinit";
+ if (!suffix.empty()) {
+ init_file_name.append("-");
+ init_file_name.append(suffix.str());
+ }
- LoadCWDlldbinitFile should_load =
- target->TargetProperties::GetLoadCWDlldbinitFile();
- if (should_load == eLoadCWDlldbinitWarn) {
- FileSpec dot_lldb(".lldbinit");
- FileSystem::Instance().Resolve(dot_lldb);
- llvm::SmallString<64> home_dir_path;
- llvm::sys::path::home_directory(home_dir_path);
- FileSpec homedir_dot_lldb(home_dir_path.c_str());
- homedir_dot_lldb.AppendPathComponent(".lldbinit");
- FileSystem::Instance().Resolve(homedir_dot_lldb);
- if (FileSystem::Instance().Exists(dot_lldb) &&
- dot_lldb.GetDirectory() != homedir_dot_lldb.GetDirectory()) {
- result.AppendErrorWithFormat(
- "There is a .lldbinit file in the current directory which is not "
- "being read.\n"
- "To silence this warning without sourcing in the local "
- ".lldbinit,\n"
- "add the following to the lldbinit file in your home directory:\n"
- " settings set target.load-cwd-lldbinit false\n"
- "To allow lldb to source .lldbinit files in the current working "
- "directory,\n"
- "set the value of this variable to true. Only do so if you "
- "understand and\n"
- "accept the security risk.");
- result.SetStatus(eReturnStatusFailed);
- return;
- }
- } else if (should_load == eLoadCWDlldbinitTrue) {
- init_file.SetFile("./.lldbinit", FileSpec::Style::native);
- FileSystem::Instance().Resolve(init_file);
- }
- }
- } else {
- // If we aren't looking in the current working directory we are looking in
- // the home directory. We will first see if there is an application
- // specific ".lldbinit" file whose name is "~/.lldbinit" followed by a "-"
- // and the name of the program. If this file doesn't exist, we fall back to
- // just the "~/.lldbinit" file. We also obey any requests to not load the
- // init files.
- llvm::SmallString<64> home_dir_path;
- llvm::sys::path::home_directory(home_dir_path);
- FileSpec profilePath(home_dir_path.c_str());
- profilePath.AppendPathComponent(".lldbinit");
- std::string init_file_path = profilePath.GetPath();
-
- if (!m_skip_app_init_files) {
- FileSpec program_file_spec(HostInfo::GetProgramFileSpec());
- const char *program_name = program_file_spec.GetFilename().AsCString();
-
- if (program_name) {
- char program_init_file_name[PATH_MAX];
- ::snprintf(program_init_file_name, sizeof(program_init_file_name),
- "%s-%s", init_file_path.c_str(), program_name);
- init_file.SetFile(program_init_file_name, FileSpec::Style::native);
- FileSystem::Instance().Resolve(init_file);
- if (!FileSystem::Instance().Exists(init_file))
- init_file.Clear();
- }
- }
+ llvm::sys::path::home_directory(init_file);
+ llvm::sys::path::append(init_file, init_file_name);
+
+ FileSystem::Instance().Resolve(init_file);
+}
- if (!init_file && !m_skip_lldbinit_files)
- init_file.SetFile(init_file_path, FileSpec::Style::native);
+static void GetCwdInitFile(llvm::SmallVectorImpl<char> &init_file) {
+ llvm::StringRef s = ".lldbinit";
+ init_file.assign(s.begin(), s.end());
+ FileSystem::Instance().Resolve(init_file);
+}
+
+static LoadCWDlldbinitFile ShouldLoadCwdInitFile() {
+ lldb::TargetPropertiesSP properties = Target::GetGlobalProperties();
+ if (!properties)
+ return eLoadCWDlldbinitFalse;
+ return properties->GetLoadCWDlldbinitFile();
+}
+
+void CommandInterpreter::SourceInitFile(FileSpec file,
+ CommandReturnObject &result) {
+ assert(!m_skip_lldbinit_files);
+
+ if (!FileSystem::Instance().Exists(file)) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
}
- // If the file exists, tell HandleCommand to 'source' it; this will do the
- // actual broadcasting of the commands back to any appropriate listener (see
+ // Use HandleCommand to 'source' the given file; this will do the actual
+ // broadcasting of the commands back to any appropriate listener (see
// CommandObjectSource::Execute for more details).
+ const bool saved_batch = SetBatchCommandMode(true);
+ ExecutionContext *ctx = nullptr;
+ CommandInterpreterRunOptions options;
+ options.SetSilent(true);
+ options.SetPrintErrors(true);
+ options.SetStopOnError(false);
+ options.SetStopOnContinue(true);
+ HandleCommandsFromFile(file, ctx, options, result);
+ SetBatchCommandMode(saved_batch);
+}
+
+void CommandInterpreter::SourceInitFileCwd(CommandReturnObject &result) {
+ if (m_skip_lldbinit_files) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
+ }
- if (FileSystem::Instance().Exists(init_file)) {
- const bool saved_batch = SetBatchCommandMode(true);
- CommandInterpreterRunOptions options;
- options.SetSilent(true);
- options.SetStopOnError(false);
- options.SetStopOnContinue(true);
-
- HandleCommandsFromFile(init_file,
- nullptr, // Execution context
- options, result);
- SetBatchCommandMode(saved_batch);
- } else {
- // nothing to be done if the file doesn't exist
+ llvm::SmallString<128> init_file;
+ GetCwdInitFile(init_file);
+ if (!FileSystem::Instance().Exists(init_file)) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
+ }
+
+ LoadCWDlldbinitFile should_load = ShouldLoadCwdInitFile();
+
+ switch (should_load) {
+ case eLoadCWDlldbinitFalse:
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ break;
+ case eLoadCWDlldbinitTrue:
+ SourceInitFile(FileSpec(init_file.str()), result);
+ break;
+ case eLoadCWDlldbinitWarn: {
+ llvm::SmallString<128> home_init_file;
+ GetHomeInitFile(home_init_file);
+ if (llvm::sys::path::parent_path(init_file) ==
+ llvm::sys::path::parent_path(home_init_file)) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ } else {
+ result.AppendErrorWithFormat(InitFileWarning);
+ result.SetStatus(eReturnStatusFailed);
+ }
+ }
}
}
+/// We will first see if there is an application specific ".lldbinit" file
+/// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
+/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+ if (m_skip_lldbinit_files) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
+ }
+
+ llvm::SmallString<128> init_file;
+ GetHomeInitFile(init_file);
+
+ if (!m_skip_app_init_files) {
+ llvm::StringRef program_name =
+ HostInfo::GetProgramFileSpec().GetFilename().GetStringRef();
+ llvm::SmallString<128> program_init_file;
+ GetHomeInitFile(program_init_file, program_name);
+ if (FileSystem::Instance().Exists(program_init_file))
+ init_file = program_init_file;
+ }
+
+ SourceInitFile(FileSpec(init_file.str()), result);
+}
+
const char *CommandInterpreter::GetCommandPrefix() {
const char *prefix = GetDebugger().GetIOHandlerCommandPrefix();
- return prefix == NULL ? "" : prefix;
+ return prefix == nullptr ? "" : prefix;
}
PlatformSP CommandInterpreter::GetPlatform(bool prefer_target_platform) {
@@ -2359,156 +2390,152 @@ enum {
eHandleCommandFlagEchoCommand = (1u << 2),
eHandleCommandFlagEchoCommentCommand = (1u << 3),
eHandleCommandFlagPrintResult = (1u << 4),
- eHandleCommandFlagStopOnCrash = (1u << 5)
+ eHandleCommandFlagPrintErrors = (1u << 5),
+ eHandleCommandFlagStopOnCrash = (1u << 6)
};
void CommandInterpreter::HandleCommandsFromFile(
FileSpec &cmd_file, ExecutionContext *context,
CommandInterpreterRunOptions &options, CommandReturnObject &result) {
- if (FileSystem::Instance().Exists(cmd_file)) {
- StreamFileSP input_file_sp(new StreamFile());
-
- std::string cmd_file_path = cmd_file.GetPath();
- Status error = FileSystem::Instance().Open(input_file_sp->GetFile(),
- cmd_file, File::eOpenOptionRead);
- if (error.Success()) {
- Debugger &debugger = GetDebugger();
-
- uint32_t flags = 0;
-
- if (options.m_stop_on_continue == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Stop on continue by default
- flags |= eHandleCommandFlagStopOnContinue;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagStopOnContinue) {
- flags |= eHandleCommandFlagStopOnContinue;
- }
- } else if (options.m_stop_on_continue == eLazyBoolYes) {
- flags |= eHandleCommandFlagStopOnContinue;
- }
-
- if (options.m_stop_on_error == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- if (GetStopCmdSourceOnError())
- flags |= eHandleCommandFlagStopOnError;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagStopOnError) {
- flags |= eHandleCommandFlagStopOnError;
- }
- } else if (options.m_stop_on_error == eLazyBoolYes) {
- flags |= eHandleCommandFlagStopOnError;
- }
-
- // stop-on-crash can only be set, if it is present in all levels of
- // pushed flag sets.
- if (options.GetStopOnCrash()) {
- if (m_command_source_flags.empty()) {
- flags |= eHandleCommandFlagStopOnCrash;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagStopOnCrash) {
- flags |= eHandleCommandFlagStopOnCrash;
- }
- }
-
- if (options.m_echo_commands == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Echo command by default
- flags |= eHandleCommandFlagEchoCommand;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagEchoCommand) {
- flags |= eHandleCommandFlagEchoCommand;
- }
- } else if (options.m_echo_commands == eLazyBoolYes) {
- flags |= eHandleCommandFlagEchoCommand;
- }
-
- // We will only ever ask for this flag, if we echo commands in general.
- if (options.m_echo_comment_commands == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Echo comments by default
- flags |= eHandleCommandFlagEchoCommentCommand;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagEchoCommentCommand) {
- flags |= eHandleCommandFlagEchoCommentCommand;
- }
- } else if (options.m_echo_comment_commands == eLazyBoolYes) {
- flags |= eHandleCommandFlagEchoCommentCommand;
- }
-
- if (options.m_print_results == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Print output by default
- flags |= eHandleCommandFlagPrintResult;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagPrintResult) {
- flags |= eHandleCommandFlagPrintResult;
- }
- } else if (options.m_print_results == eLazyBoolYes) {
- flags |= eHandleCommandFlagPrintResult;
- }
-
- if (flags & eHandleCommandFlagPrintResult) {
- debugger.GetOutputFile()->Printf("Executing commands in '%s'.\n",
- cmd_file_path.c_str());
- }
-
- // Used for inheriting the right settings when "command source" might
- // have nested "command source" commands
- lldb::StreamFileSP empty_stream_sp;
- m_command_source_flags.push_back(flags);
- IOHandlerSP io_handler_sp(new IOHandlerEditline(
- debugger, IOHandler::Type::CommandInterpreter, input_file_sp,
- empty_stream_sp, // Pass in an empty stream so we inherit the top
- // input reader output stream
- empty_stream_sp, // Pass in an empty stream so we inherit the top
- // input reader error stream
- flags,
- nullptr, // Pass in NULL for "editline_name" so no history is saved,
- // or written
- debugger.GetPrompt(), llvm::StringRef(),
- false, // Not multi-line
- debugger.GetUseColor(), 0, *this));
- const bool old_async_execution = debugger.GetAsyncExecution();
-
- // Set synchronous execution if we are not stopping on continue
- if ((flags & eHandleCommandFlagStopOnContinue) == 0)
- debugger.SetAsyncExecution(false);
-
- m_command_source_depth++;
-
- debugger.RunIOHandler(io_handler_sp);
- if (!m_command_source_flags.empty())
- m_command_source_flags.pop_back();
- m_command_source_depth--;
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- debugger.SetAsyncExecution(old_async_execution);
- } else {
- result.AppendErrorWithFormat(
- "error: an error occurred read file '%s': %s\n",
- cmd_file_path.c_str(), error.AsCString());
- result.SetStatus(eReturnStatusFailed);
- }
-
- } else {
+ if (!FileSystem::Instance().Exists(cmd_file)) {
result.AppendErrorWithFormat(
"Error reading commands from file %s - file not found.\n",
cmd_file.GetFilename().AsCString("<Unknown>"));
result.SetStatus(eReturnStatusFailed);
return;
}
-}
-ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create) {
- std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
- if (!m_script_interpreter_sp) {
- if (!can_create)
- return nullptr;
- lldb::ScriptLanguage script_lang = GetDebugger().GetScriptLanguage();
- m_script_interpreter_sp =
- PluginManager::GetScriptInterpreterForLanguage(script_lang, *this);
+ StreamFileSP input_file_sp(new StreamFile());
+ std::string cmd_file_path = cmd_file.GetPath();
+ Status error = FileSystem::Instance().Open(input_file_sp->GetFile(), cmd_file,
+ File::eOpenOptionRead);
+
+ if (error.Fail()) {
+ result.AppendErrorWithFormat(
+ "error: an error occurred read file '%s': %s\n", cmd_file_path.c_str(),
+ error.AsCString());
+ result.SetStatus(eReturnStatusFailed);
+ return;
}
- return m_script_interpreter_sp.get();
+
+ Debugger &debugger = GetDebugger();
+
+ uint32_t flags = 0;
+
+ if (options.m_stop_on_continue == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Stop on continue by default
+ flags |= eHandleCommandFlagStopOnContinue;
+ } else if (m_command_source_flags.back() &
+ eHandleCommandFlagStopOnContinue) {
+ flags |= eHandleCommandFlagStopOnContinue;
+ }
+ } else if (options.m_stop_on_continue == eLazyBoolYes) {
+ flags |= eHandleCommandFlagStopOnContinue;
+ }
+
+ if (options.m_stop_on_error == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ if (GetStopCmdSourceOnError())
+ flags |= eHandleCommandFlagStopOnError;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagStopOnError) {
+ flags |= eHandleCommandFlagStopOnError;
+ }
+ } else if (options.m_stop_on_error == eLazyBoolYes) {
+ flags |= eHandleCommandFlagStopOnError;
+ }
+
+ // stop-on-crash can only be set, if it is present in all levels of
+ // pushed flag sets.
+ if (options.GetStopOnCrash()) {
+ if (m_command_source_flags.empty()) {
+ flags |= eHandleCommandFlagStopOnCrash;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagStopOnCrash) {
+ flags |= eHandleCommandFlagStopOnCrash;
+ }
+ }
+
+ if (options.m_echo_commands == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Echo command by default
+ flags |= eHandleCommandFlagEchoCommand;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagEchoCommand) {
+ flags |= eHandleCommandFlagEchoCommand;
+ }
+ } else if (options.m_echo_commands == eLazyBoolYes) {
+ flags |= eHandleCommandFlagEchoCommand;
+ }
+
+ // We will only ever ask for this flag, if we echo commands in general.
+ if (options.m_echo_comment_commands == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Echo comments by default
+ flags |= eHandleCommandFlagEchoCommentCommand;
+ } else if (m_command_source_flags.back() &
+ eHandleCommandFlagEchoCommentCommand) {
+ flags |= eHandleCommandFlagEchoCommentCommand;
+ }
+ } else if (options.m_echo_comment_commands == eLazyBoolYes) {
+ flags |= eHandleCommandFlagEchoCommentCommand;
+ }
+
+ if (options.m_print_results == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Print output by default
+ flags |= eHandleCommandFlagPrintResult;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagPrintResult) {
+ flags |= eHandleCommandFlagPrintResult;
+ }
+ } else if (options.m_print_results == eLazyBoolYes) {
+ flags |= eHandleCommandFlagPrintResult;
+ }
+
+ if (options.m_print_errors == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Print output by default
+ flags |= eHandleCommandFlagPrintErrors;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagPrintErrors) {
+ flags |= eHandleCommandFlagPrintErrors;
+ }
+ } else if (options.m_print_errors == eLazyBoolYes) {
+ flags |= eHandleCommandFlagPrintErrors;
+ }
+
+ if (flags & eHandleCommandFlagPrintResult) {
+ debugger.GetOutputFile()->Printf("Executing commands in '%s'.\n",
+ cmd_file_path.c_str());
+ }
+
+ // Used for inheriting the right settings when "command source" might
+ // have nested "command source" commands
+ lldb::StreamFileSP empty_stream_sp;
+ m_command_source_flags.push_back(flags);
+ IOHandlerSP io_handler_sp(new IOHandlerEditline(
+ debugger, IOHandler::Type::CommandInterpreter, input_file_sp,
+ empty_stream_sp, // Pass in an empty stream so we inherit the top
+ // input reader output stream
+ empty_stream_sp, // Pass in an empty stream so we inherit the top
+ // input reader error stream
+ flags,
+ nullptr, // Pass in NULL for "editline_name" so no history is saved,
+ // or written
+ debugger.GetPrompt(), llvm::StringRef(),
+ false, // Not multi-line
+ debugger.GetUseColor(), 0, *this, nullptr));
+ const bool old_async_execution = debugger.GetAsyncExecution();
+
+ // Set synchronous execution if we are not stopping on continue
+ if ((flags & eHandleCommandFlagStopOnContinue) == 0)
+ debugger.SetAsyncExecution(false);
+
+ m_command_source_depth++;
+
+ debugger.RunIOHandler(io_handler_sp);
+ if (!m_command_source_flags.empty())
+ m_command_source_flags.pop_back();
+ m_command_source_depth--;
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ debugger.SetAsyncExecution(old_async_execution);
}
bool CommandInterpreter::GetSynchronous() { return m_synchronous_execution; }
@@ -2588,7 +2615,7 @@ void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text,
uint32_t chars_left = max_columns;
auto nextWordLength = [](llvm::StringRef S) {
- size_t pos = S.find_first_of(' ');
+ size_t pos = S.find(' ');
return pos == llvm::StringRef::npos ? S.size() : pos;
};
@@ -2801,7 +2828,9 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
HandleCommand(line.c_str(), eLazyBoolCalculate, result);
// Now emit the command output text from the command we just executed
- if (io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) {
+ if ((result.Succeeded() &&
+ io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
+ io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors)) {
// Display any STDOUT/STDERR _prior_ to emitting the command result text
GetProcessOutput();
@@ -2885,7 +2914,8 @@ bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) {
}
}
- ScriptInterpreter *script_interpreter = GetScriptInterpreter(false);
+ ScriptInterpreter *script_interpreter =
+ m_debugger.GetScriptInterpreter(false);
if (script_interpreter) {
if (script_interpreter->Interrupt())
return true;
@@ -2904,8 +2934,9 @@ void CommandInterpreter::GetLLDBCommandsFromIOHandler(
llvm::StringRef(), // Continuation prompt
true, // Get multiple lines
debugger.GetUseColor(),
- 0, // Don't show line numbers
- delegate)); // IOHandlerDelegate
+ 0, // Don't show line numbers
+ delegate, // IOHandlerDelegate
+ nullptr)); // FileShadowCollector
if (io_handler_sp) {
io_handler_sp->SetUserData(baton);
@@ -2927,8 +2958,9 @@ void CommandInterpreter::GetPythonCommandsFromIOHandler(
llvm::StringRef(), // Continuation prompt
true, // Get multiple lines
debugger.GetUseColor(),
- 0, // Don't show line numbers
- delegate)); // IOHandlerDelegate
+ 0, // Don't show line numbers
+ delegate, // IOHandlerDelegate
+ nullptr)); // FileShadowCollector
if (io_handler_sp) {
io_handler_sp->SetUserData(baton);
@@ -2968,19 +3000,23 @@ CommandInterpreter::GetIOHandler(bool force_create,
flags |= eHandleCommandFlagEchoCommentCommand;
if (options->m_print_results != eLazyBoolNo)
flags |= eHandleCommandFlagPrintResult;
+ if (options->m_print_errors != eLazyBoolNo)
+ flags |= eHandleCommandFlagPrintErrors;
} else {
- flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult;
+ flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult |
+ eHandleCommandFlagPrintErrors;
}
- m_command_io_handler_sp.reset(new IOHandlerEditline(
+ m_command_io_handler_sp = std::make_shared<IOHandlerEditline>(
m_debugger, IOHandler::Type::CommandInterpreter,
m_debugger.GetInputFile(), m_debugger.GetOutputFile(),
m_debugger.GetErrorFile(), flags, "lldb", m_debugger.GetPrompt(),
llvm::StringRef(), // Continuation prompt
false, // Don't enable multiple line input, just single line commands
m_debugger.GetUseColor(),
- 0, // Don't show line numbers
- *this));
+ 0, // Don't show line numbers
+ *this, // IOHandlerDelegate
+ GetDebugger().GetInputRecorder());
}
return m_command_io_handler_sp;
}
@@ -3170,7 +3206,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
if (!scratch_command.empty())
revised_command_line.Printf(" %s", scratch_command.c_str());
- if (cmd_obj != NULL)
+ if (cmd_obj != nullptr)
command_line = revised_command_line.GetString();
return cmd_obj;
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 05c540b37c62..8e493c7a326f 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -1,9 +1,8 @@
//===-- CommandObject.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,9 +35,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObject
-//-------------------------------------------------------------------------
CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
llvm::StringRef help, llvm::StringRef syntax, uint32_t flags)
@@ -52,6 +49,8 @@ CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef na
CommandObject::~CommandObject() {}
+Debugger &CommandObject::GetDebugger() { return m_interpreter.GetDebugger(); }
+
llvm::StringRef CommandObject::GetHelp() { return m_cmd_help_short; }
llvm::StringRef CommandObject::GetHelpLong() { return m_cmd_help_long; }
@@ -137,17 +136,15 @@ bool CommandObject::ParseOptions(Args &args, CommandReturnObject &result) {
}
bool CommandObject::CheckRequirements(CommandReturnObject &result) {
-#ifdef LLDB_CONFIGURATION_DEBUG
// Nothing should be stored in m_exe_ctx between running commands as
// m_exe_ctx has shared pointers to the target, process, thread and frame and
// we don't want any CommandObject instances to keep any of these objects
// around longer than for a single command. Every command should call
- // CommandObject::Cleanup() after it has completed
- assert(m_exe_ctx.GetTargetPtr() == NULL);
- assert(m_exe_ctx.GetProcessPtr() == NULL);
- assert(m_exe_ctx.GetThreadPtr() == NULL);
- assert(m_exe_ctx.GetFramePtr() == NULL);
-#endif
+ // CommandObject::Cleanup() after it has completed.
+ assert(!m_exe_ctx.GetTargetPtr());
+ assert(!m_exe_ctx.GetProcessPtr());
+ assert(!m_exe_ctx.GetThreadPtr());
+ assert(!m_exe_ctx.GetFramePtr());
// Lock down the interpreter's execution context prior to running the command
// so we guarantee the selected target, process, thread and frame can't go
@@ -1106,7 +1103,8 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
const CommandObject::ArgumentTableEntry *CommandObject::GetArgumentTable() {
// If this assertion fires, then the table above is out of date with the
// CommandArgumentType enumeration
- assert((sizeof(CommandObject::g_arguments_data) /
- sizeof(CommandObject::ArgumentTableEntry)) == eArgTypeLastArg);
+ static_assert((sizeof(CommandObject::g_arguments_data) /
+ sizeof(CommandObject::ArgumentTableEntry)) == eArgTypeLastArg,
+ "");
return CommandObject::g_arguments_data;
}
diff --git a/source/Interpreter/CommandObjectRegexCommand.cpp b/source/Interpreter/CommandObjectRegexCommand.cpp
index 2944177b0dc3..19335b95ca3a 100644
--- a/source/Interpreter/CommandObjectRegexCommand.cpp
+++ b/source/Interpreter/CommandObjectRegexCommand.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectRegexCommand.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// CommandObjectRegexCommand constructor
-//----------------------------------------------------------------------
CommandObjectRegexCommand::CommandObjectRegexCommand(
CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help,
llvm::StringRef syntax, uint32_t max_matches, uint32_t completion_type_mask,
@@ -26,9 +23,7 @@ CommandObjectRegexCommand::CommandObjectRegexCommand(
m_max_matches(max_matches), m_completion_type_mask(completion_type_mask),
m_entries(), m_is_removable(is_removable) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
CommandObjectRegexCommand::~CommandObjectRegexCommand() {}
bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command,
diff --git a/source/Interpreter/CommandObjectScript.cpp b/source/Interpreter/CommandObjectScript.cpp
index ed434031ae4e..edb1f67e7b37 100644
--- a/source/Interpreter/CommandObjectScript.cpp
+++ b/source/Interpreter/CommandObjectScript.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectScript.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectScript
-//-------------------------------------------------------------------------
CommandObjectScript::CommandObjectScript(CommandInterpreter &interpreter,
ScriptLanguage script_lang)
@@ -53,7 +50,7 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
return false;
}
- ScriptInterpreter *script_interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = GetDebugger().GetScriptInterpreter();
if (script_interpreter == nullptr) {
result.AppendError("no script interpreter");
diff --git a/source/Interpreter/CommandObjectScript.h b/source/Interpreter/CommandObjectScript.h
index ca453a875494..4f7a912979bf 100644
--- a/source/Interpreter/CommandObjectScript.h
+++ b/source/Interpreter/CommandObjectScript.h
@@ -1,9 +1,8 @@
//===-- CommandObjectScript.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectScript
-//-------------------------------------------------------------------------
class CommandObjectScript : public CommandObjectRaw {
public:
diff --git a/source/Interpreter/CommandOptionValidators.cpp b/source/Interpreter/CommandOptionValidators.cpp
index 1e614a958c76..c41c1566aab9 100644
--- a/source/Interpreter/CommandOptionValidators.cpp
+++ b/source/Interpreter/CommandOptionValidators.cpp
@@ -1,9 +1,8 @@
//===-- CommandOptionValidators.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/CommandReturnObject.cpp b/source/Interpreter/CommandReturnObject.cpp
index cf397a47a3bf..3a7a8755d975 100644
--- a/source/Interpreter/CommandReturnObject.cpp
+++ b/source/Interpreter/CommandReturnObject.cpp
@@ -1,9 +1,8 @@
//===-- CommandReturnObject.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionArgParser.cpp b/source/Interpreter/OptionArgParser.cpp
index b0565b706c5b..efaac0720fd0 100644
--- a/source/Interpreter/OptionArgParser.cpp
+++ b/source/Interpreter/OptionArgParser.cpp
@@ -1,9 +1,8 @@
//===-- OptionArgParser.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupArchitecture.cpp b/source/Interpreter/OptionGroupArchitecture.cpp
index 42eafc9872db..2ee1a9c7cf84 100644
--- a/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/source/Interpreter/OptionGroupArchitecture.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupBoolean.cpp b/source/Interpreter/OptionGroupBoolean.cpp
index ca694ef5f488..8a6482c8df25 100644
--- a/source/Interpreter/OptionGroupBoolean.cpp
+++ b/source/Interpreter/OptionGroupBoolean.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupFile.cpp b/source/Interpreter/OptionGroupFile.cpp
index 241bad022ba7..cda75ec205ec 100644
--- a/source/Interpreter/OptionGroupFile.cpp
+++ b/source/Interpreter/OptionGroupFile.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupFile.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupFormat.cpp b/source/Interpreter/OptionGroupFormat.cpp
index 6345a633635c..d9acfd663dd1 100644
--- a/source/Interpreter/OptionGroupFormat.cpp
+++ b/source/Interpreter/OptionGroupFormat.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupFormat.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupOutputFile.cpp b/source/Interpreter/OptionGroupOutputFile.cpp
index aebbf05131a0..ccb99a8fce4a 100644
--- a/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/source/Interpreter/OptionGroupOutputFile.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupPlatform.cpp b/source/Interpreter/OptionGroupPlatform.cpp
index 5858fcc4aa48..6dc2996bb78a 100644
--- a/source/Interpreter/OptionGroupPlatform.cpp
+++ b/source/Interpreter/OptionGroupPlatform.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupPlatform.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupString.cpp b/source/Interpreter/OptionGroupString.cpp
index 1b1fbdf4f6ed..c01b7065fbd0 100644
--- a/source/Interpreter/OptionGroupString.cpp
+++ b/source/Interpreter/OptionGroupString.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupString.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupUInt64.cpp b/source/Interpreter/OptionGroupUInt64.cpp
index bb2dcbbd23f9..53e5674d0296 100644
--- a/source/Interpreter/OptionGroupUInt64.cpp
+++ b/source/Interpreter/OptionGroupUInt64.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupUInt64.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupUUID.cpp b/source/Interpreter/OptionGroupUUID.cpp
index 0859877774cc..e32673bc52af 100644
--- a/source/Interpreter/OptionGroupUUID.cpp
+++ b/source/Interpreter/OptionGroupUUID.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupUUID.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 40f219c8ab86..4e5463a4de00 100644
--- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupVariable.cpp b/source/Interpreter/OptionGroupVariable.cpp
index f90212cfcb2f..d703c3dedcd9 100644
--- a/source/Interpreter/OptionGroupVariable.cpp
+++ b/source/Interpreter/OptionGroupVariable.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupVariable.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupWatchpoint.cpp b/source/Interpreter/OptionGroupWatchpoint.cpp
index 36b4cc5ac4f6..28e6b817fcc5 100644
--- a/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupWatchpoint.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValue.cpp b/source/Interpreter/OptionValue.cpp
index 4e480dd5784b..00c8642595b7 100644
--- a/source/Interpreter/OptionValue.cpp
+++ b/source/Interpreter/OptionValue.cpp
@@ -1,9 +1,8 @@
//===-- OptionValue.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,10 +14,8 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// Get this value as a uint64_t value if it is encoded as a boolean, uint64_t
// or int64_t. Other types will cause "fail_value" to be returned
-//-------------------------------------------------------------------------
uint64_t OptionValue::GetUInt64Value(uint64_t fail_value, bool *success_ptr) {
if (success_ptr)
*success_ptr = true;
@@ -168,13 +165,13 @@ const OptionValueFormat *OptionValue::GetAsFormat() const {
OptionValueLanguage *OptionValue::GetAsLanguage() {
if (GetType() == OptionValue::eTypeLanguage)
return static_cast<OptionValueLanguage *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueLanguage *OptionValue::GetAsLanguage() const {
if (GetType() == OptionValue::eTypeLanguage)
return static_cast<const OptionValueLanguage *>(this);
- return NULL;
+ return nullptr;
}
OptionValueFormatEntity *OptionValue::GetAsFormatEntity() {
@@ -523,7 +520,7 @@ lldb::OptionValueSP OptionValue::CreateValueFromCStringForTypeMask(
value_sp.reset(new OptionValueFormat(eFormatInvalid));
break;
case 1u << eTypeFormatEntity:
- value_sp.reset(new OptionValueFormatEntity(NULL));
+ value_sp.reset(new OptionValueFormatEntity(nullptr));
break;
case 1u << eTypeLanguage:
value_sp.reset(new OptionValueLanguage(eLanguageTypeUnknown));
diff --git a/source/Interpreter/OptionValueArch.cpp b/source/Interpreter/OptionValueArch.cpp
index e4f0b9dd0df0..92dc45d092be 100644
--- a/source/Interpreter/OptionValueArch.cpp
+++ b/source/Interpreter/OptionValueArch.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueArgs.cpp b/source/Interpreter/OptionValueArgs.cpp
index 4fa9e187668d..d619dba5678a 100644
--- a/source/Interpreter/OptionValueArgs.cpp
+++ b/source/Interpreter/OptionValueArgs.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueArgs.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueArray.cpp b/source/Interpreter/OptionValueArray.cpp
index d755fa2fddb9..30902c0f295a 100644
--- a/source/Interpreter/OptionValueArray.cpp
+++ b/source/Interpreter/OptionValueArray.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueArray.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueBoolean.cpp b/source/Interpreter/OptionValueBoolean.cpp
index a7fe10e79431..8be8220fb306 100644
--- a/source/Interpreter/OptionValueBoolean.cpp
+++ b/source/Interpreter/OptionValueBoolean.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueBoolean.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueChar.cpp b/source/Interpreter/OptionValueChar.cpp
index 1307b47a7134..23012e6e2ec3 100644
--- a/source/Interpreter/OptionValueChar.cpp
+++ b/source/Interpreter/OptionValueChar.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueChar.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueDictionary.cpp b/source/Interpreter/OptionValueDictionary.cpp
index 5058064f1ca2..eb66c485bfd1 100644
--- a/source/Interpreter/OptionValueDictionary.cpp
+++ b/source/Interpreter/OptionValueDictionary.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueDictionary.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -277,7 +276,7 @@ Status OptionValueDictionary::SetSubValue(const ExecutionContext *exe_ctx,
}
lldb::OptionValueSP
-OptionValueDictionary::GetValueForKey(const ConstString &key) const {
+OptionValueDictionary::GetValueForKey(ConstString key) const {
lldb::OptionValueSP value_sp;
collection::const_iterator pos = m_values.find(key);
if (pos != m_values.end())
@@ -285,7 +284,7 @@ OptionValueDictionary::GetValueForKey(const ConstString &key) const {
return value_sp;
}
-bool OptionValueDictionary::SetValueForKey(const ConstString &key,
+bool OptionValueDictionary::SetValueForKey(ConstString key,
const lldb::OptionValueSP &value_sp,
bool can_replace) {
// Make sure the value_sp object is allowed to contain values of the type
@@ -302,7 +301,7 @@ bool OptionValueDictionary::SetValueForKey(const ConstString &key,
return false;
}
-bool OptionValueDictionary::DeleteValueForKey(const ConstString &key) {
+bool OptionValueDictionary::DeleteValueForKey(ConstString key) {
collection::iterator pos = m_values.find(key);
if (pos != m_values.end()) {
m_values.erase(pos);
diff --git a/source/Interpreter/OptionValueEnumeration.cpp b/source/Interpreter/OptionValueEnumeration.cpp
index e65dd2b67831..0b76bd0601aa 100644
--- a/source/Interpreter/OptionValueEnumeration.cpp
+++ b/source/Interpreter/OptionValueEnumeration.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueEnumeration.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueFileSpec.cpp b/source/Interpreter/OptionValueFileSpec.cpp
index 735a7d86334d..062d7ccdf2aa 100644
--- a/source/Interpreter/OptionValueFileSpec.cpp
+++ b/source/Interpreter/OptionValueFileSpec.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFileSpec.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueFileSpecLIst.cpp b/source/Interpreter/OptionValueFileSpecLIst.cpp
index fd78bba94fef..a95188870f0b 100644
--- a/source/Interpreter/OptionValueFileSpecLIst.cpp
+++ b/source/Interpreter/OptionValueFileSpecLIst.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFileSpecLIst.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,6 +17,7 @@ using namespace lldb_private;
void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
Stream &strm, uint32_t dump_mask) {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (dump_mask & eDumpOptionType)
strm.Printf("(%s)", GetTypeAsCString());
if (dump_mask & eDumpOptionValue) {
@@ -44,6 +44,7 @@ void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
VarSetOperationType op) {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
Status error;
Args args(value.str());
const size_t argc = args.GetArgumentCount();
@@ -164,5 +165,6 @@ Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
}
lldb::OptionValueSP OptionValueFileSpecList::DeepCopy() const {
- return OptionValueSP(new OptionValueFileSpecList(*this));
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ return OptionValueSP(new OptionValueFileSpecList(m_current_value));
}
diff --git a/source/Interpreter/OptionValueFormat.cpp b/source/Interpreter/OptionValueFormat.cpp
index 945d8bd33615..ba5a44c270da 100644
--- a/source/Interpreter/OptionValueFormat.cpp
+++ b/source/Interpreter/OptionValueFormat.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFormat.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueFormatEntity.cpp b/source/Interpreter/OptionValueFormatEntity.cpp
index 18783625b86f..1bb8c9f6955a 100644
--- a/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/source/Interpreter/OptionValueFormatEntity.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFormatEntity.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueLanguage.cpp b/source/Interpreter/OptionValueLanguage.cpp
index c6e168d66b4f..d935d5e23496 100644
--- a/source/Interpreter/OptionValueLanguage.cpp
+++ b/source/Interpreter/OptionValueLanguage.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueLanguage.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValuePathMappings.cpp b/source/Interpreter/OptionValuePathMappings.cpp
index 11ec739c5bb9..75fcf0247475 100644
--- a/source/Interpreter/OptionValuePathMappings.cpp
+++ b/source/Interpreter/OptionValuePathMappings.cpp
@@ -1,9 +1,8 @@
//===-- OptionValuePathMappings.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueProperties.cpp b/source/Interpreter/OptionValueProperties.cpp
index 327d26b09ebb..4dae930c3a6f 100644
--- a/source/Interpreter/OptionValueProperties.cpp
+++ b/source/Interpreter/OptionValueProperties.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueProperties.cpp --------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@
using namespace lldb;
using namespace lldb_private;
-OptionValueProperties::OptionValueProperties(const ConstString &name)
+OptionValueProperties::OptionValueProperties(ConstString name)
: OptionValue(), m_name(name), m_properties(), m_name_to_index() {}
OptionValueProperties::OptionValueProperties(
@@ -67,8 +66,8 @@ void OptionValueProperties::SetValueChangedCallback(
property->SetValueChangedCallback(callback, baton);
}
-void OptionValueProperties::AppendProperty(const ConstString &name,
- const ConstString &desc,
+void OptionValueProperties::AppendProperty(ConstString name,
+ ConstString desc,
bool is_global,
const OptionValueSP &value_sp) {
Property property(name, desc, is_global, value_sp);
@@ -99,7 +98,7 @@ void OptionValueProperties::AppendProperty(const ConstString &name,
//
lldb::OptionValueSP
OptionValueProperties::GetValueForKey(const ExecutionContext *exe_ctx,
- const ConstString &key,
+ ConstString key,
bool will_modify) const {
lldb::OptionValueSP value_sp;
size_t idx = m_name_to_index.Find(key, SIZE_MAX);
@@ -160,7 +159,7 @@ OptionValueProperties::GetSubValue(const ExecutionContext *exe_ctx,
// args if executable basename is "test" and arch is "x86_64"
if (sub_name[1]) {
llvm::StringRef predicate_start = sub_name.drop_front();
- size_t pos = predicate_start.find_first_of('}');
+ size_t pos = predicate_start.find('}');
if (pos != llvm::StringRef::npos) {
auto predicate = predicate_start.take_front(pos);
auto rest = predicate_start.drop_front(pos);
@@ -205,7 +204,6 @@ Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx,
if (Properties::IsSettingExperimental(part))
name_contains_experimental = true;
-
lldb::OptionValueSP value_sp(GetSubValue(exe_ctx, name, will_modify, error));
if (value_sp)
error = value_sp->SetValueFromString(value, op);
@@ -220,14 +218,14 @@ Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx,
}
uint32_t
-OptionValueProperties::GetPropertyIndex(const ConstString &name) const {
+OptionValueProperties::GetPropertyIndex(ConstString name) const {
return m_name_to_index.Find(name, SIZE_MAX);
}
const Property *
OptionValueProperties::GetProperty(const ExecutionContext *exe_ctx,
bool will_modify,
- const ConstString &name) const {
+ ConstString name) const {
return GetPropertyAtIndex(
exe_ctx, will_modify,
m_name_to_index.Find(name, SIZE_MAX));
@@ -668,7 +666,7 @@ void OptionValueProperties::Apropos(
lldb::OptionValuePropertiesSP
OptionValueProperties::GetSubProperty(const ExecutionContext *exe_ctx,
- const ConstString &name) {
+ ConstString name) {
lldb::OptionValueSP option_value_sp(GetValueForKey(exe_ctx, name, false));
if (option_value_sp) {
OptionValueProperties *ov_properties = option_value_sp->GetAsProperties();
diff --git a/source/Interpreter/OptionValueRegex.cpp b/source/Interpreter/OptionValueRegex.cpp
index 3c06ff3957b0..bbe3fa715019 100644
--- a/source/Interpreter/OptionValueRegex.cpp
+++ b/source/Interpreter/OptionValueRegex.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueRegex.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueSInt64.cpp b/source/Interpreter/OptionValueSInt64.cpp
index c087c3ee24be..d26fc08a3132 100644
--- a/source/Interpreter/OptionValueSInt64.cpp
+++ b/source/Interpreter/OptionValueSInt64.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueSInt64.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueString.cpp b/source/Interpreter/OptionValueString.cpp
index c89a0c6bf404..a519249ab472 100644
--- a/source/Interpreter/OptionValueString.cpp
+++ b/source/Interpreter/OptionValueString.cpp
@@ -1,10 +1,9 @@
//===-- OptionValueString.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueUInt64.cpp b/source/Interpreter/OptionValueUInt64.cpp
index 053b5798880e..3be0772daa8c 100644
--- a/source/Interpreter/OptionValueUInt64.cpp
+++ b/source/Interpreter/OptionValueUInt64.cpp
@@ -1,10 +1,9 @@
//===-- OptionValueUInt64.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueUUID.cpp b/source/Interpreter/OptionValueUUID.cpp
index 5518a0574112..f39b66b77bb0 100644
--- a/source/Interpreter/OptionValueUUID.cpp
+++ b/source/Interpreter/OptionValueUUID.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueUUID.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index c6357399a7e2..ba15c020f2da 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -1,9 +1,8 @@
//===-- Options.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// Options
-//-------------------------------------------------------------------------
Options::Options() : m_getopt_table() { BuildValidOptionSets(); }
Options::~Options() {}
@@ -761,7 +758,7 @@ bool Options::HandleOptionArgumentCompletion(
CompletionRequest &request, OptionElementVector &opt_element_vector,
int opt_element_index, CommandInterpreter &interpreter) {
auto opt_defs = GetDefinitions();
- std::unique_ptr<SearchFilter> filter_ap;
+ std::unique_ptr<SearchFilter> filter_up;
int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
@@ -832,7 +829,7 @@ bool Options::HandleOptionArgumentCompletion(
interpreter.GetDebugger().GetSelectedTarget();
// Search filters require a target...
if (target_sp)
- filter_ap.reset(new SearchFilterByModule(target_sp, module_spec));
+ filter_up.reset(new SearchFilterByModule(target_sp, module_spec));
}
break;
}
@@ -840,7 +837,7 @@ bool Options::HandleOptionArgumentCompletion(
}
return CommandCompletions::InvokeCommonCompletionCallbacks(
- interpreter, completion_mask, request, filter_ap.get());
+ interpreter, completion_mask, request, filter_up.get());
}
void OptionGroupOptions::Append(OptionGroup *group) {
@@ -933,6 +930,7 @@ static std::vector<char *> GetArgvForParsing(const Args &args) {
result.push_back(const_cast<char *>("<FAKE-ARG0>"));
for (const Args::ArgEntry &entry : args)
result.push_back(const_cast<char *>(entry.c_str()));
+ result.push_back(nullptr);
return result;
}
@@ -975,19 +973,15 @@ static size_t FindArgumentIndexForOption(const Args &args,
return size_t(-1);
}
-llvm::Expected<Args> Options::ParseAlias(const Args &args,
- OptionArgVector *option_arg_vector,
- std::string &input_line) {
- StreamString sstr;
- int i;
- Option *long_options = GetLongOptions();
+static std::string BuildShortOptions(const Option *long_options) {
+ std::string storage;
+ llvm::raw_string_ostream sstr(storage);
- if (long_options == nullptr) {
- return llvm::make_error<llvm::StringError>("Invalid long options",
- llvm::inconvertibleErrorCode());
- }
+ // Leading : tells getopt to return a : for a missing option argument AND to
+ // suppress error messages.
+ sstr << ":";
- for (i = 0; long_options[i].definition != nullptr; ++i) {
+ for (size_t i = 0; long_options[i].definition != nullptr; ++i) {
if (long_options[i].flag == nullptr) {
sstr << (char)long_options[i].val;
switch (long_options[i].definition->option_has_arg) {
@@ -1003,6 +997,20 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
}
}
}
+ return std::move(sstr.str());
+}
+
+llvm::Expected<Args> Options::ParseAlias(const Args &args,
+ OptionArgVector *option_arg_vector,
+ std::string &input_line) {
+ Option *long_options = GetLongOptions();
+
+ if (long_options == nullptr) {
+ return llvm::make_error<llvm::StringError>("Invalid long options",
+ llvm::inconvertibleErrorCode());
+ }
+
+ std::string short_options = BuildShortOptions(long_options);
Args args_copy = args;
std::vector<char *> argv = GetArgvForParsing(args);
@@ -1010,10 +1018,15 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
int val;
- while (1) {
+ while (true) {
int long_options_index = -1;
- val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
- long_options, &long_options_index);
+ val = OptionParser::Parse(argv, short_options, long_options,
+ &long_options_index);
+
+ if (val == ':') {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "last option requires an argument");
+ }
if (val == -1)
break;
@@ -1119,33 +1132,13 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
OptionElementVector Options::ParseForCompletion(const Args &args,
uint32_t cursor_index) {
OptionElementVector option_element_vector;
- StreamString sstr;
Option *long_options = GetLongOptions();
option_element_vector.clear();
if (long_options == nullptr)
return option_element_vector;
- // Leading : tells getopt to return a : for a missing option argument AND to
- // suppress error messages.
-
- sstr << ":";
- for (int i = 0; long_options[i].definition != nullptr; ++i) {
- if (long_options[i].flag == nullptr) {
- sstr << (char)long_options[i].val;
- switch (long_options[i].definition->option_has_arg) {
- default:
- case OptionParser::eNoArgument:
- break;
- case OptionParser::eRequiredArgument:
- sstr << ":";
- break;
- case OptionParser::eOptionalArgument:
- sstr << "::";
- break;
- }
- }
- }
+ std::string short_options = BuildShortOptions(long_options);
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
@@ -1156,19 +1149,15 @@ OptionElementVector Options::ParseForCompletion(const Args &args,
std::vector<char *> dummy_vec = GetArgvForParsing(args);
- // I stick an element on the end of the input, because if the last element
- // is option that requires an argument, getopt_long_only will freak out.
- dummy_vec.push_back(const_cast<char *>("<FAKE-VALUE>"));
-
bool failed_once = false;
uint32_t dash_dash_pos = -1;
- while (1) {
+ while (true) {
bool missing_argument = false;
int long_options_index = -1;
- val = OptionParser::Parse(dummy_vec.size(), &dummy_vec[0], sstr.GetString(),
- long_options, &long_options_index);
+ val = OptionParser::Parse(dummy_vec, short_options, long_options,
+ &long_options_index);
if (val == -1) {
// When we're completing a "--" which is the last option on line,
@@ -1331,7 +1320,6 @@ llvm::Expected<Args> Options::Parse(const Args &args,
ExecutionContext *execution_context,
lldb::PlatformSP platform_sp,
bool require_validation) {
- StreamString sstr;
Status error;
Option *long_options = GetLongOptions();
if (long_options == nullptr) {
@@ -1339,32 +1327,21 @@ llvm::Expected<Args> Options::Parse(const Args &args,
llvm::inconvertibleErrorCode());
}
- for (int i = 0; long_options[i].definition != nullptr; ++i) {
- if (long_options[i].flag == nullptr) {
- if (isprint8(long_options[i].val)) {
- sstr << (char)long_options[i].val;
- switch (long_options[i].definition->option_has_arg) {
- default:
- case OptionParser::eNoArgument:
- break;
- case OptionParser::eRequiredArgument:
- sstr << ':';
- break;
- case OptionParser::eOptionalArgument:
- sstr << "::";
- break;
- }
- }
- }
- }
+ std::string short_options = BuildShortOptions(long_options);
std::vector<char *> argv = GetArgvForParsing(args);
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
int val;
- while (1) {
+ while (true) {
int long_options_index = -1;
- val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
- long_options, &long_options_index);
+ val = OptionParser::Parse(argv, short_options, long_options,
+ &long_options_index);
+
+ if (val == ':') {
+ error.SetErrorStringWithFormat("last option requires an argument");
+ break;
+ }
+
if (val == -1)
break;
@@ -1437,10 +1414,12 @@ llvm::Expected<Args> Options::Parse(const Args &args,
} else {
error.SetErrorStringWithFormat("invalid option with value '%i'", val);
}
- if (error.Fail())
- return error.ToError();
}
+ if (error.Fail())
+ return error.ToError();
+
+ argv.pop_back();
argv.erase(argv.begin(), argv.begin() + OptionParser::GetOptionIndex());
return ReconstituteArgsAfterParsing(argv, args);
}
diff --git a/source/Interpreter/Property.cpp b/source/Interpreter/Property.cpp
index 5f1022347cf4..78209311e2e5 100644
--- a/source/Interpreter/Property.cpp
+++ b/source/Interpreter/Property.cpp
@@ -1,9 +1,8 @@
//===-- Property.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,6 +15,8 @@
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Target/Language.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -30,18 +31,20 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_uint_value" is not used
// "definition.default_cstr_value" as a string value that represents the
// default string value for the architecture/triple
- m_value_sp.reset(new OptionValueArch(definition.default_cstr_value));
+ m_value_sp =
+ std::make_shared<OptionValueArch>(definition.default_cstr_value);
break;
case OptionValue::eTypeArgs:
// "definition.default_uint_value" is always a OptionValue::Type
- m_value_sp.reset(new OptionValueArgs());
+ m_value_sp = std::make_shared<OptionValueArgs>();
break;
case OptionValue::eTypeArray:
// "definition.default_uint_value" is always a OptionValue::Type
- m_value_sp.reset(new OptionValueArray(OptionValue::ConvertTypeToMask(
- (OptionValue::Type)definition.default_uint_value)));
+ m_value_sp =
+ std::make_shared<OptionValueArray>(OptionValue::ConvertTypeToMask(
+ (OptionValue::Type)definition.default_uint_value));
break;
case OptionValue::eTypeBoolean:
@@ -50,11 +53,12 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_cstr_value" as a string value that represents the
// default value.
if (definition.default_cstr_value)
- m_value_sp.reset(new OptionValueBoolean(OptionArgParser::ToBoolean(
- llvm::StringRef(definition.default_cstr_value), false, nullptr)));
+ m_value_sp =
+ std::make_shared<OptionValueBoolean>(OptionArgParser::ToBoolean(
+ llvm::StringRef(definition.default_cstr_value), false, nullptr));
else
- m_value_sp.reset(
- new OptionValueBoolean(definition.default_uint_value != 0));
+ m_value_sp = std::make_shared<OptionValueBoolean>(
+ definition.default_uint_value != 0);
break;
case OptionValue::eTypeChar: {
@@ -65,8 +69,9 @@ Property::Property(const PropertyDefinition &definition)
}
case OptionValue::eTypeDictionary:
// "definition.default_uint_value" is always a OptionValue::Type
- m_value_sp.reset(new OptionValueDictionary(OptionValue::ConvertTypeToMask(
- (OptionValue::Type)definition.default_uint_value)));
+ m_value_sp =
+ std::make_shared<OptionValueDictionary>(OptionValue::ConvertTypeToMask(
+ (OptionValue::Type)definition.default_uint_value));
break;
case OptionValue::eTypeEnum:
@@ -101,14 +106,14 @@ Property::Property(const PropertyDefinition &definition)
FileSpec file_spec = FileSpec(definition.default_cstr_value);
if (resolve)
FileSystem::Instance().Resolve(file_spec);
- m_value_sp.reset(new OptionValueFileSpec(file_spec, resolve));
+ m_value_sp = std::make_shared<OptionValueFileSpec>(file_spec, resolve);
break;
}
case OptionValue::eTypeFileSpecList:
// "definition.default_uint_value" is not used for a
// OptionValue::eTypeFileSpecList
- m_value_sp.reset(new OptionValueFileSpecList());
+ m_value_sp = std::make_shared<OptionValueFileSpecList>();
break;
case OptionValue::eTypeFormat:
@@ -123,7 +128,7 @@ Property::Property(const PropertyDefinition &definition)
nullptr);
else
new_format = (Format)definition.default_uint_value;
- m_value_sp.reset(new OptionValueFormat(new_format));
+ m_value_sp = std::make_shared<OptionValueFormat>(new_format);
}
break;
@@ -139,29 +144,30 @@ Property::Property(const PropertyDefinition &definition)
llvm::StringRef(definition.default_cstr_value));
else
new_lang = (LanguageType)definition.default_uint_value;
- m_value_sp.reset(new OptionValueLanguage(new_lang));
+ m_value_sp = std::make_shared<OptionValueLanguage>(new_lang);
}
break;
case OptionValue::eTypeFormatEntity:
// "definition.default_cstr_value" as a string value that represents the
// default
- m_value_sp.reset(
- new OptionValueFormatEntity(definition.default_cstr_value));
+ m_value_sp = std::make_shared<OptionValueFormatEntity>(
+ definition.default_cstr_value);
break;
case OptionValue::eTypePathMap:
// "definition.default_uint_value" tells us if notifications should occur
// for path mappings
- m_value_sp.reset(
- new OptionValuePathMappings(definition.default_uint_value != 0));
+ m_value_sp = std::make_shared<OptionValuePathMappings>(
+ definition.default_uint_value != 0);
break;
case OptionValue::eTypeRegex:
// "definition.default_uint_value" is used to the regular expression flags
// "definition.default_cstr_value" the default regular expression value
// value.
- m_value_sp.reset(new OptionValueRegex(definition.default_cstr_value));
+ m_value_sp =
+ std::make_shared<OptionValueRegex>(definition.default_cstr_value);
break;
case OptionValue::eTypeSInt64:
@@ -169,10 +175,10 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the
// default value.
- m_value_sp.reset(new OptionValueSInt64(
+ m_value_sp = std::make_shared<OptionValueSInt64>(
definition.default_cstr_value
? StringConvert::ToSInt64(definition.default_cstr_value)
- : definition.default_uint_value));
+ : definition.default_uint_value);
break;
case OptionValue::eTypeUInt64:
@@ -180,10 +186,10 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the
// default value.
- m_value_sp.reset(new OptionValueUInt64(
+ m_value_sp = std::make_shared<OptionValueUInt64>(
definition.default_cstr_value
? StringConvert::ToUInt64(definition.default_cstr_value)
- : definition.default_uint_value));
+ : definition.default_uint_value);
break;
case OptionValue::eTypeUUID:
@@ -193,7 +199,7 @@ Property::Property(const PropertyDefinition &definition)
UUID uuid;
if (definition.default_cstr_value)
uuid.SetFromStringRef(definition.default_cstr_value);
- m_value_sp.reset(new OptionValueUUID(uuid));
+ m_value_sp = std::make_shared<OptionValueUUID>(uuid);
}
break;
@@ -212,7 +218,7 @@ Property::Property(const PropertyDefinition &definition)
}
}
-Property::Property(const ConstString &name, const ConstString &desc,
+Property::Property(ConstString name, ConstString desc,
bool is_global, const lldb::OptionValueSP &value_sp)
: m_name(name), m_description(desc), m_value_sp(value_sp),
m_is_global(is_global) {}
diff --git a/source/Interpreter/ScriptInterpreter.cpp b/source/Interpreter/ScriptInterpreter.cpp
index 497ad283f1a4..d04baec76e60 100644
--- a/source/Interpreter/ScriptInterpreter.cpp
+++ b/source/Interpreter/ScriptInterpreter.cpp
@@ -1,9 +1,8 @@
//===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,16 +21,12 @@
using namespace lldb;
using namespace lldb_private;
-ScriptInterpreter::ScriptInterpreter(CommandInterpreter &interpreter,
+ScriptInterpreter::ScriptInterpreter(Debugger &debugger,
lldb::ScriptLanguage script_lang)
- : m_interpreter(interpreter), m_script_lang(script_lang) {}
+ : m_debugger(debugger), m_script_lang(script_lang) {}
ScriptInterpreter::~ScriptInterpreter() {}
-CommandInterpreter &ScriptInterpreter::GetCommandInterpreter() {
- return m_interpreter;
-}
-
void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
std::vector<BreakpointOptions *> &bp_options_vec,
CommandReturnObject &result) {
diff --git a/source/Interpreter/embedded_interpreter.py b/source/Interpreter/embedded_interpreter.py
index c103b7e2e1d3..8a1195d83c6f 100644
--- a/source/Interpreter/embedded_interpreter.py
+++ b/source/Interpreter/embedded_interpreter.py
@@ -72,6 +72,7 @@ def get_terminal_size(fd):
def readfunc_stdio(prompt):
sys.stdout.write(prompt)
+ sys.stdout.flush()
return sys.stdin.readline().rstrip()