From fbc5245d794c6bbb27212a8d4556ff7e6e8faf44 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Mon, 3 Oct 2016 10:45:25 -0700 Subject: [PATCH] Enable Windows WPP Logging Support (#678) * Enable support for WPP logging. --- etc/visual-studio/libopenthread_k.vcxproj | 28 +- include/platform/logging-windows.h | 411 ++++++++++++++++++++ src/core/common/logging.hpp | 22 ++ src/core/common/message.cpp | 8 +- src/core/mac/mac.cpp | 9 +- src/core/meshcop/commissioner.cpp | 2 + src/core/meshcop/dtls.cpp | 2 + src/core/meshcop/energy_scan_client.cpp | 2 + src/core/meshcop/joiner.cpp | 2 + src/core/meshcop/joiner_router.cpp | 2 + src/core/meshcop/leader.cpp | 2 + src/core/meshcop/panid_query_client.cpp | 2 + src/core/net/icmp6.cpp | 9 +- src/core/openthread.cpp | 2 + src/core/thread/address_resolver.cpp | 2 + src/core/thread/energy_scan_server.cpp | 2 + src/core/thread/mesh_forwarder.cpp | 2 + src/core/thread/meshcop_dataset_manager.cpp | 4 +- src/core/thread/mle.cpp | 36 +- src/core/thread/mle_router.cpp | 2 + src/core/thread/network_data.cpp | 2 + src/core/thread/network_data_leader.cpp | 2 + src/core/thread/panid_query_server.cpp | 2 + 23 files changed, 537 insertions(+), 20 deletions(-) create mode 100644 include/platform/logging-windows.h diff --git a/etc/visual-studio/libopenthread_k.vcxproj b/etc/visual-studio/libopenthread_k.vcxproj index d9e15b352..ae41c0a2f 100644 --- a/etc/visual-studio/libopenthread_k.vcxproj +++ b/etc/visual-studio/libopenthread_k.vcxproj @@ -199,34 +199,54 @@ - WIN32;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;OPENTHREAD_MULTIPLE_INSTANCE + WIN32;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;WINDOWS_LOGGING;OPENTHREAD_MULTIPLE_INSTANCE ..\..\include;..\..\src\missing\stdint;..\..\src\missing\stdbool;..\..\src\core;..\..\third_party\mbedtls;..\..\third_party\mbedtls\repo\include;%(AdditionalIncludeDirectories) 4100;4706;4748;%(DisableSpecificWarnings) true + true + ..\..\include\platform\logging-windows.h + -km %(WppAdditionalOptions) + otCore + WPP_INIT_TRACING - _WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;OPENTHREAD_MULTIPLE_INSTANCE + _WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;WINDOWS_LOGGING;OPENTHREAD_MULTIPLE_INSTANCE ..\..\include;..\..\src\missing\stdint;..\..\src\missing\stdbool;..\..\src\core;..\..\third_party\mbedtls;..\..\third_party\mbedtls\repo\include;%(AdditionalIncludeDirectories) 4100;4706;4748;%(DisableSpecificWarnings) true + true + ..\..\include\platform\logging-windows.h + -km %(WppAdditionalOptions) + otCore + WPP_INIT_TRACING - WIN32;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;OPENTHREAD_MULTIPLE_INSTANCE + WIN32;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;WINDOWS_LOGGING;OPENTHREAD_MULTIPLE_INSTANCE ..\..\include;..\..\src\missing\stdint;..\..\src\missing\stdbool;..\..\src\core;..\..\third_party\mbedtls;..\..\third_party\mbedtls\repo\include;%(AdditionalIncludeDirectories) 4100;4603;4627;4706;4986;4987;4996;%(DisableSpecificWarnings) true + true + ..\..\include\platform\logging-windows.h + -km %(WppAdditionalOptions) + otCore + WPP_INIT_TRACING - _WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;OPENTHREAD_MULTIPLE_INSTANCE + _WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions);MBEDTLS_CONFIG_FILE="mbedtls-config.h";OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";WINDOWS_KERNEL;WINDOWS_LOGGING;OPENTHREAD_MULTIPLE_INSTANCE ..\..\include;..\..\src\missing\stdint;..\..\src\missing\stdbool;..\..\src\core;..\..\third_party\mbedtls;..\..\third_party\mbedtls\repo\include;%(AdditionalIncludeDirectories) 4100;4603;4627;4706;4986;4987;4996;%(DisableSpecificWarnings) true + true + ..\..\include\platform\logging-windows.h + -km %(WppAdditionalOptions) + otCore + WPP_INIT_TRACING diff --git a/include/platform/logging-windows.h b/include/platform/logging-windows.h new file mode 100644 index 000000000..507116b04 --- /dev/null +++ b/include/platform/logging-windows.h @@ -0,0 +1,411 @@ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file defines the WPP Tracing Definitions. + */ + +#ifndef _LOGGING_WINDOWS_H +#define _LOGGING_WINDOWS_H + +// +// Tracing Definitions: {1AA98926-2E40-43D1-9D83-34C6BE816365} +// + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID( \ + OpenThreadGUID, (1AA98926,2E40,43D1,9D83,34C6BE816365), \ + WPP_DEFINE_BIT(DRIVER_DEFAULT) /* 0x00000001 */ \ + WPP_DEFINE_BIT(DRIVER_IOCTL) /* 0x00000002 */ \ + WPP_DEFINE_BIT(DRIVER_OID) /* 0x00000004 */ \ + WPP_DEFINE_BIT(DRIVER_DATA_PATH) /* 0x00000008 */ \ + WPP_DEFINE_BIT(OT_API) /* 0x00000010 */ \ + WPP_DEFINE_BIT(OT_MLE) /* 0x00000020 */ \ + WPP_DEFINE_BIT(OT_ARP) /* 0x00000040 */ \ + WPP_DEFINE_BIT(OT_NETD) /* 0x00000080 */ \ + WPP_DEFINE_BIT(OT_ICMP) /* 0x00000100 */ \ + WPP_DEFINE_BIT(OT_IPV6) /* 0x00000200 */ \ + WPP_DEFINE_BIT(OT_MAC) /* 0x00000400 */ \ + WPP_DEFINE_BIT(OT_MEM) /* 0x00000800 */ \ + WPP_DEFINE_BIT(OT_NCP) /* 0x00001000 */ \ + WPP_DEFINE_BIT(OT_COAP) /* 0x00002000 */ \ + WPP_DEFINE_BIT(OT_DEFAULT) /* 0x00004000 */ \ + ) + +#define WPP_LEVEL_FLAGS_LOGGER(lvl,flag) \ + WPP_FLAG_LOGGER(flag) + +#define WPP_LEVEL_FLAGS_ENABLED(lvl, flag) \ + (WPP_FLAG_ENABLED(flag) && WPP_CONTROL(WPP_BIT_ ## flag).Level >= lvl) + +// Suppress warnings about constants in logical expressions because the +// level is often a constant +#define WPP_LEVEL_FLAGS_PRE(LEVEL,FLAGS) __pragma(warning(suppress:25039 25040 25078 25080)) + +// Map no-argument macros (dummy) back to regular macros +#define WPP_LEVEL_FLAGS__PRE(lvl, flags, dummy) WPP_LEVEL_FLAGS_PRE(lvl, flags) +#define WPP_LEVEL_FLAGS__POST(lvl, flags, dummy) WPP_LEVEL_FLAGS_POST(lvl, flags) + +#define WPP_LEVEL_FLAGS_EXP_ENABLED(LEVEL,FLAGS,EXP) \ + WPP_LEVEL_FLAGS_ENABLED (LEVEL,FLAGS) +#define WPP_LEVEL_FLAGS_EXP_LOGGER(LEVEL,FLAGS,EXP) \ + WPP_LEVEL_FLAGS_LOGGER (LEVEL,FLAGS) + +#define WPP_LOGIPV6(x) WPP_LOGPAIR(16, (x)) + +// begin_wpp config +// DEFINE_CPLX_TYPE(IPV6ADDR, WPP_LOGIPV6, IN6_ADDR *, ItemIPV6Addr, "s", _IPV6_, 0); +// end_wpp + +// begin_wpp config +// USEPREFIX (TraceEvents, "%!STDPREFIX!%!SPACE!"); +// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX(LogFuncEntry, "%!STDPREFIX! ---> %!FUNC!"); +// FUNC LogFuncEntry{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS); +// end_wpp + +// begin_wpp config +// USEPREFIX(LogFuncEntryMsg, "%!STDPREFIX! ---> %!FUNC!%!SPACE!"); +// FUNC LogFuncEntryMsg{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX(LogFuncExit, "%!STDPREFIX! <--- %!FUNC!"); +// FUNC LogFuncExit{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS); +// end_wpp + +// begin_wpp config +// USEPREFIX(LogFuncExitMsg, "%!STDPREFIX! <--- %!FUNC!%!SPACE!"); +// FUNC LogFuncExitMsg{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX(LogFuncExitNT, "%!STDPREFIX! <--- %!FUNC!"); +// FUNC LogFuncExitNT{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, EXP); +// USESUFFIX(LogFuncExitNT, " %!STATUS!", EXP); +// end_wpp + +// begin_wpp config +// USEPREFIX(LogFuncExitNDIS, "%!STDPREFIX! <--- %!FUNC!"); +// FUNC LogFuncExitNDIS{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, EXP); +// USESUFFIX(LogFuncExitNDIS, " %!NDIS_STATUS!", EXP); +// end_wpp + +// begin_wpp config +// USEPREFIX(LogFuncExitWIN, "%!STDPREFIX! <--- %!FUNC!"); +// FUNC LogFuncExitWIN{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, EXP); +// USESUFFIX(LogFuncExitWIN, " %!WINERROR!", EXP); +// end_wpp + +// begin_wpp config +// USEPREFIX (LogError, "%!STDPREFIX!%!SPACE!"); +// LogError{LEVEL=TRACE_LEVEL_ERROR}(FLAGS, MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (LogWarning, "%!STDPREFIX!%!SPACE!"); +// LogWarning{LEVEL=TRACE_LEVEL_WARNING}(FLAGS, MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (LogInfo, "%!STDPREFIX!%!SPACE!"); +// LogInfo{LEVEL=TRACE_LEVEL_INFORMATION}(FLAGS, MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (LogVerbose, "%!STDPREFIX!%!SPACE!"); +// LogVerbose{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS, MSG, ...); +// end_wpp + +// +// Custom types +// + +// begin_wpp config +// CUSTOM_TYPE(otError, ItemEnum(ThreadError)); +// CUSTOM_TYPE(otDeviceRole, ItemEnum(otDeviceRole)); +// end_wpp + +// +// otCore Definitions +// + +// ==API== + +// begin_wpp config +// USEPREFIX (otLogCritApi, "%!STDPREFIX!%!SPACE!API%!SPACE!"); +// otLogCritApi{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_API}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnApi, "%!STDPREFIX!%!SPACE!API%!SPACE!"); +// otLogWarnApi{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_API}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoApi, "%!STDPREFIX!%!SPACE!API%!SPACE!"); +// otLogInfoApi{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_API}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgApi, "%!STDPREFIX!%!SPACE!API%!SPACE!"); +// otLogDebgApi{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_API}(MSG, ...); +// end_wpp + +// ==NCP== + +// begin_wpp config +// USEPREFIX (otLogCritNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!"); +// otLogCritNcp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NCP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!"); +// otLogWarnNcp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NCP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!"); +// otLogInfoNcp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NCP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgNcp, "%!STDPREFIX!%!SPACE!NCP%!SPACE!"); +// otLogDebgNcp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NCP}(MSG, ...); +// end_wpp + +// ==COAP== + +// begin_wpp config +// USEPREFIX (otLogCritMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!"); +// otLogCritMeshCoP{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_COAP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!"); +// otLogWarnMeshCoP{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_COAP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!"); +// otLogInfoMeshCoP{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_COAP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgMeshCoP, "%!STDPREFIX!%!SPACE!COAP%!SPACE!"); +// otLogDebgMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_COAP}(MSG, ...); +// end_wpp + +// ==MLE== + +// begin_wpp config +// USEPREFIX (otLogCritMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!"); +// otLogCritMle{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MLE}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!"); +// otLogWarnMle{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MLE}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!"); +// otLogInfoMle{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MLE}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgMle, "%!STDPREFIX!%!SPACE!MLE%!SPACE!"); +// otLogDebgMle{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MLE}(MSG, ...); +// end_wpp + +// ==ARP== + +// begin_wpp config +// USEPREFIX (otLogCritArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!"); +// otLogCritArp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_ARP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!"); +// otLogWarnArp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_ARP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!"); +// otLogInfoArp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_ARP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgArp, "%!STDPREFIX!%!SPACE!ARP%!SPACE!"); +// otLogDebgArp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_ARP}(MSG, ...); +// end_wpp + +// ==NETD== + +// begin_wpp config +// USEPREFIX (otLogCritNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!"); +// otLogCritNetData{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NETD}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!"); +// otLogWarnNetData{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NETD}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!"); +// otLogInfoNetData{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NETD}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgNetData, "%!STDPREFIX!%!SPACE!NETD%!SPACE!"); +// otLogDebgNetData{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NETD}(MSG, ...); +// end_wpp + +// ==ICMP== + +// begin_wpp config +// USEPREFIX (otLogCritIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!"); +// otLogCritIcmp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_ICMP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!"); +// otLogWarnIcmp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_ICMP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!"); +// otLogInfoIcmp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_ICMP}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgIcmp, "%!STDPREFIX!%!SPACE!ICMP%!SPACE!"); +// otLogDebgIcmp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_ICMP}(MSG, ...); +// end_wpp + +// ==IPV6== + +// begin_wpp config +// USEPREFIX (otLogCritIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!"); +// otLogCritIp6{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_IPV6}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!"); +// otLogWarnIp6{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_IPV6}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!"); +// otLogInfoIp6{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_IPV6}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgIp6, "%!STDPREFIX!%!SPACE!IPV6%!SPACE!"); +// otLogDebgIp6{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_IPV6}(MSG, ...); +// end_wpp + +// ==MAC== + +// begin_wpp config +// USEPREFIX (otLogCritMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!"); +// otLogCritMac{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MAC}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!"); +// otLogWarnMac{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MAC}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!"); +// otLogInfoMac{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MAC}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgMac, "%!STDPREFIX!%!SPACE!MAC%!SPACE!"); +// otLogDebgMac{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MAC}(MSG, ...); +// end_wpp + +// ==MEM== + +// begin_wpp config +// USEPREFIX (otLogCritMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!"); +// otLogCritMem{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MEM}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogWarnMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!"); +// otLogWarnMem{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MEM}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogInfoMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!"); +// otLogInfoMem{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MEM}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX (otLogDebgMem, "%!STDPREFIX!%!SPACE!MEM%!SPACE!"); +// otLogDebgMem{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MEM}(MSG, ...); +// end_wpp + +// ==FUNC== + +// begin_wpp config +// USEPREFIX(otLogFuncEntry, "%!STDPREFIX! ---> %!FUNC!"); +// FUNC otLogFuncEntry{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(...); +// end_wpp + +// begin_wpp config +// USEPREFIX(otLogFuncEntryMsg, "%!STDPREFIX! ---> %!FUNC!%!SPACE!"); +// FUNC otLogFuncEntryMsg{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX(otLogFuncExit, "%!STDPREFIX! <--- %!FUNC!"); +// FUNC otLogFuncExit{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(...); +// end_wpp + +// begin_wpp config +// USEPREFIX(otLogFuncExitMsg, "%!STDPREFIX! <--- %!FUNC!%!SPACE!"); +// FUNC otLogFuncExitMsg{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(MSG, ...); +// end_wpp + +// begin_wpp config +// USEPREFIX(otLogFuncExitErr, "%!STDPREFIX! <--- %!FUNC!"); +// FUNC otLogFuncExitErr{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_DEFAULT}(EXP); +// USESUFFIX(otLogFuncExitErr, " %!otError!", EXP); +// end_wpp + +#endif // _LOGGING_WINDOWS_H \ No newline at end of file diff --git a/src/core/common/logging.hpp b/src/core/common/logging.hpp index 001c7cd0e..62d758fc2 100644 --- a/src/core/common/logging.hpp +++ b/src/core/common/logging.hpp @@ -41,10 +41,28 @@ #include #include +#ifdef WINDOWS_LOGGING +#ifdef WINDOWS_KERNEL +#include +#endif +#include +#ifdef WPP_NAME +#include WPP_NAME +#endif +#endif + #ifdef __cplusplus extern "C" { #endif +#ifndef WINDOWS_LOGGING +#define otLogFuncEntry() +#define otLogFuncEntryMsg(aFormat, ...) +#define otLogFuncExit() +#define otLogFuncExitMsg(aFormat, ...) +#define otLogFuncExitErr(error) +#endif + /** * @def otLogCrit * @@ -109,6 +127,8 @@ extern "C" { #define otLogDebg(aRegion, aFormat, ...) #endif +#ifndef WINDOWS_LOGGING + /** * @def otLogCritApi * @@ -568,6 +588,8 @@ extern "C" { #define otLogDebgMem(aFormat, ...) #endif +#endif // WINDOWS_LOGGING + /** * @def otDumpCrit * diff --git a/src/core/common/message.cpp b/src/core/common/message.cpp index c09614516..e76a66e32 100644 --- a/src/core/common/message.cpp +++ b/src/core/common/message.cpp @@ -31,6 +31,8 @@ * This file implements the message buffer pool and message buffers. */ +#define WPP_NAME "message.tmh" + #include #include #include @@ -85,7 +87,11 @@ Buffer *MessagePool::NewBuffer(void) { Buffer *buffer = NULL; - VerifyOrExit(mFreeBuffers != NULL, otLogInfoMac("No available message buffer\n")); + if (mFreeBuffers == NULL) + { + otLogInfoMac("No available message buffer\n"); + ExitNow(); + } buffer = mFreeBuffers; mFreeBuffers = mFreeBuffers->GetNextBuffer(); diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 42faf0c03..8d4183a76 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -31,6 +31,8 @@ * This file implements the subset of IEEE 802.15.4 primitives required for Thread. */ +#define WPP_NAME "mac.tmh" + #ifdef OPENTHREAD_CONFIG_FILE #include OPENTHREAD_CONFIG_FILE #else @@ -1075,8 +1077,11 @@ void Mac::ReceiveDoneTask(Frame *aFrame, ThreadError aError) } // Duplicate Address Protection - VerifyOrExit(memcmp(&srcaddr.mExtAddress, &mExtAddress, sizeof(srcaddr.mExtAddress)) != 0, - error = kThreadError_InvalidSourceAddress; otLogDebgMac("duplicate address received\n")); + if (memcmp(&srcaddr.mExtAddress, &mExtAddress, sizeof(srcaddr.mExtAddress)) == 0) + { + otLogDebgMac("duplicate address received\n"); + ExitNow(error = kThreadError_InvalidSourceAddress); + } // Source Whitelist Processing if (srcaddr.mLength != 0 && mWhitelist.IsEnabled()) diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index 7f71c3f26..9ef384fdc 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -31,6 +31,8 @@ * This file implements a Commissioner role. */ +#define WPP_NAME "commissioner.tmh" + #ifdef OPENTHREAD_CONFIG_FILE #include OPENTHREAD_CONFIG_FILE #else diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp index 76ef0d8e1..49222c895 100644 --- a/src/core/meshcop/dtls.cpp +++ b/src/core/meshcop/dtls.cpp @@ -31,6 +31,8 @@ * This file implements the necessary hooks for mbedTLS. */ +#define WPP_NAME "dtls.tmh" + #include #include diff --git a/src/core/meshcop/energy_scan_client.cpp b/src/core/meshcop/energy_scan_client.cpp index 0bd16a1c7..f6084c6d5 100644 --- a/src/core/meshcop/energy_scan_client.cpp +++ b/src/core/meshcop/energy_scan_client.cpp @@ -31,6 +31,8 @@ * This file implements the Energy Scan Client. */ +#define WPP_NAME "energy_scan_client.tmh" + #include #include #include diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index a7d0731aa..432ae153f 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -31,6 +31,8 @@ * This file implements the Joiner role. */ +#define WPP_NAME "joiner.tmh" + #ifdef OPENTHREAD_CONFIG_FILE #include OPENTHREAD_CONFIG_FILE #else diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp index 1ec2c186c..86d192df6 100644 --- a/src/core/meshcop/joiner_router.cpp +++ b/src/core/meshcop/joiner_router.cpp @@ -31,6 +31,8 @@ * This file implements the Joiner Router role. */ +#define WPP_NAME "joiner_router.tmh" + #ifdef OPENTHREAD_CONFIG_FILE #include OPENTHREAD_CONFIG_FILE #else diff --git a/src/core/meshcop/leader.cpp b/src/core/meshcop/leader.cpp index 615f30d25..eeea2af35 100644 --- a/src/core/meshcop/leader.cpp +++ b/src/core/meshcop/leader.cpp @@ -31,6 +31,8 @@ * This file implements a MeshCoP Leader. */ +#define WPP_NAME "leader.tmh" + #include #include diff --git a/src/core/meshcop/panid_query_client.cpp b/src/core/meshcop/panid_query_client.cpp index d8bafc00b..057a80d8b 100644 --- a/src/core/meshcop/panid_query_client.cpp +++ b/src/core/meshcop/panid_query_client.cpp @@ -31,6 +31,8 @@ * This file implements the PAN ID Query Client. */ +#define WPP_NAME "panid_query_client.tmh" + #include #include #include diff --git a/src/core/net/icmp6.cpp b/src/core/net/icmp6.cpp index 839bb1fff..3cbd81e60 100644 --- a/src/core/net/icmp6.cpp +++ b/src/core/net/icmp6.cpp @@ -31,6 +31,8 @@ * This file implements ICMPv6. */ +#define WPP_NAME "icmp6.tmh" + #include #include @@ -206,7 +208,12 @@ ThreadError Icmp::HandleEchoRequest(Message &aRequestMessage, const MessageInfo icmp6Header.Init(); icmp6Header.SetType(IcmpHeader::kTypeEchoReply); - VerifyOrExit((replyMessage = mIp6.NewMessage(0)) != NULL, otLogDebgIcmp("icmp fail\n")); + if ((replyMessage = mIp6.NewMessage(0)) == NULL) + { + otLogDebgIcmp("icmp fail\n"); + ExitNow(); + } + payloadLength = aRequestMessage.GetLength() - aRequestMessage.GetOffset() - IcmpHeader::GetDataOffset(); SuccessOrExit(replyMessage->SetLength(IcmpHeader::GetDataOffset() + payloadLength)); diff --git a/src/core/openthread.cpp b/src/core/openthread.cpp index 1b67cc81b..6574379bc 100644 --- a/src/core/openthread.cpp +++ b/src/core/openthread.cpp @@ -31,6 +31,8 @@ * This file implements the top-level interface to the OpenThread stack. */ +#define WPP_NAME "openthread.tmh" + #ifdef OPENTHREAD_CONFIG_FILE #include OPENTHREAD_CONFIG_FILE #else diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index 64de9ff7f..30bd580c7 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -31,6 +31,8 @@ * This file implements Thread's EID-to-RLOC mapping and caching. */ +#define WPP_NAME "address_resolver.tmh" + #include #include #include diff --git a/src/core/thread/energy_scan_server.cpp b/src/core/thread/energy_scan_server.cpp index a202bc407..0e7ee92fb 100644 --- a/src/core/thread/energy_scan_server.cpp +++ b/src/core/thread/energy_scan_server.cpp @@ -31,6 +31,8 @@ * This file implements the Energy Scan Server. */ +#define WPP_NAME "energy_scan_server.tmh" + #include #include #include diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index bbe1157f1..897775d67 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -31,6 +31,8 @@ * This file implements mesh forwarding of IPv6/6LoWPAN messages. */ +#define WPP_NAME "mesh_forwarder.tmh" + #include #include #include diff --git a/src/core/thread/meshcop_dataset_manager.cpp b/src/core/thread/meshcop_dataset_manager.cpp index fd43add3d..a1f04e7e5 100644 --- a/src/core/thread/meshcop_dataset_manager.cpp +++ b/src/core/thread/meshcop_dataset_manager.cpp @@ -32,11 +32,13 @@ * */ -#include +#define WPP_NAME "meshcop_dataset_manager.tmh" + #include #include #include +#include #include #include #include diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index ac8c882b8..e0e34943b 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -31,6 +31,8 @@ * This file implements MLE functionality required for the Thread Child, Router and Leader roles. */ +#define WPP_NAME "mle.tmh" + #include #include #include @@ -1518,11 +1520,20 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn { if (keySequence == neighbor->mKeySequence) { - VerifyOrExit(frameCounter >= neighbor->mValid.mMleFrameCounter, otLogDebgMle("mle frame reject 1\n")); + if (frameCounter < neighbor->mValid.mMleFrameCounter) + { + otLogDebgMle("mle frame reject 1\n"); + ExitNow(); + } } else { - VerifyOrExit(keySequence > neighbor->mKeySequence, otLogDebgMle("mle frame reject 2\n")); + if (keySequence <= neighbor->mKeySequence) + { + otLogDebgMle("mle frame reject 2\n"); + ExitNow(); + } + neighbor->mKeySequence = keySequence; neighbor->mValid.mLinkFrameCounter = 0; } @@ -1531,15 +1542,18 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn } else { - VerifyOrExit(command == Header::kCommandLinkRequest || - command == Header::kCommandLinkAccept || - command == Header::kCommandLinkAcceptAndRequest || - command == Header::kCommandAdvertisement || - command == Header::kCommandParentRequest || - command == Header::kCommandParentResponse || - command == Header::kCommandChildIdRequest || - command == Header::kCommandChildUpdateRequest, - otLogDebgMle("mle sequence unknown! %d\n", command)); + if (!(command == Header::kCommandLinkRequest || + command == Header::kCommandLinkAccept || + command == Header::kCommandLinkAcceptAndRequest || + command == Header::kCommandAdvertisement || + command == Header::kCommandParentRequest || + command == Header::kCommandParentResponse || + command == Header::kCommandChildIdRequest || + command == Header::kCommandChildUpdateRequest)) + { + otLogDebgMle("mle sequence unknown! %d\n", command); + ExitNow(); + } } switch (command) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index b0c99c303..9ce41d2a6 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -31,6 +31,8 @@ * This file implements MLE functionality required for the Thread Router and Leader roles. */ +#define WPP_NAME "mle_router.tmh" + #include #include #include diff --git a/src/core/thread/network_data.cpp b/src/core/thread/network_data.cpp index fa834bd51..7d112ee30 100644 --- a/src/core/thread/network_data.cpp +++ b/src/core/thread/network_data.cpp @@ -31,6 +31,8 @@ * This file implements common methods for manipulating Thread Network Data. */ +#define WPP_NAME "network_data.tmh" + #include #include #include diff --git a/src/core/thread/network_data_leader.cpp b/src/core/thread/network_data_leader.cpp index 8a4544fa7..00acf5cf8 100644 --- a/src/core/thread/network_data_leader.cpp +++ b/src/core/thread/network_data_leader.cpp @@ -31,6 +31,8 @@ * This file implements the Thread Network Data managed by the Thread Leader. */ +#define WPP_NAME "network_data_leader.tmh" + #include #include #include diff --git a/src/core/thread/panid_query_server.cpp b/src/core/thread/panid_query_server.cpp index 76c9efb4a..3ab3c24f0 100644 --- a/src/core/thread/panid_query_server.cpp +++ b/src/core/thread/panid_query_server.cpp @@ -31,6 +31,8 @@ * This file implements the PAN ID Query Server. */ +#define WPP_NAME "panid_query_server.tmh" + #include #include #include