From 6273edc2e7179a4bd1a542de69871084e1f18daa Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 14 Sep 2016 15:03:05 +0100 Subject: Add scripts to remove/replace 'static' from functions. Getting a backtrace out with missing functions makes the backtrace much less useful. Some backtrace routines (such as that used by Memento on Android) are incapable of resolving static functions. We therefore provide 2 scripts (scripts/destatic.sh and scripts/restatic.sh) that respectively remove and replace the 'static' from function definitions. The scripts do not affect "static inline" or "static const" definitions, and they are are restricted to working in the source directory (excluding source/tools), thirdparty/mujs and the platform/{java,android} directories. The transformed source should NOT be checked in. To avoid problems with clashing symbols, some functions are renamed or tweaked slightly in this patch. --- scripts/destatic.sh | 16 ++++++++++++++++ scripts/restatic.sh | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 scripts/destatic.sh create mode 100644 scripts/restatic.sh (limited to 'scripts') diff --git a/scripts/destatic.sh b/scripts/destatic.sh new file mode 100644 index 00000000..b6b80701 --- /dev/null +++ b/scripts/destatic.sh @@ -0,0 +1,16 @@ +# Simple script to make all static functions in the main source +# unstatic. This allows backtracing functions (such as that used +# in Memento, in particular on Android) to pick up symbol names +# nicely. +# +# This script can be reversed using restatic.sh + +# Allow for the fact that mujs might not be present +MUJS_SRC= +test -d thirdparty/mujs && MUJS_SRC=thirdparty/mujs + +# Convert everything +sed -i '/^static inline/b;/^static const/b;s!^static !/\*static \*/!' $(find source platform/android/viewer platform/java $MUJS_SRC -name '*.c') + +# Convert source/tools back again. +sed -i 's!/\*static \*/!static !' $(find source/tools -name '*.c') diff --git a/scripts/restatic.sh b/scripts/restatic.sh new file mode 100644 index 00000000..f3f5b7a4 --- /dev/null +++ b/scripts/restatic.sh @@ -0,0 +1,8 @@ +# Simple script to revert the changes made by destatic.sh + +# Allow for the fact that mujs might not be present +MUJS_SRC= +test -d thirdparty/mujs && MUJS_SRC=thirdparty/mujs + +# Convert it all back +sed -i 's!/\*static \*/!static !' $(find source platform/android/viewer platform/java $MUJS_SRC -name '*.c') -- cgit v1.2.3