![]() |
![]() |
#1 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
Debug: evaluate a variable built with vbcc
I'm working on the amiga assembly extension for visual studio code.
I've added a feature to step and stop on breakpoints in C code. So it's possible to debug C and ASM in the same editor. I would like to add the possibility to evaluate a C variable. Someone has a clue to achieve that ? My simple program: Code:
#include <stdio.h> extern int mul_by_ten(short input); int main() { short i; char* s="My Text"; for (i = 0; i < 10; i++) { printf("Line %d\n", i); printf("10 * %d = %d\n", i, mul_by_ten(i)); printf("--------\n"); } return 0; } } Code:
c14234: 48 e7 20 20 movem.l d2/a2, -(a7) c14238: 45 fa 00 7a lea.l $94(pc), a2 c1423c: 74 00 moveq #$0, d2 c1423e: 60 3e bra.b $5e c14240: 30 02 move.w d2, d0 c14242: 48 c0 ext.l d0 c14244: 2f 00 move.l d0, -(a7) c14246: 48 7a 00 44 pea.l $6c(pc) c1424a: 4e b9 00 c1 4b 1c jsr $c14b1c.l c14250: 30 02 move.w d2, d0 c14252: 48 c0 ext.l d0 c14254: 2f 00 move.l d0, -(a7) c14256: 4e b9 00 c0 2f f0 jsr $c02ff0.l c1425c: 2f 00 move.l d0, -(a7) c1425e: 30 02 move.w d2, d0 c14260: 48 c0 ext.l d0 c14262: 2f 00 move.l d0, -(a7) c14264: 48 7a 00 32 pea.l $78(pc) c14268: 4e b9 00 c1 4b 1c jsr $c14b1c.l c1426e: 48 7a 00 38 pea.l $88(pc) c14272: 4e b9 00 c1 42 bc jsr $c142bc.l c14278: 4f ef 00 1c lea.l $1c(a7), a7 c1427c: 52 42 addq.w #$1, d2 c1427e: b4 7c 00 0a cmp.w #$a, d2 c14282: 6d bc blt.b $20 c14284: 70 00 moveq #$0, d0 c14286: 4c df 04 04 movem.l (a7)+, d2/a2 c1428a: 4e 75 rts How do I know the address of 's'? |
![]() |
![]() |
#2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
You don't know that without proper source level debugging information in the executable. vbcc can generate DWARF debug sections, which are not easy to parse but include everything you need to know.
DWARF doesn't work very well in hunk format executables though, and there are no debuggers which supports hunk format with DWARF, so we are enabling the -hunkdebug option by default for AmigaOS/68k. -hunkdebug generates SAS/C-style debug information, but only the LINE debug hunks, which I found documented in the Amiga Guru Book. Nothing else. Which means, with hunk format you are currently only getting the line numbers of the original source and nothing about variables. |
![]() |
![]() |
#3 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
I’m creating the debugger behavior and the parser, so I can try it...
Do you think the DWARF / hunk format is enough stable to be used? |
![]() |
![]() |
#4 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
you could also support gcc and its stab (old gcc) debug format^^
|
![]() |
![]() |
#5 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
Gcc can be tricky to install on a windows with m68k support, I like the simplicity of vbcc.
But yes, it’s an alternative. |
![]() |
![]() |
#6 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
try http://franke.ms/download/setup-amiga-gcc.exe |
|
![]() |
![]() |
#7 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
Both gcc and vbcc do DWARF2 and stabs.
Which one is the easiest to parse? Are stabs and amiga hunk format compatible? |
![]() |
![]() |
#8 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
@bebbo thanks, I’ll try this install.
|
![]() |
![]() |
#9 |
Registered User
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
|
@bebbo - does your gcc6 have prebuilt setups for MacOS as well yet?
I use vbcc over gcc because it was far simpler to install in Windows, MacOS and AOS 3.1 / 3.9 (in case I want to do some quick hacking / testing on real hardware). [EDIT] PS: Very nice to see attention to Amiga C code in the extension. I've been using it for C since I first saw it. |
![]() |
![]() |
#10 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
I’v seen that stabs is obsolete on vbcc.
I’ll stick with DWARF2 but it should work with gcc. |
![]() |
![]() |
#11 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
Quote:
I guess one problem will be that sections in a hunk-format executable are unnamed, so you cannot easily find them. And another problem is that they are loaded into memory. Oh, and DWARF uses pointers and relocations at odd addresses, which LoadSeg() doesn't support... The best solution to bring something like DWARF to the Amiga would be to have the linker parse the debug sections and convert them into a more compatible format in a HUNK_DEBUG hunk. Nothing you do on an evening, though... ![]() |
|
![]() |
![]() |
#12 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
off topic: look here: https://github.com/bebbo/amiga-gcc/releases regarding hunk + dwarf2: is there a magic cookie at start of the debug hunk which can be used to recognize a dwarf2 debug hunk? |
|
![]() |
![]() |
#13 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
That looks frightening!
Do vlink preserve the DWARF info in the exe? |
![]() |
![]() |
#14 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
Quote:
Code:
0: HUNK_DEBUG 4: hunk size in longwords 8: section offset 12: four-digit ID (e.g. "LINE", for the SAS/C line-debug hunk) Indeed, be very frightened! ![]() Some months ago I implemented DWARF2 and 3 support in vasm, to make it automatically generate DWARF sections for source level debugging. It was... challenging. Quote:
|
||
![]() |
![]() |
#15 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
* what is the 4 byte identifier used by vbcc/vlink/dwarf2? * my gcc fork is using 2 debug sections per object file which are all together merged into one debug section for the binary. If I'd implement dwarf2 debug info for gcc/amiga hunk, I'd do it the same way -> one debug hunk per binary. |
|
![]() |
![]() |
#16 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
@bebbo: which debug info format did you use in your gcc fork?
|
![]() |
![]() |
#17 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
|
![]() |
![]() |
#18 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
|
![]() |
![]() |
#19 | |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
Quote:
![]() The preview of 0.17 version already has a step debugging in ASM showing the C source, but you have to step several times for one line of C code and you do not know the variables values. I don't know if it is already useful as it is without variable value evaluation which is expected for a 'normal' debugger. As I understand for amigaos there are some build environments for C as:
Now, for my needs, I've the choice of:
I'm reading some docs about these formats to see if it's not a too big investment. Other alternatives can be the use of 'debug.lib' and listen to serial output, so the developer can send messages that are displayed in the debugger. Do you have in mind some other alternative? |
|
![]() |
![]() |
#20 |
Registered User
Join Date: May 2018
Location: France
Posts: 246
|
@bebbo: maybe connecting to your gdbserver is a better way.
I'll try it with vscode. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Variable injection? | solarmon | support.WinUAE | 12 | 20 January 2019 12:05 |
VBCC problem with standard variable types | Crank | Coders. C/C++ | 11 | 01 April 2018 19:31 |
Indy Last Crusade - Help me to DEBUG a Variable and change his value!! | DjDiabolik | support.Games | 0 | 26 December 2016 03:27 |
vbcc bind a variable to a register | iliak | Coders. Asm / Hardware | 6 | 31 July 2016 12:29 |
Evaluate a location on floppy disk by offset? (t/h/s) | andreas | Coders. General | 11 | 23 June 2005 12:03 |
|
|