https://github.com/Snape3058 created https://github.com/llvm/llvm-project/pull/85515
When developing on a headless device through SSH, we do not have a browser or even an X environment. Hence, it would be more convenient if the rewriter could stop before attempting to open the generated HTML file. Then, it can be opened remotely through an HTML server. This patch adds a new option `--dump-html-only` with a shortcut `-x` to make the rewriter stop before opening the generated HTML in a browser. The new option is marked in conflict with the existing `--dump-dot-only` option to prevent unexpected behaviors. >From 1d37cd1a7dac2ddb05fdcf125483991b3ac645d8 Mon Sep 17 00:00:00 2001 From: Ella Ma <alansnape3...@gmail.com> Date: Sat, 16 Mar 2024 18:25:12 +0800 Subject: [PATCH] allow egraph rewriter not to open html directly --- .../utils/analyzer/exploded-graph-rewriter.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py index c7c6315a0a27d1..ffec964d8ef09a 100755 --- a/clang/utils/analyzer/exploded-graph-rewriter.py +++ b/clang/utils/analyzer/exploded-graph-rewriter.py @@ -479,12 +479,14 @@ def add_raw_line(self, raw_line): # A visitor that dumps the ExplodedGraph into a DOT file with fancy HTML-based # syntax highlighing. class DotDumpVisitor: - def __init__(self, do_diffs, dark_mode, gray_mode, topo_mode, dump_dot_only): + def __init__(self, do_diffs, dark_mode, gray_mode, topo_mode, dump_dot_only, + dump_html_only): self._do_diffs = do_diffs self._dark_mode = dark_mode self._gray_mode = gray_mode self._topo_mode = topo_mode self._dump_dot_only = dump_dot_only + self._dump_html_only = dump_html_only self._output = [] def _dump_raw(self, s): @@ -998,6 +1000,8 @@ def write_temp_file(suffix, prefix, data): '<html><body bgcolor="%s">%s</body></html>' % ("#1a1a1a" if self._dark_mode else "white", svg), ) + if self._dump_html_only: + return if sys.platform == "win32": os.startfile(filename) elif sys.platform == "darwin": @@ -1176,7 +1180,8 @@ def main(): default=False, help="black-and-white mode", ) - parser.add_argument( + dump_conflict = parser.add_mutually_exclusive_group() + dump_conflict.add_argument( "--dump-dot-only", action="store_const", dest="dump_dot_only", @@ -1186,6 +1191,14 @@ def main(): "displaying it, dump the rewritten dot file " "to stdout", ) + dump_conflict.add_argument( + "--dump-html-only", + action="store_const", + dest="dump_html_only", + const=True, + default=False, + help="do not open the generated HTML immediately", + ) args = parser.parse_args() logging.basicConfig(level=args.loglevel) @@ -1206,7 +1219,8 @@ def main(): explorer = BasicExplorer() visitor = DotDumpVisitor( - args.diff, args.dark, args.gray, args.topology, args.dump_dot_only + args.diff, args.dark, args.gray, args.topology, args.dump_dot_only, + args.dump_html_only ) for trimmer in trimmers: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits