From 9d0076ab91bfc3fd2514b9f0d612b4049b5bbaf7 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 2 Aug 2022 08:21:53 -0400 Subject: Change debugger command handler parameter vector element type from std::string to std::string_view --- src/devices/cpu/arm7/arm7.cpp | 6 +- src/devices/cpu/arm7/arm7.h | 6 +- src/devices/machine/acorn_memc.cpp | 2 +- src/devices/machine/acorn_memc.h | 2 +- src/devices/machine/sun4c_mmu.cpp | 2 +- src/devices/machine/sun4c_mmu.h | 2 +- src/emu/debug/debugcmd.cpp | 331 +++++++++++++++++++------------------ src/emu/debug/debugcmd.h | 166 +++++++++---------- src/emu/debug/debugcon.cpp | 15 +- src/emu/debug/debugcon.h | 10 +- src/emu/natkeyboard.cpp | 8 +- src/emu/natkeyboard.h | 5 +- src/lib/util/corestr.cpp | 38 ++++- src/lib/util/corestr.h | 3 + src/mame/konami/konamim2.cpp | 12 +- src/mame/midway/midtunit_v.cpp | 8 +- src/mame/midway/midtunit_v.h | 8 +- src/mame/rm/rmnimbus.h | 4 +- src/mame/rm/rmnimbus_m.cpp | 8 +- src/mame/rm/rmnimbus_v.cpp | 8 +- src/mame/sega/chihiro.cpp | 12 +- src/mame/sega/model2.h | 8 +- src/mame/sega/model2_m.cpp | 18 +- src/mame/shared/xbox.cpp | 40 ++--- src/mame/shared/xbox.h | 34 ++-- src/mame/sun/sun4.cpp | 6 +- src/mame/trs/dgn_beta.h | 4 +- src/mame/trs/dgn_beta_m.cpp | 4 +- 28 files changed, 414 insertions(+), 356 deletions(-) diff --git a/src/devices/cpu/arm7/arm7.cpp b/src/devices/cpu/arm7/arm7.cpp index 7a67c2f5a30..45f2a6eb67a 100644 --- a/src/devices/cpu/arm7/arm7.cpp +++ b/src/devices/cpu/arm7/arm7.cpp @@ -862,17 +862,17 @@ bool arm7_cpu_device::translate_vaddr_to_paddr(offs_t &vaddr, const int flags) } } -void arm7_cpu_device::translate_insn_command(const std::vector ¶ms) +void arm7_cpu_device::translate_insn_command(const std::vector ¶ms) { translate_command(params, TRANSLATE_FETCH); } -void arm7_cpu_device::translate_data_command(const std::vector ¶ms) +void arm7_cpu_device::translate_data_command(const std::vector ¶ms) { translate_command(params, TRANSLATE_READ); } -void arm7_cpu_device::translate_command(const std::vector ¶ms, int intention) +void arm7_cpu_device::translate_command(const std::vector ¶ms, int intention) { uint64_t vaddr; diff --git a/src/devices/cpu/arm7/arm7.h b/src/devices/cpu/arm7/arm7.h index bb46ef980df..c46516508db 100644 --- a/src/devices/cpu/arm7/arm7.h +++ b/src/devices/cpu/arm7/arm7.h @@ -146,9 +146,9 @@ protected: uint32_t m_r[/*NUM_REGS*/37]; - void translate_insn_command(const std::vector ¶ms); - void translate_data_command(const std::vector ¶ms); - void translate_command(const std::vector ¶ms, int intention); + void translate_insn_command(const std::vector ¶ms); + void translate_data_command(const std::vector ¶ms); + void translate_command(const std::vector ¶ms, int intention); void update_insn_prefetch(uint32_t curr_pc); bool insn_fetch_thumb(uint32_t pc, uint32_t &out_insn); diff --git a/src/devices/machine/acorn_memc.cpp b/src/devices/machine/acorn_memc.cpp index 1b8fc70544a..5b05df7254f 100644 --- a/src/devices/machine/acorn_memc.cpp +++ b/src/devices/machine/acorn_memc.cpp @@ -51,7 +51,7 @@ device_memory_interface::space_config_vector acorn_memc_device::memory_space_con }; } -void acorn_memc_device::memc_map_debug_commands(const std::vector ¶ms) +void acorn_memc_device::memc_map_debug_commands(const std::vector ¶ms) { uint64_t offset; if (params.size() != 1 || !machine().debugger().commands().validate_number_parameter(params[0], offset)) diff --git a/src/devices/machine/acorn_memc.h b/src/devices/machine/acorn_memc.h index 930e7477b19..9664e07d7f0 100644 --- a/src/devices/machine/acorn_memc.h +++ b/src/devices/machine/acorn_memc.h @@ -60,7 +60,7 @@ protected: virtual space_config_vector memory_space_config() const override; private: - void memc_map_debug_commands(const std::vector ¶ms); + void memc_map_debug_commands(const std::vector ¶ms); uint32_t dram_address(uint32_t address); bool is_valid_access(int page, bool write); uint32_t invalid_access(bool is_write, offs_t offset, uint32_t data, uint32_t mem_mask = ~0); diff --git a/src/devices/machine/sun4c_mmu.cpp b/src/devices/machine/sun4c_mmu.cpp index 16b63c17dc1..f5dfe643f4f 100644 --- a/src/devices/machine/sun4c_mmu.cpp +++ b/src/devices/machine/sun4c_mmu.cpp @@ -982,7 +982,7 @@ bool sun4_mmu_base_device::translate(uint32_t &addr) return entry.valid; } -void sun4_mmu_base_device::l2p_command(const std::vector ¶ms) +void sun4_mmu_base_device::l2p_command(const std::vector ¶ms) { uint64_t addr, offset; diff --git a/src/devices/machine/sun4c_mmu.h b/src/devices/machine/sun4c_mmu.h index 48f8517f33b..bd9b1201fbf 100644 --- a/src/devices/machine/sun4c_mmu.h +++ b/src/devices/machine/sun4c_mmu.h @@ -137,7 +137,7 @@ protected: void type0_timeout_r(const uint32_t offset); void type0_timeout_w(const uint32_t offset); bool translate(uint32_t &addr); - void l2p_command(const std::vector ¶ms); + void l2p_command(const std::vector ¶ms); uint32_t vaddr_to_cache_line(uint32_t vaddr); enum diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 781ce93e9a5..064f102299c 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -464,15 +464,15 @@ void debugger_commands::global_set(global_entry *global, u64 value) /// the parameter is an empty string. /// \return true if the parameter is a valid Boolean value or an empty /// string, or false otherwise. -bool debugger_commands::validate_boolean_parameter(const std::string ¶m, bool &result) +bool debugger_commands::validate_boolean_parameter(std::string_view param, bool &result) { // nullptr parameter does nothing and returns no error if (param.empty()) return true; // evaluate the expression; success if no error - bool const is_true = !core_stricmp(param.c_str(), "true"); - bool const is_false = !core_stricmp(param.c_str(), "false"); + bool const is_true = util::streqlower(param, "true"); + bool const is_false = util::streqlower(param, "false"); if (is_true || is_false) { @@ -895,12 +895,8 @@ bool debugger_commands::debug_command_parameter_expression(std::string_view para command parameter -------------------------------------------------*/ -bool debugger_commands::debug_command_parameter_command(const char *param) +bool debugger_commands::debug_command_parameter_command(std::string_view param) { - /* nullptr parameter does nothing and returns no error */ - if (param == nullptr) - return true; - /* validate the comment; success if no error */ CMDERR err = m_console.validate_command(param); if (err.error_class() == CMDERR::NONE) @@ -917,7 +913,7 @@ bool debugger_commands::debug_command_parameter_command(const char *param) execute_help - execute the help command -------------------------------------------------*/ -void debugger_commands::execute_help(const std::vector ¶ms) +void debugger_commands::execute_help(const std::vector ¶ms) { if (params.size() == 0) m_console.printf_wrap(80, "%s\n", debug_get_help(std::string_view())); @@ -930,7 +926,7 @@ void debugger_commands::execute_help(const std::vector ¶ms) execute_print - execute the print command -------------------------------------------------*/ -void debugger_commands::execute_print(const std::vector ¶ms) +void debugger_commands::execute_print(const std::vector ¶ms) { /* validate the other parameters */ u64 values[MAX_COMMAND_PARAMS]; @@ -1079,7 +1075,7 @@ bool debugger_commands::mini_printf(std::ostream &stream, std::string_view forma -------------------------------------------------*/ template -void debugger_commands::execute_index_command(std::vector const ¶ms, T &&apply, char const *unused_message) +void debugger_commands::execute_index_command(std::vector const ¶ms, T &&apply, char const *unused_message) { std::vector index(params.size()); for (int paramnum = 0; paramnum < params.size(); paramnum++) @@ -1108,7 +1104,7 @@ void debugger_commands::execute_index_command(std::vector const &pa execute_printf - execute the printf command -------------------------------------------------*/ -void debugger_commands::execute_printf(const std::vector ¶ms) +void debugger_commands::execute_printf(const std::vector ¶ms) { /* validate the other parameters */ u64 values[MAX_COMMAND_PARAMS]; @@ -1127,7 +1123,7 @@ void debugger_commands::execute_printf(const std::vector ¶ms) execute_logerror - execute the logerror command -------------------------------------------------*/ -void debugger_commands::execute_logerror(const std::vector ¶ms) +void debugger_commands::execute_logerror(const std::vector ¶ms) { /* validate the other parameters */ u64 values[MAX_COMMAND_PARAMS]; @@ -1146,7 +1142,7 @@ void debugger_commands::execute_logerror(const std::vector ¶ms) execute_tracelog - execute the tracelog command -------------------------------------------------*/ -void debugger_commands::execute_tracelog(const std::vector ¶ms) +void debugger_commands::execute_tracelog(const std::vector ¶ms) { /* validate the other parameters */ u64 values[MAX_COMMAND_PARAMS]; @@ -1165,7 +1161,7 @@ void debugger_commands::execute_tracelog(const std::vector ¶ms) execute_tracesym - execute the tracesym command -------------------------------------------------*/ -void debugger_commands::execute_tracesym(const std::vector ¶ms) +void debugger_commands::execute_tracesym(const std::vector ¶ms) { // build a format string appropriate for the parameters and validate them std::stringstream format; @@ -1201,7 +1197,7 @@ void debugger_commands::execute_tracesym(const std::vector ¶ms) execute_cls - execute the cls command -------------------------------------------------*/ -void debugger_commands::execute_cls(const std::vector ¶ms) +void debugger_commands::execute_cls(const std::vector ¶ms) { text_buffer_clear(m_console.get_console_textbuf()); } @@ -1211,7 +1207,7 @@ void debugger_commands::execute_cls(const std::vector ¶ms) execute_quit - execute the quit command -------------------------------------------------*/ -void debugger_commands::execute_quit(const std::vector ¶ms) +void debugger_commands::execute_quit(const std::vector ¶ms) { osd_printf_warning("Exited via the debugger\n"); m_machine.schedule_exit(); @@ -1222,7 +1218,7 @@ void debugger_commands::execute_quit(const std::vector ¶ms) execute_do - execute the do command -------------------------------------------------*/ -void debugger_commands::execute_do(const std::vector ¶ms) +void debugger_commands::execute_do(const std::vector ¶ms) { u64 dummy; validate_number_parameter(params[0], dummy); @@ -1233,7 +1229,7 @@ void debugger_commands::execute_do(const std::vector ¶ms) execute_step - execute the step command -------------------------------------------------*/ -void debugger_commands::execute_step(const std::vector ¶ms) +void debugger_commands::execute_step(const std::vector ¶ms) { /* if we have a parameter, use it */ u64 steps = 1; @@ -1248,7 +1244,7 @@ void debugger_commands::execute_step(const std::vector ¶ms) execute_over - execute the over command -------------------------------------------------*/ -void debugger_commands::execute_over(const std::vector ¶ms) +void debugger_commands::execute_over(const std::vector ¶ms) { /* if we have a parameter, use it */ u64 steps = 1; @@ -1263,7 +1259,7 @@ void debugger_commands::execute_over(const std::vector ¶ms) execute_out - execute the out command -------------------------------------------------*/ -void debugger_commands::execute_out(const std::vector ¶ms) +void debugger_commands::execute_out(const std::vector ¶ms) { m_console.get_visible_cpu()->debug()->single_step_out(); } @@ -1273,7 +1269,7 @@ void debugger_commands::execute_out(const std::vector ¶ms) execute_go - execute the go command -------------------------------------------------*/ -void debugger_commands::execute_go(const std::vector ¶ms) +void debugger_commands::execute_go(const std::vector ¶ms) { u64 addr = ~0; @@ -1290,7 +1286,7 @@ void debugger_commands::execute_go(const std::vector ¶ms) command -------------------------------------------------*/ -void debugger_commands::execute_go_vblank(const std::vector ¶ms) +void debugger_commands::execute_go_vblank(const std::vector ¶ms) { m_console.get_visible_cpu()->debug()->go_vblank(); } @@ -1300,7 +1296,7 @@ void debugger_commands::execute_go_vblank(const std::vector ¶ms execute_go_interrupt - execute the goint command -------------------------------------------------*/ -void debugger_commands::execute_go_interrupt(const std::vector ¶ms) +void debugger_commands::execute_go_interrupt(const std::vector ¶ms) { u64 irqline = -1; @@ -1315,7 +1311,7 @@ void debugger_commands::execute_go_interrupt(const std::vector &par execute_go_exception - execute the goex command -------------------------------------------------*/ -void debugger_commands::execute_go_exception(const std::vector ¶ms) +void debugger_commands::execute_go_exception(const std::vector ¶ms) { u64 exception = -1; @@ -1335,7 +1331,7 @@ void debugger_commands::execute_go_exception(const std::vector &par execute_go_time - execute the gtime command -------------------------------------------------*/ -void debugger_commands::execute_go_time(const std::vector ¶ms) +void debugger_commands::execute_go_time(const std::vector ¶ms) { u64 milliseconds = -1; @@ -1351,7 +1347,7 @@ void debugger_commands::execute_go_time(const std::vector ¶ms) /*------------------------------------------------- execute_go_privilege - execute the gp command -------------------------------------------------*/ -void debugger_commands::execute_go_privilege(const std::vector ¶ms) +void debugger_commands::execute_go_privilege(const std::vector ¶ms) { parsed_expression condition(m_console.visible_symtable()); if (params.size() > 0 && !debug_command_parameter_expression(params[0], condition)) @@ -1365,7 +1361,7 @@ void debugger_commands::execute_go_privilege(const std::vector &par execute_go_branch - execute gbt or gbf command -------------------------------------------------*/ -void debugger_commands::execute_go_branch(bool sense, const std::vector ¶ms) +void debugger_commands::execute_go_branch(bool sense, const std::vector ¶ms) { parsed_expression condition(m_console.visible_symtable()); if (params.size() > 0 && !debug_command_parameter_expression(params[0], condition)) @@ -1379,7 +1375,7 @@ void debugger_commands::execute_go_branch(bool sense, const std::vector ¶ms) +void debugger_commands::execute_go_next_instruction(const std::vector ¶ms) { u64 count = 1; static constexpr u64 MAX_COUNT = 512; @@ -1420,7 +1416,7 @@ void debugger_commands::execute_go_next_instruction(const std::vector ¶ms) +void debugger_commands::execute_next(const std::vector ¶ms) { m_console.get_visible_cpu()->debug()->go_next_device(); } @@ -1430,7 +1426,7 @@ void debugger_commands::execute_next(const std::vector ¶ms) execute_focus - execute the focus command -------------------------------------------------*/ -void debugger_commands::execute_focus(const std::vector ¶ms) +void debugger_commands::execute_focus(const std::vector ¶ms) { // validate params device_t *cpu; @@ -1452,7 +1448,7 @@ void debugger_commands::execute_focus(const std::vector ¶ms) execute_ignore - execute the ignore command -------------------------------------------------*/ -void debugger_commands::execute_ignore(const std::vector ¶ms) +void debugger_commands::execute_ignore(const std::vector ¶ms) { if (params.empty()) { @@ -1515,7 +1511,7 @@ void debugger_commands::execute_ignore(const std::vector ¶ms) execute_observe - execute the observe command -------------------------------------------------*/ -void debugger_commands::execute_observe(const std::vector ¶ms) +void debugger_commands::execute_observe(const std::vector ¶ms) { if (params.empty()) { @@ -1563,7 +1559,7 @@ void debugger_commands::execute_observe(const std::vector ¶ms) execute_suspend - suspend execution on cpu -------------------------------------------------*/ -void debugger_commands::execute_suspend(const std::vector ¶ms) +void debugger_commands::execute_suspend(const std::vector ¶ms) { // if there are no parameters, dump the ignore list if (params.empty()) @@ -1622,7 +1618,7 @@ void debugger_commands::execute_suspend(const std::vector ¶ms) execute_resume - Resume execution on CPU -------------------------------------------------*/ -void debugger_commands::execute_resume(const std::vector ¶ms) +void debugger_commands::execute_resume(const std::vector ¶ms) { // if there are no parameters, dump the ignore list if (params.empty()) @@ -1667,7 +1663,7 @@ void debugger_commands::execute_resume(const std::vector ¶ms) // execute_cpulist - list all CPUs //------------------------------------------------- -void debugger_commands::execute_cpulist(const std::vector ¶ms) +void debugger_commands::execute_cpulist(const std::vector ¶ms) { int index = 0; for (device_execute_interface &exec : execute_interface_enumerator(m_machine.root_device())) @@ -1682,7 +1678,7 @@ void debugger_commands::execute_cpulist(const std::vector ¶ms) // execute_time - execute the time command //------------------------------------------------- -void debugger_commands::execute_time(const std::vector ¶ms) +void debugger_commands::execute_time(const std::vector ¶ms) { m_console.printf("%s\n", m_machine.time().as_string()); } @@ -1691,7 +1687,7 @@ void debugger_commands::execute_time(const std::vector ¶ms) execute_comment - add a comment to a line -------------------------------------------------*/ -void debugger_commands::execute_comment_add(const std::vector ¶ms) +void debugger_commands::execute_comment_add(const std::vector ¶ms) { // param 1 is the address for the comment u64 address; @@ -1711,7 +1707,8 @@ void debugger_commands::execute_comment_add(const std::vector ¶ } // Now try adding the comment - cpu->debug()->comment_add(address, params[1].c_str(), 0x00ff0000); + std::string text(params[1]); + cpu->debug()->comment_add(address, text.c_str(), 0x00ff0000); cpu->machine().debug_view().update_all(DVT_DISASSEMBLY); } @@ -1720,7 +1717,7 @@ void debugger_commands::execute_comment_add(const std::vector ¶ execute_comment_del - remove a comment from an addr --------------------------------------------------------*/ -void debugger_commands::execute_comment_del(const std::vector ¶ms) +void debugger_commands::execute_comment_del(const std::vector ¶ms) { // param 1 can either be a command or the address for the comment u64 address; @@ -1739,25 +1736,25 @@ void debugger_commands::execute_comment_del(const std::vector ¶ } /** - * @fn void execute_comment_list(const std::vector ¶ms) + * @fn void execute_comment_list(const std::vector ¶ms) * @brief Print current list of comments in debugger * * */ -void debugger_commands::execute_comment_list(const std::vector ¶ms) +void debugger_commands::execute_comment_list(const std::vector ¶ms) { if (!m_machine.debugger().cpu().comment_load(false)) m_console.printf("Error while parsing XML file\n"); } /** - * @fn void execute_comment_commit(const std::vector ¶ms) + * @fn void execute_comment_commit(const std::vector ¶ms) * @brief Add and Save current list of comments in debugger * */ -void debugger_commands::execute_comment_commit(const std::vector ¶ms) +void debugger_commands::execute_comment_commit(const std::vector ¶ms) { execute_comment_add(params); execute_comment_save(params); @@ -1767,7 +1764,7 @@ void debugger_commands::execute_comment_commit(const std::vector &p execute_comment - add a comment to a line -------------------------------------------------*/ -void debugger_commands::execute_comment_save(const std::vector ¶ms) +void debugger_commands::execute_comment_save(const std::vector ¶ms) { if (m_machine.debugger().cpu().comment_save()) m_console.printf("Comment successfully saved\n"); @@ -1777,7 +1774,7 @@ void debugger_commands::execute_comment_save(const std::vector &par // TODO: add color hex editing capabilities for comments, see below for more info /** - * @fn void execute_comment_color(const std::vector ¶ms) + * @fn void execute_comment_color(const std::vector ¶ms) * @brief Modifies comment given at address $xx with given color * Useful for marking comment with a different color scheme (for example by marking start and end of a given function visually). * @param[in] "address,color" First is the comment address in the current context, color can be hexadecimal or shorthanded to common 1bpp RGB names. @@ -1794,7 +1791,7 @@ void debugger_commands::execute_comment_save(const std::vector &par command -------------------------------------------------*/ -void debugger_commands::execute_bpset(const std::vector ¶ms) +void debugger_commands::execute_bpset(const std::vector ¶ms) { // param 1 is the address/CPU u64 address; @@ -1822,12 +1819,12 @@ void debugger_commands::execute_bpset(const std::vector ¶ms) return; // param 3 is the action - const char *action = nullptr; - if (params.size() > 2 && !debug_command_parameter_command(action = params[2].c_str())) + std::string action; + if (params.size() > 2 && !debug_command_parameter_command(action = params[2])) return; // set the breakpoint - int const bpnum = debug->breakpoint_set(address, condition.is_empty() ? nullptr : condition.original_string(), action); + int const bpnum = debug->breakpoint_set(address, condition.is_empty() ? nullptr : condition.original_string(), action.c_str()); m_console.printf("Breakpoint %X set\n", bpnum); } @@ -1837,7 +1834,7 @@ void debugger_commands::execute_bpset(const std::vector ¶ms) clear command -------------------------------------------------*/ -void debugger_commands::execute_bpclear(const std::vector ¶ms) +void debugger_commands::execute_bpclear(const std::vector ¶ms) { if (params.empty()) // if no parameters, clear all { @@ -1866,7 +1863,7 @@ void debugger_commands::execute_bpclear(const std::vector ¶ms) disable/enable commands -------------------------------------------------*/ -void debugger_commands::execute_bpdisenable(bool enable, const std::vector ¶ms) +void debugger_commands::execute_bpdisenable(bool enable, const std::vector ¶ms) { if (params.empty()) // if no parameters, disable/enable all { @@ -1895,7 +1892,7 @@ void debugger_commands::execute_bpdisenable(bool enable, const std::vector ¶ms) +void debugger_commands::execute_bplist(const std::vector ¶ms) { int printed = 0; std::string buffer; @@ -1946,7 +1943,7 @@ void debugger_commands::execute_bplist(const std::vector ¶ms) command -------------------------------------------------*/ -void debugger_commands::execute_wpset(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_wpset(int spacenum, const std::vector ¶ms) { u64 address, length; address_space *space; @@ -1969,11 +1966,11 @@ void debugger_commands::execute_wpset(int spacenum, const std::vector 4 && !debug_command_parameter_command(action = params[4].c_str())) + std::string action; + if (params.size() > 4 && !debug_command_parameter_command(action = params[4])) return; // set the watchpoint - int const wpnum = debug->watchpoint_set(*space, type, address, length, (condition.is_empty()) ? nullptr : condition.original_string(), action); + int const wpnum = debug->watchpoint_set(*space, type, address, length, (condition.is_empty()) ? nullptr : condition.original_string(), action.c_str()); m_console.printf("Watchpoint %X set\n", wpnum); } @@ -2002,7 +1999,7 @@ void debugger_commands::execute_wpset(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_wpclear(const std::vector ¶ms) { if (params.empty()) // if no parameters, clear all { @@ -2031,7 +2028,7 @@ void debugger_commands::execute_wpclear(const std::vector ¶ms) disable/enable commands -------------------------------------------------*/ -void debugger_commands::execute_wpdisenable(bool enable, const std::vector ¶ms) +void debugger_commands::execute_wpdisenable(bool enable, const std::vector ¶ms) { if (params.empty()) // if no parameters, disable/enable all { @@ -2060,7 +2057,7 @@ void debugger_commands::execute_wpdisenable(bool enable, const std::vector ¶ms) +void debugger_commands::execute_wplist(const std::vector ¶ms) { int printed = 0; std::string buffer; @@ -2123,7 +2120,7 @@ void debugger_commands::execute_wplist(const std::vector ¶ms) command -------------------------------------------------*/ -void debugger_commands::execute_rpset(const std::vector ¶ms) +void debugger_commands::execute_rpset(const std::vector ¶ms) { // CPU is implicit device_t *cpu; @@ -2136,12 +2133,12 @@ void debugger_commands::execute_rpset(const std::vector ¶ms) return; // param 2 is the action - const char *action = nullptr; - if (params.size() > 1 && !debug_command_parameter_command(action = params[1].c_str())) + std::string action; + if (params.size() > 1 && !debug_command_parameter_command(action = params[1])) return; // set the registerpoint - int const rpnum = cpu->debug()->registerpoint_set(condition.original_string(), action); + int const rpnum = cpu->debug()->registerpoint_set(condition.original_string(), action.c_str()); m_console.printf("Registerpoint %X set\n", rpnum); } @@ -2151,7 +2148,7 @@ void debugger_commands::execute_rpset(const std::vector ¶ms) clear command -------------------------------------------------*/ -void debugger_commands::execute_rpclear(const std::vector ¶ms) +void debugger_commands::execute_rpclear(const std::vector ¶ms) { if (params.empty()) // if no parameters, clear all { @@ -2180,7 +2177,7 @@ void debugger_commands::execute_rpclear(const std::vector ¶ms) disable/enable commands -------------------------------------------------*/ -void debugger_commands::execute_rpdisenable(bool enable, const std::vector ¶ms) +void debugger_commands::execute_rpdisenable(bool enable, const std::vector ¶ms) { if (params.empty()) // if no parameters, disable/enable all { @@ -2209,7 +2206,7 @@ void debugger_commands::execute_rpdisenable(bool enable, const std::vector ¶ms) +void debugger_commands::execute_rplist(const std::vector ¶ms) { int printed = 0; std::string buffer; @@ -2256,7 +2253,7 @@ void debugger_commands::execute_rplist(const std::vector ¶ms) execute_statesave - execute the statesave command -------------------------------------------------*/ -void debugger_commands::execute_statesave(const std::vector ¶ms) +void debugger_commands::execute_statesave(const std::vector ¶ms) { m_machine.immediate_save(params[0]); m_console.printf("State save attempted. Please refer to window message popup for results.\n"); @@ -2267,7 +2264,7 @@ void debugger_commands::execute_statesave(const std::vector ¶ms execute_stateload - execute the stateload command -------------------------------------------------*/ -void debugger_commands::execute_stateload(const std::vector ¶ms) +void debugger_commands::execute_stateload(const std::vector ¶ms) { m_machine.immediate_load(params[0]); @@ -2285,7 +2282,7 @@ void debugger_commands::execute_stateload(const std::vector ¶ms execute_rewind - execute the rewind command -------------------------------------------------*/ -void debugger_commands::execute_rewind(const std::vector ¶ms) +void debugger_commands::execute_rewind(const std::vector ¶ms) { bool success = m_machine.rewind_step(); if (success) @@ -2304,7 +2301,7 @@ void debugger_commands::execute_rewind(const std::vector ¶ms) execute_save - execute the save command -------------------------------------------------*/ -void debugger_commands::execute_save(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_save(int spacenum, const std::vector ¶ms) { u64 offset, endoffset, length; address_space *space; @@ -2321,7 +2318,8 @@ void debugger_commands::execute_save(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_saveregion(const std::vector ¶ms) { u64 offset, length; memory_region *region; @@ -2413,7 +2411,8 @@ void debugger_commands::execute_saveregion(const std::vector ¶m length = region->bytes() - offset; /* open the file */ - FILE *f = fopen(params[0].c_str(), "wb"); + std::string filename(params[0]); + FILE *f = fopen(filename.c_str(), "wb"); if (!f) { m_console.printf("Error opening file '%s'\n", params[0]); @@ -2430,7 +2429,7 @@ void debugger_commands::execute_saveregion(const std::vector ¶m execute_load - execute the load command -------------------------------------------------*/ -void debugger_commands::execute_load(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_load(int spacenum, const std::vector ¶ms) { u64 offset, endoffset, length = 0; address_space *space; @@ -2443,7 +2442,8 @@ void debugger_commands::execute_load(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_loadregion(const std::vector ¶ms) { u64 offset, length; memory_region *region; @@ -2560,7 +2560,8 @@ void debugger_commands::execute_loadregion(const std::vector ¶m length = region->bytes() - offset; // open the file - FILE *const f = fopen(params[0].c_str(), "rb"); + std::string filename(params[0]); + FILE *const f = fopen(filename.c_str(), "rb"); if (!f) { m_console.printf("Error opening file '%s'\n", params[0]); @@ -2586,7 +2587,7 @@ void debugger_commands::execute_loadregion(const std::vector ¶m execute_dump - execute the dump command -------------------------------------------------*/ -void debugger_commands::execute_dump(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_dump(int spacenum, const std::vector ¶ms) { // validate parameters address_space *space; @@ -2638,7 +2639,8 @@ void debugger_commands::execute_dump(int spacenum, const std::vectoraddrmask(); // open the file - FILE *const f = fopen(params[0].c_str(), "w"); + std::string filename(params[0]); + FILE *const f = fopen(filename.c_str(), "w"); if (!f) { m_console.printf("Error opening file '%s'\n", params[0]); @@ -2747,7 +2749,7 @@ void debugger_commands::execute_dump(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_strdump(int spacenum, const std::vector ¶ms) { // validate parameters u64 offset; @@ -2774,7 +2776,8 @@ void debugger_commands::execute_strdump(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_cheatrange(bool init, const std::vector ¶ms) { address_space *space = m_cheat.space; if (!space && !init) @@ -2940,7 +2943,7 @@ void debugger_commands::execute_cheatrange(bool init, const std::vector ¶ms) +void debugger_commands::execute_cheatnext(bool initial, const std::vector ¶ms) { enum { @@ -3126,25 +3129,25 @@ void debugger_commands::execute_cheatnext(bool initial, const std::vector 1) ? CHEAT_EQUALTO : CHEAT_EQUAL; - else if (!core_stricmp(params[0].c_str(), "notequal") || !core_stricmp(params[0].c_str(), "ne")) + else if (util::streqlower(params[0], "notequal") || util::streqlower(params[0], "ne")) condition = (params.size() > 1) ? CHEAT_NOTEQUALTO : CHEAT_NOTEQUAL; - else if (!core_stricmp(params[0].c_str(), "decrease") || !core_stricmp(params[0].c_str(), "de") || params[0] == "-") + else if (util::streqlower(params[0], "decrease") || util::streqlower(params[0], "de") || params[0] == "-") condition = (params.size() > 1) ? CHEAT_DECREASEOF : CHEAT_DECREASE; - else if (!core_stricmp(params[0].c_str(), "increase") || !core_stricmp(params[0].c_str(), "in") || params[0] == "+") + else if (util::streqlower(params[0], "increase") || util::streqlower(params[0], "in") || params[0] == "+") condition = (params.size() > 1) ? CHEAT_INCREASEOF : CHEAT_INCREASE; - else if (!core_stricmp(params[0].c_str(), "decreaseorequal") || !core_stricmp(params[0].c_str(), "deeq")) + else if (util::streqlower(params[0], "decreaseorequal") || util::streqlower(params[0], "deeq")) condition = CHEAT_DECREASE_OR_EQUAL; - else if (!core_stricmp(params[0].c_str(), "increaseorequal") || !core_stricmp(params[0].c_str(), "ineq")) + else if (util::streqlower(params[0], "increaseorequal") || util::streqlower(params[0], "ineq")) condition = CHEAT_INCREASE_OR_EQUAL; - else if (!core_stricmp(params[0].c_str(), "smallerof") || !core_stricmp(params[0].c_str(), "lt") || params[0] == "<") + else if (util::streqlower(params[0], "smallerof") || util::streqlower(params[0], "lt") || params[0] == "<") condition = CHEAT_SMALLEROF; - else if (!core_stricmp(params[0].c_str(), "greaterof") || !core_stricmp(params[0].c_str(), "gt") || params[0] == ">") + else if (util::streqlower(params[0], "greaterof") || util::streqlower(params[0], "gt") || params[0] == ">") condition = CHEAT_GREATEROF; - else if (!core_stricmp(params[0].c_str(), "changedby") || !core_stricmp(params[0].c_str(), "ch") || params[0] == "~") + else if (util::streqlower(params[0], "changedby") || util::streqlower(params[0], "ch") || params[0] == "~") condition = CHEAT_CHANGEDBY; else { @@ -3256,7 +3259,7 @@ void debugger_commands::execute_cheatnext(bool initial, const std::vector()); + execute_cheatlist(std::vector()); m_console.printf("%u cheats found\n", active_cheat); } @@ -3266,7 +3269,7 @@ void debugger_commands::execute_cheatnext(bool initial, const std::vector ¶ms) +void debugger_commands::execute_cheatlist(const std::vector ¶ms) { address_space *const space = m_cheat.space; if (!space) @@ -3278,7 +3281,8 @@ void debugger_commands::execute_cheatlist(const std::vector ¶ms FILE *f = nullptr; if (params.size() > 0) { - f = fopen(params[0].c_str(), "w"); + std::string filename(params[0]); + f = fopen(filename.c_str(), "w"); if (!f) { m_console.printf("Error opening file '%s'\n", params[0]); @@ -3383,7 +3387,7 @@ void debugger_commands::execute_cheatlist(const std::vector ¶ms execute_cheatundo - undo the last search -------------------------------------------------*/ -void debugger_commands::execute_cheatundo(const std::vector ¶ms) +void debugger_commands::execute_cheatundo(const std::vector ¶ms) { if (m_cheat.undo > 0) { @@ -3412,7 +3416,7 @@ void debugger_commands::execute_cheatundo(const std::vector ¶ms execute_find - execute the find command -------------------------------------------------*/ -void debugger_commands::execute_find(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_find(int spacenum, const std::vector ¶ms) { u64 offset, length; address_space *space; @@ -3436,11 +3440,11 @@ void debugger_commands::execute_find(int spacenum, const std::vector= 2) + { + if (tolower(u8(pdata[0])) == 'b' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 1; pdata.remove_prefix(2); } + if (tolower(u8(pdata[0])) == 'w' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 2; pdata.remove_prefix(2); } + if (tolower(u8(pdata[0])) == 'd' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 4; pdata.remove_prefix(2); } + if (tolower(u8(pdata[0])) == 'q' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 8; pdata.remove_prefix(2); } + } // look for a wildcard - if (!strcmp(pdata, "?")) + if (pdata == "?") data_size[data_count++] |= 0x10; // otherwise, validate as a number @@ -3538,7 +3545,7 @@ void debugger_commands::execute_find(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_fill(int spacenum, const std::vector ¶ms) { u64 offset, length; address_space *space; @@ -3561,12 +3568,12 @@ void debugger_commands::execute_fill(int spacenum, const std::vector= 2) + { + if (tolower(u8(pdata[0])) == 'b' && pdata[1] == '.') { fill_data_size[data_count] = cur_data_size = 1; pdata.remove_prefix(2); } + if (tolower(u8(pdata[0])) == 'w' && pdata[1] == '.') { fill_data_size[data_count] = cur_data_size = 2; pdata.remove_prefix(2); } + if (tolower(u8(pdata[0])) == 'd' && pdata[1] == '.') { fill_data_size[data_count] = cur_data_size = 4; pdata.remove_prefix(2); } + if (tolower(u8(pdata[0])) == 'q' && pdata[1] == '.') { fill_data_size[data_count] = cur_data_size = 8; pdata.remove_prefix(2); } + } // validate as a number if (!validate_number_parameter(pdata, fill_data[data_count++])) @@ -3643,7 +3653,7 @@ void debugger_commands::execute_fill(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_dasm(const std::vector ¶ms) { u64 offset, length; bool bytes = true; @@ -3702,7 +3712,8 @@ void debugger_commands::execute_dasm(const std::vector ¶ms) } /* write the data */ - std::ofstream f(params[0]); + std::string fname(params[0]); + std::ofstream f(fname); if (!f.good()) { m_console.printf("Error opening file '%s'\n", params[0]); @@ -3741,14 +3752,14 @@ void debugger_commands::execute_dasm(const std::vector ¶ms) trace over and trace info -------------------------------------------------*/ -void debugger_commands::execute_trace(const std::vector ¶ms, bool trace_over) +void debugger_commands::execute_trace(const std::vector ¶ms, bool trace_over) { - const char *action = nullptr; + std::string action; bool detect_loops = true; bool logerror = false; device_t *cpu; const char *mode; - std::string filename = params[0]; + std::string filename(params[0]); // replace macros strreplace(filename, "{game}", m_machine.basename()); @@ -3759,14 +3770,15 @@ void debugger_commands::execute_trace(const std::vector ¶ms, bo if (params.size() > 2) { std::stringstream stream; - stream.str(params[2]); + std::string flagparam(params[2]); + stream.str(flagparam); std::string flag; while (std::getline(stream, flag, '|')) { - if (!core_stricmp(flag.c_str(), "noloop")) + if (util::streqlower(flag, "noloop")) detect_loops = false; - else if (!core_stricmp(flag.c_str(), "logerror")) + else if (util::streqlower(flag, "logerror")) logerror = true; else { @@ -3775,12 +3787,12 @@ void debugger_commands::execute_trace(const std::vector ¶ms, bo } } } - if (!debug_command_parameter_command(action = (params.size() > 3) ? params[3].c_str() : nullptr)) + if (params.size() > 3 && !debug_command_parameter_command(action = params[3])) return; // open the file FILE *f = nullptr; - if (core_stricmp(filename.c_str(), "off") != 0) + if (!util::streqlower(filename, "off")) { mode = "w"; @@ -3800,7 +3812,7 @@ void debugger_commands::execute_trace(const std::vector ¶ms, bo } // do it - cpu->debug()->trace(f, trace_over, detect_loops, logerror, action); + cpu->debug()->trace(f, trace_over, detect_loops, logerror, action.c_str()); if (f) m_console.printf("Tracing CPU '%s' to file %s\n", cpu->tag(), filename); else @@ -3812,7 +3824,7 @@ void debugger_commands::execute_trace(const std::vector ¶ms, bo execute_traceflush - execute the trace flush command -------------------------------------------------*/ -void debugger_commands::execute_traceflush(const std::vector ¶ms) +void debugger_commands::execute_traceflush(const std::vector ¶ms) { m_machine.debugger().cpu().flush_traces(); } @@ -3822,7 +3834,7 @@ void debugger_commands::execute_traceflush(const std::vector ¶m execute_history - execute the history command -------------------------------------------------*/ -void debugger_commands::execute_history(const std::vector ¶ms) +void debugger_commands::execute_history(const std::vector ¶ms) { // validate parameters device_t *device; @@ -3870,7 +3882,7 @@ void debugger_commands::execute_history(const std::vector ¶ms) execute_trackpc - execute the trackpc command -------------------------------------------------*/ -void debugger_commands::execute_trackpc(const std::vector ¶ms) +void debugger_commands::execute_trackpc(const std::vector ¶ms) { // Gather the on/off switch (if present) bool turnOn = true; @@ -3919,7 +3931,7 @@ void debugger_commands::execute_trackpc(const std::vector ¶ms) execute_trackmem - execute the trackmem command -------------------------------------------------*/ -void debugger_commands::execute_trackmem(const std::vector ¶ms) +void debugger_commands::execute_trackmem(const std::vector ¶ms) { // Gather the on/off switch (if present) bool turnOn = true; @@ -3957,7 +3969,7 @@ void debugger_commands::execute_trackmem(const std::vector ¶ms) execute_pcatmem - execute the pcatmem command -------------------------------------------------*/ -void debugger_commands::execute_pcatmem(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_pcatmem(int spacenum, const std::vector ¶ms) { // Gather the required target address/space parameter u64 address; @@ -4008,7 +4020,7 @@ void debugger_commands::execute_pcatmem(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_snap(const std::vector ¶ms) { /* if no params, use the default behavior */ if (params.empty()) @@ -4020,8 +4032,9 @@ void debugger_commands::execute_snap(const std::vector ¶ms) /* otherwise, we have to open the file ourselves */ else { - const char *filename = params[0].c_str(); - int scrnum = (params.size() > 1) ? atoi(params[1].c_str()) : 0; + u64 scrnum = 0; + if (params.size() > 1 && !validate_number_parameter(params[1], scrnum)) + return; screen_device_enumerator iter(m_machine.root_device()); screen_device *screen = iter.byindex(scrnum); @@ -4032,7 +4045,7 @@ void debugger_commands::execute_snap(const std::vector ¶ms) return; } - std::string fname(filename); + std::string fname(params[0]); if (fname.find(".png") == -1) fname.append(".png"); emu_file file(m_machine.options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -4040,12 +4053,12 @@ void debugger_commands::execute_snap(const std::vector ¶ms) if (filerr) { - m_console.printf("Error creating file '%s' (%s:%d %s)\n", filename, filerr.category().name(), filerr.value(), filerr.message()); + m_console.printf("Error creating file '%s' (%s:%d %s)\n", params[0], filerr.category().name(), filerr.value(), filerr.message()); return; } screen->machine().video().save_snapshot(screen, file); - m_console.printf("Saved screen #%d snapshot as '%s'\n", scrnum, filename); + m_console.printf("Saved screen #%d snapshot as '%s'\n", scrnum, params[0]); } } @@ -4054,9 +4067,10 @@ void debugger_commands::execute_snap(const std::vector ¶ms) execute_source - execute the source command -------------------------------------------------*/ -void debugger_commands::execute_source(const std::vector ¶ms) +void debugger_commands::execute_source(const std::vector ¶ms) { - m_console.source_script(params[0].c_str()); + std::string filename(params[0]); + m_console.source_script(filename.c_str()); } @@ -4064,7 +4078,7 @@ void debugger_commands::execute_source(const std::vector ¶ms) execute_map - execute the map command -------------------------------------------------*/ -void debugger_commands::execute_map(int spacenum, const std::vector ¶ms) +void debugger_commands::execute_map(int spacenum, const std::vector ¶ms) { // validate parameters u64 address; @@ -4097,14 +4111,15 @@ void debugger_commands::execute_map(int spacenum, const std::vector execute_memdump - execute the memdump command -------------------------------------------------*/ -void debugger_commands::execute_memdump(const std::vector ¶ms) +void debugger_commands::execute_memdump(const std::vector ¶ms) { device_t *root = &m_machine.root_device(); if ((params.size() >= 2) && !validate_device_parameter(params[1], root)) return; - char const *const filename = params.empty() ? "memdump.log" : params[0].c_str(); - FILE *const file = fopen(filename, "w"); + using namespace std::literals; + std::string filename = params.empty() ? "memdump.log"s : std::string(params[0]); + FILE *const file = fopen(filename.c_str(), "w"); if (!file) { m_console.printf("Error opening file %s\n", filename); @@ -4163,7 +4178,7 @@ void debugger_commands::execute_memdump(const std::vector ¶ms) execute_symlist - execute the symlist command -------------------------------------------------*/ -void debugger_commands::execute_symlist(const std::vector ¶ms) +void debugger_commands::execute_symlist(const std::vector ¶ms) { const char *namelist[1000]; symbol_table *symtable; @@ -4225,7 +4240,7 @@ void debugger_commands::execute_symlist(const std::vector ¶ms) execute_softreset - execute the softreset command -------------------------------------------------*/ -void debugger_commands::execute_softreset(const std::vector ¶ms) +void debugger_commands::execute_softreset(const std::vector ¶ms) { m_machine.schedule_soft_reset(); } @@ -4235,7 +4250,7 @@ void debugger_commands::execute_softreset(const std::vector ¶ms execute_hardreset - execute the hardreset command -------------------------------------------------*/ -void debugger_commands::execute_hardreset(const std::vector ¶ms) +void debugger_commands::execute_hardreset(const std::vector ¶ms) { m_machine.schedule_hard_reset(); } @@ -4245,7 +4260,7 @@ void debugger_commands::execute_hardreset(const std::vector ¶ms mounted files -------------------------------------------------*/ -void debugger_commands::execute_images(const std::vector ¶ms) +void debugger_commands::execute_images(const std::vector ¶ms) { image_interface_enumerator iter(m_machine.root_device()); for (device_image_interface &img : iter) @@ -4275,7 +4290,7 @@ void debugger_commands::execute_images(const std::vector ¶ms) execute_mount - execute the image mount command -------------------------------------------------*/ -void debugger_commands::execute_mount(const std::vector ¶ms) +void debugger_commands::execute_mount(const std::vector ¶ms) { for (device_image_interface &img : image_interface_enumerator(m_machine.root_device())) { @@ -4295,7 +4310,7 @@ void debugger_commands::execute_mount(const std::vector ¶ms) execute_unmount - execute the image unmount command -------------------------------------------------*/ -void debugger_commands::execute_unmount(const std::vector ¶ms) +void debugger_commands::execute_unmount(const std::vector ¶ms) { for (device_image_interface &img : image_interface_enumerator(m_machine.root_device())) { @@ -4322,7 +4337,7 @@ void debugger_commands::execute_unmount(const std::vector ¶ms) natural keyboard input -------------------------------------------------*/ -void debugger_commands::execute_input(const std::vector ¶ms) +void debugger_commands::execute_input(const std::vector ¶ms) { m_machine.natkeyboard().post_coded(params[0]); } @@ -4333,15 +4348,15 @@ void debugger_commands::execute_input(const std::vector ¶ms) keyboard codes -------------------------------------------------*/ -void debugger_commands::execute_dumpkbd(const std::vector ¶ms) +void debugger_commands::execute_dumpkbd(const std::vector ¶ms) { // was there a file specified? - const char *filename = !params.empty() ? params[0].c_str() : nullptr; + std::string filename = !params.empty() ? std::string(params[0]) : std::string(); FILE *file = nullptr; - if (filename != nullptr) + if (!filename.empty()) { // if so, open it - file = fopen(filename, "w"); + file = fopen(filename.c_str(), "w"); if (file == nullptr) { m_console.printf("Cannot open \"%s\"\n", filename); diff --git a/src/emu/debug/debugcmd.h b/src/emu/debug/debugcmd.h index f93276d5d8d..9ede662511a 100644 --- a/src/emu/debug/debugcmd.h +++ b/src/emu/debug/debugcmd.h @@ -25,7 +25,7 @@ public: debugger_commands(running_machine &machine, debugger_cpu &cpu, debugger_console &console); // validates a parameter as a boolean value - bool validate_boolean_parameter(const std::string ¶m, bool &result); + 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); @@ -90,7 +90,7 @@ private: device_t &get_device_search_base(std::string_view ¶m); device_t *get_cpu_by_index(u64 cpunum); bool debug_command_parameter_expression(std::string_view param, parsed_expression &result); - bool debug_command_parameter_command(const char *param); + bool debug_command_parameter_command(std::string_view param); bool cheat_address_is_valid(address_space &space, offs_t address); @@ -101,87 +101,87 @@ private: bool mini_printf(std::ostream &stream, std::string_view format, int params, u64 *param); template - void execute_index_command(std::vector const ¶ms, T &&apply, char const *unused_message); - - void execute_help(const std::vector ¶ms); - void execute_print(const std::vector ¶ms); - void execute_printf(const std::vector ¶ms); - void execute_logerror(const std::vector ¶ms); - void execute_tracelog(const std::vector ¶ms); - void execute_tracesym(const std::vector ¶ms); - void execute_cls(const std::vector ¶ms); - void execute_quit(const std::vector ¶ms); - void execute_do(const std::vector ¶ms); - void execute_step(const std::vector ¶ms); - void execute_over(const std::vector ¶ms); - void execute_out(const std::vector ¶ms); - void execute_go(const std::vector ¶ms); - void execute_go_vblank(const std::vector ¶ms); - void execute_go_interrupt(const std::vector ¶ms); - void execute_go_exception(const std::vector ¶ms); - void execute_go_time(const std::vector ¶ms); - void execute_go_privilege(const std::vector ¶ms); - void execute_go_branch(bool sense, const std::vector ¶ms); - void execute_go_next_instruction(const std::vector ¶ms); - void execute_focus(const std::vector ¶ms); - void execute_ignore(const std::vector ¶ms); - void execute_observe(const std::vector ¶ms); - void execute_suspend(const std::vector ¶ms); - void execute_resume(const std::vector ¶ms); - void execute_next(const std::vector ¶ms); - void execute_cpulist(const std::vector ¶ms); - void execute_time(const std::vector ¶ms); - void execute_comment_add(const std::vector ¶ms); - void execute_comment_del(const std::vector ¶ms); - void execute_comment_save(const std::vector ¶ms); - void execute_comment_list(const std::vector ¶ms); - void execute_comment_commit(const std::vector ¶ms); - void execute_bpset(const std::vector ¶ms); - void execute_bpclear(const std::vector ¶ms); - void execute_bpdisenable(bool enable, const std::vector ¶ms); - void execute_bplist(const std::vector ¶ms); - void execute_wpset(int spacenum, const std::vector ¶ms); - void execute_wpclear(const std::vector ¶ms); - void execute_wpdisenable(bool enable, const std::vector ¶ms); - void execute_wplist(const std::vector ¶ms); - void execute_rpset(const std::vector ¶ms); - void execute_rpclear(const std::vector ¶ms); - void execute_rpdisenable(bool enable, const std::vector ¶ms); - void execute_rplist(const std::vector ¶ms); - void execute_statesave(const std::vector ¶ms); - void execute_stateload(const std::vector ¶ms); - void execute_rewind(const std::vector ¶ms); - void execute_save(int spacenum, const std::vector ¶ms); - void execute_saveregion(const std::vector ¶ms); - void execute_load(int spacenum, const std::vector ¶ms); - void execute_loadregion(const std::vector ¶ms); - void execute_dump(int spacenum, const std::vector ¶ms); - void execute_strdump(int spacenum, const std::vector ¶ms); - void execute_cheatrange(bool init, const std::vector ¶ms); - void execute_cheatnext(bool initial, const std::vector ¶ms); - void execute_cheatlist(const std::vector ¶ms); - void execute_cheatundo(const std::vector ¶ms); - void execute_dasm(const std::vector ¶ms); - void execute_find(int spacenum, const std::vector ¶ms); - void execute_fill(int spacenum, const std::vector ¶ms); - void execute_trace(const std::vector ¶ms, bool trace_over); - void execute_traceflush(const std::vector ¶ms); - void execute_history(const std::vector ¶ms); - void execute_trackpc(const std::vector ¶ms); - void execute_trackmem(const std::vector ¶ms); - void execute_pcatmem(int spacenum, const std::vector ¶ms); - void execute_snap(const std::vector ¶ms); - void execute_source(const std::vector ¶ms); - void execute_map(int spacenum, const std::vector ¶ms); - void execute_memdump(const std::vector ¶ms); - void execute_symlist(const std::vector ¶ms); - void execute_softreset(const std::vector ¶ms); - void execute_hardreset(const std::vector ¶ms); - void execute_images(const std::vector ¶ms); - void execute_mount(const std::vector ¶ms); - void execute_unmount(const std::vector ¶ms); - void execute_input(const std::vector ¶ms); - void execute_dumpkbd(const std::vector ¶ms); + void execute_index_command(std::vector const ¶ms, T &&apply, char const *unused_message); + + void execute_help(const std::vector ¶ms); + void execute_print(const std::vector ¶ms); + void execute_printf(const std::vector ¶ms); + void execute_logerror(const std::vector ¶ms); + void execute_tracelog(const std::vector ¶ms); + void execute_tracesym(const std::vector ¶ms); + void execute_cls(const std::vector ¶ms); + void execute_quit(const std::vector ¶ms); + void execute_do(const std::vector ¶ms); + void execute_step(const std::vector ¶ms); + void execute_over(const std::vector ¶ms); + void execute_out(const std::vector ¶ms); + void execute_go(const std::vector ¶ms); + void execute_go_vblank(const std::vector ¶ms); + void execute_go_interrupt(const std::vector ¶ms); + void execute_go_exception(const std::vector ¶ms); + void execute_go_time(const std::vector ¶ms); + void execute_go_privilege(const std::vector ¶ms); + void execute_go_branch(bool sense, const std::vector ¶ms); + void execute_go_next_instruction(const std::vector ¶ms); + void execute_focus(const std::vector ¶ms); + void execute_ignore(const std::vector ¶ms); + void execute_observe(const std::vector ¶ms); + void execute_suspend(const std::vector ¶ms); + void execute_resume(const std::vector ¶ms); + void execute_next(const std::vector ¶ms); + void execute_cpulist(const std::vector ¶ms); + void execute_time(const std::vector ¶ms); + void execute_comment_add(const std::vector ¶ms); + void execute_comment_del(const std::vector ¶ms); + void execute_comment_save(const std::vector ¶ms); + void execute_comment_list(const std::vector ¶ms); + void execute_comment_commit(const std::vector ¶ms); + void execute_bpset(const std::vector ¶ms); + void execute_bpclear(const std::vector ¶ms); + void execute_bpdisenable(bool enable, const std::vector ¶ms); + void execute_bplist(const std::vector ¶ms); + void execute_wpset(int spacenum, const std::vector ¶ms); + void execute_wpclear(const std::vector ¶ms); + void execute_wpdisenable(bool enable, const std::vector ¶ms); + void execute_wplist(const std::vector ¶ms); + void execute_rpset(const std::vector ¶ms); + void execute_rpclear(const std::vector ¶ms); + void execute_rpdisenable(bool enable, const std::vector ¶ms); + void execute_rplist(const std::vector ¶ms); + void execute_statesave(const std::vector ¶ms); + void execute_stateload(const std::vector ¶ms); + void execute_rewind(const std::vector ¶ms); + void execute_save(int spacenum, const std::vector ¶ms); + void execute_saveregion(const std::vector ¶ms); + void execute_load(int spacenum, const std::vector ¶ms); + void execute_loadregion(const std::vector ¶ms); + void execute_dump(int spacenum, const std::vector ¶ms); + void execute_strdump(int spacenum, const std::vector ¶ms); + void execute_cheatrange(bool init, const std::vector ¶ms); + void execute_cheatnext(bool initial, const std::vector ¶ms); + void execute_cheatlist(const std::vector ¶ms); + void execute_cheatundo(const std::vector ¶ms); + void execute_dasm(const std::vector ¶ms); + void execute_find(int spacenum, const std::vector ¶ms); + void execute_fill(int spacenum, const std::vector ¶ms); + void execute_trace(const std::vector ¶ms, bool trace_over); + void execute_traceflush(const std::vector ¶ms); + void execute_history(const std::vector ¶ms); + void execute_trackpc(const std::vector ¶ms); + void execute_trackmem(const std::vector ¶ms); + void execute_pcatmem(int spacenum, const std::vector ¶ms); + void execute_snap(const std::vector ¶ms); + void execute_source(const std::vector ¶ms); + void execute_map(int spacenum, const std::vector ¶ms); + void execute_memdump(const std::vector ¶ms); + void execute_symlist(const std::vector ¶ms); + void execute_softreset(const std::vector ¶ms); + void execute_hardreset(const std::vector ¶ms); + void execute_images(const std::vector ¶ms); + void execute_mount(const std::vector ¶ms); + void execute_unmount(const std::vector ¶ms); + void execute_input(const std::vector ¶ms); + void execute_dumpkbd(const std::vector ¶ms); running_machine& m_machine; debugger_console& m_console; diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp index 92f62c9909b..41e09d748f3 100644 --- a/src/emu/debug/debugcon.cpp +++ b/src/emu/debug/debugcon.cpp @@ -133,7 +133,7 @@ inline bool debugger_console::debug_command::compare::operator()(const debug_com } -debugger_console::debug_command::debug_command(std::string_view _command, u32 _flags, int _minparams, int _maxparams, std::function &)> &&_handler) +debugger_console::debug_command::debug_command(std::string_view _command, u32 _flags, int _minparams, int _maxparams, std::function &)> &&_handler) : command(_command), params(nullptr), help(nullptr), handler(std::move(_handler)), flags(_flags), minparams(_minparams), maxparams(_maxparams) { } @@ -143,7 +143,7 @@ debugger_console::debug_command::debug_command(std::string_view _command, u32 _f // execute_help_custom - execute the helpcustom command //------------------------------------------------------------ -void debugger_console::execute_help_custom(const std::vector ¶ms) +void debugger_console::execute_help_custom(const std::vector ¶ms) { for (const debug_command &cmd : m_commandlist) { @@ -160,9 +160,9 @@ void debugger_console::execute_help_custom(const std::vector ¶m execute_condump - execute the condump command ------------------------------------------------------------*/ -void debugger_console::execute_condump(const std::vector& params) +void debugger_console::execute_condump(const std::vector& params) { - std::string filename = params[0]; + std::string filename(params[0]); const char* mode; /* replace macros */ @@ -308,10 +308,7 @@ CMDERR debugger_console::internal_execute_command(bool execute, std::vector params_vec(params.begin(), params.end()); - found->handler(params_vec); - } + found->handler(params); return CMDERR::none(); } @@ -454,7 +451,7 @@ CMDERR debugger_console::validate_command(std::string_view command) register_command - register a command handler -------------------------------------------------*/ -void debugger_console::register_command(std::string_view command, u32 flags, int minparams, int maxparams, std::function &)> &&handler) +void debugger_console::register_command(std::string_view command, u32 flags, int minparams, int maxparams, std::function &)> &&handler) { if (m_machine.phase() != machine_phase::INIT) throw emu_fatalerror("Can only call debugger_console::register_command() at init time!"); diff --git a/src/emu/debug/debugcon.h b/src/emu/debug/debugcon.h index 974a43e656a..5c7b521426f 100644 --- a/src/emu/debug/debugcon.h +++ b/src/emu/debug/debugcon.h @@ -83,7 +83,7 @@ public: // command handling 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 &)> &&handler); + void register_command(std::string_view command, u32 flags, int minparams, int maxparams, std::function &)> &&handler); void source_script(const char *file); void process_source_file(); @@ -119,8 +119,8 @@ public: private: void exit(); - void execute_help_custom(const std::vector ¶ms); - void execute_condump(const std::vector& params); + void execute_help_custom(const std::vector ¶ms); + void execute_condump(const std::vector& params); [[nodiscard]] static std::string_view trim_parameter(std::string_view param, bool keep_quotes); CMDERR internal_execute_command(bool execute, std::vector ¶ms); @@ -131,7 +131,7 @@ private: struct debug_command { - debug_command(std::string_view _command, u32 _flags, int _minparams, int _maxparams, std::function &)> &&_handler); + debug_command(std::string_view _command, u32 _flags, int _minparams, int _maxparams, std::function &)> &&_handler); struct compare { @@ -144,7 +144,7 @@ private: std::string command; const char * params; const char * help; - std::function &)> handler; + std::function &)> handler; u32 flags; int minparams; int maxparams; diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp index 5a36e6b8e13..cac2e2a717a 100644 --- a/src/emu/natkeyboard.cpp +++ b/src/emu/natkeyboard.cpp @@ -505,10 +505,10 @@ void natural_keyboard::post_utf8(const char *text, size_t length, const attotime } -void natural_keyboard::post_utf8(const std::string &text, const attotime &rate) +void natural_keyboard::post_utf8(std::string_view text, const attotime &rate) { if (!text.empty()) - post_utf8(text.c_str(), text.size(), rate); + post_utf8(text.data(), text.size(), rate); } @@ -590,10 +590,10 @@ void natural_keyboard::post_coded(const char *text, size_t length, const attotim } -void natural_keyboard::post_coded(const std::string &text, const attotime &rate) +void natural_keyboard::post_coded(std::string_view text, const attotime &rate) { if (!text.empty()) - post_coded(text.c_str(), text.size(), rate); + post_coded(text.data(), text.size(), rate); } diff --git a/src/emu/natkeyboard.h b/src/emu/natkeyboard.h index dc89b0eb156..c14de66fa66 100644 --- a/src/emu/natkeyboard.h +++ b/src/emu/natkeyboard.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -63,9 +64,9 @@ public: void post_char(char32_t ch, bool normalize_crlf = false); void post(const char32_t *text, size_t length = 0, const attotime &rate = attotime::zero); void post_utf8(const char *text, size_t length = 0, const attotime &rate = attotime::zero); - void post_utf8(const std::string &text, const attotime &rate = attotime::zero); + void post_utf8(std::string_view text, const attotime &rate = attotime::zero); void post_coded(const char *text, size_t length = 0, const attotime &rate = attotime::zero); - void post_coded(const std::string &text, const attotime &rate = attotime::zero); + void post_coded(std::string_view text, const attotime &rate = attotime::zero); void paste(); // debugging diff --git a/src/lib/util/corestr.cpp b/src/lib/util/corestr.cpp index 85e7e517665..50f2469b14f 100644 --- a/src/lib/util/corestr.cpp +++ b/src/lib/util/corestr.cpp @@ -165,11 +165,11 @@ std::string strmakeupper(std::string_view str) } /** - * @fn std::string &strmakelower(std::string_view str) + * @fn std::string strmakelower(std::string_view str) * * @brief Returns a lower case version of the given string. * - * @param [in,out] str The string to make lower case + * @param [in] str The string to make lower case * * @return A new std::string having been changed to lower case */ @@ -209,6 +209,40 @@ int strreplace(std::string &str, const std::string& search, const std::string& r namespace util { +/** + * @fn bool streqlower(std::string_view str, std::string_view lcstr) + * + * @brief Tests whether a mixed-case string matches a lowercase string. + * + * @param [in] str First string to compare (may be mixed-case). + * @param [in] lcstr Second string to compare (must be all lowercase). + * + * @return True if the strings match regardless of case. + */ + +bool streqlower(std::string_view str, std::string_view lcstr) +{ + return std::equal(str.begin(), str.end(), lcstr.begin(), lcstr.end(), + [] (unsigned char c1, unsigned char c2) { return std::tolower(c1) == c2; }); +} + +/** + * @fn bool strequpper(std::string_view str, std::string_view ucstr) + * + * @brief Tests whether a mixed-case string matches an uppercase string. + * + * @param [in] str First string to compare (may be mixed-case). + * @param [in] ucstr Second string to compare (must be all uppercase). + * + * @return True if the strings match regardless of case. + */ + +bool strequpper(std::string_view str, std::string_view ucstr) +{ + return std::equal(str.begin(), str.end(), ucstr.begin(), ucstr.end(), + [] (unsigned char c1, unsigned char c2) { return std::toupper(c1) == c2; }); +} + /** * @fn double edit_distance(std::u32string_view lhs, std::u32string_view rhs) * diff --git a/src/lib/util/corestr.h b/src/lib/util/corestr.h index d5b79ddb5fa..b000d76731c 100644 --- a/src/lib/util/corestr.h +++ b/src/lib/util/corestr.h @@ -77,6 +77,9 @@ int strreplace(std::string &str, const std::string& search, const std::string& r namespace util { +bool strequpper(std::string_view str, std::string_view ucstr); +bool streqlower(std::string_view str, std::string_view lcstr); + // based on Jaro-Winkler distance - returns value from 0.0 (totally dissimilar) to 1.0 (identical) double edit_distance(std::u32string_view lhs, std::u32string_view rhs); diff --git a/src/mame/konami/konamim2.cpp b/src/mame/konami/konamim2.cpp index d93828cb3e2..4304c0a314d 100644 --- a/src/mame/konami/konamim2.cpp +++ b/src/mame/konami/konamim2.cpp @@ -371,10 +371,10 @@ private: m_ata_int = param; } - void debug_help_command(const std::vector ¶ms); - void debug_commands(const std::vector ¶ms); + void debug_help_command(const std::vector ¶ms); + void debug_commands(const std::vector ¶ms); - void dump_task_command(const std::vector ¶ms); + void dump_task_command(const std::vector ¶ms); }; @@ -1485,7 +1485,7 @@ void konamim2_state::init_hellngt() * *************************************/ -void konamim2_state::debug_help_command(const std::vector ¶ms) +void konamim2_state::debug_help_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); @@ -1494,7 +1494,7 @@ void konamim2_state::debug_help_command(const std::vector ¶ms) con.printf(" konm2 dump_dspp,
-- Dump DSPP object at
\n"); } -void konamim2_state::debug_commands(const std::vector ¶ms) +void konamim2_state::debug_commands(const std::vector ¶ms) { if (params.size() < 1) return; @@ -1507,7 +1507,7 @@ void konamim2_state::debug_commands(const std::vector ¶ms) subdevice("bda:dspp")->dump_state(); } -void konamim2_state::dump_task_command(const std::vector ¶ms) +void konamim2_state::dump_task_command(const std::vector ¶ms) { typedef uint32_t Item; typedef uint32_t m2ptr; diff --git a/src/mame/midway/midtunit_v.cpp b/src/mame/midway/midtunit_v.cpp index 952b9452894..f87332be230 100644 --- a/src/mame/midway/midtunit_v.cpp +++ b/src/mame/midway/midtunit_v.cpp @@ -77,7 +77,7 @@ void midtunit_video_device::debug_init() } } -void midtunit_video_device::debug_commands(const std::vector ¶ms) +void midtunit_video_device::debug_commands(const std::vector ¶ms) { if (params.size() < 1) return; @@ -88,7 +88,7 @@ void midtunit_video_device::debug_commands(const std::vector ¶m debug_help_command(params); } -void midtunit_video_device::debug_help_command(const std::vector ¶ms) +void midtunit_video_device::debug_help_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); @@ -97,7 +97,7 @@ void midtunit_video_device::debug_help_command(const std::vector &p con.printf(" midblit help -- this list\n"); } -void midtunit_video_device::debug_png_dma_command(const std::vector ¶ms) +void midtunit_video_device::debug_png_dma_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); @@ -141,7 +141,7 @@ void midtunit_video_device::debug_png_dma_command(const std::vector return; } - strncpy(m_log_path, params[2].c_str(), 2047); + m_log_path = params[2]; if (params.size() == 4) { diff --git a/src/mame/midway/midtunit_v.h b/src/mame/midway/midtunit_v.h index a335eb395cf..b37cb56253e 100644 --- a/src/mame/midway/midtunit_v.h +++ b/src/mame/midway/midtunit_v.h @@ -165,16 +165,16 @@ protected: int32_t m_debug_dma_command; #endif - char m_log_path[2048]; + std::string m_log_path; bool m_log_png; bool m_log_json; std::unique_ptr m_logged_rom; bitmap_argb32 m_log_bitmap; void debug_init(); - void debug_commands(const std::vector ¶ms); - void debug_help_command(const std::vector ¶ms); - void debug_png_dma_command(const std::vector ¶ms); + void debug_commands(const std::vector ¶ms); + void debug_help_command(const std::vector ¶ms); + void debug_png_dma_command(const std::vector ¶ms); void log_bitmap(int command, int bpp, bool skip); }; diff --git a/src/mame/rm/rmnimbus.h b/src/mame/rm/rmnimbus.h index 8f5d355f13e..0fe2e2d83da 100644 --- a/src/mame/rm/rmnimbus.h +++ b/src/mame/rm/rmnimbus.h @@ -261,8 +261,8 @@ private: void decode_dssi_f_plonk_char(uint16_t ds, uint16_t si); void decode_dssi_f_rw_sectors(uint16_t ds, uint16_t si); - void debug_command(const std::vector ¶ms); - void video_debug(const std::vector ¶ms); + void debug_command(const std::vector ¶ms); + void video_debug(const std::vector ¶ms); offs_t dasm_override(std::ostream &stream, offs_t pc, const util::disasm_interface::data_buffer &opcodes, const util::disasm_interface::data_buffer ¶ms); TIMER_CALLBACK_MEMBER(do_mouse); diff --git a/src/mame/rm/rmnimbus_m.cpp b/src/mame/rm/rmnimbus_m.cpp index 466010411ec..39b9ea304f2 100644 --- a/src/mame/rm/rmnimbus_m.cpp +++ b/src/mame/rm/rmnimbus_m.cpp @@ -64,6 +64,7 @@ chdman createhd -o ST125N.chd -chs 41921,1,1 -ss 512 #include "rmnimbus.h" #include "debugger.h" +#include "debug/debugcmd.h" #include "debug/debugcon.h" #include "debug/debugcpu.h" #include "imagedev/floppy.h" @@ -234,12 +235,13 @@ void rmnimbus_state::machine_start() //m_fdc->overide_delays(64,m_fdc->get_cmd_delay()); } -void rmnimbus_state::debug_command(const std::vector ¶ms) +void rmnimbus_state::debug_command(const std::vector ¶ms) { if (params.size() > 0) { - int temp; - sscanf(params[0].c_str(), "%d", &temp); + uint64_t temp; + if (!machine().debugger().commands().validate_number_parameter(params[0], temp)) + return; m_debug_machine = temp; } else diff --git a/src/mame/rm/rmnimbus_v.cpp b/src/mame/rm/rmnimbus_v.cpp index 6e4980180ea..994a436e491 100644 --- a/src/mame/rm/rmnimbus_v.cpp +++ b/src/mame/rm/rmnimbus_v.cpp @@ -32,6 +32,7 @@ #include "rmnimbus.h" #include "debugger.h" +#include "debug/debugcmd.h" #include "debug/debugcon.h" #include @@ -623,12 +624,13 @@ void rmnimbus_state::change_palette(uint8_t bank, uint16_t colours) } } -void rmnimbus_state::video_debug(const std::vector ¶ms) +void rmnimbus_state::video_debug(const std::vector ¶ms) { if (params.size() > 0) { - int temp; - sscanf(params[0].c_str(), "%d", &temp); + uint64_t temp; + if (!machine().debugger().commands().validate_number_parameter(params[0], temp)) + return; m_debug_video = temp; } else diff --git a/src/mame/sega/chihiro.cpp b/src/mame/sega/chihiro.cpp index aab4a889715..7f2016569ee 100644 --- a/src/mame/sega/chihiro.cpp +++ b/src/mame/sega/chihiro.cpp @@ -663,9 +663,9 @@ private: void chihiro_map_io(address_map &map); void jamtable_disasm(address_space &space, uint32_t address, uint32_t size); - void jamtable_disasm_command(const std::vector ¶ms); - void chihiro_help_command(const std::vector ¶ms); - void debug_commands(const std::vector ¶ms); + void jamtable_disasm_command(const std::vector ¶ms); + void chihiro_help_command(const std::vector ¶ms); + void debug_commands(const std::vector ¶ms); }; /* jamtable instructions for Chihiro (different from Xbox console) @@ -780,7 +780,7 @@ void chihiro_state::jamtable_disasm(address_space &space, uint32_t address, uint } } -void chihiro_state::jamtable_disasm_command(const std::vector ¶ms) +void chihiro_state::jamtable_disasm_command(const std::vector ¶ms) { address_space &space = m_maincpu->space(); uint64_t addr, size; @@ -794,7 +794,7 @@ void chihiro_state::jamtable_disasm_command(const std::vector ¶ jamtable_disasm(space, (uint32_t)addr, (uint32_t)size); } -void chihiro_state::chihiro_help_command(const std::vector ¶ms) +void chihiro_state::chihiro_help_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); @@ -803,7 +803,7 @@ void chihiro_state::chihiro_help_command(const std::vector ¶ms) con.printf(" chihiro help -- this list\n"); } -void chihiro_state::debug_commands(const std::vector ¶ms) +void chihiro_state::debug_commands(const std::vector ¶ms) { if (params.size() < 1) return; diff --git a/src/mame/sega/model2.h b/src/mame/sega/model2.h index eb038822aa3..1df4c92b2b0 100644 --- a/src/mame/sega/model2.h +++ b/src/mame/sega/model2.h @@ -249,10 +249,10 @@ protected: void scsp_map(address_map &map); void debug_init(); - void debug_commands(const std::vector ¶ms); - void debug_geo_dasm_command(const std::vector ¶ms); - void debug_tri_dump_command(const std::vector ¶ms); - void debug_help_command(const std::vector ¶ms); + void debug_commands(const std::vector ¶ms); + void debug_geo_dasm_command(const std::vector ¶ms); + void debug_tri_dump_command(const std::vector ¶ms); + void debug_help_command(const std::vector ¶ms); virtual void video_start() override; diff --git a/src/mame/sega/model2_m.cpp b/src/mame/sega/model2_m.cpp index f9ef81adbf3..09621be1521 100644 --- a/src/mame/sega/model2_m.cpp +++ b/src/mame/sega/model2_m.cpp @@ -25,7 +25,7 @@ void model2_state::debug_init() } } -void model2_state::debug_commands(const std::vector ¶ms) +void model2_state::debug_commands(const std::vector ¶ms) { if (params.size() < 1) return; @@ -38,7 +38,7 @@ void model2_state::debug_commands(const std::vector ¶ms) debug_help_command(params); } -void model2_state::debug_help_command(const std::vector ¶ms) +void model2_state::debug_help_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); @@ -54,7 +54,7 @@ void model2_state::debug_help_command(const std::vector ¶ms) * ****************************************/ -void model2_state::debug_geo_dasm_command(const std::vector ¶ms) +void model2_state::debug_geo_dasm_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); @@ -70,10 +70,11 @@ void model2_state::debug_geo_dasm_command(const std::vector ¶ms return; } - std::ofstream f(params[1]); + std::string fname(params[1]); + std::ofstream f(fname); if (!f) { - con.printf("Error: while opening %s for writing\n",params[1].c_str()); + con.printf("Error: while opening %s for writing\n", params[1]); return; } @@ -264,7 +265,7 @@ void model2_state::debug_geo_dasm_command(const std::vector ¶ms * ****************************************/ -void model2_state::debug_tri_dump_command(const std::vector ¶ms) +void model2_state::debug_tri_dump_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); FILE *f; @@ -281,9 +282,10 @@ void model2_state::debug_tri_dump_command(const std::vector ¶ms return; } - if((f = fopen( params[1].c_str(), "w" )) == nullptr) + std::string filename(params[1]); + if((f = fopen( filename.c_str(), "w" )) == nullptr) { - con.printf("Error: while opening %s for writing\n",params[1].c_str()); + con.printf("Error: while opening %s for writing\n", params[1]); return; } diff --git a/src/mame/shared/xbox.cpp b/src/mame/shared/xbox.cpp index 04a430121f3..faf829028bb 100644 --- a/src/mame/shared/xbox.cpp +++ b/src/mame/shared/xbox.cpp @@ -84,7 +84,7 @@ void xbox_base_state::find_debug_params() } } -void xbox_base_state::dump_string_command(const std::vector ¶ms) +void xbox_base_state::dump_string_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); address_space &space = m_maincpu->space(); @@ -126,7 +126,7 @@ void xbox_base_state::dump_string_command(const std::vector ¶ms con.printf("\n"); } -void xbox_base_state::dump_process_command(const std::vector ¶ms) +void xbox_base_state::dump_process_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); address_space &space = m_maincpu->space(); @@ -156,7 +156,7 @@ void xbox_base_state::dump_process_command(const std::vector ¶m con.printf("_padding %d byte\n", space.read_byte(address + 27)); } -void xbox_base_state::dump_list_command(const std::vector ¶ms) +void xbox_base_state::dump_list_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); address_space &space = m_maincpu->space(); @@ -209,7 +209,7 @@ void xbox_base_state::dump_list_command(const std::vector ¶ms) } } -void xbox_base_state::dump_dpc_command(const std::vector ¶ms) +void xbox_base_state::dump_dpc_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); address_space &space = m_maincpu->space(); @@ -238,7 +238,7 @@ void xbox_base_state::dump_dpc_command(const std::vector ¶ms) con.printf("SystemArgument2 %08X dword\n", space.read_dword_unaligned(address + 24)); } -void xbox_base_state::dump_timer_command(const std::vector ¶ms) +void xbox_base_state::dump_timer_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); address_space &space = m_maincpu->space(); @@ -269,7 +269,7 @@ void xbox_base_state::dump_timer_command(const std::vector ¶ms) con.printf("Period %d dword\n", space.read_dword_unaligned(address + 36)); } -void xbox_base_state::curthread_command(const std::vector ¶ms) +void xbox_base_state::curthread_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); address_space &space = m_maincpu->space(); @@ -302,7 +302,7 @@ void xbox_base_state::curthread_command(const std::vector ¶ms) con.printf("Current thread function is %08X\n", space.read_dword_unaligned(address)); } -void xbox_base_state::threadlist_command(const std::vector ¶ms) +void xbox_base_state::threadlist_command(const std::vector ¶ms) { address_space &space = m_maincpu->space(); debugger_console &con = machine().debugger().console(); @@ -341,7 +341,7 @@ void xbox_base_state::threadlist_command(const std::vector ¶ms) } } -void xbox_base_state::generate_irq_command(const std::vector ¶ms) +void xbox_base_state::generate_irq_command(const std::vector ¶ms) { uint64_t irq; @@ -356,7 +356,7 @@ void xbox_base_state::generate_irq_command(const std::vector ¶m debug_generate_irq((int)irq, true); } -void xbox_base_state::nv2a_combiners_command(const std::vector ¶ms) +void xbox_base_state::nv2a_combiners_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); bool en = nvidia_nv2a->toggle_register_combiners_usage(); @@ -366,7 +366,7 @@ void xbox_base_state::nv2a_combiners_command(const std::vector &par con.printf("Register combiners disabled\n"); } -void xbox_base_state::nv2a_wclipping_command(const std::vector ¶ms) +void xbox_base_state::nv2a_wclipping_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); bool en = nvidia_nv2a->toggle_clipping_w_support(); @@ -376,7 +376,7 @@ void xbox_base_state::nv2a_wclipping_command(const std::vector &par con.printf("W clipping disabled\n"); } -void xbox_base_state::waitvblank_command(const std::vector ¶ms) +void xbox_base_state::waitvblank_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); bool en = nvidia_nv2a->toggle_wait_vblank_support(); @@ -386,7 +386,7 @@ void xbox_base_state::waitvblank_command(const std::vector ¶ms) con.printf("Vblank method disabled\n"); } -void xbox_base_state::grab_texture_command(const std::vector ¶ms) +void xbox_base_state::grab_texture_command(const std::vector ¶ms) { uint64_t type; @@ -396,10 +396,11 @@ void xbox_base_state::grab_texture_command(const std::vector ¶m return; if (params[2].empty() || params[2].length() > 127) return; - nvidia_nv2a->debug_grab_texture((int)type, params[2].c_str()); + std::string filename(params[2]); + nvidia_nv2a->debug_grab_texture((int)type, filename.c_str()); } -void xbox_base_state::grab_vprog_command(const std::vector ¶ms) +void xbox_base_state::grab_vprog_command(const std::vector ¶ms) { uint32_t instruction[4]; FILE *fil; @@ -408,7 +409,8 @@ void xbox_base_state::grab_vprog_command(const std::vector ¶ms) return; if (params[1].empty() || params[1].length() > 127) return; - if ((fil = fopen(params[1].c_str(), "wb")) == nullptr) + std::string filename(params[1]); + if ((fil = fopen(filename.c_str(), "wb")) == nullptr) return; for (int n = 0; n < 136; n++) { @@ -418,7 +420,7 @@ void xbox_base_state::grab_vprog_command(const std::vector ¶ms) fclose(fil); } -void xbox_base_state::vprogdis_command(const std::vector ¶ms) +void xbox_base_state::vprogdis_command(const std::vector ¶ms) { address_space &space = m_maincpu->space(); @@ -470,7 +472,7 @@ void xbox_base_state::vprogdis_command(const std::vector ¶ms) } } -void xbox_base_state::vdeclaration_command(const std::vector ¶ms) +void xbox_base_state::vdeclaration_command(const std::vector ¶ms) { address_space &space = m_maincpu->space(); @@ -551,7 +553,7 @@ void xbox_base_state::vdeclaration_command(const std::vector ¶m } } -void xbox_base_state::help_command(const std::vector ¶ms) +void xbox_base_state::help_command(const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); @@ -574,7 +576,7 @@ void xbox_base_state::help_command(const std::vector ¶ms) con.printf(" xbox help -- this list\n"); } -void xbox_base_state::xbox_debug_commands(const std::vector ¶ms) +void xbox_base_state::xbox_debug_commands(const std::vector ¶ms) { if (params.size() < 1) return; diff --git a/src/mame/shared/xbox.h b/src/mame/shared/xbox.h index 6bf33ee417b..94970626b0d 100644 --- a/src/mame/shared/xbox.h +++ b/src/mame/shared/xbox.h @@ -151,23 +151,23 @@ protected: const debugger_constants *debugc_bios; private: - void dump_string_command(const std::vector ¶ms); - void dump_process_command(const std::vector ¶ms); - void dump_list_command(const std::vector ¶ms); - void dump_dpc_command(const std::vector ¶ms); - void dump_timer_command(const std::vector ¶ms); - void curthread_command(const std::vector ¶ms); - void threadlist_command(const std::vector ¶ms); - void generate_irq_command(const std::vector ¶ms); - void nv2a_combiners_command(const std::vector ¶ms); - void nv2a_wclipping_command(const std::vector ¶ms); - void waitvblank_command(const std::vector ¶ms); - void grab_texture_command(const std::vector ¶ms); - void grab_vprog_command(const std::vector ¶ms); - void vprogdis_command(const std::vector ¶ms); - void vdeclaration_command(const std::vector ¶ms); - void help_command(const std::vector ¶ms); - void xbox_debug_commands(const std::vector ¶ms); + void dump_string_command(const std::vector ¶ms); + void dump_process_command(const std::vector ¶ms); + void dump_list_command(const std::vector ¶ms); + void dump_dpc_command(const std::vector ¶ms); + void dump_timer_command(const std::vector ¶ms); + void curthread_command(const std::vector ¶ms); + void threadlist_command(const std::vector ¶ms); + void generate_irq_command(const std::vector ¶ms); + void nv2a_combiners_command(const std::vector ¶ms); + void nv2a_wclipping_command(const std::vector ¶ms); + void waitvblank_command(const std::vector ¶ms); + void grab_texture_command(const std::vector ¶ms); + void grab_vprog_command(const std::vector ¶ms); + void vprogdis_command(const std::vector ¶ms); + void vdeclaration_command(const std::vector ¶ms); + void help_command(const std::vector ¶ms); + void xbox_debug_commands(const std::vector ¶ms); int find_bios_index(); bool find_bios_hash(int bios, uint32_t &crc32); void find_debug_params(); diff --git a/src/mame/sun/sun4.cpp b/src/mame/sun/sun4.cpp index 24e00283cb6..2a7efc7fd26 100644 --- a/src/mame/sun/sun4.cpp +++ b/src/mame/sun/sun4.cpp @@ -632,7 +632,7 @@ protected: void dma_transfer_write(); void dma_transfer_read(); - void fcodes_command(int ref, const std::vector ¶ms); + void fcodes_command(int ref, const std::vector ¶ms); }; class sun4_state : public sun4_base_state @@ -690,10 +690,10 @@ void sun4_base_state::debugger_w(offs_t offset, uint32_t data, uint32_t mem_mask m_mmu->insn_data_w(offset, data, mem_mask); } -void sun4_base_state::fcodes_command(int ref, const std::vector ¶ms) +void sun4_base_state::fcodes_command(int ref, const std::vector ¶ms) { #if SUN4_LOG_FCODES - if (params < 1) + if (params.length() < 1) return; bool is_on = (params[0] == "on"); diff --git a/src/mame/trs/dgn_beta.h b/src/mame/trs/dgn_beta.h index 5042de05259..04142a34e03 100644 --- a/src/mame/trs/dgn_beta.h +++ b/src/mame/trs/dgn_beta.h @@ -228,8 +228,8 @@ private: void dgnbeta_map(address_map &map); - void execute_beta_key_dump(const std::vector ¶ms); - void execute_beta_dat_log(const std::vector ¶ms); + void execute_beta_key_dump(const std::vector ¶ms); + void execute_beta_dat_log(const std::vector ¶ms); }; #endif // MAME_INCLUDES_DGN_BETA_H diff --git a/src/mame/trs/dgn_beta_m.cpp b/src/mame/trs/dgn_beta_m.cpp index b34e014a7c4..4e7907a39f1 100644 --- a/src/mame/trs/dgn_beta_m.cpp +++ b/src/mame/trs/dgn_beta_m.cpp @@ -822,14 +822,14 @@ offs_t dgn_beta_state::dgnbeta_dasm_override(std::ostream &stream, offs_t pc, co return coco_state::os9_dasm_override(stream, pc, opcodes, params); } -void dgn_beta_state::execute_beta_dat_log(const std::vector ¶ms) +void dgn_beta_state::execute_beta_dat_log(const std::vector ¶ms) { m_LogDatWrites = !m_LogDatWrites; machine().debugger().console().printf("DAT register write info set : %d\n", m_LogDatWrites); } -void dgn_beta_state::execute_beta_key_dump(const std::vector ¶ms) +void dgn_beta_state::execute_beta_key_dump(const std::vector ¶ms) { for (int idx = 0; idx < NoKeyrows; idx++) { -- cgit v1.2.3