I have a file 'manager_server.ex'
$ file manager_server.ex
manager_server.ex: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=709713ebf61f867e84d1d2818baea02b562c7ee7, not stripped
I ran this file and then deleted it. Now I try generate a core file by gdb(generate-core-file),but I get different core file(64-bit and 32-bit). This is a correct core file:
$ sudo gdb manager_server.ex -p 28108
(gdb) generate-core-file
(gdb) quit
$ file core.28108
core.28108: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style, from '/home/ubuntu/sstx10006/manager_server'
those are not:
$ sudo gdb
(gdb) set archi i386
(gdb) attach 28108
(gdb) generate-core-file
(gdb) quit
$ file core.28108
core.28108: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from '/sstx10006/manager_server'
$ sudo gdb
(gdb) set archi i386:x86-64
(gdb) attach 28108
(gdb) generate-core-file
(gdb) quit
$ file core.28108
core.28108: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from '/home/ubuntu/sstx10006/manager_server'
$ sudo gdb
(gdb) attach 28108
(gdb) generate-core-file
(gdb) quit
$ file core.28108
core.28108: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from '/sstx10006/manager_server'
I want to know what make them different. I asked ChatGPT, but the explanation it provided was incorrect.
I want to know what make them different.
It looks that when the executable is not deleted, both gdb -p $pid
and (gdb) attach $pid
read the /proc/$pid/exe
symlink and use that executable. But when the file is deleted, GDB fails to load the manager_server.ex (deleted)
.
/proc/$pid/exe
directly instead of dereferencing it.(gdb) attach 2655529
Attaching to process 2655529
No executable file now.
warning: Could not load vsyscall page because no executable was specified
gdb /proc/2655529/exe
attach 2655529
(gdb) gcore