summaryrefslogtreecommitdiffstats
path: root/qcg.txt
blob: 24c6174e3059d269493e4b1ca6743d9c377f0618 (plain)
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
REFERENCE OF QUERY TOOL LANGUAGE:

 + `cg' denotes the whole callgraph

 + [] operator is used for filtering:
     cg[...filters...][...more filters...][...etc...]

 + simple string used as filter denotes a regular expression to be
   matched agains symbol names:

     - cg["main"]
     - cg["pthread_.*"]

 + set operations are defined on symbol sets:

     - cg["abc_.*"] + cg[".*_def"]   (set addition)
     - cg["abc_.*"] - cg[".*_def"]   (set substraction)
     - cg["abc_.*"] * cg[".*_def"]   (set intersection)
     - ~cg["abc_.*"]                 (set inversion)

 + other set operations:

     - len(cg), len(cg["abc_.*"])    (obtaining the size of the set)
     - cg.len                        (another way of doing the above, perhaps more comfortable)
     - cg.sort()                     (sort the output, see below for details)
     - cg["main"].callees()          (functions that "main" calls)
     - cg["twain"].callers()         (functions that call "twain")
     - cg["main"].trcallees()        (functions that "main" calls transitively (including itself))
     - cg["main"].tcallees()         (functions that "main" calls transitively (not including itself))
     - similar for trcallers and tcallers

 + each symbol has a couple flags that can be used to filter out
   groups of symbols:

     - cg[fun]               (only include functions)
     - cg[static]            (only include static symbols)
     - cg[decl]              (only include decl-only, undefined symbols)
     - cg[~fun]              (only include non-functions)
     - cg[var]               (currently synonym of the above)
     - cg[extern]            (synonym of cg[~static])
     - cg[fun & static]      (only include static function symbols)
     - cg[fun][static]       (same as above, but written as two filters)
     - cg[fun | static]      (only include symbols that are either functions, or static)
     - cg[fun] + cg[static]  (same as above)

 + filter 'name' is used for more general filtering based on symbol
   name:

     - cg[name == <string>]  (which is basically like cg[<string>])
     - cg[name != <string>]
     - cg[name.like(<regex>)]
     - cg[name.startswith(<string>)]
     - cg[name.endswith(<string>)]
     - cg[len(name) > 4]

 + filter 'file' is used for filtering based on name of the file where
   the symbol is defined.  Use it like `name' filter above.  There are
   two sub-filters of `file', `base' and `path' (or `dir').

     - cg[file == <string>]
     - cg[file.path != <string>]
     - cg[file.base.startswith('dwfl_')]

 + filter 'line' is used for filtering based on the number of line
   where the symbol is defined.

     - cg[line > 100]
     - cg[line != 100]

 + sorting the output: When you sort the output, the symbol set will
   still behave like a symbol set, but any additional filtering will
   again yield unsorted set.  So make the sort the last thing to do.

     - cg.sort()                         // sort all symbols by symbol name
     - cg.sort(file.base)                // sort all symbols by filename
     - cg["pthread_.*"].sort(len(name))  // sort some symbols by length of the symbol name
     - cg["pthread_.*"].sort(~name)      // sort by name, reverse order
     - cg.sort(file, name)               // sort by filename and symbol name