DWGREP(1)

πŸ“¦
version 0.4 Β· 2 versions
, in fedora 43

✨ DWGREP(1) β€” bestie edition ✨

okay so. you know grep? this is grep but for Dwarf 🧚 and honestly it's giving main character energy. welcome to the manual for dwgrep, bestie πŸ’–


🌸 NAME 🌸

dwgrep β€” grep for Dwarf. that's it. that's the whole vibe. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

dwgrep [OPTIONS] PATTERN [FILE...]
dwgrep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, Dwgrep is a tool for querying Dwarf (debuginfo) graphs. and the queries? you write them in a whole little language called Zwerg ✨ β€” the syntax lives on the project web pages (scroll down, bestie, there's links in SEE ALSO πŸ‘€). the engine itself is also available as a shared library which can be used from C. no cap. 🫢


πŸ’… OPTIONS πŸ’…

  • -H, --with-filename β€” prints the filename for each match. this is the default when there's more than one file to search. so if you're juggling multiple files, it just does this automatically. iconic. ✨
  • -a=ARG β€” passes a string argument to the running script. a command line argument like -a X is handled like --a '"X"', except with appropriate escaping. πŸŽ€
  • -c, --count β€” prints only a count of query results, not the results themselves. just the number, bestie. lowkey so useful. πŸ”’
  • -e, --expr=EXPR β€” EXPR is a query to run. at most one -e or -f option shall be present. the selected query is run over the input file(s). ⭐
  • -f, --file=FILE β€” loads the query from FILE. a Zwerg script stored in the given file is read and run over the input file(s). at most one -e or -f option shall be present. πŸ“„
  • -h, --no-filename β€” suppresses printing the filename on output. this is the default when there's less than two files to search. 🀫
  • -q, --silent, --quiet β€” suppresses all normal output. exits immediately with zero status if any match is found, even if an error was detected. sneak mode activated. 🀐
  • -s, --no-messages β€” suppresses error messages. all normal output is still produced, but error messages (if any) are not shown. πŸ’œ
heads up though: currently libzwerg produces some error messages on its own (e.g. division by zero), and those are still displayed. so like, not fully silent, sorry bestie 😭
  • --help β€” shows help and exits. 🫢
  • --version β€” shows version in the format MAJOR.MINOR and exits. πŸ”₯
  • --a=ARG β€” passes an evaluated argument to the running script. the argument is parsed as a Zwerg program and interpreted on an empty stack. TOS of each yielded stack is taken and pushed to the program stack before the query is executed. 🧠

formally, a command line such as this: dwgrep -e PROG --a X --a Y ... is interpreted like the following Zwerg snippet:

let .X := *X*;
let .Y := *Y*;
...
.X .Y *PROG*

in particular this means that if an argument yields more than once, the whole following computation is "forked" and in each branch the argument has a different value. 🌈

ELF files mentioned on the command line are passed as the first command line argument. i.e. a dwgrep invocation such as this:

dwgrep -e PROG --a X --a Y ... file1 file2 ...

is handled as follows:

dwgrep -e PROG --a '("file1", "file2", ...) dwopen' --a X --a Y ...

thus one can bind the explicitly-mentioned command line arguments to named variables and leave the ELF files themselves as implicit argument of the expression itself, as is usual when writing argument-less queries. consider:

dwgrep file1 file2 -e 'entry foo bar baz'
dwgrep file1 file2 --a A --a B -e '(|A B| entry foo bar baz)'

πŸ”₯ EXAMPLES πŸ”₯

Find ELF files:

$ dwgrep -sh $(find /usr/lib64/ -type f) -e 'name'
/usr/lib64/libogrove.so.0.0.1
/usr/lib64/libmp3lame.so.0.0.0
/usr/lib64/libgimpcolor-2.0.so.0.600.12
/usr/lib64/libmx-gtk-1.0.so.0.0.0
/usr/lib64/libkpimidentities.so.4.6.0
[... etc ...]

Find ELF files that include Dwarf information:

$ dwgrep -sh $(find /usr/lib64/ -type f) -e '?(unit) name'
/usr/lib64/python3.2/config-3.2mu/python.o
/usr/lib64/libxqilla.so.5.0.4
[... etc ...]

Find namespace names defined in one of them:

$ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
        entry ?TAG_namespace name' | sort -u
__debug
__detail
__gnu_cxx
__gnu_debug
std
xercesc_3_0
XQParser

Find names of variables defined in the namespace xercesc_3_0:

$ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
        entry ?TAG_namespace (name == "xercesc_3_0")
        child ?TAG_variable name' | sort -u
chAmpersand
chAsterisk
chAt
chBackSlash
chBang
[... etc ...]

Of those, only list the ones that don't start in ch:

$ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
        entry ?TAG_namespace (name == "xercesc_3_0")
        child ?TAG_variable name
        (!~ "ch.*")' | sort -u
gControlCharMask
gDefOutOfMemoryErrMsg
gFirstNameCharMask
gNameCharMask

Look where they are declared:

$ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
        entry ?TAG_namespace (name == "xercesc_3_0")
        child ?TAG_variable (name !~ "ch.*")
        @AT_decl_file' | sort -u
/usr/include/xercesc/util/OutOfMemoryException.hpp
/usr/include/xercesc/util/XMLChar.hpp

Use formatting strings to include line number information in the mix:

$ dwgrep /usr/lib64/libxqilla.so.5.0.4 -e '
        entry ?TAG_namespace (name == "xercesc_3_0")
        child ?TAG_variable (name !~ "ch.*")
        "%(@AT_decl_file%): %(dup @AT_decl_line%)"' | sort -u
/usr/include/xercesc/util/OutOfMemoryException.hpp: 32
/usr/include/xercesc/util/XMLChar.hpp: 33
/usr/include/xercesc/util/XMLChar.hpp: 34
/usr/include/xercesc/util/XMLChar.hpp: 35
[... etc ...]

more examples are available in documentation on syntax and in the tutorial. πŸ“šβœ¨


🌈 SEE ALSO 🌈

to learn more about Dwarf, check out:


πŸ‘‘ AUTHOR πŸ‘‘

Petr Machata 🫢


2014, 2015, 2017, 2018, Petr Machata


and that's the whole thing, bestie πŸŽ€ version 0.4, dated Jul 23, 2025 β€” go query some debuginfo, you absolute icon πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • fedora 43: dwgrep 0.4-23.fc43 Β· GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms