blob: fbcce0993736ffe850419de6fe5b9065b2de764d [file] [log] [blame]
shijie.xiong1beacb22023-06-06 16:08:52 +08001#!/bin/bash
2#
3# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
4#
5# SPDX-License-Identifier: MIT
6#
7
8#RTOS root directory
9RTOS_BASE_DIR=$(realpath $(dirname $(readlink -f ${BASH_SOURCE[0]:-$0}))/..)
10
11function usage() {
12 echo -e "\033[41;33m Notice: parameter error !!! \033[0m"
13 echo -e "\033[33m usage: ./coredump_process.sh (elf_file_path) (log_file_path)\033[0m"
14 exit 1
15}
16
17if [ -s "$1" ] && [ -s "$2" ]; then
18 COREDUMP_LOG=$(readlink -f "$2")
19 COREDUMP_BIN=$(dirname "$COREDUMP_LOG")/coredump.bin
20 COREDUMP_ELF=$(readlink -f "$1")
21
22 # Parse coredump log file.
23 $RTOS_BASE_DIR/lib/utilities/coredump/scripts/coredump_serial_log_parser.py $COREDUMP_LOG $COREDUMP_BIN
24
25 if [ $? -ne 0 ]; then
26 echo "Failed to parse coredump file ! $COREDUMP_LOG"
27 exit 1
28 fi
29
30 # Start gdbstub server.
31 $RTOS_BASE_DIR/lib/utilities/coredump/scripts/coredump_gdbserver.py $COREDUMP_ELF $COREDUMP_BIN &
32
33 if [ $? -ne 0 ]; then
34 echo "Failed to start gdbstub service !"
35 exit 1
36 fi
37
38 # Start gdbstub terminal
39 pushd $RTOS_BASE_DIR/output/toolchains/gcc-aarch64-none-elf/bin
40 aarch64-none-elf-gdb $COREDUMP_ELF
41 popd
shijie.xiong68133462023-06-26 17:14:04 +080042
43 # Clean up the abnormal exit problem of gdbstub
44 pid=$(lsof -t -i :1234)
45
46 if [ -n "$pid" ]; then
47 kill $pid
48 fi
shijie.xiong1beacb22023-06-06 16:08:52 +080049else
50 usage
51fi