Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active August 9, 2017 02:13
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeOam/83397174f2f1575f06f1 to your computer and use it in GitHub Desktop.
Save JeOam/83397174f2f1575f06f1 to your computer and use it in GitHub Desktop.
SystemTap Tips
@JeOam
Copy link
Author

JeOam commented Jan 19, 2016

Install SystemTap in Ubuntu 14.04:

sudo apt-get install systemtap
sudo apt-get install gcc
sudo apt-get install linux-headers-$(uname -r)

Test the installation with the HelloWorld example:

sudo stap -e 'probe begin { printf("Hello, World!\n"); exit() }'

You should see Hello, World! is emitted in the console.


Install debug symbols file:
Save the following codes as run.sh, and run: sh run.sh

codename=$(lsb_release -c | awk  '{print $2}')
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ ${codename}      main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-updates  main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-proposed main restricted universe multiverse
EOF

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
sudo apt-get update
sudo apt-get install linux-image-$(uname -r)-dbgsym

Test the installation with this example which will print hello world to the console when the system call sys_call is called.:

sudo stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'

Refs: Install SystemTap in Ubuntu 14.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment