我写了下面的C程序
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
void main(){
char *variable = "CodeName0...";
while (1){
printf("%sn%dn","hello from gencore code source",getpid());
sleep(2);
}
exit(0);
}
在运行之后,我使用以下命令发送了一个SIGABRT信号kill -6 <process Id from code execution>
这将在同一目录
中生成一个名为core
的核心转储文件我想读取cpu寄存器的内容(IP…)但我没能做到
我运行的是parrot OS,这是uname -a
的输出
Linux Parrot 5.16.0-12parrot1-amd64 #1 SMP PREEMPT Debian 5.16.12-2parrot1 (2022-03-11) x86_64 GNU/Linux
我尝试使用gdb,但我得到这个错误
"0x7fffd7f6de10s": not in executable format: file format not recognized
我想知道为什么会出现这种情况(文件格式无法识别)
实在不知道该如何进一步解释:
$ gdb <binary> <core>
i all-registers
,其中<binary>
是二进制文件,理想情况下使用-g3编译,<core>
是转储的核心文件。您可能需要导航到不同的帧(bt
和f <number>
),其中<number> is the frame number).
全寄存器有点冗长,但这里是i register
输出:
rax 0xfffffffffffffdfc -516
rbx 0xffffffffffffff80 -128
rcx 0x7fa81f0c650a 140360052139274
rdx 0x7ffc19fe2020 140720744570912
rsi 0x0 0
rdi 0x0 0
rbp 0x0 0x0
rsp 0x7ffc19fe1fe0 0x7ffc19fe1fe0
r8 0x0 0
r9 0x27 39
r10 0x7ffc19fe2020 140720744570912
r11 0x246 582
r12 0x562d5cc38070 94752829833328
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0x7fa81f0c650a 0x7fa81f0c650a <__GI___clock_nanosleep+42>
eflags 0x246 [ PF ZF IF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0