4 * Copyright (Thread::*c) 2000 - 2011 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>
13 * This library is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU Lesser General Public License as published by the
15 * Free Software Foundation; either version 2.1 of the License, or (at your option)
18 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21 * License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library; if not, write to the Free Software Foundation, Inc., 51
25 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 #include <FBaseDataType.h>
34 #include <FBaseRtIRunnable.h>
38 #include "probeinfo.h"
41 static enum DaOptions _sopt = OPT_THREAD;
43 extern __thread unsigned int gProbeDepth;
49 THREAD_TYPE_WORKER = 0, /**< The worker thread mode */
50 THREAD_TYPE_EVENT_DRIVEN, /**< The event-driven thread mode */
52 // This enum value is for internal use only. Using this enum value can cause behavioral,
53 // security-related, and consistency-related issues in the application.
54 // The main thread mode
58 THREAD_PRIORITY_HIGH, /**< The high priority*/
59 THREAD_PRIORITY_MID, /**< The mid priority*/
61 /**< The low priority*/
66 const static unsigned long DEFAULT_STACK_SIZE = 64 * 1024;
68 static result Sleep(long milliSeconds);
69 static Thread* GetCurrentThread(void);
70 static result Yield(void);
71 static result Exit(int exitCode=0x00);
73 result Construct(ThreadType threadType, long stackSize, // deprecated
74 ThreadPriority priority = THREAD_PRIORITY_MID);
75 result Construct(long stackSize = DEFAULT_STACK_SIZE,
76 ThreadPriority priority = THREAD_PRIORITY_MID);
77 result Construct(const Tizen::Base::String &name, long stackSize =
78 DEFAULT_STACK_SIZE, ThreadPriority priority = THREAD_PRIORITY_MID);
79 result Construct(const Tizen::Base::String &name, ThreadType threadType, // deprecated
80 long stackSize = DEFAULT_STACK_SIZE, ThreadPriority priority =
82 result Construct(IRunnable &target, long stackSize = DEFAULT_STACK_SIZE,
83 ThreadPriority priority = THREAD_PRIORITY_MID);
84 result Construct(const Tizen::Base::String &name, IRunnable &target,
85 long stackSize = DEFAULT_STACK_SIZE, ThreadPriority priority =
87 result GetExitCode(int &exitCode) const;
88 const Tizen::Base::String & GetName(void) const;
90 // virtual bool OnStart(void); // deprecated
91 // virtual void OnStop(void); // deprecated
92 // virtual void OnUserEventReceivedN(RequestId requestId, // deprecated
93 // Tizen::Base::Collection::IList *pArgs);
94 // virtual Tizen::Base::Object * Run(void);
95 // virtual result SendUserEvent(RequestId requestId, // deprecated
96 // const Tizen::Base::Collection::IList *pArgs);
98 result Stop(void); // deprecated
101 // virtual ~Thread(void);
104 // Thread(const Thread& rhs);
105 // Thread& operator =(const Thread& rhs);
107 // friend class _ThreadImpl;
108 // class _ThreadImpl* __pThreadImpl;
113 // virtual result Stop(void);
115 // virtual result Finalize(void);
116 const Thread* GetThread(void) const;
118 static void* ThreadProc(void* pParam);
123 //_ThreadImpl::GetThread(void) const
125 // typedef const Thread*
126 // (_ThreadImpl::*methodType)(void) const;
127 // static methodType GetThreadp = 0;
128 // probeInfo_t probeInfo;
131 // bool bfiltering = false;
134 // if (!GetThreadp) {
135 // probeBlockStart();
136 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
137 // if (lib_handle == NULL) {
138 // perror("dlopen failed : libosp-appfw.so");
141 // tmpPtr = dlsym(lib_handle, "_ZNK5Tizen4Base7Runtime11_ThreadImpl9GetThreadEv");
143 // if (tmpPtr == NULL || dlerror() != NULL) {
144 // perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::GetThreadp");
148 // memcpy(&GetThreadp, &tmpPtr, sizeof(tmpPtr));
153 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
154 // setProbePoint(&probeInfo);
158 // const Thread* ret = (this->*GetThreadp)();
159 // result res = GetLastResult();
161 // if (postBlockBegin(blockresult)) {
164 // log.data[0] = '\0';
165 // log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
166 // probeInfo.eventIndex, "_ThreadImpl::GetThread", probeInfo.currentTime,
167 // probeInfo.pID, probeInfo.tID);
170 // log.length += sprintf(log.data + log.length, "`,`,0x%x",ret);
171 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
172 // log.length += sprintf(log.data + log.length,
173 // "`,0`,%ld`,%d`,0`,%u`,0x%x`,%d`,%d`,`,", res,blockresult,
174 // (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_OTHER);
176 // log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
177 // getBacktraceString(&log, 4096 - log.length - 17);
178 // log.length += sprintf(log.data + log.length, "`,callstack_end");
180 // printLog(&log, MSG_LOG);
186 class EventDrivenThread : public Thread {
188 result Construct(long stackSize = DEFAULT_STACK_SIZE,
189 ThreadPriority priority = THREAD_PRIORITY_MID);
190 result Construct(const Tizen::Base::String &name, long stackSize =
191 DEFAULT_STACK_SIZE, ThreadPriority priority = THREAD_PRIORITY_MID);
193 virtual result Quit();
194 // virtual bool OnStart(void);
195 // virtual void OnStop(void);
196 // virtual void OnUserEventReceivedN(RequestId requestId,
197 // Tizen::Base::Collection::IList *pArgs);
198 // virtual Tizen::Base::Object * Run(void);
199 // virtual result SendUserEvent(RequestId requestId,
200 // const Tizen::Base::Collection::IList *pArgs);
202 // EventDrivenThread(void);
203 // virtual ~EventDrivenThread(void);
206 // EventDrivenThread(const EventDrivenThread& rhs);
207 // EventDrivenThread& operator = (const EventDrivenThread& rhs);
209 // class _EventDrivenThreadImpl* __pEventDrivenThreadImpl;
210 // friend class _EventDrivenThreadImpl;
215 _ThreadImpl::ThreadProc(void* params) {
217 (*methodType)(void*);
218 static methodType ThreadProcp = 0;
219 probeInfo_t probeInfo;
222 bool bfiltering = false;
227 if(lib_handle[LIBOSP_APPFW] == NULL) {
228 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
229 if (lib_handle[LIBOSP_APPFW] == NULL) {
230 perror("dlopen failed : libosp-appfw.so");
234 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime11_ThreadImpl10ThreadProcEPv");
236 if (tmpPtr == NULL || dlerror() != NULL) {
237 perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::ThreadProc");
241 memcpy(&ThreadProcp, &tmpPtr, sizeof(tmpPtr));
246 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
247 setProbePoint(&probeInfo);
251 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
252 probeInfo.eventIndex, "_ThreadImpl::ThreadProc", probeInfo.currentTime,
253 probeInfo.pID, probeInfo.tID);
255 _ThreadImpl* pSelf =(_ThreadImpl*)params;
256 const Thread* pThread = NULL;
258 pThread = pSelf->GetThread();
261 log.length += sprintf(log.data + log.length, "`,0x%x`,",(unsigned int)pSelf);
262 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
263 log.length += sprintf(log.data + log.length,
264 "`,0`,0`,%d`,%u`,`,0x%x`,%d`,%d", blockresult,
265 (unsigned int)CALLER_ADDRESS, (unsigned int)pThread, THREAD_OSPTHREAD_WORKER, THREAD_API_INTERNAL_START);
267 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
268 log.length += sprintf(log.data + log.length, "`,callstack_end");
270 printLog(&log, MSG_LOG);
273 // all probe should be reachable inside thread start_routine (user implemented Thread::Run)
275 TRACE_STATE_UNSET(TS_ENTER_PROBE_BLOCK);
276 (ThreadProcp)(params);
277 TRACE_STATE_SET(TS_ENTER_PROBE_BLOCK);
280 if (postBlockBegin(blockresult)) {
281 setProbePoint(&probeInfo);
285 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
286 probeInfo.eventIndex, "_ThreadImpl::ThreadProc", probeInfo.currentTime,
287 probeInfo.pID, probeInfo.tID);
289 _ThreadImpl* pSelf =(_ThreadImpl*)params;
290 const Thread* pThread = NULL;
292 pThread = pSelf->GetThread();
295 log.length += sprintf(log.data + log.length, "`,0x%x`,",(unsigned int)pSelf);
296 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
297 log.length += sprintf(log.data + log.length,
298 "`,0`,0`,%d`,%u`,`,0x%x`,%d`,%d", blockresult,
299 (unsigned int)CALLER_ADDRESS, (unsigned int)pThread, THREAD_OSPTHREAD_WORKER, THREAD_API_INTERNAL_STOP);
301 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
302 log.length += sprintf(log.data + log.length, "`,callstack_end");
304 printLog(&log, MSG_LOG);
309 //result _ThreadImpl::Stop(void) {
311 // (_ThreadImpl::*methodType)(void);
312 // static methodType Stopp = 0;
313 // probeInfo_t probeInfo;
316 // bool bfiltering = true;
320 // probeBlockStart();
321 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
322 // if (lib_handle == NULL) {
323 // perror("dlopen failed : libosp-appfw.so");
326 // tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime11_ThreadImpl4StopEv");
328 // if (tmpPtr == NULL || dlerror() != NULL) {
329 // perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::Stopp");
333 // memcpy(&Stopp, &tmpPtr, sizeof(tmpPtr));
338 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
339 // setProbePoint(&probeInfo);
343 // result ret= (this->*Stopp)();
345 // if (postBlockBegin(blockresult)) {
348 // log.data[0] = '\0';
349 // log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
350 // probeInfo.eventIndex, "_ThreadImpl::Stop", probeInfo.currentTime,
351 // probeInfo.pID, probeInfo.tID);
353 // log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
354 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
355 // log.length += sprintf(log.data + log.length,
356 // "`,0`,%ld`,%d`,0`,%u`,0x%x`,%d`,%d`,`,", ret, blockresult,
357 // (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_CLOSE);
359 // log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
360 // getBacktraceString(&log, 4096 - log.length - 17);
361 // log.length += sprintf(log.data + log.length, "`,callstack_end");
363 // printLog(&log, MSG_LOG);
369 //result _ThreadImpl::Finalize(void) {
371 // (_ThreadImpl::*methodType)(void);
372 // static methodType Finalizep = 0;
373 // probeInfo_t probeInfo;
376 // bool bfiltering = false;
380 // probeBlockStart();
381 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
382 // if (lib_handle == NULL) {
383 // perror("dlopen failed : libosp-appfw.so");
386 // tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime11_ThreadImpl8FinalizeEv");
388 // if (tmpPtr == NULL || dlerror() != NULL) {
389 // perror("dlsym failed : Tizen::Base::Runtime::_ThreadImpl::Finalizep");
393 // memcpy(&Finalizep, &tmpPtr, sizeof(tmpPtr));
397 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
398 // setProbePoint(&probeInfo);
402 // result ret= (this->*Finalizep)();
404 // if (postBlockBegin(blockresult)) {
407 // log.data[0] = '\0';
408 // log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
409 // probeInfo.eventIndex, "_ThreadImpl::Finalize", probeInfo.currentTime,
410 // probeInfo.pID, probeInfo.tID);
412 // log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
413 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
414 // log.length += sprintf(log.data + log.length,
415 // "`,0`,%ld`,%d`,0`,%u`,0x%x`,%d`,%d`,`,", ret, blockresult,
416 // (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_CLOSE);
418 // log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
419 // getBacktraceString(&log, 4096 - log.length - 17);
420 // log.length += sprintf(log.data + log.length, "`,callstack_end");
422 // printLog(&log, MSG_LOG);
427 //Thread::Thread(void) {
428 // typedef void (Thread::*methodType)();
429 // static methodType Threadp = 0;
430 // probeInfo_t probeInfo;
433 // bool bfiltering = true;
437 // probeBlockStart();
439 // tmpPtr = dlsym(RTLD_NEXT, "_ZN5Tizen4Base7Runtime6ThreadC1Ev");
441 // if (tmpPtr == NULL || dlerror() != NULL) {
444 // log.data[0] = '\0';
445 // log.length = sprintf(log.data,"dlsym failed : Tizen::Base::Runtime::Thread::Thread");
446 // perror("dlsym failed : Tizen::Base::Runtime::Thread::Thread");
447 // printLog(&log, MSG_MSG);
451 // memcpy(&Threadp, &tmpPtr, sizeof(tmpPtr));
455 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
456 // setProbePoint(&probeInfo);
460 // (this->*Threadp)();
462 // if (postBlockBegin(blockresult)) {
465 // log.data[0] = '\0';
466 // log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
467 // probeInfo.eventIndex, "Thread::Thread", probeInfo.currentTime,
468 // probeInfo.pID, probeInfo.tID);
470 // log.length += sprintf(log.data + log.length, "`,`,");
471 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
473 // log.length += sprintf(log.data + log.length,
474 // "`,0`,0`,%d`,0`,0x%x`,%d`,%d`,`,", blockresult,
475 // (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_OPEN);
477 // log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
478 // getBacktraceString(&log, 4096 - log.length - 17);
479 // log.length += sprintf(log.data + log.length, "`,callstack_end");
481 // printLog(&log, MSG_LOG);
486 //Thread::~Thread(void) {
487 // typedef void (Thread::*methodType)();
488 // static methodType ThreadDp = 0;
489 // probeInfo_t probeInfo;
492 // bool bfiltering = true;
496 // probeBlockStart();
498 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
499 // if (lib_handle == NULL) {
500 // perror("dlopen failed : libosp-appfw.so");
503 // tmpPtr = dlsym(lib_handle, "_ZN5Tizen4Base7Runtime6ThreadD0Ev");
505 // if (tmpPtr == NULL || dlerror() != NULL) {
506 // perror("dlsym failed : Tizen::Base::Runtime::Thread::~Thread");
510 // memcpy(&ThreadDp, &tmpPtr, sizeof(tmpPtr));
514 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
515 // setProbePoint(&probeInfo);
519 // (this->*ThreadDp)();
521 // if (postBlockBegin(blockresult)) {
524 // log.data[0] = '\0';
525 // log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
526 // probeInfo.eventIndex, "Thread::~Thread", probeInfo.currentTime,
527 // probeInfo.pID, probeInfo.tID);
529 // log.length += sprintf(log.data + log.length, "`,`,");
530 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
532 // log.length += sprintf(log.data + log.length,
533 // "`,0`,0`,%d`,0`,0x%x`,%d`,%d`,`,", blockresult,
534 // (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_CLOSE);
536 // log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
537 // getBacktraceString(&log, 4096 - log.length - 17);
538 // log.length += sprintf(log.data + log.length, "`,callstack_end");
540 // printLog(&log, MSG_LOG);
544 result Thread::Sleep(long milliSeconds) {
547 static methodType Sleepp = 0;
548 probeInfo_t probeInfo;
551 bool bfiltering = true;
556 if(lib_handle[LIBOSP_APPFW] == NULL) {
557 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
558 if (lib_handle[LIBOSP_APPFW] == NULL) {
559 perror("dlopen failed : libosp-appfw.so");
563 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5SleepEl");
565 if (tmpPtr == NULL || dlerror() != NULL) {
566 perror("dlsym failed : Tizen::Base::Runtime::Thread::Sleep");
570 memcpy(&Sleepp, &tmpPtr, sizeof(tmpPtr));
575 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
576 setProbePoint(&probeInfo);
580 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
581 probeInfo.eventIndex, "Thread::Sleep", probeInfo.currentTime,
582 probeInfo.pID, probeInfo.tID);
584 Thread *currentThread;
585 currentThread = GetCurrentThread();
588 log.length += sprintf(log.data + log.length, "`,%ld`,",milliSeconds);
589 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
590 log.length += sprintf(log.data + log.length,
591 "`,0`,0`,%d`,%u`,`,0x%x`,%d`,%d",blockresult,
592 (unsigned int)CALLER_ADDRESS, (unsigned int)currentThread, THREAD_OSPTHREAD_WORKER, THREAD_API_WAIT_START);
594 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
595 log.length += sprintf(log.data + log.length, "`,callstack_end");
597 printLog(&log, MSG_LOG);
601 result ret = (Sleepp)(milliSeconds);
603 if (postBlockBegin(blockresult)) {
604 setProbePoint(&probeInfo);
608 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
609 probeInfo.eventIndex, "Thread::Sleep", probeInfo.currentTime,
610 probeInfo.pID, probeInfo.tID);
612 Thread *currentThread;
613 currentThread = GetCurrentThread();
616 log.length += sprintf(log.data + log.length, "`,%ld`,%ld",milliSeconds,ret);
617 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
618 log.length += sprintf(log.data + log.length,
619 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret,blockresult,
620 (unsigned int)CALLER_ADDRESS, (unsigned int)currentThread, THREAD_OSPTHREAD_WORKER, THREAD_API_WAIT_END);
622 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
623 getBacktraceString(&log, 4096 - log.length - 17);
624 log.length += sprintf(log.data + log.length, "`,callstack_end");
626 printLog(&log, MSG_LOG);
632 Thread* Thread::GetCurrentThread(void) {
635 static methodType GetCurrentThreadp = 0;
636 probeInfo_t probeInfo;
639 bool bfiltering = true;
642 if (!GetCurrentThreadp) {
644 if(lib_handle[LIBOSP_APPFW] == NULL) {
645 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
646 if (lib_handle[LIBOSP_APPFW] == NULL) {
647 perror("dlopen failed : libosp-appfw.so");
651 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread16GetCurrentThreadEv");
653 if (tmpPtr == NULL || dlerror() != NULL) {
654 perror("dlsym failed : Tizen::Base::Runtime::Thread::GetCurrentThread");
658 memcpy(&GetCurrentThreadp, &tmpPtr, sizeof(tmpPtr));
663 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
664 setProbePoint(&probeInfo);
668 Thread *currentThread = (GetCurrentThreadp)();
669 result res = GetLastResult();
671 if (postBlockBegin(blockresult)) {
675 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
676 probeInfo.eventIndex, "Thread::GetCurrentThread", probeInfo.currentTime,
677 probeInfo.pID, probeInfo.tID);
680 log.length += sprintf(log.data + log.length, "`,`,0x%x",(unsigned int)currentThread);
681 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
682 log.length += sprintf(log.data + log.length,
683 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", res,blockresult,
684 (unsigned int)CALLER_ADDRESS, (unsigned int)currentThread, THREAD_OSPTHREAD_WORKER, THREAD_API_OTHER);
686 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
687 getBacktraceString(&log, 4096 - log.length - 17);
688 log.length += sprintf(log.data + log.length, "`,callstack_end");
690 printLog(&log, MSG_LOG);
693 return currentThread;
696 result Thread::Yield(void) {
699 static methodType Yieldp = 0;
700 probeInfo_t probeInfo;
703 bool bfiltering = true;
708 if(lib_handle[LIBOSP_APPFW] == NULL) {
709 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
710 if (lib_handle[LIBOSP_APPFW] == NULL) {
711 perror("dlopen failed : libosp-appfw.so");
715 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5YieldEv");
717 if (tmpPtr == NULL || dlerror() != NULL) {
718 perror("dlsym failed : Tizen::Base::Runtime::Thread::Yield");
722 memcpy(&Yieldp, &tmpPtr, sizeof(tmpPtr));
727 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
728 setProbePoint(&probeInfo);
732 result ret = (Yieldp)();
734 if (postBlockBegin(blockresult)) {
738 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
739 probeInfo.eventIndex, "Thread::Yield", probeInfo.currentTime,
740 probeInfo.pID, probeInfo.tID);
742 Thread *currentThread;
743 currentThread = GetCurrentThread();
746 log.length += sprintf(log.data + log.length, "`,`,%ld",ret);
747 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
748 log.length += sprintf(log.data + log.length,
749 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret,blockresult,
750 (unsigned int)CALLER_ADDRESS, (unsigned int)currentThread, THREAD_OSPTHREAD_WORKER, THREAD_API_OTHER);
752 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
753 getBacktraceString(&log, 4096 - log.length - 17);
754 log.length += sprintf(log.data + log.length, "`,callstack_end");
756 printLog(&log, MSG_LOG);
762 result Thread::Exit(int exitCode) {
764 (*methodType)(int exitCode);
765 static methodType Exitp = 0;
766 probeInfo_t probeInfo;
769 bool bfiltering = true;
774 if(lib_handle[LIBOSP_APPFW] == NULL) {
775 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
776 if (lib_handle[LIBOSP_APPFW] == NULL) {
777 perror("dlopen failed : libosp-appfw.so");
781 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4ExitEi");
783 if (tmpPtr == NULL || dlerror() != NULL) {
784 perror("dlsym failed : Tizen::Base::Runtime::Thread::Exit");
788 memcpy(&Exitp, &tmpPtr, sizeof(tmpPtr));
793 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
794 setProbePoint(&probeInfo);
798 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
799 probeInfo.eventIndex, "Thread::Exit", probeInfo.currentTime,
800 probeInfo.pID, probeInfo.tID);
802 Thread *currentThread;
803 currentThread = GetCurrentThread();
806 log.length += sprintf(log.data + log.length, "`,%d`,",exitCode);
807 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
808 log.length += sprintf(log.data + log.length,
809 "`,0`,0`,%d`,%u`,`,0x%x`,%d`,%d",blockresult,
810 (unsigned int)CALLER_ADDRESS, (unsigned int)currentThread, THREAD_OSPTHREAD_WORKER, THREAD_API_EXIT);
812 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
813 getBacktraceString(&log, 4096 - log.length - 17);
814 log.length += sprintf(log.data + log.length, "`,callstack_end");
816 printLog(&log, MSG_LOG);
820 result ret = (Exitp)(exitCode);
825 result Thread::Construct(ThreadType threadType, long stackSize,
826 ThreadPriority priority) {
828 (Thread::*methodType)(ThreadType threadType, long stackSize,
829 ThreadPriority priority);
830 static methodType Constructp = 0;
832 probeInfo_t probeInfo;
835 bool bfiltering = true;
840 if(lib_handle[LIBOSP_APPFW] == NULL) {
841 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
842 if (lib_handle[LIBOSP_APPFW] == NULL) {
843 perror("dlopen failed : libosp-appfw.so");
849 lib_handle[LIBOSP_APPFW],
850 "_ZN5Tizen4Base7Runtime6Thread9ConstructENS1_10ThreadTypeElNS1_14ThreadPriorityE");
852 if (tmpPtr == NULL || dlerror() != NULL) {
853 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
857 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
861 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
862 setProbePoint(&probeInfo);
866 ret = (this->*Constructp)(threadType, stackSize, priority);
868 if (postBlockBegin(blockresult)) {
872 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
873 probeInfo.eventIndex, "Thread::Construct",
874 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
876 log.length += sprintf(log.data + log.length, "`,%d, %ld, %d`,%ld",
877 threadType, stackSize, priority, ret);
878 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
879 log.length += sprintf(log.data + log.length,
880 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
881 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_NEW);
883 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
884 getBacktraceString(&log, 4096 - log.length - 17);
885 log.length += sprintf(log.data + log.length, "`,callstack_end");
887 printLog(&log, MSG_LOG);
892 result Thread::Construct(long stackSize, ThreadPriority priority) {
894 (Thread::*methodType)(long stackSize, ThreadPriority priority);
895 static methodType Constructp = 0;
897 probeInfo_t probeInfo;
900 bool bfiltering = true;
905 if(lib_handle[LIBOSP_APPFW] == NULL) {
906 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
907 if (lib_handle[LIBOSP_APPFW] == NULL) {
908 perror("dlopen failed : libosp-appfw.so");
912 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW],
913 "_ZN5Tizen4Base7Runtime6Thread9ConstructElNS1_14ThreadPriorityE");
914 if (tmpPtr == NULL || dlerror() != NULL) {
915 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
919 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
923 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
924 setProbePoint(&probeInfo);
928 ret = (this->*Constructp)(stackSize, priority);
930 if (postBlockBegin(blockresult)) {
934 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
935 probeInfo.eventIndex, "Thread::Construct",
936 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
938 log.length += sprintf(log.data + log.length, "`,%ld, %d`,%ld",
939 stackSize, priority, ret);
940 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
941 log.length += sprintf(log.data + log.length,
942 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
943 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_NEW);
945 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
946 getBacktraceString(&log, 4096 - log.length - 17);
947 log.length += sprintf(log.data + log.length, "`,callstack_end");
949 printLog(&log, MSG_LOG);
954 result Thread::Construct(const Tizen::Base::String &name, long stackSize,
955 ThreadPriority priority) {
957 (Thread::*methodType)(const Tizen::Base::String &name, long stackSize,
958 ThreadPriority priority);
959 static methodType Constructp = 0;
961 probeInfo_t probeInfo;
964 bool bfiltering = true;
970 if(lib_handle[LIBOSP_APPFW] == NULL) {
971 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
972 if (lib_handle[LIBOSP_APPFW] == NULL) {
973 perror("dlopen failed : libosp-appfw.so");
979 lib_handle[LIBOSP_APPFW],
980 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringElNS1_14ThreadPriorityE");
982 if (tmpPtr == NULL || dlerror() != NULL) {
983 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
987 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
991 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
992 setProbePoint(&probeInfo);
996 ret = (this->*Constructp)(name, stackSize, priority);
998 if (postBlockBegin(blockresult)) {
1002 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1003 probeInfo.eventIndex, "Thread::Construct",
1004 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1006 WcharToChar(temp, name.GetPointer());
1007 log.length += sprintf(log.data + log.length, "`,%s, %ld, %d`,%ld", temp,
1008 stackSize, priority, ret);
1009 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1010 log.length += sprintf(log.data + log.length,
1011 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1012 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_NEW);
1014 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1015 getBacktraceString(&log, 4096 - log.length - 17);
1016 log.length += sprintf(log.data + log.length, "`,callstack_end");
1018 printLog(&log, MSG_LOG);
1023 result Thread::Construct(const Tizen::Base::String &name, ThreadType threadType,
1024 long stackSize, ThreadPriority priority) {
1026 (Thread::*methodType)(const Tizen::Base::String &name, ThreadType threadType,
1027 long stackSize, ThreadPriority priority);
1028 static methodType Constructp = 0;
1030 probeInfo_t probeInfo;
1033 bool bfiltering = true;
1039 if(lib_handle[LIBOSP_APPFW] == NULL) {
1040 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1041 if (lib_handle[LIBOSP_APPFW] == NULL) {
1042 perror("dlopen failed : libosp-appfw.so");
1049 lib_handle[LIBOSP_APPFW],
1050 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringENS1_10ThreadTypeElNS1_14ThreadPriorityE");
1051 if (tmpPtr == NULL || dlerror() != NULL) {
1052 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
1056 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1060 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1061 setProbePoint(&probeInfo);
1065 ret = (this->*Constructp)(name, threadType, stackSize, priority);
1067 if (postBlockBegin(blockresult)) {
1071 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1072 probeInfo.eventIndex, "Thread::Construct",
1073 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1075 WcharToChar(temp, name.GetPointer());
1076 log.length += sprintf(log.data + log.length, "`,%s, %d, %ld, %d`,%ld",
1077 temp, threadType, stackSize, priority, ret);
1078 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1079 log.length += sprintf(log.data + log.length,
1080 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1081 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_NEW);
1083 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1084 getBacktraceString(&log, 4096 - log.length - 17);
1085 log.length += sprintf(log.data + log.length, "`,callstack_end");
1087 printLog(&log, MSG_LOG);
1092 result Thread::Construct(IRunnable &target, long stackSize,
1093 ThreadPriority priority) {
1095 (Thread::*methodType)(IRunnable &target, long stackSize,
1096 ThreadPriority priority);
1097 static methodType Constructp = 0;
1099 probeInfo_t probeInfo;
1102 bool bfiltering = true;
1107 if(lib_handle[LIBOSP_APPFW] == NULL) {
1108 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1109 if (lib_handle[LIBOSP_APPFW] == NULL) {
1110 perror("dlopen failed : libosp-appfw.so");
1116 lib_handle[LIBOSP_APPFW],
1117 "_ZN5Tizen4Base7Runtime6Thread9ConstructERNS1_9IRunnableElNS1_14ThreadPriorityE");
1119 if (tmpPtr == NULL || dlerror() != NULL) {
1120 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
1124 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1128 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1129 setProbePoint(&probeInfo);
1133 ret = (this->*Constructp)(target, stackSize, priority);
1135 if (postBlockBegin(blockresult)) {
1139 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1140 probeInfo.eventIndex, "Thread::Construct",
1141 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1143 log.length += sprintf(log.data + log.length, "`,0x%x, %ld, %d`,%ld",
1144 (unsigned int) &target, stackSize, priority, ret);
1145 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1146 log.length += sprintf(log.data + log.length,
1147 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1148 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_NEW);
1150 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1151 getBacktraceString(&log, 4096 - log.length - 17);
1152 log.length += sprintf(log.data + log.length, "`,callstack_end");
1154 printLog(&log, MSG_LOG);
1159 result Thread::Construct(const Tizen::Base::String &name, IRunnable &target,
1160 long stackSize, ThreadPriority priority) {
1162 (Thread::*methodType)(const Tizen::Base::String &name, IRunnable &target,
1163 long stackSize, ThreadPriority priority);
1164 static methodType Constructp = 0;
1166 probeInfo_t probeInfo;
1169 bool bfiltering = true;
1175 if(lib_handle[LIBOSP_APPFW] == NULL) {
1176 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1177 if (lib_handle[LIBOSP_APPFW] == NULL) {
1178 perror("dlopen failed : libosp-appfw.so");
1184 lib_handle[LIBOSP_APPFW],
1185 "_ZN5Tizen4Base7Runtime6Thread9ConstructERKNS0_6StringERNS1_9IRunnableElNS1_14ThreadPriorityE");
1187 if (tmpPtr == NULL || dlerror() != NULL) {
1188 perror("dlsym failed : Tizen::Base::Runtime::Thread::Construct");
1192 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1196 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1197 setProbePoint(&probeInfo);
1201 ret = (this->*Constructp)(name, target, stackSize, priority);
1203 if (postBlockBegin(blockresult)) {
1207 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1208 probeInfo.eventIndex, "Thread::Construct",
1209 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1211 WcharToChar(temp, name.GetPointer());
1212 log.length += sprintf(log.data + log.length, "`,%s, 0x%x, %ld, %d`,%ld",
1213 temp, (unsigned int) &target, stackSize, priority, ret);
1214 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1215 log.length += sprintf(log.data + log.length,
1216 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1217 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_NEW);
1219 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1220 getBacktraceString(&log, 4096 - log.length - 17);
1221 log.length += sprintf(log.data + log.length, "`,callstack_end");
1223 printLog(&log, MSG_LOG);
1229 result Thread::GetExitCode(int &exitCode) const {
1231 (Thread::*methodType)(int &exitCode) const;
1232 static methodType GetExitCodep = 0;
1234 probeInfo_t probeInfo;
1237 bool bfiltering = true;
1239 // int exitOld = exitCode;
1241 if (!GetExitCodep) {
1243 if(lib_handle[LIBOSP_APPFW] == NULL) {
1244 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1245 if (lib_handle[LIBOSP_APPFW] == NULL) {
1246 perror("dlopen failed : libosp-appfw.so");
1250 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW],
1251 "_ZNK5Tizen4Base7Runtime6Thread11GetExitCodeERi");
1253 if (tmpPtr == NULL || dlerror() != NULL) {
1254 perror("dlsym failed : Tizen::Base::Runtime::Thread::GetExitCode");
1258 memcpy(&GetExitCodep, &tmpPtr, sizeof(tmpPtr));
1262 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1263 setProbePoint(&probeInfo);
1267 ret = (this->*GetExitCodep)(exitCode);
1269 if (postBlockBegin(blockresult)) {
1273 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1274 probeInfo.eventIndex, "Thread::GetExitCode",
1275 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1277 // log.length += sprintf(log.data + log.length, "`,(%d->%d)`,%ld", exitOld,
1279 log.length += sprintf(log.data + log.length, "`,%d`,%ld", exitCode, ret);
1280 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1281 log.length += sprintf(log.data + log.length,
1282 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1283 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_OTHER);
1285 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1286 getBacktraceString(&log, 4096 - log.length - 17);
1287 log.length += sprintf(log.data + log.length, "`,callstack_end");
1289 printLog(&log, MSG_LOG);
1295 const Tizen::Base::String & Thread::GetName(void) const {
1296 typedef const Tizen::Base::String &
1297 (Thread::*methodType)(void) const;
1298 static methodType GetNamep = 0;
1299 probeInfo_t probeInfo;
1302 bool bfiltering = true;
1308 if(lib_handle[LIBOSP_APPFW] == NULL) {
1309 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1310 if (lib_handle[LIBOSP_APPFW] == NULL) {
1311 perror("dlopen failed : libosp-appfw.so");
1315 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZNK5Tizen4Base7Runtime6Thread7GetNameEv");
1317 if (tmpPtr == NULL || dlerror() != NULL) {
1318 perror("dlsym failed : Tizen::Base::Runtime::Thread::GetName");
1322 memcpy(&GetNamep, &tmpPtr, sizeof(tmpPtr));
1326 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1327 setProbePoint(&probeInfo);
1331 const Tizen::Base::String& ret = (this->*GetNamep)();
1332 result res = GetLastResult();
1334 if (postBlockBegin(blockresult)) {
1338 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1339 probeInfo.eventIndex, "Thread::GetName", probeInfo.currentTime,
1340 probeInfo.pID, probeInfo.tID);
1342 WcharToChar(temp, ret.GetPointer());
1343 log.length += sprintf(log.data + log.length, "`,`,%s", temp);
1344 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1345 log.length += sprintf(log.data + log.length,
1346 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", res, blockresult,
1347 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_OTHER);
1349 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1350 getBacktraceString(&log, 4096 - log.length - 17);
1351 log.length += sprintf(log.data + log.length, "`,callstack_end");
1353 printLog(&log, MSG_LOG);
1359 result Thread::Join(void) {
1361 (Thread::*methodType)(void);
1362 static methodType Joinp = 0;
1364 probeInfo_t probeInfo;
1367 bool bfiltering = true;
1372 if(lib_handle[LIBOSP_APPFW] == NULL) {
1373 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1374 if (lib_handle[LIBOSP_APPFW] == NULL) {
1375 perror("dlopen failed : libosp-appfw.so");
1379 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4JoinEv");
1381 if (tmpPtr == NULL || dlerror() != NULL) {
1382 perror("dlsym failed : Tizen::Base::Runtime::Thread::Join");
1386 memcpy(&Joinp, &tmpPtr, sizeof(tmpPtr));
1390 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1391 setProbePoint(&probeInfo);
1395 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1396 probeInfo.eventIndex, "Thread::Join", probeInfo.currentTime,
1397 probeInfo.pID, probeInfo.tID);
1399 log.length += sprintf(log.data + log.length, "`,`,");
1400 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1401 log.length += sprintf(log.data + log.length,
1402 "`,0`,0`,%d`,%u`,`,0x%x`,%d`,%d",blockresult,
1403 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_WAIT_START);
1405 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1406 log.length += sprintf(log.data + log.length, "`,callstack_end");
1408 printLog(&log, MSG_LOG);
1412 ret = (this->*Joinp)();
1414 if (postBlockBegin(blockresult)) {
1415 setProbePoint(&probeInfo);
1419 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1420 probeInfo.eventIndex, "Thread::Join", probeInfo.currentTime,
1421 probeInfo.pID, probeInfo.tID);
1423 log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
1424 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1425 log.length += sprintf(log.data + log.length,
1426 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret,blockresult,
1427 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_WAIT_END);
1429 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1430 getBacktraceString(&log, 4096 - log.length - 17);
1431 log.length += sprintf(log.data + log.length, "`,callstack_end");
1433 printLog(&log, MSG_LOG);
1438 //Tizen::Base::Object * Thread::Run(void) {
1439 // typedef Tizen::Base::Object * (Thread::*methodType)(void);
1440 // static methodType Runp = 0;
1441 // Tizen::Base::Object * ret;
1442 // probeInfo_t probeInfo;
1445 // bool bfiltering = true;
1449 // log.data[0] = '\0';
1450 // log.length = sprintf(log.data, "call Thread::Run");
1451 // printLog(&log, MSG_MSG);
1454 // probeBlockStart();
1455 // void* lib_handle = dlopen("libosp-appfw.so", RTLD_LAZY);
1456 // if (lib_handle == NULL) {
1457 // perror("dlopen failed : libosp-appfw.so");
1460 // log.data[0] = '\0';
1461 // log.length = sprintf(log.data, "dlopen failed :libosp-appfw.so");
1462 // printLog(&log, MSG_MSG);
1468 // "_ZN5Tizen4Base7Runtime6Thread3RunEv");
1470 // if (tmpPtr == NULL || dlerror() != NULL) {
1471 // perror("dlsym failed : Thread::Run");
1474 // log.data[0] = '\0';
1475 // log.length = sprintf(log.data, "dlsym failed : Thread::Run");
1476 // printLog(&log, MSG_MSG);
1480 // memcpy(&Runp, &tmpPtr, sizeof(tmpPtr));
1484 // if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1485 // setProbePoint(&probeInfo);
1489 // ret = (this->*Runp)();
1491 // if (postBlockBegin(blockresult)) {
1494 // log.data[0] = '\0';
1495 // log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1496 // probeInfo.eventIndex, "Thread::Run",
1497 // probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1499 // log.length += sprintf(log.data + log.length, "`,`,0x%x",(unsigned int)ret;
1500 // //PCAddr,errno,InternalCall,size,FD,FDType,FDApiType,FileSize,FilePath
1503 // log.length += sprintf(log.data + log.length,
1504 // "`,0`,0`,%d`,0`,0x%x`,%d`,%d`,`,", blockresult,
1505 // (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_OTHER);
1507 // log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1508 // getBacktraceString(&log, 4096 - log.length - 17);
1509 // log.length += sprintf(log.data + log.length, "`,callstack_end");
1511 // printLog(&log, MSG_LOG);
1517 result Thread::Start(void) {
1518 typedef result (Thread::*methodType)(void);
1519 static methodType Startp = 0;
1521 probeInfo_t probeInfo;
1524 bool bfiltering = true;
1529 if(lib_handle[LIBOSP_APPFW] == NULL) {
1530 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1531 if (lib_handle[LIBOSP_APPFW] == NULL) {
1532 perror("dlopen failed : libosp-appfw.so");
1536 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread5StartEv");
1538 if (tmpPtr == NULL || dlerror() != NULL) {
1539 perror("dlsym failed : Tizen::Base::Runtime::Thread::Start");
1543 memcpy(&Startp, &tmpPtr, sizeof(tmpPtr));
1547 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1548 setProbePoint(&probeInfo);
1552 ret = (this->*Startp)();
1554 if (postBlockBegin(blockresult)) {
1558 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1559 probeInfo.eventIndex, "Thread::Start", probeInfo.currentTime,
1560 probeInfo.pID, probeInfo.tID);
1562 log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
1563 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1564 log.length += sprintf(log.data + log.length,
1565 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1566 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_START);
1568 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1569 getBacktraceString(&log, 4096 - log.length - 17);
1570 log.length += sprintf(log.data + log.length, "`,callstack_end");
1572 printLog(&log, MSG_LOG);
1577 result Thread::Stop(void) {
1578 typedef result (Thread::*methodType)(void);
1579 static methodType Stopp = 0;
1581 probeInfo_t probeInfo;
1584 bool bfiltering = true;
1589 if(lib_handle[LIBOSP_APPFW] == NULL) {
1590 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1591 if (lib_handle[LIBOSP_APPFW] == NULL) {
1592 perror("dlopen failed : libosp-appfw.so");
1596 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime6Thread4StopEv");
1598 if (tmpPtr == NULL || dlerror() != NULL) {
1599 perror("dlsym failed : Tizen::Base::Runtime::Thread::Stop");
1603 memcpy(&Stopp, &tmpPtr, sizeof(tmpPtr));
1607 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1608 setProbePoint(&probeInfo);
1612 ret = (this->*Stopp)();
1614 if (postBlockBegin(blockresult)) {
1618 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1619 probeInfo.eventIndex, "Thread::Stop", probeInfo.currentTime,
1620 probeInfo.pID, probeInfo.tID);
1622 log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
1623 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1624 log.length += sprintf(log.data + log.length,
1625 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1626 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_WORKER, THREAD_API_STOP);
1628 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1629 getBacktraceString(&log, 4096 - log.length - 17);
1630 log.length += sprintf(log.data + log.length, "`,callstack_end");
1632 printLog(&log, MSG_LOG);
1638 result EventDrivenThread::Construct(long stackSize, ThreadPriority priority) {
1640 (Thread::*methodType)(long stackSize, ThreadPriority priority);
1641 static methodType Constructp = 0;
1643 probeInfo_t probeInfo;
1646 bool bfiltering = true;
1651 if(lib_handle[LIBOSP_APPFW] == NULL) {
1652 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1653 if (lib_handle[LIBOSP_APPFW] == NULL) {
1654 perror("dlopen failed : libosp-appfw.so");
1658 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW],
1659 "_ZN5Tizen4Base7Runtime17EventDrivenThread9ConstructElNS1_14ThreadPriorityE");
1660 if (tmpPtr == NULL || dlerror() != NULL) {
1661 perror("dlsym failed : Tizen::Base::Runtime::EventDrivenThread::Construct");
1665 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1669 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1670 setProbePoint(&probeInfo);
1674 ret = (this->*Constructp)(stackSize, priority);
1676 if (postBlockBegin(blockresult)) {
1680 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1681 probeInfo.eventIndex, "EventDrivenThread::Construct",
1682 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1684 log.length += sprintf(log.data + log.length, "`,%ld, %d`,%ld",
1685 stackSize, priority, ret);
1686 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1687 log.length += sprintf(log.data + log.length,
1688 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1689 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_EVENTDRIVEN, THREAD_API_NEW);
1691 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1692 getBacktraceString(&log, 4096 - log.length - 17);
1693 log.length += sprintf(log.data + log.length, "`,callstack_end");
1695 printLog(&log, MSG_LOG);
1701 result EventDrivenThread::Construct(const Tizen::Base::String &name, long stackSize,
1702 ThreadPriority priority) {
1704 (Thread::*methodType)(const Tizen::Base::String &name, long stackSize,
1705 ThreadPriority priority);
1706 static methodType Constructp = 0;
1708 probeInfo_t probeInfo;
1711 bool bfiltering = true;
1717 if(lib_handle[LIBOSP_APPFW] == NULL) {
1718 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1719 if (lib_handle[LIBOSP_APPFW] == NULL) {
1720 perror("dlopen failed : libosp-appfw.so");
1726 lib_handle[LIBOSP_APPFW],
1727 "_ZN5Tizen4Base7Runtime17EventDrivenThread9ConstructERKNS0_6StringElNS1_14ThreadPriorityE");
1729 if (tmpPtr == NULL || dlerror() != NULL) {
1730 perror("dlsym failed : Tizen::Base::Runtime::EventDrivenThread::Construct");
1734 memcpy(&Constructp, &tmpPtr, sizeof(tmpPtr));
1738 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1739 setProbePoint(&probeInfo);
1743 ret = (this->*Constructp)(name, stackSize, priority);
1745 if (postBlockBegin(blockresult)) {
1749 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1750 probeInfo.eventIndex, "EventDrivenThread::Construct",
1751 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1753 WcharToChar(temp, name.GetPointer());
1754 log.length += sprintf(log.data + log.length, "`,%s, %ld, %d`,%ld", temp,
1755 stackSize, priority, ret);
1756 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1757 log.length += sprintf(log.data + log.length,
1758 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1759 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_EVENTDRIVEN, THREAD_API_NEW);
1761 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1762 getBacktraceString(&log, 4096 - log.length - 17);
1763 log.length += sprintf(log.data + log.length, "`,callstack_end");
1765 printLog(&log, MSG_LOG);
1772 result EventDrivenThread::Quit() {
1773 typedef result (Thread::*methodType)(void);
1774 static methodType Quitp = 0;
1776 probeInfo_t probeInfo;
1779 bool bfiltering = true;
1784 if(lib_handle[LIBOSP_APPFW] == NULL) {
1785 lib_handle[LIBOSP_APPFW] = dlopen(lib_string[LIBOSP_APPFW], RTLD_LAZY);
1786 if (lib_handle[LIBOSP_APPFW] == NULL) {
1787 perror("dlopen failed : libosp-appfw.so");
1791 tmpPtr = dlsym(lib_handle[LIBOSP_APPFW], "_ZN5Tizen4Base7Runtime17EventDrivenThread4QuitEv");
1793 if (tmpPtr == NULL || dlerror() != NULL) {
1794 perror("dlsym failed : Tizen::Base::Runtime::EventThread::Quit");
1798 memcpy(&Quitp, &tmpPtr, sizeof(tmpPtr));
1802 if ((blockresult = preBlockBegin(CALLER_ADDRESS, bfiltering, _sopt)) != 0) {
1803 setProbePoint(&probeInfo);
1807 ret = (this->*Quitp)();
1809 if (postBlockBegin(blockresult)) {
1813 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", LC_THREAD,
1814 probeInfo.eventIndex, "EventThread::Quit", probeInfo.currentTime,
1815 probeInfo.pID, probeInfo.tID);
1817 log.length += sprintf(log.data + log.length, "`,`,%ld", ret);
1818 //PCAddr,errno,InternalCall,CallerPCAddr,PThreadID,OspThreadID,ThreadType,ApiType
1819 log.length += sprintf(log.data + log.length,
1820 "`,0`,%lu`,%d`,%u`,`,0x%x`,%d`,%d", ret, blockresult,
1821 (unsigned int)CALLER_ADDRESS, (unsigned int) this, THREAD_OSPTHREAD_EVENTDRIVEN, THREAD_API_STOP);
1823 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1824 getBacktraceString(&log, 4096 - log.length - 17);
1825 log.length += sprintf(log.data + log.length, "`,callstack_end");
1827 printLog(&log, MSG_LOG);