diff --git a/src/commands.cc b/src/commands.cc index aafad24f..17941932 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1392,7 +1392,7 @@ const CommandDesc debug_cmd = { [](const Context& context, CompletionFlags flags, const String& prefix, ByteCount cursor_pos) -> Completions { auto c = {"info", "buffers", "options", "memory", "shared-strings", - "profile-hash-maps", "faces", "mappings", "regex"}; + "profile-hash-maps", "faces", "mappings", "regex", "registers"}; return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) }; }), [](const ParametersParser& parser, Context& context, const ShellContext&) @@ -1485,6 +1485,20 @@ const CommandDesc debug_cmd = { write_to_debug_buffer(format(" * {}:\n{}", parser[1], dump_regex(compile_regex(parser[1], RegexCompileFlags::Optimize)))); } + else if (parser[0] == "registers") + { + write_to_debug_buffer("Register info:"); + for (auto&& [name, reg] : RegisterManager::instance()) + { + auto content = reg->get(context); + + if (content.size() == 1 and content[0] == "") + continue; + + write_to_debug_buffer(format(" * {} = {}\n", name, + join(content | transform(quote), "\n = "))); + } + } else throw runtime_error(format("no such debug command: '{}'", parser[0])); } diff --git a/src/register_manager.hh b/src/register_manager.hh index 75daf1ab..1fe8680b 100644 --- a/src/register_manager.hh +++ b/src/register_manager.hh @@ -124,6 +124,9 @@ public: void add_register(Codepoint c, std::unique_ptr reg); CandidateList complete_register_name(StringView prefix, ByteCount cursor_pos) const; + auto begin() const { return m_registers.begin(); } + auto end() const { return m_registers.end(); } + protected: HashMap, MemoryDomain::Registers> m_registers; };