# The pattern is a string with optional '*' wildcards, similar to file
# globbing. If you'd prefer to use regular expressions, use the -r option.
#
+# Without the '-l' option, only the innermost calls will be recorded.
+# Use '-l LEVEL' to record the outermost n levels of nested/recursive functions.
+#
# Copyright (c) 2015 Brendan Gregg.
+# Copyright (c) 2021 Chenyue Zhou.
# Licensed under the Apache License, Version 2.0 (the "License")
#
# 20-Sep-2015 Brendan Gregg Created this.
# 06-Oct-2016 Sasha Goldshtein Added user function support.
+# 14-Apr-2021 Chenyue Zhou Added nested or recursive function support.
from __future__ import print_function
from bcc import BPF
if need_key:
pid = '-1' if not library else 'tgid'
- if args.level > 1:
+ if args.level and args.level > 1:
bpf_text = bpf_text.replace('TYPEDEF',
"""
#define STACK_DEPTH %s
}
u32 index = --stack->head;
-
if (index < STACK_DEPTH) {
/* bound check */
cache->ip = stack->cache[index].ip;
if (index > STACK_DEPTH - 1) {
/* bound check */
-
return -1;
}
stack->head++;
-
stack->cache[index].ip = cache->ip;
stack->cache[index].start_ts = cache->start_ts;
func_stack_t *stack = func_stack.lookup(&pid);
if (!stack) {
/* miss start */
-
return 0;
}
return 0;
}
-
ip = cache.ip;
start_ts = cache.start_ts;
delta = bpf_ktime_get_ns() - start_ts;
if (stack->head == 0) {
/* empty */
-
func_stack.delete(&pid);
}
""" % pid)
524288 -> 1048575 : 0 | |
1048576 -> 2097151 : 0 | |
2097152 -> 4194303 : 1 | |
-
+
avg = 13746 nsecs, total: 6543360 nsecs, count: 476
Detaching...
-F, --function show a separate histogram per function
-r, --regexp use regular expressions. Default is "*" wildcards
only.
+ -l LEVEL, --level LEVEL
+ set the level of nested or recursive functions
-v, --verbose print the BPF program (for debugging purposes)
examples: