add sync probes in bada_sync.cpp
[platform/core/system/swap-probe.git] / probe_thread / da_thread.h
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: 
7  *
8  * Woojin Jung <woojin2.jung@samsung.com>
9  * Jaewon Lim <jaewon81.lim@samsung.com>
10  * Juyoung Kim <j0.kim@samsung.com>
11  * 
12  * This library is free software; you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation; either version 2.1 of the License, or (at your option)
15  * any later version.
16  * 
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this library; if not, write to the Free Software Foundation, Inc., 51
24  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  * 
29  */
30
31 #ifndef __DA_THREAD_H__
32 #define __DA_THREAD_H__
33
34 #include "daprobe.h"
35
36 #define DECLARE_VARIABLE_THREAD                                         \
37         DECLARE_VARIABLE_STANDARD                                               
38 //      pthread_t pSelf
39
40 #define BEFORE_ORIGINAL_THREAD(FUNCNAME, LIBNAME)       \
41         DECLARE_VARIABLE_THREAD;                                                \
42         GET_REAL_FUNC(FUNCNAME, LIBNAME);                               \
43         PRE_PROBEBLOCK()
44
45 #define POST_PROBEBLOCK_MIDDLE_THREAD(THREADVAL, APITYPE)                       \
46         log.length += sprintf(log.data + log.length, "`,%lu`,`,%d`,%d", \
47                         THREADVAL, THREAD_PTHREAD, APITYPE)
48
49 #define AFTER_ORIGINAL_THREAD_RET(RTYPE, RVAL, THREADVAL, APITYPE, INPUTFORMAT, ...)    \
50         POST_PROBEBLOCK_BEGIN(LC_THREAD, RTYPE, RVAL, INPUTFORMAT, __VA_ARGS__);                        \
51         POST_PROBEBLOCK_MIDDLE_THREAD(THREADVAL, APITYPE);                                                                      \
52         POST_PROBEBLOCK_CALLSTACK();                                                                                                            \
53         POST_PROBEBLOCK_END()
54
55 #define BEFORE_PACK_ORIGINAL_THREAD(FUNCNAME, LIBNAME)  \
56         PREPARE_LOCAL_BUF();                                                            \
57         GET_REAL_FUNC(FUNCNAME, LIBNAME);                                       \
58         PRE_PROBEBLOCK()
59
60 #define AFTER_PACK_ORIGINAL_THREAD(RVAL, THREADVAL, APITYPE, INPUTFORMAT, ...)                  \
61         POST_PACK_PROBEBLOCK_BEGIN(LC_THREAD, RVAL, INPUTFORMAT, __VA_ARGS__);                          \
62         PACK_COMMON_BEGIN(MSG_PROBE_THREAD, LC_THREAD, INPUTFORMAT, __VA_ARGS__);                       \
63         PACK_COMMON_END(RVAL, errno, blockresult);                                                                                      \
64         PACK_THREAD(THREADVAL, THREAD_PTHREAD, APITYPE);                                                                \
65         FLUSH_LOCAL_BUF();                                                                                                                                      \
66         POST_PACK_PROBEBLOCK_END()
67
68 #endif // __DA_THREAD_H__
69