diff --git a/src/Search/Search.hs b/src/Search/Search.hs index 8438cf7e8c972262c756243a914b62e858f99bd5..9fcbf3af0c97a2bf2cfa888e3ead2b371642c17d 100644 --- a/src/Search/Search.hs +++ b/src/Search/Search.hs @@ -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