[kgtp] r940 committed - Update patch

  • From: kgtp@xxxxxxxxxxxxxx
  • To: kgtp@xxxxxxxxxxxxx
  • Date: Sat, 25 Feb 2012 10:37:46 +0000

Revision: 940
Author:   teawater
Date:     Sat Feb 25 02:36:54 2012
Log:      Update patch

http://code.google.com/p/kgtp/source/detail?r=940

Modified:
 /trunk/gtp.c
 /trunk/gtp_2.6.33_to_2.6.38.patch
 /trunk/gtp_2.6.39.patch
 /trunk/gtp_3.0_to_upstream.patch
 /trunk/gtp_for_review.patch
 /trunk/gtp_older_to_2.6.32.patch

=======================================
--- /trunk/gtp.c        Thu Feb 23 23:02:43 2012
+++ /trunk/gtp.c        Sat Feb 25 02:36:54 2012
@@ -4743,7 +4743,7 @@
                                        goto release_out;
                                } else if (arg == GTP_VAR_KRET_ID) {
                                        /* XXX: still not set it
-                                               value to maxactive.  */
+                                          value to maxactive.  */
                                        tpe->is_kretprobe = 1;
                                        ret = 1;
                                        goto release_out;
=======================================
--- /trunk/gtp_2.6.33_to_2.6.38.patch   Tue Jan 31 04:51:57 2012
+++ /trunk/gtp_2.6.33_to_2.6.38.patch   Sat Feb 25 02:36:54 2012
@@ -1,24 +1,25 @@
 ---
- Documentation/trace/gtp.txt            | 1517 +++++
- Documentation/trace/gtp_quickstart.txt |  250
- include/linux/perf_event.h             |    3
- kernel/perf_event.c                    |   26
- lib/Kconfig.debug                      |   10
- lib/Makefile                           |    2
- lib/gtp.c | 9031 +++++++++++++++++++++++++++++++++
- lib/gtp_rb.c                           |  474 +
- scripts/getgtprsp.pl                   |  102
- scripts/getmod.py                      |  132
- 10 files changed, 11545 insertions(+), 2 deletions(-)
+ Documentation/gtp/howto.txt      | 1519 ++++++
+ Documentation/gtp/quickstart.txt |  250 +
+ include/linux/perf_event.h       |    3
+ kernel/perf_event.c              |   26
+ lib/Kconfig.debug                |   10
+ lib/Makefile                     |    2
+ lib/gtp.c | 9210 +++++++++++++++++++++++++++++++++++++++
+ lib/gtp_rb.c                     |  495 ++
+ scripts/gtp/add-ons/pe.py        |  729 +++
+ scripts/gtp/getgtprsp.pl         |  137
+ scripts/gtp/getmod.py            |  132
+ 11 files changed, 12511 insertions(+), 2 deletions(-)

 --- /dev/null
-+++ b/Documentation/trace/gtp.txt
-@@ -0,0 +1,1517 @@
++++ b/Documentation/gtp/howto.txt
+@@ -0,0 +1,1519 @@
 +              Linux Kernel GDB tracepoint module (KGTP)
 +              =========================================
 +              By Hui Zhu <teawater@xxxxxxxxx>
 +              https://code.google.com/p/kgtp/wiki/HOWTO
-+              2011-12-16
++              2012-02-21
 +
 +Table of contents
 +-----------------
@@ -50,7 +51,7 @@
 +      How to use trace state variables
 +              Simple trace state variables
 +              Per_cpu trace state variables
-+              Special trace state variables $current_task,
++              Special trace state variables $current_task, $current_task_pid,
 +                  $current_thread_info, $cpu_id, $dump_stack, $printk_level,
 +                  $printk_format, $printk_tmp, $clock, $rdtsc, $hardirq_count,
 +                  $softirq_count and $irq_count
@@ -100,7 +101,7 @@
 +(See https://code.google.com/p/kgtp/wiki/HowToUseKGTPinAndroid).
 +It supports X86-32, X86-64, MIPS and ARM.
 +
-+For new user of KGTP, please go to see gtp_quickstart.txt.
++For new user of KGTP, please go to see quickstart.txt.
 +
 +
 +
@@ -651,9 +652,9 @@
 +of each CPU.
 +
 +
-+Special trace state variables $current_task, $current_thread_info, $cpu_id,
-+$dump_stack, $printk_level, $printk_format, $printk_tmp, $clock, $rdtsc,
-+$hardirq_count, $softirq_count and $irq_count
++Special trace state variables $current_task, $current_task_pid,
++$current_thread_info, $cpu_id, $dump_stack, $printk_level, $printk_format,
++$printk_tmp, $clock, $rdtsc, $hardirq_count, $softirq_count and $irq_count
+---------------------------------------------------------------------------
 +
 +KGTP special trace state variables $current_task, $current_thread_info,
@@ -662,6 +663,8 @@
 +or actions.
+Access $current_task in tracepoint condition and action will get that returns
 +of get_current().
++Access $current_task_pid in tracepoint condition and action will get that
++returns of get_current()->pid.
+Access $current_thread_info in tracepoint condition and action will get that
 +returns of current_thread_info().
 +Access $cpu_id in tracepoint condition and action will get that returns of
@@ -794,12 +797,12 @@
 +And the last error number will available in "$last_errno".
 +
 +---------------------------------
-+tvariable $ignore_error
++tvariable $ignore_error=1
 +---------------------------------
 +This command will open ignore.
 +
 +---------------------------------
-+delete tvariable $ignore_error
++tvariable $ignore_error=0
 +---------------------------------
 +This command will close ignore.
 +
@@ -1532,7 +1535,7 @@
 +This way is better to work with python to parse Kernel.
 +I will introduce them in example.
 --- /dev/null
-+++ b/Documentation/trace/gtp_quickstart.txt
++++ b/Documentation/gtp/quickstart.txt
 @@ -0,0 +1,250 @@
 +              Linux Kernel GDB tracepoint module (KGTP) quick start
 +              =====================================================
@@ -1674,7 +1677,7 @@
 +(gdb) tstop
 +(gdb) tfind
 +Found trace frame 0, tracepoint 1
-+#0 vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at /build/buildd/linux-2.6.35/fs/readdir.c:23
++#0  vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at readdir.c:23
 +23      {
 +
 +
@@ -1905,7 +1908,7 @@

 --- /dev/null
 +++ b/lib/gtp.c
-@@ -0,0 +1,9031 @@
+@@ -0,0 +1,9210 @@
 +/*
 + * Kernel GDB tracepoint module.
 + *
@@ -1928,7 +1931,7 @@
 + */
 +
 +/* If *10 means that this is not a release version.  */
-+#define GTP_VERSION                   (20120131)
++#define GTP_VERSION                   (20120224)
 +
 +#include <linux/version.h>
 +#ifndef RHEL_RELEASE_VERSION
@@ -2113,6 +2116,7 @@
 +#endif
 +
 +#define GTP_RW_MAX            16384
++#define GTP_RW_BUFP_MAX               (GTP_RW_MAX - 4 - gtp_rw_size)
 +
 +#define FID_TYPE              unsigned int
 +#define FID_SIZE              sizeof(FID_TYPE)
@@ -2339,7 +2343,9 @@
 +      GTP_VAR_HARDIRQ_COUNT_ID,
 +      GTP_VAR_SOFTIRQ_COUNT_ID,
 +      GTP_VAR_IRQ_COUNT_ID,
-+      GTP_VAR_SPECIAL_MAX = GTP_VAR_IRQ_COUNT_ID,
++      GTP_VAR_PIPE_TRACE_ID,
++      GTP_VAR_CURRENT_TASK_PID_ID,
++      GTP_VAR_SPECIAL_MAX = GTP_VAR_PIPE_TRACE_ID,
 +};
 +
 +#define PREV_VAR      NULL
@@ -2349,6 +2355,10 @@
 +      .num            = GTP_VAR_VERSION_ID,
 +      .src            = "0:1:6774705f76657273696f6e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_version)
@@ -2358,6 +2368,10 @@
 +      .num            = GTP_VAR_CPU_ID,
 +      .src            = "0:1:6370755f6964",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_id)
@@ -2367,15 +2381,36 @@
 +      .num            = GTP_VAR_CURRENT_TASK_ID,
 +      .src            = "0:1:63757272656e745f7461736b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_task)
 +
++static struct gtp_var         gtp_var_current_task_pid = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_CURRENT_TASK_PID_ID,
++      .src            = "0:1:63757272656e745f7461736b5f706964",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_current_task_pid)
++
 +static struct gtp_var         gtp_var_current_thread_info = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CURRENT_THREAD_INFO_ID,
 +      .src            = "0:1:63757272656e745f7468726561645f696e666f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_thread_info)
@@ -2385,6 +2420,10 @@
 +      .num            = GTP_VAR_CLOCK_ID,
 +      .src            = "0:1:636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_clock)
@@ -2394,6 +2433,10 @@
 +      .num            = GTP_VAR_COOKED_CLOCK_ID,
 +      .src            = "0:1:636f6f6b65645f636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_clock)
@@ -2404,6 +2447,10 @@
 +      .num            = GTP_VAR_RDTSC_ID,
 +      .src            = "0:1:7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_rdtsc)
@@ -2412,6 +2459,10 @@
 +      .num            = GTP_VAR_COOKED_RDTSC_ID,
 +      .src            = "0:1:636f6f6b65645f7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_rdtsc)
@@ -2423,6 +2474,10 @@
 +      .num            = GTP_VAR_GTP_RB_DISCARD_PAGE_NUMBER,
 +      .src            = "0:1:646973636172645f706167655f6e756d",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_gtp_rb_discard_page_number)
@@ -2433,6 +2488,10 @@
 +      .num            = GTP_VAR_PRINTK_TMP_ID,
 +      .src            = "0:1:7072696e746b5f746d70",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_tmp)
@@ -2442,6 +2501,10 @@
 +      .num            = GTP_VAR_PRINTK_LEVEL_ID,
 +      .src            = "8:1:7072696e746b5f6c6576656c",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_level)
@@ -2451,6 +2514,10 @@
 +      .num            = GTP_VAR_PRINTK_FORMAT_ID,
 +      .src            = "0:1:7072696e746b5f666f726d6174",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_format)
@@ -2460,6 +2527,10 @@
 +      .num            = GTP_VAR_DUMP_STACK_ID,
 +      .src            = "0:1:64756d705f737461636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_dump_stack)
@@ -2469,15 +2540,36 @@
 +      .num            = GTP_VAR_NO_SELF_TRACE_ID,
 +      .src            = "0:1:6e6f5f73656c665f7472616365",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_no_self_trace)
 +
++static struct gtp_var         gtp_var_pipe_trace = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_PIPE_TRACE_ID,
++      .src            = "0:1:706970655f7472616365",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_pipe_trace)
++
 +static struct gtp_var         gtp_var_cpu_number = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CPU_NUMBER_ID,
 +      .src            = "0:1:6370755f6e756d626572",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_number)
@@ -2487,6 +2579,10 @@
 +      .num            = GTP_VAR_PC_PE_EN_ID,
 +      .src            = "0:1:70635f70655f656e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_pc_pe_en)
@@ -2496,6 +2592,10 @@
 +      .num            = GTP_VAR_KRET_ID,
 +      .src            = "0:1:6b726574",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_kret)
@@ -2505,6 +2605,10 @@
 +      .num            = GTP_VAR_XTIME_SEC_ID,
 +      .src            = "0:1:7874696d655f736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_sec)
@@ -2514,6 +2618,10 @@
 +      .num            = GTP_VAR_XTIME_NSEC_ID,
 +      .src            = "0:1:7874696d655f6e736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_nsec)
@@ -2523,6 +2631,10 @@
 +      .num            = GTP_VAR_IGNORE_ERROR_ID,
 +      .src            = "0:1:69676e6f72655f6572726f72",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_ignore_error)
@@ -2532,6 +2644,10 @@
 +      .num            = GTP_VAR_LAST_ERRNO_ID,
 +      .src            = "0:1:6c6173745f6572726e6f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_last_errno)
@@ -2541,6 +2657,10 @@
 +      .num            = GTP_VAR_HARDIRQ_COUNT_ID,
 +      .src            = "0:1:686172646972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_hardirq_count)
@@ -2550,6 +2670,10 @@
 +      .num            = GTP_VAR_SOFTIRQ_COUNT_ID,
 +      .src            = "0:1:736f66746972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_softirq_count)
@@ -2559,6 +2683,10 @@
 +      .num            = GTP_VAR_IRQ_COUNT_ID,
 +      .src            = "0:1:6972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +
@@ -2566,19 +2694,6 @@
 +
 +#define GTP_VAR_IS_SPECIAL(x)         ((x) >= GTP_VAR_SPECIAL_MIN \
 +                                       && (x) <= GTP_VAR_SPECIAL_MAX)
