1DWGREP(1) dwgrep DWGREP(1)
2
3
4
6 dwgrep - grep for Dwarf
7
9 dwgrep [OPTIONS] PATTERN [FILE...]
10 dwgrep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]
11
13 Dwgrep is a tool for querying Dwarf (debuginfo) graphs. Queries are
14 written in a language called Zwerg, the syntax of which is described on
15 project web pages (see below). The engine itself is available as a
16 shared library which can be used from C.
17
19 -H, --with-filename
20 Print the filename for each match. This is the default when
21 there is more than one file to search.
22
23 -c, --count
24 Print only a count of query results, not the results themselves.
25
26 -e, --expr=EXPR
27 EXPR is a query to run. At most one -e or -f option shall be
28 present. The selected query is run over the input file(s).
29
30 -f, --file=FILE
31 Load query from FILE. A Zwerg script stored in the given file
32 is read and run over the input file(s). At most one -e or -f
33 option shall be present.
34
35 -h, --no-filename
36 Suppress printing filename on output. This is the default when
37 there is less than two files to search.
38
39 -q, --silent, --quiet
40 Suppress all normal output. Exit immediately with zero status
41 if any match is found, even if an error was detected.
42
43 -s, --no-messages
44 Suppress error messages. All normal output is produced, but
45 error messages (if any) are not shown.
46
47 Note that currently libzwerg produces some error messages on its
48 own (e.g. division by zero), and those are still displayed.
49
50 --help Show help and exit.
51
52 --version
53 Show version in the format MAJOR.MINOR and exit.
54
56 Find ELF files:
57
58 $ dwgrep -sh $(find /usr/lib64/ -type f) -e 'name'
59 /usr/lib64/libogrove.so.0.0.1
60 /usr/lib64/libmp3lame.so.0.0.0
61 /usr/lib64/libgimpcolor-2.0.so.0.600.12
62 /usr/lib64/libmx-gtk-1.0.so.0.0.0
63 /usr/lib64/libkpimidentities.so.4.6.0
64 [... etc ...]
65
66 Find ELF files that include Dwarf information:
67
68 $ dwgrep -sh $(find /usr/lib64/ -type f) -e '?(unit) name'
69 /usr/lib64/python3.2/config-3.2mu/python.o
70 /usr/lib64/libxqilla.so.5.0.4
71 [... etc ...]
72
73 Find namespace names defined in one of them:
74
75 $ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
76 entry ?TAG_namespace name' | sort -u
77 __debug
78 __detail
79 __gnu_cxx
80 __gnu_debug
81 std
82 xercesc_3_0
83 XQParser
84
85 Find names of variables defined in the namespace xercesc_3_0:
86
87 $ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
88 entry ?TAG_namespace (name == "xercesc_3_0")
89 child ?TAG_variable name' | sort -u
90 chAmpersand
91 chAsterisk
92 chAt
93 chBackSlash
94 chBang
95 [... etc ...]
96
97 Of those, only list the ones that don't start in ch:
98
99 $ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
100 entry ?TAG_namespace (name == "xercesc_3_0")
101 child ?TAG_variable name
102 (!~ "ch.*")' | sort -u
103 gControlCharMask
104 gDefOutOfMemoryErrMsg
105 gFirstNameCharMask
106 gNameCharMask
107
108 Look where they are declared:
109
110 $ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
111 entry ?TAG_namespace (name == "xercesc_3_0")
112 child ?TAG_variable (name !~ "ch.*")
113 @AT_decl_file' | sort -u
114 /usr/include/xercesc/util/OutOfMemoryException.hpp
115 /usr/include/xercesc/util/XMLChar.hpp
116
117 Use formatting strings to include line number information in the mix:
118
119 $ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
120 entry ?TAG_namespace (name == "xercesc_3_0")
121 child ?TAG_variable (name !~ "ch.*")
122 "%(@AT_decl_file%): %(dup @AT_decl_line%)"' | sort -u
123 /usr/include/xercesc/util/OutOfMemoryException.hpp: 32
124 /usr/include/xercesc/util/XMLChar.hpp: 33
125 /usr/include/xercesc/util/XMLChar.hpp: 34
126 /usr/include/xercesc/util/XMLChar.hpp: 35
127 [... etc ...]
128
129 More examples are available in documentation on syntax and in the tuto‐
130 rial.
131
133 To learn more about Dwarf, check out:
134
135 · Introduction to the DWARF Debugging Format <‐
136 http://www.dwarfstd.org/doc/Debugging%20using%20DWARF.pdf>
137
138 · Dwarf standard <http://dwarfstd.org/Download.php>
139
140 · Project homepage <https://github.com/pmachata/dwgrep>
141
143 Petr Machata
144
146 2014, 2015, Petr Machata
147
148
149
150
1510.3 Jul 13, 2018 DWGREP(1)