This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Systemtap Upcoming Feature: Address to File:Line Mapping
- From: Abe Jakop <ajakop at redhat dot com>
- To: systemtap at sourceware dot org
- Date: Thu, 18 Dec 2014 16:52:00 -0500 (EST)
- Subject: Systemtap Upcoming Feature: Address to File:Line Mapping
- Authentication-results: sourceware.org; auth=none
Hello everyone,
I have been working on a new feature for SystemTap to provide
address to file:line mappings. The goal of this email is to
provide details and demonstrate how to use the new feature.
To implement this feature, line debugging information is
retrieved and stored in a generated header for processing
during runtime. The line data is used to determine an
approximate line number to match the given address.
As for using this new feature, there are two new tapset
functions, usymfileline() and symfileline(). The former
requires a user-space address, and a kernel address
for the the latter.
These functions return a string containing the file and line
number based on the provided address.
Similar to [u]symname(), if the address given cannot be
mapped to a line number or filename, the given address is
returned as a hexadecimal number.
For testing purposes, see branch ajakop/12276 on the
SystemTap repo:
https://sourceware.org/git/gitweb.cgi?p=systemtap.git
____
NOTE
Since this feature stores line data for runtime access,
using this feature may result in large probe modules.
_____
USAGE
A basic example of the feature is to print out a list of
what statements are executed.
Take the c program below, for example, which will just
call a few functions.
linenumbers2.c
===============
1 void func4 () {
2 return;
3 }
4
5 void func3 () {
6 func4();
7 }
linenumbers1.c
===============
1 #include "linenumbers2.c"
2
3 void func2 () {
4 func4();
5 }
6
7 void func1 (int num) {
8 for(; num > 0; num--)
9 func2();
10 func3();
11 }
12
13 int main () {
14 func1 (2);
15 }
The stap script below will print out the file name and
line number for each statement the probe hits.
linenumbers.stp
===============
1 probe process.statement("*") {
2 printf("addr: %#x, file and line: %s\n",
3 addr(), usymfileline(addr()) )
4 }
Running the script from above, this is the output.
$ stap linenumbers.stp -c ./linenumbers
addr: 0x400544, file and line: linenumbers1.c:13
addr: 0x400517, file and line: linenumbers1.c:7
addr: 0x400507, file and line: linenumbers1.c:3
addr: 0x4004f0, file and line: linenumbers2.c:1
addr: 0x400507, file and line: linenumbers1.c:3
addr: 0x4004f0, file and line: linenumbers2.c:1
addr: 0x4004f7, file and line: linenumbers2.c:5
addr: 0x4004f0, file and line: linenumbers2.c:1
===============
This addition to SystemTap's tapset library will
hopefully be beneficial to users for gathering
and printing out relevant information.
Comments and feedback are always welcome.
Abegail Jakop