phate / jlm

GNU Lesser General Public License v2.1
44 stars 14 forks source link

Improve dot output slightly, to make ports easier to click in my tool #481

Closed haved closed 1 month ago

haved commented 1 month ago

While debugging other things, I caved and put together a little web-app to render the Graphviz output, where I can click the nodes, ports and edges to look at their attributes, and highlight related elements. It is lacking features, and doesn't look good (highlight colors are extremely arbitrary), but it did help me debug :)

Note that the webapp should be able to render any Graphviz, not just output from the GraphWriter. The utility of the tool is of course greater when nodes and edges have non-standard attributes.

This PR gives nodes a white fill instead of being transparent, making them easier to click (can click anywhere instead of on text or border). The rest of the PR is just cleanup of the code used to dump the PointerObjectSet subset graph.

If you want to try the webapp, it's hosted at https://dot-tree-viz.vercel.app/.

The code I wrote to dump RVSDG using the GraphWriter is not included, as it was very ad hoc (see e.g. the type graph that does no de-duplication).

Here is some example GraphViz ``` digraph graph0 { node[shape=box style=filled fillcolor=white]; penwidth=6; label="Type graph" node0 [label=ptr tooltip="555d654afb10" ]; node1 [label=ptr tooltip="555d6547ca90" ]; node2 [label=iostate tooltip="555d65484230" ]; node3 [label=mem tooltip="555d65484290" ]; node4 [label=ptr tooltip="555d6549b3a0" ]; node5 [label=bit32 tooltip="555d6547ead0" ]; node6 [label=bit32 tooltip="555d65476b40" ]; node7 [label=bit32 tooltip="555d65499260" ]; node8 [label=bit32 tooltip="555d65499040" ]; node9 [label=vararg tooltip="555d6547cc20" ]; node10 [label=bit32 tooltip="555d65474c20" ]; node11 [label=ptr tooltip="555d6546f9b0" ]; node12 [label=mem tooltip="555d6546fa80" ]; node13 [label=mem tooltip="555d6547ca30" ]; node14 [label=ptr tooltip="555d65487a80" ]; node15 [label=ptr tooltip="555d6548f240" ]; node16 [label=struct tooltip="555d65471670" ]; node17 [label=bit32 tooltip="555d654afaa0" ]; node18 [label=ptr tooltip="555d65483c50" ]; node19 [label=iostate tooltip="555d65471760" ]; node20 [label=mem tooltip="555d65471810" ]; node21 [label=bit32 tooltip="555d654ab7b0" ]; node22 [label=ptr tooltip="555d65480ab0" ]; node23 [label=mem tooltip="555d65476920" ]; node24 [label=mem tooltip="555d654773f0" ]; node17 -> node16[id=edge0 ]; node18 -> node16[id=edge1 ]; } digraph graph1 { node[shape=box style=filled fillcolor=white]; penwidth=6; label="RVSDG root graph" tooltip="555d65497890" { rank=source; a0 [label=a0 type=node0 tooltip="555d65488270" ]; } node25 [shape=plain style=solid label=<
LAMBDA[reorder_basic_blocks]
graph2
> tooltip="555d6549b420" ]; { rank=sink; r2 [label=r2 tooltip="555d6547e270" ]; } a0 -> node25:i0:n[id=edge25 ]; node25:o0:s -> r2[id=edge26 ]; } digraph graph2 { node[shape=box style=filled fillcolor=white]; penwidth=6; tooltip="555d65493e20" { rank=source; a1 [label=a1 type=node2 tooltip="555d65489b00" ]; a2 [label=a2 type=node3 tooltip="555d65474340" ]; a1 -> a2[style=invis]; a3 [label=a3 type=node4 tooltip="555d65488150" ]; a2 -> a3[style=invis]; } node26 [shape=plain style=solid label=<
BITS32(1)
> tooltip="555d65476bc0" ]; node27 [shape=plain style=solid label=<
BITS32(0)
> tooltip="555d654769a0" ]; node28 [shape=plain style=solid label=<
BITS32(0)
> tooltip="555d654990c0" ]; node29 [shape=plain style=solid label=<
BITS32(0)
> tooltip="555d654718a0" ]; node30 [shape=plain style=solid label=<
VALIST
> tooltip="555d654897a0" ]; node31 [shape=plain style=solid label=<
BITS32(1)
> tooltip="555d65476d90" ]; node32 [shape=plain style=solid label=<
ALLOCA[struct]
> tooltip="555d65476e20" ]; node33 [shape=plain style=solid label=<
MemStateMerge
> tooltip="555d654ae220" ]; node34 [shape=plain style=solid label=<
GetElementPtr
> tooltip="555d654993b0" ]; node35 [shape=plain style=solid label=<
GetElementPtr
> tooltip="555d6547eba0" ]; node36 [shape=plain style=solid label=<
CALL
> tooltip="555d65473470" ]; node37 [shape=plain style=solid label=<
ExtractValue
> tooltip="555d6548ddf0" ]; node38 [shape=plain style=solid label=<
ExtractValue
> tooltip="555d6548f2c0" ]; node39 [shape=plain style=solid label=<
Store
> tooltip="555d654ab830" ]; node40 [shape=plain style=solid label=<
Store
> tooltip="555d65480b30" ]; { rank=sink; r0 [label=r0 tooltip="555d65477490" ]; r1 [label=r1 tooltip="555d65477550" ]; r0 -> r1[style=invis]; } node31:o6:s -> node32:i1:n[id=edge2 ]; node32:o8:s -> node33:i2:n[id=edge3 color="#FF0000" ]; a2 -> node33:i3:n[id=edge4 color="#FF0000" ]; node32:o7:s -> node34:i4:n[id=edge5 ]; node29:o4:s -> node34:i5:n[id=edge6 ]; node28:o3:s -> node34:i6:n[id=edge7 ]; node32:o7:s -> node35:i7:n[id=edge8 ]; node27:o2:s -> node35:i8:n[id=edge9 ]; node26:o1:s -> node35:i9:n[id=edge10 ]; a3 -> node36:i10:n[id=edge11 ]; node30:o5:s -> node36:i11:n[id=edge12 ]; a1 -> node36:i12:n[id=edge13 color="#00FF00" ]; node33:o9:s -> node36:i13:n[id=edge14 color="#FF0000" ]; node36:o12:s -> node37:i14:n[id=edge15 ]; node36:o12:s -> node38:i15:n[id=edge16 ]; node34:o10:s -> node39:i16:n[id=edge17 ]; node37:o15:s -> node39:i17:n[id=edge18 ]; node36:o14:s -> node39:i18:n[id=edge19 color="#FF0000" ]; node35:o11:s -> node40:i19:n[id=edge20 ]; node38:o16:s -> node40:i20:n[id=edge21 ]; node39:o17:s -> node40:i21:n[id=edge22 color="#FF0000" ]; node36:o13:s -> r0[id=edge23 color="#00FF00" ]; node40:o18:s -> r1[id=edge24 color="#FF0000" ]; } ```
haved commented 1 month ago

I agree using references is nicer, so it has been changed.