From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19065 invoked by alias); 11 Feb 2008 16:29:40 -0000 Received: (qmail 19038 invoked by uid 9697); 11 Feb 2008 16:29:40 -0000 Date: Mon, 11 Feb 2008 16:29:00 -0000 Message-ID: <20080211162940.19023.qmail@sourceware.org> From: pmachata@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Support -stack in ftrace X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 8385f074781658054b44640914b94edeaf1e2c93 X-Git-Newrev: 7cd0b6627235a9e66fe836693d83dc496a5c7a89 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00191.txt.bz2 The branch, master has been updated via 7cd0b6627235a9e66fe836693d83dc496a5c7a89 (commit) via c92649be731ef76400fd4cebf5c049578f6dd254 (commit) from 8385f074781658054b44640914b94edeaf1e2c93 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 7cd0b6627235a9e66fe836693d83dc496a5c7a89 Author: Petr Machata Date: Mon Feb 11 17:29:10 2008 +0100 Support -stack in ftrace commit c92649be731ef76400fd4cebf5c049578f6dd254 Author: Petr Machata Date: Mon Feb 11 16:26:02 2008 +0100 Update manual page of ftrace ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 9 ++ frysk-core/frysk/bindir/ftrace.java | 17 ++++- frysk-core/frysk/bindir/ftrace.xml | 138 ++++++++++++++++++++-------------- 3 files changed, 105 insertions(+), 59 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index b4b46e0..7bf2104 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,5 +1,14 @@ 2008-02-11 Petr Machata + * ftrace.java: Support -stack. + * ftrace.xml: Describe -stack. + +2008-02-11 Petr Machata + + * ftrace.xml: Describe -sys option, remove description of -S and -t. + +2008-02-11 Petr Machata + * ftrace.java: Refactoring. (Rule.checkVersionMatches): Moved from MyFtraceController. (Rule.checkNameMatches): Likewise. diff --git a/frysk-core/frysk/bindir/ftrace.java b/frysk-core/frysk/bindir/ftrace.java index 281063d..e61329e 100644 --- a/frysk-core/frysk/bindir/ftrace.java +++ b/frysk-core/frysk/bindir/ftrace.java @@ -257,9 +257,15 @@ class MyFtraceController // Which symbols should yield a stack trace. private HashSet symbolsStackTraceSet = new HashSet(); + private boolean stackTraceEverything = false; + + public void stackTraceEverything() { + stackTraceEverything = true; + } public boolean shouldStackTraceOnSymbol(Symbol symbol) { - return symbolsStackTraceSet.contains(symbol); + return stackTraceEverything + || symbolsStackTraceSet.contains(symbol); } public MyFtraceController() { } @@ -306,7 +312,8 @@ class MyFtraceController Map ret = new HashMap(); for (Iterator it = workingSet.iterator(); it.hasNext(); ) { Object syscall = it.next(); - ret.put(syscall, Boolean.valueOf(stackTraceSet.contains(syscall))); + ret.put(syscall, Boolean.valueOf(stackTraceEverything + || stackTraceSet.contains(syscall))); } return ret; } @@ -596,6 +603,12 @@ class ftrace symRules.add(arg); } }); + + parser.add(new Option("stack", "stack trace on every traced entity") { + public void parsed(String arg) { + controller.stackTraceEverything(); + } + }); } public void run(String[] args) diff --git a/frysk-core/frysk/bindir/ftrace.xml b/frysk-core/frysk/bindir/ftrace.xml index 30bb6b8..ab67392 100644 --- a/frysk-core/frysk/bindir/ftrace.xml +++ b/frysk-core/frysk/bindir/ftrace.xml @@ -73,12 +73,11 @@ -m -o=FILE -p=PID - -s=SYSCALL[,SYSCALL...] - -S - -t=SYSCALL[,SYSCALL...] + -sys=SYSCALL[,SYSCALL...] -plt=RULE[,RULE...] -dyn=RULE[,RULE...] -sym=RULE[,RULE...] + -stack -- command arguments... @@ -121,41 +120,31 @@ System Call Tracing - System calls are traced by default. - - - -S - - Suppress system call tracing. - - - - - -s=SYSCALL[,SYSCALL...] - - Stack trace on this set of system calls. - When stack-traced syscall is encountered, a stack - trace of the calling task is printed out. Each - SYSCALL entry is name - of one system call. - - + + -sys=SYSCALL[,SYSCALL...] + + Trace system calls that match given + SYSCALL ruleset are. See + below for description of + SYSCALL syntax. + + - - -t=SYSCALL[,SYSCALL...] - - Explicitly define syscalls that should be - traced. Each SYSCALL - entry is name of one system call. - - + + -stack + + Stack trace when traced system call is hit. Note + that this option also applies to traced symbols. If you + need to cherry-pick which event should stack trace, use + # operator described in sections below. + + - - Entry Point Tracing + Symbol Tracing @@ -169,20 +158,21 @@ - -plt=RULE[,RULE...] + -plt=SYMBOL[,SYMBOL...] - Trace library calls done via PLT entries matching each - given RULE. By tracing PLT - entry, you effectively trace calls done FROM given library - or executable, and generally can't say which library the - call leads TO. (At least for now. Ftrace may grow brains - for this in future.) See below for description of - RULE syntax. + Trace library calls done via PLT entries matching + each given SYMBOL ruleset. + By tracing PLT entry, you effectively trace calls done + FROM given library or executable, and generally can't + say which library the call leads TO. (At least for now. + Ftrace may grow brains for this in future.) See below + for description of SYMBOL + rule syntax. - -dyn=RULE[,RULE...] + -dyn=SYMBOL[,SYMBOL...] Trace calls through the symbol entry points. By tracing entry points, you catch all calls that end up at @@ -193,19 +183,29 @@ functions call each other in the library internals. On the other hand, it may be useful to cherry pick few entry points to see when or if they are called, and with which arguments. - See below for description of RULE - syntax. + See below for description of SYMBOL + rule syntax. - -sym=RULE[,RULE...] + -sym=SYMBOL[,SYMBOL...] Just like , but doesn't look for symbols in dynamic symbol table, but normal symbol table. (Which doesn't have to be present, e.g. when a binary is stripped.) See below for description of - RULE syntax. + SYMBOL rule syntax. + + + + + -stack + + Stack trace when traced symbol is hit. Note that + this option also applies to traced system calls. If you + need to cherry-pick which event should stack trace, use + # operator described in sections below. @@ -228,7 +228,7 @@ - RULE SYNTAX + SYMBOL RULE SYNTAX To decide which PLT slots or entry points should be traced, following process takes place. Initial working set is empty. @@ -277,15 +277,44 @@ "foo@@".) Empty rule is considered to miss all components. If you - need to match empty symbol, use regular expression "^$". + need to match an empty symbol, use regular expression "^$". + + + + SYSCALL RULE SYNTAX + + Under the presence of the option, all + system calls are always traced. This is a limitation of the + ptrace layer. The system call rules however serve as a simple way + of filtering the output. + + System call rule syntax and semantics are the same as the + symbol rule syntax: + [-][#]pattern + + System call selection pattern syntax is then as + follows: + + syscall name|syscall number + + When the pattern is empty, then it matches all system calls + known to frysk. When the pattern is simple number + (e.g. "12"), then the pattern matches system call with + the given number. Otherwise the pattern is considered to be + written using extended regular expression syntax, and matched + agains system call names. EXAMPLES - Trace all plt library calls: + Trace all system calls: + ftrace -sys= ls + Trace variants of stat system call and moreover a system call #3: + ftrace -sys=".*stat.*",3 ls + Trace all library calls: ftrace -plt= ls Trace all library calls to functions that contain substring "write" in their names: @@ -352,22 +381,17 @@ BUGS - The option parser is greedy when looking for options so running ftrace on a program that uses options can be a problem, use -- to split between ftrace and the program. So change from: + I think ftrace doesn't handle tracing one function through both entry point and plt. + The option parser is greedy when looking for options so running ftrace on a program that uses options can be a problem, use -- to split between ftrace and the program. So change from: ~/prefix/bin/ftrace ~/prefix/lib64/frysk/funit --arch 32 frysk.proc.TestAbandon to ~/prefix/bin/ftrace -- ~/prefix/lib64/frysk/funit --arch 32 frysk.proc.TestAbandon - Report bugs to - http://sources.redhat.com/ftrace/ . + Report bugs to + http://sources.redhat.com/frysk/ . - - BUGS - I think ftrace doesn't handle tracing one function through both entry point and plt. - Report bugs to http://sources.redhat.com/frysk. - - hooks/post-receive -- frysk system monitor/debugger