[fpc-pascal]RE: The inexplicable overflow.
Pierre Muller
pierre at freepascal.org
Fri Sep 27 10:27:21 CEST 2002
At 10:03 27/09/2002 , vous avez écrit:
>Hi,
>If followed the advice presented and recompiled with range checking and
>overflow checking on. My program subsequently caused a near immediate 201
>crash.
>The compiler issues this warning:
>
>minerunner.pas(95,56) Warning: Mixing signed expressions and cardinals
>here may cause a range check error
>
>Line 95 looks like this:
> If (level.block[blockX,blockY].what = pit) And
>(SDL_Getticks > level.block[blockX,blockY].digtime + 10000)
>Then
>
>The code in question steps through the level, looking for pit's (holes dug
>by the player) and when it finds them the if statement above is used to
>compare the time when the hole was dug with the current time, if more than
>10 secconds elapsed the hole is filled up again.
>
>It is interesting that a different problem occurs if I turn on integer
>overflow checking and not range checking, the program then fails in
>characters.draw (though I cannot determine which character is being drawn
>when it happens).
>
>What I would love to do is a line by line step over and execute like you
>could in BP, however GDB refuses to step unless you run the program -
>which then happens without a pause until the program exits or waits for
>input - since the game's input is asynchrounous it never waits for input.
>
>Is there anyway to do this ? So I can step over the code and determine the
>exact moment of the errors - which when combined with a few whatches
>should allow me to solve them.
Why don't you simply use the FP IDE?
Its gdb surrounded by an editor (similar to BP editor)
and you can set breakpoints
by using Ctrl-F8 key,
after this you Run the program at it will stop when it comes to your breakpoint.
For that point you can use F7 to 'step into' or F8 to 'step over'
If you need more details on what is going on,
you can get a mixed source/assembler window
by first calling the 'Debug|Call stack' (Ctrl-F3)
and then Alt-I key...
Inside this window F7 behave like a instruction step
and F8 like GDB nexti (instruction step, but
without stepping inside called func/procedures...)
If you never used the IDE before,
you will need first to configure your IDE to get your program to compile
correctly.
For this:
1) select Debug mode in "Options|Mode" menu.
2) select the native target in 'Compiler|Target'
(you can not cross debug.. with the IDE)
3) set all options in 'Options|Compiler'
4) set all directories in 'Options|Directories'
5) Compile with 'Compile|Build'
(this way ou will add debug information to most of the units that you use).
Once that is done, you can go on with the list above.
More information about the fpc-pascal
mailing list