English Amiga Board


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

 
 
Thread Tools
Old 09 October 2018, 05:31   #1
majikeyric
Registered User

majikeyric's Avatar
 
Join Date: Oct 2015
Location: France
Posts: 82
VBCC & guru meditation

Hi!

I have some problems when writing C code with VBCC 0.9fp1 (Windows), the generated executables produce gurus meditation and I can't figure out why ?

I generate kick1.3 execs.

This code works :

Code:
switch (i)
{
	case FIGHTER1:
		image = param + actor[i].direction;
		break;
		
	case FIGHTER2:
		image = param + actor[i].direction + 53;
		break;
		
	case REFEREE:
		image = param;
		break;
}

actor[i].image=image;
This one, produces a guru #0000000B.00c05128

Code:
switch (i)
{
	case FIGHTER1:
		image = param + actor[i].direction;
		break;
		
	case FIGHTER2:
		image = param + actor[i].direction + 53;
		break;
		
	case REFEREE:
		image = param;
		break;
}

if (actor[i].image_timer>5)
{
	actor[i].image = image;
}
though at $C05128 I have this, don't know what could be the cause of these gurus.....

majikeyric is offline  
Old 09 October 2018, 09:51   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,265
What type is actor.image_timer? A line F exception could mean that there's some FPU code in there. The easiest way to find out is to look at the generated assembly.
Leffmann is offline  
Old 09 October 2018, 09:58   #3
majikeyric
Registered User

majikeyric's Avatar
 
Join Date: Oct 2015
Location: France
Posts: 82
it is an unsigned byte,
how do you know it is a line F exception ? I don't use any float in my program.

looking to generate assembly listing ...
majikeyric is offline  
Old 09 October 2018, 12:15   #4
Hedeon
PPC Hacker

 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,537
It's disassembled garbage. It looks like code but it isn't. You have to know what is in front of this address and if/how it jumped to here.

Edit: you probably disassembled the task structure as that is what you are given by a guru in this case.

You should disassemble the generated code.
Hedeon is offline  
Old 09 October 2018, 12:22   #5
dodke
Registered User

 
Join Date: Feb 2018
Location: London / UK
Posts: 107
If the change looks fine then the error must be elsewhere. I've had problems with some completely random changes suddenly breaking things and it's caused for another issue like not restoring registers properly after some assembly routine.

You could try what happens if you disable all optimisations.
dodke is offline  
Old 09 October 2018, 13:30   #6
majikeyric
Registered User

majikeyric's Avatar
 
Join Date: Oct 2015
Location: France
Posts: 82
not at home yet but as I mix C & ASM, it is probably because I don't restore a register properly. i had some other random crashes the days before that were fixed without any valid reason... :/
majikeyric is offline  
Old 09 October 2018, 13:47   #7
Hedeon
PPC Hacker

 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,537
But you only showed the C part of your code then?
Hedeon is offline  
Old 09 October 2018, 16:47   #8
majikeyric
Registered User

majikeyric's Avatar
 
Join Date: Oct 2015
Location: France
Posts: 82
The C part which I thought was faulty. my project is 7000 lines (C+ASM) actually,
it is : http://eab.abime.net/showthread.php?t=94146
majikeyric is offline  
Old 09 October 2018, 17:16   #9
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,985
Most important when hunting such a crash:
1. Is it always the same crash (Guru #B)?
2. Is it reproducible and does always happen at the same point?

When you can answer both with "yes", then it should be very easy to locate the exact crash-location in your source.

There are several options:

In case your program doesn't kill the OS:

- Make sure to compile your C and assembler sources with symbol information. Then use a debugger to find the crash location. vbcc and vasm also support SAS/C LINE-Debug hunks, which can show the original source lines while debugging (e.g. with BDebug).

- Otherwise run something like Enforcer and SegTracker to show the exact section-offset of the crash. Then use a tool like "FindHit" to print the source line for this offset (in case you compiled with LINE-Debug hunks).

In case your program kills the OS:

- Debug it with UAE. Set a breakpoint to a location, which you think is still reached before the crash happens. For the UAE-debugger I am using "dc.w $cf4f" in the source, which is an "EXG A7,A7" and has no effect. You can tell the debugger to stop at this instruction: "fi cf4f". Then happily trace through your hardware-banging code.

- What I additionally did in my games: implement a small internal debugger. Set all exception vectors to your debugger and print all details about the crash, like the exception vector, the registers, the stack and the offset to your program's start address. So you can find the location in source. Source code for my internal debugger can be found in the Solid Gold source (debug.asm).
phx is offline  
Old 09 October 2018, 19:10   #10
majikeyric
Registered User

majikeyric's Avatar
 
Join Date: Oct 2015
Location: France
Posts: 82
that's very useful information phx thanks!

in the meantime I had added lines in my C source and the executable worked again ?!!

I scanned the ASM routines called by the C and finally .....

found one routine which destroyed the D6 register !!!!!!!!!!!!!! Hmmmm this was probably the cause of those random crashes!

Sorry to have incriminated VBCC but the problem was well between the keyboard and the chair

Last edited by majikeyric; 10 October 2018 at 08:42.
majikeyric is offline  
Old 09 October 2018, 23:09   #11
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,985
Quote:
Originally Posted by majikeyric View Post
Sorry to have incriminate VBCC but the problem was well between the keyboard and the chair
Glad you found it. Good luck with your games!
phx is offline  
Old 10 October 2018, 08:37   #12
majikeyric
Registered User

majikeyric's Avatar
 
Join Date: Oct 2015
Location: France
Posts: 82
Quote:
Originally Posted by phx View Post
Glad you found it. Good luck with your games!
Thanks!!!!!!
majikeyric 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
DiskImage Guru Meditation eva support.Apps 6 28 October 2014 02:09
Zool 2: Guru meditation TenLeftFingers support.FS-UAE 11 11 October 2013 23:17
Need help with Guru Meditation Ioncannon support.Hardware 15 09 October 2010 02:40
Guru Meditation: no orders possible A500-Danny News 0 05 August 2007 16:38
A3000 and Guru meditation gizmomelb support.Hardware 2 25 August 2006 23:41

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 21:28.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.10465 seconds with 13 queries