-+#define GTP_VAR_NOT_GETV(x)           ((x) == GTP_VAR_PRINTK_LEVEL_ID \
-+                                       || (x) == GTP_VAR_PRINTK_FORMAT_ID \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_SETV(x)           (((x) >= GTP_VAR_CURRENT_TASK_ID \
-+                                        && (x) <= GTP_VAR_CPU_ID) \
-+                                       || (x) == GTP_VAR_DUMP_STACK_ID \
-+                                       || (x) == GTP_VAR_CPU_NUMBER_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_TRACEV(x)         (((x) >= GTP_VAR_PRINTK_LEVEL_ID \
-+                                       && (x) <= GTP_VAR_PRINTK_FORMAT_ID) \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
 +#ifdef GTP_RB
 +#define GTP_VAR_AUTO_TRACEV(x)                ((x) == GTP_VAR_CPU_ID)
 +#endif
@@ -2632,6 +2747,8 @@
 +static uint64_t                       gtp_start_last_errno;
 +static int                    gtp_start_ignore_error;
 +
++static int                    gtp_pipe_trace;
++
 +#ifdef GTP_RB
 +#include "gtp_rb.c"
 +#endif
@@ -2752,8 +2869,8 @@
 +{
 +      char    *tmp;
 +
-+      if ((grs->real_size < grs->size + size)
-+          || (is_end && grs->real_size != grs->size + size)) {
++      if (unlikely((grs->real_size < grs->size + size)
++                   || (is_end && grs->real_size != grs->size + size))) {
 +              grs->real_size = grs->size + size;
 +              if (!is_end)
 +                      grs->real_size += 100;
@@ -2789,6 +2906,30 @@
 +
 +      return 0;
 +}
++
++static inline void
++gtp_realloc_reset(struct gtp_realloc_s *grs)
++{
++      grs->size = 0;
++}
++
++static inline int
++gtp_realloc_is_alloced(struct gtp_realloc_s *grs)
++{
++      return (grs->buf != NULL);
++}
++
++static inline int
++gtp_realloc_is_empty(struct gtp_realloc_s *grs)
++{
++      return (grs->size == 0);
++}
++
++static inline void
++gtp_realloc_sub_size(struct gtp_realloc_s *grs, size_t size)
++{
++      grs->size -= size;
++}
 +
 +#ifdef CONFIG_X86
 +static ULONGEST
@@ -3666,8 +3807,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_disable(ppl->event);
-+
++#else
++                      perf_event_disable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -3681,7 +3825,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_enable(ppl->event);
++#else
++                      perf_event_enable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -4287,6 +4435,12 @@
 +              else
 +                      return (uint64_t)(CORE_ADDR)get_current();
 +              break;
++      case GTP_VAR_CURRENT_TASK_PID_ID:
++              if (gts->ri)
++                      return (uint64_t)(CORE_ADDR)gts->ri->task->pid;
++              else
++                      return (uint64_t)(CORE_ADDR)get_current()->pid;
++              break;
 +      case GTP_VAR_CURRENT_THREAD_INFO_ID:
 +              return (uint64_t)(CORE_ADDR)current_thread_info();
 +              break;
@@ -4474,7 +4628,8 @@
 +                              gtp_action_x_setv_pe;                   \
 +                              /* Not check the other special          \
 +                                 trace state variables.               \
-+                                 Checked in gtp_check_x.  */          \
++                                 Because set in tve->val doesn't   \
++                                 affect anything.  */                 \
 +                              tve->val = (uint64_t)top;            \
 +                      }                                               \
 +                      break;                                          \
@@ -4569,7 +4724,7 @@
 +      char            *pbuf = __get_cpu_var(gtp_printf);
 +      ULONGEST        *stack = __get_cpu_var(action_x_stack);
 +
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_lock(&gtp_var_lock);
 +
 +      if (ae->type == 'X') {
@@ -5177,24 +5332,18 @@
 +                      case 0x2c:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_GETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_getv;
 +                              break;
 +                      /* setv */
 +                      case 0x2d:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_SETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_setv;
 +                              break;
 +                      /* tracev */
 +                      case 0x2e:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_TRACEV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_tracev;
 +                              break;
 +                      /* printf */
@@ -5203,9 +5352,8 @@
 +
 +                                      if (arg) {
 +                                              void    *argv = (void *)
-+                                                              (unsigned long)
-+                                                              top;
-+
++                                                               (unsigned long)
++                                                               top;
 +                                              /* pop */
 +                                              if (sp)
 +                                                      top = stack[--sp];
@@ -5215,7 +5363,7 @@
 +                                              gtp_action_x_printf;
 +                                      } else
 +                                              snprintf(pbuf, psize,
-+                                                      (char *)(ebuf + pc));
++                                                       (char *)(ebuf + pc));
 +                                      psize -= strlen(pbuf);
 +                                      pbuf += strlen(pbuf);
 +
@@ -5223,8 +5371,7 @@
 +                              }
 +                              break;
 +                      }
-+
-+                      if (sp > STACK_MAX - 5) {
++                      if (unlikely(sp > STACK_MAX - 5)) {
 +                              printk(KERN_WARNING "gtp_action_x: stack "
 +                                                  "overflow.\n");
 +                              gts->tpe->reason
@@ -5241,14 +5388,14 @@
 +                          "action X get error in pc %u.\n",
 +              (int)gts->tpe->num, (void *)(CORE_ADDR)gts->tpe->addr, pc);
 +out:
-+      if (psize != GTP_PRINTF_MAX) {
++      if (unlikely(psize != GTP_PRINTF_MAX)) {
 +              unsigned long   flags;
 +
 +              local_irq_save(flags);
 +              printk("%s", pbuf - (GTP_PRINTF_MAX - psize));
 +              local_irq_restore(flags);
 +      }
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_unlock(&gtp_var_lock);
 +      return ret;
 +}
@@ -5284,15 +5431,15 @@
 +      if (gts->tpe->kpreg == 0)
 +              return;
 +
-+      if (gts->tpe->no_self_trace) {
-+              if (get_current()->pid == gtp_gtp_pid
-+                  || get_current()->pid == gtp_gtpframe_pid)
-+                      return;
-+
 +#if defined(GTP_FTRACE_RING_BUFFER) || defined(GTP_RB)
-+              if (get_current()->pid == gtp_gtpframe_pipe_pid)
-+                      return;
++      if (!gtp_pipe_trace && get_current()->pid == gtp_gtpframe_pipe_pid)
++              return;
 +#endif
++
++      if (gts->tpe->no_self_trace
++          && (get_current()->pid == gtp_gtp_pid
++              || get_current()->pid == gtp_gtpframe_pid)) {
++                      return;
 +      }
 +
 +      if (gts->tpe->have_printk) {
@@ -6461,13 +6608,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_GETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "get.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 1)) {
@@ -6510,13 +6650,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_SETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "set.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (arg == GTP_VAR_PRINTK_LEVEL_ID)
 +                                      tpe->have_printk = 1;
@@ -6547,13 +6680,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_TRACEV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "trace.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 4)) {
@@ -6981,7 +7107,7 @@
 +                      continue;
 +
 +              /* Get event.  */
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,0,0))
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
 +              tve->pts->event =
 +                      perf_event_create_kernel_counter(&(tve->pts->attr),
 +                                                       tve->pts->cpu,
@@ -7819,7 +7945,7 @@
 +              else
 +                      gtp_frame_head_find_num(old_num);
 +#endif
-+              strcpy(gtp_rw_bufp, "F-1");
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F-1");
 +              gtp_rw_bufp += 3;
 +              gtp_rw_size += 3;
 +      } else {
@@ -7843,8 +7969,9 @@
 +              tmp = ring_buffer_event_data(rbe);
 +              gtp_frame_current_tpe = *(ULONGEST *)(tmp + FID_SIZE);
 +#endif
-+              sprintf(gtp_rw_bufp, "F%xT%x", gtp_frame_current_num,
-+                      (unsigned int) gtp_frame_current_tpe);
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F%xT%x",
++                       gtp_frame_current_num,
++                       (unsigned int) gtp_frame_current_tpe);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +      }
@@ -7908,6 +8035,8 @@
 +                      var->val = val;
 +              if (num == GTP_VAR_IGNORE_ERROR_ID)
 +                      gtp_start_ignore_error = (int)val;
++              else if (num == GTP_VAR_PIPE_TRACE_ID)
++                      gtp_pipe_trace = (int)val;
 +
 +              return 0;
 +      }
@@ -8189,7 +8318,7 @@
 +}
 +
 +static int
-+gtp_get_status(struct gtp_entry *tpe, char *buf)
++gtp_get_status(struct gtp_entry *tpe, char *buf, int bufmax)
 +{
 +      int                     size = 0;
 +      int                     tfnum = 0;
@@ -8201,39 +8330,41 @@
 +#if defined(GTP_FRAME_SIMPLE) || defined(GTP_FTRACE_RING_BUFFER)
 +      if (!gtp_frame) {
 +#endif
-+              sprintf(buf, "tnotrun:0;");
++              snprintf(buf, bufmax, "tnotrun:0;");
 +              buf += 10;
 +              size += 10;
++              bufmax -= 10;
 +      } else if (!tpe || (tpe && tpe->reason == gtp_stop_normal)) {
-+              sprintf(buf, "tstop:0;");
++              snprintf(buf, bufmax, "tstop:0;");
 +              buf += 8;
 +              size += 8;
++              bufmax -= 8;
 +      } else {
 +              char    outtmp[100];
 +
 +              switch (tpe->reason) {
 +              case gtp_stop_frame_full:
-+                      sprintf(buf, "tfull:%lx;",
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "tfull:%lx;",
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_efault:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("read memory false", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("read memory false", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_access_wrong_reg:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("access wrong register", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("access wrong register", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_code_error:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("agent expression code error",
-+                                         outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("agent expression code error",
++                                          outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_stack_overflow:
-+                      sprintf(buf, "terror:%s:%lx;",
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
 +                              string2hex("agent expression stack overflow",
 +                                         outtmp),
 +                              (unsigned long)tpe->num);
@@ -8244,6 +8375,7 @@
 +              }
 +
 +              size += strlen(buf);
++              bufmax -= strlen(buf);
 +              buf += strlen(buf);
 +      }
 +
@@ -8325,28 +8457,33 @@
 +#endif
 +      }
 +
-+      sprintf(buf, "tframes:%x;", tfnum);
++      snprintf(buf, bufmax, "tframes:%x;", tfnum);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "tcreated:%x;", atomic_read(&gtp_frame_create));
++      snprintf(buf, bufmax, "tcreated:%x;", atomic_read(&gtp_frame_create));
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
-+      sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE);
++      snprintf(buf, bufmax, "tsize:%x;", GTP_FRAME_SIZE);
 +#endif
 +#ifdef GTP_FTRACE_RING_BUFFER
 +      if (gtp_frame)
-+              sprintf(buf, "tsize:%lx;", ring_buffer_size(gtp_frame));
++              snprintf(buf, bufmax, "tsize:%lx;",
++                       ring_buffer_size(gtp_frame));
 +      else
-+              sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE * num_online_cpus());
++              snprintf(buf, bufmax, "tsize:%x;",
++                       GTP_FRAME_SIZE * num_online_cpus());
 +#endif
 +#ifdef GTP_RB
-+      sprintf(buf, "tsize:%lx;",
-+              gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
++      snprintf(buf, bufmax, "tsize:%lx;",
++               gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
 +#endif
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
@@ -8387,16 +8524,19 @@
 +                        * num_online_cpus();
 +      }
 +#endif
-+      sprintf(buf, "tfree:%lx;", (unsigned long)tmpaddr);
++      snprintf(buf, bufmax, "tfree:%lx;", (unsigned long)tmpaddr);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "circular:%x;", gtp_circular);
++      snprintf(buf, bufmax, "circular:%x;", gtp_circular);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "disconn:%x", gtp_disconnected_tracing);
++      snprintf(buf, bufmax, "disconn:%x", gtp_disconnected_tracing);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +      return size;
@@ -8416,41 +8556,53 @@
 +      if (gtp_start && tpe)   /* Tpe is stop, stop all tpes.  */
 +              gtp_gdbrsp_qtstop();
 +
-+      sprintf(gtp_rw_bufp, "T%x;", gtp_start ? 1 : 0);
++      snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "T%x;", gtp_start ? 1 : 0);
 +      gtp_rw_bufp += 3;
 +      gtp_rw_size += 3;
 +
-+      tmp = gtp_get_status(tpe, gtp_rw_bufp);
++      tmp = gtp_get_status(tpe, gtp_rw_bufp, GTP_RW_BUFP_MAX);
 +      gtp_rw_bufp += tmp;
 +      gtp_rw_size += tmp;
 +
 +      return 1;
 +}
++
++#define GTP_REPORT_TRACEPOINT_MAX     (1 + 16 + 1 + 16 + 1 + 1 + 1 + \
++                                       20 + 1 + 16 + 1)
 +
 +static void
-+gtp_report_tracepoint(struct gtp_entry *gtp, char *buf)
++gtp_report_tracepoint(struct gtp_entry *gtp, char *buf, int bufmax)
 +{
-+      sprintf(buf, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
-+              gtp->step, (unsigned long)gtp->pass);
++      snprintf(buf, bufmax, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
++               gtp->step, (unsigned long)gtp->pass);
++}
++
++static int
++gtp_report_action_max(struct gtp_entry *gtp, struct action *action)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(action->src) + 1;
 +}
 +
 +static void
