How to use cross gdb to check kernel file using crosstarget machine

I have a core file from an embedded SH3 linux device and gdb cross-compiler environment (sh3-linux-gdb) in my Linux host.

But I have problems loading the kernel file using gdb:

 $ sh3-linux-gdb ./myprogram ./core GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. ... This GDB was configured as "--host=i386-pc-linux-gnu --target=sh3-linux"... GDB can't read core files on this machine. (gdb) 

Why can't he read the main file? Is there a way to read the main file from the target system in cross gdb?

The target machine (SH3-linux) has gdbserver, but not gdb itself. I can debug processes on the target machine using gdbserver and sh3-linux-gdb , so sh3-linux-gdb must be compiled correctly.

EDIT: Backup required:

 [build]$ sh3-linux-readelf -a core ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2 complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: CORE (Core file) Machine: Renesas / SuperH SH Version: 0x1 Entry point address: 0x0 Start of program headers: 52 (bytes into file) Start of section headers: 0 (bytes into file) Flags: 0x0 Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 51 Size of section headers: 0 (bytes) Number of section headers: 0 Section header string table index: 0 There are no sections in this file. There are no sections in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align NOTE 0x000694 0x00000000 0x00000000 0x00200 0x00000 0 LOAD 0x001000 0x00400000 0x00000000 0x00000 0x01000 RE 0x1000 ----- several boring lines removed ----- LOAD 0x05a000 0x29952000 0x00000000 0x01000 0x01000 RW 0x1000 LOAD 0x05b000 0x7be48000 0x00000000 0x15000 0x15000 RWE 0x1000 There is no dynamic section in this file. There are no relocations in this file. There are no unwind sections in this file. No version information found in this file. Notes at offset 0x00000694 with length 0x00000200: Owner Data size Description CORE 0x000000a8 NT_PRSTATUS (prstatus structure) CORE 0x0000007c NT_PRPSINFO (prpsinfo structure) CORE 0x000000a0 NT_AUXV (auxiliary vector) [build]$ 

EDIT2:. Same problem with the --core :

 $ sh3-linux-gdb ./myprogram --core=./core GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i386-pc-linux-gnu --target=sh3-linux"...RUN GDB INIT GDB can't read core files on this machine. (gdb) 
+6
source share
2 answers

Try according to http://forums.freescale.com/t5/68K-ColdFire-reg-Microprocessors/GDB-can-t-read-core-files/td-p/70181

  sh3-linux-gdb ./myprogram --core=./core 

It might be a bug in the old gdb http://sourceware.org/bugzilla/show_bug.cgi?id=9542 - so try the new gdb (7) as well.

It is also possible that the kernel was dropped in an unsupported format. What is the target OS version?

Can you post output or readelf -a core ?

+1
source

You can debug your application, not directly with gdb, but with the gdb server. The first thing you need to do is call gdbserver on the target system (you said in your question that this package was already installed):

 gdbserver AAA.BBB.CCC.DDD:port ./myprogram 

It is assumed that the target computer is available for the IP address: AAA.BBB.CCC.DDD:port . Once you do this, you can invoke gdb on your development machine by specifying the target remote server:

  % gdb ./myprogram % [...] (gdb) target remote AAA.BBB.CCC.DDD:port 

Note that the destination IP address of the remote server is the same for gdbserver.

-1
source

Source: https://habr.com/ru/post/893253/


All Articles