Getting assembled code

SGDK only sub forum

Moderator: Stef

Post Reply
tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Getting assembled code

Post by tryphon » Sat Jul 18, 2015 6:41 pm

Hello,

for debugging purposes, I'd like to be able to locate the addresses of my compiled functions in the ROM (so I could set breakpoints in Gens, for example).

Is there a way to change the "make.exe -f makefile.gen" command to do that ?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sat Jul 18, 2015 11:09 pm

you can modify the makefile.gen to produce symbol list for instance.
In the next SGDK version i will add a "debug" target to produce debug symbols :)

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Sat Jul 18, 2015 11:25 pm

you can use NM for that.
It's what I'm using to generate watchers for KMod,like in this makefile
https://bitbucket.org/SpritesMind/genre ... ile?at=dev

command :

Code: Select all

$(NM) -n -S -t x $(ROM).out >$(ROM).nm
I think you'll need to generate the binary with -g flag, to keep symbols[/code]

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Sun Jul 19, 2015 8:17 am

Thanks for anwers !
you can modify the makefile.gen to produce symbol list for instance.
Sorry, I'm new to makefiles and GCC command line options (and the least that can be said is that the man page is dense :) ).

I suppose I must add a flag in :

Code: Select all

release: FLAGS= $(DEFAULT_FLAGS) -O1 -fomit-frame-pointer
but which one ? (-g ?)
I think you'll need to generate the binary with -g flag, to keep symbols
Seems interesting. What's the exact name of it (because NM search on Google gives gazillions of results, none of them related to coding :) ) ?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Jul 19, 2015 10:04 am

In the makefile.gen fle you can replace this line :

Code: Select all

out/rom.bin: out/rom.out
by

Code: Select all

out/rom.bin: out/rom.out out/symbol.txt
and you will always have a symbol.txt file produced along the rom.bin file so you know the address of your variables and functions.

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Sun Jul 19, 2015 12:41 pm

In fact you already did it, I just didn't notice :)

Sorry for bothering :)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Jul 19, 2015 2:57 pm

Almost, you just need to modify a bit the makefile.gen file. In next SGDK version using the "debug" target will automatically produce the symbol file.

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Sun Jul 19, 2015 8:44 pm

Nope :

Code: Select all

make.exe -f makefile.gen debug
generated a symbol.txt.

There's these lines in makefile.gen :

Code: Select all

debug: FLAGS= $(DEFAULT_FLAGS) -O1 -ggdb -DDEBUG=1
debug: out/rom.bin out/rom.out out/symbol.txt
I suppose they are the one responsibles for that, and I assume they are yours :)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Jul 19, 2015 8:51 pm

Ohhh indeed i though it was not yet available ^^

Post Reply