Skip to content
Snippets Groups Projects
Commit d23d934a authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

search: Beautify graphs

Makes the nodes rectangular and adds more information in their
description.
parent f0d01faf
No related branches found
No related tags found
No related merge requests found
......@@ -144,13 +144,25 @@ handleLine pstdin state = parseLine pstdin >>= \case
graph2Dot :: Graph -> Text
graph2Dot graph =
"digraph gcfg {\n"
<> dotNodes graph
<> M.foldMapWithKey nodeStr graph
<> "}"
where
nodeStr from tos = mconcat $ map (arrow from) $ S.toList tos
arrow from to = " " <> num2str from <> " -> "
<> num2str to <> " [label=\"" <> edgeLabel (fst from) <> "\"];\n"
num2str (call, state) = T.tail state <> "_" <> call
arrow from to = " " <> nodeId from <> " -> "
<> nodeId to <> " [label=\"" <> edgeLabel (fst from) <> "\"];\n"
edgeLabel txt = T.dropEnd 1 $ T.dropWhileEnd (/='_') $
T.drop (T.length "OSEKOS_") txt
dotNodes :: Graph -> Text
dotNodes = foldMap formatNode . M.keys
where
formatNode (call, state) = nodeId (call,state)
<> " [label=\""
<> "State: " <> state <> "\\n"
<> "Syscall: " <> call
<> "\", shape=box];\n"
nodeId :: Vertex -> Text
nodeId (call, state) = "node" <> state <> "_" <> call
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment