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