commit 0b9081fa538de6b5f995a68f8a6f05f5f1df17cf
parent 508af1a4cd4debb9da3ad61afef317c818d7cb8d
Author: Jacob R. Edwards <n/a>
Date: Wed, 23 Nov 2022 17:05:43 -0600
Add C writing utility scripts
Cdec is simply a combination of cdec and cnoname, and ctrace is a
janky sed script (in which -i may be passed) that tries to tell you
when functions have been entered and left. It is imperfect, but can
be useful (although there's certainly a better way of doing it).
(These have existed for a long time, but were never added for one
reason or another.)
Diffstat:
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/local/bin/bin/Cdec b/local/bin/bin/Cdec
@@ -0,0 +1,5 @@
+#!/bin/sh
+# Copyright 2022 Jacob R. Edwards
+# Produce C function declarations without variable names
+
+cdec "$@" | cnoname
diff --git a/local/bin/bin/ctrace b/local/bin/bin/ctrace
@@ -0,0 +1,18 @@
+#!/usr/bin/sed -f
+# Copyright 2021 Jacob R. Edwards
+# Insert function call tracing dprintf calls
+#
+# This makes many assumtions which all usually work fine except for
+# return statements which return a funtions return ('return func()').
+
+/^[A-Za-z0-9_]*(.*)$/ N
+
+/^[A-Za-z0-9_]*(.*)[\n ]{$/ a\
+ dprintf(2, "-> %s()\\n", __func__);
+
+/return[( ]/ { i\
+{\
+ dprintf(2, "<- %s()\\n", __func__);
+ a\
+}
+}