OILS / benchmarks / systemtap.sh View on Github | oilshell.org

75 lines, 37 significant
1#!/usr/bin/env bash
2#
3# Following:
4# https://docs.python.org/3/howto/instrumentation.html
5#
6# Couldn't get this to work. Even building it from source doesn't work!
7# 'stap' invokes a compiler, and I get compiler errors.
8#
9# It appears to be very brittle.
10#
11# https://stackoverflow.com/questions/46047270/systemtap-error-on-ubuntu
12#
13# Usage:
14# ./systemtap.sh <function name>
15
16set -o nounset
17set -o pipefail
18set -o errexit
19
20deps() {
21 # 'stap' lives in systemtap package
22 sudo apt install systemtap systemtap-sdt-dev
23}
24
25stap-deps() {
26 # For DWARF debugging info, interesting.
27 sudo apt install libdw-dev libdw1
28}
29
30# NOTE: systemtap-3.2 is out, but doesn't compile on Ubuntu xenial!
31download() {
32 wget --no-clobber --directory _tmp \
33 https://sourceware.org/systemtap/ftp/releases/systemtap-3.1.tar.gz
34}
35
36extract() {
37 cd _tmp
38 tar -x -z < systemtap-3.1.tar.gz
39}
40
41readonly PY36=~/src/languages/Python-3.6.1
42
43build-python() {
44 pushd $PY36
45 # There is no --with-systemtap/
46 ./configure --with-dtrace
47 make -j 7
48 popd
49}
50
51# Default Python build doesn't have it
52elf() {
53 readelf -n $(which python3)
54 echo ---
55 # Now this has "stapsdt" -- SystemTap probe descriptors.
56 readelf -n $PY36/python
57}
58
59_demo() {
60 #local stp="$PWD/benchmarks/call-hierarchy.stp"
61
62 # C compile errors? It's getting further.
63 #local stp="$PY36/Lib/test/dtracedata/call_stack.stp"
64 local stp="$PY36/Lib/test/dtracedata/gc.stp"
65 #local stp="$PY36/Lib/test/dtracedata/assert_usable.stp"
66
67 local py="$PWD/test/sh_spec.py"
68
69 pushd $PY36
70 stap -v $stp -c "./python $py"
71 popd
72}
73demo() { sudo $0 _demo; }
74
75"$@"