Closed didibib closed 1 year ago
What does "the inspector" mean?
The visual studio inspector, where I can view variables. .
Why use a debugger? They are notoriously bad at dealing with optimizable variables. E.g. using my Vim to debug I can confirm:
Note <optimized out>
.
Note this is even still the case with building at -O0 -fno-omit-frame-pointer
. So, instead just print the information:
id:"n0" owner_id:"G"
id:"n1" owner_id:"G"
id:"n10" owner_id:"G"
id:"n100" owner_id:"G"
id:"n101" owner_id:"G"
id:"n102" owner_id:"G"
...
id:"n97" owner_id:"G"
id:"n98" owner_id:"G"
id:"n99" owner_id:"G"
Remaining unparsed input: '
'
Now this may not be what you expected, but I expect the expectation may be wrong. I've carefully compared the behavior of graphviz (courtesy libgraph) using the nop
layout engine and they clearly suggest a complicated behavior where ownership isn't fixed during lexical parsing. I.e. if you reduce the input to be:
the output becomes
You can tweak the semantics by looking at https://github.com/sehe/spirit-graphviz/blob/master/spirit-graphviz.hpp#L559
} else {
if (&owner != it->owner)
debug << "Reassigning node " << id
<< (it->owner ? " from graph '" + it->owner->id + "'"
: "")
<< " to graph '" << owner.id << "'\n";
}
all_nodes.modify(it, [&owner](OwnedNode& on) { /*if (not on.owner)*/ on.owner = &owner; });
Changing it to read something more like:
} else {
if (&owner != it->owner)
debug << "Not reassigning node " << id
<< (it->owner ? " from graph '" + it->owner->id + "'" : "")
<< " to graph '" << owner.id << "'\n";
}
all_nodes.modify(it, [&owner](OwnedNode& on) { if (not on.owner) on.owner = &owner; });
Keep in mind that YMMV. I feel it makes a lot of sense to retain initial node ownership (as evidenced by the existence of the commented
if (not on.owner)
condition), but it might prove harder to roundtrip/achieve parity with graphviz's native semantics. If that's not important for your use-case, by all means tweak to taste :)
In order for me to be able to print these lines lines id:"n0" owner_id:"G"...
I had to run it in Release mode, but the code block at https://github.com/sehe/spirit-graphviz/blob/3590f8500dbca93fb307e97dfb433a8514c667f2/spirit-graphviz.hpp#L179 would be grayed out and then I would get the error
C2679 binary '<<': no operator found which takes a right-hand operand of type 'T' (or there is no acceptable conversion)boost\fusion\sequence\io\detail\out.hpp 62
In the build output it said that the error was generated by this line
spirit-graphviz.hpp(243,111): message : see reference to function template instantiation
.
I just removed the guards, but maybe this information is useful for you.
I out-commented the if (not on.owner)
condition, because that is indeed the behavior I needed.
Thanks for your help!
Yeah the AST printing code was originally only intended for debugging. With BOOST_SPIRIT_DEBUG, mind you, not using a debugger.
Glad you found the code useful, good luck!
I am loading in devonshiredebate_withclusters.dot which contains subgraphs. I want to know to which subgraph each node belongs. Each node has a owner, but when inspecting
owner->id
it says<Error reading characters of string.>
in the inspector.g->graph->subgraphs
hassize=11
, so the subgraphs are found I assume.