aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initrdscripts/initramfs-framework/debug
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2011-12-07 21:23:00 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-12-08 15:14:05 +0000
commit7b69ad2167a1f0e57db82817b98a0cbcb70a0dd3 (patch)
treeb5715e5e90ea8174dbfb0646d81bad43609eb2dd /meta/recipes-core/initrdscripts/initramfs-framework/debug
parentc9f714062c1100cedbcb2c16d16656e3f5442133 (diff)
downloadopenembedded-core-contrib-7b69ad2167a1f0e57db82817b98a0cbcb70a0dd3.tar.gz
initramfs-framework: provides a modular initramfs
Provides the API and modules for a modular initramfs. The currently included modules are: * initramfs-module-debug adds support to dynamic debugging of initramfs using bootparams * initramfs-module-udev: enables udev usage * initramfs-module-mdev: enables mdev usage * initramfs-module-e2fs: adds support for ext4, ext3 and ext2 filesystems Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'meta/recipes-core/initrdscripts/initramfs-framework/debug')
-rw-r--r--meta/recipes-core/initrdscripts/initramfs-framework/debug82
1 files changed, 82 insertions, 0 deletions
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:<module> : starts a shell before <module> is loaded and run
+# shell=after:<module> : starts a shell after <module> is loaded and run
+#
+# shell-debug : run set -x as soon as possible
+# shell-debug=before:<module> : run set -x before <module> is loaded and run
+# shell-debug=after:<module> : run set -x after <module> 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"
+}