From c65cdadcbf295d9a5416613e184410a32c9a13a5 Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Sun, 20 Nov 2016 10:18:13 -0500 Subject: [PATCH] Changing the MIPS DRC to not use static char buffers when disassembling --- src/devices/cpu/mips/mips3.h | 1 - src/devices/cpu/mips/mips3drc.cpp | 17 ++++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/devices/cpu/mips/mips3.h b/src/devices/cpu/mips/mips3.h index e9022aff082..a1a1270ac63 100644 --- a/src/devices/cpu/mips/mips3.h +++ b/src/devices/cpu/mips/mips3.h @@ -771,7 +771,6 @@ private: ***************************************************************************/ unsigned dasmmips3(std::ostream &stream, unsigned pc, uint32_t op); -unsigned dasmmips3(char *buffer, unsigned pc, uint32_t op); #endif /* __MIPS3_H__ */ diff --git a/src/devices/cpu/mips/mips3drc.cpp b/src/devices/cpu/mips/mips3drc.cpp index 9be286efda4..92299fa3808 100644 --- a/src/devices/cpu/mips/mips3drc.cpp +++ b/src/devices/cpu/mips/mips3drc.cpp @@ -3947,9 +3947,10 @@ void mips3_device::log_add_disasm_comment(drcuml_block *block, uint32_t pc, uint { if (m_drcuml->logging()) { - char buffer[100]; - dasmmips3(buffer, pc, op); - block->append_comment("%08X: %s", pc, buffer); // comment + std::ostringstream stream; + dasmmips3(stream, pc, op); + const std::string stream_string = stream.str(); + block->append_comment("%08X: %s", pc, stream_string.c_str()); // comment } } @@ -4077,19 +4078,21 @@ void mips3_device::log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desc /* output each descriptor */ for ( ; desclist != nullptr; desclist = desclist->next()) { - char buffer[100]; + std::ostringstream buffer; /* disassemle the current instruction and output it to the log */ if (drcuml->logging() || drcuml->logging_native()) { if (desclist->flags & OPFLAG_VIRTUAL_NOOP) - strcpy(buffer, ""); + buffer << ""; else dasmmips3(buffer, desclist->pc, desclist->opptr.l[0]); } else - strcpy(buffer, "???"); - drcuml->log_printf("%08X [%08X] t:%08X f:%s: %-30s", desclist->pc, desclist->physpc, desclist->targetpc, log_desc_flags_to_string(desclist->flags), buffer); + buffer << "???"; + + const std::string buffer_string = buffer.str(); + drcuml->log_printf("%08X [%08X] t:%08X f:%s: %-30s", desclist->pc, desclist->physpc, desclist->targetpc, log_desc_flags_to_string(desclist->flags), buffer_string.c_str()); /* output register states */ log_register_list(drcuml, "use", desclist->regin, nullptr);