From 6d7b1f9dbdc8d71502fe96302ec4eefc7a103f55 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 1 Feb 2017 17:38:58 +0100 Subject: [PATCH] common: move ssappendf in DisR59000asm.cpp Legacy function to print EE opcode. It doesn't worth an extra file. --- common/build/Utilities/utilities.vcxproj | 1 - .../build/Utilities/utilities.vcxproj.filters | 3 -- common/include/Utilities/StringHelpers.h | 9 ---- common/src/Utilities/CMakeLists.txt | 1 - common/src/Utilities/vssprintf.cpp | 51 ------------------- pcsx2/DebugTools/DisR5900asm.cpp | 34 +++++++++++++ 6 files changed, 34 insertions(+), 65 deletions(-) delete mode 100644 common/src/Utilities/vssprintf.cpp diff --git a/common/build/Utilities/utilities.vcxproj b/common/build/Utilities/utilities.vcxproj index 19dcae5e03..a94c324771 100644 --- a/common/build/Utilities/utilities.vcxproj +++ b/common/build/Utilities/utilities.vcxproj @@ -86,7 +86,6 @@ - diff --git a/common/build/Utilities/utilities.vcxproj.filters b/common/build/Utilities/utilities.vcxproj.filters index bcc1fdd592..f60cbd81ad 100644 --- a/common/build/Utilities/utilities.vcxproj.filters +++ b/common/build/Utilities/utilities.vcxproj.filters @@ -59,9 +59,6 @@ Source Files - - Source Files - Source Files diff --git a/common/include/Utilities/StringHelpers.h b/common/include/Utilities/StringHelpers.h index 209b9e269e..3fd00b0cbb 100644 --- a/common/include/Utilities/StringHelpers.h +++ b/common/include/Utilities/StringHelpers.h @@ -233,12 +233,3 @@ extern wxString operator+(const wxString &str1, const FastFormatUnicode &str2); extern wxString operator+(const wxChar *str1, const FastFormatUnicode &str2); extern wxString operator+(const FastFormatUnicode &str1, const wxString &str2); extern wxString operator+(const FastFormatUnicode &str1, const wxChar *str2); - - -////////////////////////////////////////////////////////////////////////////////////////// -// Custom internal sprintf functions, which are ASCII only (even in UNICODE builds) -// -// These functions are useful since they are ASCII always, even under Unicode. Typically -// even in a unicode app. - -extern void ssappendf(std::string &dest, const char *format, ...); diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt index 1767c42458..249df85468 100644 --- a/common/src/Utilities/CMakeLists.txt +++ b/common/src/Utilities/CMakeLists.txt @@ -42,7 +42,6 @@ set(UtilitiesSources StringHelpers.cpp ThreadingDialogs.cpp ThreadTools.cpp - vssprintf.cpp wxAppWithHelpers.cpp wxGuiTools.cpp wxHelpers.cpp diff --git a/common/src/Utilities/vssprintf.cpp b/common/src/Utilities/vssprintf.cpp deleted file mode 100644 index 5a130c8214..0000000000 --- a/common/src/Utilities/vssprintf.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2015 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#include "PrecompiledHeader.h" - -// Note: std::vsnprintf requires C++11 (and the function must return the total -// number of characters which would have been written even if a truncation occured) -// Note2: Code is only used in debugger (perf is not important) -static void vssappendf(std::string &dest, const char *format, va_list args) -{ - char first_try[128]; // this function is called 99% (100%?) of the times for small string - va_list args_copy; - va_copy(args_copy, args); - - s32 size = std::vsnprintf(first_try, 128, format, args_copy) + 1; - - va_end(args_copy); - - if (size < 0) - return; - if (size < 128) { - dest += first_try; - return; - } - - std::vector output; - output.resize(size + 1); - std::vsnprintf(output.data(), size, format, args); - - dest += output.data(); -} - -void ssappendf(std::string &dest, const char *format, ...) -{ - va_list args; - va_start(args, format); - vssappendf(dest, format, args); - va_end(args); -} diff --git a/pcsx2/DebugTools/DisR5900asm.cpp b/pcsx2/DebugTools/DisR5900asm.cpp index 5555f79ec4..807e0b7bd0 100644 --- a/pcsx2/DebugTools/DisR5900asm.cpp +++ b/pcsx2/DebugTools/DisR5900asm.cpp @@ -29,6 +29,40 @@ // Note only a subset of the opcodes are supported. It is intended as a cheap debugger //#define PRINT_REG_CONTENT +// Note: Perf is not important +static void vssappendf(std::string &dest, const char *format, va_list args) +{ + char first_try[128]; // this function is called 99% (100%?) of the times for small string + va_list args_copy; + va_copy(args_copy, args); + + s32 size = std::vsnprintf(first_try, 128, format, args_copy) + 1; + + va_end(args_copy); + + if (size < 0) + return; + if (size < 128) { + dest += first_try; + return; + } + + std::vector output; + output.resize(size + 1); + std::vsnprintf(output.data(), size, format, args); + + dest += output.data(); +} + +void ssappendf(std::string &dest, const char *format, ...) +{ + va_list args; + va_start(args, format); + vssappendf(dest, format, args); + va_end(args); +} + + unsigned long opcode_addr; u32 disasmOpcode; bool disSimplify;