From 29e28f92ef12b4810385df3912446afe460bdfac Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 5 Jun 2024 00:16:30 +1200 Subject: [PATCH] Rename `GdbCommand` to `DebuggerExtensionCommand` --- CMakeLists.txt | 2 +- scripts/rr-gdb-script-host.py | 8 +++---- ...Command.cc => DebuggerExtensionCommand.cc} | 24 +++++++++---------- ...dbCommand.h => DebuggerExtensionCommand.h} | 18 +++++++------- src/DebuggerExtensionCommandHandler.cc | 16 ++++++------- src/DebuggerExtensionCommandHandler.h | 6 ++--- src/GdbServer.h | 2 +- 7 files changed, 38 insertions(+), 38 deletions(-) rename src/{GdbCommand.cc => DebuggerExtensionCommand.cc} (91%) rename src/{GdbCommand.h => DebuggerExtensionCommand.h} (79%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbbdb3e3951..3ae012857a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -579,7 +579,7 @@ set(RR_SOURCES src/FileNameCommand.cc src/Flags.cc src/ftrace.cc - src/GdbCommand.cc + src/DebuggerExtensionCommand.cc src/DebuggerExtensionCommandHandler.cc src/GdbServerConnection.cc src/GdbServerExpression.cc diff --git a/scripts/rr-gdb-script-host.py b/scripts/rr-gdb-script-host.py index b4e143e38fd..4e2bf298513 100755 --- a/scripts/rr-gdb-script-host.py +++ b/scripts/rr-gdb-script-host.py @@ -16,9 +16,9 @@ def strip_prefix(s: str, needle: str) -> Optional[str]: GdbNewObjfileEventCallback = Callable[[object], None] -class GdbCommand: +class DebuggerExtensionCommand: def __init__(self, *args, **kwargs): - logging.debug("GdbCommand(%s, %s)" % (args, kwargs)) + logging.debug("DebuggerExtensionCommand(%s, %s)" % (args, kwargs)) class GdbScriptHost: """ The filename of the main symbol file """ @@ -166,8 +166,8 @@ def COMMAND_USER(self) -> int: return 13 @property - def Command(self) -> GdbCommand: - return GdbCommand + def Command(self) -> DebuggerExtensionCommand: + return DebuggerExtensionCommand if __name__ == '__main__': with open(sys.argv[1], 'r') as user_script_file: diff --git a/src/GdbCommand.cc b/src/DebuggerExtensionCommand.cc similarity index 91% rename from src/GdbCommand.cc rename to src/DebuggerExtensionCommand.cc index b9ce6c5d787..fb00de00981 100644 --- a/src/GdbCommand.cc +++ b/src/DebuggerExtensionCommand.cc @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ -#include "GdbCommand.h" +#include "DebuggerExtensionCommand.h" #include "ReplayTask.h" #include "log.h" @@ -9,7 +9,7 @@ using namespace std; namespace rr { -static SimpleGdbCommand elapsed_time( +static SimpleDebuggerExtensionCommand elapsed_time( "elapsed-time", "Print elapsed time (in seconds) since the start of the trace, in the" " 'record' timeline.", @@ -25,7 +25,7 @@ static SimpleGdbCommand elapsed_time( return string("Elapsed Time (s): ") + to_string(elapsed_time); }); -static SimpleGdbCommand when( +static SimpleDebuggerExtensionCommand when( "when", "Print the number of the last completely replayed rr event.", [](GdbServer&, Task* t, const vector&) { if (!t->session().is_replaying()) { @@ -38,7 +38,7 @@ static SimpleGdbCommand when( static_cast(t)->current_trace_frame().time() - 1); }); -static SimpleGdbCommand when_ticks( +static SimpleDebuggerExtensionCommand when_ticks( "when-ticks", "Print the current rr tick count for the current thread.", [](GdbServer&, Task* t, const vector&) { if (!t->session().is_replaying()) { @@ -47,7 +47,7 @@ static SimpleGdbCommand when_ticks( return string("Current tick: ") + to_string(t->tick_count()); }); -static SimpleGdbCommand when_tid( +static SimpleDebuggerExtensionCommand when_tid( "when-tid", "Print the real tid for the current thread.", [](GdbServer&, Task* t, const vector&) { if (!t->session().is_replaying()) { @@ -59,7 +59,7 @@ static SimpleGdbCommand when_tid( static std::vector back_stack; static ReplayTimeline::Mark current_history_cp; static std::vector forward_stack; -static SimpleGdbCommand rr_history_push( +static SimpleDebuggerExtensionCommand rr_history_push( "rr-history-push", "Push an entry into the rr history.", [](GdbServer& gdb_server, Task* t, const vector&) { if (!gdb_server.timeline()) { @@ -76,7 +76,7 @@ static SimpleGdbCommand rr_history_push( forward_stack.clear(); return string(); }); -static SimpleGdbCommand back( +static SimpleDebuggerExtensionCommand back( "back", "Go back one entry in the rr history.", [](GdbServer& gdb_server, Task* t, const vector&) { if (!gdb_server.timeline()) { @@ -94,7 +94,7 @@ static SimpleGdbCommand back( gdb_server.timeline()->seek_to_mark(current_history_cp); return string(); }); -static SimpleGdbCommand forward( +static SimpleDebuggerExtensionCommand forward( "forward", "Go forward one entry in the rr history.", [](GdbServer& gdb_server, Task* t, const vector&) { if (!gdb_server.timeline()) { @@ -135,7 +135,7 @@ string invoke_checkpoint(GdbServer& gdb_server, Task*, *gdb_server.timeline(), gdb_server.last_continue_task, e, where); return string("Checkpoint ") + to_string(checkpoint_id) + " at " + where; } -static SimpleGdbCommand checkpoint( +static SimpleDebuggerExtensionCommand checkpoint( "checkpoint", "create a checkpoint representing a point in the execution\n" "use the 'restart' command to return to the checkpoint", @@ -161,7 +161,7 @@ string invoke_delete_checkpoint(GdbServer& gdb_server, Task*, return string("No checkpoint number ") + to_string(id) + "."; } } -static SimpleGdbCommand delete_checkpoint( +static SimpleDebuggerExtensionCommand delete_checkpoint( "delete checkpoint", "remove a checkpoint created with the 'checkpoint' command", invoke_delete_checkpoint); @@ -178,12 +178,12 @@ string invoke_info_checkpoints(GdbServer& gdb_server, Task*, } return out; } -static SimpleGdbCommand info_checkpoints( +static SimpleDebuggerExtensionCommand info_checkpoints( "info checkpoints", "list all checkpoints created with the 'checkpoint' command", invoke_info_checkpoints); -/*static*/ void GdbCommand::init_auto_args() { +/*static*/ void DebuggerExtensionCommand::init_auto_args() { checkpoint.add_auto_arg("rr-where"); } diff --git a/src/GdbCommand.h b/src/DebuggerExtensionCommand.h similarity index 79% rename from src/GdbCommand.h rename to src/DebuggerExtensionCommand.h index 198441becae..82308656666 100644 --- a/src/GdbCommand.h +++ b/src/DebuggerExtensionCommand.h @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ -#ifndef RR_GDB_COMMAND_H_ -#define RR_GDB_COMMAND_H_ +#ifndef RR_DEBUGGER_EXTENSION_COMMAND_H_ +#define RR_DEBUGGER_EXTENSION_COMMAND_H_ #include "DebuggerExtensionCommandHandler.h" #include "GdbServer.h" @@ -12,15 +12,15 @@ namespace rr { -class GdbCommand { +class DebuggerExtensionCommand { protected: - GdbCommand(const std::string& cmd_name, const std::string& documentation) + DebuggerExtensionCommand(const std::string& cmd_name, const std::string& documentation) : cmd_name(cmd_name), documentation(documentation) { DebuggerExtensionCommandHandler::register_command(*this); } public: - virtual ~GdbCommand() {} + virtual ~DebuggerExtensionCommand() {} const std::string& name() const { return cmd_name; } const std::string& docs() const { return documentation; } @@ -56,13 +56,13 @@ class GdbCommand { std::vector cmd_auto_args; }; -class SimpleGdbCommand : public GdbCommand { +class SimpleDebuggerExtensionCommand : public DebuggerExtensionCommand { public: - SimpleGdbCommand( + SimpleDebuggerExtensionCommand( const std::string& cmd_name, const std::string& documentation, const std::function&)>& invoker) - : GdbCommand(cmd_name, documentation), invoker(invoker) {} + : DebuggerExtensionCommand(cmd_name, documentation), invoker(invoker) {} virtual std::string invoke(GdbServer& gdb_server, Task* t, const std::vector& args) override { @@ -76,4 +76,4 @@ class SimpleGdbCommand : public GdbCommand { } // namespace rr -#endif +#endif /* RR_DEBUGGER_EXTENSION_COMMAND_H_ */ diff --git a/src/DebuggerExtensionCommandHandler.cc b/src/DebuggerExtensionCommandHandler.cc index 9dc915ea2db..45dcd48427e 100644 --- a/src/DebuggerExtensionCommandHandler.cc +++ b/src/DebuggerExtensionCommandHandler.cc @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ #include "DebuggerExtensionCommandHandler.h" -#include "GdbCommand.h" +#include "DebuggerExtensionCommand.h" #include "log.h" #include @@ -13,9 +13,9 @@ namespace rr { // HashMap would be better here but the unordered_map API is annoying // and linear search is fine. -static vector* gdb_command_list; +static vector* gdb_command_list; -static string gdb_macro_binding(const GdbCommand& cmd) { +static string gdb_macro_binding(const DebuggerExtensionCommand& cmd) { string auto_args_str = "["; for (size_t i = 0; i < cmd.auto_args().size(); i++) { if (i > 0) { @@ -32,7 +32,7 @@ static string gdb_macro_binding(const GdbCommand& cmd) { } /* static */ string DebuggerExtensionCommandHandler::gdb_macros() { - GdbCommand::init_auto_args(); + DebuggerExtensionCommand::init_auto_args(); stringstream ss; ss << string(R"Delimiter( @@ -186,7 +186,7 @@ end return ss.str(); } -/*static*/ GdbCommand* DebuggerExtensionCommandHandler::command_for_name(const string& name) { +/*static*/ DebuggerExtensionCommand* DebuggerExtensionCommandHandler::command_for_name(const string& name) { if (!gdb_command_list) { return nullptr; } @@ -198,10 +198,10 @@ end return nullptr; } -void DebuggerExtensionCommandHandler::register_command(GdbCommand& cmd) { +void DebuggerExtensionCommandHandler::register_command(DebuggerExtensionCommand& cmd) { LOG(debug) << "registering command: " << cmd.name(); if (!gdb_command_list) { - gdb_command_list = new vector(); + gdb_command_list = new vector(); } gdb_command_list->push_back(&cmd); } @@ -251,7 +251,7 @@ static string gdb_unescape(const string& str) { args.push_back(gdb_unescape(arg)); } - GdbCommand* cmd = command_for_name(rr_cmd.name); + DebuggerExtensionCommand* cmd = command_for_name(rr_cmd.name); if (!cmd) { return gdb_escape(string() + "Command '" + rr_cmd.name + "' not found.\n"); } diff --git a/src/DebuggerExtensionCommandHandler.h b/src/DebuggerExtensionCommandHandler.h index e4f400fe0d1..d4a539fa0d1 100644 --- a/src/DebuggerExtensionCommandHandler.h +++ b/src/DebuggerExtensionCommandHandler.h @@ -9,7 +9,7 @@ namespace rr { -class GdbCommand; +class DebuggerExtensionCommand; class GdbServer; class Task; @@ -23,7 +23,7 @@ class DebuggerExtensionCommandHandler { // wrapper code. static std::string gdb_macros(); - static void register_command(GdbCommand& cmd); + static void register_command(DebuggerExtensionCommand& cmd); /** * Process an incoming GDB payload of the following form: @@ -35,7 +35,7 @@ class DebuggerExtensionCommandHandler { static std::string process_command(GdbServer& gdb_server, Task* t, const GdbRequest::RRCmd& rr_cmd); - static GdbCommand* command_for_name(const std::string& name); + static DebuggerExtensionCommand* command_for_name(const std::string& name); /** * Special return value for commands that immediately end a diversion session diff --git a/src/GdbServer.h b/src/GdbServer.h index d1d0b7c3da2..d639c2787b0 100644 --- a/src/GdbServer.h +++ b/src/GdbServer.h @@ -23,7 +23,7 @@ namespace rr { class GdbServer { - // Not ideal but we can't inherit friend from GdbCommand + // Not ideal but we can't inherit friend from DebuggerExtensionCommand friend std::string invoke_checkpoint(GdbServer&, Task*, const std::vector&); friend std::string invoke_delete_checkpoint(GdbServer&, Task*,