mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-07 17:46:15 +00:00
This patch adds the usercrash client in the pipe of core_pattern without affecting default core_pattern program. In acrnprobe_prepare.sh, core_pattern will be set as usercrash-wrapper with all of the arguments, which parses the parameters of the default core_pattern program and the usercrash client, and then invokes them separately. Tracked-On: #1024 Signed-off-by: CHEN Gang <gang.c.chen@intel.com> Reviewed-by: Zhi Jin <zhi.jin@intel.com> Reviewed-by: xiaojin2 <xiaojing.liu@intel.com> Acked-by: Zhang Di <di.zhang@intel.com>
130 lines
3.0 KiB
Bash
Executable File
130 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (C) <2018> Intel Corporation
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
#
|
|
|
|
if [ $# != 13 ]; then
|
|
logger "Expected 13 arguments, got $#"
|
|
exit -1
|
|
fi
|
|
|
|
# Error Handling
|
|
default_core_pattern_file="/var/log/crashlog/default_core_pattern"
|
|
|
|
if [ ! -f $default_core_pattern_file ]; then
|
|
logger "File default_core_pattern doesn't exist under /var/log/crashlog"
|
|
exit -1
|
|
fi
|
|
|
|
# default coredump app and usercrash parameters index file under /tmp
|
|
d_param_index_file=/tmp/default_param_index_file
|
|
u_param_index_file=/tmp/usercrash_param_index_file
|
|
|
|
# function to get the params from the input arguments
|
|
function get_params()
|
|
{
|
|
raw_params=$1
|
|
|
|
count=$[(${#raw_params} + 1) / 3]
|
|
for((i=0;i<$count;i++))
|
|
do
|
|
a_index=$[$i * 3 + 1]
|
|
param_list[$i]=${raw_params:($a_index):1}
|
|
done
|
|
return 0;
|
|
}
|
|
|
|
# function to generate the index for the parameters of default coredump app
|
|
function gen_index()
|
|
{
|
|
full_list=$1
|
|
dump_list=$2
|
|
|
|
i=0
|
|
for arg in ${dump_list[@]}
|
|
do
|
|
q=(`expr \`expr $(expr index "$full_list" "$arg") + 1\` / 2`)
|
|
index[$i]=$[$q - 1]
|
|
let i+=1
|
|
done
|
|
return 0;
|
|
}
|
|
|
|
# get default core_pattern parameters list
|
|
default_content=`cat $default_core_pattern_file`
|
|
default_params=${default_content#* }
|
|
|
|
# abstract the application of the default core_pattern
|
|
t_app=${default_content%% *}
|
|
default_app=${t_app#*|}
|
|
|
|
# function to save the index to /tmp. The index is the parameter
|
|
# index of the default coredump app and usercrash referring to
|
|
# the full parameters.
|
|
function save_index()
|
|
{
|
|
# get full coredump parameters list
|
|
pattern=`cat /proc/sys/kernel/core_pattern`
|
|
full_params=${pattern#* }
|
|
|
|
get_params "$full_params"
|
|
for((i=0;i<$count;i++))
|
|
do
|
|
full_param_list[$i]=${param_list[$i]}
|
|
done
|
|
|
|
get_params "$default_params"
|
|
for((i=0;i<$count;i++))
|
|
do
|
|
default_param_list[$i]=${param_list[$i]}
|
|
done
|
|
|
|
# get the index of default parameter list accroding to
|
|
# the full parameter list
|
|
gen_index "${full_param_list[*]}" "${default_param_list[*]}"
|
|
for((j=0;j<$i;j++))
|
|
do
|
|
default_param_index[$j]=${index[$j]}
|
|
done
|
|
echo "${default_param_index[@]}" > $d_param_index_file
|
|
|
|
# get the index of usercrash_c parameter accroding to
|
|
# the full parameter list
|
|
usercrash_param_list=("p" "e" "s")
|
|
gen_index "${full_param_list[*]}" "${usercrash_param_list[*]}"
|
|
for((j=0;j<$i;j++))
|
|
do
|
|
usercrash_param_index[$j]=${index[$j]}
|
|
done
|
|
echo "${usercrash_param_index[@]}" > $u_param_index_file
|
|
}
|
|
|
|
if [[ ! -f $d_param_index_file ]] || [[ ! -f $u_param_index_file ]];then
|
|
save_index
|
|
fi
|
|
|
|
# get all the value of parameters in var[]
|
|
i=0
|
|
for p in "$@"
|
|
do
|
|
var[$i]=$p
|
|
let i+=1
|
|
done
|
|
|
|
str_usercrash_param_index=`cat $u_param_index_file`
|
|
u_param_index_arr=(${str_usercrash_param_index// / })
|
|
for((i=0;i<${#u_param_index_arr[@]};i++))
|
|
do
|
|
usercrash_var[$i]=${var[${u_param_index_arr[$i]}]}
|
|
done
|
|
|
|
str_default_param_index=`cat $d_param_index_file`
|
|
d_param_index_arr=(${str_default_param_index// / })
|
|
for((i=0;i<${#d_param_index_arr[@]};i++))
|
|
do
|
|
default_var[$i]=${var[${d_param_index_arr[$i]}]}
|
|
done
|
|
|
|
tee >(/usr/bin/usercrash_c ${usercrash_var[*]}) | $default_app ${default_var[*]}
|