-+gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf)
++gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf,
++                int bufmax)
 +{
-+      sprintf(buf, "A%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              action->src);
++      snprintf(buf, bufmax, "A%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, action->src);
++}
++
++static int
++gtp_report_src_max(struct gtp_entry *gtp, struct gtpsrc *src)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(src->src) + 1;
 +}
 +
 +static void
-+gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf)
++gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf, int bufmax)
 +{
-+      sprintf(buf, "Z%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              src->src);
++      snprintf(buf, bufmax, "Z%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, src->src);
 +}
 +
 +static void
@@ -8474,15 +8626,18 @@
 +{
 +      if (gtp_list) {
 +              current_gtp = gtp_list;
-+              gtp_report_tracepoint(current_gtp, gtp_rw_bufp);
++              gtp_report_tracepoint(current_gtp, gtp_rw_bufp,
++                                    GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_action = current_gtp->action_list;
 +              gtp_current_action_check();
 +      } else {
-+              gtp_rw_bufp[0] = 'l';
-+              gtp_rw_size += 1;
-+              gtp_rw_bufp += 1;
++              if (GTP_RW_BUFP_MAX > 1) {
++                      gtp_rw_bufp[0] = 'l';
++                      gtp_rw_size += 1;
++                      gtp_rw_bufp += 1;
++              }
 +      }
 +
 +      return 1;
@@ -8493,7 +8648,7 @@
 +{
 +      if (current_gtp_action) {
 +              gtp_report_action(current_gtp, current_gtp_action,
-+                                gtp_rw_bufp);
++                                gtp_rw_bufp, GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_action = current_gtp_action->next;
@@ -8502,7 +8657,8 @@
 +      }
 +
 +      if (current_gtp_src) {
-+              gtp_report_src(current_gtp, current_gtp_src, gtp_rw_bufp);
++              gtp_report_src(current_gtp, current_gtp_src, gtp_rw_bufp,
++                             GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_src = current_gtp_src->next;
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/gtp_2.6.39.patch     Tue Jan 31 04:51:57 2012
+++ /trunk/gtp_2.6.39.patch     Sat Feb 25 02:36:54 2012
@@ -1,24 +1,25 @@
 ---
- Documentation/trace/gtp.txt            | 1517 +++++
- Documentation/trace/gtp_quickstart.txt |  250
- include/linux/perf_event.h             |    3
- kernel/perf_event.c                    |   16
- lib/Kconfig.debug                      |   10
- lib/Makefile                           |    2
- lib/gtp.c | 9031 +++++++++++++++++++++++++++++++++
- lib/gtp_rb.c                           |  474 +
- scripts/getgtprsp.pl                   |  102
- scripts/getmod.py                      |  132
- 10 files changed, 11535 insertions(+), 2 deletions(-)
+ Documentation/gtp/howto.txt      | 1519 ++++++
+ Documentation/gtp/quickstart.txt |  250 +
+ include/linux/perf_event.h       |    3
+ kernel/perf_event.c              |   16
+ lib/Kconfig.debug                |   10
+ lib/Makefile                     |    2
+ lib/gtp.c | 9210 +++++++++++++++++++++++++++++++++++++++
+ lib/gtp_rb.c                     |  495 ++
+ scripts/gtp/add-ons/pe.py        |  729 +++
+ scripts/gtp/getgtprsp.pl         |  137
+ scripts/gtp/getmod.py            |  132
+ 11 files changed, 12501 insertions(+), 2 deletions(-)

 --- /dev/null
-+++ b/Documentation/trace/gtp.txt
-@@ -0,0 +1,1517 @@
++++ b/Documentation/gtp/howto.txt
+@@ -0,0 +1,1519 @@
 +              Linux Kernel GDB tracepoint module (KGTP)
 +              =========================================
 +              By Hui Zhu <teawater@xxxxxxxxx>
 +              https://code.google.com/p/kgtp/wiki/HOWTO
-+              2011-12-16
++              2012-02-21
 +
 +Table of contents
 +-----------------
@@ -50,7 +51,7 @@
 +      How to use trace state variables
 +              Simple trace state variables
 +              Per_cpu trace state variables
-+              Special trace state variables $current_task,
++              Special trace state variables $current_task, $current_task_pid,
 +                  $current_thread_info, $cpu_id, $dump_stack, $printk_level,
 +                  $printk_format, $printk_tmp, $clock, $rdtsc, $hardirq_count,
 +                  $softirq_count and $irq_count
@@ -100,7 +101,7 @@
 +(See https://code.google.com/p/kgtp/wiki/HowToUseKGTPinAndroid).
 +It supports X86-32, X86-64, MIPS and ARM.
 +
-+For new user of KGTP, please go to see gtp_quickstart.txt.
++For new user of KGTP, please go to see quickstart.txt.
 +
 +
 +
@@ -651,9 +652,9 @@
 +of each CPU.
 +
 +
-+Special trace state variables $current_task, $current_thread_info, $cpu_id,
-+$dump_stack, $printk_level, $printk_format, $printk_tmp, $clock, $rdtsc,
-+$hardirq_count, $softirq_count and $irq_count
++Special trace state variables $current_task, $current_task_pid,
++$current_thread_info, $cpu_id, $dump_stack, $printk_level, $printk_format,
++$printk_tmp, $clock, $rdtsc, $hardirq_count, $softirq_count and $irq_count
+---------------------------------------------------------------------------
 +
 +KGTP special trace state variables $current_task, $current_thread_info,
@@ -662,6 +663,8 @@
 +or actions.
+Access $current_task in tracepoint condition and action will get that returns
 +of get_current().
++Access $current_task_pid in tracepoint condition and action will get that
++returns of get_current()->pid.
+Access $current_thread_info in tracepoint condition and action will get that
 +returns of current_thread_info().
 +Access $cpu_id in tracepoint condition and action will get that returns of
@@ -794,12 +797,12 @@
 +And the last error number will available in "$last_errno".
 +
 +---------------------------------
-+tvariable $ignore_error
++tvariable $ignore_error=1
 +---------------------------------
 +This command will open ignore.
 +
 +---------------------------------
-+delete tvariable $ignore_error
++tvariable $ignore_error=0
 +---------------------------------
 +This command will close ignore.
 +
@@ -1532,7 +1535,7 @@
 +This way is better to work with python to parse Kernel.
 +I will introduce them in example.
 --- /dev/null
-+++ b/Documentation/trace/gtp_quickstart.txt
++++ b/Documentation/gtp/quickstart.txt
 @@ -0,0 +1,250 @@
 +              Linux Kernel GDB tracepoint module (KGTP) quick start
 +              =====================================================
@@ -1674,7 +1677,7 @@
 +(gdb) tstop
 +(gdb) tfind
 +Found trace frame 0, tracepoint 1
-+#0 vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at /build/buildd/linux-2.6.35/fs/readdir.c:23
++#0  vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at readdir.c:23
 +23      {
 +
 +
@@ -1898,7 +1901,7 @@

 --- /dev/null
 +++ b/lib/gtp.c
-@@ -0,0 +1,9031 @@
+@@ -0,0 +1,9210 @@
 +/*
 + * Kernel GDB tracepoint module.
 + *
@@ -1921,7 +1924,7 @@
 + */
 +
 +/* If *10 means that this is not a release version.  */
-+#define GTP_VERSION                   (20120131)
++#define GTP_VERSION                   (20120224)
 +
 +#include <linux/version.h>
 +#ifndef RHEL_RELEASE_VERSION
@@ -2106,6 +2109,7 @@
 +#endif
 +
 +#define GTP_RW_MAX            16384
++#define GTP_RW_BUFP_MAX               (GTP_RW_MAX - 4 - gtp_rw_size)
 +
 +#define FID_TYPE              unsigned int
 +#define FID_SIZE              sizeof(FID_TYPE)
@@ -2332,7 +2336,9 @@
 +      GTP_VAR_HARDIRQ_COUNT_ID,
 +      GTP_VAR_SOFTIRQ_COUNT_ID,
 +      GTP_VAR_IRQ_COUNT_ID,
-+      GTP_VAR_SPECIAL_MAX = GTP_VAR_IRQ_COUNT_ID,
++      GTP_VAR_PIPE_TRACE_ID,
++      GTP_VAR_CURRENT_TASK_PID_ID,
++      GTP_VAR_SPECIAL_MAX = GTP_VAR_PIPE_TRACE_ID,
 +};
 +
 +#define PREV_VAR      NULL
@@ -2342,6 +2348,10 @@
 +      .num            = GTP_VAR_VERSION_ID,
 +      .src            = "0:1:6774705f76657273696f6e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_version)
@@ -2351,6 +2361,10 @@
 +      .num            = GTP_VAR_CPU_ID,
 +      .src            = "0:1:6370755f6964",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_id)
@@ -2360,15 +2374,36 @@
 +      .num            = GTP_VAR_CURRENT_TASK_ID,
 +      .src            = "0:1:63757272656e745f7461736b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_task)
 +
++static struct gtp_var         gtp_var_current_task_pid = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_CURRENT_TASK_PID_ID,
++      .src            = "0:1:63757272656e745f7461736b5f706964",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_current_task_pid)
++
 +static struct gtp_var         gtp_var_current_thread_info = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CURRENT_THREAD_INFO_ID,
 +      .src            = "0:1:63757272656e745f7468726561645f696e666f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_thread_info)
@@ -2378,6 +2413,10 @@
 +      .num            = GTP_VAR_CLOCK_ID,
 +      .src            = "0:1:636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_clock)
@@ -2387,6 +2426,10 @@
 +      .num            = GTP_VAR_COOKED_CLOCK_ID,
 +      .src            = "0:1:636f6f6b65645f636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_clock)
@@ -2397,6 +2440,10 @@
 +      .num            = GTP_VAR_RDTSC_ID,
 +      .src            = "0:1:7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_rdtsc)
@@ -2405,6 +2452,10 @@
 +      .num            = GTP_VAR_COOKED_RDTSC_ID,
 +      .src            = "0:1:636f6f6b65645f7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_rdtsc)
@@ -2416,6 +2467,10 @@
 +      .num            = GTP_VAR_GTP_RB_DISCARD_PAGE_NUMBER,
 +      .src            = "0:1:646973636172645f706167655f6e756d",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_gtp_rb_discard_page_number)
@@ -2426,6 +2481,10 @@
 +      .num            = GTP_VAR_PRINTK_TMP_ID,
 +      .src            = "0:1:7072696e746b5f746d70",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_tmp)
@@ -2435,6 +2494,10 @@
 +      .num            = GTP_VAR_PRINTK_LEVEL_ID,
 +      .src            = "8:1:7072696e746b5f6c6576656c",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_level)
@@ -2444,6 +2507,10 @@
 +      .num            = GTP_VAR_PRINTK_FORMAT_ID,
 +      .src            = "0:1:7072696e746b5f666f726d6174",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_format)
@@ -2453,6 +2520,10 @@
 +      .num            = GTP_VAR_DUMP_STACK_ID,
 +      .src            = "0:1:64756d705f737461636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_dump_stack)
@@ -2462,15 +2533,36 @@
 +      .num            = GTP_VAR_NO_SELF_TRACE_ID,
 +      .src            = "0:1:6e6f5f73656c665f7472616365",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_no_self_trace)
 +
++static struct gtp_var         gtp_var_pipe_trace = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_PIPE_TRACE_ID,
++      .src            = "0:1:706970655f7472616365",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_pipe_trace)
++
 +static struct gtp_var         gtp_var_cpu_number = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CPU_NUMBER_ID,
 +      .src            = "0:1:6370755f6e756d626572",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_number)
@@ -2480,6 +2572,10 @@
 +      .num            = GTP_VAR_PC_PE_EN_ID,
 +      .src            = "0:1:70635f70655f656e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_pc_pe_en)
@@ -2489,6 +2585,10 @@
 +      .num            = GTP_VAR_KRET_ID,
 +      .src            = "0:1:6b726574",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_kret)
@@ -2498,6 +2598,10 @@
 +      .num            = GTP_VAR_XTIME_SEC_ID,
 +      .src            = "0:1:7874696d655f736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_sec)
@@ -2507,6 +2611,10 @@
 +      .num            = GTP_VAR_XTIME_NSEC_ID,
 +      .src            = "0:1:7874696d655f6e736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_nsec)
@@ -2516,6 +2624,10 @@
 +      .num            = GTP_VAR_IGNORE_ERROR_ID,
 +      .src            = "0:1:69676e6f72655f6572726f72",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_ignore_error)
@@ -2525,6 +2637,10 @@
 +      .num            = GTP_VAR_LAST_ERRNO_ID,
 +      .src            = "0:1:6c6173745f6572726e6f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_last_errno)
@@ -2534,6 +2650,10 @@
 +      .num            = GTP_VAR_HARDIRQ_COUNT_ID,
 +      .src            = "0:1:686172646972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_hardirq_count)
@@ -2543,6 +2663,10 @@
 +      .num            = GTP_VAR_SOFTIRQ_COUNT_ID,
 +      .src            = "0:1:736f66746972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_softirq_count)
@@ -2552,6 +2676,10 @@
 +      .num            = GTP_VAR_IRQ_COUNT_ID,
 +      .src            = "0:1:6972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +
@@ -2559,19 +2687,6 @@
 +
 +#define GTP_VAR_IS_SPECIAL(x)         ((x) >= GTP_VAR_SPECIAL_MIN \
 +                                       && (x) <= GTP_VAR_SPECIAL_MAX)
-+#define GTP_VAR_NOT_GETV(x)           ((x) == GTP_VAR_PRINTK_LEVEL_ID \
-+                                       || (x) == GTP_VAR_PRINTK_FORMAT_ID \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_SETV(x)           (((x) >= GTP_VAR_CURRENT_TASK_ID \
-+                                        && (x) <= GTP_VAR_CPU_ID) \
-+                                       || (x) == GTP_VAR_DUMP_STACK_ID \
-+                                       || (x) == GTP_VAR_CPU_NUMBER_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_TRACEV(x)         (((x) >= GTP_VAR_PRINTK_LEVEL_ID \
-+                                       && (x) <= GTP_VAR_PRINTK_FORMAT_ID) \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
 +#ifdef GTP_RB
 +#define GTP_VAR_AUTO_TRACEV(x)                ((x) == GTP_VAR_CPU_ID)
 +#endif
@@ -2625,6 +2740,8 @@
 +static uint64_t                       gtp_start_last_errno;
 +static int                    gtp_start_ignore_error;
 +
++static int                    gtp_pipe_trace;
++
 +#ifdef GTP_RB
 +#include "gtp_rb.c"
 +#endif
@@ -2745,8 +2862,8 @@
 +{
 +      char    *tmp;
 +
-+      if ((grs->real_size < grs->size + size)
-+          || (is_end && grs->real_size != grs->size + size)) {
++      if (unlikely((grs->real_size < grs->size + size)
++                   || (is_end && grs->real_size != grs->size + size))) {
 +              grs->real_size = grs->size + size;
 +              if (!is_end)
 +                      grs->real_size += 100;
@@ -2782,6 +2899,30 @@
 +
 +      return 0;
 +}
++
++static inline void
++gtp_realloc_reset(struct gtp_realloc_s *grs)
++{
++      grs->size = 0;
++}
++
++static inline int
++gtp_realloc_is_alloced(struct gtp_realloc_s *grs)
++{
++      return (grs->buf != NULL);
++}
++
++static inline int
++gtp_realloc_is_empty(struct gtp_realloc_s *grs)
++{
++      return (grs->size == 0);
++}
++
++static inline void
++gtp_realloc_sub_size(struct gtp_realloc_s *grs, size_t size)
++{
++      grs->size -= size;
++}
 +
 +#ifdef CONFIG_X86
 +static ULONGEST
@@ -3659,8 +3800,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_disable(ppl->event);
-+
++#else
++                      perf_event_disable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -3674,7 +3818,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_enable(ppl->event);
++#else
++                      perf_event_enable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -4280,6 +4428,12 @@
 +              else
 +                      return (uint64_t)(CORE_ADDR)get_current();
 +              break;
++      case GTP_VAR_CURRENT_TASK_PID_ID:
++              if (gts->ri)
++                      return (uint64_t)(CORE_ADDR)gts->ri->task->pid;
++              else
++                      return (uint64_t)(CORE_ADDR)get_current()->pid;
++              break;
 +      case GTP_VAR_CURRENT_THREAD_INFO_ID:
 +              return (uint64_t)(CORE_ADDR)current_thread_info();
 +              break;
@@ -4467,7 +4621,8 @@
 +                              gtp_action_x_setv_pe;                   \
 +                              /* Not check the other special          \
 +                                 trace state variables.               \
-+                                 Checked in gtp_check_x.  */          \
++                                 Because set in tve->val doesn't   \
++                                 affect anything.  */                 \
 +                              tve->val = (uint64_t)top;            \
 +                      }                                               \
 +                      break;                                          \
@@ -4562,7 +4717,7 @@
 +      char            *pbuf = __get_cpu_var(gtp_printf);
 +      ULONGEST        *stack = __get_cpu_var(action_x_stack);
 +
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_lock(&gtp_var_lock);
 +
 +      if (ae->type == 'X') {
@@ -5170,24 +5325,18 @@
 +                      case 0x2c:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_GETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_getv;
 +                              break;
 +                      /* setv */
 +                      case 0x2d:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_SETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_setv;
 +                              break;
 +                      /* tracev */
 +                      case 0x2e:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_TRACEV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_tracev;
 +                              break;
 +                      /* printf */
@@ -5196,9 +5345,8 @@
 +
 +                                      if (arg) {
 +                                              void    *argv = (void *)
-+                                                              (unsigned long)
-+                                                              top;
-+
++                                                               (unsigned long)
++                                                               top;
 +                                              /* pop */
 +                                              if (sp)
 +                                                      top = stack[--sp];
@@ -5208,7 +5356,7 @@
 +                                              gtp_action_x_printf;
 +                                      } else
 +                                              snprintf(pbuf, psize,
-+                                                      (char *)(ebuf + pc));
++                                                       (char *)(ebuf + pc));
 +                                      psize -= strlen(pbuf);
 +                                      pbuf += strlen(pbuf);
 +
@@ -5216,8 +5364,7 @@
 +                              }
 +                              break;
 +                      }
-+
-+                      if (sp > STACK_MAX - 5) {
++                      if (unlikely(sp > STACK_MAX - 5)) {
 +                              printk(KERN_WARNING "gtp_action_x: stack "
 +                                                  "overflow.\n");
 +                              gts->tpe->reason
@@ -5234,14 +5381,14 @@
 +                          "action X get error in pc %u.\n",
 +              (int)gts->tpe->num, (void *)(CORE_ADDR)gts->tpe->addr, pc);
 +out:
-+      if (psize != GTP_PRINTF_MAX) {
++      if (unlikely(psize != GTP_PRINTF_MAX)) {
 +              unsigned long   flags;
 +
 +              local_irq_save(flags);
 +              printk("%s", pbuf - (GTP_PRINTF_MAX - psize));
 +              local_irq_restore(flags);
 +      }
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_unlock(&gtp_var_lock);
 +      return ret;
 +}
@@ -5277,15 +5424,15 @@
 +      if (gts->tpe->kpreg == 0)
 +              return;
 +
-+      if (gts->tpe->no_self_trace) {
-+              if (get_current()->pid == gtp_gtp_pid
-+                  || get_current()->pid == gtp_gtpframe_pid)
-+                      return;
-+
 +#if defined(GTP_FTRACE_RING_BUFFER) || defined(GTP_RB)
-+              if (get_current()->pid == gtp_gtpframe_pipe_pid)
-+                      return;
++      if (!gtp_pipe_trace && get_current()->pid == gtp_gtpframe_pipe_pid)
++              return;
 +#endif
++
++      if (gts->tpe->no_self_trace
++          && (get_current()->pid == gtp_gtp_pid
++              || get_current()->pid == gtp_gtpframe_pid)) {
++                      return;
 +      }
 +
 +      if (gts->tpe->have_printk) {
@@ -6454,13 +6601,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_GETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "get.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 1)) {
@@ -6503,13 +6643,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_SETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "set.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (arg == GTP_VAR_PRINTK_LEVEL_ID)
 +                                      tpe->have_printk = 1;
@@ -6540,13 +6673,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_TRACEV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "trace.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 4)) {
@@ -6974,7 +7100,7 @@
 +                      continue;
 +
 +              /* Get event.  */
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,0,0))
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
 +              tve->pts->event =
 +                      perf_event_create_kernel_counter(&(tve->pts->attr),
 +                                                       tve->pts->cpu,
@@ -7812,7 +7938,7 @@
 +              else
 +                      gtp_frame_head_find_num(old_num);
 +#endif
-+              strcpy(gtp_rw_bufp, "F-1");
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F-1");
 +              gtp_rw_bufp += 3;
 +              gtp_rw_size += 3;
 +      } else {
@@ -7836,8 +7962,9 @@
 +              tmp = ring_buffer_event_data(rbe);
 +              gtp_frame_current_tpe = *(ULONGEST *)(tmp + FID_SIZE);
 +#endif
-+              sprintf(gtp_rw_bufp, "F%xT%x", gtp_frame_current_num,
-+                      (unsigned int) gtp_frame_current_tpe);
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F%xT%x",
++                       gtp_frame_current_num,
++                       (unsigned int) gtp_frame_current_tpe);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +      }
@@ -7901,6 +8028,8 @@
 +                      var->val = val;
 +              if (num == GTP_VAR_IGNORE_ERROR_ID)
 +                      gtp_start_ignore_error = (int)val;
++              else if (num == GTP_VAR_PIPE_TRACE_ID)
++                      gtp_pipe_trace = (int)val;
 +
 +              return 0;
 +      }
@@ -8182,7 +8311,7 @@
 +}
 +
 +static int
-+gtp_get_status(struct gtp_entry *tpe, char *buf)
++gtp_get_status(struct gtp_entry *tpe, char *buf, int bufmax)
 +{
 +      int                     size = 0;
 +      int                     tfnum = 0;
@@ -8194,39 +8323,41 @@
 +#if defined(GTP_FRAME_SIMPLE) || defined(GTP_FTRACE_RING_BUFFER)
 +      if (!gtp_frame) {
 +#endif
-+              sprintf(buf, "tnotrun:0;");
++              snprintf(buf, bufmax, "tnotrun:0;");
 +              buf += 10;
 +              size += 10;
++              bufmax -= 10;
 +      } else if (!tpe || (tpe && tpe->reason == gtp_stop_normal)) {
-+              sprintf(buf, "tstop:0;");
++              snprintf(buf, bufmax, "tstop:0;");
 +              buf += 8;
 +              size += 8;
++              bufmax -= 8;
 +      } else {
 +              char    outtmp[100];
 +
 +              switch (tpe->reason) {
 +              case gtp_stop_frame_full:
-+                      sprintf(buf, "tfull:%lx;",
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "tfull:%lx;",
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_efault:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("read memory false", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("read memory false", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_access_wrong_reg:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("access wrong register", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("access wrong register", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_code_error:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("agent expression code error",
-+                                         outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("agent expression code error",
++                                          outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_stack_overflow:
-+                      sprintf(buf, "terror:%s:%lx;",
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
 +                              string2hex("agent expression stack overflow",
 +                                         outtmp),
 +                              (unsigned long)tpe->num);
@@ -8237,6 +8368,7 @@
 +              }
 +
 +              size += strlen(buf);
++              bufmax -= strlen(buf);
 +              buf += strlen(buf);
 +      }
 +
@@ -8318,28 +8450,33 @@
 +#endif
 +      }
 +
-+      sprintf(buf, "tframes:%x;", tfnum);
++      snprintf(buf, bufmax, "tframes:%x;", tfnum);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "tcreated:%x;", atomic_read(&gtp_frame_create));
++      snprintf(buf, bufmax, "tcreated:%x;", atomic_read(&gtp_frame_create));
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
-+      sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE);
++      snprintf(buf, bufmax, "tsize:%x;", GTP_FRAME_SIZE);
 +#endif
 +#ifdef GTP_FTRACE_RING_BUFFER
 +      if (gtp_frame)
-+              sprintf(buf, "tsize:%lx;", ring_buffer_size(gtp_frame));
++              snprintf(buf, bufmax, "tsize:%lx;",
++                       ring_buffer_size(gtp_frame));
 +      else
-+              sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE * num_online_cpus());
++              snprintf(buf, bufmax, "tsize:%x;",
++                       GTP_FRAME_SIZE * num_online_cpus());
 +#endif
 +#ifdef GTP_RB
-+      sprintf(buf, "tsize:%lx;",
-+              gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
++      snprintf(buf, bufmax, "tsize:%lx;",
++               gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
 +#endif
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
@@ -8380,16 +8517,19 @@
 +                        * num_online_cpus();
 +      }
 +#endif
-+      sprintf(buf, "tfree:%lx;", (unsigned long)tmpaddr);
++      snprintf(buf, bufmax, "tfree:%lx;", (unsigned long)tmpaddr);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "circular:%x;", gtp_circular);
++      snprintf(buf, bufmax, "circular:%x;", gtp_circular);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "disconn:%x", gtp_disconnected_tracing);
++      snprintf(buf, bufmax, "disconn:%x", gtp_disconnected_tracing);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +      return size;
@@ -8409,41 +8549,53 @@
 +      if (gtp_start && tpe)   /* Tpe is stop, stop all tpes.  */
 +              gtp_gdbrsp_qtstop();
 +
-+      sprintf(gtp_rw_bufp, "T%x;", gtp_start ? 1 : 0);
++      snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "T%x;", gtp_start ? 1 : 0);
 +      gtp_rw_bufp += 3;
 +      gtp_rw_size += 3;
 +
-+      tmp = gtp_get_status(tpe, gtp_rw_bufp);
++      tmp = gtp_get_status(tpe, gtp_rw_bufp, GTP_RW_BUFP_MAX);
 +      gtp_rw_bufp += tmp;
 +      gtp_rw_size += tmp;
 +
 +      return 1;
 +}
++
++#define GTP_REPORT_TRACEPOINT_MAX     (1 + 16 + 1 + 16 + 1 + 1 + 1 + \
++                                       20 + 1 + 16 + 1)
 +
 +static void
-+gtp_report_tracepoint(struct gtp_entry *gtp, char *buf)
++gtp_report_tracepoint(struct gtp_entry *gtp, char *buf, int bufmax)
 +{
-+      sprintf(buf, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
-+              gtp->step, (unsigned long)gtp->pass);
++      snprintf(buf, bufmax, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
++               gtp->step, (unsigned long)gtp->pass);
++}
++
++static int
++gtp_report_action_max(struct gtp_entry *gtp, struct action *action)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(action->src) + 1;
 +}
 +
 +static void
-+gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf)
++gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf,
++                int bufmax)
 +{
-+      sprintf(buf, "A%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              action->src);
++      snprintf(buf, bufmax, "A%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, action->src);
++}
++
++static int
++gtp_report_src_max(struct gtp_entry *gtp, struct gtpsrc *src)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(src->src) + 1;
 +}
 +
 +static void
-+gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf)
++gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf, int bufmax)
 +{
-+      sprintf(buf, "Z%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              src->src);
++      snprintf(buf, bufmax, "Z%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, src->src);
 +}
 +
 +static void
@@ -8467,15 +8619,18 @@
 +{
 +      if (gtp_list) {
 +              current_gtp = gtp_list;
-+              gtp_report_tracepoint(current_gtp, gtp_rw_bufp);
++              gtp_report_tracepoint(current_gtp, gtp_rw_bufp,
++                                    GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_action = current_gtp->action_list;
 +              gtp_current_action_check();
 +      } else {
-+              gtp_rw_bufp[0] = 'l';
-+              gtp_rw_size += 1;
-+              gtp_rw_bufp += 1;
++              if (GTP_RW_BUFP_MAX > 1) {
++                      gtp_rw_bufp[0] = 'l';
++                      gtp_rw_size += 1;
++                      gtp_rw_bufp += 1;
++              }
 +      }
 +
 +      return 1;
@@ -8486,7 +8641,7 @@
 +{
 +      if (current_gtp_action) {
 +              gtp_report_action(current_gtp, current_gtp_action,
-+                                gtp_rw_bufp);
++                                gtp_rw_bufp, GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_action = current_gtp_action->next;
@@ -8495,7 +8650,8 @@
 +      }
 +
 +      if (current_gtp_src) {
-+              gtp_report_src(current_gtp, current_gtp_src, gtp_rw_bufp);
++              gtp_report_src(current_gtp, current_gtp_src, gtp_rw_bufp,
++                             GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_src = current_gtp_src->next;
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/gtp_3.0_to_upstream.patch    Tue Jan 31 04:51:57 2012
+++ /trunk/gtp_3.0_to_upstream.patch    Sat Feb 25 02:36:54 2012
@@ -1,24 +1,25 @@
 ---
- Documentation/trace/gtp.txt            | 1517 +++++
- Documentation/trace/gtp_quickstart.txt |  250
- include/linux/perf_event.h             |    3
- kernel/events/core.c                   |   26
- lib/Kconfig.debug                      |   10
- lib/Makefile                           |    2
- lib/gtp.c | 9031 +++++++++++++++++++++++++++++++++
- lib/gtp_rb.c                           |  474 +
- scripts/getgtprsp.pl                   |  102
- scripts/getmod.py                      |  132
- 10 files changed, 11545 insertions(+), 2 deletions(-)
+ Documentation/gtp/howto.txt      | 1519 ++++++
+ Documentation/gtp/quickstart.txt |  250 +
+ include/linux/perf_event.h       |    3
+ kernel/events/core.c             |   26
+ lib/Kconfig.debug                |   10
+ lib/Makefile                     |    2
+ lib/gtp.c | 9210 +++++++++++++++++++++++++++++++++++++++
+ lib/gtp_rb.c                     |  495 ++
+ scripts/gtp/add-ons/pe.py        |  729 +++
+ scripts/gtp/getgtprsp.pl         |  137
+ scripts/gtp/getmod.py            |  132
+ 11 files changed, 12511 insertions(+), 2 deletions(-)

 --- /dev/null
-+++ b/Documentation/trace/gtp.txt
-@@ -0,0 +1,1517 @@
++++ b/Documentation/gtp/howto.txt
+@@ -0,0 +1,1519 @@
 +              Linux Kernel GDB tracepoint module (KGTP)
 +              =========================================
 +              By Hui Zhu <teawater@xxxxxxxxx>
 +              https://code.google.com/p/kgtp/wiki/HOWTO
-+              2011-12-16
++              2012-02-21
 +
 +Table of contents
 +-----------------
@@ -50,7 +51,7 @@
 +      How to use trace state variables
 +              Simple trace state variables
 +              Per_cpu trace state variables
-+              Special trace state variables $current_task,
++              Special trace state variables $current_task, $current_task_pid,
 +                  $current_thread_info, $cpu_id, $dump_stack, $printk_level,
 +                  $printk_format, $printk_tmp, $clock, $rdtsc, $hardirq_count,
 +                  $softirq_count and $irq_count
@@ -100,7 +101,7 @@
 +(See https://code.google.com/p/kgtp/wiki/HowToUseKGTPinAndroid).
 +It supports X86-32, X86-64, MIPS and ARM.
 +
-+For new user of KGTP, please go to see gtp_quickstart.txt.
++For new user of KGTP, please go to see quickstart.txt.
 +
 +
 +
@@ -651,9 +652,9 @@
 +of each CPU.
 +
 +
-+Special trace state variables $current_task, $current_thread_info, $cpu_id,
-+$dump_stack, $printk_level, $printk_format, $printk_tmp, $clock, $rdtsc,
-+$hardirq_count, $softirq_count and $irq_count
++Special trace state variables $current_task, $current_task_pid,
++$current_thread_info, $cpu_id, $dump_stack, $printk_level, $printk_format,
++$printk_tmp, $clock, $rdtsc, $hardirq_count, $softirq_count and $irq_count
+---------------------------------------------------------------------------
 +
 +KGTP special trace state variables $current_task, $current_thread_info,
@@ -662,6 +663,8 @@
 +or actions.
+Access $current_task in tracepoint condition and action will get that returns
 +of get_current().
++Access $current_task_pid in tracepoint condition and action will get that
++returns of get_current()->pid.
+Access $current_thread_info in tracepoint condition and action will get that
 +returns of current_thread_info().
 +Access $cpu_id in tracepoint condition and action will get that returns of
@@ -794,12 +797,12 @@
 +And the last error number will available in "$last_errno".
 +
 +---------------------------------
-+tvariable $ignore_error
++tvariable $ignore_error=1
 +---------------------------------
 +This command will open ignore.
 +
 +---------------------------------
-+delete tvariable $ignore_error
++tvariable $ignore_error=0
 +---------------------------------
 +This command will close ignore.
 +
@@ -1532,7 +1535,7 @@
 +This way is better to work with python to parse Kernel.
 +I will introduce them in example.
 --- /dev/null
-+++ b/Documentation/trace/gtp_quickstart.txt
++++ b/Documentation/gtp/quickstart.txt
 @@ -0,0 +1,250 @@
 +              Linux Kernel GDB tracepoint module (KGTP) quick start
 +              =====================================================
@@ -1674,7 +1677,7 @@
 +(gdb) tstop
 +(gdb) tfind
 +Found trace frame 0, tracepoint 1
-+#0 vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at /build/buildd/linux-2.6.35/fs/readdir.c:23
++#0  vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at readdir.c:23
 +23      {
 +
 +
@@ -1786,7 +1789,7 @@
 +Please go to HOWTO to get more message about howto use KGTP.
 --- a/include/linux/perf_event.h
 +++ b/include/linux/perf_event.h
-@@ -1145,9 +1145,12 @@ extern void perf_output_copy(struct perf
+@@ -1146,9 +1146,12 @@ extern void perf_output_copy(struct perf
                             const void *buf, unsigned int len);
  extern int perf_swevent_get_recursion_context(void);
  extern void perf_swevent_put_recursion_context(int rctx);
@@ -1868,7 +1871,7 @@

  /*
   * Test whether two contexts are equivalent, i.e. whether they
-@@ -3035,6 +3049,14 @@ static void perf_event_reset(struct perf
+@@ -3065,6 +3079,14 @@ static void perf_event_reset(struct perf
        perf_event_update_userpage(event);
  }

@@ -1904,9 +1907,9 @@
  source "lib/Kconfig.kgdb"
 --- a/lib/Makefile
 +++ b/lib/Makefile
-@@ -121,6 +121,8 @@ obj-$(CONFIG_DQL) += dynamic_queue_limit
- obj-$(CONFIG_MPILIB) += mpi/
- obj-$(CONFIG_SIGNATURE) += digsig.o
+@@ -123,6 +123,8 @@ obj-$(CONFIG_SIGNATURE) += digsig.o
+
+ obj-$(CONFIG_CLZ_TAB) += clz_tab.o

 +obj-$(CONFIG_GTP) += gtp.o
 +
@@ -1915,7 +1918,7 @@

 --- /dev/null
 +++ b/lib/gtp.c
-@@ -0,0 +1,9031 @@
+@@ -0,0 +1,9210 @@
 +/*
 + * Kernel GDB tracepoint module.
 + *
@@ -1938,7 +1941,7 @@
 + */
 +
 +/* If *10 means that this is not a release version.  */
-+#define GTP_VERSION                   (20120131)
++#define GTP_VERSION                   (20120224)
 +
 +#include <linux/version.h>
 +#ifndef RHEL_RELEASE_VERSION
@@ -2123,6 +2126,7 @@
 +#endif
 +
 +#define GTP_RW_MAX            16384
++#define GTP_RW_BUFP_MAX               (GTP_RW_MAX - 4 - gtp_rw_size)
 +
 +#define FID_TYPE              unsigned int
 +#define FID_SIZE              sizeof(FID_TYPE)
@@ -2349,7 +2353,9 @@
 +      GTP_VAR_HARDIRQ_COUNT_ID,
 +      GTP_VAR_SOFTIRQ_COUNT_ID,
 +      GTP_VAR_IRQ_COUNT_ID,
-+      GTP_VAR_SPECIAL_MAX = GTP_VAR_IRQ_COUNT_ID,
++      GTP_VAR_PIPE_TRACE_ID,
++      GTP_VAR_CURRENT_TASK_PID_ID,
++      GTP_VAR_SPECIAL_MAX = GTP_VAR_PIPE_TRACE_ID,
 +};
 +
 +#define PREV_VAR      NULL
@@ -2359,6 +2365,10 @@
 +      .num            = GTP_VAR_VERSION_ID,
 +      .src            = "0:1:6774705f76657273696f6e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_version)
@@ -2368,6 +2378,10 @@
 +      .num            = GTP_VAR_CPU_ID,
 +      .src            = "0:1:6370755f6964",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_id)
@@ -2377,15 +2391,36 @@
 +      .num            = GTP_VAR_CURRENT_TASK_ID,
 +      .src            = "0:1:63757272656e745f7461736b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_task)
 +
++static struct gtp_var         gtp_var_current_task_pid = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_CURRENT_TASK_PID_ID,
++      .src            = "0:1:63757272656e745f7461736b5f706964",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_current_task_pid)
++
 +static struct gtp_var         gtp_var_current_thread_info = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CURRENT_THREAD_INFO_ID,
 +      .src            = "0:1:63757272656e745f7468726561645f696e666f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_thread_info)
@@ -2395,6 +2430,10 @@
 +      .num            = GTP_VAR_CLOCK_ID,
 +      .src            = "0:1:636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_clock)
@@ -2404,6 +2443,10 @@
 +      .num            = GTP_VAR_COOKED_CLOCK_ID,
 +      .src            = "0:1:636f6f6b65645f636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_clock)
@@ -2414,6 +2457,10 @@
 +      .num            = GTP_VAR_RDTSC_ID,
 +      .src            = "0:1:7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_rdtsc)
@@ -2422,6 +2469,10 @@
 +      .num            = GTP_VAR_COOKED_RDTSC_ID,
 +      .src            = "0:1:636f6f6b65645f7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_rdtsc)
@@ -2433,6 +2484,10 @@
 +      .num            = GTP_VAR_GTP_RB_DISCARD_PAGE_NUMBER,
 +      .src            = "0:1:646973636172645f706167655f6e756d",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_gtp_rb_discard_page_number)
@@ -2443,6 +2498,10 @@
 +      .num            = GTP_VAR_PRINTK_TMP_ID,
 +      .src            = "0:1:7072696e746b5f746d70",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_tmp)
@@ -2452,6 +2511,10 @@
 +      .num            = GTP_VAR_PRINTK_LEVEL_ID,
 +      .src            = "8:1:7072696e746b5f6c6576656c",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_level)
@@ -2461,6 +2524,10 @@
 +      .num            = GTP_VAR_PRINTK_FORMAT_ID,
 +      .src            = "0:1:7072696e746b5f666f726d6174",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_format)
@@ -2470,6 +2537,10 @@
 +      .num            = GTP_VAR_DUMP_STACK_ID,
 +      .src            = "0:1:64756d705f737461636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_dump_stack)
@@ -2479,15 +2550,36 @@
 +      .num            = GTP_VAR_NO_SELF_TRACE_ID,
 +      .src            = "0:1:6e6f5f73656c665f7472616365",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_no_self_trace)
 +
++static struct gtp_var         gtp_var_pipe_trace = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_PIPE_TRACE_ID,
++      .src            = "0:1:706970655f7472616365",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_pipe_trace)
++
 +static struct gtp_var         gtp_var_cpu_number = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CPU_NUMBER_ID,
 +      .src            = "0:1:6370755f6e756d626572",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_number)
@@ -2497,6 +2589,10 @@
 +      .num            = GTP_VAR_PC_PE_EN_ID,
 +      .src            = "0:1:70635f70655f656e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_pc_pe_en)
@@ -2506,6 +2602,10 @@
 +      .num            = GTP_VAR_KRET_ID,
 +      .src            = "0:1:6b726574",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_kret)
@@ -2515,6 +2615,10 @@
 +      .num            = GTP_VAR_XTIME_SEC_ID,
 +      .src            = "0:1:7874696d655f736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_sec)
@@ -2524,6 +2628,10 @@
 +      .num            = GTP_VAR_XTIME_NSEC_ID,
 +      .src            = "0:1:7874696d655f6e736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_nsec)
@@ -2533,6 +2641,10 @@
 +      .num            = GTP_VAR_IGNORE_ERROR_ID,
 +      .src            = "0:1:69676e6f72655f6572726f72",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_ignore_error)
@@ -2542,6 +2654,10 @@
 +      .num            = GTP_VAR_LAST_ERRNO_ID,
 +      .src            = "0:1:6c6173745f6572726e6f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_last_errno)
@@ -2551,6 +2667,10 @@
 +      .num            = GTP_VAR_HARDIRQ_COUNT_ID,
 +      .src            = "0:1:686172646972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_hardirq_count)
@@ -2560,6 +2680,10 @@
 +      .num            = GTP_VAR_SOFTIRQ_COUNT_ID,
 +      .src            = "0:1:736f66746972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_softirq_count)
@@ -2569,6 +2693,10 @@
 +      .num            = GTP_VAR_IRQ_COUNT_ID,
 +      .src            = "0:1:6972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +
@@ -2576,19 +2704,6 @@
 +
 +#define GTP_VAR_IS_SPECIAL(x)         ((x) >= GTP_VAR_SPECIAL_MIN \
 +                                       && (x) <= GTP_VAR_SPECIAL_MAX)
-+#define GTP_VAR_NOT_GETV(x)           ((x) == GTP_VAR_PRINTK_LEVEL_ID \
-+                                       || (x) == GTP_VAR_PRINTK_FORMAT_ID \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_SETV(x)           (((x) >= GTP_VAR_CURRENT_TASK_ID \
-+                                        && (x) <= GTP_VAR_CPU_ID) \
-+                                       || (x) == GTP_VAR_DUMP_STACK_ID \
-+                                       || (x) == GTP_VAR_CPU_NUMBER_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_TRACEV(x)         (((x) >= GTP_VAR_PRINTK_LEVEL_ID \
-+                                       && (x) <= GTP_VAR_PRINTK_FORMAT_ID) \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
 +#ifdef GTP_RB
 +#define GTP_VAR_AUTO_TRACEV(x)                ((x) == GTP_VAR_CPU_ID)
 +#endif
@@ -2642,6 +2757,8 @@
 +static uint64_t                       gtp_start_last_errno;
 +static int                    gtp_start_ignore_error;
 +
++static int                    gtp_pipe_trace;
++
 +#ifdef GTP_RB
 +#include "gtp_rb.c"
 +#endif
@@ -2762,8 +2879,8 @@
 +{
 +      char    *tmp;
 +
-+      if ((grs->real_size < grs->size + size)
-+          || (is_end && grs->real_size != grs->size + size)) {
++      if (unlikely((grs->real_size < grs->size + size)
++                   || (is_end && grs->real_size != grs->size + size))) {
 +              grs->real_size = grs->size + size;
 +              if (!is_end)
 +                      grs->real_size += 100;
@@ -2799,6 +2916,30 @@
 +
 +      return 0;
 +}
++
++static inline void
++gtp_realloc_reset(struct gtp_realloc_s *grs)
++{
++      grs->size = 0;
++}
++
++static inline int
++gtp_realloc_is_alloced(struct gtp_realloc_s *grs)
++{
++      return (grs->buf != NULL);
++}
++
++static inline int
++gtp_realloc_is_empty(struct gtp_realloc_s *grs)
++{
++      return (grs->size == 0);
++}
++
++static inline void
++gtp_realloc_sub_size(struct gtp_realloc_s *grs, size_t size)
++{
++      grs->size -= size;
++}
 +
 +#ifdef CONFIG_X86
 +static ULONGEST
@@ -3676,8 +3817,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_disable(ppl->event);
-+
++#else
++                      perf_event_disable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -3691,7 +3835,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_enable(ppl->event);
++#else
++                      perf_event_enable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -4297,6 +4445,12 @@
 +              else
 +                      return (uint64_t)(CORE_ADDR)get_current();
 +              break;
++      case GTP_VAR_CURRENT_TASK_PID_ID:
++              if (gts->ri)
++                      return (uint64_t)(CORE_ADDR)gts->ri->task->pid;
++              else
++                      return (uint64_t)(CORE_ADDR)get_current()->pid;
++              break;
 +      case GTP_VAR_CURRENT_THREAD_INFO_ID:
 +              return (uint64_t)(CORE_ADDR)current_thread_info();
 +              break;
@@ -4484,7 +4638,8 @@
 +                              gtp_action_x_setv_pe;                   \
 +                              /* Not check the other special          \
 +                                 trace state variables.               \
-+                                 Checked in gtp_check_x.  */          \
++                                 Because set in tve->val doesn't   \
++                                 affect anything.  */                 \
 +                              tve->val = (uint64_t)top;            \
 +                      }                                               \
 +                      break;                                          \
@@ -4579,7 +4734,7 @@
 +      char            *pbuf = __get_cpu_var(gtp_printf);
 +      ULONGEST        *stack = __get_cpu_var(action_x_stack);
 +
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_lock(&gtp_var_lock);
 +
 +      if (ae->type == 'X') {
@@ -5187,24 +5342,18 @@
 +                      case 0x2c:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_GETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_getv;
 +                              break;
 +                      /* setv */
 +                      case 0x2d:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_SETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_setv;
 +                              break;
 +                      /* tracev */
 +                      case 0x2e:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_TRACEV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_tracev;
 +                              break;
 +                      /* printf */
@@ -5213,9 +5362,8 @@
 +
 +                                      if (arg) {
 +                                              void    *argv = (void *)
-+                                                              (unsigned long)
-+                                                              top;
-+
++                                                               (unsigned long)
++                                                               top;
 +                                              /* pop */
 +                                              if (sp)
 +                                                      top = stack[--sp];
@@ -5225,7 +5373,7 @@
 +                                              gtp_action_x_printf;
 +                                      } else
 +                                              snprintf(pbuf, psize,
-+                                                      (char *)(ebuf + pc));
++                                                       (char *)(ebuf + pc));
 +                                      psize -= strlen(pbuf);
 +                                      pbuf += strlen(pbuf);
 +
@@ -5233,8 +5381,7 @@
 +                              }
 +                              break;
 +                      }
-+
-+                      if (sp > STACK_MAX - 5) {
++                      if (unlikely(sp > STACK_MAX - 5)) {
 +                              printk(KERN_WARNING "gtp_action_x: stack "
 +                                                  "overflow.\n");
 +                              gts->tpe->reason
@@ -5251,14 +5398,14 @@
 +                          "action X get error in pc %u.\n",
 +              (int)gts->tpe->num, (void *)(CORE_ADDR)gts->tpe->addr, pc);
 +out:
-+      if (psize != GTP_PRINTF_MAX) {
++      if (unlikely(psize != GTP_PRINTF_MAX)) {
 +              unsigned long   flags;
 +
 +              local_irq_save(flags);
 +              printk("%s", pbuf - (GTP_PRINTF_MAX - psize));
 +              local_irq_restore(flags);
 +      }
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_unlock(&gtp_var_lock);
 +      return ret;
 +}
@@ -5294,15 +5441,15 @@
 +      if (gts->tpe->kpreg == 0)
 +              return;
 +
-+      if (gts->tpe->no_self_trace) {
-+              if (get_current()->pid == gtp_gtp_pid
-+                  || get_current()->pid == gtp_gtpframe_pid)
-+                      return;
-+
 +#if defined(GTP_FTRACE_RING_BUFFER) || defined(GTP_RB)
-+              if (get_current()->pid == gtp_gtpframe_pipe_pid)
-+                      return;
++      if (!gtp_pipe_trace && get_current()->pid == gtp_gtpframe_pipe_pid)
++              return;
 +#endif
++
++      if (gts->tpe->no_self_trace
++          && (get_current()->pid == gtp_gtp_pid
++              || get_current()->pid == gtp_gtpframe_pid)) {
++                      return;
 +      }
 +
 +      if (gts->tpe->have_printk) {
@@ -6471,13 +6618,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_GETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "get.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 1)) {
@@ -6520,13 +6660,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_SETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "set.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (arg == GTP_VAR_PRINTK_LEVEL_ID)
 +                                      tpe->have_printk = 1;
@@ -6557,13 +6690,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_TRACEV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "trace.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 4)) {
@@ -6991,7 +7117,7 @@
 +                      continue;
 +
 +              /* Get event.  */
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,0,0))
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
 +              tve->pts->event =
 +                      perf_event_create_kernel_counter(&(tve->pts->attr),
 +                                                       tve->pts->cpu,
@@ -7829,7 +7955,7 @@
 +              else
 +                      gtp_frame_head_find_num(old_num);
 +#endif
-+              strcpy(gtp_rw_bufp, "F-1");
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F-1");
 +              gtp_rw_bufp += 3;
 +              gtp_rw_size += 3;
 +      } else {
@@ -7853,8 +7979,9 @@
 +              tmp = ring_buffer_event_data(rbe);
 +              gtp_frame_current_tpe = *(ULONGEST *)(tmp + FID_SIZE);
 +#endif
-+              sprintf(gtp_rw_bufp, "F%xT%x", gtp_frame_current_num,
-+                      (unsigned int) gtp_frame_current_tpe);
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F%xT%x",
++                       gtp_frame_current_num,
++                       (unsigned int) gtp_frame_current_tpe);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +      }
@@ -7918,6 +8045,8 @@
 +                      var->val = val;
 +              if (num == GTP_VAR_IGNORE_ERROR_ID)
 +                      gtp_start_ignore_error = (int)val;
++              else if (num == GTP_VAR_PIPE_TRACE_ID)
++                      gtp_pipe_trace = (int)val;
 +
 +              return 0;
 +      }
@@ -8199,7 +8328,7 @@
 +}
 +
 +static int
