summaryrefslogtreecommitdiff
path: root/source/Commands/CommandObjectWatchpointCommand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Commands/CommandObjectWatchpointCommand.cpp')
-rw-r--r--source/Commands/CommandObjectWatchpointCommand.cpp59
1 files changed, 24 insertions, 35 deletions
diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp
index 3a9ebfbd15d0..2be0b5b154e0 100644
--- a/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectWatchpointCommand.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;
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommandAdd
-//-------------------------------------------------------------------------
// FIXME: "script-type" needs to have its contents determined dynamically, so
// somebody can add a new scripting
@@ -46,12 +43,8 @@ static constexpr OptionEnumValues ScriptOptionEnum() {
}
static constexpr OptionDefinition g_watchpoint_command_add_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." },
- { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether watchpoint command execution should terminate on error." },
- { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, ScriptOptionEnum(), 0, eArgTypeNone, "Specify the language for the commands - if none is specified, the lldb command interpreter will be used." },
- { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate." }
- // clang-format on
+#define LLDB_OPTIONS_watchpoint_command_add
+#include "CommandOptions.inc"
};
class CommandObjectWatchpointCommandAdd : public CommandObjectParsed,
@@ -208,9 +201,9 @@ are no syntax errors may indicate that a function was declared but never called.
Options *GetOptions() override { return &m_options; }
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(
"Enter your debugger command(s). Type 'DONE' to end.\n");
output_sp->Flush();
@@ -226,12 +219,12 @@ are no syntax errors may indicate that a function was declared but never called.
WatchpointOptions *wp_options =
(WatchpointOptions *)io_handler.GetUserData();
if (wp_options) {
- std::unique_ptr<WatchpointOptions::CommandData> data_ap(
+ std::unique_ptr<WatchpointOptions::CommandData> data_up(
new WatchpointOptions::CommandData());
- if (data_ap) {
- data_ap->user_source.SplitIntoLines(line);
+ if (data_up) {
+ data_up->user_source.SplitIntoLines(line);
auto baton_sp = std::make_shared<WatchpointOptions::CommandBaton>(
- std::move(data_ap));
+ std::move(data_up));
wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp);
}
}
@@ -250,19 +243,19 @@ are no syntax errors may indicate that a function was declared but never called.
/// Set a one-liner as the callback for the watchpoint.
void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
const char *oneliner) {
- std::unique_ptr<WatchpointOptions::CommandData> data_ap(
+ std::unique_ptr<WatchpointOptions::CommandData> data_up(
new WatchpointOptions::CommandData());
// It's necessary to set both user_source and script_source to the
// oneliner. The former is used to generate callback description (as in
// watchpoint command list) while the latter is used for Python to
// interpret during the actual callback.
- data_ap->user_source.AppendString(oneliner);
- data_ap->script_source.assign(oneliner);
- data_ap->stop_on_error = m_options.m_stop_on_error;
+ data_up->user_source.AppendString(oneliner);
+ data_up->script_source.assign(oneliner);
+ data_up->stop_on_error = m_options.m_stop_on_error;
auto baton_sp =
- std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_ap));
+ std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_up));
wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp);
}
@@ -298,6 +291,7 @@ are no syntax errors may indicate that a function was declared but never called.
options.SetStopOnError(data->stop_on_error);
options.SetEchoCommands(false);
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetAddToHistory(false);
debugger.GetCommandInterpreter().HandleCommands(commands, &exe_ctx,
@@ -390,7 +384,7 @@ are no syntax errors may indicate that a function was declared but never called.
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("There is not a current executable; there are no "
@@ -445,7 +439,7 @@ protected:
if (m_options.m_use_script_language) {
// Special handling for one-liner specified inline.
if (m_options.m_use_one_liner) {
- m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback(
+ GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
wp_options, m_options.m_one_liner.c_str());
}
// Special handling for using a Python function by name instead of
@@ -455,10 +449,11 @@ protected:
else if (!m_options.m_function_name.empty()) {
std::string oneliner(m_options.m_function_name);
oneliner += "(frame, wp, internal_dict)";
- m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback(
+ GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
wp_options, oneliner.c_str());
} else {
- m_interpreter.GetScriptInterpreter()
+ GetDebugger()
+ .GetScriptInterpreter()
->CollectDataForWatchpointCommandCallback(wp_options, result);
}
} else {
@@ -479,9 +474,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommandDelete
-//-------------------------------------------------------------------------
class CommandObjectWatchpointCommandDelete : public CommandObjectParsed {
public:
@@ -508,7 +501,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("There is not a current executable; there are no "
@@ -559,9 +552,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommandList
-//-------------------------------------------------------------------------
class CommandObjectWatchpointCommandList : public CommandObjectParsed {
public:
@@ -589,7 +580,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("There is not a current executable; there are no "
@@ -659,9 +650,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommand
-//-------------------------------------------------------------------------
CommandObjectWatchpointCommand::CommandObjectWatchpointCommand(
CommandInterpreter &interpreter)