English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 26 August 2017, 13:05   #1
MartinW
Registered User

 
Join Date: Mar 2017
Location: United Kingdom
Posts: 211
Debugging?

General question...

If I'm writing in C and cross compiling (using gccv6), whats the generally accepted way of debugging program? Am I to assume that I copy it to real hardware and use a native debugger? In which case, any in particular?

At the moment on my native hardware (a GB-A1000 with 060) I am using StormC v3. I read a lot of bad things about it, but for someone just starting out, no matter how clunky it may be, the "IDE" is a great and fast way to get going. I've copied the install files for vbcc over to the machine but wasn't really intending to install it until something dictated the need.

I do also have FS-UAE running on the linux side of things that I use 75% of the time before trying on the real hardware.

Last night I had code that was crashing the minute I ran it on FS-UAE (software failure) so I built it on the Amiga with StormC but it didn't crash. It also didn't do anything, but it didn't crash. I tried to debug it, but of course, no crash meant that was kind of impossible.

The ideal would be remote debugging from within my linux based IDE (Jetbrains CLion). I'm sure I've seen remote debugging mentioned here in a search.
MartinW is offline  
Old 26 August 2017, 14:46   #2
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 431
I know this is not what you'd like to hear, but....lot's of printfs.
alkis is offline  
Old 26 August 2017, 18:20   #3
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,165
The debugger in UAE is quite low-level. But when your knowledge of 68k-assembler is good, then this is an option. It doesn't offer much comfort, though. Its main advantage is to be able to debug low-level stuff, which is otherwise impossible to debug (because you have taken over the system, for example). Otherwise, better use a debugger on real hardware.

Most Amiga compilers can include symbols in the final executable (HUNK_SYMBOL). And also some compilers (including vbcc) support the LINE DEBUG hunks, introduced by SAS/C, which offer you some minimal source level debugging. A debugger would be able to show you the current source for the code you are debugging. Any additional debugging information is usually compiler/debugger-specific.

Be prepared that you have to debug your code on the 68k level, even with native debuggers. When you have some symbols to set a breakpoint on a function, you are already lucky.

I am using BDebug from the Barfly assembler package, which is a nice, system-compliant, AmigaOS debugger. It supports symbols and source level debugging via HUNK_DEBUG/LINE.

But Alkis is right. Most of the time printf is the easiest way to go.
phx is offline  
Old 27 August 2017, 01:58   #4
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by MartinW View Post
If I'm writing in C and cross compiling (using gccv6), whats the generally accepted way of debugging program? Am I to assume that I copy it to real hardware and use a native debugger? In which case, any in particular?
Some programmers are using GCC 6 with vlink (vbcc linker) which should give Amiga HUNK format and allow BDebug (Barfly) and CPR (SAS/C) debugging. Maybe others have GDB working?

Quote:
Originally Posted by MartinW View Post
At the moment on my native hardware (a GB-A1000 with 060) I am using StormC v3. I read a lot of bad things about it, but for someone just starting out, no matter how clunky it may be, the "IDE" is a great and fast way to get going. I've copied the install files for vbcc over to the machine but wasn't really intending to install it until something dictated the need.
StormC v4 uses an old but good version of GCC.

Quote:
Originally Posted by MartinW View Post
The ideal would be remote debugging from within my linux based IDE (Jetbrains CLion). I'm sure I've seen remote debugging mentioned here in a search.
GDB and CPR support remote debugging.

Quote:
Originally Posted by phx View Post
I am using BDebug from the Barfly assembler package, which is a nice, system-compliant, AmigaOS debugger. It supports symbols and source level debugging via HUNK_DEBUG/LINE.
I prefer BDebug also for vbcc and SAS/C generated executables.

http://aminet.net/dev/asm/BarflyDisk2_00.lha
matthey is offline  
Old 27 August 2017, 12:36   #5
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,773
Also use enforcer-like program to instantly detect most invalid/null pointers. And in emulation you can also enable invalid access logging in addition to other debugging tools.
Toni Wilen is offline  
Old 27 August 2017, 13:00   #6
MartinW
Registered User

 
Join Date: Mar 2017
Location: United Kingdom
Posts: 211
Thanks everyone for the comments. For a noob to the Amiga programming world there's a lot to take in and read up on but I have a good basis now for doing just that. All I need is time now

I'm a programmer of 25 years for a living incidentally so I'm no stranger to printf debugging - indeed even in the world of modern IDEs that we live in it's not uncommon that I have to resort to that. It simply didn't occur to me that using printf's would automatically pop open a window with STDOUT in it.
MartinW is offline  
Old 27 August 2017, 14:11   #7
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 431
This is related: http://eab.abime.net/showthread.php?t=80894
alkis is offline  
Old 27 August 2017, 22:29   #8
MartinW
Registered User

 
Join Date: Mar 2017
Location: United Kingdom
Posts: 211
Nice - that's an interesting way of tackling things. I'm not so interested in being able to see the Amiga programs output in the Linux term because, let's face it, if I'm running the program on the Amiga (real or emulated) then I can see it in the window on the Amiga just as easily (split screen or multi screen).

What had already occurred to me however was to write a small resident program on the Amiga side which listened to the serial port and waited to be told what to do. Commands could be things like "run this program". That way my Linux build script can write it's output to a folder that is mapped on the Amiga to "PCDATA:" and then a command can be sent over serial to tell the Amiga to run it. Another command could tell it to kill it.

Only works if the program you want to remotely run doesn't take over the OS of course, and a lot of this is pointless if the program you're writing for the Amiga requires user interaction, because then you'll have to switch to the Amiga and input stuff anyway.

All useful info however!
MartinW is offline  
Old 28 August 2017, 15:32   #9
nogginthenog
Amigan

 
Join Date: Feb 2012
Location: London
Posts: 624
Quote:
Originally Posted by MartinW View Post
What had already occurred to me however was to write a small resident program on the Amiga side which listened to the serial port and waited to be told what to do. Commands could be things like "run this program". That way my Linux build script can write it's output to a folder that is mapped on the Amiga to "PCDATA:" and then a command can be sent over serial to tell the Amiga to run it. Another command could tell it to kill it.
You can run an Amiga shell over a serial connection and send shell commands. Not sure how you would kill a process but I'm sure there is a tool out there (Scout?).
Code:
newcli aux:
Or you can do it over a TCP/IP if your Amiga is networked.
nogginthenog is offline  
Old 28 August 2017, 15:33   #10
nogginthenog
Amigan

 
Join Date: Feb 2012
Location: London
Posts: 624
BTW, what is the status of GDB on the Amiga? I saw a GDB stub for AROS but I never tried it.
nogginthenog is offline  
Old 03 January 2018, 20:59   #11
cla
dev

cla's Avatar
 
Join Date: Aug 2014
Location: Copenhagen
Age: 43
Posts: 63
Send a message via ICQ to cla
Quote:
Originally Posted by nogginthenog View Post
BTW, what is the status of GDB on the Amiga? I saw a GDB stub for AROS but I never tried it.
The only version I have been able to dig up:
http://aminet.net/package/dev/gg/gdb-bin

Maybe the last.
cla is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Debugging + Linker? wk_end Coders. Asm / Hardware 3 21 April 2016 13:40
Debugging vbcc code tolkien Coders. C/C++ 5 14 February 2015 06:45
Debugging on the real device neoman Coders. Asm / Hardware 2 08 May 2014 22:47
Remote C/C++ debugging? alkis Coders. C/C++ 1 03 January 2014 12:17
Enforcer debugging tool M&F support.WinUAE 0 21 May 2002 22:53

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.07613 seconds with 15 queries