Skip to content
Snippets Groups Projects
Commit 0cf81665 authored by chenyue.zhou's avatar chenyue.zhou Committed by yonghong-song
Browse files

update

parent c76cd926
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,9 @@ Print output every interval seconds.
\-d DURATION
Total duration of trace, in seconds.
.TP
\-l LEVEL
Set the level of nested or recursive functions.
.TP
\-T
Include timestamps on output.
.TP
......
......@@ -12,11 +12,16 @@
# 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
......@@ -173,7 +178,7 @@ else:
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
......@@ -204,7 +209,6 @@ static inline int stack_pop(func_stack_t *stack, func_cache_t *cache) {
}
u32 index = --stack->head;
if (index < STACK_DEPTH) {
/* bound check */
cache->ip = stack->cache[index].ip;
......@@ -219,12 +223,10 @@ static inline int stack_push(func_stack_t *stack, func_cache_t *cache) {
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;
......@@ -264,7 +266,6 @@ static inline int stack_push(func_stack_t *stack, func_cache_t *cache) {
func_stack_t *stack = func_stack.lookup(&pid);
if (!stack) {
/* miss start */
return 0;
}
......@@ -274,7 +275,6 @@ static inline int stack_push(func_stack_t *stack, func_cache_t *cache) {
return 0;
}
ip = cache.ip;
start_ts = cache.start_ts;
delta = bpf_ktime_get_ns() - start_ts;
......@@ -290,7 +290,6 @@ static inline int stack_push(func_stack_t *stack, func_cache_t *cache) {
if (stack->head == 0) {
/* empty */
func_stack.delete(&pid);
}
""" % pid)
......
......@@ -29,7 +29,7 @@ Tracing do_sys_open... Hit Ctrl-C to end.
524288 -> 1048575 : 0 | |
1048576 -> 2097151 : 0 | |
2097152 -> 4194303 : 1 | |
avg = 13746 nsecs, total: 6543360 nsecs, count: 476
Detaching...
......@@ -383,6 +383,8 @@ optional arguments:
-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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment