EmbeddedRelated.com
Forums

debugging arm executuble with gdb

Started by Unknown April 18, 2013
Hi,

I have compiled linux kernel with arm-eabi toolchain on Ubuntu. The 
kernel is working. Now I'd like to debug it with gdb.
I tried this command: arm-eabi-gdb vmlinux

My questions:
Which gdb should I use?
There is a gdb in the arm-eabi (downloaded with android) toolchain. This 
will good?
I have tried that but I have got Don't know how to run. Try "help 
target" error message.
I tried to set breakpoint to __init_begin, this works but when I tried 
to start the debug with *start, run, cont* I have got this error 
message.
attila@attila-desktop:~/Upload$ arm-eabi-gdb vmlinux
GNU gdb (GDB) 7.1-android-gg2
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-elf-linux".
Reading symbols from /home/attila/Upload/vmlinux...(no debugging symbols found)...done.
(gdb) break __init_begin
Breakpoint 1 at 0xc0008000
(gdb) load vmlinux
You can't do that when your target is `exec'
(gdb) start
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
Starting program: /home/attila/Upload/vmlinux 
Don't know how to run.  Try "help target".
(gdb) cont
The program is not being run.
(gdb) run
Starting program: /home/attila/Upload/vmlinux 
Don't know how to run.  Try "help target".
On 18.4.13 8:25 , csnews77@gmail.com wrote:
> Hi, > > I have compiled linux kernel with arm-eabi toolchain on Ubuntu. The > kernel is working. Now I'd like to debug it with gdb. > I tried this command: arm-eabi-gdb vmlinux > > My questions: > Which gdb should I use? > There is a gdb in the arm-eabi (downloaded with android) toolchain. This > will good? > I have tried that but I have got Don't know how to run. Try "help > target" error message. > I tried to set breakpoint to __init_begin, this works but when I tried > to start the debug with *start, run, cont* I have got this error > message. > attila@attila-desktop:~/Upload$ arm-eabi-gdb vmlinux > GNU gdb (GDB) 7.1-android-gg2 > This GDB was configured as "--host=x86_64-linux-gnu --target=arm-elf-linux". > Reading symbols from /home/attila/Upload/vmlinux...(no debugging symbols found)...done. > (gdb) break __init_begin > Breakpoint 1 at 0xc0008000 > (gdb) load vmlinux > You can't do that when your target is `exec' > (gdb) start > Function "main" not defined. > Make breakpoint pending on future shared library load? (y or [n]) n > Starting program: /home/attila/Upload/vmlinux > Don't know how to run. Try "help target". > (gdb) cont > The program is not being run. > (gdb) run > Starting program: /home/attila/Upload/vmlinux > Don't know how to run. Try "help target".
Kernel in not a normal executable. It needs special techniques to debug. One of them is the kernel debugger, kgdb. Please google for 'linux kernel debugging'. There are plenty of hits. -- Tauno Voipio
>On 18.4.13 8:25 , csnews77@gmail.com wrote: >> Hi, >> >> I have compiled linux kernel with arm-eabi toolchain on Ubuntu. The >> kernel is working. Now I'd like to debug it with gdb. >> I tried this command: arm-eabi-gdb vmlinux >> >> My questions: >> Which gdb should I use? >> There is a gdb in the arm-eabi (downloaded with android) toolchain.
This
>> will good? >> I have tried that but I have got Don't know how to run. Try "help >> target" error message. >> I tried to set breakpoint to __init_begin, this works but when I tried >> to start the debug with *start, run, cont* I have got this error >> message. >> attila@attila-desktop:~/Upload$ arm-eabi-gdb vmlinux >> GNU gdb (GDB) 7.1-android-gg2 >> This GDB was configured as "--host=x86_64-linux-gnu
--target=arm-elf-linux".
>> Reading symbols from /home/attila/Upload/vmlinux...(no debugging symbols
found)...done.
>> (gdb) break __init_begin >> Breakpoint 1 at 0xc0008000 >> (gdb) load vmlinux >> You can't do that when your target is `exec' >> (gdb) start >> Function "main" not defined. >> Make breakpoint pending on future shared library load? (y or [n]) n >> Starting program: /home/attila/Upload/vmlinux >> Don't know how to run. Try "help target". >> (gdb) cont >> The program is not being run. >> (gdb) run >> Starting program: /home/attila/Upload/vmlinux >> Don't know how to run. Try "help target". >
The kernel is not runnable as a classical userland executable is (that is why you cannot run it from GDB), even if the binary formats are the same (that is why you can open it in GDB, and even put a breakpoint on a symbol). You must debug a running kernel, be it on your target hardware or an emulator, and use the proposed documentation reference. --------------------------------------- Posted through http://www.EmbeddedRelated.com