1 // Copyright 2016 The Fuchsia Authors 2 // Copyright (c) 2008-2013 Travis Geiselbrecht 3 // 4 // Use of this source code is governed by a MIT-style 5 // license that can be found in the LICENSE file or at 6 // https://opensource.org/licenses/MIT 7 8 #pragma once 9 10 #include <stdio.h> 11 12 //#define __FUNC__ __PRETTY_FUNCTION__ 13 #define __FUNC__ __func__ 14 15 /* trace routines */ 16 #define TRACE_ENTRY printf("%s: entry\n", __FUNC__) 17 #define TRACE_EXIT printf("%s: exit\n", __FUNC__) 18 #define TRACE_ENTRY_OBJ printf("%s: entry obj %p\n", __FUNC__, this) 19 #define TRACE_EXIT_OBJ printf("%s: exit obj %p\n", __FUNC__, this) 20 #define TRACE printf("%s:%d\n", __FUNC__, __LINE__) 21 #define TRACEF(str, x...) do { printf("%s:%d: " str, __FUNC__, __LINE__, ## x); } while (0) 22 23 /* trace routines that work if LOCAL_TRACE is set */ 24 #define LTRACE_ENTRY do { if (LOCAL_TRACE) { TRACE_ENTRY; } } while (0) 25 #define LTRACE_EXIT do { if (LOCAL_TRACE) { TRACE_EXIT; } } while (0) 26 #define LTRACE_ENTRY_OBJ do { if (LOCAL_TRACE) { TRACE_ENTRY_OBJ; } } while (0) 27 #define LTRACE_EXIT_OBJ do { if (LOCAL_TRACE) { TRACE_EXIT_OBJ; } } while (0) 28 #define LTRACE do { if (LOCAL_TRACE) { TRACE; } } while (0) 29 #define LTRACEF(x...) do { if (LOCAL_TRACE) { TRACEF(x); } } while (0) 30 #define LTRACEF_LEVEL(level, x...) do { if (LOCAL_TRACE >= (level)) { TRACEF(x); } } while (0) 31 32