
This is an NFC cleanup. Many of the API's that returned BreakpointOptions always returned valid ones. Internally the BreakpointLocations usually have null BreakpointOptions, since they use their owner's options until an option is set specifically on the location. So the original code used pointers & unique_ptr everywhere for consistency. But that made the code hard to reason about from the outside. This patch changes the code so that everywhere an API is guaranteed to return a non-null BreakpointOption, it returns it as a reference to make that clear. It also changes the Breakpoint to hold a BreakpointOption member where it previously had a UP. Since we were always filling the UP in the Breakpoint constructor, having the UP wasn't helping anything. Differential Revision: https://reviews.llvm.org/D104162
99 lines
3.2 KiB
C++
99 lines
3.2 KiB
C++
//===-- ScriptInterpreterLua.h ----------------------------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef liblldb_ScriptInterpreterLua_h_
|
|
#define liblldb_ScriptInterpreterLua_h_
|
|
|
|
#include <vector>
|
|
|
|
#include "lldb/Core/StructuredDataImpl.h"
|
|
#include "lldb/Interpreter/ScriptInterpreter.h"
|
|
#include "lldb/Utility/Status.h"
|
|
#include "lldb/lldb-enumerations.h"
|
|
|
|
namespace lldb_private {
|
|
class Lua;
|
|
class ScriptInterpreterLua : public ScriptInterpreter {
|
|
public:
|
|
class CommandDataLua : public BreakpointOptions::CommandData {
|
|
public:
|
|
CommandDataLua() : BreakpointOptions::CommandData() {
|
|
interpreter = lldb::eScriptLanguageLua;
|
|
}
|
|
CommandDataLua(StructuredData::ObjectSP extra_args_sp)
|
|
: BreakpointOptions::CommandData(), m_extra_args_sp(extra_args_sp) {
|
|
interpreter = lldb::eScriptLanguageLua;
|
|
}
|
|
StructuredData::ObjectSP m_extra_args_sp;
|
|
};
|
|
|
|
ScriptInterpreterLua(Debugger &debugger);
|
|
|
|
~ScriptInterpreterLua() override;
|
|
|
|
bool ExecuteOneLine(
|
|
llvm::StringRef command, CommandReturnObject *result,
|
|
const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
|
|
|
|
void ExecuteInterpreterLoop() override;
|
|
|
|
bool LoadScriptingModule(const char *filename, bool init_session,
|
|
lldb_private::Status &error,
|
|
StructuredData::ObjectSP *module_sp = nullptr,
|
|
FileSpec extra_search_dir = {}) override;
|
|
|
|
// Static Functions
|
|
static void Initialize();
|
|
|
|
static void Terminate();
|
|
|
|
static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger);
|
|
|
|
static lldb_private::ConstString GetPluginNameStatic();
|
|
|
|
static const char *GetPluginDescriptionStatic();
|
|
|
|
static bool BreakpointCallbackFunction(void *baton,
|
|
StoppointCallbackContext *context,
|
|
lldb::user_id_t break_id,
|
|
lldb::user_id_t break_loc_id);
|
|
|
|
// PluginInterface protocol
|
|
lldb_private::ConstString GetPluginName() override;
|
|
|
|
uint32_t GetPluginVersion() override;
|
|
|
|
Lua &GetLua();
|
|
|
|
llvm::Error EnterSession(lldb::user_id_t debugger_id);
|
|
llvm::Error LeaveSession();
|
|
|
|
void CollectDataForBreakpointCommandCallback(
|
|
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
|
|
CommandReturnObject &result) override;
|
|
|
|
Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
|
|
const char *command_body_text) override;
|
|
|
|
Status SetBreakpointCommandCallbackFunction(
|
|
BreakpointOptions &bp_options, const char *function_name,
|
|
StructuredData::ObjectSP extra_args_sp) override;
|
|
|
|
private:
|
|
std::unique_ptr<Lua> m_lua;
|
|
bool m_session_is_active = false;
|
|
|
|
Status RegisterBreakpointCallback(BreakpointOptions &bp_options,
|
|
const char *command_body_text,
|
|
StructuredData::ObjectSP extra_args_sp);
|
|
};
|
|
|
|
} // namespace lldb_private
|
|
|
|
#endif // liblldb_ScriptInterpreterLua_h_
|