From 22d27936b3d771a36b170b1f4b4ba58badbf3971 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 10 Dec 2024 02:12:39 -0700 Subject: Get lib9p building on rp2040 --- build-aux/stack.c.gen | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'build-aux') diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen index 86bca26..2ce874d 100755 --- a/build-aux/stack.c.gen +++ b/build-aux/stack.c.gen @@ -164,8 +164,7 @@ def analyze( f"unexpected label value {repr(v)}" ) if m.group("usage_kind") == "dynamic": - pass - #raise ValueError(f"can't handle dynamic stack usage: {repr(elem.attrs.get("title", ""))}") + print(f"// warning: can't handle dynamic stack usage: {repr(elem.attrs.get("title", ""))}") node.location = m.group("location") node.nstatic = int(m.group("nstatic")) node.ndynamic = int(m.group("ndynamic")) @@ -264,32 +263,31 @@ def analyze( ) for grp_name, grp_filter in app_func_filters.items(): - namelen = max( - [len(app_location_xform(name)) for name in graph if grp_filter(name)] - + [len(grp_name) + 4] - ) - numlen = max(len(str(nstatic(name))) for name in graph if name.endswith("_cr")) - sep1 = ("=" * namelen) + " " + "=" * numlen - sep2 = ("-" * namelen) + " " + "-" * numlen - - print("= " + grp_name + " " + sep1[len(grp_name) + 3 :]) - + # Gather the data. nmax = 0 nsum = 0 + rows: dict[str, int] = {} for funcname in graph: if grp_filter(funcname): n = nstatic(funcname) - print( - f"{app_location_xform(funcname).ljust(namelen)} {str(n).rjust(numlen)}" - ) + rows[app_location_xform(funcname)] = n if n > nmax: nmax = n nsum += n + # Figure sizes. + namelen = max([len(k) for k in rows.keys()] + [len(grp_name) + 4]) + numlen = len(str(nsum)) + sep1 = ("=" * namelen) + " " + "=" * numlen + sep2 = ("-" * namelen) + " " + "-" * numlen + + # Print. + print("= " + grp_name + " " + sep1[len(grp_name) + 3 :]) + for name, num in rows.items(): + print(f"{name.ljust(namelen)} {str(num).rjust(numlen)}") print(sep2) print(f"{'Total'.ljust(namelen)} {str(nsum).rjust(numlen)}") print(f"{'Maximum'.ljust(namelen)} {str(nmax).rjust(numlen)}") - print(sep1) for funcname in sorted(missing): @@ -326,7 +324,7 @@ def main( re_call_other = re.compile(r"(?P[^(]+)\(.*") all_nodes: list[Node] = [] - hooks_is_intrhandler: list[typing.Callable([str], bool)] = [] + hooks_is_intrhandler: list[typing.Callable[[str], bool]] = [] hooks_indirect_callees: list[typing.Callable[[str, str], list[str] | None]] = [] hooks_skip_call: list[typing.Callable[[list[str], str], bool]] = [] @@ -379,7 +377,11 @@ def main( hooks_indirect_callees += [sbc_indirect_callees] def sbc_is_thread(name: str) -> bool: - return name.endswith("_cr") or name == "main" + if name.endswith("_cr") and name != "lib9p_srv_read_cr": + return True + if name == "main": + return True + return False def sbc_is_intrhandler(name: str) -> bool: return name in [ @@ -403,8 +405,6 @@ def main( and any(c.endswith(":__assert_msg_fail") for c in chain[:-1]) ): return True - if call == "_cr_select_dequeue": # TODO: FIXME - return True return False hooks_skip_call += [sbc_skip_call] @@ -645,13 +645,6 @@ def main( hooks_indirect_callees += [tud_indirect_callees] - def tud_skip_call(chain: list[str], call: str) -> bool: - if call == "usbd_app_driver_get_cb": # TODO: FIXME - return True - return False - - hooks_skip_call += [tud_skip_call] - # newlib ######################################################### if arg_pico_platform == "rp2040": @@ -671,6 +664,7 @@ def main( synthetic_node("memcpy", 0), # TODO synthetic_node("memset", 0), # TODO synthetic_node("strlen", 0), # TODO + synthetic_node("strnlen", 0), # TODO synthetic_node("strncpy", 0), # TODO # other synthetic_node("random", 0), # TODO -- cgit v1.2.3-2-g168b