4 * Copyright (Thread::*c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
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>
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)
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.
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
30 * - Samsung RnD Institute Russia
36 #include "probeinfo.h"
41 static enum DaOptions _sopt = OPT_THREAD;
49 // virtual result Stop(void);
51 // virtual result Finalize(void);
52 const Thread* GetThread(void) const;
54 static void* ThreadProc(void* pParam);
59 //_ThreadImpl::GetThread(void) const
61 // typedef const Thread*
62 // (_ThreadImpl::*methodType)(void) const;
63 // static methodType GetThreadp = 0;
64 // probeInfo_t probeInfo;
67 // bool bfiltering = false;
72 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
73 // if (lib_handle == NULL) {
74 // perror("dlopen failed : libosp-appfw.so");
77 // tmpPtr = dlsym(lib_handle, "_ZNK5Tizen4Base7Runtime11_ThreadImpl9GetThreadEv");
79 // if (tmpPtr == NULL || dlerror() != NULL) {
80 // perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::GetThreadp");
84 // memcpy(&GetThreadp, &tmpPtr, sizeof(tmpPtr));
89 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
90 // setProbePoint(&probeInfo);
94 // const Thread* ret = (this->*GetThreadp)();
95 // result res = GetLastResult();
97 // if (postBlockBegin(blockresult)) {
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);
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);
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");
116 // printLog(&log, MSG_LOG);
123 _ThreadImpl::ThreadProc(void* params) {
125 (*methodType)(void*);
126 static methodType ThreadProcp = 0;
127 probeInfo_t probeInfo;
129 bool bfiltering = false;
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");
141 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime11_ThreadImpl10ThreadProcEPv");
143 if (tmpPtr == NULL || dlerror() != NULL) {
144 perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::ThreadProc");
148 memcpy(&ThreadProcp, &tmpPtr, sizeof(tmpPtr));
153 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
154 setProbePoint(&probeInfo);
156 _ThreadImpl* pSelf =(_ThreadImpl*)params;
157 const Thread* pThread = NULL;
159 pThread = pSelf->GetThread();
163 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
164 API_ID_void___ThreadImpl__ThreadProc_void__params_,
166 PACK_COMMON_END((unsigned int)pSelf, 0, blockresult);
167 PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_START);
172 // all probe should be reachable inside thread start_routine (user implemented Thread::Run)
174 (ThreadProcp)(params);
177 if (postBlockBegin(blockresult)) {
178 setProbePoint(&probeInfo);
180 _ThreadImpl* pSelf =(_ThreadImpl*)params;
181 const Thread* pThread = NULL;
183 pThread = pSelf->GetThread();
187 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
188 API_ID_void___ThreadImpl__ThreadProc_void__params_,
190 PACK_COMMON_END((unsigned int)pSelf, 0, blockresult);
191 PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_STOP);
198 //result _ThreadImpl::Stop(void) {
200 // (_ThreadImpl::*methodType)(void);
201 // static methodType Stopp = 0;
202 // probeInfo_t probeInfo;
205 // bool bfiltering = true;
209 // probeBlockStart();
210 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
211 // if (lib_handle == NULL) {
212 // perror("dlopen failed : libosp-appfw.so");
215 // tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime11_ThreadImpl4StopEv");
217 // if (tmpPtr == NULL || dlerror() != NULL) {
218 // perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::Stopp");
222 // memcpy(&Stopp, &tmpPtr, sizeof(tmpPtr));
227 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
228 // setProbePoint(&probeInfo);
232 // result ret= (this->*Stopp)();
234 // if (postBlockBegin(blockresult)) {
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);
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);
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");
252 // printLog(&log, MSG_LOG);
258 //result _ThreadImpl::Finalize(void) {
260 // (_ThreadImpl::*methodType)(void);
261 // static methodType Finalizep = 0;
262 // probeInfo_t probeInfo;
265 // bool bfiltering = false;
269 // probeBlockStart();
270 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
271 // if (lib_handle == NULL) {
272 // perror("dlopen failed : libosp-appfw.so");
275 // tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime11_ThreadImpl8FinalizeEv");
277 // if (tmpPtr == NULL || dlerror() != NULL) {
278 // perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::Finalizep");
282 // memcpy(&Finalizep, &tmpPtr, sizeof(tmpPtr));
286 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
287 // setProbePoint(&probeInfo);
291 // result ret= (this->*Finalizep)();
293 // if (postBlockBegin(blockresult)) {
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);
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);
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");
311 // printLog(&log, MSG_LOG);
316 //Thread::Thread(void) {
317 // typedef void (Thread::*methodType)();
318 // static methodType Threadp = 0;
319 // probeInfo_t probeInfo;
322 // bool bfiltering = true;
326 // probeBlockStart();
328 // tmpPtr = dlsym(RTLD_NEXT, "_ZN5Tizen4Base7Runtime6ThreadC1Ev");
330 // if (tmpPtr == NULL || dlerror() != NULL) {
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);
340 // memcpy(&Threadp, &tmpPtr, sizeof(tmpPtr));
344 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
345 // setProbePoint(&probeInfo);
349 // (this->*Threadp)();
351 // if (postBlockBegin(blockresult)) {
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);
359 // log.length += sprintf(log.data + log.length, "`,`,");
360 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
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);
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");
370 // printLog(&log, MSG_LOG);
375 //Thread::~Thread(void) {
376 // typedef void (Thread::*methodType)();
377 // static methodType ThreadDp = 0;
378 // probeInfo_t probeInfo;
381 // bool bfiltering = true;
385 // probeBlockStart();
387 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
388 // if (lib_handle == NULL) {
389 // perror("dlopen failed : libosp-appfw.so");
392 // tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime6ThreadD0Ev");
394 // if (tmpPtr == NULL || dlerror() != NULL) {
395 // perror("dlsym failed : Tizen::Base::Runtime::Thread::~Thread");
399 // memcpy(&ThreadDp, &tmpPtr, sizeof(tmpPtr));
403 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
404 // setProbePoint(&probeInfo);
408 // (this->*ThreadDp)();
410 // if (postBlockBegin(blockresult)) {
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);
418 // log.length += sprintf(log.data + log.length, "`,`,");
419 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
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);
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");
429 // printLog(&log, MSG_LOG);
433 result Thread::Sleep(long milliSeconds) {
436 static methodType Sleepp = 0;
437 probeInfo_t probeInfo;
439 bool bfiltering = true;
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");
451 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5SleepEl");
453 if (tmpPtr == NULL || dlerror() != NULL) {
454 perror("dlsym failed : Tizen::Base::Runtime::Thread::Sleep");
458 memcpy(&Sleepp, &tmpPtr, sizeof(tmpPtr));
463 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
464 setProbePoint(&probeInfo);
466 Thread *currentThread;
467 currentThread = GetCurrentThread();
470 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
471 API_ID_result_Thread__Sleep_long_milliSeconds_,
473 PACK_COMMON_END(0, 0, blockresult);
474 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START);
480 result ret = (Sleepp)(milliSeconds);
482 if (postBlockBegin(blockresult)) {
483 setProbePoint(&probeInfo);
485 Thread *currentThread;
486 currentThread = GetCurrentThread();
489 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
490 API_ID_result_Thread__Yield_void_,
492 PACK_COMMON_END(ret, ret, blockresult);
493 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END);
501 Thread* Thread::GetCurrentThread(void) {
504 static methodType GetCurrentThreadp = 0;
505 probeInfo_t probeInfo;
507 bool bfiltering = true;
510 if (!GetCurrentThreadp) {
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");
519 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread16GetCurrentThreadEv");
521 if (tmpPtr == NULL || dlerror() != NULL) {
522 perror("dlsym failed : Tizen::Base::Runtime::Thread::GetCurrentThread");
526 memcpy(&GetCurrentThreadp, &tmpPtr, sizeof(tmpPtr));
531 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
532 setProbePoint(&probeInfo);
536 Thread *currentThread = (GetCurrentThreadp)();
537 result res = GetLastResult();
539 if (postBlockBegin(blockresult)) {
542 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
543 API_ID_Thread__Thread__GetCurrentThread_void_,
545 PACK_COMMON_END((unsigned int)currentThread, res, blockresult);
546 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
551 return currentThread;
554 result Thread::Yield(void) {
557 static methodType Yieldp = 0;
558 probeInfo_t probeInfo;
560 bool bfiltering = true;
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");
572 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5YieldEv");
574 if (tmpPtr == NULL || dlerror() != NULL) {
575 perror("dlsym failed : Tizen::Base::Runtime::Thread::Yield");
579 memcpy(&Yieldp, &tmpPtr, sizeof(tmpPtr));
584 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
585 setProbePoint(&probeInfo);
589 result ret = (Yieldp)();
591 if (postBlockBegin(blockresult)) {
592 Thread *currentThread;
593 currentThread = GetCurrentThread();
596 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
597 API_ID_result_Thread__Yield_void_,
599 PACK_COMMON_END(ret, ret, blockresult);
600 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
608 result Thread::Exit(int exitCode) {
610 (*methodType)(int exitCode);
611 static methodType Exitp = 0;
612 probeInfo_t probeInfo;
614 bool bfiltering = true;
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");
626 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4ExitEi");
628 if (tmpPtr == NULL || dlerror() != NULL) {
629 perror("dlsym failed : Tizen::Base::Runtime::Thread::Exit");
633 memcpy(&Exitp, &tmpPtr, sizeof(tmpPtr));
638 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
639 setProbePoint(&probeInfo);
641 Thread *currentThread;
642 currentThread = GetCurrentThread();
645 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
646 API_ID_result_Thread__Exit_int_exitCode_,
648 PACK_COMMON_END(0, 0, blockresult);
649 PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_EXIT);
655 result ret = (Exitp)(exitCode);
660 result Thread::Construct(ThreadType threadType, long stackSize,
661 ThreadPriority priority) {
663 (Thread::*methodType)(ThreadType threadType, long stackSize,
664 ThreadPriority priority);
665 static methodType Constructp = 0;
667 probeInfo_t probeInfo;
669 bool bfiltering = true;
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");
683 lib_handle[LIBOSP_APPFW],
684 "_ZN5Tizen4Base7Runtime6Thread9ConstructENS1_10ThreadTypeElNS1_14ThreadPriorityE");
686 if (tmpPtr == NULL || dlerror() != NULL) {
687 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
691 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
695 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
696 setProbePoint(&probeInfo);
700 ret = (this->*Constructp)(threadType, stackSize, priority);
702 if (postBlockBegin(blockresult)) {
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);
716 result Thread::Construct(long stackSize, ThreadPriority priority) {
718 (Thread::*methodType)(long stackSize, ThreadPriority priority);
719 static methodType Constructp = 0;
721 probeInfo_t probeInfo;
723 bool bfiltering = true;
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");
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");
742 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
746 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
747 setProbePoint(&probeInfo);
751 ret = (this->*Constructp)(stackSize, priority);
753 if (postBlockBegin(blockresult)) {
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);
767 result Thread::Construct(const Tizen::Base::String &name, long stackSize,
768 ThreadPriority priority) {
770 (Thread::*methodType)(const Tizen::Base::String &name, long stackSize,
771 ThreadPriority priority);
772 static methodType Constructp = 0;
774 probeInfo_t probeInfo;
776 bool bfiltering = true;
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");
791 lib_handle[LIBOSP_APPFW],
792 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringElNS1_14ThreadPriorityE");
794 if (tmpPtr == NULL || dlerror() != NULL) {
795 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
799 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
803 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
804 setProbePoint(&probeInfo);
808 ret = (this->*Constructp)(name, stackSize, priority);
810 if (postBlockBegin(blockresult)) {
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);
824 result Thread::Construct(const Tizen::Base::String &name, ThreadType threadType,
825 long stackSize, ThreadPriority priority) {
827 (Thread::*methodType)(const Tizen::Base::String &name, ThreadType threadType,
828 long stackSize, ThreadPriority priority);
829 static methodType Constructp = 0;
831 probeInfo_t probeInfo;
833 bool bfiltering = true;
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");
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");
856 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
860 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
861 setProbePoint(&probeInfo);
865 ret = (this->*Constructp)(name, threadType, stackSize, priority);
867 if (postBlockBegin(blockresult)) {
869 WcharToChar(temp, name.GetPointer());
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);
883 result Thread::Construct(IRunnable &target, long stackSize,
884 ThreadPriority priority) {
886 (Thread::*methodType)(IRunnable &target, long stackSize,
887 ThreadPriority priority);
888 static methodType Constructp = 0;
890 probeInfo_t probeInfo;
892 bool bfiltering = true;
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");
906 lib_handle[LIBOSP_APPFW],
907 "_ZN5Tizen4Base7Runtime6Thread9ConstructERNS1_9IRunnableElNS1_14ThreadPriorityE");
909 if (tmpPtr == NULL || dlerror() != NULL) {
910 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
914 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
918 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
919 setProbePoint(&probeInfo);
923 ret = (this->*Constructp)(target, stackSize, priority);
925 if (postBlockBegin(blockresult)) {
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);
939 result Thread::Construct(const Tizen::Base::String &name, IRunnable &target,
940 long stackSize, ThreadPriority priority) {
942 (Thread::*methodType)(const Tizen::Base::String &name, IRunnable &target,
943 long stackSize, ThreadPriority priority);
944 static methodType Constructp = 0;
946 probeInfo_t probeInfo;
948 bool bfiltering = true;
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");
963 lib_handle[LIBOSP_APPFW],
964 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringERNS1_9IRunnableElNS1_14ThreadPriorityE");
966 if (tmpPtr == NULL || dlerror() != NULL) {
967 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
971 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
975 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
976 setProbePoint(&probeInfo);
980 ret = (this->*Constructp)(name, target, stackSize, priority);
982 if (postBlockBegin(blockresult)) {
984 WcharToChar(temp, name.GetPointer());
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);
999 result Thread::GetExitCode(int &exitCode) const {
1001 (Thread::*methodType)(int &exitCode) const;
1002 static methodType GetExitCodep = 0;
1004 probeInfo_t probeInfo;
1006 bool bfiltering = true;
1008 // int exitOld = exitCode;
1010 if (!GetExitCodep) {
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");
1019 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW],
1020 "_ZNK5Tizen4Base7Runtime6Thread11GetExitCodeERi");
1022 if (tmpPtr == NULL || dlerror() != NULL) {
1023 perror("dlsym failed : Tizen::Base::Runtime::Thread::GetExitCode");
1027 memcpy(&GetExitCodep, &tmpPtr, sizeof(tmpPtr));
1031 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1032 setProbePoint(&probeInfo);
1036 ret = (this->*GetExitCodep)(exitCode);
1038 if (postBlockBegin(blockresult)) {
1040 PREPARE_LOCAL_BUF();
1041 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1042 API_ID_result_Thread__GetExitCode_int__exitCode__const,
1044 PACK_COMMON_END(ret, ret, blockresult);
1045 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
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;
1059 bool bfiltering = true;
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");
1072 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZNK5Tizen4Base7Runtime6Thread7GetNameEv");
1074 if (tmpPtr == NULL || dlerror() != NULL) {
1075 perror("dlsym failed : Tizen::Base::Runtime::Thread::GetName");
1079 memcpy(&GetNamep, &tmpPtr, sizeof(tmpPtr));
1083 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1084 setProbePoint(&probeInfo);
1088 const Tizen::Base::String& ret = (this->*GetNamep)();
1089 result res = GetLastResult();
1091 if (postBlockBegin(blockresult)) {
1093 WcharToChar(temp, ret.GetPointer());
1095 PREPARE_LOCAL_BUF();
1096 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1097 API_ID_const_Tizen__Base__String___Thread__GetName_void__const,
1099 PACK_COMMON_END(ret.GetPointer(), res, blockresult);
1100 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
1108 result Thread::Join(void) {
1110 (Thread::*methodType)(void);
1111 static methodType Joinp = 0;
1113 probeInfo_t probeInfo;
1115 bool bfiltering = true;
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");
1127 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4JoinEv");
1129 if (tmpPtr == NULL || dlerror() != NULL) {
1130 perror("dlsym failed : Tizen::Base::Runtime::Thread::Join");
1134 memcpy(&Joinp, &tmpPtr, sizeof(tmpPtr));
1138 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1139 setProbePoint(&probeInfo);
1141 PREPARE_LOCAL_BUF();
1142 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1143 API_ID_result_Thread__Join_void_,
1145 PACK_COMMON_END(0, 0, blockresult);
1146 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START);
1152 ret = (this->*Joinp)();
1154 if (postBlockBegin(blockresult)) {
1155 setProbePoint(&probeInfo);
1157 PREPARE_LOCAL_BUF();
1158 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1159 API_ID_result_Thread__Join_void_,
1161 PACK_COMMON_END(ret, ret, blockresult);
1162 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END);
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;
1176 // bool bfiltering = true;
1180 // log.data[0] = '\0';
1181 // log.length = sprintf(log.data, "call Thread::Run");
1182 // printLog(&log, MSG_MSG);
1185 // probeBlockStart();
1186 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
1187 // if (lib_handle == NULL) {
1188 // perror("dlopen failed : libosp-appfw.so");
1191 // log.data[0] = '\0';
1192 // log.length = sprintf(log.data, "dlopen failed :libosp-appfw.so");
1193 // printLog(&log, MSG_MSG);
1199 // "_ZN5Tizen4Base7Runtime6Thread3RunEv");
1201 // if (tmpPtr == NULL || dlerror() != NULL) {
1202 // perror("dlsym failed : Thread::Run");
1205 // log.data[0] = '\0';
1206 // log.length = sprintf(log.data, "dlsym failed : Thread::Run");
1207 // printLog(&log, MSG_MSG);
1211 // memcpy(&Runp, &tmpPtr, sizeof(tmpPtr));
1215 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1216 // setProbePoint(&probeInfo);
1220 // ret = (this->*Runp)();
1222 // if (postBlockBegin(blockresult)) {
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);
1230 // log.length += sprintf(log.data + log.length, "`,`,0x%x",(unsigned int)ret;
1231 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
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);
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");
1242 // printLog(&log, MSG_LOG);
1248 result Thread::Start(void) {
1249 typedef result (Thread::*methodType)(void);
1250 static methodType Startp = 0;
1252 probeInfo_t probeInfo;
1254 bool bfiltering = true;
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");
1266 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5StartEv");
1268 if (tmpPtr == NULL || dlerror() != NULL) {
1269 perror("dlsym failed : Tizen::Base::Runtime::Thread::Start");
1273 memcpy(&Startp, &tmpPtr, sizeof(tmpPtr));
1277 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1278 setProbePoint(&probeInfo);
1282 ret = (this->*Startp)();
1284 if (postBlockBegin(blockresult)) {
1286 PREPARE_LOCAL_BUF();
1287 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1288 API_ID_result_Thread__Start_void_,
1290 PACK_COMMON_END(ret, ret, blockresult);
1291 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_START);
1298 result Thread::Stop(void) {
1299 typedef result (Thread::*methodType)(void);
1300 static methodType Stopp = 0;
1302 probeInfo_t probeInfo;
1304 bool bfiltering = true;
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");
1316 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4StopEv");
1318 if (tmpPtr == NULL || dlerror() != NULL) {
1319 perror("dlsym failed : Tizen::Base::Runtime::Thread::Stop");
1323 memcpy(&Stopp, &tmpPtr, sizeof(tmpPtr));
1327 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1328 setProbePoint(&probeInfo);
1332 ret = (this->*Stopp)();
1334 if (postBlockBegin(blockresult)) {
1336 PREPARE_LOCAL_BUF();
1337 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1338 API_ID_result_Thread__Stop_void_,
1340 PACK_COMMON_END(ret, ret, blockresult);
1341 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_STOP);
1349 result EventDrivenThread::Construct(long stackSize, ThreadPriority priority) {
1351 (Thread::*methodType)(long stackSize, ThreadPriority priority);
1352 static methodType Constructp = 0;
1354 probeInfo_t probeInfo;
1356 bool bfiltering = true;
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");
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");
1375 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1379 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1380 setProbePoint(&probeInfo);
1384 ret = (this->*Constructp)(stackSize, priority);
1386 if (postBlockBegin(blockresult)) {
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);
1401 result EventDrivenThread::Construct(const Tizen::Base::String &name, long stackSize,
1402 ThreadPriority priority) {
1404 (Thread::*methodType)(const Tizen::Base::String &name, long stackSize,
1405 ThreadPriority priority);
1406 static methodType Constructp = 0;
1408 probeInfo_t probeInfo;
1410 bool bfiltering = true;
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");
1425 lib_handle[LIBOSP_APPFW],
1426 "_ZN5Tizen4Base7Runtime17EventDrivenThread9ConstructERKNS0_6StringElNS1_14ThreadPriorityE");
1428 if (tmpPtr == NULL || dlerror() != NULL) {
1429 perror("dlsym failed : Tizen::Base::Runtime::EventDrivenThread::Construct");
1433 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1437 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1438 setProbePoint(&probeInfo);
1442 ret = (this->*Constructp)(name, stackSize, priority);
1444 if (postBlockBegin(blockresult)) {
1446 WcharToChar(temp, name.GetPointer());
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);
1462 result EventDrivenThread::Quit() {
1463 typedef result (Thread::*methodType)(void);
1464 static methodType Quitp = 0;
1466 probeInfo_t probeInfo;
1468 bool bfiltering = true;
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");
1480 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime17EventDrivenThread4QuitEv");
1482 if (tmpPtr == NULL || dlerror() != NULL) {
1483 perror("dlsym failed : Tizen::Base::Runtime::EventThread::Quit");
1487 memcpy(&Quitp, &tmpPtr, sizeof(tmpPtr));
1491 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1492 setProbePoint(&probeInfo);
1496 ret = (this->*Quitp)();
1498 if (postBlockBegin(blockresult)) {
1500 PREPARE_LOCAL_BUF();
1501 PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
1502 API_ID_result_EventDrivenThread__Quit__,
1504 PACK_COMMON_END(ret, ret, blockresult);
1505 PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_STOP);