gdb won't read core file from foreign architecture
Asked Answered
H

2

11

I'm trying to read an ARM core file on my Linux desktop, but it seems not to be able to figure out my core file. Is there any way I can instruct gdb what type my core file is?

$ file ~/daemon
./daemon: ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped
$ file ~/core
./core: ELF 32-bit LSB core file ARM, version 1 (SYSV), SVR4-style, from './daemon -v -v -v -v -e 10 -t foo'
$ gdb-multiarch ~/daemon ~/core
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from ./daemon...done.
"./core" is not a core dump: File format is ambiguous
(gdb) core-file ~/core 
"./core" is not a core dump: File format is ambiguous

The generating platform is armv4, which gdb-multiarch claim to support, according to the "set architecture" list.

EDIT: To clarify, my desktop machine running gdb is "x86_64-linux-gnu", namely an 64-bit Intel Ubuntu box.

Haletta answered 27/9, 2012 at 12:34 Comment(1)
gdb states reading daemon was ok, but problem was with core file. try readelf on core file to see anything suspicious. file utility must be very superficial for such tasks.Tax
B
21

This may help:

$ gdb-multiarch
...
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) set gnutarget elf32-littlearm
(gdb) file daemon
...
(gdb) target core core
...
(gdb)
Bawcock answered 8/2, 2013 at 13:1 Comment(0)
I
-5

The following is relevant only if your desktop (where you are trying to run gdb-multiarch) is x86.

Gdb is a debugger. As such it will not be able to debug a foreign architecture executable on your x86 desktop machine because you cannot run arm code on x86 processor. You can however debug it remotely using gdb-server which will run on arm machine.

Is your desktop arm or x86?

Irv answered 27/9, 2012 at 14:42 Comment(4)
I may be confused, but I thought gdb would be able to "read" the core dump even though it is frmo a foreign core architecture? I'm not trying to execute it. I just want to look at the backtrace, at registers and such.Haletta
As far as I know gdb is a dynamic analysis tool and as such requires loading the binary to executable memory. I know this is not what you are asking for however maybe what you are looking for is something such as objdump or ida?Irv
user1629505 is correct. Can you post an answer so I can mark it?Haletta
Loading something to memory does not necessarily mean executing it on a real CPU core.Nix

© 2022 - 2024 — McMap. All rights reserved.