summaryrefslogtreecommitdiff
path: root/usr.sbin/btrace
AgeCommit message (Collapse)Author
2024-01-16Handle variable names (things strating with $ or @) in yylex() this wayClaudio Jeker
the error handling of strange variable names can be better controlled. With and OK dv@
2023-12-20btrace: add support for hex and octal values.Dave Voutila
Changes number tokenizing and parsing to support hex & octal values. Does not address other lexer issues (e.g. $0x1) to close gaps with bpftrace. OK claudio@
2023-12-20btrace: "too long line" -> "line too long"Dave Voutila
ok claudio@
2023-11-10zap some unused includesJasper Lievisse Adriaanse
2023-10-22bt(5), btrace(8): execute END probe and print non-empty maps upon exit()Scott Soule Cheloha
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@
2023-10-12bt(5), btrace(8): add support for binary modulo operator ('%')Scott Soule Cheloha
Link: https://marc.info/?l=openbsd-tech&m=169695435209410&w=2 ok mpi@
2023-09-15Also update usage() to include [-p file].Claudio Jeker
2023-09-15Even if support for utsack is very limited, document the option needed.Claudio Jeker
OK mpi@
2023-09-13Properly evaluate variables when inserting them into a map.Martin Pieuchot
Somehow missed in previous, regression reported by anton@.
2023-09-11Implement tuples, needed to export per-CPU scheduling data.Martin Pieuchot
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)
2023-09-03Let builtin process names be stored in maps as string.Martin Pieuchot
ok dv@
2023-09-02btrace(8): allow empty statements in probes.Dave Voutila
Allows for probes like `BEGIN {}`, in parity with bpftrace. Also fixes an incorrect syntax error parsing argN builtins in subsequent probes after an empty BEGIN block. ok mpi@
2023-09-02btrace(8): fix probe builtin in BEGIN/END.Dave Voutila
Resolves segfaults when using probe within BEGIN or END. ok mpi@
2023-08-28btrace(8): prohibit use of argN builtins in BEGIN/END.Dave Voutila
The argN builtins are undefined for BEGIN and END special probes. Similar to bpftrace, produce an error from the parser. Adds a regress test, as well. ok mpi@
2023-08-16Backout changes for btrace(8) argN builtins.Dave Voutila
Talking with mpi@, going to rework this to be part of the parser. Reverts commit 0iIzGtIFgBXVfbNa.
2023-08-15btrace(8): fix out of bounds read using argN in BEGIN/END.Dave Voutila
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@
2023-08-13btrace(8): fix yacc reduce conflicts and undefined symbol warnings.Dave Voutila
Define the STR symbol, used for the str function. Tune the grammar, simplifying the 'pat' rule to 'expr'. Resolves the reduce conflicts related to 'pat' and 'factor' both matching a lone CSTRING token. ok mpi@
2023-08-13Add support for storing builtin TID and PID in variables.Martin Pieuchot
2023-08-13Prevent user-after/double free in map insertion.Martin Pieuchot
Freeing arguments tied to statements is not an option because rules are parsed multiple times. Always make a copy of them if they are assigned to a key in a map.
2023-06-30sepcific -> specificJonathan Gray
ok claudio@
2023-06-27Make it possible to store the kstack or ustack in a map (as value, not key).Claudio Jeker
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@
2023-06-27Document the map specific functions (count, max, min, sum) in their ownClaudio Jeker
part of the bt.5 man page. Input and OK kn@
2023-05-12btrace(8) support to symbolize utrace addresses.Claudio Jeker
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@
2023-03-10btrace(8) retrieves the types of the arguments of each tracepointAlexander Bluhm
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@
2022-12-28spelling fixes; from paul tagliamonteJason McIntyre
any parts of his diff not taken are noted on tech
2022-12-22Denote multiple arguments with 'arg ...' not 'args'Klemens Nanni
A few programs used the plural in their synopsis which doesn't read as clear as the obvious triple-dot notation. mdoc(7) .Ar defaults to "file ..." if no arguments are given and consistent use of 'arg ...' matches that behaviour. Cleanup a few markups of the same argument so the text keeps reading naturally; omit unhelpful parts like 'if optional arguments are given, they are passed along' for tools like time(1) and timeout(1) that obviously execute commands with whatever arguments where given -- just like doas(1) which doesn't mention arguments in its DESCRIPTION in the first place. For expr(1) the difference between 'expressions' and 'expression ...' is crucial, as arguments must be passed as individual words. Feedback millert jmc schwarze deraadt OK jmc
2022-11-12Add support for string comparison in filters.Martin Pieuchot
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.
2022-11-11Add support for storing builtins arguments into local variables.Martin Pieuchot
2022-11-11Add support for multiple statements in if () blocks.Martin Pieuchot
2022-11-11typoMartin Pieuchot
2022-06-02Let btrace(8) execute the END probe upon receiving a SIGTERM signalJeremie Courreges-Anglas
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@
2022-05-01Install useful btrace scripts into /usr/share/btrace directory.Alexander Bluhm
OK tedu@
2022-04-30add support for printing some extra large numbers to histogramsTed Unangst
ok mpi
2022-04-28btrace(8): fix lexer to allow whitespace after filters.Dave Voutila
Whitespace is allowed after the closing slash of a filter and before the opening brace of an action. This makes the lexer scan ahead and collect any whitespace and newlines into the end of filter token. ok mpi@
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
2022-02-22Since other exported commandnames were increased to 24 and graduated intoTheo de Raadt
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
2021-12-07Delete the last emulation callbacks: we're Just ELF, so declarePhilip Guenther
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@
2021-11-15Change printing of maps to use qsort to order the output using a pointerClaudio Jeker
array. This replaces the current solution that only prints one element for a certain value and not all elements with tha same value. This can be further optimized but printing is not really a hot path in btrace. OK mpi@
2021-11-12Implement the probe variable. Can be used for example withClaudio Jeker
@map[probe] = count(); OK mpi@
2021-10-24Use unveil(2) for the possible script file, dt(4) and ksyms(4) nodes.Martin Pieuchot
btrace(8) cannot be pledge due to its use of special ioctl()s. ok deraadt@
2021-10-03bt(5)/btrace(8): add support for str()Dave Voutila
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@
2021-09-21Add NUL termination to btfile content to avoid that strlcpy(3) readsAlexander Bluhm
too much in btrace(8). OK mpi@ deraadt@
2021-09-09fix crash when passing empty cli arguments as B_AT_NIL wasn't handled as a ↵Jasper Lievisse Adriaanse
valid argument type found with afl++ ok mpi@
2021-09-09Relax the check for accessing variable before setting them.Martin Pieuchot
First we can't assume rules are written in the order they will be executed. Secondly filters might need to check variables before they had a chance to be populated by the right event.
2021-09-09Let ba2str() handle unitialized map just like ba2long() does.Martin Pieuchot
2021-09-09Make it possible to associate multiple probes to a single rule.Martin Pieuchot
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.
2021-09-09Handle new NIL type in ba_name().Martin Pieuchot
Fix filter debugging.
2021-09-09Do not treat empty map has invalid.Martin Pieuchot
2021-09-09Use a dynamic buffer to allow parsing scripts bigger than BUFSIZ.Martin Pieuchot
ok jasper@
2021-09-09Make sure all map operators work after calling clear() on a map.Martin Pieuchot
Fix assertions found by jasper@ with AFL++. ok jasper@