diff options
Diffstat (limited to 'build-aux/measurestack/analyze.py')
-rw-r--r-- | build-aux/measurestack/analyze.py | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/build-aux/measurestack/analyze.py b/build-aux/measurestack/analyze.py index 67c44ce..97f1769 100644 --- a/build-aux/measurestack/analyze.py +++ b/build-aux/measurestack/analyze.py @@ -276,7 +276,7 @@ class Application(typing.Protocol): # code ######################################################################### -re_node_label = re.compile( +re_node_normal_label = re.compile( r"(?P<funcname>[^\n]+)\n" + r"(?P<location>[^\n]+:[0-9]+:[0-9]+)\n" + r"(?P<nstatic>[0-9]+) bytes \((?P<usage_kind>static|dynamic|dynamic,bounded)\)\n" @@ -284,6 +284,10 @@ re_node_label = re.compile( + r"(?:\n.*)*", flags=re.MULTILINE, ) +re_node_alias_label = re.compile( + r"(?P<funcname>[^\n]+)\n" + r"(?P<location>[^\n]+:[0-9]+:[0-9]+)", + flags=re.MULTILINE, +) class _Graph: @@ -376,20 +380,44 @@ def _make_graph( case "title": node.funcname = QName(v) case "label": - if elem.attrs.get("shape", "") != "ellipse": - m = re_node_label.fullmatch(v) - if not m: - raise ValueError(f"unexpected label value {v!r}") - node.location = m.group("location") - node.usage_kind = typing.cast( - UsageKind, m.group("usage_kind") - ) - node.nstatic = int(m.group("nstatic")) - node.ndynamic = int(m.group("ndynamic")) + shape: str | None = elem.attrs.get("shape", None) + match shape: + case "ellipse": # external + pass + case "triangle": # alias (since GCC 15) + m = re_node_alias_label.fullmatch(v) + if not m: + raise ValueError( + f"unexpected label value {v!r}" + ) + node.location = m.group("location") + node.usage_kind = "static" + node.nstatic = 0 + node.ndynamic = 0 + case None: # normal + m = re_node_normal_label.fullmatch(v) + if not m: + raise ValueError( + f"unexpected label value {v!r}" + ) + node.location = m.group("location") + node.usage_kind = typing.cast( + UsageKind, m.group("usage_kind") + ) + node.nstatic = int(m.group("nstatic")) + node.ndynamic = int(m.group("ndynamic")) + case _: + raise ValueError( + f"unexpected shape value {shape!r}" + ) case "shape": - if v != "ellipse": - raise ValueError(f"unexpected shape value {v!r}") - skip = True + match v: + case "ellipse": # external + skip = True + case "triangle": # alias (since GCC 15) + pass + case _: + raise ValueError(f"unexpected shape value {v!r}") case _: raise ValueError(f"unknown edge key {k!r}") if not skip: |