106f6ba60Sopenharmony_ci/* 206f6ba60Sopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 306f6ba60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 406f6ba60Sopenharmony_ci * you may not use this file except in compliance with the License. 506f6ba60Sopenharmony_ci * You may obtain a copy of the License at 606f6ba60Sopenharmony_ci * 706f6ba60Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 806f6ba60Sopenharmony_ci * 906f6ba60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1006f6ba60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1106f6ba60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1206f6ba60Sopenharmony_ci * See the License for the specific language governing permissions and 1306f6ba60Sopenharmony_ci * limitations under the License. 1406f6ba60Sopenharmony_ci * 1506f6ba60Sopenharmony_ci */ 1606f6ba60Sopenharmony_ci#ifndef HIPERF_DEBUG_H 1706f6ba60Sopenharmony_ci#define HIPERF_DEBUG_H 1806f6ba60Sopenharmony_ci 1906f6ba60Sopenharmony_ci#include <chrono> 2006f6ba60Sopenharmony_ci#include <cstdio> 2106f6ba60Sopenharmony_ci#include <cstring> 2206f6ba60Sopenharmony_ci#include <map> 2306f6ba60Sopenharmony_ci#include <memory> 2406f6ba60Sopenharmony_ci#include <mutex> 2506f6ba60Sopenharmony_ci#include <sstream> 2606f6ba60Sopenharmony_ci#include <string> 2706f6ba60Sopenharmony_ci#include <unistd.h> 2806f6ba60Sopenharmony_ci 2906f6ba60Sopenharmony_ci#include "get_thread_id.h" 3006f6ba60Sopenharmony_ci 3106f6ba60Sopenharmony_cinamespace OHOS { 3206f6ba60Sopenharmony_cinamespace Developtools { 3306f6ba60Sopenharmony_cinamespace NativeDaemon { 3406f6ba60Sopenharmony_cienum DebugLevel { 3506f6ba60Sopenharmony_ci LEVEL_MUCH = 1, 3606f6ba60Sopenharmony_ci LEVEL_VERBOSE, 3706f6ba60Sopenharmony_ci LEVEL_DEBUG, 3806f6ba60Sopenharmony_ci LEVEL_INFO, 3906f6ba60Sopenharmony_ci LEVEL_WARNING, 4006f6ba60Sopenharmony_ci LEVEL_ERROR, 4106f6ba60Sopenharmony_ci LEVEL_FATAL, 4206f6ba60Sopenharmony_ci LEVEL_STDOUT, // printf 4306f6ba60Sopenharmony_ci LEVEL_MAX, // max 4406f6ba60Sopenharmony_ci}; 4506f6ba60Sopenharmony_ci 4606f6ba60Sopenharmony_ci#ifdef HIPERF_DEBUG 4706f6ba60Sopenharmony_ci#if is_ohos 4806f6ba60Sopenharmony_ciconst std::string DEFAULT_LOG_PATH = "/data/local/tmp/hiperf_log.txt"; 4906f6ba60Sopenharmony_ci#elif is_mingw 5006f6ba60Sopenharmony_ciconst std::string DEFAULT_LOG_PATH = ".\\hiperf_log.txt"; 5106f6ba60Sopenharmony_ci#elif is_linux 5206f6ba60Sopenharmony_ciconst std::string DEFAULT_LOG_PATH = "hiperf_log.txt"; 5306f6ba60Sopenharmony_ci#else 5406f6ba60Sopenharmony_ci#error unkow os 5506f6ba60Sopenharmony_ci#endif 5606f6ba60Sopenharmony_ci 5706f6ba60Sopenharmony_ci#define HILOG_BASE_TAG "HILOG" 5806f6ba60Sopenharmony_ci#ifndef HILOG_TAG 5906f6ba60Sopenharmony_ci#define HILOG_TAG "" 6006f6ba60Sopenharmony_ci#define HILOG_TAG_NAME HILOG_BASE_TAG 6106f6ba60Sopenharmony_ci#else 6206f6ba60Sopenharmony_ci#define HILOG_TAG_NAME HILOG_BASE_TAG "_" HILOG_TAG 6306f6ba60Sopenharmony_ci#endif 6406f6ba60Sopenharmony_ci 6506f6ba60Sopenharmony_ci#define SHORT_FILENAME \ 6606f6ba60Sopenharmony_ci (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 6706f6ba60Sopenharmony_ci 6806f6ba60Sopenharmony_ciconst std::map<DebugLevel, const std::string> DebugLevelMap = { 6906f6ba60Sopenharmony_ci {LEVEL_MUCH, "M"}, {LEVEL_VERBOSE, "V"}, {LEVEL_DEBUG, "D"}, {LEVEL_INFO, "I"}, 7006f6ba60Sopenharmony_ci {LEVEL_WARNING, "W"}, {LEVEL_ERROR, "E"}, {LEVEL_FATAL, "F"}, 7106f6ba60Sopenharmony_ci}; 7206f6ba60Sopenharmony_ciconstexpr const int LOG_BUFFER_SIZE = 4 * 1024 * 1024; 7306f6ba60Sopenharmony_ci 7406f6ba60Sopenharmony_ciclass DebugLogger { 7506f6ba60Sopenharmony_cipublic: 7606f6ba60Sopenharmony_ci DebugLogger(); 7706f6ba60Sopenharmony_ci ~DebugLogger(); 7806f6ba60Sopenharmony_ci 7906f6ba60Sopenharmony_ci static DebugLogger *GetInstance(); 8006f6ba60Sopenharmony_ci DebugLevel SetLogLevel(DebugLevel debugLevel); 8106f6ba60Sopenharmony_ci bool SetMixLogOutput(bool enable); 8206f6ba60Sopenharmony_ci bool SetLogPath(const std::string &logPath); 8306f6ba60Sopenharmony_ci void SetLogTags(const std::string &tags); 8406f6ba60Sopenharmony_ci 8506f6ba60Sopenharmony_ci int Log(DebugLevel level, const std::string &logTag, const char *fmt, ...) const 8606f6ba60Sopenharmony_ci __attribute__((format(printf, 4, 5))); 8706f6ba60Sopenharmony_ci // for class, pointer need add 1 offset (first one is *this) 8806f6ba60Sopenharmony_ci 8906f6ba60Sopenharmony_ci bool EnableHiLog(bool = true); 9006f6ba60Sopenharmony_ci DebugLevel GetLogLevel() const 9106f6ba60Sopenharmony_ci { 9206f6ba60Sopenharmony_ci return debugLevel_; 9306f6ba60Sopenharmony_ci }; 9406f6ba60Sopenharmony_ci 9506f6ba60Sopenharmony_ci void Disable(bool disable = true); 9606f6ba60Sopenharmony_ci static bool logDisabled_; 9706f6ba60Sopenharmony_ci 9806f6ba60Sopenharmony_ci#ifdef HIPERF_DEBUG_TIME 9906f6ba60Sopenharmony_ci mutable size_t logCount_ = 0; 10006f6ba60Sopenharmony_ci mutable std::chrono::microseconds logTimes_ = std::chrono::microseconds::zero(); 10106f6ba60Sopenharmony_ci mutable std::chrono::microseconds logWriteTimes_ = std::chrono::microseconds::zero(); 10206f6ba60Sopenharmony_ci mutable std::chrono::microseconds logSprintfTimes_ = std::chrono::microseconds::zero(); 10306f6ba60Sopenharmony_ci#endif 10406f6ba60Sopenharmony_ci 10506f6ba60Sopenharmony_ciprivate: 10606f6ba60Sopenharmony_ci bool ShouldLog(DebugLevel debugLevel, const std::string &logTag) const; 10706f6ba60Sopenharmony_ci DebugLevel GetLogLevelByName(const std::string &) const; 10806f6ba60Sopenharmony_ci DebugLevel GetLogLevelByTag(const std::string &) const; 10906f6ba60Sopenharmony_ci const std::string GetLogLevelName(DebugLevel) const; 11006f6ba60Sopenharmony_ci 11106f6ba60Sopenharmony_ci void HiLog(std::string &buffer) const; 11206f6ba60Sopenharmony_ci 11306f6ba60Sopenharmony_ci static std::unique_ptr<DebugLogger> logInstance_; 11406f6ba60Sopenharmony_ci std::string logFileBuffer_; 11506f6ba60Sopenharmony_ci 11606f6ba60Sopenharmony_ci mutable std::mutex logMutex_; 11706f6ba60Sopenharmony_ci static DebugLevel debugLevel_; 11806f6ba60Sopenharmony_ci const std::chrono::steady_clock::time_point timeStamp_; 11906f6ba60Sopenharmony_ci bool OpenLog(); 12006f6ba60Sopenharmony_ci FILE *file_ = nullptr; 12106f6ba60Sopenharmony_ci bool mixLogOutput_ = false; // log mix to std 12206f6ba60Sopenharmony_ci bool enableHilog_ = false; 12306f6ba60Sopenharmony_ci bool exitOnFatal_ = true; 12406f6ba60Sopenharmony_ci std::string logPath_; 12506f6ba60Sopenharmony_ci std::map<std::string, DebugLevel> logTagLevelmap_; 12606f6ba60Sopenharmony_ci}; 12706f6ba60Sopenharmony_ci 12806f6ba60Sopenharmony_ci#ifdef HIPERF_DEBUG_PRINTF 12906f6ba60Sopenharmony_ci#ifndef printf 13006f6ba60Sopenharmony_ci#define printf(format, ...) \ 13106f6ba60Sopenharmony_ci do { \ 13206f6ba60Sopenharmony_ci std::printf(format, ##__VA_ARGS__); \ 13306f6ba60Sopenharmony_ci DebugLogger::GetInstance()->Log(LEVEL_STDOUT, HILOG_TAG, format, ##__VA_ARGS__); \ 13406f6ba60Sopenharmony_ci } while (0) 13506f6ba60Sopenharmony_ci#endif 13606f6ba60Sopenharmony_ci 13706f6ba60Sopenharmony_ci#ifndef perror 13806f6ba60Sopenharmony_ci#define perror(format, ...) \ 13906f6ba60Sopenharmony_ci do { \ 14006f6ba60Sopenharmony_ci std::perror(format); \ 14106f6ba60Sopenharmony_ci DebugLogger::GetInstance()->Log(LEVEL_STDOUT, HILOG_TAG, format "<%d:%s>\n", \ 14206f6ba60Sopenharmony_ci ##__VA_ARGS__, errno, strerror(errno)); \ 14306f6ba60Sopenharmony_ci } while (0) 14406f6ba60Sopenharmony_ci#endif 14506f6ba60Sopenharmony_ci#endif 14606f6ba60Sopenharmony_ci 14706f6ba60Sopenharmony_ciclass ScopeDebugLevel { 14806f6ba60Sopenharmony_cipublic: 14906f6ba60Sopenharmony_ci ScopeDebugLevel(DebugLevel level, bool mix = false); 15006f6ba60Sopenharmony_ci ~ScopeDebugLevel(); 15106f6ba60Sopenharmony_ci 15206f6ba60Sopenharmony_ciprivate: 15306f6ba60Sopenharmony_ci DebugLevel savedDebugLevel_; 15406f6ba60Sopenharmony_ci bool savedMixOutput_ = false; // log mix to std 15506f6ba60Sopenharmony_ci}; 15606f6ba60Sopenharmony_ci#define TempMixLogLevel(level) ScopeDebugLevel tempLogLevel(level, true) 15706f6ba60Sopenharmony_ci 15806f6ba60Sopenharmony_ci#define LOG_LEVEL(LEVEL) LOG_##LEVEL 15906f6ba60Sopenharmony_ci#define LOG_LEVEL_MUCH "M:" 16006f6ba60Sopenharmony_ci#define LOG_LEVEL_VERBOSE "V:" 16106f6ba60Sopenharmony_ci#define LOG_LEVEL_DEBUG "D:" 16206f6ba60Sopenharmony_ci#define LOG_LEVEL_INFO "I:" 16306f6ba60Sopenharmony_ci#define LOG_LEVEL_WARNING "W:" 16406f6ba60Sopenharmony_ci#define LOG_LEVEL_ERROR "E:" 16506f6ba60Sopenharmony_ci#define LOG_LEVEL_FATAL "F:" 16606f6ba60Sopenharmony_ci 16706f6ba60Sopenharmony_ci#ifndef HLOG 16806f6ba60Sopenharmony_ci#define HLOG(level, format, ...) \ 16906f6ba60Sopenharmony_ci do { \ 17006f6ba60Sopenharmony_ci if (__builtin_expect(!DebugLogger::logDisabled_, false)) { \ 17106f6ba60Sopenharmony_ci DebugLogger::GetInstance()->Log( \ 17206f6ba60Sopenharmony_ci level, HILOG_TAG, \ 17306f6ba60Sopenharmony_ci HILOG_TAG_NAME "/" LOG_LEVEL(level) "<%ld>[%s:%d]%s:" format "\n", (long)(gettid()), \ 17406f6ba60Sopenharmony_ci SHORT_FILENAME, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ 17506f6ba60Sopenharmony_ci } \ 17606f6ba60Sopenharmony_ci } while (0) 17706f6ba60Sopenharmony_ci#endif 17806f6ba60Sopenharmony_ci 17906f6ba60Sopenharmony_ci// only log first n times 18006f6ba60Sopenharmony_ci#ifndef HLOGV_FIRST 18106f6ba60Sopenharmony_ci#define HLOGV_FIRST(first, format, ...) \ 18206f6ba60Sopenharmony_ci do { \ 18306f6ba60Sopenharmony_ci static int limit = first; \ 18406f6ba60Sopenharmony_ci if (limit > 0) { \ 18506f6ba60Sopenharmony_ci HLOG(LEVEL_VERBOSE, format, ##__VA_ARGS__); \ 18606f6ba60Sopenharmony_ci if (--limit == 0) { \ 18706f6ba60Sopenharmony_ci HLOG(LEVEL_VERBOSE, " nexttime log will be suppressed..."); \ 18806f6ba60Sopenharmony_ci } \ 18906f6ba60Sopenharmony_ci } \ 19006f6ba60Sopenharmony_ci } while (0) 19106f6ba60Sopenharmony_ci#endif 19206f6ba60Sopenharmony_ci 19306f6ba60Sopenharmony_ci#ifndef HLOGV_FIRST_LOCAL 19406f6ba60Sopenharmony_ci#define HLOGV_FIRST_LOCAL(local_limit, format, ...) \ 19506f6ba60Sopenharmony_ci { \ 19606f6ba60Sopenharmony_ci if (local_limit != 0) { \ 19706f6ba60Sopenharmony_ci HLOG(LEVEL_VERBOSE, format, ##__VA_ARGS__); \ 19806f6ba60Sopenharmony_ci if (local_limit > 0 && --local_limit == 0) { \ 19906f6ba60Sopenharmony_ci HLOG(LEVEL_VERBOSE, " nexttime log will be suppressed..."); \ 20006f6ba60Sopenharmony_ci } \ 20106f6ba60Sopenharmony_ci } \ 20206f6ba60Sopenharmony_ci } 20306f6ba60Sopenharmony_ci#endif 20406f6ba60Sopenharmony_ci 20506f6ba60Sopenharmony_ci#ifndef HLOGV 20606f6ba60Sopenharmony_ci#define HLOGV_IF(condition, format, ...) \ 20706f6ba60Sopenharmony_ci if (condition) { \ 20806f6ba60Sopenharmony_ci HLOG(LEVEL_VERBOSE, format, ##__VA_ARGS__) \ 20906f6ba60Sopenharmony_ci } 21006f6ba60Sopenharmony_ci#define HLOGVVV HLOGV 21106f6ba60Sopenharmony_ci#endif 21206f6ba60Sopenharmony_ci 21306f6ba60Sopenharmony_ci#ifndef HLOGDUMMY 21406f6ba60Sopenharmony_ci#define HLOGDUMMY(format, ...) while (0) 21506f6ba60Sopenharmony_ci#endif 21606f6ba60Sopenharmony_ci 21706f6ba60Sopenharmony_ci#ifndef HLOGM 21806f6ba60Sopenharmony_ci#define HLOGM(format, ...) HLOG(LEVEL_MUCH, format, ##__VA_ARGS__) 21906f6ba60Sopenharmony_ci#define HLOGMMM HLOGM 22006f6ba60Sopenharmony_ci#endif 22106f6ba60Sopenharmony_ci 22206f6ba60Sopenharmony_ci#ifndef HLOGV 22306f6ba60Sopenharmony_ci#define HLOGV(format, ...) HLOG(LEVEL_VERBOSE, format, ##__VA_ARGS__) 22406f6ba60Sopenharmony_ci#endif 22506f6ba60Sopenharmony_ci 22606f6ba60Sopenharmony_ci#ifndef HLOGD 22706f6ba60Sopenharmony_ci#define HLOGD(format, ...) HLOG(LEVEL_DEBUG, format, ##__VA_ARGS__) 22806f6ba60Sopenharmony_ci#define HLOGDDD HLOGM 22906f6ba60Sopenharmony_ci#endif 23006f6ba60Sopenharmony_ci 23106f6ba60Sopenharmony_ci#ifndef HLOGI 23206f6ba60Sopenharmony_ci#define HLOGI(format, ...) HLOG(LEVEL_INFO, format, ##__VA_ARGS__) 23306f6ba60Sopenharmony_ci#endif 23406f6ba60Sopenharmony_ci 23506f6ba60Sopenharmony_ci#ifndef HLOGW 23606f6ba60Sopenharmony_ci#define HLOGW(format, ...) HLOG(LEVEL_WARNING, format, ##__VA_ARGS__) 23706f6ba60Sopenharmony_ci#endif 23806f6ba60Sopenharmony_ci 23906f6ba60Sopenharmony_ci#ifndef HLOGE 24006f6ba60Sopenharmony_ci#define HLOGE(format, ...) HLOG(LEVEL_ERROR, format, ##__VA_ARGS__) 24106f6ba60Sopenharmony_ci#endif 24206f6ba60Sopenharmony_ci 24306f6ba60Sopenharmony_ci#ifndef HLOGEP 24406f6ba60Sopenharmony_ci#define HLOGEP(format, ...) \ 24506f6ba60Sopenharmony_ci HLOG(LEVEL_ERROR, format "(errno %d:%s)", ##__VA_ARGS__, errno, strerror(errno)) 24606f6ba60Sopenharmony_ci#endif 24706f6ba60Sopenharmony_ci 24806f6ba60Sopenharmony_ci#ifndef HLOGF 24906f6ba60Sopenharmony_ci#define HLOGF(format, ...) \ 25006f6ba60Sopenharmony_ci HLOG(LEVEL_FATAL, "FATAL error at %s:%d " format, __FILE__, __LINE__, ##__VA_ARGS__) 25106f6ba60Sopenharmony_ci#endif 25206f6ba60Sopenharmony_ci 25306f6ba60Sopenharmony_ci#ifndef HLOG_ASSERT_MESSAGE 25406f6ba60Sopenharmony_ci#define HLOG_ASSERT_MESSAGE(condition, format, ...) \ 25506f6ba60Sopenharmony_ci if (!(condition)) { \ 25606f6ba60Sopenharmony_ci HLOG(LEVEL_FATAL, " assert failed: '%s' " format, #condition, ##__VA_ARGS__); \ 25706f6ba60Sopenharmony_ci } 25806f6ba60Sopenharmony_ci#endif 25906f6ba60Sopenharmony_ci 26006f6ba60Sopenharmony_ci#ifndef HLOG_ASSERT 26106f6ba60Sopenharmony_ci#define HLOG_ASSERT(condition) HLOG_ASSERT_MESSAGE(condition, "") 26206f6ba60Sopenharmony_ci#endif 26306f6ba60Sopenharmony_ci 26406f6ba60Sopenharmony_ci#undef assert 26506f6ba60Sopenharmony_ciclass LogMessage { 26606f6ba60Sopenharmony_cipublic: 26706f6ba60Sopenharmony_ci LogMessage(DebugLevel level = LEVEL_VERBOSE, bool showError = false) 26806f6ba60Sopenharmony_ci : level_(level), showError_(showError) 26906f6ba60Sopenharmony_ci { 27006f6ba60Sopenharmony_ci } 27106f6ba60Sopenharmony_ci std::ostream &Stream() 27206f6ba60Sopenharmony_ci { 27306f6ba60Sopenharmony_ci return buffer_; 27406f6ba60Sopenharmony_ci } 27506f6ba60Sopenharmony_ci ~LogMessage() 27606f6ba60Sopenharmony_ci { 27706f6ba60Sopenharmony_ci if (!DebugLogger::logDisabled_) { 27806f6ba60Sopenharmony_ci if (!showError_) { 27906f6ba60Sopenharmony_ci DebugLogger::GetInstance()->Log(level_, HILOG_TAG, "%s\n", buffer_.str().c_str()); 28006f6ba60Sopenharmony_ci } else { 28106f6ba60Sopenharmony_ci DebugLogger::GetInstance()->Log(level_, HILOG_TAG, "%s (errno %d:%s)\n", 28206f6ba60Sopenharmony_ci buffer_.str().c_str(), errno, strerror(errno)); 28306f6ba60Sopenharmony_ci } 28406f6ba60Sopenharmony_ci } 28506f6ba60Sopenharmony_ci } 28606f6ba60Sopenharmony_ci 28706f6ba60Sopenharmony_ciprivate: 28806f6ba60Sopenharmony_ci DebugLevel level_; 28906f6ba60Sopenharmony_ci bool showError_; 29006f6ba60Sopenharmony_ci std::ostringstream buffer_; 29106f6ba60Sopenharmony_ci}; 29206f6ba60Sopenharmony_ci#define HLOGMESSAGE(level, error) \ 29306f6ba60Sopenharmony_ci LogMessage(level, error).Stream() \ 29406f6ba60Sopenharmony_ci << HILOG_TAG_NAME << "/" << LOG_LEVEL(level) << "<" << gettid() << ">[" << SHORT_FILENAME \ 29506f6ba60Sopenharmony_ci << ":" << __LINE__ << "]" << __FUNCTION__ << ":" 29606f6ba60Sopenharmony_ci 29706f6ba60Sopenharmony_ci#define HLOGS(level) HLOGMESSAGE(level, false) 29806f6ba60Sopenharmony_ci 29906f6ba60Sopenharmony_ci#define HLOGSP(level) HLOGMESSAGE(level, true) 30006f6ba60Sopenharmony_ci#define UNWIND_CHECK_NOTNULL(ptr, retval, fmt, ...) \ 30106f6ba60Sopenharmony_ci do { \ 30206f6ba60Sopenharmony_ci if (ptr == nullptr) { \ 30306f6ba60Sopenharmony_ci HLOGE("UNWIND_CHECK_NOTNULL(%s) in %s:%d FAILED, " fmt, #ptr, __func__, \ 30406f6ba60Sopenharmony_ci __LINE__, ##__VA_ARGS__); \ 30506f6ba60Sopenharmony_ci return retval; \ 30606f6ba60Sopenharmony_ci } \ 30706f6ba60Sopenharmony_ci } while (0) 30806f6ba60Sopenharmony_ci 30906f6ba60Sopenharmony_ci#define UNWIND_CHECK_TRUE(expr, retval, fmt, ...) \ 31006f6ba60Sopenharmony_ci do { \ 31106f6ba60Sopenharmony_ci if (!(expr)) { \ 31206f6ba60Sopenharmony_ci HLOGE("UNWIND_CHECK_TRUE(%s) in %s:%d FAILED, " fmt, #expr, __func__, __LINE__, ##__VA_ARGS__); \ 31306f6ba60Sopenharmony_ci return retval; \ 31406f6ba60Sopenharmony_ci } \ 31506f6ba60Sopenharmony_ci } while (0) 31606f6ba60Sopenharmony_ci#else 31706f6ba60Sopenharmony_ci#define HLOGS(...) std::ostringstream() 31806f6ba60Sopenharmony_ci#define HLOGSP(...) std::ostringstream() 31906f6ba60Sopenharmony_ci 32006f6ba60Sopenharmony_ci#define HLOGDUMMY(...) \ 32106f6ba60Sopenharmony_ci do { \ 32206f6ba60Sopenharmony_ci } while (0) 32306f6ba60Sopenharmony_ci#define HLOGEP(...) \ 32406f6ba60Sopenharmony_ci do { \ 32506f6ba60Sopenharmony_ci } while (0) 32606f6ba60Sopenharmony_ci#define HLOGM(...) \ 32706f6ba60Sopenharmony_ci do { \ 32806f6ba60Sopenharmony_ci } while (0) 32906f6ba60Sopenharmony_ci#define HLOGMMM(...) \ 33006f6ba60Sopenharmony_ci do { \ 33106f6ba60Sopenharmony_ci } while (0) 33206f6ba60Sopenharmony_ci#define HLOGV(...) \ 33306f6ba60Sopenharmony_ci do { \ 33406f6ba60Sopenharmony_ci } while (0) 33506f6ba60Sopenharmony_ci#define HLOGVVV(...) \ 33606f6ba60Sopenharmony_ci do { \ 33706f6ba60Sopenharmony_ci } while (0) 33806f6ba60Sopenharmony_ci#define HLOGD(...) \ 33906f6ba60Sopenharmony_ci do { \ 34006f6ba60Sopenharmony_ci } while (0) 34106f6ba60Sopenharmony_ci#define HLOGDDD(...) \ 34206f6ba60Sopenharmony_ci do { \ 34306f6ba60Sopenharmony_ci } while (0) 34406f6ba60Sopenharmony_ci#define HLOGI(...) \ 34506f6ba60Sopenharmony_ci do { \ 34606f6ba60Sopenharmony_ci } while (0) 34706f6ba60Sopenharmony_ci#define HLOGW(...) \ 34806f6ba60Sopenharmony_ci do { \ 34906f6ba60Sopenharmony_ci } while (0) 35006f6ba60Sopenharmony_ci#define HLOGE(...) \ 35106f6ba60Sopenharmony_ci do { \ 35206f6ba60Sopenharmony_ci } while (0) 35306f6ba60Sopenharmony_ci#define HLOGF(...) \ 35406f6ba60Sopenharmony_ci do { \ 35506f6ba60Sopenharmony_ci } while (0) 35606f6ba60Sopenharmony_ci#define HLOG_ASSERT_MESSAGE(...) \ 35706f6ba60Sopenharmony_ci do { \ 35806f6ba60Sopenharmony_ci } while (0) 35906f6ba60Sopenharmony_ci#define HLOG_ASSERT(...) \ 36006f6ba60Sopenharmony_ci do { \ 36106f6ba60Sopenharmony_ci } while (0) 36206f6ba60Sopenharmony_ci#define UNWIND_CHECK_NOTNULL(ptr, retval, fmt, ...) \ 36306f6ba60Sopenharmony_ci do { \ 36406f6ba60Sopenharmony_ci if (ptr == nullptr) { \ 36506f6ba60Sopenharmony_ci return retval; \ 36606f6ba60Sopenharmony_ci } \ 36706f6ba60Sopenharmony_ci } while (0) 36806f6ba60Sopenharmony_ci 36906f6ba60Sopenharmony_ci#define UNWIND_CHECK_TRUE(expr, retval, fmt, ...) \ 37006f6ba60Sopenharmony_ci do { \ 37106f6ba60Sopenharmony_ci if (!(expr)) { \ 37206f6ba60Sopenharmony_ci return retval; \ 37306f6ba60Sopenharmony_ci } \ 37406f6ba60Sopenharmony_ci } while (0) 37506f6ba60Sopenharmony_ci 37606f6ba60Sopenharmony_ciclass ScopeDebugLevel { 37706f6ba60Sopenharmony_cipublic: 37806f6ba60Sopenharmony_ci ScopeDebugLevel(DebugLevel level, bool mix = false) {}; 37906f6ba60Sopenharmony_ci}; 38006f6ba60Sopenharmony_ci#endif 38106f6ba60Sopenharmony_ci} // namespace NativeDaemon 38206f6ba60Sopenharmony_ci} // namespace Developtools 38306f6ba60Sopenharmony_ci} // namespace OHOS 38406f6ba60Sopenharmony_ci#endif // _HIPERF_DEBUG_H_