public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Josh Triplett <josh@joshtriplett.org>
Subject: [PATCH 2/8] tracing: Add vim script to enable folding for function_graph traces
Date: Wed, 26 Aug 2009 00:59:47 -0400	[thread overview]
Message-ID: <20090826050050.893406395@goodmis.org> (raw)
In-Reply-To: 20090826045945.201094161@goodmis.org

[-- Attachment #1: 0002-tracing-Add-vim-script-to-enable-folding-for-functio.patch --]
[-- Type: text/plain, Size: 3104 bytes --]

From: Josh Triplett <josh@joshtriplett.org>

function_graph traces look like nested function calls, complete with
braces denoting the start and end of functions.  function-graph-fold.vim
teaches vim how to fold these functions, to make it more convenient to
browse them.

To use, :source function-graph-fold.vim while viewing a function_graph
trace, or use "view -S function-graph-fold.vim some-trace" to load it
from the command-line together with a trace.  You can then use the usual
vim fold commands, such as "za", to open and close nested functions.
While closed, a fold will show the total time taken for a call, as would
normally appear on the line with the closing brace.  Folded functions
will not include finish_task_switch(), so folding should remain
relatively sane even through a context switch.

Note that this will almost certainly only work well with a single-CPU
trace (e.g. trace-cmd report --cpu 1).  It also takes some time to run
(a few seconds for a large trace on my laptop).  Nevertheless, I found
it very handy to get an overview of a trace and then drill down on
problematic calls.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
LKML-Reference: <20090806145701.GB7661@feather>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 Documentation/trace/function-graph-fold.vim |   42 +++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/trace/function-graph-fold.vim

diff --git a/Documentation/trace/function-graph-fold.vim b/Documentation/trace/function-graph-fold.vim
new file mode 100644
index 0000000..0544b50
--- /dev/null
+++ b/Documentation/trace/function-graph-fold.vim
@@ -0,0 +1,42 @@
+" Enable folding for ftrace function_graph traces.
+"
+" To use, :source this file while viewing a function_graph trace, or use vim's
+" -S option to load from the command-line together with a trace.  You can then
+" use the usual vim fold commands, such as "za", to open and close nested
+" functions.  While closed, a fold will show the total time taken for a call,
+" as would normally appear on the line with the closing brace.  Folded
+" functions will not include finish_task_switch(), so folding should remain
+" relatively sane even through a context switch.
+"
+" Note that this will almost certainly only work well with a
+" single-CPU trace (e.g. trace-cmd report --cpu 1).
+
+function! FunctionGraphFoldExpr(lnum)
+  let line = getline(a:lnum)
+  if line[-1:] == '{'
+    if line =~ 'finish_task_switch() {$'
+      return '>1'
+    endif
+    return 'a1'
+  elseif line[-1:] == '}'
+    return 's1'
+  else
+    return '='
+  endif
+endfunction
+
+function! FunctionGraphFoldText()
+  let s = split(getline(v:foldstart), '|', 1)
+  if getline(v:foldend+1) =~ 'finish_task_switch() {$'
+    let s[2] = ' task switch  '
+  else
+    let e = split(getline(v:foldend), '|', 1)
+    let s[2] = e[2]
+  endif
+  return join(s, '|')
+endfunction
+
+setlocal foldexpr=FunctionGraphFoldExpr(v:lnum)
+setlocal foldtext=FunctionGraphFoldText()
+setlocal foldcolumn=12
+setlocal foldmethod=expr
-- 
1.6.3.3

-- 

  parent reply	other threads:[~2009-08-26  5:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-26  4:59 [PATCH 0/8] [GIT PULL] tracing: updates for 2.6.32 Steven Rostedt
2009-08-26  4:59 ` [PATCH 1/8] tracing/sched: show CPU task wakes up on in trace event Steven Rostedt
2009-08-26  4:59 ` Steven Rostedt [this message]
2009-08-26  4:59 ` [PATCH 3/8] tracing/filters: Add filter_type to struct ftrace_event_field Steven Rostedt
2009-08-26  4:59 ` [PATCH 4/8] tracing/filters: Add __field_ext() to TRACE_EVENT Steven Rostedt
2009-08-26  4:59 ` [PATCH 5/8] tracing/filters: Support filtering for char patches prog prog2 quilt-mail x strings Steven Rostedt
2009-08-26  4:59 ` [PATCH 6/8] ftrace: Move setting of clock-source out of options Steven Rostedt
2009-08-26  4:59 ` [PATCH 7/8] tracing/events: fix the include file dependencies Steven Rostedt
2009-08-26  4:59 ` [PATCH 8/8] tracing: add comments to explain TRACE_EVENT out of protection Steven Rostedt
2009-08-26  6:27 ` [PATCH 0/8] [GIT PULL] tracing: updates for 2.6.32 Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090826050050.893406395@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox