Author Topic: How to get a elf-file?? -> Now: Debuging for dummies  (Read 26784 times)

Offline starkeeper

  • Multiple posting newcomer
  • *
  • Posts: 15
How to get a elf-file?? -> Now: Debuging for dummies
« on: June 07, 2007, 03:07:57 pm »
Hi,
I want to use Codeblocks for my ARM projects. I have chosen the GNU ARM GCC compiler, but the output file is called ARMTest.exe and not usable ARMTest.elf!

The output file ist really big, around 150kb, the same source compiled in eclipse has a 30Kb ".elf" file.

Finnaly I got theese questions on how to start with Codeblocks and ARM:

1. Which type of project should I use? Is a "Console application" correct?
2. How can I persuade the compiler to make a usable elf-file?
3. Which Debugger initialization commands should I use?
« Last Edit: June 08, 2007, 07:02:03 pm by starkeeper »

mariocup

  • Guest
Re: How to get a elf-file??
« Reply #1 on: June 07, 2007, 03:31:21 pm »
Hi starkeeper,

just have a look at the project properties.

Select Build targets and set:
Output filename e.g.: obj\name.elf

Activate Auto-generate filename prefix
Disable Auto-generate filename extension.

Thats all.

Bye,

Mario

Offline starkeeper

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: How to get a elf-file??
« Reply #2 on: June 07, 2007, 03:47:47 pm »
Well now I got a elf-file but it is still 150kB big.

You can see my project option on the screenshot. I wonder that there is still Windows,Unix,Mac selected as target! Shouldn't this be something like ARM?


[attachment deleted by admin]

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to get a elf-file??
« Reply #3 on: June 07, 2007, 04:05:50 pm »
Quote
Well now I got a elf-file but it is still 150kB big.

Click the "Build options" button and in the "compiler flags" list make sure you put a checkmark on the "Strip all symbols from binary (minimizes size) [-s]" flag. Then rebuild your project.
Be patient!
This bug will be fixed soon...

mariocup

  • Guest
Re: How to get a elf-file??
« Reply #4 on: June 07, 2007, 04:07:03 pm »
Hi starkeeper,

you have select Debug as Build Target. This target normally contains debug information. So just check the compiler flag in your build options. Select the category Debugging and deselect "Produce debugging symbols".

Bye,

Mario

Offline starkeeper

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: How to get a elf-file??
« Reply #5 on: June 07, 2007, 04:13:57 pm »
Hi starkeeper,

you have select Debug as Build Target. This target normally contains debug information. So just check the compiler flag in your build options. Select the category Debugging and deselect "Produce debugging symbols".

Bye,

Mario

Is it possible to debug the code with arm-elf-gdb, without debugging symbols?

mariocup

  • Guest
Re: How to get a elf-file??
« Reply #6 on: June 07, 2007, 04:27:33 pm »
Hi startkeeper,

it is not possible to debug an target without debug information. This information is stored in the debug section of your elf-File. The normal way is two have two build targets:
Debug and Release.
The Release Targets is generated without debug info and Target Debug with the info.

I do not understand why user should work in a different manner.

Bye,

Mario

Offline starkeeper

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: How to get a elf-file??
« Reply #7 on: June 07, 2007, 04:58:18 pm »
Ok, thanks a lot!

Now to the debugging, which initial debug commands will I have to use?
I used this one here in eclipse:
Code
target remote localhost:3333
monitor reset
monitor sleep 500
monitor poll
monitor soft_reset_halt
monitor arm7_9 sw_bkpts enable
monitor mww 0xA0000050 0x01c2
monitor mdw 0xA0000050
break main
load
continue

But this does not work for codeblocks. Starting the debugger with the "Debug/Continue" button gives me this result:

Debugger name and version: GNU gdb 6.5.50.20060612-cvs
In ?? () ()
Continuing...

And thats all, the debugger stops not at the breakpoint and I'm also not able to step through the code.

mariocup

  • Guest
Re: How to get a elf-file??
« Reply #8 on: June 08, 2007, 12:36:18 am »
Hi starkeeper,

did you try to use this command in the command line version of gdb.

arm-elf-gdb <filename>.elf
tar remote localhost:3333
...#
lo
b main
r

Use the run commando instead of the continue command. Eclipse implicitly does some steps, I do not know exactly. Which debugger interface are you using with Eclipse? Embedded CDT from zylin?

We are working on a plugin for starting external debugger for embedded targets like arm with insight. As soon the plugin is stable it will be released to the codeblocks team. We will also provide a download for the ARM Toolchain with codeblocks.

See http://forums.codeblocks.org/index.php/topic,6040.0.html.

Hope to release the plugin next week.

Bye,

Mario

