top | item 29973685

(no title)

lwerdna | 4 years ago

I use graphviz probably weekly and it's actually become a bit of a productivity hack. If there's something I don't want to do, I can often convince myself to just DRAW it instead, usually with graphviz. Once drawn, the actual task is easier, both because the barrier of starting is overcome, and because the drawing is useful in the task.

For example, I had to parse DWARF debug info recently to scrape type information, something I dreaded doing. Instead of diving into the DWARF specs, I set out to adapt one of the pyelftools [1] examples to produce a .dot file and graphed it with dot, producing [2].

Now looking at the picture, it's nearly obvious how functions and structs and types are stored. The rest is trivia (How do I access this attribute? How do I iterate over a DIE's children?).

Here's a simple alias so that anything that writes to /tmp/tmp.dot can be viewed with a single command:

    alias graph='dot -Tpng /tmp/tmp.dot -o /tmp/tmp.png && open /tmp/tmp.png'
[1] https://pypi.org/project/pyelftools/

[2] http://tmp2.dreamhosters.com/draw-dwarf-graph.svg

discuss

order

edwinyzh|4 years ago

Wonderful, the graph is much clearer than text specs.