From 11ce4f0eded26fa9b0170c3c8c36c5111d44b5b4 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 13 Feb 2021 14:31:35 -0500 Subject: Stop converting debugger console commands to all lowercase before parsing them. Case insensitivity has been preserved for command names, CPU and region tags and certain symbolic parameters (as well as expressions, which were treated as case-insensitive in other contexts), but filenames and character constants are no longer automatically lowercased. * debugcmd.cpp, debugcon.cpp: Remove some superfluous c_str() calls * debugcmd.cpp: Remove local member referencing debugger_cpu, which is accessed only rarely since the console now tracks the visible CPU --- src/emu/debug/debugcmd.cpp | 95 +++++++++++++++++++++++----------------------- src/emu/debug/debugcmd.h | 1 - src/emu/debug/debugcon.cpp | 16 ++++---- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 65a0218eddb..2b631e99ad3 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -111,12 +111,11 @@ u64 debugger_commands::cheat_read_extended(const cheat_system *cheatsys, address debugger_commands::debugger_commands(running_machine& machine, debugger_cpu& cpu, debugger_console& console) : m_machine(machine) - , m_cpu(cpu) , m_console(console) { m_global_array = std::make_unique(MAX_GLOBALS); - symbol_table &symtable = m_cpu.global_symtable(); + symbol_table &symtable = cpu.global_symtable(); /* add a few simple global functions */ using namespace std::placeholders; @@ -541,7 +540,7 @@ bool debugger_commands::validate_cpu_parameter(const char *param, device_t *&res } /* first look for a tag match */ - result = m_machine.root_device().subdevice(param); + result = m_machine.root_device().subdevice(strmakelower(param)); if (result) return true; @@ -609,7 +608,7 @@ bool debugger_commands::validate_cpu_space_parameter(const char *param, int spac bool debugger_commands::validate_memory_region_parameter(const std::string ¶m, memory_region *&result) { auto ®ions = m_machine.memory().regions(); - auto iter = regions.find(param); + auto iter = regions.find(strmakelower(param)); if(iter == regions.end()) { m_console.printf("No matching memory region found for '%s'\n", param); return false; @@ -873,10 +872,10 @@ void debugger_commands::execute_tracesym(int ref, const std::vector for (int i = 0; i < params.size(); i++) { // find this symbol - symbol_entry *sym = m_console.visible_symtable().find(params[i].c_str()); + symbol_entry *sym = m_console.visible_symtable().find(strmakelower(params[i]).c_str()); if (!sym) { - m_console.printf("Unknown symbol: %s\n", params[i].c_str()); + m_console.printf("Unknown symbol: %s\n", params[i]); return; } @@ -1108,7 +1107,7 @@ void debugger_commands::execute_ignore(int ref, const std::vector & /* special message for none */ if (buffer.empty()) buffer = string_format("Not currently ignoring any devices"); - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); } /* otherwise clear the ignore flag on all requested CPUs */ @@ -1171,7 +1170,7 @@ void debugger_commands::execute_observe(int ref, const std::vector /* special message for none */ if (buffer.empty()) buffer = string_format("Not currently observing any devices"); - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); } /* otherwise set the ignore flag on all requested CPUs */ @@ -1219,7 +1218,7 @@ void debugger_commands::execute_suspend(int ref, const std::vector /* special message for none */ if (buffer.empty()) buffer = string_format("No currently suspended devices"); - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); } else { @@ -1278,7 +1277,7 @@ void debugger_commands::execute_resume(int ref, const std::vector & /* special message for none */ if (buffer.empty()) buffer = string_format("No currently suspended devices"); - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); } else { @@ -1396,7 +1395,7 @@ void debugger_commands::execute_comment_commit(int ref, const std::vector ¶ms) { - if (m_cpu.comment_save()) + if (m_machine.debugger().cpu().comment_save()) m_console.printf("Comment successfully saved\n"); else m_console.printf("Comment not saved\n"); @@ -1547,7 +1546,7 @@ void debugger_commands::execute_bplist(int ref, const std::vector & buffer.append(string_format(" if %s", bp.condition())); if (std::string(bp.action()).compare("") != 0) buffer.append(string_format(" do %s", bp.action())); - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); printed++; } } @@ -1583,11 +1582,11 @@ void debugger_commands::execute_wpset(int ref, const std::vector &p return; /* param 3 is the type */ - if (params[2] == "r") + if (!core_stricmp(params[2].c_str(), "r")) type = read_or_write::READ; - else if (params[2] == "w") + else if (!core_stricmp(params[2].c_str(), "w")) type = read_or_write::WRITE; - else if (params[2] == "rw" || params[2] == "wr") + else if (!core_stricmp(params[2].c_str(), "rw") || !core_stricmp(params[2].c_str(), "wr")) type = read_or_write::READWRITE; else { @@ -1712,7 +1711,7 @@ void debugger_commands::execute_wplist(int ref, const std::vector & buffer.append(string_format(" if %s", wp->condition())); if (std::string(wp->action()).compare("") != 0) buffer.append(string_format(" do %s", wp->action())); - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); printed++; } } @@ -1845,7 +1844,7 @@ void debugger_commands::execute_rplist(int ref, const std::vector & buffer = string_format("%c%4X if %s", rp.enabled() ? ' ' : 'D', rp.index(), rp.condition()); if (rp.action() != nullptr) buffer.append(string_format(" do %s", rp.action())); - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); printed++; } } @@ -1975,7 +1974,7 @@ void debugger_commands::execute_save(int ref, const std::vector &pa f = fopen(params[0].c_str(), "wb"); if (!f) { - m_console.printf("Error opening file '%s'\n", params[0].c_str()); + m_console.printf("Error opening file '%s'\n", params[0]); return; } @@ -2067,7 +2066,7 @@ void debugger_commands::execute_saveregion(int ref, const std::vectorbase() + offset, 1, length, f); @@ -2099,7 +2098,7 @@ void debugger_commands::execute_load(int ref, const std::vector &pa f.open(params[0], std::ifstream::in | std::ifstream::binary); if (f.fail()) { - m_console.printf("Error opening file '%s'\n", params[0].c_str()); + m_console.printf("Error opening file '%s'\n", params[0]); return; } @@ -2214,7 +2213,7 @@ void debugger_commands::execute_loadregion(int ref, const std::vector &pa FILE* f = fopen(params[0].c_str(), "w"); if (!f) { - m_console.printf("Error opening file '%s'\n", params[0].c_str()); + m_console.printf("Error opening file '%s'\n", params[0]); return; } @@ -2431,7 +2430,7 @@ void debugger_commands::execute_strdump(int ref, const std::vector FILE *f = fopen(params[0].c_str(), "w"); if (!f) { - m_console.printf("Error opening file '%s'\n", params[0].c_str()); + m_console.printf("Error opening file '%s'\n", params[0]); return; } @@ -2601,9 +2600,10 @@ void debugger_commands::execute_cheatinit(int ref, const std::vector 1) ? CHEAT_EQUALTO : CHEAT_EQUAL; - else if (params[0] == "notequal" || params[0] == "ne") + else if (!core_stricmp(params[0].c_str(), "notequal") || !core_stricmp(params[0].c_str(), "ne")) condition = (params.size() > 1) ? CHEAT_NOTEQUALTO : CHEAT_NOTEQUAL; - else if (params[0] == "decrease" || params[0] == "de" || params[0] == "-") + else if (!core_stricmp(params[0].c_str(), "decrease") || !core_stricmp(params[0].c_str(), "de") || params[0] == "-") condition = (params.size() > 1) ? CHEAT_DECREASEOF : CHEAT_DECREASE; - else if (params[0] == "increase" || params[0] == "in" || params[0] == "+") + else if (!core_stricmp(params[0].c_str(), "increase") || !core_stricmp(params[0].c_str(), "in") || params[0] == "+") condition = (params.size() > 1) ? CHEAT_INCREASEOF : CHEAT_INCREASE; - else if (params[0] == "decreaseorequal" || params[0] == "deeq") + else if (!core_stricmp(params[0].c_str(), "decreaseorequal") || !core_stricmp(params[0].c_str(), "deeq")) condition = CHEAT_DECREASE_OR_EQUAL; - else if (params[0] == "increaseorequal" || params[0] == "ineq") + else if (!core_stricmp(params[0].c_str(), "increaseorequal") || !core_stricmp(params[0].c_str(), "ineq")) condition = CHEAT_INCREASE_OR_EQUAL; - else if (params[0] == "smallerof" || params[0] == "lt" || params[0] == "<") + else if (!core_stricmp(params[0].c_str(), "smallerof") || !core_stricmp(params[0].c_str(), "lt") || params[0] == "<") condition = CHEAT_SMALLEROF; - else if (params[0] == "greaterof" || params[0] == "gt" || params[0] == ">") + else if (!core_stricmp(params[0].c_str(), "greaterof") || !core_stricmp(params[0].c_str(), "gt") || params[0] == ">") condition = CHEAT_GREATEROF; - else if (params[0] == "changedby" || params[0] == "ch" || params[0] == "~") + else if (!core_stricmp(params[0].c_str(), "changedby") || !core_stricmp(params[0].c_str(), "ch") || params[0] == "~") condition = CHEAT_CHANGEDBY; else { @@ -3389,7 +3390,7 @@ void debugger_commands::execute_trace_internal(int ref, const std::vectordebug()->trace(f, trace_over, detect_loops, logerror, action); if (f) - m_console.printf("Tracing CPU '%s' to file %s\n", cpu->tag(), filename.c_str()); + m_console.printf("Tracing CPU '%s' to file %s\n", cpu->tag(), filename); else m_console.printf("Stopped tracing on CPU '%s'\n", cpu->tag()); } @@ -3452,7 +3453,7 @@ void debugger_commands::execute_traceover(int ref, const std::vector ¶ms) { - m_cpu.flush_traces(); + m_machine.debugger().cpu().flush_traces(); } @@ -3808,7 +3809,7 @@ void debugger_commands::execute_symlist(int ref, const std::vector } else { - symtable = &m_cpu.global_symtable(); + symtable = &m_machine.debugger().cpu().global_symtable(); m_console.printf("Global symbols:\n"); } @@ -3899,7 +3900,7 @@ void debugger_commands::execute_mount(int ref, const std::vector &p } } if (!done) - m_console.printf("There is no image device :%s\n", params[0].c_str()); + m_console.printf("There is no image device :%s\n", params[0]); } /*------------------------------------------------- @@ -3963,7 +3964,7 @@ void debugger_commands::execute_dumpkbd(int ref, const std::vector if (file != nullptr) fprintf(file, "%s\n", buffer.c_str()); else - m_console.printf("%s\n", buffer.c_str()); + m_console.printf("%s\n", buffer); // cleanup if (file != nullptr) diff --git a/src/emu/debug/debugcmd.h b/src/emu/debug/debugcmd.h index 0fad46d7009..08f90e54a16 100644 --- a/src/emu/debug/debugcmd.h +++ b/src/emu/debug/debugcmd.h @@ -180,7 +180,6 @@ private: void execute_dumpkbd(int ref, const std::vector ¶ms); running_machine& m_machine; - debugger_cpu& m_cpu; debugger_console& m_console; std::unique_ptr m_global_array; diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp index b282b000283..0eea46d5a6d 100644 --- a/src/emu/debug/debugcon.cpp +++ b/src/emu/debug/debugcon.cpp @@ -146,7 +146,7 @@ void debugger_console::execute_condump(int ref, const std::vector& mode = "w"; /* opening for append? */ - if ((filename[0] == '>') && (filename[1] == '>')) + if (filename.length() >= 2 && filename[0] == '>' && filename[1] == '>') { mode = "a"; filename = filename.substr(2); @@ -155,7 +155,7 @@ void debugger_console::execute_condump(int ref, const std::vector& FILE* f = fopen(filename.c_str(), mode); if (!f) { - printf("Error opening file '%s'\n", filename.c_str()); + printf("Error opening file '%s'\n", filename); return; } @@ -166,7 +166,7 @@ void debugger_console::execute_condump(int ref, const std::vector& } fclose(f); - printf("Wrote console contents to '%s'\n", filename.c_str()); + printf("Wrote console contents to '%s'\n", filename); } //------------------------------------------------- @@ -275,7 +275,7 @@ CMDERR debugger_console::internal_execute_command(bool execute, int params, char len = strlen(command); debug_command *found = nullptr; for (debug_command &cmd : m_commandlist) - if (!strncmp(command, cmd.command, len)) + if (!core_strnicmp(command, cmd.command, len)) { foundcount++; found = &cmd; @@ -363,7 +363,7 @@ CMDERR debugger_console::internal_parse_command(const std::string &original_comm case '+': if (parendex == 0 && paramcount == 1 && p[1] == '+') isexpr = true; *p = c; break; case '=': if (parendex == 0 && paramcount == 1) isexpr = true; *p = c; break; case 0: foundend = true; break; - default: *p = tolower(u8(c)); break; + default: *p = c; break; } } } @@ -419,7 +419,7 @@ CMDERR debugger_console::execute_command(const std::string &command, bool echo) { /* echo if requested */ if (echo) - printf(">%s\n", command.c_str()); + printf(">%s\n", command); /* parse and execute */ const CMDERR result = internal_parse_command(command, true); @@ -428,9 +428,9 @@ CMDERR debugger_console::execute_command(const std::string &command, bool echo) if (result.error_class() != CMDERR::NONE) { if (!echo) - printf(">%s\n", command.c_str()); + printf(">%s\n", command); printf(" %*s^\n", result.error_offset(), ""); - printf("%s\n", cmderr_to_string(result).c_str()); + printf("%s\n", cmderr_to_string(result)); } /* update all views */ -- cgit v1.2.3