summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/debugcon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/debug/debugcon.h')
-rw-r--r--src/emu/debug/debugcon.h93
1 files changed, 63 insertions, 30 deletions
diff --git a/src/emu/debug/debugcon.h b/src/emu/debug/debugcon.h
index 2d811523650..37b2e235348 100644
--- a/src/emu/debug/debugcon.h
+++ b/src/emu/debug/debugcon.h
@@ -16,24 +16,20 @@
#include "textbuf.h"
#include <functional>
+#include <set>
/***************************************************************************
CONSTANTS
***************************************************************************/
-#define MAX_COMMAND_LENGTH 4096
-#define MAX_COMMAND_PARAMS 128
+constexpr int MAX_COMMAND_PARAMS = 128;
// flags for command parsing
constexpr u32 CMDFLAG_NONE = 0x0000;
constexpr u32 CMDFLAG_KEEP_QUOTES = 0x0001;
constexpr u32 CMDFLAG_CUSTOM_HELP = 0x0002;
-/* parameter separator macros */
-#define CMDPARAM_SEPARATOR "\0"
-#define CMDPARAM_TERMINATOR "\0\0"
-
/***************************************************************************
@@ -71,7 +67,6 @@ public:
private:
u16 m_error_class, m_error_offset;
-
};
@@ -79,26 +74,27 @@ class debugger_console
{
public:
debugger_console(running_machine &machine);
+ ~debugger_console();
// command handling
- CMDERR execute_command(const std::string &command, bool echo);
- CMDERR validate_command(const char *command);
- void register_command(const char *command, u32 flags, int ref, int minparams, int maxparams, std::function<void(int, const std::vector<std::string> &)> handler);
+ CMDERR execute_command(std::string_view command, bool echo);
+ CMDERR validate_command(std::string_view command);
+ void register_command(std::string_view command, u32 flags, int minparams, int maxparams, std::function<void (const std::vector<std::string_view> &)> &&handler);
void source_script(const char *file);
void process_source_file();
// console management
- void vprintf(util::format_argument_pack<std::ostream> const &args);
- void vprintf(util::format_argument_pack<std::ostream> &&args);
- void vprintf_wrap(int wrapcol, util::format_argument_pack<std::ostream> const &args);
- void vprintf_wrap(int wrapcol, util::format_argument_pack<std::ostream> &&args);
+ void vprintf(util::format_argument_pack<char> const &args);
+ void vprintf(util::format_argument_pack<char> &&args);
+ void vprintf_wrap(int wrapcol, util::format_argument_pack<char> const &args);
+ void vprintf_wrap(int wrapcol, util::format_argument_pack<char> &&args);
text_buffer &get_console_textbuf() const { return *m_console_textbuf; }
- /* errorlog management */
+ // errorlog management
void errorlog_write_line(const char *line);
text_buffer &get_errorlog_textbuf() const { return *m_errorlog_textbuf; }
- /* convenience templates */
+ // convenience templates
template <typename Format, typename... Params>
inline void printf(Format &&fmt, Params &&...args)
{
@@ -110,35 +106,72 @@ public:
vprintf_wrap(wrapcol, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
}
- device_t *get_visible_cpu() { return m_visiblecpu; }
+ device_t *get_visible_cpu() const { return m_visiblecpu; }
void set_visible_cpu(device_t *visiblecpu) { m_visiblecpu = visiblecpu; }
- symbol_table &visible_symtable();
+ symbol_table &visible_symtable() const;
static std::string cmderr_to_string(CMDERR error);
+ // validates a parameter as a boolean value
+ bool validate_boolean_parameter(std::string_view param, bool &result);
+
+ // validates a parameter as a numeric value
+ bool validate_number_parameter(std::string_view param, u64 &result);
+
+ // validates a parameter as a device
+ bool validate_device_parameter(std::string_view param, device_t *&result);
+
+ // validates a parameter as a CPU
+ bool validate_cpu_parameter(std::string_view param, device_t *&result);
+
+ // validates a parameter as an address space identifier
+ bool validate_device_space_parameter(std::string_view param, int spacenum, address_space *&result);
+
+ // validates a parameter as a target address and retrieves the given address space and address
+ bool validate_target_address_parameter(std::string_view param, int spacenum, address_space *&space, u64 &addr);
+
+ // validates a parameter as a memory region name and retrieves the given region
+ bool validate_memory_region_parameter(std::string_view param, memory_region *&result);
+
+ // validates a parameter as a debugger expression
+ bool validate_expression_parameter(std::string_view param, parsed_expression &result);
+
+ // validates a parameter as a debugger command
+ bool validate_command_parameter(std::string_view param);
+
private:
void exit();
- void execute_help_custom(int ref, const std::vector<std::string> &params);
- void execute_condump(int ref, const std::vector<std::string>& params);
+ void execute_help_custom(const std::vector<std::string_view> &params);
+ void execute_condump(const std::vector<std::string_view>& params);
+
+ [[nodiscard]] static std::string_view trim_parameter(std::string_view param, bool keep_quotes);
+ CMDERR internal_execute_command(bool execute, std::vector<std::string_view> &params);
+ CMDERR internal_parse_command(std::string_view command, bool execute);
- void trim_parameter(char **paramptr, bool keep_quotes);
- CMDERR internal_execute_command(bool execute, int params, char **param);
- CMDERR internal_parse_command(const std::string &original_command, bool execute);
+ void print_core(std::string_view text); // core text output
+ void print_core_wrap(std::string_view text, int wrapcol); // core text output
- void print_core(const char *text); // core text output
- void print_core_wrap(const char *text, int wrapcol); // core text output
+ device_t &get_device_search_base(std::string_view &param) const;
+ device_t *get_cpu_by_index(u64 cpunum) const;
struct debug_command
{
- debug_command(const char *_command, u32 _flags, int _ref, int _minparams, int _maxparams, std::function<void(int, const std::vector<std::string> &)> _handler);
+ debug_command(std::string_view _command, u32 _flags, int _minparams, int _maxparams, std::function<void (const std::vector<std::string_view> &)> &&_handler);
+
+ struct compare
+ {
+ using is_transparent = void;
+ bool operator()(const debug_command &a, const debug_command &b) const;
+ bool operator()(const char *a, const debug_command &b) const;
+ bool operator()(const debug_command &a, const char *b) const;
+ };
- char command[32];
+ std::string command;
const char * params;
const char * help;
- std::function<void(int, const std::vector<std::string> &)> handler;
+ std::function<void (const std::vector<std::string_view> &)> handler;
u32 flags;
- int ref;
int minparams;
int maxparams;
};
@@ -151,7 +184,7 @@ private:
text_buffer_ptr m_console_textbuf;
text_buffer_ptr m_errorlog_textbuf;
- std::forward_list<debug_command> m_commandlist;
+ std::set<debug_command, debug_command::compare> m_commandlist;
std::unique_ptr<std::istream> m_source_file; // script source file
std::unique_ptr<emu_file> m_logfile; // logfile for debug console output