Welcome, Guest. Please login or register.

Author Topic: Best C compiler for Amiga?  (Read 20149 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Ezrec

  • Jr. Member
  • **
  • Join Date: Aug 2010
  • Posts: 58
    • Show all replies
    • http://www.evillabs.net
Re: Best C compiler for Amiga?
« on: November 02, 2013, 12:58:41 PM »
.. and just to complete this thread, I do all my Amiga 3.x development using the AROS cross-compilation SDK under Linux, using a GDB stub + serial port combination to debug my apps/drivers on both real hardware and E-UAE.

(I'm heavily mentally invested in the bash+vi+make+gdb development model..)
 

Offline Ezrec

  • Jr. Member
  • **
  • Join Date: Aug 2010
  • Posts: 58
    • Show all replies
    • http://www.evillabs.net
Re: Best C compiler for Amiga?
« Reply #1 on: November 02, 2013, 04:05:05 PM »
Quote from: EDanaII;751667
Ezerec?

Can you write up how you (or point somewhere that describes how to) use GDB to debug? I'd love to give it a try. I use Eclipse's CDT which uses GCC, so, in theory I should be able to use GDB similarly...

Just a request. :)


Well, the two key parts are C:GDBStub (sources in AROS/arch/m68k-amiga/c/gdbstub.c), which causes a serial port based GDB stub to activate on a trap, and the m68k-aros-gdb from the AROS m68k SDK on Linux.

To debug, I compile a driver/app first as an ELF binary, then use the AROS elf2hunk utility to convert it to AmigaOS 3.1 compatible hunk style.

Also, I modify my driver/app to have a 'asm volatile ("trap #1")' as the first thing to do in my main() (or equivalent).

I copy the HUNK version to AmigaOS 3.1, then RUN C:GDBStub before running my driver/app.

On the Linux side, I use:

$ m68k-aros-nm myapp.elf | grep main
-- this gets me the address of the main routine --
$ m68k-aros-objdump -h myapp.elf
-- this gets me the segment names and their HUNK load order.
$ m68k-aros-gdb
> target /dev/ttyS0 115200
> x /i $pc
-- This gets me the address of the 'trap #1', and allows me to figure out the offset 'text_offset' that the AmigaOS decided to load main() at)
> add-symbol-file myapp.elf 'text_offset'
-- Now I have the text of my program. If I don't need any .data or .bss debugging, I'm done here.
-- For app debugging, I do something like:
> set $segarray=((struct Process *)((*((struct ExecBase **)4))->ThisTask))->pr_SegList)<<2;
-- That's the address of my app's seglist array
> set $seglist=(($segarray+5*4)<<2)
-- And that's the seglist.
-- You can walk the seglist as per usual to discover the additional segment offsets, using the HUNK load order from 'objdump'
> add-symbol-file myapp.elf 'text_offset' -s .data 'data_offset' -s .rodata 'rodata_offset' ...


Of course, you could use SegTracker, or some other thing, to assist in this process.