1 /*
2  * Copyright (C) 2018-2022 Intel Corporation.
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef CRASH_DUMP_H
7 #define CRASH_DUMP_H
8 
9 /**
10  * So far, crash_dump use gdb command to dump process info. But in the future,
11  * we will replace gdb command with a better implementation.
12  */
13 #define GET_GDB_INFO "/usr/bin/gdb %s -batch "\
14 			"-ex 'bt' "\
15 			"-ex 'printf \"\nRegisters\n\"' "\
16 			"-ex 'info registers' "\
17 			"-ex 'printf \"\n\nMemory near rax\n\"' "\
18 			"-ex 'x/16x $rax-0x20' "\
19 			"-ex 'x/48x $rax' "\
20 			"-ex 'printf \"\n\nMemory near rbx\n\"' "\
21 			"-ex 'x/16x $rbx-0x20' "\
22 			"-ex 'x/48x $rbx' "\
23 			"-ex 'printf \"\n\nMemory near rcx\n\"' "\
24 			"-ex 'x/16x $rcx-0x20' "\
25 			"-ex 'x/48x $rcx' "\
26 			"-ex 'printf \"\n\nMemory near rdx\n\"' "\
27 			"-ex 'x/16x $rdx-0x20' "\
28 			"-ex 'x/48x $rdx' "\
29 			"-ex 'printf \"\n\nMemory near rsi\n\"' "\
30 			"-ex 'x/16x $rsi-0x20' "\
31 			"-ex 'x/48x $rsi' "\
32 			"-ex 'printf \"\n\nMemory near rdi\n\"' "\
33 			"-ex 'x/16x $rdi-0x20' "\
34 			"-ex 'x/48x $rdi' "\
35 			"-ex 'printf \"\n\nMemory near rbp\n\"' "\
36 			"-ex 'x/16x $rbp-0x20' "\
37 			"-ex 'x/48x $rbp' "\
38 			"-ex 'printf \"\n\nMemory near rsp\n\"' "\
39 			"-ex 'x/16x $rsp-0x20' "\
40 			"-ex 'x/48x $rsp' "\
41 			"-ex 'printf \"\n\ncode around rip\n\"' "\
42 			"-ex 'x/8i $rip-0x20' "\
43 			"-ex 'x/48i $rip' "\
44 			"-ex 'printf \"\nThreads\n\n\"' "\
45 			"-ex 'info threads' "\
46 			"-ex 'printf \"\nThreads backtrace\n\n\"' "\
47 			"-ex 'thread apply all bt' "\
48 			"-ex 'quit'"
49 
50 void crash_dump(int pid, int sig, int out_fd);
51 
52 #endif
53