[FIX] argument types conformance
[platform/core/system/swap-probe.git] / probe_tizenapi / tizen_thread.cpp
1 /*
2  *  DA probe
3  *
4  * Copyright (Thread::*c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Woojin Jung <woojin2.jung@samsung.com>
9  * Yeongtaik Byeon <yeongtaik.byeon@samsung.com>
10  * Jaewon Lim <jaewon81.lim@samsung.com>
11  * Juyoung Kim <j0.kim@samsung.com>
12  * Anastasia Lyupa <a.lyupa@samsung.com>
13  *
14  * This library is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License as published by the
16  * Free Software Foundation; either version 2.1 of the License, or (at your option)
17  * any later version.
18  *
19  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
20  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
22  * License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with this library; if not, write to the Free Software Foundation, Inc., 51
26  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  *
28  * Contributors:
29  * - S-Core Co., Ltd
30  * - Samsung RnD Institute Russia
31  *
32  */
33
34 #include <FBase.h>
35 #include "daprobe.h"
36 #include "probeinfo.h"
37 #include "dahelper.h"
38
39 #include "binproto.h"
40
41 static enum DaOptions _sopt = OPT_THREAD;
42
43 namespace Tizen {
44 namespace Base {
45 namespace Runtime {
46
47 class _ThreadImpl {
48 //public:
49 //      virtual result Stop(void);
50 protected:
51 //      virtual result Finalize(void);
52         const Thread* GetThread(void) const;
53 private:
54         static void* ThreadProc(void* pParam);
55 //protected:
56 //      Thread* _pThread;
57 };
58 //const Thread*
59 //_ThreadImpl::GetThread(void) const
60 //{
61 //      typedef const Thread*
62 //      (_ThreadImpl::*methodType)(void) const;
63 //      static methodType GetThreadp = 0;
64 //      probeInfo_t probeInfo;
65 //      log_t log;
66 //      int blockresult;
67 //      bool bfiltering = false;
68 //      void *tmpPtr;
69 //
70 //      if (!GetThreadp) {
71 //              probeBlockStart();
72 //              void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
73 //              if (lib_handle == NULL) {
74 //                      perror("dlopen failed : libosp-appfw.so");
75 //                      exit(0);
76 //              }
77 //              tmpPtr = dlsym(lib_handle, "_ZNK5Tizen4Base7Runtime11_ThreadImpl9GetThreadEv");
78 //
79 //              if (tmpPtr == NULL || dlerror() != NULL) {
80 //                      perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::GetThreadp");
81 //                      exit(0);
82 //              }
83 //
84 //              memcpy(&GetThreadp, &tmpPtr, sizeof(tmpPtr));
85 //
86 //              probeBlockEnd();
87 //      }
88 //
89 //      if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
90 //              setProbePoint(&probeInfo);
91 //              preBlockEnd();
92 //      }
93 //      //
94 //      const Thread* ret = (this->*GetThreadp)();
95 //      result res = GetLastResult();
96 //      //
97 //      if (postBlockBegin(blockresult)) {
98 //              log.type = 0;
99 //              log.length = 0;
100 //              log.data[0] = '\0';
101 //              log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
102 //                              probeInfo.eventIndex, "_ThreadImpl::GetThread", probeInfo.currentTime,
103 //                              probeInfo.pID, probeInfo.tID);
104 //
105 //              //Input,ret
106 //              log.length += sprintf(log.data + log.length, "`,`,0x%x",ret);
107 //              //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
108 //              log.length += sprintf(log.data + log.length,
109 //                              "`,0`,%ld`,%d`,0`,%u`,0x%x`,%d`,%d`,`,", res,blockresult,
110 //                              (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
111 //              //callstack
112 //              log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
113 //              getBacktraceString(&log, 4096 - log.length - 17);
114 //              log.length += sprintf(log.data + log.length, "`,callstack_end");
115 //
116 //              printLog(&log, MSG_LOG);
117 //              postBlockEnd();
118 //      }
119 //      return ret;
120 //}
121
122 void*
123 _ThreadImpl::ThreadProc(void* params) {
124         typedef void*
125         (*methodType)(void*);
126         static methodType ThreadProcp = 0;
127         probeInfo_t probeInfo;
128         int blockresult;
129         bool bfiltering = false;
130         void *tmpPtr;
131
132         if (!ThreadProcp) {
133                 probeBlockStart();
134                 if(lib_handle[LIBOSP_APPFW] == NULL) {
135                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
136                         if (lib_handle[LIBOSP_APPFW] == NULL) {
137                                 perror("dlopen failed : libosp-appfw.so");
138                                 exit(0);
139                         }
140                 }
141                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime11_ThreadImpl10ThreadProcEPv");
142
143                 if (tmpPtr == NULL || dlerror() != NULL) {
144                         perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::ThreadProc");
145                         exit(0);
146                 }
147
148                 memcpy(&ThreadProcp, &tmpPtr, sizeof(tmpPtr));
149
150                 probeBlockEnd();
151         }
152
153         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
154                 setProbePoint(&probeInfo);
155
156                 _ThreadImpl* pSelf =(_ThreadImpl*)params;
157                 const Thread* pThread = NULL;
158                 if(pSelf != null){
159                         pThread = pSelf->GetThread();
160                 }
161
162                 PREPARE_LOCAL_BUF();
163                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
164                                   API_ID_void___ThreadImpl__ThreadProc_void__params_,
165                                   "p", voidp_to_uint64(params));
166                 PACK_COMMON_END((unsigned int)pSelf, 0, blockresult);
167                 PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_START);
168                 FLUSH_LOCAL_BUF();
169
170                 preBlockEnd();
171                 probingEnd();
172         }
173         // all probe should be reachable inside thread start_routine (user implemented Thread::Run)
174         (ThreadProcp)(params);
175         //
176         if (postBlockBegin(blockresult)) {
177                 probingStart();
178                 setProbePoint(&probeInfo);
179
180                 _ThreadImpl* pSelf =(_ThreadImpl*)params;
181                 const Thread* pThread = NULL;
182                 if(pSelf != null){
183                         pThread = pSelf->GetThread();
184                 }
185
186                 PREPARE_LOCAL_BUF();
187                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
188                                   API_ID_void___ThreadImpl__ThreadProc_void__params_,
189                                   "p", voidp_to_uint64(params));
190                 PACK_COMMON_END((unsigned int)pSelf, 0, blockresult);
191                 PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_STOP);
192                 FLUSH_LOCAL_BUF();
193
194                 postBlockEnd();
195         }
196         return null;
197 }
198 //result _ThreadImpl::Stop(void) {
199 //      typedef result
200 //      (_ThreadImpl::*methodType)(void);
201 //      static methodType Stopp = 0;
202 //      probeInfo_t probeInfo;
203 //      log_t log;
204 //      int blockresult;
205 //      bool bfiltering = true;
206 //      void *tmpPtr;
207 //
208 //      if (!Stopp) {
209 //              probeBlockStart();
210 //              void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
211 //              if (lib_handle == NULL) {
212 //                      perror("dlopen failed : libosp-appfw.so");
213 //                      exit(0);
214 //              }
215 //              tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime11_ThreadImpl4StopEv");
216 //
217 //              if (tmpPtr == NULL || dlerror() != NULL) {
218 //                      perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::Stopp");
219 //                      exit(0);
220 //              }
221 //
222 //              memcpy(&Stopp, &tmpPtr, sizeof(tmpPtr));
223 //
224 //              probeBlockEnd();
225 //      }
226 //
227 //      if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
228 //              setProbePoint(&probeInfo);
229 //              preBlockEnd();
230 //      }
231 //      //
232 //      result ret= (this->*Stopp)();
233 //      //
234 //      if (postBlockBegin(blockresult)) {
235 //              log.type = 0;
236 //              log.length = 0;
237 //              log.data[0] = '\0';
238 //              log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
239 //                              probeInfo.eventIndex, "_ThreadImpl::Stop", probeInfo.currentTime,
240 //                              probeInfo.pID, probeInfo.tID);
241 //              //Input,ret
242 //              log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
243 //              //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
244 //              log.length += sprintf(log.data + log.length,
245 //                              "`,0`,%ld`,%d`,0`,%u`,0x%x`,%d`,%d`,`,", ret, blockresult,
246 //                              (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_CLOSE);
247 //              //callstack
248 //              log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
249 //              getBacktraceString(&log, 4096 - log.length - 17);
250 //              log.length += sprintf(log.data + log.length, "`,callstack_end");
251 //
252 //              printLog(&log, MSG_LOG);
253 //              postBlockEnd();
254 //      }
255 //      return ret;
256 //}
257 //
258 //result _ThreadImpl::Finalize(void) {
259 //      typedef result
260 //      (_ThreadImpl::*methodType)(void);
261 //      static methodType Finalizep = 0;
262 //      probeInfo_t probeInfo;
263 //      log_t log;
264 //      int blockresult;
265 //      bool bfiltering = false;
266 //      void *tmpPtr;
267 //
268 //      if (!Finalizep) {
269 //              probeBlockStart();
270 //              void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
271 //              if (lib_handle == NULL) {
272 //                      perror("dlopen failed : libosp-appfw.so");
273 //                      exit(0);
274 //              }
275 //              tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime11_ThreadImpl8FinalizeEv");
276 //
277 //              if (tmpPtr == NULL || dlerror() != NULL) {
278 //                      perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::Finalizep");
279 //                      exit(0);
280 //              }
281 //
282 //              memcpy(&Finalizep, &tmpPtr, sizeof(tmpPtr));
283 //              probeBlockEnd();
284 //      }
285 //
286 //      if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
287 //              setProbePoint(&probeInfo);
288 //              preBlockEnd();
289 //      }
290 //      //
291 //      result ret= (this->*Finalizep)();
292 //      //
293 //      if (postBlockBegin(blockresult)) {
294 //              log.type = 0;
295 //              log.length = 0;
296 //              log.data[0] = '\0';
297 //              log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
298 //                              probeInfo.eventIndex, "_ThreadImpl::Finalize", probeInfo.currentTime,
299 //                              probeInfo.pID, probeInfo.tID);
300 //              //Input,ret
301 //              log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
302 //              //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
303 //              log.length += sprintf(log.data + log.length,
304 //                              "`,0`,%ld`,%d`,0`,%u`,0x%x`,%d`,%d`,`,", ret, blockresult,
305 //                              (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_CLOSE);
306 //              //callstack
307 //              log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
308 //              getBacktraceString(&log, 4096 - log.length - 17);
309 //              log.length += sprintf(log.data + log.length, "`,callstack_end");
310 //
311 //              printLog(&log, MSG_LOG);
312 //              postBlockEnd();
313 //      }
314 //      return ret;
315 //}
316 //Thread::Thread(void) {
317 //      typedef void (Thread::*methodType)();
318 //      static methodType Threadp = 0;
319 //      probeInfo_t probeInfo;
320 //      log_t log;
321 //      int blockresult;
322 //      bool bfiltering = true;
323 //      void *tmpPtr;
324 //
325 //      if (!Threadp) {
326 //              probeBlockStart();
327 //
328 //              tmpPtr = dlsym(RTLD_NEXT, "_ZN5Tizen4Base7Runtime6ThreadC1Ev");
329 //
330 //              if (tmpPtr == NULL || dlerror() != NULL) {
331 //                      log.type = 0;
332 //                                                                                      log.length = 0;
333 //                                                                                      log.data[0] = '\0';
334 //                                                                                      log.length = sprintf(log.data,"dlsym failed : Tizen::Base::Runtime::Thread::Thread");
335 //                      perror("dlsym failed : Tizen::Base::Runtime::Thread::Thread");
336 //                      printLog(&log, MSG_MSG);
337 //                      return;
338 //              }
339 //
340 //              memcpy(&Threadp, &tmpPtr, sizeof(tmpPtr));
341 //              probeBlockEnd();
342 //      }
343 //
344 //      if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
345 //              setProbePoint(&probeInfo);
346 //              preBlockEnd();
347 //      }
348 ////
349 //      (this->*Threadp)();
350 ////
351 //      if (postBlockBegin(blockresult)) {
352 //              log.type = 0;
353 //              log.length = 0;
354 //              log.data[0] = '\0';
355 //              log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
356 //                              probeInfo.eventIndex, "Thread::Thread", probeInfo.currentTime,
357 //                              probeInfo.pID, probeInfo.tID);
358 //              //Input,ret
359 //              log.length += sprintf(log.data + log.length, "`,`,");
360 //              //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
361 //
362 //              log.length += sprintf(log.data + log.length,
363 //                              "`,0`,0`,%d`,0`,0x%x`,%d`,%d`,`,", blockresult,
364 //                              (unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OPEN);
365 //              //callstack
366 //              log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
367 //              getBacktraceString(&log, 4096 - log.length - 17);
368 //              log.length += sprintf(log.data + log.length, "`,callstack_end");
369 //
370 //              printLog(&log, MSG_LOG);
371 //              postBlockEnd();
372 //      }
373 //}
374 //
375 //Thread::~Thread(void) {
376 //      typedef void (Thread::*methodType)();
377 //      static methodType ThreadDp = 0;
378 //      probeInfo_t probeInfo;
379 //      log_t log;
380 //      int blockresult;
381 //      bool bfiltering = true;
382 //      void *tmpPtr;
383 //
384 //      if (!ThreadDp) {
385 //              probeBlockStart();
386 //
387 //              void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
388 //              if (lib_handle == NULL) {
389 //                      perror("dlopen failed : libosp-appfw.so");
390 //                      exit(0);
391 //              }
392 //              tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime6ThreadD0Ev");
393 //
394 //              if (tmpPtr == NULL || dlerror() != NULL) {
395 //                      perror("dlsym failed : Tizen::Base::Runtime::Thread::~Thread");
396 //                      exit(0);
397 //              }
398 //
399 //              memcpy(&ThreadDp, &tmpPtr, sizeof(tmpPtr));
400 //              probeBlockEnd();
401 //      }
402 //
403 //      if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
404 //              setProbePoint(&probeInfo);
405 //              preBlockEnd();
406 //      }
407 ////
408 //      (this->*ThreadDp)();
409 ////
410 //      if (postBlockBegin(blockresult)) {
411 //              log.type = 0;
412 //              log.length = 0;
413 //              log.data[0] = '\0';
414 //              log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
415 //                              probeInfo.eventIndex, "Thread::~Thread", probeInfo.currentTime,
416 //                              probeInfo.pID, probeInfo.tID);
417 //              //Input,ret
418 //              log.length += sprintf(log.data + log.length, "`,`,");
419 //              //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
420 //
421 //              log.length += sprintf(log.data + log.length,
422 //                              "`,0`,0`,%d`,0`,0x%x`,%d`,%d`,`,", blockresult,
423 //                              (unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_CLOSE);
424 //              //callstack
425 //              log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
426 //              getBacktraceString(&log, 4096 - log.length - 17);
427 //              log.length += sprintf(log.data + log.length, "`,callstack_end");
428 //
429 //              printLog(&log, MSG_LOG);
430 //              postBlockEnd();
431 //      }
432 //}
433 result Thread::Sleep(long milliSeconds) {
434         typedef result
435         (*methodType)(long);
436         static methodType Sleepp = 0;
437         probeInfo_t probeInfo;
438         int blockresult;
439         bool bfiltering = true;
440         void *tmpPtr;
441
442         if (!Sleepp) {
443                 probeBlockStart();
444                 if(lib_handle[LIBOSP_APPFW] == NULL) {
445                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
446                         if (lib_handle[LIBOSP_APPFW] == NULL) {
447                                 perror("dlopen failed : libosp-appfw.so");
448                                 exit(0);
449                         }
450                 }
451                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5SleepEl");
452
453                 if (tmpPtr == NULL || dlerror() != NULL) {
454                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Sleep");
455                         exit(0);
456                 }
457
458                 memcpy(&Sleepp, &tmpPtr, sizeof(tmpPtr));
459
460                 probeBlockEnd();
461         }
462
463         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
464                 setProbePoint(&probeInfo);
465
466                 Thread *currentThread;
467                 currentThread = GetCurrentThread();
468
469                 PREPARE_LOCAL_BUF();
470                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
471                                   API_ID_result_Thread__Sleep_long_milliSeconds_,
472                                   "x", (uint64_t)(milliSeconds));
473                 PACK_COMMON_END(0, 0, blockresult);
474                 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START);
475                 FLUSH_LOCAL_BUF();
476
477                 preBlockEnd();
478         }
479         //
480         result ret = (Sleepp)(milliSeconds);
481         //
482         if (postBlockBegin(blockresult)) {
483                 setProbePoint(&probeInfo);
484
485                 Thread *currentThread;
486                 currentThread = GetCurrentThread();
487
488                 PREPARE_LOCAL_BUF();
489                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
490                                   API_ID_result_Thread__Yield_void_,
491                                   "x", (uint64_t)(milliSeconds));
492                 PACK_COMMON_END(ret, ret, blockresult);
493                 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END);
494                 FLUSH_LOCAL_BUF();
495
496                 postBlockEnd();
497         }
498         return ret;
499 }
500
501 Thread* Thread::GetCurrentThread(void) {
502         typedef Thread*
503                 (*methodType)(void);
504         static methodType GetCurrentThreadp = 0;
505         probeInfo_t probeInfo;
506         int blockresult;
507         bool bfiltering = true;
508         void *tmpPtr;
509
510         if (!GetCurrentThreadp) {
511                 probeBlockStart();
512                 if(lib_handle[LIBOSP_APPFW] == NULL) {
513                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
514                         if (lib_handle[LIBOSP_APPFW] == NULL) {
515                                 perror("dlopen failed : libosp-appfw.so");
516                                 exit(0);
517                         }
518                 }
519                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread16GetCurrentThreadEv");
520
521                 if (tmpPtr == NULL || dlerror() != NULL) {
522                         perror("dlsym failed : Tizen::Base::Runtime::Thread::GetCurrentThread");
523                         exit(0);
524                 }
525
526                 memcpy(&GetCurrentThreadp, &tmpPtr, sizeof(tmpPtr));
527
528                 probeBlockEnd();
529         }
530
531         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
532                 setProbePoint(&probeInfo);
533                 preBlockEnd();
534         }
535         //
536         Thread *currentThread = (GetCurrentThreadp)();
537         result res = GetLastResult();
538         //
539         if (postBlockBegin(blockresult)) {
540
541                 PREPARE_LOCAL_BUF();
542                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
543                                   API_ID_Thread__Thread__GetCurrentThread_void_,
544                                   "", 0);
545                 PACK_COMMON_END((unsigned int)currentThread, res, blockresult);
546                 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
547                 FLUSH_LOCAL_BUF();
548
549                 postBlockEnd();
550         }
551         return currentThread;
552 }
553
554 result Thread::Yield(void) {
555         typedef result
556                 (*methodType)(void);
557         static methodType Yieldp = 0;
558         probeInfo_t probeInfo;
559         int blockresult;
560         bool bfiltering = true;
561         void *tmpPtr;
562
563         if (!Yieldp) {
564                 probeBlockStart();
565                 if(lib_handle[LIBOSP_APPFW] == NULL) {
566                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
567                         if (lib_handle[LIBOSP_APPFW] == NULL) {
568                                 perror("dlopen failed : libosp-appfw.so");
569                                 exit(0);
570                         }
571                 }
572                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5YieldEv");
573
574                 if (tmpPtr == NULL || dlerror() != NULL) {
575                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Yield");
576                         exit(0);
577                 }
578
579                 memcpy(&Yieldp, &tmpPtr, sizeof(tmpPtr));
580
581                 probeBlockEnd();
582         }
583
584         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
585                 setProbePoint(&probeInfo);
586                 preBlockEnd();
587         }
588         //
589         result ret = (Yieldp)();
590         //
591         if (postBlockBegin(blockresult)) {
592                 Thread *currentThread;
593                 currentThread = GetCurrentThread();
594
595                 PREPARE_LOCAL_BUF();
596                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
597                                   API_ID_result_Thread__Yield_void_,
598                                   "", 0);
599                 PACK_COMMON_END(ret, ret, blockresult);
600                 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
601                 FLUSH_LOCAL_BUF();
602
603                 postBlockEnd();
604         }
605         return ret;
606 }
607
608 result Thread::Exit(int exitCode) {
609         typedef result
610                 (*methodType)(int exitCode);
611         static methodType Exitp = 0;
612         probeInfo_t probeInfo;
613         int blockresult;
614         bool bfiltering = true;
615         void *tmpPtr;
616
617         if (!Exitp) {
618                 probeBlockStart();
619                 if(lib_handle[LIBOSP_APPFW] == NULL) {
620                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
621                         if (lib_handle[LIBOSP_APPFW] == NULL) {
622                                 perror("dlopen failed : libosp-appfw.so");
623                                 exit(0);
624                         }
625                 }
626                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4ExitEi");
627
628                 if (tmpPtr == NULL || dlerror() != NULL) {
629                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Exit");
630                         exit(0);
631                 }
632
633                 memcpy(&Exitp, &tmpPtr, sizeof(tmpPtr));
634
635                 probeBlockEnd();
636         }
637
638         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
639                 setProbePoint(&probeInfo);
640
641                 Thread *currentThread;
642                 currentThread = GetCurrentThread();
643
644                 PREPARE_LOCAL_BUF();
645                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
646                                   API_ID_result_Thread__Exit_int_exitCode_,
647                                   "d", exitCode);
648                 PACK_COMMON_END(0, 0, blockresult);
649                 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_EXIT);
650                 FLUSH_LOCAL_BUF();
651
652                 preBlockEnd();
653         }
654         //
655         result ret = (Exitp)(exitCode);
656         //
657         return ret;
658 }
659
660 result Thread::Construct(ThreadType threadType, long stackSize,
661                 ThreadPriority priority) {
662         typedef result
663         (Thread::*methodType)(ThreadType threadType, long stackSize,
664                         ThreadPriority priority);
665         static methodType Constructp = 0;
666         result ret;
667         probeInfo_t probeInfo;
668         int blockresult;
669         bool bfiltering = true;
670         void *tmpPtr;
671
672         if (!Constructp) {
673                 probeBlockStart();
674                 if(lib_handle[LIBOSP_APPFW] == NULL) {
675                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
676                         if (lib_handle[LIBOSP_APPFW] == NULL) {
677                                 perror("dlopen failed : libosp-appfw.so");
678                                 exit(0);
679                         }
680                 }
681                 tmpPtr =
682                                 dlsym(
683                                                 lib_handle[LIBOSP_APPFW],
684                                                 "_ZN5Tizen4Base7Runtime6Thread9ConstructENS1_10ThreadTypeElNS1_14ThreadPriorityE");
685
686                 if (tmpPtr == NULL || dlerror() != NULL) {
687                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
688                         exit(0);
689                 }
690
691                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
692                 probeBlockEnd();
693         }
694
695         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
696                 setProbePoint(&probeInfo);
697                 preBlockEnd();
698         }
699         //
700         ret = (this->*Constructp)(threadType, stackSize, priority);
701         //
702         if (postBlockBegin(blockresult)) {
703
704                 PREPARE_LOCAL_BUF();
705                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
706                                   API_ID_result_Thread__Construct_ThreadType_threadType__long_stackSize__ThreadPriority_priority_,
707                                   "dxd", threadType, (uint64_t)(stackSize),
708                                   priority);
709                 PACK_COMMON_END(ret, ret, blockresult);
710                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
711                 FLUSH_LOCAL_BUF();
712
713                 postBlockEnd();
714         }
715         return ret;
716 }
717 result Thread::Construct(long stackSize, ThreadPriority priority) {
718         typedef result
719         (Thread::*methodType)(long stackSize, ThreadPriority priority);
720         static methodType Constructp = 0;
721         result ret;
722         probeInfo_t probeInfo;
723         int blockresult;
724         bool bfiltering = true;
725         void *tmpPtr;
726
727         if (!Constructp) {
728                 probeBlockStart();
729                 if(lib_handle[LIBOSP_APPFW] == NULL) {
730                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
731                         if (lib_handle[LIBOSP_APPFW] == NULL) {
732                                 perror("dlopen failed : libosp-appfw.so");
733                                 exit(0);
734                         }
735                 }
736                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW],
737                                 "_ZN5Tizen4Base7Runtime6Thread9ConstructElNS1_14ThreadPriorityE");
738                 if (tmpPtr == NULL || dlerror() != NULL) {
739                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
740                         exit(0);
741                 }
742
743                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
744                 probeBlockEnd();
745         }
746
747         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
748                 setProbePoint(&probeInfo);
749                 preBlockEnd();
750         }
751         //
752         ret = (this->*Constructp)(stackSize, priority);
753         //
754         if (postBlockBegin(blockresult)) {
755
756                 PREPARE_LOCAL_BUF();
757                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
758                                   API_ID_result_Thread__Construct_long_stackSize__ThreadPriority_priority_,
759                                   "xd", (uint64_t)(stackSize), priority);
760                 PACK_COMMON_END(ret, ret, blockresult);
761                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
762                 FLUSH_LOCAL_BUF();
763
764                 postBlockEnd();
765         }
766         return ret;
767 }
768 result Thread::Construct(const Tizen::Base::String &name, long stackSize,
769                 ThreadPriority priority) {
770         typedef result
771         (Thread::*methodType)(const Tizen::Base::String &name, long stackSize,
772                         ThreadPriority priority);
773         static methodType Constructp = 0;
774         result ret;
775         probeInfo_t probeInfo;
776         int blockresult;
777         bool bfiltering = true;
778         void *tmpPtr;
779         char temp[50];
780
781         if (!Constructp) {
782                 probeBlockStart();
783                 if(lib_handle[LIBOSP_APPFW] == NULL) {
784                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
785                         if (lib_handle[LIBOSP_APPFW] == NULL) {
786                                 perror("dlopen failed : libosp-appfw.so");
787                                 exit(0);
788                         }
789                 }
790                 tmpPtr =
791                                 dlsym(
792                                                 lib_handle[LIBOSP_APPFW],
793                                                 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringElNS1_14ThreadPriorityE");
794
795                 if (tmpPtr == NULL || dlerror() != NULL) {
796                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
797                         exit(0);
798                 }
799
800                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
801                 probeBlockEnd();
802         }
803
804         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
805                 setProbePoint(&probeInfo);
806                 preBlockEnd();
807         }
808         //
809         ret = (this->*Constructp)(name, stackSize, priority);
810         //
811         if (postBlockBegin(blockresult)) {
812
813                 PREPARE_LOCAL_BUF();
814                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
815                                   API_ID_result_Thread__Construct_const_Tizen__Base__String__name__long_stackSize__ThreadPriority_priority_,
816                                   "sxd", temp, (uint64_t)(stackSize), priority);
817                 PACK_COMMON_END(ret, ret, blockresult);
818                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
819                 FLUSH_LOCAL_BUF();
820
821                 postBlockEnd();
822         }
823         return ret;
824 }
825 result Thread::Construct(const Tizen::Base::String &name, ThreadType threadType,
826                 long stackSize, ThreadPriority priority) {
827         typedef result
828         (Thread::*methodType)(const Tizen::Base::String &name, ThreadType threadType,
829                         long stackSize, ThreadPriority priority);
830         static methodType Constructp = 0;
831         result ret;
832         probeInfo_t probeInfo;
833         int blockresult;
834         bool bfiltering = true;
835         void *tmpPtr;
836         char temp[50];
837
838         if (!Constructp) {
839                 probeBlockStart();
840                 if(lib_handle[LIBOSP_APPFW] == NULL) {
841                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
842                         if (lib_handle[LIBOSP_APPFW] == NULL) {
843                                 perror("dlopen failed : libosp-appfw.so");
844                                 exit(0);
845                         }
846                 }
847
848                 tmpPtr =
849                                 dlsym(
850                                                 lib_handle[LIBOSP_APPFW],
851                                                 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringENS1_10ThreadTypeElNS1_14ThreadPriorityE");
852                 if (tmpPtr == NULL || dlerror() != NULL) {
853                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
854                         exit(0);
855                 }
856
857                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
858                 probeBlockEnd();
859         }
860
861         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
862                 setProbePoint(&probeInfo);
863                 preBlockEnd();
864         }
865         //
866         ret = (this->*Constructp)(name, threadType, stackSize, priority);
867         //
868         if (postBlockBegin(blockresult)) {
869
870                 WcharToChar(temp, name.GetPointer());
871
872                 PREPARE_LOCAL_BUF();
873                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
874                                   API_ID_result_Thread__Construct_const_Tizen__Base__String__name__ThreadType_threadType__long_stackSize__ThreadPriority_priority_,
875                                   "sdxd", temp, threadType,
876                                   (uint64_t)(stackSize), priority);
877                 PACK_COMMON_END(ret, ret, blockresult);
878                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
879                 FLUSH_LOCAL_BUF();
880
881                 postBlockEnd();
882         }
883         return ret;
884 }
885 result Thread::Construct(IRunnable &target, long stackSize,
886                 ThreadPriority priority) {
887         typedef result
888         (Thread::*methodType)(IRunnable &target, long stackSize,
889                         ThreadPriority priority);
890         static methodType Constructp = 0;
891         result ret;
892         probeInfo_t probeInfo;
893         int blockresult;
894         bool bfiltering = true;
895         void *tmpPtr;
896
897         if (!Constructp) {
898                 probeBlockStart();
899                 if(lib_handle[LIBOSP_APPFW] == NULL) {
900                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
901                         if (lib_handle[LIBOSP_APPFW] == NULL) {
902                                 perror("dlopen failed : libosp-appfw.so");
903                                 exit(0);
904                         }
905                 }
906                 tmpPtr =
907                                 dlsym(
908                                                 lib_handle[LIBOSP_APPFW],
909                                                 "_ZN5Tizen4Base7Runtime6Thread9ConstructERNS1_9IRunnableElNS1_14ThreadPriorityE");
910
911                 if (tmpPtr == NULL || dlerror() != NULL) {
912                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
913                         exit(0);
914                 }
915
916                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
917                 probeBlockEnd();
918         }
919
920         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
921                 setProbePoint(&probeInfo);
922                 preBlockEnd();
923         }
924         //
925         ret = (this->*Constructp)(target, stackSize, priority);
926         //
927         if (postBlockBegin(blockresult)) {
928
929                 PREPARE_LOCAL_BUF();
930                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
931                                   API_ID_result_Thread__Construct_IRunnable__target__long_stackSize__ThreadPriority_priority_,
932                                   "xxd", (uint64_t)(&target),
933                                   (uint64_t)(stackSize), priority);
934                 PACK_COMMON_END(ret, ret, blockresult);
935                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
936                 FLUSH_LOCAL_BUF();
937
938                 postBlockEnd();
939         }
940         return ret;
941 }
942 result Thread::Construct(const Tizen::Base::String &name, IRunnable &target,
943                 long stackSize, ThreadPriority priority) {
944         typedef result
945         (Thread::*methodType)(const Tizen::Base::String &name, IRunnable &target,
946                         long stackSize, ThreadPriority priority);
947         static methodType Constructp = 0;
948         result ret;
949         probeInfo_t probeInfo;
950         int blockresult;
951         bool bfiltering = true;
952         void *tmpPtr;
953         char temp[50];
954
955         if (!Constructp) {
956                 probeBlockStart();
957                 if(lib_handle[LIBOSP_APPFW] == NULL) {
958                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
959                         if (lib_handle[LIBOSP_APPFW] == NULL) {
960                                 perror("dlopen failed : libosp-appfw.so");
961                                 exit(0);
962                         }
963                 }
964                 tmpPtr =
965                                 dlsym(
966                                                 lib_handle[LIBOSP_APPFW],
967                                                 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringERNS1_9IRunnableElNS1_14ThreadPriorityE");
968
969                 if (tmpPtr == NULL || dlerror() != NULL) {
970                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
971                         exit(0);
972                 }
973
974                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
975                 probeBlockEnd();
976         }
977
978         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
979                 setProbePoint(&probeInfo);
980                 preBlockEnd();
981         }
982         //
983         ret = (this->*Constructp)(name, target, stackSize, priority);
984         //
985         if (postBlockBegin(blockresult)) {
986
987                 WcharToChar(temp, name.GetPointer());
988
989                 PREPARE_LOCAL_BUF();
990                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
991                                   API_ID_result_Thread__Construct_const_Tizen__Base__String__name__IRunnable__target__long_stackSize__ThreadPriority_priority_,
992                                   "sxxd", temp, (uint64_t)(&target),
993                                   (uint64_t)(stackSize), priority);
994                 PACK_COMMON_END(ret, ret, blockresult);
995                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
996                 FLUSH_LOCAL_BUF();
997
998                 postBlockEnd();
999         }
1000         return ret;
1001 }
1002
1003 result Thread::GetExitCode(int &exitCode) const {
1004         typedef result
1005         (Thread::*methodType)(int &exitCode) const;
1006         static methodType GetExitCodep = 0;
1007         result ret;
1008         probeInfo_t probeInfo;
1009         int blockresult;
1010         bool bfiltering = true;
1011         void *tmpPtr;
1012 //      int exitOld = exitCode;
1013
1014         if (!GetExitCodep) {
1015                 probeBlockStart();
1016                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1017                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1018                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1019                                 perror("dlopen failed : libosp-appfw.so");
1020                                 exit(0);
1021                         }
1022                 }
1023                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW],
1024                                 "_ZNK5Tizen4Base7Runtime6Thread11GetExitCodeERi");
1025
1026                 if (tmpPtr == NULL || dlerror() != NULL) {
1027                         perror("dlsym failed : Tizen::Base::Runtime::Thread::GetExitCode");
1028                         exit(0);
1029                 }
1030
1031                 memcpy(&GetExitCodep, &tmpPtr, sizeof(tmpPtr));
1032                 probeBlockEnd();
1033         }
1034
1035         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1036                 setProbePoint(&probeInfo);
1037                 preBlockEnd();
1038         }
1039         //
1040         ret = (this->*GetExitCodep)(exitCode);
1041         //
1042         if (postBlockBegin(blockresult)) {
1043
1044                 PREPARE_LOCAL_BUF();
1045                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1046                                   API_ID_result_Thread__GetExitCode_int__exitCode__const,
1047                                   "d", exitCode);
1048                 PACK_COMMON_END(ret, ret, blockresult);
1049                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
1050                 FLUSH_LOCAL_BUF();
1051
1052                 postBlockEnd();
1053         }
1054         return ret;
1055 }
1056
1057 const Tizen::Base::String & Thread::GetName(void) const {
1058         typedef const Tizen::Base::String &
1059         (Thread::*methodType)(void) const;
1060         static methodType GetNamep = 0;
1061         probeInfo_t probeInfo;
1062         int blockresult;
1063         bool bfiltering = true;
1064         void *tmpPtr;
1065         char temp[50];
1066
1067         if (!GetNamep) {
1068                 probeBlockStart();
1069                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1070                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1071                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1072                                 perror("dlopen failed : libosp-appfw.so");
1073                                 exit(0);
1074                         }
1075                 }
1076                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZNK5Tizen4Base7Runtime6Thread7GetNameEv");
1077
1078                 if (tmpPtr == NULL || dlerror() != NULL) {
1079                         perror("dlsym failed : Tizen::Base::Runtime::Thread::GetName");
1080                         exit(0);
1081                 }
1082
1083                 memcpy(&GetNamep, &tmpPtr, sizeof(tmpPtr));
1084                 probeBlockEnd();
1085         }
1086
1087         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1088                 setProbePoint(&probeInfo);
1089                 preBlockEnd();
1090         }
1091         //
1092         const Tizen::Base::String& ret = (this->*GetNamep)();
1093         result res = GetLastResult();
1094         //
1095         if (postBlockBegin(blockresult)) {
1096
1097                 WcharToChar(temp, ret.GetPointer());
1098
1099                 PREPARE_LOCAL_BUF();
1100                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1101                                   API_ID_const_Tizen__Base__String___Thread__GetName_void__const,
1102                                   "", 0);
1103                 PACK_COMMON_END(ret.GetPointer(), res, blockresult);
1104                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
1105                 FLUSH_LOCAL_BUF();
1106
1107                 postBlockEnd();
1108         }
1109         return ret;
1110 }
1111
1112 result Thread::Join(void) {
1113         typedef result
1114         (Thread::*methodType)(void);
1115         static methodType Joinp = 0;
1116         result ret;
1117         probeInfo_t probeInfo;
1118         int blockresult;
1119         bool bfiltering = true;
1120         void *tmpPtr;
1121
1122         if (!Joinp) {
1123                 probeBlockStart();
1124                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1125                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1126                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1127                                 perror("dlopen failed : libosp-appfw.so");
1128                                 exit(0);
1129                         }
1130                 }
1131                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4JoinEv");
1132
1133                 if (tmpPtr == NULL || dlerror() != NULL) {
1134                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Join");
1135                         exit(0);
1136                 }
1137
1138                 memcpy(&Joinp, &tmpPtr, sizeof(tmpPtr));
1139                 probeBlockEnd();
1140         }
1141
1142         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1143                 setProbePoint(&probeInfo);
1144
1145                 PREPARE_LOCAL_BUF();
1146                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1147                                   API_ID_result_Thread__Join_void_,
1148                                   "", 0);
1149                 PACK_COMMON_END(0, 0, blockresult);
1150                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START);
1151                 FLUSH_LOCAL_BUF();
1152
1153                 preBlockEnd();
1154         }
1155         //
1156         ret = (this->*Joinp)();
1157         //
1158         if (postBlockBegin(blockresult)) {
1159                 setProbePoint(&probeInfo);
1160
1161                 PREPARE_LOCAL_BUF();
1162                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1163                                   API_ID_result_Thread__Join_void_,
1164                                   "", 0);
1165                 PACK_COMMON_END(ret, ret, blockresult);
1166                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END);
1167                 FLUSH_LOCAL_BUF();
1168
1169                 postBlockEnd();
1170         }
1171         return ret;
1172 }
1173 //Tizen::Base::Object * Thread::Run(void) {
1174 //      typedef Tizen::Base::Object * (Thread::*methodType)(void);
1175 //      static methodType Runp = 0;
1176 //      Tizen::Base::Object * ret;
1177 //      probeInfo_t probeInfo;
1178 //      log_t log;
1179 //      int blockresult;
1180 //      bool bfiltering = true;
1181 //      void *tmpPtr;
1182 //      log.type = 0;
1183 //                              log.length = 0;
1184 //                              log.data[0] = '\0';
1185 //                              log.length = sprintf(log.data, "call Thread::Run");
1186 //                              printLog(&log, MSG_MSG);
1187 //                              return null;
1188 //      if (!Runp) {
1189 //              probeBlockStart();
1190 //              void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
1191 //              if (lib_handle == NULL) {
1192 //                      perror("dlopen failed : libosp-appfw.so");
1193 //                      log.type = 0;
1194 //                      log.length = 0;
1195 //                      log.data[0] = '\0';
1196 //                      log.length = sprintf(log.data, "dlopen failed :libosp-appfw.so");
1197 //                      printLog(&log, MSG_MSG);
1198 //                      return null;
1199 //              }
1200 //              tmpPtr =
1201 //                              dlsym(
1202 //                                              RTLD_NEXT,
1203 //                                              "_ZN5Tizen4Base7Runtime6Thread3RunEv");
1204 //
1205 //              if (tmpPtr == NULL || dlerror() != NULL) {
1206 //                      perror("dlsym failed : Thread::Run");
1207 //                      log.type = 0;
1208 //                      log.length = 0;
1209 //                      log.data[0] = '\0';
1210 //                      log.length = sprintf(log.data, "dlsym failed : Thread::Run");
1211 //                      printLog(&log, MSG_MSG);
1212 //                      return null;
1213 //              }
1214 //
1215 //              memcpy(&Runp, &tmpPtr, sizeof(tmpPtr));
1216 //              probeBlockEnd();
1217 //      }
1218 //
1219 //      if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1220 //              setProbePoint(&probeInfo);
1221 //              preBlockEnd();
1222 //      }
1223 //      //
1224 //      ret = (this->*Runp)();
1225 //      //
1226 //      if (postBlockBegin(blockresult)) {
1227 //              log.type = 0;
1228 //              log.length = 0;
1229 //              log.data[0] = '\0';
1230 //              log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1231 //                              probeInfo.eventIndex, "Thread::Run",
1232 //                              probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1233 //              //Input,ret
1234 //              log.length += sprintf(log.data + log.length, "`,`,0x%x",(unsigned int)ret;
1235 //              //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
1236 //
1237 //
1238 //              log.length += sprintf(log.data + log.length,
1239 //                              "`,0`,0`,%d`,0`,0x%x`,%d`,%d`,`,", blockresult,
1240 //                              (unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
1241 //              //callstack
1242 //              log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1243 //              getBacktraceString(&log, 4096 - log.length - 17);
1244 //              log.length += sprintf(log.data + log.length, "`,callstack_end");
1245 //
1246 //              printLog(&log, MSG_LOG);
1247 //              postBlockEnd();
1248 //      }
1249 //      return ret;
1250 //}
1251
1252 result Thread::Start(void) {
1253         typedef result (Thread::*methodType)(void);
1254         static methodType Startp = 0;
1255         result ret;
1256         probeInfo_t probeInfo;
1257         int blockresult;
1258         bool bfiltering = true;
1259         void *tmpPtr;
1260
1261         if (!Startp) {
1262                 probeBlockStart();
1263                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1264                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1265                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1266                                 perror("dlopen failed : libosp-appfw.so");
1267                                 exit(0);
1268                         }
1269                 }
1270                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5StartEv");
1271
1272                 if (tmpPtr == NULL || dlerror() != NULL) {
1273                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Start");
1274                         exit(0);
1275                 }
1276
1277                 memcpy(&Startp, &tmpPtr, sizeof(tmpPtr));
1278                 probeBlockEnd();
1279         }
1280
1281         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1282                 setProbePoint(&probeInfo);
1283                 preBlockEnd();
1284         }
1285         //
1286         ret = (this->*Startp)();
1287         //
1288         if (postBlockBegin(blockresult)) {
1289
1290                 PREPARE_LOCAL_BUF();
1291                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1292                                   API_ID_result_Thread__Start_void_,
1293                                   "", 0);
1294                 PACK_COMMON_END(ret, ret, blockresult);
1295                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_START);
1296                 FLUSH_LOCAL_BUF();
1297
1298                 postBlockEnd();
1299         }
1300         return ret;
1301 }
1302 result Thread::Stop(void) {
1303         typedef result (Thread::*methodType)(void);
1304         static methodType Stopp = 0;
1305         result ret;
1306         probeInfo_t probeInfo;
1307         int blockresult;
1308         bool bfiltering = true;
1309         void *tmpPtr;
1310
1311         if (!Stopp) {
1312                 probeBlockStart();
1313                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1314                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1315                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1316                                 perror("dlopen failed : libosp-appfw.so");
1317                                 exit(0);
1318                         }
1319                 }
1320                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4StopEv");
1321
1322                 if (tmpPtr == NULL || dlerror() != NULL) {
1323                         perror("dlsym failed : Tizen::Base::Runtime::Thread::Stop");
1324                         exit(0);
1325                 }
1326
1327                 memcpy(&Stopp, &tmpPtr, sizeof(tmpPtr));
1328                 probeBlockEnd();
1329         }
1330
1331         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1332                 setProbePoint(&probeInfo);
1333                 preBlockEnd();
1334         }
1335         //
1336         ret = (this->*Stopp)();
1337         //
1338         if (postBlockBegin(blockresult)) {
1339
1340                 PREPARE_LOCAL_BUF();
1341                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1342                                   API_ID_result_Thread__Stop_void_,
1343                                   "", 0);
1344                 PACK_COMMON_END(ret, ret, blockresult);
1345                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_STOP);
1346                 FLUSH_LOCAL_BUF();
1347
1348                 postBlockEnd();
1349         }
1350         return ret;
1351 }
1352
1353 result EventDrivenThread::Construct(long stackSize, ThreadPriority priority) {
1354         typedef result
1355         (Thread::*methodType)(long stackSize, ThreadPriority priority);
1356         static methodType Constructp = 0;
1357         result ret;
1358         probeInfo_t probeInfo;
1359         int blockresult;
1360         bool bfiltering = true;
1361         void *tmpPtr;
1362
1363         if (!Constructp) {
1364                 probeBlockStart();
1365                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1366                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1367                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1368                                 perror("dlopen failed : libosp-appfw.so");
1369                                 exit(0);
1370                         }
1371                 }
1372                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW],
1373                                 "_ZN5Tizen4Base7Runtime17EventDrivenThread9ConstructElNS1_14ThreadPriorityE");
1374                 if (tmpPtr == NULL || dlerror() != NULL) {
1375                         perror("dlsym failed : Tizen::Base::Runtime::EventDrivenThread::Construct");
1376                         exit(0);
1377                 }
1378
1379                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1380                 probeBlockEnd();
1381         }
1382
1383         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1384                 setProbePoint(&probeInfo);
1385                 preBlockEnd();
1386         }
1387         //
1388         ret = (this->*Constructp)(stackSize, priority);
1389         //
1390         if (postBlockBegin(blockresult)) {
1391
1392                 PREPARE_LOCAL_BUF();
1393                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1394                                   API_ID_result_EventDrivenThread__Construct_long_stackSize__ThreadPriority_priority_,
1395                                   "xd", (uint64_t)(stackSize), priority);
1396                 PACK_COMMON_END(ret, ret, blockresult);
1397                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_NEW);
1398                 FLUSH_LOCAL_BUF();
1399
1400                 postBlockEnd();
1401         }
1402         return ret;
1403 }
1404
1405 result EventDrivenThread::Construct(const Tizen::Base::String &name, long stackSize,
1406                 ThreadPriority priority) {
1407         typedef result
1408         (Thread::*methodType)(const Tizen::Base::String &name, long stackSize,
1409                         ThreadPriority priority);
1410         static methodType Constructp = 0;
1411         result ret;
1412         probeInfo_t probeInfo;
1413         int blockresult;
1414         bool bfiltering = true;
1415         void *tmpPtr;
1416         char temp[50];
1417
1418         if (!Constructp) {
1419                 probeBlockStart();
1420                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1421                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1422                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1423                                 perror("dlopen failed : libosp-appfw.so");
1424                                 exit(0);
1425                         }
1426                 }
1427                 tmpPtr =
1428                                 dlsym(
1429                                                 lib_handle[LIBOSP_APPFW],
1430                                                 "_ZN5Tizen4Base7Runtime17EventDrivenThread9ConstructERKNS0_6StringElNS1_14ThreadPriorityE");
1431
1432                 if (tmpPtr == NULL || dlerror() != NULL) {
1433                         perror("dlsym failed : Tizen::Base::Runtime::EventDrivenThread::Construct");
1434                         exit(0);
1435                 }
1436
1437                 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1438                 probeBlockEnd();
1439         }
1440
1441         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1442                 setProbePoint(&probeInfo);
1443                 preBlockEnd();
1444         }
1445         //
1446         ret = (this->*Constructp)(name, stackSize, priority);
1447         //
1448         if (postBlockBegin(blockresult)) {
1449
1450                 WcharToChar(temp, name.GetPointer());
1451
1452                 PREPARE_LOCAL_BUF();
1453                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1454                                   API_ID_result_EventDrivenThread__Construct_const_Tizen__Base__String__name__long_stackSize__ThreadPriority_priority_,
1455                                   "sx", temp, (uint64_t)(stackSize));
1456                 PACK_COMMON_END(ret, ret, blockresult);
1457                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_NEW);
1458                 FLUSH_LOCAL_BUF();
1459
1460                 postBlockEnd();
1461         }
1462         return ret;
1463
1464 }
1465
1466 result EventDrivenThread::Quit() {
1467         typedef result (Thread::*methodType)(void);
1468         static methodType Quitp = 0;
1469         result ret;
1470         probeInfo_t probeInfo;
1471         int blockresult;
1472         bool bfiltering = true;
1473         void *tmpPtr;
1474
1475         if (!Quitp) {
1476                 probeBlockStart();
1477                 if(lib_handle[LIBOSP_APPFW] == NULL) {
1478                         lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1479                         if (lib_handle[LIBOSP_APPFW] == NULL) {
1480                                 perror("dlopen failed : libosp-appfw.so");
1481                                 exit(0);
1482                         }
1483                 }
1484                 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime17EventDrivenThread4QuitEv");
1485
1486                 if (tmpPtr == NULL || dlerror() != NULL) {
1487                         perror("dlsym failed : Tizen::Base::Runtime::EventThread::Quit");
1488                         exit(0);
1489                 }
1490
1491                 memcpy(&Quitp, &tmpPtr, sizeof(tmpPtr));
1492                 probeBlockEnd();
1493         }
1494
1495         if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1496                 setProbePoint(&probeInfo);
1497                 preBlockEnd();
1498         }
1499         //
1500         ret = (this->*Quitp)();
1501         //
1502         if (postBlockBegin(blockresult)) {
1503
1504                 PREPARE_LOCAL_BUF();
1505                 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1506                                   API_ID_result_EventDrivenThread__Quit__,
1507                                   "", 0);
1508                 PACK_COMMON_END(ret, ret, blockresult);
1509                 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_STOP);
1510                 FLUSH_LOCAL_BUF();
1511
1512                 postBlockEnd();
1513         }
1514         return ret;
1515 }
1516
1517 }
1518 }
1519 }