4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
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)
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.
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
35 #include <pthread.h> // for pthread_mutex_t
45 #define MAX_PATH_LENGTH 256
46 #define MAX_STACK_DEPTH 128
47 #define TRIM_STACK_DEPTH 2
50 #define WIN_RENDER_POST 0
51 #define CONTROLBAR_RENDER_POST 1
52 #define NAVIFRAME_RENDER_POST 2
53 #define PAGER_RENDER_POST 3
54 #define RENDER_POST_COUNT 4
56 #define SNAPSHOT_WAIT_TIME_MAX 10000
59 #define TS_NONE 0x00000000
60 #define TS_PROBE 0x00000001
61 #define TS_INIT 0x00000002
62 #define TS_FINIT 0x00000004
63 #define TS_ENTER_PROBE_BLOCK 0x00000008
64 #define TS_SET_PROBE_POINT 0x00000010
65 #define TS_PRINT_LOG 0x00000020
66 #define TS_PRINT_SAMPLE_LOG 0x00000040
67 #define TS_APPEND_TYPE_LOG 0x00000080
68 #define TS_BACKTRACE 0x00000100
69 #define TS_HASHFUNC 0x00000200
70 #define TS_PROFIL_THREAD 0x00000400
71 #define TS_PROFIL_COUNT 0x00000800
72 #define TS_DETECT_TOUCH 0x00001000
73 #define TS_REGIST_SCREEN_CHANGE 0x00002000
74 #define TS_POSSIBLE_CAPTURE 0x00004000
75 #define TS_RECV_THREAD 0x00008000
76 #define TS_CUSTOM_CHART_THREAD 0x00010000
77 #define TRACE_STATE_SET(value) ((gSTrace) |= (value))
78 #define TRACE_STATE_UNSET(value) ((gSTrace) &= (~value))
80 #define ENABLE_INTERNAL_MALLOC 0x0001
81 #define ENABLE_SNAPSHOT 0x0002
83 #define LOG(FORMAT, ...) \
86 sprintf(buf, FORMAT, __VA_ARGS__); \
90 #define SCREENSHOT_LOCK() \
93 LOG("screenshot_lock : %d, %s\n", gTraceInfo.screenshot.state, __func__); \
94 pthread_mutex_lock(&(gTraceInfo.screenshot.ssMutex)); \
95 old = gTraceInfo.screenshot.state; \
96 gTraceInfo.screenshot.state = -1; \
97 pthread_mutex_unlock(&(gTraceInfo.screenshot.ssMutex)); \
99 if(isOptionEnabled(OPT_SNAPSHOT)) \
104 #define SCREENSHOT_UNLOCK() \
106 LOG("screenshot_unlock : %d, %s\n", gTraceInfo.screenshot.state, __func__); \
107 pthread_mutex_lock(&(gTraceInfo.screenshot.ssMutex)); \
108 gTraceInfo.screenshot.state = 1; \
109 pthread_mutex_unlock(&(gTraceInfo.screenshot.ssMutex)); \
112 #define SCREENSHOT_SET() \
115 LOG("screenshot_set : %d, %s\n", gTraceInfo.screenshot.state, __func__); \
116 pthread_mutex_lock(&(gTraceInfo.screenshot.ssMutex)); \
117 old = gTraceInfo.screenshot.state; \
118 if(gTraceInfo.screenshot.state >= 0) \
119 gTraceInfo.screenshot.state = 1; \
120 pthread_mutex_unlock(&(gTraceInfo.screenshot.ssMutex)); \
122 if(isOptionEnabled(OPT_SNAPSHOT)) \
127 #define SCREENSHOT_UNSET() \
129 LOG("screenshot_unset : %d, %s\n", gTraceInfo.screenshot.state, __func__); \
130 pthread_mutex_lock(&(gTraceInfo.screenshot.ssMutex)); \
131 if(gTraceInfo.screenshot.state >= 0) \
132 gTraceInfo.screenshot.state = 0; \
133 pthread_mutex_unlock(&(gTraceInfo.screenshot.ssMutex)); \
136 #define SCREENSHOT_DONE() \
139 LOG("screenshot_done : %d, %s\n", gTraceInfo.screenshot.state, __func__); \
140 pthread_mutex_lock(&(gTraceInfo.screenshot.ssMutex)); \
141 old = gTraceInfo.screenshot.state; \
142 if(gTraceInfo.screenshot.state == 1) \
143 gTraceInfo.screenshot.state = 2; \
144 pthread_mutex_unlock(&(gTraceInfo.screenshot.ssMutex)); \
146 activateCaptureTimer(); \
150 #define SCREENSHOT_TIMEOUT() \
153 LOG("screenshot_timeout : %d, %s\n", gTraceInfo.screenshot.state, __func__); \
154 pthread_mutex_lock(&(gTraceInfo.screenshot.ssMutex)); \
155 old = gTraceInfo.screenshot.state; \
156 if(gTraceInfo.screenshot.state == 2) \
157 gTraceInfo.screenshot.state = 0; \
158 pthread_mutex_unlock(&(gTraceInfo.screenshot.ssMutex)); \
160 if(isOptionEnabled(OPT_SNAPSHOT)) \
165 #define NUM_ORIGINAL_LIBRARY 9
175 LIBECORE_INPUT_EVAS = 6,
177 LIBCAPI_APPFW_APPLICATION = 8
180 extern char *lib_string[NUM_ORIGINAL_LIBRARY];
181 extern void *lib_handle[NUM_ORIGINAL_LIBRARY];
183 // type definition for global variable
187 pthread_mutex_t eventMutex;
193 pthread_mutex_t sockMutex;
199 unsigned int startTime;
205 pthread_mutex_t ssMutex;
219 __screenshotInfo screenshot;
223 int custom_chart_callback_count;
224 unsigned long optionflag;
227 extern __thread unsigned long gSTrace;
228 extern __traceInfo gTraceInfo;
230 int get_map_address(void* symbol, void** map_start, void** map_end);
231 char** da_backtrace_symbols (void* const* array, int size);
232 char** cached_backtrace_symbols (void* const* array, int size);
235 int __profil(int mode);
238 void WcharToChar(char* pstrDest, const wchar_t* pwstrSrc);
240 // screen capture functions
241 int initialize_screencapture();
242 int finalize_screencapture();
244 int activateCaptureTimer();
245 void _cb_render_post(void* data, Evas* e, void* eventinfo);
247 // event related functions
248 int initialize_event();
249 int finalize_event();
250 int getOrientation();
251 void orientationEnabled();
252 void on_orientation_changed(int angle, bool capi);
254 int remove_indir(const char* dirname);
257 #define isOptionEnabled(OPT) ((gTraceInfo.optionflag & OPT) != 0)
263 #endif // _DAHELPER_H_