[STYLE] Spec: remove commented requires
[platform/core/system/swap-probe.git] / probe_tizenapi / tizen_thread.cpp
index b332012..10c9e62 100755 (executable)
@@ -31,6 +31,8 @@
  *
  */
 
+#include <typeinfo>
+#include <cxxabi.h>
 #include <FBase.h>
 #include "daprobe.h"
 #include "probeinfo.h"
@@ -128,6 +130,7 @@ _ThreadImpl::ThreadProc(void* params) {
        int blockresult;
        bool bfiltering = false;
        void *tmpPtr;
+       void *ret;
 
        if (!ThreadProcp) {
                probeBlockStart();
@@ -162,16 +165,16 @@ _ThreadImpl::ThreadProc(void* params) {
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_void___ThreadImpl__ThreadProc_void__params_,
-                                 "p", params);
-               PACK_COMMON_END((unsigned int)pSelf, 0, blockresult);
-               PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_START);
+                                 "p", voidp_to_uint64(params));
+               PACK_COMMON_END('p', 0, 0, blockresult);
+               PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_START, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                preBlockEnd();
                probingEnd();
        }
        // all probe should be reachable inside thread start_routine (user implemented Thread::Run)
-       (ThreadProcp)(params);
+       ret = (ThreadProcp)(params);
        //
        if (postBlockBegin(blockresult)) {
                probingStart();
@@ -186,9 +189,9 @@ _ThreadImpl::ThreadProc(void* params) {
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_void___ThreadImpl__ThreadProc_void__params_,
-                                 "p", params);
-               PACK_COMMON_END((unsigned int)pSelf, 0, blockresult);
-               PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_STOP);
+                                 "p", voidp_to_uint64(params));
+               PACK_COMMON_END('p', ret, 0, blockresult);
+               PACK_THREAD((unsigned int)pThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_INTERNAL_STOP, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -469,9 +472,9 @@ result Thread::Sleep(long milliSeconds) {
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Sleep_long_milliSeconds_,
-                                 "x", milliSeconds);
-               PACK_COMMON_END(0, 0, blockresult);
-               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START);
+                                 "x", (uint64_t)(milliSeconds));
+               PACK_COMMON_END('x', 0, 0, blockresult);
+               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                preBlockEnd();
@@ -488,9 +491,9 @@ result Thread::Sleep(long milliSeconds) {
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Yield_void_,
-                                 "x", milliSeconds);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END);
+                                 "x", (uint64_t)(milliSeconds));
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -542,8 +545,9 @@ Thread* Thread::GetCurrentThread(void) {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_Thread__Thread__GetCurrentThread_void_,
                                  "", 0);
-               PACK_COMMON_END((unsigned int)currentThread, res, blockresult);
-               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
+               PACK_COMMON_END('p', voidp_to_uint64(currentThread),
+                               res, blockresult);
+               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -596,8 +600,8 @@ result Thread::Yield(void) {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Yield_void_,
                                  "", 0);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -645,8 +649,8 @@ result Thread::Exit(int exitCode) {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Exit_int_exitCode_,
                                  "d", exitCode);
