-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathcalltree_usage.txt
86 lines (86 loc) · 5.79 KB
/
calltree_usage.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<cs2>calltree.pl<end> - <cs2>A tool used to surf C++ code source.<end>
-
- <cs2>prerequisites<end>
-- perl 5.10+: Most Linux distributions and MacOS have intalled perl 5.10+.
-- ag(the_silver_searcher):
--- Must be installed,
--- Although calltree.pl can leverage official https://github.com/ggreer/the_silver_searcher, but not the best choice.
--- Suggest to install customized https://github.com/satanson/the_silver_searcher that extract function body precisely.
-- calltree.pl/java_calltree.pl/cpptree.pl/javatree.pl/deptree.pl are standalone scripts with no others dependencies.
-
- <cs2>Format: calltree.pl '<src_regex>' '[[-]<dst_regex>]' <mode(0|1|2|3|4)> <verbose> <[-]depth> [[-]path_regex]<end>
- <cs2>REGEX in calltree.pl are perl regex, and must be enclosed by quotes.<end>
-
- <cs2>Arguments<end>:
-- <cs2><src_regex>: (required)<end> Search since functions match `src_regex`, these functions will be root of subtrees.
--- demos
---- <cs1>calltree.pl '(\bfsync|fdatasync|sync_file_range\b)' 'Write' 1 1 3<end> # rocksdb
---- <cs1>calltree.pl '((?i)\b\w*compaction\w*\b)' '' 1 1 3<end> # rocksdb
-- <cs2>[[-]<dst_regex>]: (required)<end> Search till functions match `dst_regex`, these functions will be leaf of subtrees.
--- demos
---- <cs1>calltree.pl '(\bfsync|fdatasync|sync_file_range\b)' '' 1 1 3<end> # empty '' means match any functions
---- <cs1>calltree.pl '(\bfsync|fdatasync|sync_file_range\b)' '-Write' 1 1 3<end> # '-<regex>' means interested in functions not match the regex
---- <cs1>calltree.pl '(\bfsync|fdatasync|sync_file_range\b)' '(?i)compaction' 1 1 3<end> # '<regex>' means interested in functions match the regex
--
-- <cs2><mode>: (required)<end>
--- <cs3>0: show calling tree(caller is parent node, callee is child node).<end>
---- demos
----- <cs1>calltree.pl 'parsePassPipeline' '(Pass|Analysis|Pipeline)$' 0 1 2<end> # llvm
----- <cs1>calltree.pl 'main' 'Pipeline' 0 1 3<end> # llvm
--- <cs3>1: show called tree(callee is parent node, caller is child node).<end>
---- demos
----- <cs1>calltree.pl build_hash '(?i)agg' 1 1 3<end> # StarRocks
----- <cs1>calltree.pl '\bpush_chunk\b' 'thread' 1 1 4 'pipeline'<end> # StarRocks
--- 2: show all functions that matches `src_regex` and has callees.
---- demos
----- <cs1>calltree.pl '^\w*txn\w*$' '' 2 1 1<end> # rocksdb
----- <cs1>calltree.pl '^\w*compile\w*$' '' 2 1 1<end> # llvm
--- 3: show all functions that matches `src_regex` and has no callees but have callers.
---- demos
----- <cs1>calltree.pl '^\w*io_uring\w*$' '' 3 1 1<end> # rocksdb
----- <cs1>calltree.pl '^\w*compile\w*$' '' 3 1 1<end> # llvm
--- <cs3>4: show called tree and used to find functions/files that enclosing the contents match `src_regex`.<end>
---- demos
----- <cs1>calltree.pl 'evalfunc_private\s*=\s*.*' '' 4 1 2<end> # postgres
----- <cs1>calltree.pl 'evalfunc\s*=\s*.*' '' 4 1 2<end> # postgres
----- <cs1>calltree.pl '\w+\s*=\s*llvm_compile_expr' '' 4 1 3<end> # posgres
----- <cs1>calltree.pl '.*\b_PG_jit_provider_init\b.*' '' 4 1 3<end> #postgres
--
-- <cs2><verbose>: (required)<end>
--- 0|1: 0 for not showing file-lineno infos, 1 for showing file-lineno infos, take effect on all modes.
---- demos
----- <cs1>calltree.pl '^\w*io_uring\w*$' '' 1 0 3<end> # rocksdb, not verbose
----- <cs1>calltree.pl '^\w*io_uring\w*$' '' 1 1 3<end> # rocksdb, verbose
--- <cs3>qhcv or hcv: a four-digit or three-digit number, take effect only on mode 0.<end>
---- q: quiet, 0 for non-quiet(default) and 1 for quiet, not show common subtrees when quiet.
---- h: height of common subtrees, >=3(default), subtrees height than `h` will be extracted as common subtrees.
---- c: repetition count of common subtrees, >=2(default), subtrees ocurrs at least for `c` times will be considered as common subtrees.
---- v: verbose, 0 for not showing file-lineno infos and 1 for showing file-lineno infos.
---- <cs3>motivation: mode 0(show calling tree) leverages qhcv and hcv to speed up searching and collapse duplicate calling patterns.<end>
---- demos:
----- <cs1>calltree.pl "(?i)^(create|build|parse)\w*pipeline$" "(?i)^(create|build|parse)\w*pipeline$" 0 431 7<end> # llvm
------ Prune and print common subtrees(height=4, repetition count=3)
----- <cs1>calltree.pl "(?i)^(create|build|parse)\w*pipeline$" "(?i)^(create|build|parse)\w*pipeline$" 0 1431 7<end> # llvm
------ Just prune the common subtrees(height=4, repetition count=3), not print common subtrees.
----- <cs1>calltree.pl "(?i)^(create|build|parse)\w*pipeline$" "(?i)^(create|build|parse)\w*pipeline$" 0 0431 7<end> # llvm
------ 0431 Equivalent to 431
--
-- <cs2>[-]<depth>: (required)<end> the depth of the tree output, a larger depth means cost more times to generate trees.
--- depth > 0: take effect on all modes.
--- depth < 0: only take effect on mode 1 (show called tree),
---- It is quite similar to |depth|, but adjacent functions with the name will be collapsed to only one.
---- It is very useful when your are reading codes that designed in Visitor or Iterator pattern.
--- demos:
---- <cs1>calltree.pl '^\w*io_uring\w*$' '' 1 1 3<end> # rocksdb, depth=3
---- <cs1>calltree.pl '^\w*io_uring\w*$' '' 1 1 4<end> # rocksdb, depth=4
---- <cs1>calltree.pl '^\w*io_uring\w*$' '' 1 1 5<end> # rocksdb, depth=5
---- <cs1>calltree.pl 'get_next' 'open' 1 1 -4<end> # StarRocks, depth=4, minus sign means squeezing adjacent functions with the same name.
--
-- <cs2>[[-]<path_regex>]: (optional)<end> Sometimes, your are only interested in functions in paths that match the regex or not match.
--- demos
---- <cs1>calltree.pl "buildModuleOptimizationPipeline" '^main$' 1 1 7<end> # llvm
---- <cs1>calltree.pl "buildModuleOptimizationPipeline" '^main$' 1 1 7 '-LTO'<end> # llvm, skip paths matches LTO
---- <cs1>calltree.pl "buildModuleOptimizationPipeline" '^main$' 1 1 7 '(lib|opt)'<end> #llvm, skip paths does not match `(lib|opt)`
-
- <cs2>How to reach me<end>
-- E-Mail: ranpanf@gmail.com