-+gtp_get_status(struct gtp_entry *tpe, char *buf)
++gtp_get_status(struct gtp_entry *tpe, char *buf, int bufmax)
 +{
 +      int                     size = 0;
 +      int                     tfnum = 0;
@@ -8211,39 +8340,41 @@
 +#if defined(GTP_FRAME_SIMPLE) || defined(GTP_FTRACE_RING_BUFFER)
 +      if (!gtp_frame) {
 +#endif
-+              sprintf(buf, "tnotrun:0;");
++              snprintf(buf, bufmax, "tnotrun:0;");
 +              buf += 10;
 +              size += 10;
++              bufmax -= 10;
 +      } else if (!tpe || (tpe && tpe->reason == gtp_stop_normal)) {
-+              sprintf(buf, "tstop:0;");
++              snprintf(buf, bufmax, "tstop:0;");
 +              buf += 8;
 +              size += 8;
++              bufmax -= 8;
 +      } else {
 +              char    outtmp[100];
 +
 +              switch (tpe->reason) {
 +              case gtp_stop_frame_full:
-+                      sprintf(buf, "tfull:%lx;",
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "tfull:%lx;",
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_efault:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("read memory false", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("read memory false", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_access_wrong_reg:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("access wrong register", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("access wrong register", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_code_error:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("agent expression code error",
-+                                         outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("agent expression code error",
++                                          outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_stack_overflow:
-+                      sprintf(buf, "terror:%s:%lx;",
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
 +                              string2hex("agent expression stack overflow",
 +                                         outtmp),
 +                              (unsigned long)tpe->num);
@@ -8254,6 +8385,7 @@
 +              }
 +
 +              size += strlen(buf);
++              bufmax -= strlen(buf);
 +              buf += strlen(buf);
 +      }
 +
@@ -8335,28 +8467,33 @@
 +#endif
 +      }
 +
-+      sprintf(buf, "tframes:%x;", tfnum);
++      snprintf(buf, bufmax, "tframes:%x;", tfnum);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "tcreated:%x;", atomic_read(&gtp_frame_create));
++      snprintf(buf, bufmax, "tcreated:%x;", atomic_read(&gtp_frame_create));
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
-+      sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE);
++      snprintf(buf, bufmax, "tsize:%x;", GTP_FRAME_SIZE);
 +#endif
 +#ifdef GTP_FTRACE_RING_BUFFER
 +      if (gtp_frame)
-+              sprintf(buf, "tsize:%lx;", ring_buffer_size(gtp_frame));
++              snprintf(buf, bufmax, "tsize:%lx;",
++                       ring_buffer_size(gtp_frame));
 +      else
-+              sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE * num_online_cpus());
++              snprintf(buf, bufmax, "tsize:%x;",
++                       GTP_FRAME_SIZE * num_online_cpus());
 +#endif
 +#ifdef GTP_RB
-+      sprintf(buf, "tsize:%lx;",
-+              gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
++      snprintf(buf, bufmax, "tsize:%lx;",
++               gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
 +#endif
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
@@ -8397,16 +8534,19 @@
 +                        * num_online_cpus();
 +      }
 +#endif
-+      sprintf(buf, "tfree:%lx;", (unsigned long)tmpaddr);
++      snprintf(buf, bufmax, "tfree:%lx;", (unsigned long)tmpaddr);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "circular:%x;", gtp_circular);
++      snprintf(buf, bufmax, "circular:%x;", gtp_circular);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "disconn:%x", gtp_disconnected_tracing);
++      snprintf(buf, bufmax, "disconn:%x", gtp_disconnected_tracing);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +      return size;
@@ -8426,41 +8566,53 @@
 +      if (gtp_start && tpe)   /* Tpe is stop, stop all tpes.  */
 +              gtp_gdbrsp_qtstop();
 +
-+      sprintf(gtp_rw_bufp, "T%x;", gtp_start ? 1 : 0);
++      snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "T%x;", gtp_start ? 1 : 0);
 +      gtp_rw_bufp += 3;
 +      gtp_rw_size += 3;
 +
-+      tmp = gtp_get_status(tpe, gtp_rw_bufp);
++      tmp = gtp_get_status(tpe, gtp_rw_bufp, GTP_RW_BUFP_MAX);
 +      gtp_rw_bufp += tmp;
 +      gtp_rw_size += tmp;
 +
 +      return 1;
 +}
++
++#define GTP_REPORT_TRACEPOINT_MAX     (1 + 16 + 1 + 16 + 1 + 1 + 1 + \
++                                       20 + 1 + 16 + 1)
 +
 +static void
-+gtp_report_tracepoint(struct gtp_entry *gtp, char *buf)
++gtp_report_tracepoint(struct gtp_entry *gtp, char *buf, int bufmax)
 +{
-+      sprintf(buf, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
-+              gtp->step, (unsigned long)gtp->pass);
++      snprintf(buf, bufmax, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
++               gtp->step, (unsigned long)gtp->pass);
++}
++
++static int
++gtp_report_action_max(struct gtp_entry *gtp, struct action *action)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(action->src) + 1;
 +}
 +
 +static void
-+gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf)
++gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf,
++                int bufmax)
 +{
-+      sprintf(buf, "A%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              action->src);
++      snprintf(buf, bufmax, "A%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, action->src);
++}
++
++static int
++gtp_report_src_max(struct gtp_entry *gtp, struct gtpsrc *src)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(src->src) + 1;
 +}
 +
 +static void
-+gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf)
++gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf, int bufmax)
 +{
-+      sprintf(buf, "Z%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              src->src);
++      snprintf(buf, bufmax, "Z%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, src->src);
 +}
 +
 +static void
@@ -8484,15 +8636,18 @@
 +{
 +      if (gtp_list) {
 +              current_gtp = gtp_list;
-+              gtp_report_tracepoint(current_gtp, gtp_rw_bufp);
++              gtp_report_tracepoint(current_gtp, gtp_rw_bufp,
++                                    GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_action = current_gtp->action_list;
 +              gtp_current_action_check();
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/gtp_for_review.patch Thu Feb 23 23:02:43 2012
+++ /trunk/gtp_for_review.patch Sat Feb 25 02:36:54 2012
@@ -1,22 +1,22 @@
 ---
- Documentation/trace/gtp.txt            | 1519 +++++
- Documentation/trace/gtp_quickstart.txt |  250
- arch/arm/include/asm/gtp.h             |   13
- arch/mips/include/asm/gtp.h            |   18
- arch/x86/include/asm/gtp.h             |   18
- include/linux/perf_event.h             |    3
- kernel/events/core.c                   |   14
- lib/Kconfig.debug                      |   10
- lib/Makefile                           |    4
- lib/gtp.c | 8606 +++++++++++++++++++++++++++++++++
- lib/gtp_rb.c                           |  495 +
- scripts/gtp/add-ons/pe.py              |  729 ++
- scripts/gtp/getgtprsp.pl               |  137
- scripts/gtp/getmod.py                  |  132
- 14 files changed, 11946 insertions(+), 2 deletions(-)
+ Documentation/gtp/howto.txt      | 1519 ++++++
+ Documentation/gtp/quickstart.txt |  250 +
+ arch/arm/include/asm/gtp.h       |   13
+ arch/mips/include/asm/gtp.h      |   18
+ arch/x86/include/asm/gtp.h       |   18
+ include/linux/perf_event.h       |    3
+ kernel/events/core.c             |   14
+ lib/Kconfig.debug                |   10
+ lib/Makefile                     |    4
+ lib/gtp.c | 8608 +++++++++++++++++++++++++++++++++++++++
+ lib/gtp_rb.c                     |  495 ++
+ scripts/gtp/add-ons/pe.py        |  729 +++
+ scripts/gtp/getgtprsp.pl         |  137
+ scripts/gtp/getmod.py            |  132
+ 14 files changed, 11948 insertions(+), 2 deletions(-)

 --- /dev/null
-+++ b/Documentation/trace/gtp.txt
++++ b/Documentation/gtp/howto.txt
 @@ -0,0 +1,1519 @@
 +              Linux Kernel GDB tracepoint module (KGTP)
 +              =========================================
@@ -104,7 +104,7 @@
 +(See https://code.google.com/p/kgtp/wiki/HowToUseKGTPinAndroid).
 +It supports X86-32, X86-64, MIPS and ARM.
 +
-+For new user of KGTP, please go to see gtp_quickstart.txt.
++For new user of KGTP, please go to see quickstart.txt.
 +
 +
 +
@@ -1538,7 +1538,7 @@
 +This way is better to work with python to parse Kernel.
 +I will introduce them in example.
 --- /dev/null
-+++ b/Documentation/trace/gtp_quickstart.txt
++++ b/Documentation/gtp/quickstart.txt
 @@ -0,0 +1,250 @@
 +              Linux Kernel GDB tracepoint module (KGTP) quick start
 +              =====================================================
@@ -1952,7 +1952,7 @@
 +gtp.o: gtp_rb.c
 --- /dev/null
 +++ b/lib/gtp.c
-@@ -0,0 +1,8606 @@
+@@ -0,0 +1,8608 @@
 +/*
 + * Kernel GDB tracepoint module.
 + *
@@ -1971,6 +1971,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 + *
+ * Copyright(C) KGTP team (https://code.google.com/p/kgtp/), 2010, 2011, 2012
++ *
 + */
 +
 +/* If *10 means that this is not a release version.  */
@@ -6196,8 +6197,8 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              } else if (arg == GTP_VAR_KRET_ID) {
-+                                      /* XXX: still not set it value to
-+                                         maxactive.  */
++                                      /* XXX: still not set it
++                                         value to maxactive.  */
 +                                      tpe->is_kretprobe = 1;
 +                                      ret = 1;
 +                                      goto release_out;
@@ -6893,9 +6894,9 @@
 +                              return -EINVAL;
 +                      pkg++;
 +                      step_action = 1;
-+                      /* XXX: Still not support step.  */
-+                      return 1;
-+              }
++              } else if (tpe->step_action_list)
++                      step_action = 1;
++
 +              while (pkg[0]) {
 +                      struct action   *ae = NULL, *atail = NULL;
 +
@@ -7376,7 +7377,6 @@
 +      printk(GTP_DEBUG "gtp_gdbrsp_qtframe: %s\n", pkg);
 +#endif
 +
-+      /* XXX: If this check is removed, add a check for gtp_frame.  */
 +      if (atomic_read(&gtp_frame_create) == 0)
 +              goto out;
 +
@@ -7851,7 +7851,8 @@
 +
 +#ifdef GTP_RB
 +      if (GTP_RB_PAGE_IS_EMPTY) {
-+#elif defined(GTP_FRAME_SIMPLE) || defined(GTP_FTRACE_RING_BUFFER)
++#endif
++#if defined(GTP_FRAME_SIMPLE) || defined(GTP_FTRACE_RING_BUFFER)
 +      if (!gtp_frame) {
 +#endif
 +              snprintf(buf, bufmax, "tnotrun:0;");
@@ -8664,9 +8665,10 @@
 +#endif
 +              int     ret;
 +
-+              /* The following part is for gtpro support.
++              /* XXX: Issue 1: The following part is for gtpro support.
 +                 It is not available because it make disassemble cannot
 +                 work when select a trace frame. */
++
 +#if 0
 +              struct gtpro_entry      *gtroe;
 +
=======================================
--- /trunk/gtp_older_to_2.6.32.patch    Tue Jan 31 04:51:57 2012
+++ /trunk/gtp_older_to_2.6.32.patch    Sat Feb 25 02:36:54 2012
@@ -1,22 +1,23 @@
 ---
- Documentation/trace/gtp.txt            | 1517 +++++
- Documentation/trace/gtp_quickstart.txt |  250
- lib/Kconfig.debug                      |   10
- lib/Makefile                           |    2
- lib/gtp.c | 9031 +++++++++++++++++++++++++++++++++
- lib/gtp_rb.c                           |  474 +
- scripts/getgtprsp.pl                   |  102
- scripts/getmod.py                      |  132
- 8 files changed, 11518 insertions(+)
+ Documentation/gtp/howto.txt      | 1519 ++++++
+ Documentation/gtp/quickstart.txt |  250 +
+ lib/Kconfig.debug                |   10
+ lib/Makefile                     |    2
+ lib/gtp.c | 9210 +++++++++++++++++++++++++++++++++++++++
+ lib/gtp_rb.c                     |  495 ++
+ scripts/gtp/add-ons/pe.py        |  729 +++
+ scripts/gtp/getgtprsp.pl         |  137
+ scripts/gtp/getmod.py            |  132
+ 9 files changed, 12484 insertions(+)

 --- /dev/null
-+++ b/Documentation/trace/gtp.txt
-@@ -0,0 +1,1517 @@
++++ b/Documentation/gtp/howto.txt
+@@ -0,0 +1,1519 @@
 +              Linux Kernel GDB tracepoint module (KGTP)
 +              =========================================
 +              By Hui Zhu <teawater@xxxxxxxxx>
 +              https://code.google.com/p/kgtp/wiki/HOWTO
-+              2011-12-16
++              2012-02-21
 +
 +Table of contents
 +-----------------
@@ -48,7 +49,7 @@
 +      How to use trace state variables
 +              Simple trace state variables
 +              Per_cpu trace state variables
-+              Special trace state variables $current_task,
++              Special trace state variables $current_task, $current_task_pid,
 +                  $current_thread_info, $cpu_id, $dump_stack, $printk_level,
 +                  $printk_format, $printk_tmp, $clock, $rdtsc, $hardirq_count,
 +                  $softirq_count and $irq_count
@@ -98,7 +99,7 @@
 +(See https://code.google.com/p/kgtp/wiki/HowToUseKGTPinAndroid).
 +It supports X86-32, X86-64, MIPS and ARM.
 +
-+For new user of KGTP, please go to see gtp_quickstart.txt.
++For new user of KGTP, please go to see quickstart.txt.
 +
 +
 +
@@ -649,9 +650,9 @@
 +of each CPU.
 +
 +
-+Special trace state variables $current_task, $current_thread_info, $cpu_id,
-+$dump_stack, $printk_level, $printk_format, $printk_tmp, $clock, $rdtsc,
-+$hardirq_count, $softirq_count and $irq_count
++Special trace state variables $current_task, $current_task_pid,
++$current_thread_info, $cpu_id, $dump_stack, $printk_level, $printk_format,
++$printk_tmp, $clock, $rdtsc, $hardirq_count, $softirq_count and $irq_count
+---------------------------------------------------------------------------
 +
 +KGTP special trace state variables $current_task, $current_thread_info,
@@ -660,6 +661,8 @@
 +or actions.
+Access $current_task in tracepoint condition and action will get that returns
 +of get_current().
++Access $current_task_pid in tracepoint condition and action will get that
++returns of get_current()->pid.
+Access $current_thread_info in tracepoint condition and action will get that
 +returns of current_thread_info().
 +Access $cpu_id in tracepoint condition and action will get that returns of
@@ -792,12 +795,12 @@
 +And the last error number will available in "$last_errno".
 +
 +---------------------------------
-+tvariable $ignore_error
++tvariable $ignore_error=1
 +---------------------------------
 +This command will open ignore.
 +
 +---------------------------------
-+delete tvariable $ignore_error
++tvariable $ignore_error=0
 +---------------------------------
 +This command will close ignore.
 +
@@ -1530,7 +1533,7 @@
 +This way is better to work with python to parse Kernel.
 +I will introduce them in example.
 --- /dev/null
-+++ b/Documentation/trace/gtp_quickstart.txt
++++ b/Documentation/gtp/quickstart.txt
 @@ -0,0 +1,250 @@
 +              Linux Kernel GDB tracepoint module (KGTP) quick start
 +              =====================================================
@@ -1672,7 +1675,7 @@
 +(gdb) tstop
 +(gdb) tfind
 +Found trace frame 0, tracepoint 1
-+#0 vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at /build/buildd/linux-2.6.35/fs/readdir.c:23
++#0  vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at readdir.c:23
 +23      {
 +
 +
@@ -1814,7 +1817,7 @@

 --- /dev/null
 +++ b/lib/gtp.c
-@@ -0,0 +1,9031 @@
+@@ -0,0 +1,9210 @@
 +/*
 + * Kernel GDB tracepoint module.
 + *
@@ -1837,7 +1840,7 @@
 + */
 +
 +/* If *10 means that this is not a release version.  */
-+#define GTP_VERSION                   (20120131)
++#define GTP_VERSION                   (20120224)
 +
 +#include <linux/version.h>
 +#ifndef RHEL_RELEASE_VERSION
@@ -2022,6 +2025,7 @@
 +#endif
 +
 +#define GTP_RW_MAX            16384
++#define GTP_RW_BUFP_MAX               (GTP_RW_MAX - 4 - gtp_rw_size)
 +
 +#define FID_TYPE              unsigned int
 +#define FID_SIZE              sizeof(FID_TYPE)
@@ -2248,7 +2252,9 @@
 +      GTP_VAR_HARDIRQ_COUNT_ID,
 +      GTP_VAR_SOFTIRQ_COUNT_ID,
 +      GTP_VAR_IRQ_COUNT_ID,
-+      GTP_VAR_SPECIAL_MAX = GTP_VAR_IRQ_COUNT_ID,
++      GTP_VAR_PIPE_TRACE_ID,
++      GTP_VAR_CURRENT_TASK_PID_ID,
++      GTP_VAR_SPECIAL_MAX = GTP_VAR_PIPE_TRACE_ID,
 +};
 +
 +#define PREV_VAR      NULL
@@ -2258,6 +2264,10 @@
 +      .num            = GTP_VAR_VERSION_ID,
 +      .src            = "0:1:6774705f76657273696f6e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_version)
@@ -2267,6 +2277,10 @@
 +      .num            = GTP_VAR_CPU_ID,
 +      .src            = "0:1:6370755f6964",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_id)
@@ -2276,15 +2290,36 @@
 +      .num            = GTP_VAR_CURRENT_TASK_ID,
 +      .src            = "0:1:63757272656e745f7461736b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_task)
 +
++static struct gtp_var         gtp_var_current_task_pid = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_CURRENT_TASK_PID_ID,
++      .src            = "0:1:63757272656e745f7461736b5f706964",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_current_task_pid)
++
 +static struct gtp_var         gtp_var_current_thread_info = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CURRENT_THREAD_INFO_ID,
 +      .src            = "0:1:63757272656e745f7468726561645f696e666f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_current_thread_info)
@@ -2294,6 +2329,10 @@
 +      .num            = GTP_VAR_CLOCK_ID,
 +      .src            = "0:1:636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_clock)
@@ -2303,6 +2342,10 @@
 +      .num            = GTP_VAR_COOKED_CLOCK_ID,
 +      .src            = "0:1:636f6f6b65645f636c6f636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_clock)
@@ -2313,6 +2356,10 @@
 +      .num            = GTP_VAR_RDTSC_ID,
 +      .src            = "0:1:7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_rdtsc)
@@ -2321,6 +2368,10 @@
 +      .num            = GTP_VAR_COOKED_RDTSC_ID,
 +      .src            = "0:1:636f6f6b65645f7264747363",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cooked_rdtsc)
@@ -2332,6 +2383,10 @@
 +      .num            = GTP_VAR_GTP_RB_DISCARD_PAGE_NUMBER,
 +      .src            = "0:1:646973636172645f706167655f6e756d",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_gtp_rb_discard_page_number)
@@ -2342,6 +2397,10 @@
 +      .num            = GTP_VAR_PRINTK_TMP_ID,
 +      .src            = "0:1:7072696e746b5f746d70",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_tmp)
@@ -2351,6 +2410,10 @@
 +      .num            = GTP_VAR_PRINTK_LEVEL_ID,
 +      .src            = "8:1:7072696e746b5f6c6576656c",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_level)
@@ -2360,6 +2423,10 @@
 +      .num            = GTP_VAR_PRINTK_FORMAT_ID,
 +      .src            = "0:1:7072696e746b5f666f726d6174",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_printk_format)
@@ -2369,6 +2436,10 @@
 +      .num            = GTP_VAR_DUMP_STACK_ID,
 +      .src            = "0:1:64756d705f737461636b",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_dump_stack)
@@ -2378,15 +2449,36 @@
 +      .num            = GTP_VAR_NO_SELF_TRACE_ID,
 +      .src            = "0:1:6e6f5f73656c665f7472616365",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_no_self_trace)
 +
++static struct gtp_var         gtp_var_pipe_trace = {
++      .next           = PREV_VAR,
++      .num            = GTP_VAR_PIPE_TRACE_ID,
++      .src            = "0:1:706970655f7472616365",
++      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
++};
++#undef PREV_VAR
++#define PREV_VAR      (&gtp_var_pipe_trace)
++
 +static struct gtp_var         gtp_var_cpu_number = {
 +      .next           = PREV_VAR,
 +      .num            = GTP_VAR_CPU_NUMBER_ID,
 +      .src            = "0:1:6370755f6e756d626572",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_cpu_number)
@@ -2396,6 +2488,10 @@
 +      .num            = GTP_VAR_PC_PE_EN_ID,
 +      .src            = "0:1:70635f70655f656e",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_pc_pe_en)
@@ -2405,6 +2501,10 @@
 +      .num            = GTP_VAR_KRET_ID,
 +      .src            = "0:1:6b726574",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_kret)
@@ -2414,6 +2514,10 @@
 +      .num            = GTP_VAR_XTIME_SEC_ID,
 +      .src            = "0:1:7874696d655f736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_sec)
@@ -2423,6 +2527,10 @@
 +      .num            = GTP_VAR_XTIME_NSEC_ID,
 +      .src            = "0:1:7874696d655f6e736563",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_xtime_nsec)
@@ -2432,6 +2540,10 @@
 +      .num            = GTP_VAR_IGNORE_ERROR_ID,
 +      .src            = "0:1:69676e6f72655f6572726f72",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_ignore_error)
@@ -2441,6 +2553,10 @@
 +      .num            = GTP_VAR_LAST_ERRNO_ID,
 +      .src            = "0:1:6c6173745f6572726e6f",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_last_errno)
@@ -2450,6 +2566,10 @@
 +      .num            = GTP_VAR_HARDIRQ_COUNT_ID,
 +      .src            = "0:1:686172646972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_hardirq_count)
@@ -2459,6 +2579,10 @@
 +      .num            = GTP_VAR_SOFTIRQ_COUNT_ID,
 +      .src            = "0:1:736f66746972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +#define PREV_VAR      (&gtp_var_softirq_count)
@@ -2468,6 +2592,10 @@
 +      .num            = GTP_VAR_IRQ_COUNT_ID,
 +      .src            = "0:1:6972715f636f756e74",
 +      .per_cpu        = NULL,
++#ifdef GTP_PERF_EVENTS
++      .ptid           = 0,
++      .pts            = NULL,
++#endif
 +};
 +#undef PREV_VAR
 +
@@ -2475,19 +2603,6 @@
 +
 +#define GTP_VAR_IS_SPECIAL(x)         ((x) >= GTP_VAR_SPECIAL_MIN \
 +                                       && (x) <= GTP_VAR_SPECIAL_MAX)
-+#define GTP_VAR_NOT_GETV(x)           ((x) == GTP_VAR_PRINTK_LEVEL_ID \
-+                                       || (x) == GTP_VAR_PRINTK_FORMAT_ID \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_SETV(x)           (((x) >= GTP_VAR_CURRENT_TASK_ID \
-+                                        && (x) <= GTP_VAR_CPU_ID) \
-+                                       || (x) == GTP_VAR_DUMP_STACK_ID \
-+                                       || (x) == GTP_VAR_CPU_NUMBER_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
-+#define GTP_VAR_NOT_TRACEV(x)         (((x) >= GTP_VAR_PRINTK_LEVEL_ID \
-+                                       && (x) <= GTP_VAR_PRINTK_FORMAT_ID) \
-+                                       || (x) == GTP_VAR_PC_PE_EN_ID \
-+                                       || (x) == GTP_VAR_KRET_ID)
 +#ifdef GTP_RB
 +#define GTP_VAR_AUTO_TRACEV(x)                ((x) == GTP_VAR_CPU_ID)
 +#endif
@@ -2541,6 +2656,8 @@
 +static uint64_t                       gtp_start_last_errno;
 +static int                    gtp_start_ignore_error;
 +
++static int                    gtp_pipe_trace;
++
 +#ifdef GTP_RB
 +#include "gtp_rb.c"
 +#endif
@@ -2661,8 +2778,8 @@
 +{
 +      char    *tmp;
 +
-+      if ((grs->real_size < grs->size + size)
-+          || (is_end && grs->real_size != grs->size + size)) {
++      if (unlikely((grs->real_size < grs->size + size)
++                   || (is_end && grs->real_size != grs->size + size))) {
 +              grs->real_size = grs->size + size;
 +              if (!is_end)
 +                      grs->real_size += 100;
@@ -2698,6 +2815,30 @@
 +
 +      return 0;
 +}
++
++static inline void
++gtp_realloc_reset(struct gtp_realloc_s *grs)
++{
++      grs->size = 0;
++}
++
++static inline int
++gtp_realloc_is_alloced(struct gtp_realloc_s *grs)
++{
++      return (grs->buf != NULL);
++}
++
++static inline int
++gtp_realloc_is_empty(struct gtp_realloc_s *grs)
++{
++      return (grs->size == 0);
++}
++
++static inline void
++gtp_realloc_sub_size(struct gtp_realloc_s *grs, size_t size)
++{
++      grs->size -= size;
++}
 +
 +#ifdef CONFIG_X86
 +static ULONGEST
@@ -3575,8 +3716,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_disable(ppl->event);
-+
++#else
++                      perf_event_disable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -3590,7 +3734,11 @@
 +
 +      for (ppl = __get_cpu_var(pc_pe_list); ppl; ppl = ppl->pc_next) {
 +              if (ppl->en)
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 +                      __perf_event_enable(ppl->event);
++#else
++                      perf_event_enable(ppl->event);
++#endif
 +      }
 +}
 +
@@ -4196,6 +4344,12 @@
 +              else
 +                      return (uint64_t)(CORE_ADDR)get_current();
 +              break;
++      case GTP_VAR_CURRENT_TASK_PID_ID:
++              if (gts->ri)
++                      return (uint64_t)(CORE_ADDR)gts->ri->task->pid;
++              else
++                      return (uint64_t)(CORE_ADDR)get_current()->pid;
++              break;
 +      case GTP_VAR_CURRENT_THREAD_INFO_ID:
 +              return (uint64_t)(CORE_ADDR)current_thread_info();
 +              break;
@@ -4383,7 +4537,8 @@
 +                              gtp_action_x_setv_pe;                   \
 +                              /* Not check the other special          \
 +                                 trace state variables.               \
-+                                 Checked in gtp_check_x.  */          \
++                                 Because set in tve->val doesn't   \
++                                 affect anything.  */                 \
 +                              tve->val = (uint64_t)top;            \
 +                      }                                               \
 +                      break;                                          \
@@ -4478,7 +4633,7 @@
 +      char            *pbuf = __get_cpu_var(gtp_printf);
 +      ULONGEST        *stack = __get_cpu_var(action_x_stack);
 +
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_lock(&gtp_var_lock);
 +
 +      if (ae->type == 'X') {
@@ -5086,24 +5241,18 @@
 +                      case 0x2c:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_GETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_getv;
 +                              break;
 +                      /* setv */
 +                      case 0x2d:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_SETV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_setv;
 +                              break;
 +                      /* tracev */
 +                      case 0x2e:
 +                              arg = ebuf[pc++];
 +                              arg = (arg << 8) + ebuf[pc++];
-+                              if (GTP_VAR_NOT_TRACEV(arg))
-+                                      goto code_error_out;
 +                              gtp_action_x_tracev;
 +                              break;
 +                      /* printf */
@@ -5112,9 +5261,8 @@
 +
 +                                      if (arg) {
 +                                              void    *argv = (void *)
-+                                                              (unsigned long)
-+                                                              top;
-+
++                                                               (unsigned long)
++                                                               top;
 +                                              /* pop */
 +                                              if (sp)
 +                                                      top = stack[--sp];
@@ -5124,7 +5272,7 @@
 +                                              gtp_action_x_printf;
 +                                      } else
 +                                              snprintf(pbuf, psize,
-+                                                      (char *)(ebuf + pc));
++                                                       (char *)(ebuf + pc));
 +                                      psize -= strlen(pbuf);
 +                                      pbuf += strlen(pbuf);
 +
@@ -5132,8 +5280,7 @@
 +                              }
 +                              break;
 +                      }
