Update scripts to use `increment` (#1905)
* Replace boilerplate for increment with a call to `increment`
from new tooling. Found cases to replace using `ripgrep`[1]:
```
$ rg '\(\*\w+\)\s*\+\+' -l | grep tools | grep -v old
```
[1]: https://github.com/BurntSushi/ripgrep
* Replace boilerplate for bigger than 1 increments with the new
`increment` call
from new tooling. Found cases to replace using `ripgrep`[1]:
```
$ rg '\(\*\w+\)\s*\+=' -l | grep tools | grep -v old
```
[1]: https://github.com/BurntSushi/ripgrep
* Update examples indicating the alternative increment call for hash tables
diff --git a/examples/tracing/mallocstacks.py b/examples/tracing/mallocstacks.py
index 0def220..2f3eb25 100644
--- a/examples/tracing/mallocstacks.py
+++ b/examples/tracing/mallocstacks.py
@@ -33,6 +33,7 @@
if (key < 0)
return 0;
+ // could also use `calls.increment(key, size);`
u64 zero = 0, *val;
val = calls.lookup_or_init(&key, &zero);
(*val) += size;
diff --git a/examples/tracing/strlen_count.py b/examples/tracing/strlen_count.py
index 7d2db89..49d7080 100755
--- a/examples/tracing/strlen_count.py
+++ b/examples/tracing/strlen_count.py
@@ -31,6 +31,7 @@
u64 zero = 0, *val;
bpf_probe_read(&key.c, sizeof(key.c), (void *)PT_REGS_PARM1(ctx));
+ // could also use `counts.increment(key)`
val = counts.lookup_or_init(&key, &zero);
(*val)++;
return 0;
diff --git a/examples/tracing/task_switch.py b/examples/tracing/task_switch.py
index 7a73d8b..161edfb 100755
--- a/examples/tracing/task_switch.py
+++ b/examples/tracing/task_switch.py
@@ -22,6 +22,7 @@
key.curr_pid = bpf_get_current_pid_tgid();
key.prev_pid = prev->pid;
+ // could also use `stats.increment(key);`
val = stats.lookup_or_init(&key, &zero);
(*val)++;
return 0;