Offline starkeeper

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: How to get a elf-file??
« Reply #9 on: June 08, 2007, 09:41:56 am »
Good morning!

Well with eclipse I was using the same arm-elf-gdb executable.

I also experimented with the commando-interface, this is the output:
Code
GNU gdb 6.5.50.20060612-cvs
Copyright (C) 2006 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=i686-pc-mingw32 --target=arm-elf"...
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x000d2664 in ?? ()
(gdb) monitor reset
(gdb) monitor sleep 500
(gdb) monitor poll
target state: halted
target halted in ARM state due to debug request, current mode: Undefined
cpsr: 0xf00000db pc: 0x000d26d0
(gdb) monitor soft_reset_halt
requesting target halt and executing a soft reset
(gdb) monitor arm7_9 sw_bkpts enable
software breakpoints enabled
(gdb) monitor mww 0xA0000050 0x01c2
(gdb) monitor mdw 0xA0000050
0xa0000050: 000001c2
(gdb) break main
Breakpoint 1 at 0x20000158: file main.c, line 6.
(gdb) list
1
2
3       int main(void)
4       {
5
6           int a = 0, b =5;
7           a = a + b;
8
9           while(1)
10          {
(gdb) run
Starting program: C:\ARMProjects\ARMTestII/main.elf
Don't know how to run.  Try "help target".
(gdb)

So this is the output for the run command. Evertime I type "run" the OpenOCD closes with this error:
Code
Error:   gdb_server.c:101 gdb_get_char(): read: 10054


mariocup

  • Guest
Re: How to get a elf-file??
« Reply #10 on: June 08, 2007, 01:27:43 pm »
Hi,

I do not see the problem.
But I am using ARM compiler 3.4.5 with gdb 6.1 and our jtag-server for arm and Xscale under codeblocks and everything works fine. If you like I can send you the link for downloading the ARM Toolchain that contains all tools tested with the current codeblocks version. I think it will be available next week.

Bye,

Mario

P.S.: What plugin are you using with eclispe for embedded debugging?

Offline starkeeper

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: How to get a elf-file?? -> Now: Debuging for dummies
« Reply #11 on: June 08, 2007, 07:57:09 pm »
Ok, now I got a working script for the arm-elf-gdb commando interface:

starting gdb like this: arm-elf-gdb main.elf
Code
set complaints 1
set output-radix 16
set input-radix 16
target remote localhost:3333
monitor reset
monitor sleep 500
monitor halt
set remote memory-write-packet-size 1024
set remote memory-write-packet-size fixed
set remote memory-read-packet-size 1024
set remote memory-read-packet-size fixed
set remote hardware-watchpoint-limit 2
set remote hardware-breakpoint-limit 2
load
break main
monitor arm7_9 sw_bkpts enable
monitor mww 0xA0000050 0x01c2
monitor mdw 0xA0000050
Continue

This results in total debuging paradise!

Pasting this script in codeblocks gives me this output:
Code
Command-line: C:\Programme\yagarto\bin\arm-elf-gdb.exe -nx -fullname  -quiet -args main.elf
Working dir : C:\ARMProjects\ARMTestII\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.5.50.20060612-cvs
Copyright (C) 2006 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=i686-pc-mingw32 --target=arm-elf".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
No symbol "debugevents" in current context.
>>>>>>cb_gdb:
> set new-console on
No symbol "new" in current context.
>>>>>>cb_gdb:
> set disassembly-flavor att
No symbol "disassembly" in current context.
>>>>>>cb_gdb:
> set complaints 1
set output-radix 16
set input-radix 16
file main.elf

target remote localhost:3333
monitor reset
monitor sleep 500
monitor halt
set remote memory-write-packet-size 1024
set remote memory-write-packet-size fixed
set remote memory-read-packet-size 1024
set remote memory-read-packet-size fixed
set remote hardware-watchpoint-limit 2
set remote hardware-breakpoint-limit 2
load
break main
monitor arm7_9 sw_bkpts enable
monitor mww 0xA0000050 0x01c2
monitor mdw 0xA0000050
Continue
>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:
> directory C:/ARMProjects/ARMTestII/
0x200002e8 in __bss_start ()
>>>>>>cb_gdb:
>>>>>>cb_gdb:
requesting target halt...
>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:Loading section .text, size 0x194 lma 0x20000000
Remote communication error: Bad file descriptor.
>>>>>>cb_gdb:Breakpoint 1 at 0x20000158: file main.c, line 6.
putpkt: write failed: No error.
>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:
putpkt: write failed: No error.
putpkt: write failed: No error.
putpkt: write failed: No error.

And this is not working because the load command failes with:
Loading section .text, size 0x194 lma 0x20000000
Remote communication error: Bad file descriptor.