[kgtp] r922 committed - Add $current_task_pid

  • From: kgtp@xxxxxxxxxxxxxx
  • To: kgtp@xxxxxxxxxxxxx
  • Date: Tue, 21 Feb 2012 04:07:43 +0000

Revision: 922
Author:   teawater
Date:     Mon Feb 20 20:06:54 2012
Log:      Add $current_task_pid

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

Modified:
 /trunk/gtp.c
 /trunk/gtp.txt
 /trunk/gtp_for_review.patch
 /wiki/HOWTO.wiki

=======================================
--- /trunk/gtp.c        Fri Feb 17 06:49:57 2012
+++ /trunk/gtp.c        Mon Feb 20 20:06:54 2012
@@ -432,6 +432,7 @@
        GTP_VAR_SOFTIRQ_COUNT_ID,
        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,
 };

@@ -464,6 +465,15 @@
 #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,
+};
+#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,
@@ -2407,6 +2417,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;
=======================================
--- /trunk/gtp.txt      Fri Feb 17 07:11:56 2012
+++ /trunk/gtp.txt      Mon Feb 20 20:06:54 2012
@@ -2,7 +2,7 @@
                =========================================
                By Hui Zhu <teawater@xxxxxxxxx>
                https://code.google.com/p/kgtp/wiki/HOWTO
-               2012-02-17
+               2012-02-21

 Table of contents
 -----------------
@@ -34,7 +34,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
@@ -635,9 +635,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,
@@ -646,6 +646,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
=======================================
--- /trunk/gtp_for_review.patch Sat Feb 18 19:09:33 2012
+++ /trunk/gtp_for_review.patch Mon Feb 20 20:06:54 2012
@@ -1,7 +1,5 @@
 ---
-
----
- Documentation/trace/gtp.txt            | 1517 +++++
+ 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
@@ -10,20 +8,20 @@
  kernel/events/core.c                   |   14
  lib/Kconfig.debug                      |   10
  lib/Makefile                           |    4
- lib/gtp.c | 8452 +++++++++++++++++++++++++++++++++ + lib/gtp.c | 8468 +++++++++++++++++++++++++++++++++
  lib/gtp_rb.c                           |  495 +
  scripts/gtp/getgtprsp.pl               |  137
  scripts/gtp/getmod.py                  |  132
- 13 files changed, 11061 insertions(+), 2 deletions(-)
+ 13 files changed, 11079 insertions(+), 2 deletions(-)

 --- /dev/null
 +++ b/Documentation/trace/gtp.txt
-@@ -0,0 +1,1517 @@
+@@ -0,0 +1,1519 @@
 +              Linux Kernel GDB tracepoint module (KGTP)
 +              =========================================
 +              By Hui Zhu <teawater@xxxxxxxxx>
 +              https://code.google.com/p/kgtp/wiki/HOWTO
-+              2012-02-17
++              2012-02-21
 +
 +Table of contents
 +-----------------
@@ -55,7 +53,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
@@ -656,9 +654,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,
@@ -667,6 +665,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
@@ -1951,7 +1951,7 @@
 +gtp.o: gtp_rb.c
 --- /dev/null
 +++ b/lib/gtp.c
-@@ -0,0 +1,8452 @@
+@@ -0,0 +1,8468 @@
 +/*
 + * Kernel GDB tracepoint module.
 + *
@@ -2232,6 +2232,7 @@
 +      GTP_VAR_SOFTIRQ_COUNT_ID,
 +      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,
 +};
 +
@@ -2264,6 +2265,15 @@
 +#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,
++};
++#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,
@@ -3883,6 +3893,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;
=======================================
--- /wiki/HOWTO.wiki    Fri Feb 17 07:11:56 2012
+++ /wiki/HOWTO.wiki    Mon Feb 20 20:06:54 2012
@@ -1,5 +1,5 @@
 #labels Phase-QA,Phase-Deploy
-Update in 2012-02-17
+Update in 2012-02-21
 <wiki:toc max_depth="3" />
 = What is KGTP =
*KGTP* is a *realtime* and *lightweight* Linux Kernel *debugger* and *tracer*.<br><br>
@@ -386,11 +386,12 @@
 }}}
These GDB commands define a tracepoint that count the times that call vfs_read of each CPU.

-=== Special trace state variables $current_task, $current_thread_info, $cpu_id, $dump_stack, $printk_level, $printk_format, $printk_tmp ,$clock, $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, $hardirq_count, $softirq_count and $irq_count === KGTP special trace state variables $current_task, $current_thread_info, $cpu_id and $clock can very easy to access to some special value.
 You can see them when GDB connects to the KGTP.
 You can use them in tracepoint conditions or actions. <br>
Access $current_task in tracepoint condition and action will get that returns of get_current().<br> +Access $current_task_pid in tracepoint condition and action will get that returns of get_current()->pid.<br> Access $current_thread_info in tracepoint condition and action will get that returns of current_thread_info().<br> Access $cpu_id in tracepoint condition and action will get that returns of smp_processor_id().<br> Access $clock in tracepoint condition and action will get that returns of local_clock() that return the timestamp in nanoseconds.<br>

Other related posts:

  • » [kgtp] r922 committed - Add $current_task_pid - kgtp