diff options
| author | Jayanth Othayoth <ojayanth@in.ibm.com> | 2017-08-09 07:10:39 -0500 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2017-08-22 20:48:18 +0000 |
| commit | 47a14167d159f783f0d4931f030fc8630bdca8ec (patch) | |
| tree | e4f57fd8a50563f6de16d7f1054d6da1c3e9438a /tools | |
| parent | f1e02d3357a9147537c0cc2dceb202ac7a5d9b06 (diff) | |
| download | phosphor-debug-collector-47a14167d159f783f0d4931f030fc8630bdca8ec.tar.gz phosphor-debug-collector-47a14167d159f783f0d4931f030fc8630bdca8ec.zip | |
dreport: Implementation of extracting pid from the core file name
Change-Id: I5605f6f5697ccd4bffa58917b3c6d660a301c6cd
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/dreport | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/dreport b/tools/dreport index 03f6e13..9f6afca 100755 --- a/tools/dreport +++ b/tools/dreport @@ -65,6 +65,7 @@ declare -x dreport_log="" declare -x summary_log="" declare -x cur_dump_size=0 declare -a command_list=("") +declare -x core_pid="0" # @brief Initialize user type command array function runlevel_user() @@ -305,6 +306,29 @@ function run_command() fi } +# @brief get pid from the file +# dreport "core" type user provides core file as optional file parameter. +# As per coredump source code systemd-coredump uses below format +# https://github.com/systemd/systemd/blob/master/src/coredump/coredump.c +# /var/lib/systemd/coredump/core.%s.%s." SD_ID128_FORMAT_STR “. +# <process ID>.%s000000" +# Added additional check to make sure that user provided in +# systemd-coredump format. +function set_pid() +{ + #from coredump.c file. + CORE_BASE_STRING="/var/lib/systemd/coredump/core" + + #Escape bash characters in file name + file=$(printf %q "$optional_file") + + string=$(echo $file | awk -F . '{ print $1}') + if [ "$CORE_BASE_STRING" = "$string" ]; then + #matching systemd-coredump core file format. + core_pid=$(echo $file | awk -F . '{ print $5}') + fi +} + # @brief Capture debug data based on the input command array. # and stores in to global temporary name specific location. # @param $1 Source array |

