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