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