Added function trace macros 31/68831/4
authorMinJeong Kim <minjjj.kim@samsung.com>
Tue, 10 May 2016 04:44:25 +0000 (13:44 +0900)
committerMinJeong Kim <minjjj.kim@samsung.com>
Wed, 11 May 2016 06:07:37 +0000 (23:07 -0700)
Change-Id: I22f5ac59169894a060a5fd48dc98d9f48687b1f6

configure.ac
packaging/enlightenment.spec
src/bin/e_log.h

index d34d92ee913b1fcb15d60f60c6541348e3096504..70edeab974cb090a52952be4c340a139f4b79318 100755 (executable)
@@ -247,6 +247,17 @@ AC_ARG_ENABLE([quick-init],
 AC_MSG_CHECKING([whether enlightenment quick initialization is enabled])
 AC_MSG_RESULT([${quick_init}])
 
+function_trace=no
+AC_ARG_ENABLE([function-trace],
+  AS_HELP_STRING([--enable-function-trace],[]),
+  [
+   function_trace=yes
+   AC_DEFINE_UNQUOTED([ENABLE_FUNCTION_TRACE], [1], [enable function trace])
+  ],
+  [function_trace=no])
+AC_MSG_CHECKING([whether enlightenment function trace is enabled])
+AC_MSG_RESULT([${function_trace}])
+
 e_requires="\
   evas >= $efl_version \
   ecore >= $efl_version \
index 55ba37ab0d3ada91c8792529ceef04bdbab924a3..d8b341c6e362774d5b395996202642ef4d6786e7 100644 (file)
@@ -55,11 +55,14 @@ cp %{SOURCE1001} .
 %build
 export CFLAGS+=" -fPIE "
 export LDFLAGS+=" -pie "
+
+%autogen \
 %if "%_repository" == "emulator32-wayland" || "%_repository" == "emulator64-wayland"
-%autogen --enable-wayland --enable-wl-drm --enable-quick-init --disable-hwc
-%else
-%autogen --enable-wayland --enable-wl-drm --enable-quick-init
+      --disable-hwc \
 %endif
+      --enable-function-trace \
+      --enable-wayland \
+      --enable-quick-init
 
 make %{?_smp_mflags}
 
index 1729c8c0f182db361a365b0ac83b22117424693f..ebdd612e1920f6ea8626e53157f5057ae69044db 100644 (file)
 #define ERR(...)            EINA_LOG_DOM_ERR(e_log_dom, __VA_ARGS__)
 #define CRI(...)            EINA_LOG_DOM_CRIT(e_log_dom, __VA_ARGS__)
 
+#undef PRCTL
+#undef PRCTL_BACKTRACE
+#undef DLOG_BACKTRACE
+
+#ifdef ENABLE_FUNCTION_TRACE
+# include <sys/prctl.h>
+# undef PR_TASK_PERF_USER_TRACE
+# define PR_TASK_PERF_USER_TRACE 666
+# define PRCTL(str, x...) \
+   ({ \
+    char __buf__[256]; \
+    snprintf(__buf__, sizeof(__buf__), str, ##x); \
+    prctl(PR_TASK_PERF_USER_TRACE, __buf__, strlen(__buf__)); \
+    })
+
+# include <execinfo.h>
+# define PRCTL_BACKTRACE()                               \
+   ({                                                    \
+    void *__buf__[256];                                  \
+    char **__strings__;                                  \
+    int __nptrs__, i;                                    \
+    __nptrs__ = backtrace(__buf__, 256);                 \
+    __strings__ = backtrace_symbols(__buf__, __nptrs__); \
+    if (__strings__)                                     \
+    {                                                    \
+       for(i = 0 ; i < __nptrs__ ; ++i)                  \
+       PRCTL("%s", __strings__[i]);                      \
+       free(__strings__);                                \
+    }                                                    \
+})
+
+# ifdef HAVE_DLOG
+#  define DLOG_BACKTRACE()                               \
+   ({                                                    \
+    void *__buf__[256];                                  \
+    char **__strings__;                                  \
+    int __nptrs__, i;                                    \
+    __nptrs__ = backtrace(__buf__, 256);                 \
+    __strings__ = backtrace_symbols(__buf__, __nptrs__); \
+    if (__strings__)                                     \
+    {                                                    \
+       for(i = 0 ; i < __nptrs__ ; ++i)                  \
+       dlog_print(DLOG_ERROR, LOG_TAG, "%s", __strings__[i]); \
+       free(__strings__);                                \
+    }                                                    \
+})
+# endif
+#else
+# define PRCTL
+# define PRCTL_BACKTRACE
+# define DLOG_BACKTRACE
+#endif
+
 #define ELOG(t, cp, ec)                                    \
    do                                                      \
      {                                                     \
@@ -77,6 +130,13 @@ EINTERN int e_log_shutdown(void);
 #define CRI(...)            do { printf(__VA_ARGS__); putc('\n', stdout); } while(0)
 #define ELOG(...)           ;
 #define ELOGF(...)          ;
+
+#undef PRCTL
+#undef PRCTL_BACKTRACE
+#undef DLOG_BACKTRACE
+#define PRCTL
+#define PRCTL_BACKTRACE
+#define DLOG_BACKTRACE
 #endif
 
 #endif