Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 1999-07

Trace routines using Assert doesn't work

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Michael A. Hess: I have written the Trace routines and have assigned the AssertErrorProc procedure.…
Michael A. Hess wrote 12 lines
I have written the Trace routines and have assigned the AssertErrorProc procedure. Everything should work like gang busters but it doesn't. Everything is setup correctly and my handler is called if an Assertion fires. The problem is that if I do any kind of writing from in my Handler such as a simple writeln the program throws and exceptions and stops. If I don't have any code in the handler the program runs fine. Add just one writeln and it will output whatever the writeln contained and then it stops cold. What could be preventing me from adding any writeln code to the handler? Any clues compiler guys??

None; the default routine does exactly that: it writes a message !!

Can you send me the unit, I'll have a look.

Michael.

Reply by email

Peter Vreman
to Michael A. Hess: I have written the Trace routines and have assigned the AssertErrorProc procedure.…
you wrote 12 lines
I have written the Trace routines and have assigned the AssertErrorProc procedure. Everything should work like gang busters but it doesn't. Everything is setup correctly and my handler is called if an Assertion fires. The problem is that if I do any kind of writing from in my Handler such as a simple writeln the program throws and exceptions and stops. If I don't have any code in the handler the program runs fine. Add just one writeln and it will output whatever the writeln contained and then it stops cold. What could be preventing me from adding any writeln code to the handler? Any clues compiler guys??

No, because i don't have code which shows the bugs.

Reply by email

Michael A. Hess
to Michael Van Canneyt: None; the default routine does exactly that: it writes a message !! Can you send me the…
Michael Van Canneyt wrote
None; the default routine does exactly that: it writes a message !!

That's why I am confused.

Can you send me the unit, I'll have a look.

Well I just tried to write a real simple program that uses the utrace unit and guess what. The simple code works JUST fine. Something in the lcl must be unhappy with what is going on. Let me look at it some more maybe with some more messing around I can find it. :-\

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email

Michael A. Hess
to Peter Vreman: No, because i don't have code which shows the bugs.
Peter Vreman wrote 6 lines
>What could be preventing me from adding any writeln code to the >handler? > >Any clues compiler guys?? No, because i don't have code which shows the bugs.

I didn't send you any code because the simple code version I created works fine. It is only in the lcl code that it blows out. I was hoping that maybe I was doing something stupid and you would be able to say, "well you did do such and such didn't you". However, with further testing it seems to be more involved then that. The exceptions isn't coming from the Assert exception is coming from the very next method call after the Assert line in my code. It happens to be

   inherited Create(Owner);

So the code looks like this

begin
   Assert(False, 'Trace:the message');
   inherited Create(Owner);
   Assert(False, 'Trace:next trace message');

.
.
.
.
end;

If I put a try..except around this it fails but ONLY if Assertions are turned on. I'll work on checking exactly what exception is being thrown and try to track down who is throwing it.

The weird thing is that if I put a writeln between the Assert and the inherited line like this

   Assert(False, 'Trace:the message');
writeln('back from Assert');
   inherited Create(Owner);

Then the code DOESN'T throw an exception in the inherited call. But it will throw and exception on the line following the NEXT Assert line.

I hate it when writeln's fix bugs. :-\

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email

Peter Vreman
to Peter Vreman: No, because i don't have code which shows the bugs.
you wrote 49 lines
Peter Vreman wrote: > > >What could be preventing me from adding any writeln code to the > >handler? > > > >Any clues compiler guys?? > No, because i don't have code which shows the bugs. I didn't send you any code because the simple code version I created works fine. It is only in the lcl code that it blows out. I was hoping that maybe I was doing something stupid and you would be able to say, "well you did do such and such didn't you". However, with further testing it seems to be more involved then that. The exceptions isn't coming from the Assert exception is coming from the very next method call after the Assert line in my code. It happens to be inherited Create(Owner); So the code looks like this begin Assert(False, 'Trace:the message'); inherited Create(Owner); Assert(False, 'Trace:next trace message'); . . . . end; If I put a try..except around this it fails but ONLY if Assertions are turned on. I'll work on checking exactly what exception is being thrown and try to track down who is throwing it. The weird thing is that if I put a writeln between the Assert and the inherited line like this Assert(False, 'Trace:the message'); writeln('back from Assert'); inherited Create(Owner); Then the code DOESN'T throw an exception in the inherited call. But it will throw and exception on the line following the NEXT Assert line. I hate it when writeln's fix bugs. :-\

Then it's in 90% of the cases a bug with the stack.

Reply by email

Michael A. Hess

I have written the Trace routines and have assigned the AssertErrorProc procedure. Everything should work like gang busters but it doesn't. Everything is setup correctly and my handler is called if an Assertion fires. The problem is that if I do any kind of writing from in my Handler such as a simple writeln the program throws and exceptions and stops. If I don't have any code in the handler the program runs fine. Add just one writeln and it will output whatever the writeln contained and then it stops cold.

What could be preventing me from adding any writeln code to the handler?

Any clues compiler guys??

(this is what we were calling the debug routines. I felt that debug was going to get to confusing with what is normally considered debugging. This is actually just tracing code during execution. Hence forth it is called Tracing.)

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email