From 6b14322fc12b2bb770817133a666035a21c04b48 Mon Sep 17 00:00:00 2001 From: Patrick Mackinlay Date: Fri, 10 Jul 2020 12:26:12 +0700 Subject: [PATCH] drcbe: fixed logging problem --- src/devices/cpu/drcbex64.cpp | 16 ++++++++++++---- src/devices/cpu/drcbex64.h | 9 --------- src/devices/cpu/drcbex86.cpp | 8 ++++---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/devices/cpu/drcbex64.cpp b/src/devices/cpu/drcbex64.cpp index 846850e4043..2a53220a1cf 100644 --- a/src/devices/cpu/drcbex64.cpp +++ b/src/devices/cpu/drcbex64.cpp @@ -398,6 +398,14 @@ const drcbe_x64::opcode_table_entry drcbe_x64::s_opcode_table_source[] = { uml::OP_ICOPYF, &drcbe_x64::op_icopyf } // ICOPYF dst,src }; +class ThrowableErrorHandler : public ErrorHandler +{ +public: + void handleError(Error err, const char *message, BaseEmitter *origin) override + { + throw emu_fatalerror("asmjit error %d: %s", err, message); + } +}; //************************************************************************** @@ -854,7 +862,7 @@ void drcbe_x64::generate(drcuml_block &block, const instruction *instlist, uint3 a.addValidationOptions(BaseEmitter::kValidationOptionIntermediate); // generate code - const char *blockname = nullptr; + std::string blockname; for (int inum = 0; inum < numinst; inum++) { const instruction &inst = instlist[inum]; @@ -873,12 +881,12 @@ void drcbe_x64::generate(drcuml_block &block, const instruction *instlist, uint3 } // extract a blockname - if (blockname == nullptr) + if (blockname.empty()) { if (inst.opcode() == OP_HANDLE) blockname = inst.param(0).handle().string(); else if (inst.opcode() == OP_HASH) - blockname = string_format("Code: mode=%d PC=%08X", (uint32_t)inst.param(0).immediate(), (offs_t)inst.param(1).immediate()).c_str(); + blockname = string_format("Code: mode=%d PC=%08X", (uint32_t)inst.param(0).immediate(), (offs_t)inst.param(1).immediate()); } // generate code @@ -892,7 +900,7 @@ void drcbe_x64::generate(drcuml_block &block, const instruction *instlist, uint3 // log it if (m_log != nullptr) - x86log_disasm_code_range(m_log, (blockname == nullptr) ? "Unknown block" : blockname, dst, dst + bytes); + x86log_disasm_code_range(m_log, (blockname.empty()) ? "Unknown block" : blockname.c_str(), dst, dst + bytes); // tell all of our utility objects that the block is finished m_hash.block_end(block); diff --git a/src/devices/cpu/drcbex64.h b/src/devices/cpu/drcbex64.h index 224fd12e879..7fa9900063b 100644 --- a/src/devices/cpu/drcbex64.h +++ b/src/devices/cpu/drcbex64.h @@ -277,13 +277,4 @@ private: using drc::drcbe_x64; -class ThrowableErrorHandler : public ErrorHandler -{ -public: - void handleError(Error err, const char *message, BaseEmitter *origin) override - { - throw emu_fatalerror("asmjit error %d: %s", err, message); - } -}; - #endif /* MAME_DEVICES_CPU_DRCBEX64_H */ diff --git a/src/devices/cpu/drcbex86.cpp b/src/devices/cpu/drcbex86.cpp index 8a43a1863c5..794d1007418 100644 --- a/src/devices/cpu/drcbex86.cpp +++ b/src/devices/cpu/drcbex86.cpp @@ -784,7 +784,7 @@ void drcbe_x86::generate(drcuml_block &block, const instruction *instlist, uint3 x86code *dst = base; // generate code - const char *blockname = nullptr; + std::string blockname; for (int inum = 0; inum < numinst; inum++) { const instruction &inst = instlist[inum]; @@ -798,12 +798,12 @@ void drcbe_x86::generate(drcuml_block &block, const instruction *instlist, uint3 } // extract a blockname - if (blockname == nullptr) + if (blockname.empty()) { if (inst.opcode() == OP_HANDLE) blockname = inst.param(0).handle().string(); else if (inst.opcode() == OP_HASH) - blockname = string_format("Code: mode=%d PC=%08X", (uint32_t)inst.param(0).immediate(), (offs_t)inst.param(1).immediate()).c_str(); + blockname = string_format("Code: mode=%d PC=%08X", (uint32_t)inst.param(0).immediate(), (offs_t)inst.param(1).immediate()); } // generate code @@ -816,7 +816,7 @@ void drcbe_x86::generate(drcuml_block &block, const instruction *instlist, uint3 // log it if (m_log != nullptr) - x86log_disasm_code_range(m_log, (blockname == nullptr) ? "Unknown block" : blockname, base, m_cache.top()); + x86log_disasm_code_range(m_log, (blockname.empty()) ? "Unknown block" : blockname.c_str(), base, m_cache.top()); // tell all of our utility objects that the block is finished m_hash.block_end(block);