-+
-+                      if (sp > STACK_MAX - 5) {
++                      if (unlikely(sp > STACK_MAX - 5)) {
 +                              printk(KERN_WARNING "gtp_action_x: stack "
 +                                                  "overflow.\n");
 +                              gts->tpe->reason
@@ -5150,14 +5297,14 @@
 +                          "action X get error in pc %u.\n",
 +              (int)gts->tpe->num, (void *)(CORE_ADDR)gts->tpe->addr, pc);
 +out:
-+      if (psize != GTP_PRINTF_MAX) {
++      if (unlikely(psize != GTP_PRINTF_MAX)) {
 +              unsigned long   flags;
 +
 +              local_irq_save(flags);
 +              printk("%s", pbuf - (GTP_PRINTF_MAX - psize));
 +              local_irq_restore(flags);
 +      }
-+      if (ae->u.exp.need_var_lock)
++      if (unlikely(ae->u.exp.need_var_lock))
 +              spin_unlock(&gtp_var_lock);
 +      return ret;
 +}
@@ -5193,15 +5340,15 @@
 +      if (gts->tpe->kpreg == 0)
 +              return;
 +
-+      if (gts->tpe->no_self_trace) {
-+              if (get_current()->pid == gtp_gtp_pid
-+                  || get_current()->pid == gtp_gtpframe_pid)
-+                      return;
-+
 +#if defined(GTP_FTRACE_RING_BUFFER) || defined(GTP_RB)
-+              if (get_current()->pid == gtp_gtpframe_pipe_pid)
-+                      return;
++      if (!gtp_pipe_trace && get_current()->pid == gtp_gtpframe_pipe_pid)
++              return;
 +#endif
++
++      if (gts->tpe->no_self_trace
++          && (get_current()->pid == gtp_gtp_pid
++              || get_current()->pid == gtp_gtpframe_pid)) {
++                      return;
 +      }
 +
 +      if (gts->tpe->have_printk) {
@@ -6370,13 +6517,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_GETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "get.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 1)) {
@@ -6419,13 +6559,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_SETV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "set.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (arg == GTP_VAR_PRINTK_LEVEL_ID)
 +                                      tpe->have_printk = 1;
@@ -6456,13 +6589,6 @@
 +                                      ret = 1;
 +                                      goto release_out;
 +                              }
-+
-+                              if (GTP_VAR_NOT_TRACEV(arg)) {
-+                                      printk(KERN_WARNING
-+                                             "gtp_check_x: The tv %d cannot "
-+                                             "trace.\n", arg);
-+                                      goto release_out;
-+                              }
 +
 +                              if (!GTP_VAR_IS_SPECIAL(arg)) {
 +                                      if (gtp_x_var_add(&vlist, arg, 4)) {
@@ -6890,7 +7016,7 @@
 +                      continue;
 +
 +              /* Get event.  */
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,0,0))
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
 +              tve->pts->event =
 +                      perf_event_create_kernel_counter(&(tve->pts->attr),
 +                                                       tve->pts->cpu,
@@ -7728,7 +7854,7 @@
 +              else
 +                      gtp_frame_head_find_num(old_num);
 +#endif
-+              strcpy(gtp_rw_bufp, "F-1");
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F-1");
 +              gtp_rw_bufp += 3;
 +              gtp_rw_size += 3;
 +      } else {
@@ -7752,8 +7878,9 @@
 +              tmp = ring_buffer_event_data(rbe);
 +              gtp_frame_current_tpe = *(ULONGEST *)(tmp + FID_SIZE);
 +#endif
-+              sprintf(gtp_rw_bufp, "F%xT%x", gtp_frame_current_num,
-+                      (unsigned int) gtp_frame_current_tpe);
++              snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "F%xT%x",
++                       gtp_frame_current_num,
++                       (unsigned int) gtp_frame_current_tpe);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +      }
@@ -7817,6 +7944,8 @@
 +                      var->val = val;
 +              if (num == GTP_VAR_IGNORE_ERROR_ID)
 +                      gtp_start_ignore_error = (int)val;
++              else if (num == GTP_VAR_PIPE_TRACE_ID)
++                      gtp_pipe_trace = (int)val;
 +
 +              return 0;
 +      }
@@ -8098,7 +8227,7 @@
 +}
 +
 +static int
-+gtp_get_status(struct gtp_entry *tpe, char *buf)
++gtp_get_status(struct gtp_entry *tpe, char *buf, int bufmax)
 +{
 +      int                     size = 0;
 +      int                     tfnum = 0;
@@ -8110,39 +8239,41 @@
 +#if defined(GTP_FRAME_SIMPLE) || defined(GTP_FTRACE_RING_BUFFER)
 +      if (!gtp_frame) {
 +#endif
-+              sprintf(buf, "tnotrun:0;");
++              snprintf(buf, bufmax, "tnotrun:0;");
 +              buf += 10;
 +              size += 10;
++              bufmax -= 10;
 +      } else if (!tpe || (tpe && tpe->reason == gtp_stop_normal)) {
-+              sprintf(buf, "tstop:0;");
++              snprintf(buf, bufmax, "tstop:0;");
 +              buf += 8;
 +              size += 8;
++              bufmax -= 8;
 +      } else {
 +              char    outtmp[100];
 +
 +              switch (tpe->reason) {
 +              case gtp_stop_frame_full:
-+                      sprintf(buf, "tfull:%lx;",
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "tfull:%lx;",
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_efault:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("read memory false", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("read memory false", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_access_wrong_reg:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("access wrong register", outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("access wrong register", outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_code_error:
-+                      sprintf(buf, "terror:%s:%lx;",
-+                              string2hex("agent expression code error",
-+                                         outtmp),
-+                              (unsigned long)tpe->num);
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
++                               string2hex("agent expression code error",
++                                          outtmp),
++                               (unsigned long)tpe->num);
 +                      break;
 +              case gtp_stop_agent_expr_stack_overflow:
-+                      sprintf(buf, "terror:%s:%lx;",
++                      snprintf(buf, bufmax, "terror:%s:%lx;",
 +                              string2hex("agent expression stack overflow",
 +                                         outtmp),
 +                              (unsigned long)tpe->num);
@@ -8153,6 +8284,7 @@
 +              }
 +
 +              size += strlen(buf);
++              bufmax -= strlen(buf);
 +              buf += strlen(buf);
 +      }
 +
@@ -8234,28 +8366,33 @@
 +#endif
 +      }
 +
-+      sprintf(buf, "tframes:%x;", tfnum);
++      snprintf(buf, bufmax, "tframes:%x;", tfnum);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "tcreated:%x;", atomic_read(&gtp_frame_create));
++      snprintf(buf, bufmax, "tcreated:%x;", atomic_read(&gtp_frame_create));
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
-+      sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE);
++      snprintf(buf, bufmax, "tsize:%x;", GTP_FRAME_SIZE);
 +#endif
 +#ifdef GTP_FTRACE_RING_BUFFER
 +      if (gtp_frame)
-+              sprintf(buf, "tsize:%lx;", ring_buffer_size(gtp_frame));
++              snprintf(buf, bufmax, "tsize:%lx;",
++                       ring_buffer_size(gtp_frame));
 +      else
-+              sprintf(buf, "tsize:%x;", GTP_FRAME_SIZE * num_online_cpus());
++              snprintf(buf, bufmax, "tsize:%x;",
++                       GTP_FRAME_SIZE * num_online_cpus());
 +#endif
 +#ifdef GTP_RB
-+      sprintf(buf, "tsize:%lx;",
-+              gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
++      snprintf(buf, bufmax, "tsize:%lx;",
++               gtp_rb_page_count * GTP_RB_DATA_MAX * num_online_cpus());
 +#endif
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +#ifdef GTP_FRAME_SIMPLE
@@ -8296,16 +8433,19 @@
 +                        * num_online_cpus();
 +      }
 +#endif
-+      sprintf(buf, "tfree:%lx;", (unsigned long)tmpaddr);
++      snprintf(buf, bufmax, "tfree:%lx;", (unsigned long)tmpaddr);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "circular:%x;", gtp_circular);
++      snprintf(buf, bufmax, "circular:%x;", gtp_circular);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
-+      sprintf(buf, "disconn:%x", gtp_disconnected_tracing);
++      snprintf(buf, bufmax, "disconn:%x", gtp_disconnected_tracing);
 +      size += strlen(buf);
++      bufmax -= strlen(buf);
 +      buf += strlen(buf);
 +
 +      return size;
@@ -8325,41 +8465,53 @@
 +      if (gtp_start && tpe)   /* Tpe is stop, stop all tpes.  */
 +              gtp_gdbrsp_qtstop();
 +
-+      sprintf(gtp_rw_bufp, "T%x;", gtp_start ? 1 : 0);
++      snprintf(gtp_rw_bufp, GTP_RW_BUFP_MAX, "T%x;", gtp_start ? 1 : 0);
 +      gtp_rw_bufp += 3;
 +      gtp_rw_size += 3;
 +
-+      tmp = gtp_get_status(tpe, gtp_rw_bufp);
++      tmp = gtp_get_status(tpe, gtp_rw_bufp, GTP_RW_BUFP_MAX);
 +      gtp_rw_bufp += tmp;
 +      gtp_rw_size += tmp;
 +
 +      return 1;
 +}
++
++#define GTP_REPORT_TRACEPOINT_MAX     (1 + 16 + 1 + 16 + 1 + 1 + 1 + \
++                                       20 + 1 + 16 + 1)
 +
 +static void
-+gtp_report_tracepoint(struct gtp_entry *gtp, char *buf)
++gtp_report_tracepoint(struct gtp_entry *gtp, char *buf, int bufmax)
 +{
-+      sprintf(buf, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
-+              gtp->step, (unsigned long)gtp->pass);
++      snprintf(buf, bufmax, "T%lx:%lx:%c:%d:%lx", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, (gtp->disable ? 'D' : 'E'),
++               gtp->step, (unsigned long)gtp->pass);
++}
++
++static int
++gtp_report_action_max(struct gtp_entry *gtp, struct action *action)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(action->src) + 1;
 +}
 +
 +static void
-+gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf)
++gtp_report_action(struct gtp_entry *gtp, struct action *action, char *buf,
++                int bufmax)
 +{
-+      sprintf(buf, "A%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              action->src);
++      snprintf(buf, bufmax, "A%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, action->src);
++}
++
++static int
++gtp_report_src_max(struct gtp_entry *gtp, struct gtpsrc *src)
++{
++      return 1 + 16 + 1 + 16 + 1 + strlen(src->src) + 1;
 +}
 +
 +static void
-+gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf)
++gtp_report_src(struct gtp_entry *gtp, struct gtpsrc *src, char *buf, int bufmax)
 +{
-+      sprintf(buf, "Z%lx:%lx:%s",
-+              (unsigned long)gtp->num,
-+              (unsigned long)gtp->addr,
-+              src->src);
++      snprintf(buf, bufmax, "Z%lx:%lx:%s", (unsigned long)gtp->num,
++               (unsigned long)gtp->addr, src->src);
 +}
 +
 +static void
@@ -8383,15 +8535,18 @@
 +{
 +      if (gtp_list) {
 +              current_gtp = gtp_list;
-+              gtp_report_tracepoint(current_gtp, gtp_rw_bufp);
++              gtp_report_tracepoint(current_gtp, gtp_rw_bufp,
++                                    GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_action = current_gtp->action_list;
 +              gtp_current_action_check();
 +      } else {
-+              gtp_rw_bufp[0] = 'l';
-+              gtp_rw_size += 1;
-+              gtp_rw_bufp += 1;
++              if (GTP_RW_BUFP_MAX > 1) {
++                      gtp_rw_bufp[0] = 'l';
++                      gtp_rw_size += 1;
++                      gtp_rw_bufp += 1;
++              }
 +      }
 +
 +      return 1;
@@ -8402,7 +8557,7 @@
 +{
 +      if (current_gtp_action) {
 +              gtp_report_action(current_gtp, current_gtp_action,
-+                                gtp_rw_bufp);
++                                gtp_rw_bufp, GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_action = current_gtp_action->next;
@@ -8411,7 +8566,8 @@
 +      }
 +
 +      if (current_gtp_src) {
-+              gtp_report_src(current_gtp, current_gtp_src, gtp_rw_bufp);
++              gtp_report_src(current_gtp, current_gtp_src, gtp_rw_bufp,
++                             GTP_RW_BUFP_MAX);
 +              gtp_rw_size += strlen(gtp_rw_bufp);
 +              gtp_rw_bufp += strlen(gtp_rw_bufp);
 +              current_gtp_src = current_gtp_src->next;
@@ -8420,15 +8576,18 @@
 +      }
 +
 +      if (current_gtp) {
***The diff for this file has been truncated for email.***

Other related posts:

  • » [kgtp] r940 committed - Update patch - kgtp