summaryrefslogtreecommitdiff
path: root/build-aux/measurestack/analyze.py
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-12 14:26:21 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-12 14:26:21 -0600
commit811d9700e1414dae3357361b3ca565f673f63b08 (patch)
treece628075a2ae59d5362d2662465c918f57e81607 /build-aux/measurestack/analyze.py
parentcd5e55ebb7d5a51c0a8bd62137ab75a0f6ff1356 (diff)
parentb4a081932338f65aa87aeba5008463feb0a78519 (diff)
Merge branch 'lukeshu/misc'HEADmain
Diffstat (limited to 'build-aux/measurestack/analyze.py')
-rw-r--r--build-aux/measurestack/analyze.py56
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: