aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-07-13 00:59:08 +0200
committerThomas Deutschmann <whissi@gentoo.org>2019-07-14 13:58:06 +0200
commit549306a6e9bf0d83fce848836d1a154a591716c4 (patch)
treec1707bb416a95c84fecc143c37e3853d7f4d101f /gen_funcs.sh
parentgen_funcs.sh: Rename isBootRO() function to is_boot_ro() (diff)
downloadgenkernel-549306a6e9bf0d83fce848836d1a154a591716c4.tar.gz
genkernel-549306a6e9bf0d83fce848836d1a154a591716c4.tar.bz2
genkernel-549306a6e9bf0d83fce848836d1a154a591716c4.zip
gen_funcs.sh: Add get_useful_function_stack() function
"Useful" because it will not return the complete stack. Only all functions till calling or specified function while filtering common functions like "main". Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'gen_funcs.sh')
-rwxr-xr-xgen_funcs.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh
index 003300b..93feea4 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -477,6 +477,38 @@ debug_breakpoint() {
exit 99
}
+get_useful_function_stack() {
+ local end_function=${1:-${FUNCNAME}}
+ local n_functions=${#FUNCNAME[@]}
+ local last_function=$(( n_functions - 1 )) # -1 because arrays are starting with 0
+ local first_function=0
+
+ local stack_str=
+ local last_function_name=
+ while [ ${last_function} -gt ${first_function} ]
+ do
+ last_function_name=${FUNCNAME[last_function]}
+ last_function=$(( last_function - 1 ))
+
+ case "${last_function_name}" in
+ __module_main|main)
+ # filter main function
+ continue
+ ;;
+ ${end_function})
+ # this the end
+ break
+ ;;
+ *)
+ ;;
+ esac
+
+ stack_str+="${last_function_name}(): "
+ done
+
+ echo "${stack_str}"
+}
+
trap_cleanup(){
# Call exit code of 1 for failure
cleanup