summaryrefslogtreecommitdiff
path: root/usr.sbin/btrace
AgeCommit message (Collapse)Author
2024-11-07Add multi-line strings support to the bt(5) script parser.Martin Pieuchot
From Christian Ludwig
2024-09-06Interpret the argument of '%c' as an integer instead of a string.Martin Pieuchot
From Christian Ludwig.
2024-07-09Read the whole buffer, not its size minus one.Martin Pieuchot
From Christian Ludwig cludwig at genua.de.
2024-05-21remove prototypes with no matching function and externs with no varJonathan Gray
partly checked by millert@
2024-04-01init var to fix missing symtab section pathJonathan Gray
found by smatch, ok mpi@
2024-03-30Implement else branching logic including 'else if'.Martin Pieuchot
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
2024-03-16btrace(8): cache ELF symbols in sorted arrayScott Soule Cheloha
Currently, every kelf_snprintsym() call performs a linear search through the .symtab for a symbol matching the given PC. The search is expensive and seems to be a major source of dropped profiling events. Storing all STT_FUNC .symtab entries and their names in a sorted array cuts search time from O(n) to O(lg n). In practice, the faster lookups seem to dramatically reduce the profiling drop rate. With tweaks from mpi@. Thread: https://marc.info/?l=openbsd-tech&m=170830125132105&w=2 ok mpi@
2024-03-14Revert "btrace(8): cache ELF .symtab, .strtab entries in sorted array"Scott Soule Cheloha
"No it's not okay." mpi@
2024-03-12btrace(8): cache ELF .symtab, .strtab entries in sorted arrayScott Soule Cheloha
Currently, every kelf_snprintsym() call performs a linear search through the .symtab for a matching symbol. The search is very costly and causes btrace(8) to drop a lot of profiling events. Storing the STT_FUNC .symtab entries and their corresponding .strtab entries in a sorted array cuts the lookup cost from O(n) to O(lg n). Lower overhead reduces the drop rate for profiling events. With tweaks from mpi@. Thread: https://marc.info/?l=openbsd-tech&m=170830125132105&w=2 probably ok mpi@
2024-02-27Printing large tuples require more than 64 chars, bump the string limit.Martin Pieuchot
2024-02-27Make it possible to check for existing string in maps.Martin Pieuchot
2024-02-24Check for builtins used inside tuple to ask the kernel to copyout specific data.Martin Pieuchot
Allow to save stacktrace and process name in tuples.
2024-02-24Implement 'store' for maps.Martin Pieuchot
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.
2024-02-24Implement 'store' for all builtins, they are either string or integer.Martin Pieuchot
2024-02-12Fix tuple & string comparisons in maps.Martin Pieuchot
2024-02-12Trailing spacesMartin Pieuchot
2024-02-07Prevent tuples to be used as map key, associative array is what we want.Martin Pieuchot
2024-02-05Print statistics on stderr to be able to redirect bt(5) script output.Martin Pieuchot
From Christian Ludwig.
2024-01-25Return 0 when accessing an argument not defined in a probe.Martin Pieuchot
Adapted from a fix from Christian Ludwig.
2024-01-23Consider the whole tuple when reading a map entry whose key is that tuple.Martin Pieuchot
Previously only the first element of the tuple was considered. This led to the introduction of new map entries. Reported by Christian Ludwig.
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