summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/debugcon.h
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-06-08 08:10:55 +1000
committer Vas Crabb <vas@vastheman.com>2016-06-08 08:10:55 +1000
commit56bd36c5ef3960874628bc08cbfcedf4c6057a19 (patch)
tree3cce04b8c27b773befde51785210bc83673f9fd0 /src/emu/debug/debugcon.h
parentbf281b3cad1d05c6ef863fa179d3d6ab442a163c (diff)
Major refactoring of debugger core [Ryan Holtz]
* Eliminate globals/file statics * Remove lots of stuff from global scope * Use std::function for custom command registration * Eliminate some trampolines * Build fixes from Vas Crabb and balr0g
Diffstat (limited to 'src/emu/debug/debugcon.h')
-rw-r--r--src/emu/debug/debugcon.h100
1 files changed, 63 insertions, 37 deletions
diff --git a/src/emu/debug/debugcon.h b/src/emu/debug/debugcon.h
index 95aa2e0f8c8..5e04d349454 100644
--- a/src/emu/debug/debugcon.h
+++ b/src/emu/debug/debugcon.h
@@ -11,10 +11,11 @@
#ifndef __DEBUGCON_H__
#define __DEBUGCON_H__
+#include <functional>
+
#include "emu.h"
#include "textbuf.h"
-
/***************************************************************************
CONSTANTS
***************************************************************************/
@@ -68,42 +69,67 @@
/* CMDERR is an error code for command evaluation */
typedef UINT32 CMDERR;
-
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-/* initialization */
-void debug_console_init(running_machine &machine);
-
-/* command handling */
-CMDERR debug_console_execute_command(running_machine &machine, const char *command, int echo);
-CMDERR debug_console_validate_command(running_machine &machine, const char *command);
-void debug_console_register_command(running_machine &machine, const char *command, UINT32 flags, int ref, int minparams, int maxparams, void (*handler)(running_machine &machine, int ref, int params, const char **param));
-const char * debug_cmderr_to_string(CMDERR error);
-
-/* console management */
-void debug_console_vprintf(running_machine &machine, util::format_argument_pack<std::ostream> const &args);
-void debug_console_vprintf(running_machine &machine, util::format_argument_pack<std::ostream> &&args);
-void debug_console_vprintf_wrap(running_machine &machine, int wrapcol, util::format_argument_pack<std::ostream> const &args);
-void debug_console_vprintf_wrap(running_machine &machine, int wrapcol, util::format_argument_pack<std::ostream> &&args);
-text_buffer * debug_console_get_textbuf(void);
-
-/* errorlog management */
-void debug_errorlog_write_line(const running_machine &machine, const char *line);
-text_buffer * debug_errorlog_get_textbuf(void);
-
-/* convenience templates */
-template <typename Format, typename... Params>
-inline void debug_console_printf(running_machine &machine, Format &&fmt, Params &&...args)
-{
- debug_console_vprintf(machine, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
-}
-template <typename Format, typename... Params>
-inline void debug_console_printf_wrap(running_machine &machine, int wrapcol, Format &&fmt, Params &&...args)
+class debugger_console
{
- debug_console_vprintf_wrap(machine, wrapcol, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
-}
+public:
+ debugger_console(running_machine &machine);
+
+ /* command handling */
+ CMDERR execute_command(const char *command, bool echo);
+ CMDERR validate_command(const char *command);
+ void register_command(const char *command, UINT32 flags, int ref, int minparams, int maxparams, std::function<void(int, int, const char **)> handler);
+
+ /* 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);
+ text_buffer * get_console_textbuf() const { return m_console_textbuf; }
+
+ /* errorlog management */
+ void errorlog_write_line(const char *line);
+ text_buffer * get_errorlog_textbuf() const { return m_errorlog_textbuf; }
+
+ /* convenience templates */
+ template <typename Format, typename... Params>
+ inline void printf(Format &&fmt, Params &&...args)
+ {
+ vprintf(util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
+ }
+ template <typename Format, typename... Params>
+ inline void printf_wrap(int wrapcol, Format &&fmt, Params &&...args)
+ {
+ vprintf_wrap(wrapcol, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
+ }
+
+ static const char * cmderr_to_string(CMDERR error);
+
+private:
+ void exit();
+
+ void trim_parameter(char **paramptr, bool keep_quotes);
+ CMDERR internal_execute_command(bool execute, int params, char **param);
+ CMDERR internal_parse_command(const char *original_command, bool execute);
+
+ struct debug_command
+ {
+ debug_command * next;
+ char command[32];
+ const char * params;
+ const char * help;
+ std::function<void(int, int, const char **)> handler;
+ UINT32 flags;
+ int ref;
+ int minparams;
+ int maxparams;
+ };
+
+ running_machine &m_machine;
+
+ text_buffer *m_console_textbuf;
+ text_buffer *m_errorlog_textbuf;
+
+ debug_command *m_commandlist;
+};
#endif