*
* Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
*
* Jaewon Lim <jaewon81.lim@samsung.com>
* Woojin Jung <woojin2.jung@samsung.com>
* Juyoung Kim <j0.kim@samsung.com>
- *
+ *
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
- *
+ *
* This library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
*
* Contributors:
* - S-Core Co., Ltd
- *
+ *
*/
#ifndef __BADA_PROBE_H__
extern "C" {
#endif
-#define GET_REAL_FUNC_OSP(FUNCNAME, LIBNAME, FUNCTIONPOINTER) \
- do { \
+#define GET_REAL_FUNC_OSP(FUNCNAME, LIBNAME, FUNCTIONPOINTER) \
+ do { \
if(!FUNCTIONPOINTER) { \
- probeBlockStart(); \
- if(lib_handle[LIBNAME] == NULL) { \
+ probeBlockStart(); \
+ if(lib_handle[LIBNAME] == NULL) { \
lib_handle[LIBNAME] = dlopen(lib_string[LIBNAME], RTLD_LAZY); \
- if(lib_handle[LIBNAME] == NULL) { \
- char perror_msg[PERROR_MSG_MAX]; \
+ if(lib_handle[LIBNAME] == NULL) { \
+ char perror_msg[PERROR_MSG_MAX]; \
sprintf(perror_msg, "dlopen failed : %s", lib_string[LIBNAME]); \
- perror(perror_msg); \
- exit(0); \
- } \
- } \
- void* funcp = dlsym(lib_handle[LIBNAME], #FUNCNAME); \
- if(funcp == NULL || dlerror() != NULL) { \
- perror("dlsym failed : " #FUNCNAME); \
- exit(0); \
- } \
- memcpy(&FUNCTIONPOINTER, &funcp, sizeof(void*)); \
- probeBlockEnd(); \
- } \
+ perror(perror_msg); \
+ exit(0); \
+ } \
+ } \
+ void* funcp = dlsym(lib_handle[LIBNAME], #FUNCNAME); \
+ if(funcp == NULL || dlerror() != NULL) { \
+ perror("dlsym failed : " #FUNCNAME); \
+ exit(0); \
+ } \
+ memcpy(&FUNCTIONPOINTER, &funcp, sizeof(void*)); \
+ probeBlockEnd(); \
+ } \
} while(0)
-#define PRE_PROBEBLOCK_OSP(FILTER) \
- do { \
+#define PRE_PROBEBLOCK_OSP(FILTER) \
+ do { \
if((blockresult = preBlockBegin(CALLER_ADDRESS, FILTER, _sopt)) != 0) { \
- setProbePoint(&probeInfo); \
- preBlockEnd(); \
- } \
+ setProbePoint(&probeInfo); \
+ preBlockEnd(); \
+ } \
} while(0)
extern int SceneManagerUsed;
*
* log format
* SeqNumber`,ApiName`,Time`,Pid`,Tid`,InputParm`,Return`,PCAddr`,Error`,
- * Size`,FDValue`,FDType`,FDApiType`,\n
+ * Size`,FDValue`,FDType`,FDApiType`, \n
* callstack_start`,callstack`,callstack_end
*
* fd type
// macro for file probe
// ===================================================================
-#define GET_FD_FROM_FILEP(FILEP) \
+#define GET_FD_FROM_FILEP(FILEP) \
_fd = (FILEP != NULL) ? fileno(FILEP) : -1
-#define DECLARE_VARIABLE_FD \
- DECLARE_VARIABLE_STANDARD; \
- char* _filepath = ""; \
- int __attribute((unused)) _fd; \
- int __attribute((unused)) _fstatret = -1; \
+#define DECLARE_VARIABLE_FD \
+ DECLARE_VARIABLE_STANDARD; \
+ char* _filepath = ""; \
+ int __attribute((unused)) _fd; \
+ int __attribute((unused)) _fstatret = -1; \
struct stat __attribute((unused)) _statbuf
// =================================================================
// POST_PROBEBLOCK_MIDDLE for file
// =================================================================
-#define POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, FD, APITYPE) \
- PACK_RESOURCE(SIZE, FD, APITYPE, \
- (_fstatret == 0 ? _statbuf.st_size : 0), _filepath); \
+#define POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, FD, APITYPE) \
+ PACK_RESOURCE(SIZE, FD, APITYPE, \
+ (_fstatret == 0 ? _statbuf.st_size : 0), _filepath); \
FLUSH_LOCAL_BUF()
-#define POST_PACK_PROBEBLOCK_MIDDLE_NOFD(SIZE, APITYPE) \
- PACK_RESOURCE(SIZE, 0, APITYPE, 0, _filepath); \
+#define POST_PACK_PROBEBLOCK_MIDDLE_NOFD(SIZE, APITYPE) \
+ PACK_RESOURCE(SIZE, 0, APITYPE, 0, _filepath); \
FLUSH_LOCAL_BUF()
// ==================================================================
// BEFORE_ORIGINAL macro for file
// ==================================================================
-#define BEFORE_ORIGINAL_FILE(FUNCNAME, LIBNAME) \
- DECLARE_VARIABLE_FD; \
- GET_REAL_FUNC(FUNCNAME, LIBNAME); \
+#define BEFORE_ORIGINAL_FILE(FUNCNAME, LIBNAME) \
+ DECLARE_VARIABLE_FD; \
+ GET_REAL_FUNC(FUNCNAME, LIBNAME); \
PRE_PROBEBLOCK()
-#define BEFORE_ORIGINAL_FILE_NOFILTER(FUNCNAME, LIBNAME) \
- DECLARE_VARIABLE_FD; \
+#define BEFORE_ORIGINAL_FILE_NOFILTER(FUNCNAME, LIBNAME) \
+ DECLARE_VARIABLE_FD; \
GET_REAL_FUNC(FUNCNAME, LIBNAME); \
- bfiltering = false; \
+ bfiltering = false; \
PRE_PROBEBLOCK()
// ==================================================================
// ==================================================================
#define FILE_API_START_BLOCK(API_ID, APITYPE) \
- PRE_PROBEBLOCK(); \
- POST_PACK_PROBEBLOCK_BEGIN(); \
- PREPARE_LOCAL_BUF(); \
- PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, "", 0); \
- PACK_COMMON_END(0, 0, 0); \
- PACK_RESOURCE(0, 0, APITYPE, 0, _filepath); \
- FLUSH_LOCAL_BUF(); \
+ PRE_PROBEBLOCK(); \
+ POST_PACK_PROBEBLOCK_BEGIN(); \
+ PREPARE_LOCAL_BUF(); \
+ PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, "", 0); \
+ PACK_COMMON_END(0, 0, 0); \
+ PACK_RESOURCE(0, 0, APITYPE, 0, _filepath); \
+ FLUSH_LOCAL_BUF(); \
POST_PACK_PROBEBLOCK_END()
// ==================================================================
// AFTER_ORIGINAL macro for file
// ==================================================================
-#define AFTER_PACK_ORIGINAL_FD(API_ID, RVAL, SIZE, FD, APITYPE, INPUTFORMAT, ...) \
- POST_PACK_PROBEBLOCK_BEGIN(); \
- PREPARE_LOCAL_BUF(); \
+#define AFTER_PACK_ORIGINAL_FD(API_ID, RVAL, SIZE, FD, APITYPE, INPUTFORMAT, ...) \
+ POST_PACK_PROBEBLOCK_BEGIN(); \
+ PREPARE_LOCAL_BUF(); \
PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \
- PACK_COMMON_END(RVAL, newerrno, blockresult); \
- _fstatret = fstat(FD, &_statbuf); \
- POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, FD, APITYPE); \
+ PACK_COMMON_END(RVAL, newerrno, blockresult); \
+ _fstatret = fstat(FD, &_statbuf); \
+ POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, FD, APITYPE); \
POST_PACK_PROBEBLOCK_END()
-#define AFTER_PACK_ORIGINAL_NOFD(API_ID, RVAL, SIZE, APITYPE, INPUTFORMAT, ...) \
- POST_PACK_PROBEBLOCK_BEGIN(); \
- PREPARE_LOCAL_BUF(); \
- PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \
- PACK_COMMON_END(RVAL, newerrno, blockresult); \
- POST_PACK_PROBEBLOCK_MIDDLE_NOFD(SIZE, APITYPE); \
+#define AFTER_PACK_ORIGINAL_NOFD(API_ID, RVAL, SIZE, APITYPE, INPUTFORMAT, ...) \
+ POST_PACK_PROBEBLOCK_BEGIN(); \
+ PREPARE_LOCAL_BUF(); \
+ PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \
+ PACK_COMMON_END(RVAL, newerrno, blockresult); \
+ POST_PACK_PROBEBLOCK_MIDDLE_NOFD(SIZE, APITYPE); \
POST_PACK_PROBEBLOCK_END()
#define AFTER_PACK_ORIGINAL_FILEP(API_ID, RVAL, SIZE, FILEP, APITYPE, INPUTFORMAT, ...) \
- POST_PACK_PROBEBLOCK_BEGIN(); \
- GET_FD_FROM_FILEP(FILEP); \
- if(_fd != -1) { \
- _fstatret = fstat(_fd, &_statbuf); \
- } \
- PREPARE_LOCAL_BUF(); \
- PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \
- PACK_COMMON_END(RVAL, newerrno, blockresult); \
- POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, _fd, APITYPE); \
+ POST_PACK_PROBEBLOCK_BEGIN(); \
+ GET_FD_FROM_FILEP(FILEP); \
+ if(_fd != -1) { \
+ _fstatret = fstat(_fd, &_statbuf); \
+ } \
+ PREPARE_LOCAL_BUF(); \
+ PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \
+ PACK_COMMON_END(RVAL, newerrno, blockresult); \
+ POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, _fd, APITYPE); \
POST_PACK_PROBEBLOCK_END()
#endif // __DA_IO_H__