diff options
author | Eunji, Lee <eunjieji.lee@samsung.com> | 2016-07-05 21:16:06 +0900 |
---|---|---|
committer | Eunji, Lee <eunjieji.lee@samsung.com> | 2016-07-05 22:12:34 +0900 |
commit | 1891443319d103a542dbf4d18af66a73ec288938 (patch) | |
tree | 1abb9db736b2781ed290a175671aec8af4e9521f | |
parent | 5f101213b21ee0493415cd6b37163370a7611684 (diff) | |
download | ttrace-1891443319d103a542dbf4d18af66a73ec288938.tar.gz ttrace-1891443319d103a542dbf4d18af66a73ec288938.tar.bz2 ttrace-1891443319d103a542dbf4d18af66a73ec288938.zip |
change the logic of start/stop to prevent T-trace from writing to the locked bufferHEADsubmit/tizen/20160706.042922accepted/tizen/wearable/20160706.082716accepted/tizen/tv/20160706.082707accepted/tizen/mobile/20160706.082718accepted/tizen/ivi/20160706.082804accepted/tizen/common/20160707.171122master
print out error msg only if ttrace is running on debug mode
Change-Id: Ic1ee96dbb3a619cdf92187f2f5490b50b3781464
-rwxr-xr-x | src/atrace/atrace.cpp | 42 | ||||
-rwxr-xr-x | src/ttrace.c | 22 |
2 files changed, 42 insertions, 22 deletions
diff --git a/src/atrace/atrace.cpp b/src/atrace/atrace.cpp index c80cf06..dad1fa6 100755 --- a/src/atrace/atrace.cpp +++ b/src/atrace/atrace.cpp @@ -758,6 +758,12 @@ static bool setKernelTraceFuncs(const char* funcs) return ok; } +// Enable tracing in the kernel. +static bool startTrace() +{ + return setTracingEnabled(true); +} + // Set all the kernel tracing settings to the desired state for this trace // capture. static bool setUpTrace() @@ -779,7 +785,6 @@ static bool setUpTrace() #endif ok &= setPrintTgidEnableIfPresent(true); - // Set up the tags property. uint64_t tags = 0; #ifdef DEVICE_TYPE_TIZEN @@ -795,6 +800,13 @@ static bool setUpTrace() #ifdef DEVICE_TYPE_TIZEN if (tags == 0) tags |= TTRACE_TAG_ALWAYS; } + ok &= startTrace(); + if(!g_append_trace) { + // For debug + // printf("\nclear the trace\n"); + // + ok &= clearTrace(); + } #endif ok &= setTagsProperty(tags); ok &= setAppCmdlineProperty(g_debugAppCmdLine); @@ -833,7 +845,9 @@ static void cleanUpTrace() disableKernelTraceEvents(); // Reset the system properties. +#ifndef DEVICE_TYPE_TIZEN setTagsProperty(0); +#endif setAppCmdlineProperty(""); pokeBinderServices(); @@ -845,16 +859,12 @@ static void cleanUpTrace() setKernelTraceFuncs(NULL); } - -// Enable tracing in the kernel. -static bool startTrace() -{ - return setTracingEnabled(true); -} - // Disable tracing in the kernel. static void stopTrace() { +#ifdef DEVICE_TYPE_TIZEN + setTagsProperty(0); +#endif setTracingEnabled(false); } @@ -1234,17 +1244,18 @@ int main(int argc, char **argv) #ifdef DEVICE_TYPE_TIZEN if(traceStart && g_backup_trace) { //before start tracing by atrace, backup existig traces - stopTrace(); + stopTrace(); dumpTrace(true); } #endif if (!(async && !g_traceOverwrite)) { ok &= setUpTrace(); } +#ifndef DEVICE_TYPE_TIZEN ok &= startTrace(); - +#endif if (ok && traceStart) { - // For debug + // For debug // printf("capturing trace..."); // fflush(stdout); @@ -1254,13 +1265,14 @@ int main(int argc, char **argv) // contain entries from only one CPU can cause "begin" entries without a // matching "end" entry to show up if a task gets migrated from one CPU to // another. - if(!g_append_trace) { +#ifndef DEVICE_TYPE_TIZEN + if(!g_append_trace) { // For debug // printf("\nclear the trace\n"); // ok = clearTrace(); - } - + } +#endif if (ok && !async) { // Sleep to allow the trace to be captured. struct timespec timeLeft; @@ -1283,7 +1295,7 @@ int main(int argc, char **argv) printf(" done\nTRACE:\n"); fflush(stdout); #ifdef DEVICE_TYPE_TIZEN - dumpTrace(false); + dumpTrace(false); #else dumpTrace(); #endif diff --git a/src/ttrace.c b/src/ttrace.c index c255194..18da848 100755 --- a/src/ttrace.c +++ b/src/ttrace.c @@ -150,9 +150,10 @@ void traceBegin(uint64_t tag, const char *name, ...) if (g_extension_state == EXT_ACTIVATED) ttrace_extension_write(buf, len); else ret = write(g_trace_handle_fd, buf, len); - +#ifdef TTRACE_DEBUG if (ret < 0) fprintf(stderr, "error writing, len: %d, ret: %d, errno: %d at traceBegin.\n", len, ret, errno); +#endif } #ifdef TTRACE_DEBUG else { @@ -170,9 +171,10 @@ void traceEnd(uint64_t tag) if (g_extension_state == EXT_ACTIVATED) ttrace_extension_write("E", 1); else ret = write(g_trace_handle_fd, &end, 1); - +#ifdef TTRACE_DEBUG if (ret < 0) fprintf(stderr, "error writing, len: %d, ret: %d, errno: %d at traceEnd.\n", 1, ret, errno); +#endif } #ifdef TTRACE_DEBUG else @@ -211,9 +213,10 @@ void traceAsyncBegin(uint64_t tag, int32_t cookie, const char *name, ...) if (g_extension_state == EXT_ACTIVATED) ttrace_extension_write(buf, len); else ret = write(g_trace_handle_fd, buf, len); - +#ifdef TTRACE_DEBUG if (ret < 0) fprintf(stderr, "error writing, len: %d, ret: %d, errno: %d at traceAsyncBegin.\n", len, ret, errno); +#endif } #ifdef TTRACE_DEBUG else @@ -246,9 +249,10 @@ void traceAsyncEnd(uint64_t tag, int32_t cookie, const char *name, ...) if (g_extension_state == EXT_ACTIVATED) ttrace_extension_write(buf, len); else ret = write(g_trace_handle_fd, buf, len); - +#ifdef TTRACE_DEBUG if (ret < 0) fprintf(stderr, "error writing, len: %d, ret: %d, errno: %d at traceAsyncEnd.\n", len, ret, errno); +#endif } #ifdef TTRACE_DEBUG else @@ -280,15 +284,18 @@ void traceMark(uint64_t tag, const char *name, ...) if (g_extension_state == EXT_ACTIVATED) ttrace_extension_write(buf, len); else ret = write(g_trace_handle_fd, buf, len); - + +#ifdef TTRACE_DEBUG if (ret < 0) fprintf(stderr, "error writing, len: %d, ret: %d, errno: %d at traceMark.\n", len, ret, errno); +#endif if (g_extension_state == EXT_ACTIVATED) ttrace_extension_write("E", 1); else ret = write(g_trace_handle_fd, &end, 1); - +#ifdef TTRACE_DEBUG if (ret < 0) fprintf(stderr, "error writing, len: %d, ret: %d, errno: %d at traceMark.\n", 1, ret, errno); +#endif } #ifdef TTRACE_DEBUG else @@ -327,9 +334,10 @@ void traceCounter(uint64_t tag, int32_t value, const char *name, ...) if (g_extension_state == EXT_ACTIVATED) ttrace_extension_write(buf, len); else ret = write(g_trace_handle_fd, buf, len); - +#ifdef TTRACE_DEBUG if (ret < 0) fprintf(stderr, "error writing, len: %d, ret: %d, errno: %d at traceCounter.\n", len, ret, errno); +#endif } #ifdef TTRACE_DEBUG else |