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