[IMPROVE] add cache for pid
authorNikita Kalyazin <n.kalyazin@samsung.com>
Thu, 31 Oct 2013 10:07:26 +0000 (14:07 +0400)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Fri, 1 Nov 2013 13:17:05 +0000 (13:17 +0000)
As it's done for tid

Change-Id: Ieecf7ce5cc7f82bd1a9e1ad3bc078278152ab573
Signed-off-by: Nikita Kalyazin <n.kalyazin@samsung.com>
helper/libdaprobe.c

index 01f8a78..8ed1dfb 100755 (executable)
@@ -66,6 +66,7 @@
 
 __thread int           gProbeBlockCount = 0;
 __thread int           gProbeDepth = 0;
+pid_t gPid = -1;
 __thread pid_t         gTid = -1;
 
 int                    g_timerfd = 0;
@@ -184,6 +185,14 @@ static int determineCaller(char* tracestring)
        }
 }
 
+// return current process id
+static pid_t _getpid()
+{
+       if (gPid == -1)
+               gPid = getpid();
+       return gPid;
+}
+
 // return current thread id
 static pid_t _gettid()
 {
@@ -761,7 +770,7 @@ bool setProbePoint(probeInfo_t* iProbe)
        real_pthread_mutex_unlock(&(gTraceInfo.index.eventMutex));
 
        iProbe->currentTime = getCurrentTime();
-       iProbe->pID = getpid();
+       iProbe->pID = _getpid();
        iProbe->tID = _gettid();
        iProbe->callDepth = gProbeDepth;