[Gambas-user] Weird errors using debug
Benoit Minisini
gambas at ...1...
Sat Sep 20 12:21:03 CEST 2008
On samedi 20 septembre 2008, richard terry wrote:
> I think i need a mini-tutorial on how to user debug.
>
> I assumed that the statement could be used in place of PRINT to print out
> messages in the console, but after 8-10 hours of wondering why my program
> was suddenly doing bizaare things, I eventually tracked it down to my use
> of putting in lines line
>
> Debug "Starting to save....."
>
> .... my code here
>
> Debug "Finished saving"
>
> What happened was really really bizarre. The program flow became altered,
> If the code within one suboutine had called on another subroutine, the
> program flow in the orginal routine continued without waiting for the
> execution of the subroutine, and even weider, the contents of some
> variables I'd been using in the calling routine where partially internally
> overwritten by code statements from within my gambas program itself and in
> part from some of the console output!, not necessarily from the routine I
> was in.
>
> Almost like memory addresses somehow were getting mixed up.
>
> I was doing some complex parsing of html, substituting src= statements
> contianing temporary file names, for the database pk of the image I was
> saving in the html.After 10 frustrating hours, I did a global substitution
> of all my Debug with PRINT, and hey presto - the problem disappeared.
>
> I note this from the documentation:
>
> Prints expressions to the standard error output, only if your program is
> compiled with debugging informations.
>
> Maybe my program is somehow not containing 'debugging information(s) -wrong
> spelling by the way, perhaps someone can explain to me how to use debug.
>
> Regards
>
> Richard
>
If you run your program in the IDE, debugging information is enabled.
DEBUG is like PRINT, except that:
- Everything is sent to the standard error output.
- The current class, current method and current line is printed before the
message.
Anyway, your own interpretation of what you see is not really useful. I need a
project and a way to reproduce the described behaviour.
If you want to see if there was memory corruption (why not?), just use
valgrind to run the interpreter:
$ cd /my/gambas/project
$ valgrind --tool=memcheck --num-callers=50 gbx2 -p
...
Regards,
--
Benoit Minisini
More information about the User
mailing list