-               PACK_COMMON_END(0, 0, blockresult);
-               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_EXIT);
+               PACK_COMMON_END('n', 0, 0, blockresult);
+               PACK_THREAD((unsigned int)currentThread, THREAD_TIZENTHREAD_WORKER, THREAD_API_EXIT, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                preBlockEnd();
@@ -704,9 +708,10 @@ result Thread::Construct(ThreadType threadType, long stackSize,
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Construct_ThreadType_threadType__long_stackSize__ThreadPriority_priority_,
-                                 "dxd", threadType, stackSize, priority);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
+                                 "dxd", threadType, (uint64_t)(stackSize),
+                                 priority);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -755,9 +760,9 @@ result Thread::Construct(long stackSize, ThreadPriority priority) {
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Construct_long_stackSize__ThreadPriority_priority_,
-                                 "xd", stackSize, priority);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
+                                 "xd", (uint64_t)(stackSize), priority);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -812,9 +817,9 @@ result Thread::Construct(const Tizen::Base::String &name, long stackSize,
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Construct_const_Tizen__Base__String__name__long_stackSize__ThreadPriority_priority_,
-                                 "sxd", temp, stackSize, priority);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
+                                 "sxd", temp, (uint64_t)(stackSize), priority);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -871,9 +876,10 @@ result Thread::Construct(const Tizen::Base::String &name, ThreadType threadType,
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Construct_const_Tizen__Base__String__name__ThreadType_threadType__long_stackSize__ThreadPriority_priority_,
-                                 "sdxd", temp, threadType, stackSize, priority);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
+                                 "sdxd", temp, threadType,
+                                 (uint64_t)(stackSize), priority);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -927,9 +933,10 @@ result Thread::Construct(IRunnable &target, long stackSize,
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Construct_IRunnable__target__long_stackSize__ThreadPriority_priority_,
-                                 "xxd", (unsigned int) &target, stackSize, priority);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
+                                 "xxd", (uint64_t)(&target),
+                                 (uint64_t)(stackSize), priority);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -986,9 +993,10 @@ result Thread::Construct(const Tizen::Base::String &name, IRunnable &target,
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Construct_const_Tizen__Base__String__name__IRunnable__target__long_stackSize__ThreadPriority_priority_,
-                                 "sxxd", temp, (unsigned int) &target, stackSize, priority);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW);
+                                 "sxxd", temp, (uint64_t)(&target),
+                                 (uint64_t)(stackSize), priority);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -1041,8 +1049,8 @@ result Thread::GetExitCode(int &exitCode) const {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__GetExitCode_int__exitCode__const,
                                  "d", exitCode);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -1096,8 +1104,8 @@ const Tizen::Base::String & Thread::GetName(void) const {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_const_Tizen__Base__String___Thread__GetName_void__const,
                                  "", 0);
-               PACK_COMMON_END(ret.GetPointer(), res, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER);
+               PACK_COMMON_END('p', ret.GetPointer(), res, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_OTHER, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -1142,8 +1150,8 @@ result Thread::Join(void) {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Join_void_,
                                  "", 0);
-               PACK_COMMON_END(0, 0, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START);
+               PACK_COMMON_END('x', 0, 0, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_START, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                preBlockEnd();
@@ -1158,8 +1166,8 @@ result Thread::Join(void) {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Join_void_,
                                  "", 0);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_WAIT_END, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -1282,15 +1290,16 @@ result Thread::Start(void) {
        ret = (this->*Startp)();
        //
        if (postBlockBegin(blockresult)) {
-
+               int status;
+               char *class_name = abi::__cxa_demangle(typeid(*this).name(),0,0,&status);
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Start_void_,
                                  "", 0);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_START);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_START, class_name);
                FLUSH_LOCAL_BUF();
-
+               free(class_name);
                postBlockEnd();
        }
        return ret;
@@ -1337,8 +1346,8 @@ result Thread::Stop(void) {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_Thread__Stop_void_,
                                  "", 0);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_STOP);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_WORKER, THREAD_API_STOP, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -1388,9 +1397,9 @@ result EventDrivenThread::Construct(long stackSize, ThreadPriority priority) {
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_EventDrivenThread__Construct_long_stackSize__ThreadPriority_priority_,
-                                 "xd", stackSize, priority);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_NEW);
+                                 "xd", (uint64_t)(stackSize), priority);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -1448,9 +1457,9 @@ result EventDrivenThread::Construct(const Tizen::Base::String &name, long stackS
                PREPARE_LOCAL_BUF();
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_EventDrivenThread__Construct_const_Tizen__Base__String__name__long_stackSize__ThreadPriority_priority_,
-                                 "sx", temp, stackSize);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_NEW);
+                                 "sx", temp, (uint64_t)(stackSize));
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_NEW, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();
@@ -1501,8 +1510,8 @@ result EventDrivenThread::Quit() {
                PACK_COMMON_BEGIN(MSG_PROBE_THREAD,
                                  API_ID_result_EventDrivenThread__Quit__,
                                  "", 0);
-               PACK_COMMON_END(ret, ret, blockresult);
-               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_STOP);
+               PACK_COMMON_END('x', ret, ret, blockresult);
+               PACK_THREAD((unsigned int) this, THREAD_TIZENTHREAD_EVENTDRIVEN, THREAD_API_STOP, THREAD_CLASS_BLANK);
                FLUSH_LOCAL_BUF();
 
                postBlockEnd();