From c527fd1f14c27855a37f2e8ac5346ce8d940ced2 Mon Sep 17 00:00:00 2001 From: Tudor Florea Date: Thu, 16 Oct 2014 03:05:19 +0200 Subject: initial commit for Enea Linux 4.0-140929 Migrated from the internal git server on the daisy-enea-point-release branch Signed-off-by: Tudor Florea --- .../initrdscripts/initramfs-framework/debug | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 meta/recipes-core/initrdscripts/initramfs-framework/debug (limited to 'meta/recipes-core/initrdscripts/initramfs-framework/debug') diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/debug b/meta/recipes-core/initrdscripts/initramfs-framework/debug new file mode 100644 index 0000000000..00bfd7d3f5 --- /dev/null +++ b/meta/recipes-core/initrdscripts/initramfs-framework/debug @@ -0,0 +1,82 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +# Adds support to dynamic debugging of initramfs using bootparam in +# following format: +# shell : starts a shell before and after each module +# shell=before: : starts a shell before is loaded and run +# shell=after: : starts a shell after is loaded and run +# +# shell-debug : run set -x as soon as possible +# shell-debug=before: : run set -x before is loaded and run +# shell-debug=after: : run set -x after is loaded and run + +DEBUG_SHELL="false" + +debug_hook_handler() { + status=$1 + module=$2 + + if [ -n "$bootparam_shell" ] && [ "$bootparam_shell" != "true" ]; then + shell_wanted_status=`expr $bootparam_shell : '\(.*\):.*'` + shell_wanted_module=`expr $bootparam_shell : '.*:\(.*\)'` + + if [ "$shell_wanted_status" = "before" ]; then + shell_wanted_status=pre + else + shell_wanted_status=post + fi + fi + + if [ "$bootparam_shell" = "true" ] || + ( [ "$status" = "$shell_wanted_status" ] && + [ "$module" = "$shell_wanted_module" ] ); then + if [ "$status" = "pre" ]; then + status_msg="before" + else + status_msg="after" + fi + + msg "Starting shell $status_msg $module..." + sh + fi + + if [ -n "$bootparam_shell_debug" ] && [ "$bootparam_shell_debug" != "true" ]; then + shell_debug_wanted_status=`expr $bootparam_shell_debug : '\(.*\):.*'` + shell_debug_wanted_module=`expr $bootparam_shell_debug : '.*:\(.*\)'` + + if [ "$shell_debug_wanted_status" = "before" ]; then + shell_debug_wanted_status=pre + else + shell_debug_wanted_status=post + fi + fi + + if [ "$bootparam_shell_debug" = "true" ] || + ( [ "$status" = "$shell_debug_wanted_status" ] && + [ "$module" = "$shell_debug_wanted_module" ] ); then + if [ "$DEBUG_SHELL" = "true" ]; then + return 0 + fi + + if [ "$status" = "pre" ]; then + status_msg="before" + else + status_msg="after" + fi + + msg "Starting shell debugging $status_msg $module..." + DEBUG_SHELL="true" + set -x + fi +} + +debug_enabled() { + return 0 +} + +debug_run() { + add_module_pre_hook "debug_hook_handler" + add_module_post_hook "debug_hook_handler" +} -- cgit v1.2.3-54-g00ecf