From: Manuel Naranjo <manuel@aircable.net>
To: BlueZ <linux-bluetooth@vger.kernel.org>
Subject: [PATCH 2/2] Add function tracer formatter
Date: Mon, 19 Jul 2010 13:26:57 -0300 [thread overview]
Message-ID: <4C447CD1.5000402@aircable.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 358 bytes --]
This patch adds the script available at
http://www.logix.cz/michal/devel/CygProfiler to the tools folder, I
don't know if it makes sense to install this into somewhere as this is
only developers only intendeed.
The way to use it is:
perl tools/cyg-resolve.pl src/.libs/bluetoothd bluetoothd-log.<PID>
Signed-off-by: Manuel Naranjo <manuel@aircable.net>
[-- Attachment #2: 0002-added-perl-script-to-resolve-symbols-on-tracing.patch --]
[-- Type: text/plain, Size: 3019 bytes --]
>From 43691108561e8e39226ccd9064a05690ba48bd66 Mon Sep 17 00:00:00 2001
From: Manuel Francisco Naranjo <manuel@aircable.net>
Date: Mon, 19 Jul 2010 13:18:43 -0300
Subject: [PATCH 2/2] added perl script to resolve symbols on tracing
---
tools/cyg-resolve.pl | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 111 insertions(+), 0 deletions(-)
create mode 100644 tools/cyg-resolve.pl
diff --git a/tools/cyg-resolve.pl b/tools/cyg-resolve.pl
new file mode 100644
index 0000000..5d56bd3
--- /dev/null
+++ b/tools/cyg-resolve.pl
@@ -0,0 +1,111 @@
+#!/usr/bin/perl
+
+#
+# cyg-resolve.pl - CygProfiler resolver
+#
+# Michal Ludvig <michal@logix.cz>
+# http://www.logix.cz/michal/devel
+#
+# Use this script to parse the output of the CygProfile suite.
+#
+
+use strict;
+use warnings;
+no warnings 'portable';
+use diagnostics;
+use English;
+
+my %symtab;
+my ($binfile, $textfile, $levelcorr);
+
+$OUTPUT_AUTOFLUSH=1;
+
+&help() if($#ARGV < 1);
+$binfile=$ARGV[0];
+&help() if($binfile =~ /--help/);
+$textfile=($#ARGV > 0 ? $ARGV[1] : "cygprof.log");
+$levelcorr=($#ARGV > 1 ? $ARGV[2] : -1);
+
+&main();
+
+# ==== Subs
+
+sub help()
+{
+ printf("CygProgile parser, Michal Ludvig <michal\@logix.cz>, 2002-2003\n");
+ printf("Usage: %s <bin-file> <log-file> [<correction>]\n", $0);
+ printf("\t<bin-file> Program that generated the logfile.\n");
+ printf("\t<log-file> Logfile generated by the profiled program.\n");
+ printf("\t<correction> Correction of the nesting level.\n");
+ exit;
+}
+
+sub main()
+{
+ my($offset, $type, $function);
+ my($nsym, $nfunc);
+
+ $nsym=0;
+ $nfunc=0;
+
+ open(NM, "nm $binfile|") or die("Unable to run 'nm $binfile': $!\n");
+ printf("Loading symbols from $binfile ... ");
+
+ while(<NM>)
+ {
+ $nsym++;
+ next if(!/^([0-9A-F]+) (.) (.+)$/i);
+ $offset=hex($1); $type=$2; $function=$3;
+ next if($type !~ /[tT]/);
+ $nfunc++;
+ $symtab{$offset}=$function;
+ }
+ printf("OK\nSeen %d symbols, stored %d function offsets\n", $nsym, $nfunc);
+ close(NM);
+
+ open(TEXT, "$textfile")
+ or die("Unable to open '$textfile': $!\n");
+
+ if ($levelcorr == -1)
+ {
+ $levelcorr = 0;
+ while(<TEXT>)
+ {
+ if ((/^.*[+-] (-*\d+)/) && ($1 < -$levelcorr))
+ { $levelcorr = -$1; }
+ }
+ printf("Level correction set to %d\n", $levelcorr);
+ seek(TEXT, 0, 0);
+ }
+
+ while(<TEXT>)
+ {
+ # Change the pattern if the output format
+ # of __cyg_...() functions has changed.
+ if(!/(.*)([+-]) (-*\d+) 0x([[:xdigit:]]+) 0x([[:xdigit:]]+)\s*(\d*)/)
+ { print $_; next; }
+ else
+ {
+ my $prolog=$1;
+ my $type=$2;
+
+ my $level=$3 + $levelcorr;
+ my $off1=hex($4);
+ my $off2=hex($5);
+ my $pid=$6;
+
+ printf("$prolog\n") if ($prolog);
+
+ # Don't print exits
+ next if($type eq "-");
+ my $sym=(defined($symtab{$off1})?$symtab{$off1}:"???");
+
+ printf("\t%s %2d 0x%x (from 0x%x) %*s%s\n",
+ $type, $level, $off1, $off2,
+ $level+1, " ", "$sym()");
+ }
+ }
+ close(TEXT);
+
+ printf("done\n");
+}
--
1.6.4.4
reply other threads:[~2010-07-19 16:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4C447CD1.5000402@aircable.net \
--to=manuel@aircable.net \
--cc=linux-bluetooth@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.