OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.24 / (download) - annotate - [select for diffs], Mon Sep 11 19:01:26 2023 UTC (8 months, 4 weeks ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, HEAD
Changes since 1.23: +38 -85 lines
Diff to previous 1.23 (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.23 / (download) - annotate - [select for diffs], Sun Sep 3 10:26:35 2023 UTC (9 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.22: +2 -1 lines
Diff to previous 1.22 (colored)

Let builtin process names be stored in maps as string.

ok dv@

Revision 1.22 / (download) - annotate - [select for diffs], Sun Aug 13 09:48:27 2023 UTC (9 months, 4 weeks ago) by mpi
Branch: MAIN
Changes since 1.21: +3 -3 lines
Diff to previous 1.21 (colored)

Prevent user-after/double free in map insertion.

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.

Revision 1.21 / (download) - annotate - [select for diffs], Tue Jun 27 14:17:00 2023 UTC (11 months, 2 weeks ago) by claudio
Branch: MAIN
Changes since 1.20: +6 -1 lines
Diff to previous 1.20 (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.20 / (download) - annotate - [select for diffs], Sat Apr 30 01:29:05 2022 UTC (2 years, 1 month ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.19: +17 -5 lines
Diff to previous 1.19 (colored)

add support for printing some extra large numbers to histograms
ok mpi

Revision 1.19 / (download) - annotate - [select for diffs], Mon Nov 15 14:57:57 2021 UTC (2 years, 6 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.18: +37 -23 lines
Diff to previous 1.18 (colored)

Change printing of maps to use qsort to order the output using a pointer
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@

Revision 1.18 / (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.17: +2 -1 lines
Diff to previous 1.17 (colored)

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

Revision 1.17 / (download) - annotate - [select for diffs], Thu Sep 9 06:58:39 2021 UTC (2 years, 9 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.16: +1 -4 lines
Diff to previous 1.16 (colored)

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

Fix assertions found by jasper@ with AFL++.

ok jasper@

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

Imitate how free(3) behaves and make map_clear() works on NULL map.

Revision 1.15 / (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.14: +4 -1 lines
Diff to previous 1.14 (colored)

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

Revision 1.14 / (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.13: +2 -1 lines
Diff to previous 1.13 (colored)

Support storing syscall arguments in a map/hist.

Revision 1.13 / (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.12: +3 -6 lines
Diff to previous 1.12 (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.12 / (download) - annotate - [select for diffs], Thu Jan 21 13:19:25 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.11: +2 -1 lines
Diff to previous 1.11 (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.11 / (download) - annotate - [select for diffs], Fri Sep 18 19:19:38 2020 UTC (3 years, 8 months ago) by jasper
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

fix typo in comment and trailing whitespace

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

When dealing with integers, it seems that [1] and [1, 2) are the same.

Revision 1.9 / (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.8: +1 -3 lines
Diff to previous 1.8 (colored)

Do not hardcode the key length.

Revision 1.8 / (download) - annotate - [select for diffs], Sat Jul 11 14:52:14 2020 UTC (3 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.7: +151 -10 lines
Diff to previous 1.7 (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.7 / (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.6: +6 -3 lines
Diff to previous 1.6 (colored)

Print the correct register for syscall return value.

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

Revision 1.6 / (download) - annotate - [select for diffs], Wed Apr 15 16:59:04 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.5: +26 -32 lines
Diff to previous 1.5 (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.5 / (download) - annotate - [select for diffs], Wed Apr 15 14:51:45 2020 UTC (4 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

Crank key size to 256 to avoid conflicts when storing stack traces in maps.

Revision 1.4 / (download) - annotate - [select for diffs], Thu Mar 19 15:52:30 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.3: +3 -2 lines
Diff to previous 1.3 (colored)

Add support for unnamed map.

The following is now possible but won't print anything by default:

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

ok patrick@, tobhe@

Revision 1.3 / (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.2: +34 -5 lines
Diff to previous 1.2 (colored)

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

For the moment map values are currently limited to integers.

Revision 1.2 / (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.1: +45 -18 lines
Diff to previous 1.1 (colored)

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

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.