STAPREF(1)

๐Ÿ’– STAPREF(1) ๐Ÿ’–

okay bestie, welcome to stapref, aka the systemtap language reference โ€” this is your one-stop glow-up guide for the whole systemtap scripting language, from the General Commands Manual section of your local man pages. pull up a chair, grab a boba, and let's get into it ๐Ÿง‹โœจ


โœจ SYNOPSIS โœจ

stapref

๐ŸŒธ DESCRIPTION ๐ŸŒธ

it's the reference for the systemtap scripting language. that's it, that's the description. the whole language, right here, no cap ๐Ÿ’…


๐Ÿ‘‘ LANGUAGE ๐Ÿ‘‘

๐Ÿ”‘ Keywords

your reserved-word royalty, do not use these as names or they will absolutely call you out:

  • break
  • continue
  • delete
  • else
  • exit
  • foreach
  • for
  • function
  • global
  • private
  • if
  • in
  • next
  • probe
  • return
  • try/catch
  • while

๐Ÿงฎ Data Types and Operators

Integers

  • var1 = 5
  • global var2 = 10

Strings

  • var1 = "string1"
  • global var2 = "string2"

Associative Arrays

  • global array1[]
  • global array2[SIZE]
  • array[index] = 5

Context Variables

  • $var
  • $var$ โ€” this one is the pretty printed string form, she's dressed up ๐Ÿ’…

Binary numeric operators

  • * / % + - << >> >>> & ^ | && ||

Binary string operators

  • . โ€” that's string concatenation, gluing strings together like besties holding hands ๐Ÿซถ

Numeric assignment operators

  • = += -= *= /= %= >>= <<= &= ^= |=

String assignment operators

  • = .=

Unary numeric operators

  • + - ! ~ ++ --

Numeric & string comparison operators

  • < > <= >= == !=

Regular expression matching operators

  • =~ !~

Ternary operator

  • cond ? exp1 : exp2

Grouping operator

  • ( expression )

Array operators

  • array[index] โ€” that's the array read/write right there
  • [index] in array

Aggregation operator

  • var <<< value

๐Ÿ“ Statements

Jump Statements

  • continue
  • break
  • next โ€” early return from a probe, she leaves the party early, iconic
  • return expression โ€” from a function
  • try statement catch (message) statement

Selection Statements

  • if (expression) statement
  • else statement

Iteration Statements

  • foreach (variable in array) statement
  • foreach ([var1,var2,...] in array) statement
  • for (expression; expression; expression) statement
  • while (expression) statement

Declaration Statements

  • function name (variable : type, ...) { statement }
  • function name : type (variable : type, ...) { statement }
  • function name : type (variable : type, ...) %{ c_statement %}
  • probe probepoint { statement }
  • probe label = probepoint { statement }

๐Ÿ”ค Lexical Structure

Comments

  • # ... comment
  • // ... comment
  • /* ... comment ... */

Preprocessor

  • %( expression %? true_tokens %: false_tokens %)
  • @define label (variable, ...) %{ statement %}

๐Ÿ› ๏ธ Builtin Functions

Aggregation Builtin Functions

  • @avg (variable)
  • @count (variable)
  • @hist_linear (variable, N, N, N)
  • @hist_log (variable)
  • @max (variable)
  • @min (variable)
  • @sum (variable)

Output Builtin Functions

  • print (variable)
  • printf (format:string, variable, ...) โ€” where format is of the form: %[flags][width][.precision][length]specifier
  • printd (delimiter:string, variable, ...)
  • printdln (delimiter:string, variable, ...)
  • println ()
  • sprint:string (variable)
  • sprintf:string (format:string, variable, ...)

Variable Access Builtin Functions

  • @var ("varname[@src/FILE.c]"[, "module"]) โ€” static or global
  • @cast (variable, "type_name"[, "module"])
  • @defined (variable)
  • @probewrite (variable)

๐ŸŽฏ Probepoints

some of the more commonly used probepoints:

  • kernel.function(PATTERN) kernel.function(PATTERN).call
  • kernel.function(PATTERN).return
  • kernel.FUNCTION (PATTERN).return.maxactive(VALUE)
  • kernel.FUNCTION (PATTERN).inline
  • kernel.FUNCTION (PATTERN).label(LPATTERN)
  • module(MPATTERN).FUNCTION (PATTERN)
  • module(MPATTERN).FUNCTION (PATTERN).call
  • module(MPATTERN).FUNCTION (PATTERN).return.maxactive(VALUE)
  • module(MPATTERN).FUNCTION (PATTERN).inline
  • kernel.statement(PATTERN)
  • kernel.statement(ADDRESS).absolute
  • module(MPATTERN).statement(PATTERN)
  • kprobe.FUNCTION (FUNCTION)
  • kprobe.FUNCTION (FUNCTION).return
  • kprobe.module(NAME).FUNCTION (FUNCTION)
  • kprobe.module(NAME).FUNCTION (FUNCTION).return
  • kprobe.statement(ADDRESS).absolute
  • process.begin process("PATH").begin
  • process(PID).begin process.thread.begin
  • process("PATH").thread.begin
  • process(PID).thread.begin
  • process.end
  • process("PATH").end
  • process(PID).end
  • process.thread.end
  • process("PATH").thread.end
  • process(PID).thread.end
  • process("PATH").syscall
  • process(PID).syscall
  • process.syscall.return
  • process("PATH").syscall.return
  • process(PID).syscall.return
  • process("PATH").FUNCTION ("NAME")
  • process("PATH").statement("*@FILE.c:123")
  • process("PATH").FUNCTION ("*").return
  • process("PATH").FUNCTION ("myfun").label("foo")
  • process("PATH").mark("LABEL")
  • java("PNAME").class("CLASSNAME").method("PATTERN")
  • java("PNAME").class("CLASSNAME").method("PATTERN").return
  • java(PID).class("CLASSNAME").method("PATTERN")
  • java(PID).class("CLASSNAME").method("PATTERN").return
  • python3.module("MODULENAME").function("PATTERN")
  • python3.module("MODULENAME").function("PATTERN").return

๐Ÿงš Tapset Functions

some of the more commonly used tapset functions:

  • addr:long ()
  • backtrace:string ()
  • caller:string ()
  • caller_addr:long ()
  • cmdline_arg:string (N:long)
  • cmdline_args:string (N:long,m:long,delim:string)
  • cmdline_str:string ()
  • env_var:string (name:string)
  • execname:string ()
  • int_arg:long (N:long)
  • isinstr:long(s1:string,s2:string)
  • long_arg:long (N:long)
  • modname:string ()
  • module_name:string ()
  • pid:long ()
  • pn:string ()
  • pointer_arg:string (N:long)
  • pp:string ()
  • print_backtrace ()
  • probefunc:string ()
  • register:long(name:string)
  • str_replace:string(prnt_str:string,srch_str:string,rplc_str:string)
  • stringat:long(str:string,pos:long)
  • strlen:long(str:string)
  • strtol:long(str:string,base:long)
  • substr:string(str:string,start:long,length:long)
  • user_long:long(addr:long)
  • user_string:string(addr:long)

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

๐Ÿ’€ BUGS ๐Ÿ’€

found a bug? use the Bugzilla link of the project web page, or slide into our mailing list:


ngl if you got this far you're lowkey a systemtap legend already. go write some probes, bestie ๐Ÿซถ

and that's the whole page, babes โ€” this is stapref(1) from the General Commands Manual section, and the footer's just that same stapref(1) name stamped at the bottom like a little signature. no date, no version drama, just vibes. periodt ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from