OpenBSD CVS

CVS log for src/usr.sbin/btrace/btrace.c


[BACK] Up to [local] / src / usr.sbin / btrace

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.91 / (download) - annotate - [select for diffs], Tue May 21 05:00:48 2024 UTC (2 weeks, 4 days ago) by jsg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.90: +1 -2 lines
Diff to previous 1.90 (colored)

remove prototypes with no matching function and externs with no var
partly checked by millert@

Revision 1.90 / (download) - annotate - [select for diffs], Sat Mar 30 07:41:45 2024 UTC (2 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.89: +18 -16 lines
Diff to previous 1.89 (colored)

Implement else branching logic including 'else if'.

Statement lists for if & else conditions are now wrapped in a new
'struct bt_cond'.  Handling B_AC_TEST statements moved to stmt_eval()
to handle nested conditional statements.

From Christian Ludwig christian_ludwig at genua.de

Revision 1.89 / (download) - annotate - [select for diffs], Tue Feb 27 12:38:12 2024 UTC (3 months, 1 week ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.88: +4 -1 lines
Diff to previous 1.88 (colored)

Make it possible to check for existing string in maps.

Revision 1.88 / (download) - annotate - [select for diffs], Sat Feb 24 19:42:54 2024 UTC (3 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.87: +61 -45 lines
Diff to previous 1.87 (colored)

Check for builtins used inside tuple to ask the kernel to copyout specific data.

Allow to save stacktrace and process name in tuples.

Revision 1.87 / (download) - annotate - [select for diffs], Sat Feb 24 17:05:59 2024 UTC (3 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.86: +12 -1 lines
Diff to previous 1.86 (colored)

Implement 'store' for maps.

A current limitation is the value read from a map is converted to an
integer.  To preserve the original type we have to make maps aware of
the type of its elements.

Revision 1.86 / (download) - annotate - [select for diffs], Sat Feb 24 16:19:49 2024 UTC (3 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.85: +7 -1 lines
Diff to previous 1.85 (colored)

Implement 'store' for all builtins, they are either string or integer.

Revision 1.85 / (download) - annotate - [select for diffs], Mon Feb 12 15:12:09 2024 UTC (3 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.84: +6 -2 lines
Diff to previous 1.84 (colored)

Fix tuple & string comparisons in maps.

Revision 1.84 / (download) - annotate - [select for diffs], Mon Feb 5 15:11:35 2024 UTC (4 months ago) by mpi
Branch: MAIN
Changes since 1.83: +4 -4 lines
Diff to previous 1.83 (colored)

Print statistics on stderr to be able to redirect bt(5) script output.

From Christian Ludwig.

Revision 1.83 / (download) - annotate - [select for diffs], Thu Jan 25 20:50:58 2024 UTC (4 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.82: +8 -3 lines
Diff to previous 1.82 (colored)

Return 0 when accessing an argument not defined in a probe.

Adapted from a fix from Christian Ludwig.

Revision 1.82 / (download) - annotate - [select for diffs], Tue Jan 23 22:04:15 2024 UTC (4 months, 2 weeks ago) by mpi
Branch: MAIN
Changes since 1.81: +3 -3 lines
Diff to previous 1.81 (colored)

Consider the whole tuple when reading a map entry whose key is that tuple.

Previously only the first element of the tuple was considered.  This led to
the introduction of new map entries.

Reported by Christian Ludwig.

Revision 1.81 / (download) - annotate - [select for diffs], Fri Nov 10 18:56:21 2023 UTC (6 months, 4 weeks ago) by jasper
Branch: MAIN
Changes since 1.80: +1 -2 lines
Diff to previous 1.80 (colored)

zap some unused includes

Revision 1.80 / (download) - annotate - [select for diffs], Sun Oct 22 19:30:35 2023 UTC (7 months, 2 weeks ago) by cheloha
Branch: MAIN
Changes since 1.79: +44 -20 lines
Diff to previous 1.79 (colored)

bt(5), btrace(8): execute END probe and print non-empty maps upon exit()

BPFTrace's exit() statement executes the END probe (if any) and prints
the contents of all non-empty maps before terminating the interpreter.

Implement this in btrace(8) with a halting check after each statement.
If a statement causes the program to halt, the condition bubbles up to
the top-level evaluation loop and causes rules_teardown() to run
immediately.

btrace(8) still performs a full rules_setup() if exit() is called
during the BEGIN probe, though the top-level evaluation loop is never
run.

One edge-like case: an exit() from the END probe is treated as an
early return; END is not executed multiple times.

Thread: https://marc.info/?l=openbsd-tech&m=169765169420751&w=2

ok mpi@

Revision 1.79 / (download) - annotate - [select for diffs], Thu Oct 12 15:16:44 2023 UTC (7 months, 3 weeks ago) by cheloha
Branch: MAIN
Changes since 1.78: +6 -1 lines
Diff to previous 1.78 (colored)

bt(5), btrace(8): add support for binary modulo operator ('%')

Link: https://marc.info/?l=openbsd-tech&m=169695435209410&w=2

ok mpi@

Revision 1.78 / (download) - annotate - [select for diffs], Fri Sep 15 10:59:02 2023 UTC (8 months, 3 weeks ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.77: +3 -3 lines
Diff to previous 1.77 (colored)

Also update usage() to include [-p file].

Revision 1.77 / (download) - annotate - [select for diffs], Wed Sep 13 13:47:58 2023 UTC (8 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.76: +2 -1 lines
Diff to previous 1.76 (colored)

Properly evaluate variables when inserting them into a map.

Somehow missed in previous, regression reported by anton@.

Revision 1.76 / (download) - annotate - [select for diffs], Mon Sep 11 19:01:26 2023 UTC (8 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.75: +153 -21 lines
Diff to previous 1.75 (colored)

Implement tuples, needed to export per-CPU scheduling data.

It is now possible to save and print immutable arrays as below:

..$t = (1, 42, "something");
..printf("%d %s\n", $t.1, $t.2);

Also add support for evaluating builtin in order to save them in variables
(required by tuples)

Revision 1.75 / (download) - annotate - [select for diffs], Sat Sep 2 15:16:12 2023 UTC (9 months ago) by dv
Branch: MAIN
Changes since 1.74: +12 -2 lines
Diff to previous 1.74 (colored)

btrace(8): fix probe builtin in BEGIN/END.

Resolves segfaults when using probe within BEGIN or END.

ok mpi@

Revision 1.74 / (download) - annotate - [select for diffs], Wed Aug 16 13:07:11 2023 UTC (9 months, 3 weeks ago) by dv
Branch: MAIN
Changes since 1.73: +4 -12 lines
Diff to previous 1.73 (colored)

Backout changes for btrace(8) argN builtins.

Talking with mpi@, going to rework this to be part of the parser.
Reverts commit 0iIzGtIFgBXVfbNa.

Revision 1.73 / (download) - annotate - [select for diffs], Tue Aug 15 20:51:45 2023 UTC (9 months, 3 weeks ago) by dv
Branch: MAIN
Changes since 1.72: +13 -5 lines
Diff to previous 1.72 (colored)

btrace(8): fix out of bounds read using argN in BEGIN/END.

The argN builtins aren't valid in BEGIN or END actions. The fake
probe number btrace uses to facilitate other valid builtins caused
an out of bound read of an array, producing a segfault.

Change the fake probe number to 0 as it's an unsigned int and check
for that condition.

Adds asserts near other probe array indexing to catch future issues.

ok kn@

Revision 1.72 / (download) - annotate - [select for diffs], Sun Aug 13 09:52:47 2023 UTC (9 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.71: +9 -1 lines
Diff to previous 1.71 (colored)

Add support for storing builtin TID and PID in variables.

Revision 1.71 / (download) - annotate - [select for diffs], Tue Jun 27 14:17:00 2023 UTC (11 months, 1 week ago) by claudio
Branch: MAIN
Changes since 1.70: +43 -19 lines
Diff to previous 1.70 (colored)

Make it possible to store the kstack or ustack in a map (as value, not key).
Additionally fix the bacmp() function to work on integers and strings.
bacmp() is used when maps are printed out since the output is sorted by value.
Also adjust the rule parser to look into correctly into if branches to figure
out which values to request from the kernel.
OK kn@

Revision 1.70 / (download) - annotate - [select for diffs], Fri May 12 14:14:16 2023 UTC (12 months, 4 weeks ago) by claudio
Branch: MAIN
Changes since 1.69: +58 -13 lines
Diff to previous 1.69 (colored)

btrace(8) support to symbolize utrace addresses.

This only works for a single static binary where everything was compiled
with -fno-omit-frame-pointer since the stack unwinder requires the
frame-pointer.

A possible btrace script to capture performace of a single process is:
profile:hz:100 / pid == $1 / {
        @[ustack] = count();
}
Then using btrace -p program uprofile.bt `pgrep program` will collect
the information for program.

This is far from perfect but should allow other people to play with this
and hopefully improve work.
OK mpi@

Revision 1.69 / (download) - annotate - [select for diffs], Fri Mar 10 23:02:30 2023 UTC (14 months, 4 weeks ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.68: +69 -36 lines
Diff to previous 1.68 (colored)

btrace(8) retrieves the types of the arguments of each tracepoint
from the kernel.  Add them to a cache when needed, and print them
with btrace -l.  If the argument is of type int, print the value
as %d signed integer.  This gives pretty output for refcnt changes.
All other types still use %ul.
The probe and argument number can be used as array index.  Remove
the qsort and search for probe number to simplify the code.  Use
array index for both probes and argument types.
OK mpi@

Revision 1.68 / (download) - annotate - [select for diffs], Wed Dec 28 21:30:16 2022 UTC (17 months, 1 week ago) by jmc
Branch: MAIN
Changes since 1.67: +3 -3 lines
Diff to previous 1.67 (colored)

spelling fixes; from paul tagliamonte
any parts of his diff not taken are noted on tech

Revision 1.67 / (download) - annotate - [select for diffs], Sat Nov 12 14:19:08 2022 UTC (18 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.66: +59 -5 lines
Diff to previous 1.66 (colored)

Add support for string comparison in filters.

It is now possible to filter by process name, like:

syscall:mmap:entry
/comm == "ld"/
{
...
}

Currently the parser treats C-string like any other expression member even
if arithmetic operations do no apply to strings.

Revision 1.66 / (download) - annotate - [select for diffs], Fri Nov 11 22:43:09 2022 UTC (18 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.65: +3 -1 lines
Diff to previous 1.65 (colored)

Add support for storing builtins arguments into local variables.

Revision 1.65 / (download) - annotate - [select for diffs], Fri Nov 11 22:40:41 2022 UTC (18 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.64: +11 -3 lines
Diff to previous 1.64 (colored)

Add support for multiple statements in if () blocks.

Revision 1.64 / (download) - annotate - [select for diffs], Fri Nov 11 10:51:39 2022 UTC (18 months, 3 weeks ago) by mpi
Branch: MAIN
Changes since 1.63: +3 -3 lines
Diff to previous 1.63 (colored)

typo

Revision 1.63 / (download) - annotate - [select for diffs], Thu Jun 2 21:38:46 2022 UTC (2 years ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.62: +3 -1 lines
Diff to previous 1.62 (colored)

Let btrace(8) execute the END probe upon receiving a SIGTERM signal

While SIGINT (already handled) makes sense for interactive use, handling
SIGTERM in the same manner is less surprising for scripting.  This lets
you do:

  btrace ... & some workload; kill $!

and get the expected output.

ok mpi@

Revision 1.62 / (download) - annotate - [select for diffs], Tue Feb 22 17:26:04 2022 UTC (2 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.61: +2 -2 lines
Diff to previous 1.61 (colored)

Since other exported commandnames were increased to 24 and graduated into
proper strings, adapt dt's exported string in the same way.
Old/new files/tools will not work the same way.
That this interface needs to also change was pointed out by jsg

Revision 1.61 / (download) - annotate - [select for diffs], Tue Dec 7 22:17:03 2021 UTC (2 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.60: +3 -3 lines
Diff to previous 1.60 (colored)

Delete the last emulation callbacks: we're Just ELF, so declare
exec_elf_fixup() and coredump_elf() in <sys/exec_elf.h> and call
them and the MD setregs() directly in kern_exec.c and kern_sig.c

Also delete e_name[] (only used by sysctl), e_errno (unused), and
e_syscallnames[] (only used by SYSCALL_DEBUG) and constipate
syscallnames to 'const char *const[]'

ok kettenis@

Revision 1.60 / (download) - annotate - [select for diffs], Fri Nov 12 16:57:24 2021 UTC (2 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.59: +40 -1 lines
Diff to previous 1.59 (colored)

Implement the probe variable. Can be used for example with
	@map[probe] = count();
OK mpi@

Revision 1.59 / (download) - annotate - [select for diffs], Sun Oct 24 14:18:58 2021 UTC (2 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.58: +17 -7 lines
Diff to previous 1.58 (colored)

Use unveil(2) for the possible script file, dt(4) and ksyms(4) nodes.

btrace(8) cannot be pledge due to its use of special ioctl()s.

ok deraadt@

Revision 1.58 / (download) - annotate - [select for diffs], Sun Oct 3 22:01:48 2021 UTC (2 years, 8 months ago) by dv
Branch: MAIN
Changes since 1.57: +45 -2 lines
Diff to previous 1.57 (colored)

bt(5)/btrace(8): add support for str()

Implement initial support for the str() function, which is used
primarily to truncate or NUL-terminate strings from either cli args
or args to tracepoints and syscalls.

Current implementation only supports cli args and is primarily for
compatability with bpftrace. Future work is needed once dt(4)
supports builtin args other than long values.

Adds a regress test and wires in argument-based tests again.

ok mpi@

Revision 1.57 / (download) - annotate - [select for diffs], Tue Sep 21 21:33:35 2021 UTC (2 years, 8 months ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.56: +3 -2 lines
Diff to previous 1.56 (colored)

Add NUL termination to btfile content to avoid that strlcpy(3) reads
too much in btrace(8).
OK mpi@ deraadt@

Revision 1.56 / (download) - annotate - [select for diffs], Thu Sep 9 20:07:49 2021 UTC (2 years, 8 months ago) by jasper
Branch: MAIN
Changes since 1.55: +2 -1 lines
Diff to previous 1.55 (colored)

fix crash when passing empty cli arguments as B_AT_NIL wasn't handled as a valid argument type

found with afl++
ok mpi@

Revision 1.55 / (download) - annotate - [select for diffs], Thu Sep 9 11:20:40 2021 UTC (2 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.54: +6 -1 lines
Diff to previous 1.54 (colored)

Let ba2str() handle unitialized map just like ba2long() does.

Revision 1.54 / (download) - annotate - [select for diffs], Thu Sep 9 09:53:11 2021 UTC (2 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.53: +79 -59 lines
Diff to previous 1.53 (colored)

Make it possible to associate multiple probes to a single rule.

The following syntax, reducing duplication, is now allowed:

END,
interval:hz:2
{
...
}

Rule descriptors are now linked to a list of probe descriptors instead of
a single one.  Enabled kernel probes are now linked to btrace(8) probe
descriptors.

While here stop parsing filter and probe if debug is not enabled.

Revision 1.53 / (download) - annotate - [select for diffs], Thu Sep 9 09:43:49 2021 UTC (2 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.52: +3 -1 lines
Diff to previous 1.52 (colored)

Handle new NIL type in ba_name().

Fix filter debugging.

Revision 1.52 / (download) - annotate - [select for diffs], Thu Sep 9 07:17:31 2021 UTC (2 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.51: +7 -7 lines
Diff to previous 1.51 (colored)

Do not treat empty map has invalid.

Revision 1.51 / (download) - annotate - [select for diffs], Thu Sep 9 07:03:10 2021 UTC (2 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.50: +21 -13 lines
Diff to previous 1.50 (colored)

Use a dynamic buffer to allow parsing scripts bigger than BUFSIZ.

ok jasper@

Revision 1.50 / (download) - annotate - [select for diffs], Thu Sep 9 06:58:39 2021 UTC (2 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.49: +37 -17 lines
Diff to previous 1.49 (colored)

Make sure all map operators work after calling clear() on a map.

Fix assertions found by jasper@ with AFL++.

ok jasper@

Revision 1.49 / (download) - annotate - [select for diffs], Wed Sep 8 13:29:51 2021 UTC (2 years, 9 months ago) by dv
Branch: MAIN
Changes since 1.48: +14 -16 lines
Diff to previous 1.48 (colored)

btrace(8): add initial support for cli arguments

This adds initial support for passing cli args to btrace(8) for use
in bt(5) scripts. Similar to bpftrace, they are referenced via $1,
$2, etc. with $# being the number of command line arguments provided.

Adds an initial regress test and a Makefile change to allow providing
arguments to regress tests in a .args file.

Currently no limit is imposed on the number of arguments, keeping
a similar approach as observed in bpftrace. References to undefined
arguments result in a new "nil" type that contextually acts as a
zero or empty string. More work can be done here to improve bpftrace
compatibility.

ok mpi@, jasper@

Revision 1.48 / (download) - annotate - [select for diffs], Tue Sep 7 19:29:12 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.47: +7 -1 lines
Diff to previous 1.47 (colored)

Check that map/hist functions are called with the right argument.

Change the parser to make clear() and zero() accept only local and
global variables as arguments.

Since the parser has no knowledge of the type of a variable abort
the execution if clear() or zero() are being called with something
other than a map or hist.

Fix assertions found by jasper@ with AFL++ (port coming soon!).

ok jasper@

Revision 1.47 / (download) - annotate - [select for diffs], Fri Sep 3 16:45:44 2021 UTC (2 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.46: +8 -5 lines
Diff to previous 1.46 (colored)

add kprobes provider for dt

this allows us to dynamically trace function boundaries with btrace by patching
prologues and epilogues with a breakpoint upon which the handler records the data,
sends it back to userland for btrace to consume.
currently it's hidden behind DDBPROF, and there is still a lot to cleanup and
improve, but basic scripts that observe return codes from a probed function
work.

from Tom Rollet, with various changes by me
feedback and ok mpi@

Revision 1.46 / (download) - annotate - [select for diffs], Thu Sep 2 17:21:39 2021 UTC (2 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.45: +6 -6 lines
Diff to previous 1.45 (colored)

rename struct dt_evt fields to make it clear this isn't only used for tracing syscalls
and adjust btrace(8) accordingly.
extracted from a larger diff by Tom Rollet.

ok mpi@

Revision 1.45 / (download) - annotate - [select for diffs], Wed Sep 1 13:21:24 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.44: +5 -1 lines
Diff to previous 1.44 (colored)

Handle the case where map/hist can be read after calling clear().

Fix a NULL-derference found by jasper@ with AFL++ (port coming soon!).

ok jasper@

Revision 1.44 / (download) - annotate - [select for diffs], Wed Sep 1 08:01:09 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.43: +4 -6 lines
Diff to previous 1.43 (colored)

Always print non-empty map & hist on exit even if there's an END rule.

Match bpftrace behavior.

Revision 1.43 / (download) - annotate - [select for diffs], Wed Sep 1 07:35:21 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

Support for insert pid/tid/cpu builtins in map/hist.

Revision 1.42 / (download) - annotate - [select for diffs], Tue Aug 31 12:51:24 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.41: +48 -36 lines
Diff to previous 1.41 (colored)

Basic test, if (no else atm), support with a single statement.

Revision 1.41 / (download) - annotate - [select for diffs], Tue Aug 31 11:30:21 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.40: +23 -6 lines
Diff to previous 1.40 (colored)

Support storing syscall arguments in a map/hist.

Revision 1.40 / (download) - annotate - [select for diffs], Tue Aug 31 08:39:26 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.39: +116 -40 lines
Diff to previous 1.39 (colored)

Rewrite grammar to implement operator precedence without using %right or %prec.

Arithmetic operator should now behave as expeted and tests can now be written
without superfluous parenthesis, for example:

syscall:select:entry
/($1 == 0) || (pid == $1)/
{
}

Can now be written:

syscall:select:entry
/$1 == 0 || pid == $1/
{
}

While here improve filter debugging support.

Revision 1.39 / (download) - annotate - [select for diffs], Mon Aug 30 11:57:45 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.38: +11 -1 lines
Diff to previous 1.38 (colored)

Implement '<' and '>' operators in filters.

Based on a diff from and ok dv@

Revision 1.38 / (download) - annotate - [select for diffs], Mon Jun 28 08:55:06 2021 UTC (2 years, 11 months ago) by bluhm
Branch: MAIN
Changes since 1.37: +5 -3 lines
Diff to previous 1.37 (colored)

Also show the time spent in userland when analyzing the kernel stack
in flame graph.  Only when both kernel and userland are displayed,
the whole picture of system activity becomes clear.  Fixes a parsing
bug in the flame graph tool where userland time was interpreted as
invalid kernel stack.
OK kn@

Revision 1.37 / (download) - annotate - [select for diffs], Wed Jun 23 11:24:01 2021 UTC (2 years, 11 months ago) by dv
Branch: MAIN
Changes since 1.36: +5 -1 lines
Diff to previous 1.36 (colored)

btrace(8): init and update timespec for BEGIN/END event

BEGIN and END use a fake dt(4) event, so in order to use the nsecs
var or time() it needs a timespec set. Init for BEGIN and update
at END.

ok mpi@

Revision 1.36 / (download) - annotate - [select for diffs], Mon Jun 7 12:55:19 2021 UTC (3 years ago) by dv
Branch: MAIN
Changes since 1.35: +4 -1 lines
Diff to previous 1.35 (colored)

btrace(8): add "cpu" to long conversion

Special values need to be translated to longs for use with functions
like hist/lhist. Add "cpu" to conversion list.

ok mpi@

Revision 1.35 / (download) - annotate - [select for diffs], Thu Apr 22 09:36:39 2021 UTC (3 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.34: +7 -71 lines
Diff to previous 1.34 (colored)

Remove support for in-kernel filters.

This might be added back in a future if copying events to userland becomes
a performance issue.  However note that it is not always possible to filter
in-kernel if, for example. a variable has to be evaluated when a rule fires.

Revision 1.34 / (download) - annotate - [select for diffs], Wed Apr 21 13:23:56 2021 UTC (3 years, 1 month ago) by jmc
Branch: MAIN
Changes since 1.33: +2 -2 lines
Diff to previous 1.33 (colored)

remove -p from usage;

Revision 1.33 / (download) - annotate - [select for diffs], Wed Apr 21 10:53:17 2021 UTC (3 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.32: +62 -22 lines
Diff to previous 1.32 (colored)

Extend filters to support any conditionnal test including global variables.

Stop using in-kernel filtering for the moment except for not tracing the
tracer.

Keep track of the number of filtered events.

Revision 1.32 / (download) - annotate - [select for diffs], Wed Apr 21 10:26:18 2021 UTC (3 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.31: +49 -15 lines
Diff to previous 1.31 (colored)

Extend print() to support any kind of variable.

Revision 1.31 / (download) - annotate - [select for diffs], Wed Apr 21 10:22:36 2021 UTC (3 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.30: +17 -19 lines
Diff to previous 1.30 (colored)

Support first shell argument as $1 in order to use it in filters.

Remove '-p' option now that scripts can filter by pid/tid.

Revision 1.30 / (download) - annotate - [select for diffs], Sun Mar 21 01:24:35 2021 UTC (3 years, 2 months ago) by jmatthew
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.29: +10 -4 lines
Diff to previous 1.29 (colored)

Add -n (no action) mode, which just parses the program and exits.

ok mpi@ kn@

Revision 1.29 / (download) - annotate - [select for diffs], Mon Feb 8 09:46:45 2021 UTC (3 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.28: +96 -31 lines
Diff to previous 1.28 (colored)

Extend binary operators support, required for more filter features.

Improve debugging of filters and print operator names in debug output.

Revision 1.28 / (download) - annotate - [select for diffs], Mon Feb 1 11:26:29 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.27: +40 -11 lines
Diff to previous 1.27 (colored)

Start implementing conditionals for filters.

Allows to check the existence of a variable in predicates, making it
possible to trace syscall latency, as follow:

syscall:select:entry
{
  @start[pid] = nsecs;
}

syscall:select:return
/@start[pid]/
{
  @usecs = hist((nsecs - @start[pid]) / 1000);
  delete(@start[pid]);
}

Revision 1.27 / (download) - annotate - [select for diffs], Thu Jan 21 13:19:25 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.26: +7 -1 lines
Diff to previous 1.26 (colored)

Make it possible to convert map arguments to long and insert nsecs in maps.

Necessary to measure latency, example below to better understand the kqueue
select(2) regression:

syscall:select:entry { @start[pid] = nsecs; }
syscall:select:return { @usecs = hist((nsecs - @start[pid]) / 1000); }

Revision 1.26 / (download) - annotate - [select for diffs], Mon Dec 7 18:28:09 2020 UTC (3 years, 6 months ago) by bluhm
Branch: MAIN
Changes since 1.25: +32 -16 lines
Diff to previous 1.25 (colored)

In btrace(8) handle snprintf(3) errors correctly.  If snprintf
fails, buffer is unchanged; initialize it with empty string.  snprintf
may return negative value or the length that would have been written;
check and calculate remaining size.  snprintf writes size - 1
characters; pass buffer size as length.
OK mpi@

Revision 1.25 / (download) - annotate - [select for diffs], Mon Sep 14 18:45:19 2020 UTC (3 years, 8 months ago) by jasper
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.24: +11 -5 lines
Diff to previous 1.24 (colored)

add support for '&' and '|' operators in btrace scripts

feedback from otto@
ok mpi@ kn@ semarie@

Revision 1.24 / (download) - annotate - [select for diffs], Fri Sep 11 08:16:15 2020 UTC (3 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.23: +22 -10 lines
Diff to previous 1.23 (colored)

Support '-p' a flag to filter all actions by PID.

Revision 1.23 / (download) - annotate - [select for diffs], Thu Aug 13 11:35:21 2020 UTC (3 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.22: +5 -2 lines
Diff to previous 1.22 (colored)

Be compatible with bpftrace(8)'s output when printing stack traces in maps.

This allows us to use `stackcollapse-bpftrace.pl' from Brendan Gregg's
FrameGraph without pre-processing outputs.

Revision 1.22 / (download) - annotate - [select for diffs], Fri Aug 7 14:04:59 2020 UTC (3 years, 10 months ago) by mpi
Branch: MAIN
Changes since 1.21: +3 -3 lines
Diff to previous 1.21 (colored)

Do not hardcode the key length.

Revision 1.21 / (download) - annotate - [select for diffs], Sat Jul 11 14:52:14 2020 UTC (3 years, 10 months ago) by mpi
Branch: MAIN
Changes since 1.20: +114 -12 lines
Diff to previous 1.20 (colored)

Implement linear and power-of-two histograms: hist() and lhist() keywords.

This is built on top of maps which are currently built on top of RB-trees.
Improvements are welcome!  For example the use of a hashing table as pointed
by espie@.

The following one-liner produce an histogram of power-of-two values returned
by the read(2) syscall:

btrace 'syscall:read:return { @bytes = hist(retval); }'
^C
@bytes:
[0]               19 |@@@@@@@@@@@@@@@@@@@@@@@@@@                          |
[1]               26 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                |
[1, 2)             1 |@                                                   |
[2, 4)            13 |@@@@@@@@@@@@@@@@@@                                  |
[4, 8)             4 |@@@@@                                               |
[8, 16)            3 |@@@@                                                |
[16, 32)           1 |@                                                   |
[32, 64)           8 |@@@@@@@@@@@                                         |
[64, 128)         14 |@@@@@@@@@@@@@@@@@@@                                 |
[128, 256)         7 |@@@@@@@@@                                           |
[256, 512)        37 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[512, 1K)          1 |@                                                   |
[1K, 2K)          10 |@@@@@@@@@@@@@@                                      |
[2K, 4K)          11 |@@@@@@@@@@@@@@@                                     |
[8K, 16K)          1 |@                                                   |

Revision 1.20 / (download) - annotate - [select for diffs], Sat Jul 4 10:16:15 2020 UTC (3 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.19: +6 -3 lines
Diff to previous 1.19 (colored)

Print the correct register for syscall return value.

While here make it possible to store syscall return values in maps.

Revision 1.19 / (download) - annotate - [select for diffs], Thu Jun 18 10:26:53 2020 UTC (3 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.18: +3 -10 lines
Diff to previous 1.18 (colored)

Apply rules to the number of events returned by the last read(2).

Fix a corner case where old events could be re-evaluated.

From Yuichiro NAITO.

Revision 1.18 / (download) - annotate - [select for diffs], Fri Apr 24 14:56:43 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.17: +5 -3 lines
Diff to previous 1.17 (colored)

Print given identifier in the error message when no matching probe exist.

Revision 1.17 / (download) - annotate - [select for diffs], Thu Apr 23 18:36:51 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.16: +6 -1 lines
Diff to previous 1.16 (colored)

Implement builtin 'cpu' keyword.

This is useful to know which CPU recorded a given event.

While here document 'retval' and comment out 'ustack' until we have a
way to capture userland stacks.

Revision 1.16 / (download) - annotate - [select for diffs], Thu Apr 23 14:54:12 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.15: +71 -43 lines
Diff to previous 1.15 (colored)

Extend map to support keys composed of multiple arguments.

Keys are still strings representing the output value.

The following example is now possible to count the number of "on CPU"
events ordered by thread ID and executable name:

# btrace -e 'tracepoint:sched:on__cpu { @[tid, comm] = count() }'
^C
@[138836, idle0]: 830941
@[161307, sshd]: 716476
@[482901, softnet]: 582008
@[104443, systqmp]: 405749
@[269230, update]: 396133
@[326533, softclock]: 316926
@[61040, sshd]: 177201
@[453567, reaper]: 119676
@[446052, ksh]: 85675
@[26270, syslogd]: 66625
@[504699, sshd]: 52958
@[446052, sshd]: 32207
@[44046, tset]: 13333
@[162960, zerothread]: 101
@[313046, ntpd]: 1

Revision 1.15 / (download) - annotate - [select for diffs], Thu Apr 23 09:14:27 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.14: +10 -11 lines
Diff to previous 1.14 (colored)

Make debug output less verbose.

Revision 1.14 / (download) - annotate - [select for diffs], Wed Apr 15 16:59:04 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.13: +21 -9 lines
Diff to previous 1.13 (colored)

Make map functions accept a "struct map *" instead of a "struct bt_var *".

This is a step towards reducing the type casting crazyness.

Revision 1.13 / (download) - annotate - [select for diffs], Wed Apr 15 14:50:14 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.12: +4 -15 lines
Diff to previous 1.12 (colored)

Stop including <machine/param.h> and <machine/vmparam.h>.

There's no need to redefine the INKERNEL() macro in userland because
stacktrace_save_at() only saves kernel stack traces.

If we decide to use the same interface to unwind & save userland stack
traces we can simply indicate that in the "struct stacktrace".

Discussed with deraadt@ and kettenis@

Revision 1.12 / (download) - annotate - [select for diffs], Fri Mar 27 16:22:26 2020 UTC (4 years, 2 months ago) by cheloha
Branch: MAIN
Changes since 1.11: +6 -9 lines
Diff to previous 1.11 (colored)

btrace(8): simplify builtin_nsecs(); ok mpi@

Revision 1.11 / (download) - annotate - [select for diffs], Mon Mar 23 15:36:30 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.10: +2 -1 lines
Diff to previous 1.10 (colored)

Some architectures require <machine/param.h> to use VM_MIN_KERNEL_ADDRESS.

Fix build on at least sparc64

Revision 1.10 / (download) - annotate - [select for diffs], Mon Mar 23 15:34:45 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.9: +8 -1 lines
Diff to previous 1.9 (colored)

Document some functions.

Revision 1.9 / (download) - annotate - [select for diffs], Mon Mar 23 14:55:51 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.8: +24 -1 lines
Diff to previous 1.8 (colored)

Print maps when exiting unless an END rule has been defined.

This allows to use oneliners like:

# btrace -e 'profile:hz:99 { @[tid] = count(); }'

ok kn@

Revision 1.8 / (download) - annotate - [select for diffs], Thu Mar 19 15:55:55 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.7: +10 -9 lines
Diff to previous 1.7 (colored)

Use bv_name() in debug output and include the hash of a map.

Revision 1.7 / (download) - annotate - [select for diffs], Thu Mar 19 15:48:13 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.6: +55 -39 lines
Diff to previous 1.6 (colored)

When looking at which data should be recorded by the kernel include the
key of a map.

This makes map indexed by stack traces work.  For example to know where
the sleeps are coming from:

tracepoint:sched:sleep {
	@map[kstack] = count();
}

ok patrick@, tobhe@

Revision 1.6 / (download) - annotate - [select for diffs], Wed Mar 18 20:10:34 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.5: +2 -1 lines
Diff to previous 1.5 (colored)

Whitelist 'map' type in order to use them in real (non BEGIN/END) rules.

Revision 1.5 / (download) - annotate - [select for diffs], Mon Mar 16 08:54:08 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.4: +5 -5 lines
Diff to previous 1.4 (colored)

Fix affectation that should be conditionnal tests inside asserts.

From tom@

Revision 1.4 / (download) - annotate - [select for diffs], Tue Jan 28 16:39:51 2020 UTC (4 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.3: +7 -2 lines
Diff to previous 1.3 (colored)

Implement map functions min(), max() and sum().

For the moment map values are currently limited to integers.

Revision 1.3 / (download) - annotate - [select for diffs], Tue Jan 28 12:13:49 2020 UTC (4 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.2: +20 -12 lines
Diff to previous 1.2 (colored)

Implement delete() and @map[key] access.

Revision 1.2 / (download) - annotate - [select for diffs], Mon Jan 27 14:15:25 2020 UTC (4 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.1: +40 -1 lines
Diff to previous 1.1 (colored)

Implement builtin time() function.

Revision 1.1 / (download) - annotate - [select for diffs], Tue Jan 21 16:24:55 2020 UTC (4 years, 4 months ago) by mpi
Branch: MAIN

Import a bug tracer, companion of dt(4), that speaks the bt(5) language.

ok kettenis@, visa@, jasper@, deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.