From 88a8796b1de60ef7fd6aa10eaaa11220891751b9 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 25 Jul 2024 14:12:57 -0700 Subject: [PATCH] Fix double printing in StressLog and simplify stresslog macros (#105420) --- src/coreclr/gc/env/gcenv.h | 291 +++-------- src/coreclr/inc/stresslog.h | 457 +++--------------- src/coreclr/nativeaot/Runtime/inc/stressLog.h | 233 +++------ src/coreclr/vm/threads.cpp | 5 +- 4 files changed, 183 insertions(+), 803 deletions(-) diff --git a/src/coreclr/gc/env/gcenv.h b/src/coreclr/gc/env/gcenv.h index f90efe93241da..8a796a0ab9a8e 100644 --- a/src/coreclr/gc/env/gcenv.h +++ b/src/coreclr/gc/env/gcenv.h @@ -55,72 +55,38 @@ LOGALWAYS(msg); \ } while(0) +#define STRESS_LOG_WRITE(facility, level, msg, ...) do { \ + if (StressLog::LogOn(facility, level)) \ + StressLog::LogMsg(facility, level, StressLogMsg(msg, __VA_ARGS__)); \ + LOG((facility, level, msg, __VA_ARGS__)); \ + } while(0) + #define STRESS_LOG0(facility, level, msg) do { \ if (StressLog::LogOn(facility, level)) \ StressLog::LogMsg(level, facility, StressLogMsg(msg)); \ LOG((facility, level, msg)); \ } while(0) -#define STRESS_LOG1(facility, level, msg, data1) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, \ - StressLogMsg(msg, (void*)(size_t)(data1))); \ - LOG((facility, level, msg, data1)); \ - } while(0) +#define STRESS_LOG1(facility, level, msg, data1) \ + STRESS_LOG_WRITE(facility, level, msg, data1) -#define STRESS_LOG2(facility, level, msg, data1, data2) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, \ - StressLogMsg(msg, (void*)(size_t)(data1), (void*)(size_t)(data2))); \ - LOG((facility, level, msg, data1, data2)); \ - } while(0) +#define STRESS_LOG2(facility, level, msg, data1, data2) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2) -#define STRESS_LOG2_CHECK_EE_STARTED(facility, level, msg, data1, data2) do { \ - if (g_fEEStarted) \ - STRESS_LOG2(facility, level, msg, data1, data2); \ - else \ - LOG((facility, level, msg, data1, data2)); \ - } while(0) - -#define STRESS_LOG3(facility, level, msg, data1, data2, data3) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, \ - StressLogMsg(msg, \ - (void*)(size_t)(data1),(void*)(size_t)(data2),(void*)(size_t)(data3))); \ - LOG((facility, level, msg, data1, data2, data3)); \ - } while(0) +#define STRESS_LOG3(facility, level, msg, data1, data2, data3) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3) -#define STRESS_LOG4(facility, level, msg, data1, data2, data3, data4) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, \ - StressLogMsg(msg, (void*)(size_t)(data1),(void*)(size_t)(data2), \ - (void*)(size_t)(data3),(void*)(size_t)(data4))); \ - LOG((facility, level, msg, data1, data2, data3, data4)); \ - } while(0) +#define STRESS_LOG4(facility, level, msg, data1, data2, data3, data4) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4) -#define STRESS_LOG5(facility, level, msg, data1, data2, data3, data4, data5) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 5, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5)); \ - } while(0) +#define STRESS_LOG5(facility, level, msg, data1, data2, data3, data4, data5) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5) -#define STRESS_LOG6(facility, level, msg, data1, data2, data3, data4, data5, data6) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 6, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5, data6)); \ - } while(0) +#define STRESS_LOG6(facility, level, msg, data1, data2, data3, data4, data5, data6) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5, data6) -#define STRESS_LOG7(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 7, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6), (void*)(size_t)(data7)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5, data6, data7)); \ - } while(0) +#define STRESS_LOG7(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) #define LOGALWAYS(msg) @@ -205,200 +171,53 @@ struct StressLogMsg const char* m_format; void* m_args[16]; - StressLogMsg(const char* format) : m_cArgs(0), m_format(format) - { - } - - template < typename T1 > - StressLogMsg(const char* format, T1 data1) : m_cArgs(1), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - } - - template < typename T1, typename T2 > - StressLogMsg(const char* format, T1 data1, T2 data2) : m_cArgs(2), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - } - - template < typename T1, typename T2, typename T3 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3) : m_cArgs(3), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - } - - template < typename T1, typename T2, typename T3, typename T4 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4) : m_cArgs(4), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5) : m_cArgs(5), m_format(format) + template + static void* ConvertArgument(T arg) { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; + static_assert_no_msg(sizeof(T) <= sizeof(void*)); + return (void*)(size_t)arg; } - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6) : m_cArgs(6), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7) : m_cArgs(7), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8) : m_cArgs(8), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9) : m_cArgs(9), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10) : m_cArgs(10), m_format(format) + StressLogMsg(const char* format) : m_cArgs(0), m_format(format) { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; } - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11) : m_cArgs(11), m_format(format) + template + StressLogMsg(const char* format, Ts... args) + : m_cArgs(sizeof...(args)) + , m_format(format) + , m_args{ ConvertArgument(args)... } { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; + static_assert_no_msg(sizeof...(args) <= ARRAY_SIZE(m_args)); } +}; - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12) : m_cArgs(12), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; - m_args[11] = (void*)(size_t)data12; - } +template<> +void* StressLogMsg::ConvertArgument(float arg) = delete; +#if TARGET_64BIT +template<> +inline void* StressLogMsg::ConvertArgument(double arg) +{ + return (void*)(size_t)(*((uint64_t*)&arg)); +} +#else +template<> +void* StressLogMsg::ConvertArgument(double arg) = delete; - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13) : m_cArgs(13), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; - m_args[11] = (void*)(size_t)data12; - m_args[12] = (void*)(size_t)data13; - } +// COMPAT: Truncate 64-bit integer arguments to 32-bit +template<> +inline void* StressLogMsg::ConvertArgument(uint64_t arg) +{ + return (void*)(size_t)arg; +} - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13, T14 data14) : m_cArgs(14), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*) && sizeof(T14) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; - m_args[11] = (void*)(size_t)data12; - m_args[12] = (void*)(size_t)data13; - m_args[13] = (void*)(size_t)data14; - } -}; +template<> +inline void* StressLogMsg::ConvertArgument(int64_t arg) +{ + return (void*)(size_t)arg; +} +#endif class StressLog { diff --git a/src/coreclr/inc/stresslog.h b/src/coreclr/inc/stresslog.h index ef8ecb1462986..39a0d6c5be370 100644 --- a/src/coreclr/inc/stresslog.h +++ b/src/coreclr/inc/stresslog.h @@ -71,126 +71,36 @@ LOGALWAYS(msg); \ } while(0) -#define STRESS_LOG0(facility, level, msg) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 0, msg); \ - LOG((facility, level, msg)); \ +#define STRESS_LOG_WRITE(facility, level, msg, ...) do { \ + if (StressLog::StressLogOn(facility, level)) \ + StressLog::LogMsgOL(facility, level, msg, __VA_ARGS__); \ } while(0) -#define STRESS_LOG1(facility, level, msg, data1) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 1, msg, (void*)(size_t)(data1));\ - LOG((facility, level, msg, data1)); \ +#define STRESS_LOG0(facility, level, msg) do { \ + if (StressLog::StressLogOn(facility, level)) \ + StressLog::LogMsg(facility, level, 0, msg); \ } while(0) -#define STRESS_LOG2(facility, level, msg, data1, data2) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 2, msg, \ - (void*)(size_t)(data1), (void*)(size_t)(data2)); \ - LOG((facility, level, msg, data1, data2)); \ - } while(0) - -#define STRESS_LOG2_CHECK_EE_STARTED(facility, level, msg, data1, data2) do { \ - if (g_fEEStarted) \ - STRESS_LOG2(facility, level, msg, data1, data2); \ - else \ - LOG((facility, level, msg, data1, data2)); \ - } while(0) +#define STRESS_LOG1(facility, level, msg, data1) \ + STRESS_LOG_WRITE(facility, level, msg, data1) -#define STRESS_LOG3(facility, level, msg, data1, data2, data3) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 3, msg, \ - (void*)(size_t)(data1),(void*)(size_t)(data2),(void*)(size_t)(data3)); \ - LOG((facility, level, msg, data1, data2, data3)); \ - } while(0) +#define STRESS_LOG2(facility, level, msg, data1, data2) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2) -#define STRESS_LOG4(facility, level, msg, data1, data2, data3, data4) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 4, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4)); \ - LOG((facility, level, msg, data1, data2, data3, data4)); \ - } while(0) +#define STRESS_LOG3(facility, level, msg, data1, data2, data3) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3) -#define STRESS_LOG5(facility, level, msg, data1, data2, data3, data4, data5) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 5, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5)); \ - } while(0) +#define STRESS_LOG4(facility, level, msg, data1, data2, data3, data4) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4) -#define STRESS_LOG6(facility, level, msg, data1, data2, data3, data4, data5, data6) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 6, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5, data6)); \ - } while(0) +#define STRESS_LOG5(facility, level, msg, data1, data2, data3, data4, data5) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5) -#define STRESS_LOG7(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) do { \ - if (StressLog::LogOn(facility, level)) \ - StressLog::LogMsg(level, facility, 7, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6), (void*)(size_t)(data7)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5, data6, data7)); \ - } while(0) +#define STRESS_LOG6(facility, level, msg, data1, data2, data3, data4, data5, data6) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5, data6) -#define STRESS_LOG_COND0(facility, level, cond, msg) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 0, msg); \ - LOG((facility, level, msg)); \ - } while(0) - -#define STRESS_LOG_COND1(facility, level, cond, msg, data1) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 1, msg, (void*)(size_t)(data1)); \ - LOG((facility, level, msg, data1)); \ - } while(0) - -#define STRESS_LOG_COND2(facility, level, cond, msg, data1, data2) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 2, msg, \ - (void*)(size_t)(data1), (void*)(size_t)(data2)); \ - LOG((facility, level, msg, data1, data2)); \ - } while(0) - -#define STRESS_LOG_COND3(facility, level, cond, msg, data1, data2, data3) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 3, msg, \ - (void*)(size_t)(data1),(void*)(size_t)(data2),(void*)(size_t)(data3)); \ - LOG((facility, level, msg, data1, data2, data3)); \ - } while(0) - -#define STRESS_LOG_COND4(facility, level, cond, msg, data1, data2, data3, data4) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 4, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4)); \ - LOG((facility, level, msg, data1, data2, data3, data4)); \ - } while(0) - -#define STRESS_LOG_COND5(facility, level, cond, msg, data1, data2, data3, data4, data5) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 5, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5)); \ - } while(0) - -#define STRESS_LOG_COND6(facility, level, cond, msg, data1, data2, data3, data4, data5, data6) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 6, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5, data6)); \ - } while(0) - -#define STRESS_LOG_COND7(facility, level, cond, msg, data1, data2, data3, data4, data5, data6, data7) do { \ - if (StressLog::LogOn(facility, level) && (cond)) \ - StressLog::LogMsg(level, facility, 7, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6), (void*)(size_t)(data7)); \ - LOG((facility, level, msg, data1, data2, data3, data4, data5, data6, data7)); \ - } while(0) +#define STRESS_LOG7(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) #define STRESS_LOG_RESERVE_MEM(numChunks) do { \ if (StressLog::StressLogOn(LF_ALL, LL_ALWAYS)) \ @@ -408,6 +318,13 @@ class StressLog { static void AddModule(uint8_t* moduleBase); + template + static void* ConvertArgument(T arg) + { + static_assert_no_msg(sizeof(T) <= sizeof(void*)); + return (void*)(size_t)arg; + } + // Support functions for STRESS_LOG_VA // We disable the warning "conversion from 'type' to 'type' of greater size" since everything will // end up on the stack, and LogMsg will know the size of the variable based on the format string. @@ -415,105 +332,20 @@ class StressLog { #pragma warning( push ) #pragma warning( disable : 4312 ) #endif + static void LogMsgOL(const char* format) { LogMsg(LL_ALWAYS, LF_GC, 0, format); } - template < typename T1 > - static void LogMsgOL(const char* format, T1 data1) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 1, format, (void*)(size_t)data1); - } - - template < typename T1, typename T2 > - static void LogMsgOL(const char* format, T1 data1, T2 data2) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 2, format, (void*)(size_t)data1, (void*)(size_t)data2); - } - - template < typename T1, typename T2, typename T3 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 3, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3); - } - - template < typename T1, typename T2, typename T3, typename T4 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 4, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 5, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 6, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 7, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 8, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 9, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 10, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11) + template + static void LogMsgOL(const char* format, Ts... args) { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 11, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11); + LogMsg(LL_ALWAYS, LF_GC, sizeof...(args), format, ConvertArgument(args)...); } - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12) + template + static void LogMsgOL(unsigned facility, unsigned level, const char* format, Ts... args) { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 12, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11, (void*)(size_t)data12); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 13, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11, (void*)(size_t)data12, (void*)(size_t)data13); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13, T14 data14) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*) && sizeof(T14) <= sizeof(void*)); - LogMsg(LL_ALWAYS, LF_GC, 14, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11, (void*)(size_t)data12, (void*)(size_t)data13, (void*)(size_t)data14); + LogMsg(level, facility, sizeof...(args), format, ConvertArgument(args)...); } #ifdef _MSC_VER @@ -538,6 +370,34 @@ typedef USHORT static StressLog theLog; // We only have one log, and this is it }; + +template<> +void* StressLog::ConvertArgument(float arg) = delete; + +#if TARGET_64BIT +template<> +inline void* StressLog::ConvertArgument(double arg) +{ + return (void*)(size_t)(*((uint64_t*)&arg)); +} +#else +template<> +void* StressLog::ConvertArgument(double arg) = delete; + +// COMPAT: Truncate 64-bit integer arguments to 32-bit +template<> +inline void* StressLog::ConvertArgument(uint64_t arg) +{ + return (void*)(size_t)arg; +} + +template<> +inline void* StressLog::ConvertArgument(int64_t arg) +{ + return (void*)(size_t)arg; +} +#endif + #ifndef STRESS_LOG_ANALYZER typedef Holder> StressLogLockHolder; #endif //!STRESS_LOG_ANALYZER @@ -1009,193 +869,13 @@ struct StressLogMsg { } - template < typename T1 > - StressLogMsg(const char* format, T1 data1) : m_cArgs(1), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - } - - template < typename T1, typename T2 > - StressLogMsg(const char* format, T1 data1, T2 data2) : m_cArgs(2), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - } - - template < typename T1, typename T2, typename T3 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3) : m_cArgs(3), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - } - - template < typename T1, typename T2, typename T3, typename T4 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4) : m_cArgs(4), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5) : m_cArgs(5), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6) : m_cArgs(6), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7) : m_cArgs(7), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8) : m_cArgs(8), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9) : m_cArgs(9), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10) : m_cArgs(10), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11) : m_cArgs(11), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12) : m_cArgs(12), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; - m_args[11] = (void*)(size_t)data12; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13) : m_cArgs(13), m_format(format) - { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; - m_args[11] = (void*)(size_t)data12; - m_args[12] = (void*)(size_t)data13; - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14 > - StressLogMsg(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13, T14 data14) : m_cArgs(14), m_format(format) + template + StressLogMsg(const char* format, Ts... args) + : m_cArgs(sizeof...(args)) + , m_format(format) + , m_args{ StressLog::ConvertArgument(args)... } { - static_assert_no_msg(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*) && sizeof(T14) <= sizeof(void*)); - m_args[0] = (void*)(size_t)data1; - m_args[1] = (void*)(size_t)data2; - m_args[2] = (void*)(size_t)data3; - m_args[3] = (void*)(size_t)data4; - m_args[4] = (void*)(size_t)data5; - m_args[5] = (void*)(size_t)data6; - m_args[6] = (void*)(size_t)data7; - m_args[7] = (void*)(size_t)data8; - m_args[8] = (void*)(size_t)data9; - m_args[9] = (void*)(size_t)data10; - m_args[10] = (void*)(size_t)data11; - m_args[11] = (void*)(size_t)data12; - m_args[12] = (void*)(size_t)data13; - m_args[13] = (void*)(size_t)data14; + static_assert_no_msg(sizeof...(args) <= ARRAY_SIZE(m_args)); } }; @@ -1205,7 +885,6 @@ struct StressLogMsg #define STRESS_LOG0(facility, level, msg) do { } while(0) #define STRESS_LOG1(facility, level, msg, data1) do { } while(0) #define STRESS_LOG2(facility, level, msg, data1, data2) do { } while(0) -#define STRESS_LOG2_CHECK_EE_STARTED(facility, level, msg, data1, data2)do { } while(0) #define STRESS_LOG3(facility, level, msg, data1, data2, data3) do { } while(0) #define STRESS_LOG4(facility, level, msg, data1, data2, data3, data4) do { } while(0) #define STRESS_LOG5(facility, level, msg, data1, data2, data3, data4, data5) do { } while(0) diff --git a/src/coreclr/nativeaot/Runtime/inc/stressLog.h b/src/coreclr/nativeaot/Runtime/inc/stressLog.h index 9c78a120bfac6..fc031897f492d 100644 --- a/src/coreclr/nativeaot/Runtime/inc/stressLog.h +++ b/src/coreclr/nativeaot/Runtime/inc/stressLog.h @@ -109,103 +109,36 @@ enum LogFacilitiesEnum: unsigned int { StressLog::LogMsgOL(_Args msg); \ } WHILE_0 -#define STRESS_LOG0(facility, level, msg) do { \ - if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 0, msg); \ - } WHILE_0 \ - -#define STRESS_LOG1(facility, level, msg, data1) do { \ - if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 1, msg, (void*)(size_t)(data1)); \ - } WHILE_0 - -#define STRESS_LOG2(facility, level, msg, data1, data2) do { \ - if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 2, msg, \ - (void*)(size_t)(data1), (void*)(size_t)(data2)); \ - } WHILE_0 - -#define STRESS_LOG3(facility, level, msg, data1, data2, data3) do { \ - if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 3, msg, \ - (void*)(size_t)(data1),(void*)(size_t)(data2),(void*)(size_t)(data3)); \ - } WHILE_0 - -#define STRESS_LOG4(facility, level, msg, data1, data2, data3, data4) do { \ - if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 4, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4)); \ - } WHILE_0 - -#define STRESS_LOG5(facility, level, msg, data1, data2, data3, data4, data5) do { \ - if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 5, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5)); \ - } WHILE_0 - -#define STRESS_LOG6(facility, level, msg, data1, data2, data3, data4, data5, data6) do { \ +#define STRESS_LOG_WRITE(facility, level, msg, ...) do { \ if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 6, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6)); \ + StressLog::LogMsgOL(facility, msg, __VA_ARGS__); \ } WHILE_0 -#define STRESS_LOG7(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) do { \ - if (StressLog::StressLogOn(facility, level)) \ - StressLog::LogMsg(facility, 7, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6), (void*)(size_t)(data7)); \ - } WHILE_0 - -#define STRESS_LOG_COND0(facility, level, msg) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ +#define STRESS_LOG0(facility, level, msg) do { \ + if (StressLog::StressLogOn(facility, level)) \ StressLog::LogMsg(facility, 0, msg); \ - } WHILE_0 + } WHILE_0 \ -#define STRESS_LOG_COND1(facility, level, cond, msg, data1) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ - StressLog::LogMsg(facility, 1, msg, (void*)(size_t)(data1)); \ - } WHILE_0 +#define STRESS_LOG1(facility, level, msg, data1) \ + STRESS_LOG_WRITE(facility, level, msg, data1) -#define STRESS_LOG_COND2(facility, level, cond, msg, data1, data2) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ - StressLog::LogMsg(facility, 2, msg, \ - (void*)(size_t)(data1), (void*)(size_t)(data2)); \ - } WHILE_0 +#define STRESS_LOG2(facility, level, msg, data1, data2) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2) -#define STRESS_LOG_COND3(facility, level, cond, msg, data1, data2, data3) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ - StressLog::LogMsg(facility, 3, msg, \ - (void*)(size_t)(data1),(void*)(size_t)(data2),(void*)(size_t)(data3)); \ - } WHILE_0 +#define STRESS_LOG3(facility, level, msg, data1, data2, data3) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3) -#define STRESS_LOG_COND4(facility, level, cond, msg, data1, data2, data3, data4) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ - StressLog::LogMsg(facility, 4, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4)); \ - } WHILE_0 +#define STRESS_LOG4(facility, level, msg, data1, data2, data3, data4) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4) -#define STRESS_LOG_COND5(facility, level, cond, msg, data1, data2, data3, data4, data5) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ - StressLog::LogMsg(facility, 5, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5)); \ - } WHILE_0 +#define STRESS_LOG5(facility, level, msg, data1, data2, data3, data4, data5) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5) -#define STRESS_LOG_COND6(facility, level, cond, msg, data1, data2, data3, data4, data5, data6) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ - StressLog::LogMsg(facility, 6, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6)); \ - } WHILE_0 +#define STRESS_LOG6(facility, level, msg, data1, data2, data3, data4, data5, data6) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5, data6) -#define STRESS_LOG_COND7(facility, level, cond, msg, data1, data2, data3, data4, data5, data6, data7) do { \ - if (StressLog::StressLogOn(facility, level) && (cond)) \ - StressLog::LogMsg(facility, 7, msg, (void*)(size_t)(data1), \ - (void*)(size_t)(data2),(void*)(size_t)(data3),(void*)(size_t)(data4), \ - (void*)(size_t)(data5), (void*)(size_t)(data6), (void*)(size_t)(data7)); \ - } WHILE_0 +#define STRESS_LOG7(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) \ + STRESS_LOG_WRITE(facility, level, msg, data1, data2, data3, data4, data5, data6, data7) #define STRESS_LOG_RESERVE_MEM(numChunks) do { \ if (StressLog::StressLogOn(LF_ALL, LL_ALWAYS)) \ @@ -375,105 +308,24 @@ class StressLog { #pragma warning( push ) #pragma warning( disable : 4312 ) #endif - static void LogMsgOL(const char* format) - { LogMsg(LF_GC, 0, format); } - - template < typename T1 > - static void LogMsgOL(const char* format, T1 data1) - { - C_ASSERT(sizeof(T1) <= sizeof(void*)); - LogMsg(LF_GC, 1, format, (void*)(size_t)data1); - } - - template < typename T1, typename T2 > - static void LogMsgOL(const char* format, T1 data1, T2 data2) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*)); - LogMsg(LF_GC, 2, format, (void*)(size_t)data1, (void*)(size_t)data2); - } - - template < typename T1, typename T2, typename T3 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*)); - LogMsg(LF_GC, 3, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3); - } - - template < typename T1, typename T2, typename T3, typename T4 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*)); - LogMsg(LF_GC, 4, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*)); - LogMsg(LF_GC, 5, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5); - } - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6) + template + static void* ConvertArgument(T arg) { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*)); - LogMsg(LF_GC, 6, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6); + C_ASSERT(sizeof(T) <= sizeof(void*)); + return (void*)(size_t)arg; } - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7) + template + static void LogMsgOL(const char* format, Ts... args) { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*)); - LogMsg(LF_GC, 7, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7); + LogMsg(LF_GC, sizeof...(args), format, ConvertArgument(args)...); } - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8) + template + static void LogMsgOL(unsigned facility, const char* format, Ts... args) { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*)); - LogMsg(LF_GC, 8, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*)); - LogMsg(LF_GC, 9, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*)); - LogMsg(LF_GC, 10, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*)); - LogMsg(LF_GC, 11, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*)); - LogMsg(LF_GC, 12, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11, (void*)(size_t)data12); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*)); - LogMsg(LF_GC, 13, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11, (void*)(size_t)data12, (void*)(size_t)data13); - } - - template < typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14 > - static void LogMsgOL(const char* format, T1 data1, T2 data2, T3 data3, T4 data4, T5 data5, T6 data6, T7 data7, T8 data8, T9 data9, T10 data10, T11 data11, T12 data12, T13 data13, T14 data14) - { - C_ASSERT(sizeof(T1) <= sizeof(void*) && sizeof(T2) <= sizeof(void*) && sizeof(T3) <= sizeof(void*) && sizeof(T4) <= sizeof(void*) && sizeof(T5) <= sizeof(void*) && sizeof(T6) <= sizeof(void*) && sizeof(T7) <= sizeof(void*) && sizeof(T8) <= sizeof(void*) && sizeof(T9) <= sizeof(void*) && sizeof(T10) <= sizeof(void*) && sizeof(T11) <= sizeof(void*) && sizeof(T12) <= sizeof(void*) && sizeof(T13) <= sizeof(void*) && sizeof(T14) <= sizeof(void*)); - LogMsg(LF_GC, 14, format, (void*)(size_t)data1, (void*)(size_t)data2, (void*)(size_t)data3, (void*)(size_t)data4, (void*)(size_t)data5, (void*)(size_t)data6, (void*)(size_t)data7, (void*)(size_t)data8, (void*)(size_t)data9, (void*)(size_t)data10, (void*)(size_t)data11, (void*)(size_t)data12, (void*)(size_t)data13, (void*)(size_t)data14); + LogMsg(facility, sizeof...(args), format, ConvertArgument(args)...); } #ifdef _MSC_VER @@ -492,6 +344,33 @@ class StressLog { }; +template<> +void* StressLog::ConvertArgument(float arg) = delete; + +#if TARGET_64BIT +template<> +inline void* StressLog::ConvertArgument(double arg) +{ + return (void*)(size_t)(*((uint64_t*)&arg)); +} +#else +template<> +void* StressLog::ConvertArgument(double arg) = delete; + +// COMPAT: Truncate 64-bit integer arguments to 32-bit +template<> +inline void* StressLog::ConvertArgument(uint64_t arg) +{ + return (void*)(size_t)arg; +} + +template<> +inline void* StressLog::ConvertArgument(int64_t arg) +{ + return (void*)(size_t)arg; +} +#endif + //========================================================================================== // Private classes // diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 863789cd7a2e6..8c60b2b5a7982 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -4231,7 +4231,10 @@ void Thread::SetLastThrownObject(OBJECTREF throwable, BOOL isUnhandled) } CONTRACTL_END; - STRESS_LOG_COND1(LF_EH, LL_INFO100, OBJECTREFToObject(throwable) != NULL, "in Thread::SetLastThrownObject: obj = %p\n", OBJECTREFToObject(throwable)); + if (OBJECTREFToObject(throwable) != NULL) + { + STRESS_LOG1(LF_EH, LL_INFO100, "in Thread::SetLastThrownObject: obj = %p\n", OBJECTREFToObject(throwable)); + } // you can't have a NULL unhandled exception _ASSERTE(!(throwable == NULL && isUnhandled));