kennyshields.net
About Projects

DSymList

Published: May 20, 2023

About

DSymList is a program for listing D Language symbols in binary files. It can print the symbols to a terminal or save them to a file, and is also capeable of searching for symbols within specific namespaces. DSymList uses the nm program as a back-end for symbol extraction.

Basic Usage

To use DSymList, simply run it in a terminal and provide it with the path of the file you wish to examine:

./dsymlist path/to/my-d-binary

If the file contains D symbols, you should begin to see output immediately. Here is a sample of what that might look like:

std.stdio (4)
{
    ulong : readlnImpl ( shared(core.stdc.stdio._IO_FILE)*, ref char[], dchar, std.stdio.File.Orientation )
    char* : readlnImpl ( shared(core.stdc.stdio._IO_FILE)*, ref char[], dchar, std.stdio.File.Orientation )
    ulong : readlnImpl ( shared(core.stdc.stdio._IO_FILE)*, ref char[], dchar, std.stdio.File.Orientation )
    @property @trusted std.stdio.File : trustedStdout (  )
} End of std.stdio

All D symbols will be listed by default, including symbols imported from Phobos, etc, and core. To perform a more granular search, read the “Advanced Usage” section below.

Advanced Usage

Naturally, if you’re looking for specific symbols in a file, you might not want see all of the other symbols that were imported during compilation. To solve this issue, DSymList provides support for a “namespace” option, which takes a comma-seperated list of module namespaces to use when searching. When namespaces are provided, DSymList will only display symbols in those namespaces. For example, consider that you have the following D module:

module program;

class MyClass
{

    void method1()
    {

    }

private:

    bool method2()
    {
        return true;
    }

}

void myFunc()
{

}

If you wanted to look for symbols matching the namespace of that module, you would run the following:

./dsymlist path/to/my-d-binary --namespace=program

The result would be a list of symbols filtered by the module namespace “program”:

program (1)
{
    void : myFunc (  )
} End of program
program.MyClass (2)
{
    void : method1 (  )
    bool : method2 (  )
} End of program.MyClass

In addition to namespace filtering, DSymList also provides a number of other options to control it’s behavior:

--quiet (-q)Disables printing to stdout.
outfile (-o)File path to write output to.
mangle (-m)Includes the mangled names of D symbols.
spacing (-s)Adds extra spacing to output for improved readability.

License

DSymList is licensed under the MIT License