diff options
author | joon.c.baek <joon.c.baek@samsung.com> | 2016-01-04 17:13:38 +0900 |
---|---|---|
committer | joon.c.baek <joon.c.baek@samsung.com> | 2016-01-06 10:49:45 +0900 |
commit | a830ba37def639d3203839fce89b4db8600eaf9f (patch) | |
tree | db2134c7a7f8ef870e4ca1359e273b21f8ca87da | |
parent | 0143e851101918c1ead75234a3ac67592e89600f (diff) | |
download | ttrace-a830ba37def639d3203839fce89b4db8600eaf9f.tar.gz ttrace-a830ba37def639d3203839fce89b4db8600eaf9f.tar.bz2 ttrace-a830ba37def639d3203839fce89b4db8600eaf9f.zip |
ttrace: sync with latest code at spin server
sync with below commit,
spin change id : I81a345fdbf66e54cfbf1f3bcf0797fd91188b93c
spin commit id : 34f2dfa9650369778681e43b0d45768c036bfcd7
Change-Id: Ia0bbe19f47a23361385a34510b6c4f1c6768ca62
Signed-off-by: joon.c.baek <joon.c.baek@samsung.com>
-rwxr-xr-x | CMakeLists.txt | 2 | ||||
-rw-r--r-- | include/ttrace.h | 57 | ||||
-rwxr-xr-x | packaging/atrace-bootup.sh | 2 | ||||
-rwxr-xr-x | packaging/exec-ttrace-marker | 96 | ||||
-rwxr-xr-x[-rw-r--r--] | packaging/ttrace-marker.service | 3 | ||||
-rwxr-xr-x | packaging/ttrace.spec | 4 | ||||
-rwxr-xr-x | src/atrace/atrace.cpp | 105 | ||||
-rwxr-xr-x[-rw-r--r--] | src/ttrace.c | 4 | ||||
-rwxr-xr-x | ttrace.h.in | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | ttrace.manifest | 11 |
10 files changed, 171 insertions, 118 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 438b5b8..f0fd51e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ ADD_EXECUTABLE(${ATRACE} ${SRCS_atrace}) SET_TARGET_PROPERTIES(${ATRACE} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES(${ATRACE} PROPERTIES VERSION ${VERSION}) #SET_TARGET_PROPERTIES(${ATRACE} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_common}) -TARGET_LINK_LIBRARIES(${ATRACE} ${pkg_atrace_LDFLAGS} "-ldl") +TARGET_LINK_LIBRARIES(${ATRACE} ${pkg_atrace_LDFLAGS} "-ldl -lsmack") CONFIGURE_FILE(${ATRACE}.pc.in ${ATRACE}.pc @ONLY) diff --git a/include/ttrace.h b/include/ttrace.h deleted file mode 100644 index 5bfc5b9..0000000 --- a/include/ttrace.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * T-trace - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _CDBG_TIZEN_TTRACE_H_ -#define _CDBG_TIZEN_TTRACE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Define TTRACE_TAG */ -#define TTRACE_TAG_NEVER 0 // This tag is never enabled. -#define TTRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. -#define TTRACE_TAG_GRAPHICS (1<<1) -#define TTRACE_TAG_INPUT (1<<2) -#define TTRACE_TAG_VIEW (1<<3) -#define TTRACE_TAG_WEB (1<<4) -#define TTRACE_TAG_WINDOW_MANAGER (1<<5) -#define TTRACE_TAG_APPLICATION_MANAGER (1<<6) -#define TTRACE_TAG_IMAGE (1<<7) -#define TTRACE_TAG_AUDIO (1<<8) -#define TTRACE_TAG_VIDEO (1<<9) -#define TTRACE_TAG_CAMERA (1<<10) -#define TTRACE_TAG_HAL (1<<11) -#define TTRACE_TAG_MEDIA_CONTENT (1<<12) -#define TTRACE_TAG_MEDIA_DB (1<<13) -#define TTRACE_TAG_SCREEN_MIRRORING (1<<14) -#define TTRACE_TAG_APP (1<<15) -#define TTRACE_TAG_LAST TTRACE_TAG_APP - -#define ENABLED_TAG_FILE "/etc/ttrace/ttrace_tag" -void traceBegin(int tag, const char *name, ...); -void traceEnd(int tag); -void traceAsyncBegin(int tag, int cookie, const char *name, ...); -void traceAsyncEnd(int tag, int cookie, const char *name, ...); -void traceMark(int tag, const char *name, ...); -void traceCounter(int tag, int value, const char *name, ...); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _CDBG_TIZEN_TTRACE_H_ */ - diff --git a/packaging/atrace-bootup.sh b/packaging/atrace-bootup.sh index 8e45f2a..a9acea7 100755 --- a/packaging/atrace-bootup.sh +++ b/packaging/atrace-bootup.sh @@ -13,7 +13,7 @@ function HELP { CONF="/etc/ttrace.conf" SPACE=" " -COMMAND="atrace --async_start --append" +COMMAND="atrace --async_start" DEFTAGS="" NUMARGS=$# diff --git a/packaging/exec-ttrace-marker b/packaging/exec-ttrace-marker index 8b3b87a..2269efd 100755 --- a/packaging/exec-ttrace-marker +++ b/packaging/exec-ttrace-marker @@ -5,76 +5,78 @@ conf="/etc/ttrace.conf" change_permission="--update" function init_perms(){ - chown root:users /sys/kernel/debug/tracing/trace_clock - chown root:users /sys/kernel/debug/tracing/buffer_size_kb - chown root:users /sys/kernel/debug/tracing/options/overwrite - chown root:users /sys/kernel/debug/tracing/options/print-tgid - chown root:users /sys/kernel/debug/tracing/events/sched/sched_switch/enable - chown root:users /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable - chown root:users /sys/kernel/debug/tracing/events/power/cpu_frequency/enable - chown root:users /sys/kernel/debug/tracing/events/power/clock_set_rate/enable - chown root:users /sys/kernel/debug/tracing/events/cpufreq_interactive/enable - chown root:users /sys/kernel/debug/tracing/events/power/cpu_idle/enable - chown root:users /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable - chown root:users /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable - chown root:users /sys/kernel/debug/tracing/events/block/block_rq_issue/enable - chown root:users /sys/kernel/debug/tracing/events/block/block_rq_complete/enable - chown root:users /sys/kernel/debug/tracing/events/mmc/enable - chown root:users /sys/kernel/debug/tracing/events/sync/enable - chown root:users /sys/kernel/debug/tracing/events/workqueue/enable - chown root:users /sys/kernel/debug/tracing/current_tracer - chown root:users /sys/kernel/debug/tracing/tracing_on - chown root:users /sys/kernel/debug/tracing/trace - chown root:users /usr/bin/atrace - chown root:users /tmp/ttrace_tag + chown root:developer /tmp/ttrace_tag + chmod 0664 /tmp/ttrace_tag + chsmack -a '*' /tmp/ttrace_tag - chmod 0664 /sys/kernel/debug/tracing/trace_clock - chmod 0664 /sys/kernel/debug/tracing/buffer_size_kb - chmod 0664 /sys/kernel/debug/tracing/options/overwrite - chmod 0664 /sys/kernel/debug/tracing/options/print-tgid - chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_switch/enable - chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable - chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_frequency/enable - chmod 0664 /sys/kernel/debug/tracing/events/power/clock_set_rate/enable - chmod 0664 /sys/kernel/debug/tracing/events/cpufreq_interactive/enable - chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_idle/enable - chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable - chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable - chmod 0664 /sys/kernel/debug/tracing/events/block/block_rq_issue/enable - chmod 0664 /sys/kernel/debug/tracing/events/block/block_rq_complete/enable - chmod 0664 /sys/kernel/debug/tracing/events/mmc/enable - chmod 0664 /sys/kernel/debug/tracing/events/sync/enable - chmod 0664 /sys/kernel/debug/tracing/events/workqueue/enable - chmod 0664 /sys/kernel/debug/tracing/current_tracer - chmod 0222 /sys/kernel/debug/tracing/trace_marker - chmod 0664 /sys/kernel/debug/tracing/tracing_on - chmod 0660 /sys/kernel/debug/tracing/trace chmod 0755 /sys/kernel/debug - chmod 0755 /usr/bin/atrace - chmod 0664 /tmp/ttrace_tag + chown root:developer /sys/kernel/debug/tracing/trace_marker + chmod 0222 /sys/kernel/debug/tracing/trace_marker + chsmack -a '*' /sys/kernel/debug/tracing/trace_marker + chown root:developer /sys/kernel/debug/tracing/trace_clock + chmod 0664 /sys/kernel/debug/tracing/trace_clock chsmack -a '*' /sys/kernel/debug/tracing/trace_clock + chown root:developer /sys/kernel/debug/tracing/buffer_size_kb + chmod 0664 /sys/kernel/debug/tracing/buffer_size_kb chsmack -a '*' /sys/kernel/debug/tracing/buffer_size_kb + chown root:developer /sys/kernel/debug/tracing/options/overwrite + chmod 0664 /sys/kernel/debug/tracing/options/overwrite chsmack -a '*' /sys/kernel/debug/tracing/options/overwrite + chown root:developer /sys/kernel/debug/tracing/options/print-tgid + chmod 0664 /sys/kernel/debug/tracing/options/print-tgid chsmack -a '*' /sys/kernel/debug/tracing/options/print-tgid + chown root:developer /sys/kernel/debug/tracing/events/sched/sched_switch/enable + chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_switch/enable chsmack -a '*' /sys/kernel/debug/tracing/events/sched/sched_switch/enable + chown root:developer /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable + chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable chsmack -a '*' /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable + chown root:developer /sys/kernel/debug/tracing/events/power/cpu_frequency/enable + chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_frequency/enable chsmack -a '*' /sys/kernel/debug/tracing/events/power/cpu_frequency/enable + chown root:developer /sys/kernel/debug/tracing/events/power/clock_set_rate/enable + chmod 0664 /sys/kernel/debug/tracing/events/power/clock_set_rate/enable chsmack -a '*' /sys/kernel/debug/tracing/events/power/clock_set_rate/enable + chown root:developer /sys/kernel/debug/tracing/events/cpufreq_interactive/enable + chmod 0664 /sys/kernel/debug/tracing/events/cpufreq_interactive/enable chsmack -a '*' /sys/kernel/debug/tracing/events/cpufreq_interactive/enable + chown root:developer /sys/kernel/debug/tracing/events/power/cpu_idle/enable + chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_idle/enable chsmack -a '*' /sys/kernel/debug/tracing/events/power/cpu_idle/enable + chown root:developer /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable + chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable chsmack -a '*' /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable + chown root:developer /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable + chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable chsmack -a '*' /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable + chown root:developer /sys/kernel/debug/tracing/events/block/block_rq_issue/enable + chmod 0664 /sys/kernel/debug/tracing/events/block/block_rq_issue/enable chsmack -a '*' /sys/kernel/debug/tracing/events/block/block_rq_issue/enable + chown root:developer /sys/kernel/debug/tracing/events/block/block_rq_complete/enable + chmod 0664 /sys/kernel/debug/tracing/events/block/block_rq_complete/enable chsmack -a '*' /sys/kernel/debug/tracing/events/block/block_rq_complete/enable + chown root:developer /sys/kernel/debug/tracing/events/mmc/enable + chmod 0664 /sys/kernel/debug/tracing/events/mmc/enable chsmack -a '*' /sys/kernel/debug/tracing/events/mmc/enable + chown root:developer /sys/kernel/debug/tracing/events/sync/enable + chmod 0664 /sys/kernel/debug/tracing/events/sync/enable chsmack -a '*' /sys/kernel/debug/tracing/events/sync/enable + chown root:developer /sys/kernel/debug/tracing/events/workqueue/enable + chmod 0664 /sys/kernel/debug/tracing/events/workqueue/enable chsmack -a '*' /sys/kernel/debug/tracing/events/workqueue/enable + chown root:developer /sys/kernel/debug/tracing/current_tracer + chmod 0664 /sys/kernel/debug/tracing/current_tracer chsmack -a '*' /sys/kernel/debug/tracing/current_tracer - chsmack -a '*' /sys/kernel/debug/tracing/trace_marker + chown root:developer /sys/kernel/debug/tracing/tracing_on + chmod 0664 /sys/kernel/debug/tracing/tracing_on chsmack -a '*' /sys/kernel/debug/tracing/tracing_on + chown root:developer /sys/kernel/debug/tracing/trace + chmod 0660 /sys/kernel/debug/tracing/trace chsmack -a '*' /sys/kernel/debug/tracing/trace - chsmack -a '*' /tmp/ttrace_tag + + chown root:developer /usr/bin/atrace + chmod 0755 /usr/bin/atrace } diff --git a/packaging/ttrace-marker.service b/packaging/ttrace-marker.service index ac7b938..288e676 100644..100755 --- a/packaging/ttrace-marker.service +++ b/packaging/ttrace-marker.service @@ -5,7 +5,8 @@ After=sys-kernel-debug.mount [Service] Type=simple -ExecStart=/usr/bin/exec-ttrace-marker +ExecStart=/usr/bin/atrace --init_exec +SmackProcessLabel=ttrace [Install] WantedBy=sys-kernel-debug.mount diff --git a/packaging/ttrace.spec b/packaging/ttrace.spec index fa9bda8..b450a72 100755 --- a/packaging/ttrace.spec +++ b/packaging/ttrace.spec @@ -5,13 +5,13 @@ Release: 1 Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -SOURCE101: packaging/exec-ttrace-marker SOURCE102: packaging/ttrace-marker.service SOURCE103: packaging/atrace-bootup.sh BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(libsmack) BuildRequires: cmake %define keepstatic 1 @@ -55,7 +55,6 @@ rm -rf %{buildroot} install -d %{buildroot}%{_unitdir}/ttrace-marker.service.wants install -m0644 %{SOURCE102} %{buildroot}%{_unitdir} mkdir -p %{buildroot}%{_bindir} -cp %{SOURCE101} %{buildroot}%{_bindir} cp %{SOURCE103} %{buildroot}%{_bindir} mkdir -p %{buildroot}/usr/share/license cp LICENSE %{buildroot}/usr/share/license/%{name} @@ -73,7 +72,6 @@ cp LICENSE %{buildroot}/usr/share/license/%{name} %{_unitdir}/ttrace-marker.service.wants/ %attr(755,root,developer) %{_bindir}/atrace %attr(755,root,developer) %{_bindir}/atrace-1.1 -%attr(755,root,root) %{_bindir}/exec-ttrace-marker %{_unitdir}/sys-kernel-debug.mount.wants/ttrace-marker.service %attr(755,root,root) %{_bindir}/atrace-bootup.sh /usr/share/license/%{name} diff --git a/src/atrace/atrace.cpp b/src/atrace/atrace.cpp index 129e720..65721cf 100755 --- a/src/atrace/atrace.cpp +++ b/src/atrace/atrace.cpp @@ -31,12 +31,18 @@ #include <stdint.h> #include <strings.h> #include <string.h> +#include <grp.h> #include <sys/mman.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/smack.h> +#include <unistd.h> #include "ttrace.h" #define TTRACE_TAG_NONE 9999 #define TAG_NONE_IDX 0 #define BACKUP_TRACE "/tmp/trace.backup" +#define BOOTUP_TRACE "/etc/ttrace.conf" #else #include <binder/IBinder.h> #include <binder/IServiceManager.h> @@ -59,6 +65,35 @@ const char* k_traceAppCmdlineProperty = "debug.atrace.app_cmdlines"; typedef enum { OPT, REQ } requiredness ; char str_error[256] = ""; +struct CommonNode { + const char* path; + const mode_t perms; +}; +static const CommonNode commonNodes[] = { + { "/tmp/ttrace_tag", 0664 }, + { "/sys/kernel/debug", 0755 }, + { "/sys/kernel/debug/tracing/trace_marker", 0222 }, + { "/sys/kernel/debug/tracing/trace_clock", 0664 }, + { "/sys/kernel/debug/tracing/buffer_size_kb", 0664 }, + { "/sys/kernel/debug/tracing/current_tracer", 0664 }, + { "/sys/kernel/debug/tracing/tracing_on", 0664 }, + { "/sys/kernel/debug/tracing/trace", 0660 }, + { "/sys/kernel/debug/tracing/options/overwrite", 0664 }, + { "/sys/kernel/debug/tracing/options/print-tgid", 0664 }, + { "/sys/kernel/debug/tracing/events/sched/sched_switch/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/sched/sched_wakeup/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/power/cpu_frequency/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/memory_bus/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/power/cpu_idle/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/block/block_rq_issue/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/block/block_rq_complete/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/mmc/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/cpufreq_interactive/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/sync/enable", 0664 }, + { "/sys/kernel/debug/tracing/events/workqueue/enable", 0664 }, +}; struct TracingCategory { // The name identifying the category. @@ -150,6 +185,7 @@ static const TracingCategory k_categories[] = { } }, #ifdef TTRACE_PROFILE_MOBILE #elif defined TTRACE_PROFILE_TV + { "system", "System", TTRACE_TAG_SYSTEM, { } }, #elif defined TTRACE_PROFILE_WEARABLE #endif }; @@ -223,6 +259,32 @@ static bool fileExists(const char* filename) { static bool fileIsWritable(const char* filename) { return access(filename, W_OK) != -1; } +static bool initSysfsPermission() { + struct group group_dev; + struct group* group_ptr; + char buf[128]; + if(0 != getgrnam_r("developer", &group_dev, buf, sizeof(buf), &group_ptr)) + return false; + for (int i = 0 ; i < NELEM(commonNodes); i++) { + const CommonNode &node = commonNodes[i]; + if (node.path != NULL) { + if (fileExists(node.path)) { + if (strcmp(node.path, "/sys/kernel/debug") == 0) { + chmod(node.path, node.perms); + } + else { + chown(node.path, 0, group_dev.gr_gid); + chmod(node.path, node.perms); + smack_setlabel(node.path, "*", SMACK_LABEL_ACCESS); + } + } + } + else { + return false; + } + } + return true; +} // Truncate a file. static bool truncateFile(const char* path) @@ -415,10 +477,16 @@ static bool setTagsProperty(uint64_t tags) #ifdef DEVICE_TYPE_TIZEN uint64_t *sm_for_enabled_tag = NULL; int fd = -1; - fd = open(ENABLED_TAG_FILE, O_CREAT | O_RDWR | O_CLOEXEC, 0666); + if(g_init_exec) { + fd = open("/tmp/tmp_tag", O_CREAT | O_RDWR | O_CLOEXEC, 0666); if(fd < 0){ fprintf(stderr, "Fail to open enabled_tag file: %s(%d)\n", strerror_r(errno, str_error, sizeof(str_error)), errno); + return false; + } + if (ftruncate(fd, sizeof(uint64_t)) < 0) { + fprintf(stderr, "error: ftruncate() failed(%s)\n", strerror_r(errno, str_error, sizeof(str_error))); + close(fd); return false; } sm_for_enabled_tag = (uint64_t*)mmap(NULL, sizeof(uint64_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); @@ -428,16 +496,43 @@ static bool setTagsProperty(uint64_t tags) close(fd); return false; } - if(g_init_exec) { - if (ftruncate(fd, sizeof(uint64_t)) < 0) { - fprintf(stderr, "error: ftruncate() failed(%s)\n", strerror_r(errno, str_error, sizeof(str_error))); + + memset(sm_for_enabled_tag, 0, sizeof(uint64_t)); + if(-1 == rename("/tmp/tmp_tag", ENABLED_TAG_FILE)) { + fprintf(stderr, "Fail to rename enabled_tag file: %s(%d)\n", strerror_r(errno, str_error, sizeof(str_error)), errno); + } + if(false == initSysfsPermission()) { + fprintf(stderr, "Fail to init sysfs permisions: %s(%d)\n", strerror_r(errno, str_error, sizeof(str_error)), errno); + } + if(fileExists(BOOTUP_TRACE)) { + FILE *ifile = NULL; + char bootup_cmd[128]; + ifile = fopen(BOOTUP_TRACE, "r"); + if (ifile == NULL) { munmap(sm_for_enabled_tag, sizeof(uint64_t)); close(fd); return false; } - memset(sm_for_enabled_tag, 0, sizeof(uint64_t)); + fgets(bootup_cmd, sizeof(bootup_cmd), ifile); + fclose(ifile); + remove(BOOTUP_TRACE); + system(bootup_cmd); + } } + else { + fd = open(ENABLED_TAG_FILE, O_RDWR | O_CLOEXEC, 0666); + if(fd < 0){ + fprintf(stderr, "Fail to open enabled_tag file: %s(%d)\n", strerror_r(errno, str_error, sizeof(str_error)), errno); + return false; + } + sm_for_enabled_tag = (uint64_t*)mmap(NULL, sizeof(uint64_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if(sm_for_enabled_tag == MAP_FAILED) { + fprintf(stderr, "error: mmap() failed(%s)\n", strerror_r(errno, str_error, sizeof(str_error))); + close(fd); + return false; + } *sm_for_enabled_tag = tags; + } // For debug // fprintf(stderr, "Enabled TAGs: %u\n", (uint32_t)*sm_for_enabled_tag); // diff --git a/src/ttrace.c b/src/ttrace.c index ec00949..e9277ae 100644..100755 --- a/src/ttrace.c +++ b/src/ttrace.c @@ -62,6 +62,7 @@ static uint64_t traceInit() { uint64_t *sm_for_enabled_tag; + if(g_trace_handle_fd == FD_INITIAL_VALUE) { g_trace_handle_fd = open(TRACE_FILE, O_WRONLY); if (g_trace_handle_fd < 0) { TTRACE_LOG("Fail to open trace file: %s(%d)", strerror(errno), errno); @@ -71,6 +72,7 @@ static uint64_t traceInit() set_last_result(TRACE_ERROR_IO_ERROR); return 0; + } } if (cur_enabled_tag == ((void *)&dummy)) { g_enabled_tag_fd = open(ENABLED_TAG_FILE, O_RDONLY | O_CLOEXEC); @@ -98,7 +100,7 @@ static uint64_t traceInit() static inline uint64_t isTagEnabled(uint64_t cur_tag) { - if (g_trace_handle_fd == TRACE_FILE_NOT_EXIST || g_enabled_tag_fd == TRACE_FILE_NOT_EXIST) + if (g_trace_handle_fd == TRACE_FILE_NOT_EXIST) return 0; /* if no tag is enabled, trace all tags. */ cur_tag |= TTRACE_TAG_ALWAYS; diff --git a/ttrace.h.in b/ttrace.h.in index a6aabf4..f52b85b 100755 --- a/ttrace.h.in +++ b/ttrace.h.in @@ -50,9 +50,10 @@ extern "C" { #ifdef TTRACE_PROFILE_MOBILE //define TAGs belonging to mobile profile only #elif defined TTRACE_PROFILE_TV -//define TAGs belonging to mobile profile only +//define TAGs belonging to tv profile only +#define TTRACE_TAG_SYSTEM (1<<16) #elif defined TTRACE_PROFILE_WEARABLE -//define TAGs belonging to mobile profile only +//define TAGs belonging to wearable profile only #endif #define TTRACE_TAG_LAST (1<<63) diff --git a/ttrace.manifest b/ttrace.manifest index 97e8c31..9ba6396 100644..100755 --- a/ttrace.manifest +++ b/ttrace.manifest @@ -1,4 +1,15 @@ <manifest> + <define> + <domain name="ttrace" policy="restricted"/> + <request> + <smack request="sdbd" type="r" /> + </request> + </define> + <assign> + <filesystem path="/usr/bin/atrace" label="_" exec_label="ttrace" /> + <filesystem path="/usr/bin/atrace-1.1" label="_" exec_label="ttrace" /> + <filesystem path="/usr/bin/atrace-bootup.sh" label="_" exec_label="ttrace" /> + </assign> <request> <domain name="_"/> </request> |