Debugging in BlitzMax

BlitzMax Forums/BlitzMax Programming/Debugging in BlitzMax

Sean Doherty(Posted 2006) [#1]
Returning Ziggy's thread:

Type TBase
	Field FOne:Int =3
'---------------------------------------------
Function Create:TBase ()
	Local 	Temp:TBase 	= New TBase
		Temp.FOne		= 1
	Return Temp
End Function
EndType
'----------------------------------------------
Type TExtend	Extends TBase
Field FTwo:Int=4
'---------------------------------------------
Function Create:TExtend ()
		Local	Temp:TExtend	= New TExtend
				Temp.FTwo		= 2
		Return Temp
	End Function
End Type

Global mine:TBase	= TBase.Create()
Print mine.FOne
Global newmine:TExtend	= TExtend(mine)
Print mine.FOne
Print newmine.FOne+","+newmine.FTwo
mine.FOne:+999
newmine.FOne:+ 1
Print mine.FOne
Print newmine.FOne+","+newmine.FTwo


@Myself

Run this in release and it works. But realy its not working, run in Debug to find out. This sort od thing can happen all the time if you are not "Dios de Blitz". No change that, it happens all the time if you are me ;(


Grisu(Posted 2006) [#2]
There seem to be a lot of issues with bmx and outputting NULL objects.

Just be happy that's only in debug mode and not vica versa.


H&K(Posted 2006) [#3]
But debug mode is right, because Im trying to cast an object in a way that cannot be done. Its realese mode that is wrong. (well not wrong, but is now useing an object that is unallocated)


Sean Doherty(Posted 2006) [#4]
Debug mode is correct. You forward casted the base class to a type that had not been constructed. I'm really surprised that it doesn't crash in release mode. I'm guessing if you had a bigger application, the memory would get corrupted and you would see a crash at some point.

Generally, I have a pretty specific style. I use almost no functions and I try not to call member variables without using methods. Also, I make my base function abstract so they shouldn't compile.

For example,

local pTExtend:TExtend = Null

pTExtend = new TExtend
pTExtend.Initialize(iNumber)

Print pTExtend.GetNumber()


As an example...

That said, it looks like it might be worth running an application through debug mode from time to time just to check for things not picked up in release mode.

The problem is that my code is written to catch and throw errors. I seem to remember that max didn't like it when you through an error while in debug mode. I'll have to try it again to refresh my memory.

Thanks


H&K(Posted 2006) [#5]
Well anyway thats the reason I think That even tho it takes longer to build a debug version, Im a lot better off using it. Because I dont even know how to throw errors, and so thats not realy a problem for me :0


Sean Doherty(Posted 2006) [#6]
throw("This is an error")


I ran my game in debug mode. It didn't crash, but I dropped the framerate down to 2 FPS at times. Very slow. It runs at 75 fps in release mode for the most part.


H&K(Posted 2006) [#7]
Ahh, well thats the problem when you bother with game logic, or graphics or sounds and stuff ;)