• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef HAP_DEBUG_H
2 #define HAP_DEBUG_H
3 /**
4  * Copyright (c) 2019, The Linux Foundation. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *    * Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *    * Redistributions in binary form must reproduce the above
12  *      copyright notice, this list of conditions and the following
13  *      disclaimer in the documentation and/or other materials provided
14  *      with the distribution.
15  *    * Neither the name of The Linux Foundation nor the names of its
16  *      contributors may be used to endorse or promote products derived
17  *      from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
28  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
29  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include "AEEStdDef.h"
33 #include <stdarg.h>
34 #include <stdio.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #define HAP_LEVEL_LOW       0
41 #define HAP_LEVEL_MEDIUM    1
42 #define HAP_LEVEL_HIGH      2
43 #define HAP_LEVEL_ERROR     3
44 #define HAP_LEVEL_FATAL     4
45 
46 #define HAP_LEVEL_RUNTIME   (1 << 5)
47 
48 //Add a weak reference so shared objects work with older images
49 #pragma weak HAP_debug_v2
50 
51 //Add a weak reference so runtime FARFs are ignored on older images
52 #pragma weak HAP_debug_runtime
53 
54 /**************************************************************************
55     These HAP_debug* functions are not meant to be called directly.
56     Please use the FARF() macros to call them instead
57 **************************************************************************/
58 void HAP_debug_v2(int level, const char* file, int line, const char* format, ...);
59 void HAP_debug_runtime(int level, const char* file, int line, const char* format, ...);
60 int HAP_setFARFRuntimeLoggingParams(unsigned int mask, const char* files[],
61                                     unsigned short numberOfFiles);
62 
63 // Keep these around to support older shared objects and older images
64 void HAP_debug(const char *msg, int level, const char *filename, int line);
65 
_HAP_debug_v2(int level,const char * file,int line,const char * format,...)66 static __inline void _HAP_debug_v2(int level, const char* file, int line,
67                           const char* format, ...){
68    char buf[256];
69    va_list args;
70    va_start(args, format);
71    vsnprintf(buf, sizeof(buf), format, args);
72    va_end(args);
73    HAP_debug(buf, level, file, line);
74 }
75 
76 /*!
77 This function is called to log an accumlated log entry. If logging is
78 enabled for the entry by the external device, then the entry is copied
79 into the diag allocation manager and commited.
80 
81     [in] log_code_type    ID of the event to be reported
82     [in] *data            data points to the log which is to be submitted
83     [in] dataLen          The length of the data to be logged.
84 
85 Returns
86     TRUE if log is submitted successfully into diag buffers
87     FALSE if there is no space left in the buffers.
88 
89 */
90 boolean HAP_log_data_packet(unsigned short log_code_type, unsigned int dataLen,
91                     byte* data);
92 
93 #define HAP_DEBUG_TRACEME 0
94 
95 long HAP_debug_ptrace(int req, unsigned int pid, void* addr, void* data);
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif // HAP_DEBUG_H
102 
103