Sign in Join

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

Mailing lists / lazarus / 1999-07

Trace via Assert is committed

10 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Jeff Wormsley
to Michael Wood: Hi -----Original Message----- From: Jeff Wormsley To: Date: 29 July 1999 02:45 Subject:…
Michael Wood wrote 7 lines
But you can if you install Cygwin :) It comes with bash so you can do something like this: lazarus 2>debug.txt just like in Unix/Linux.

I looked at Cygwin a few weeks ago. I wasn't sure if it was a good idea to mix environments. Win32 people like to do things the Win32 way. It's even worse when you mix linux, dos, and NT all together. You end up with a confusing mishmash of ways to do things that no one can figure out. Even the makefiles confuse me sometimes, since I am not familiar with all of the command line switches that are used for things like rm. My first thought for the Win32 HowTo was to install Cygwin and then follow the Linux HowTo ;^)

Jeff.

Reply by email

Michael A. Hess
to Unknown author: You may want to change the default behaviour to output to stderr instead of output; this…
Jeff Wormsley wrote
Remember if you do this for a Win32 machine, you won't be able to capture the output by piping to a file, as in "lazarus > debug.txt" because stderr does not get piped out like normal output.

That is why the Trace code supports alternate file output. If you set the TraceFileName variable with a file name then it outputs the data there and not to strerr or strout which ever one is used. Then you don't need to pipe to anything.

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

Reply by email

Michael A. Hess

OK. I finally got the Trace working with Assert and it is committed. I changed all the gtkint.pp + incs., control.pp + .incs, forms.pp + incs., buttons.pp + incs.

I was testing with hello_world so I didn't hit some of the other files. They will have to be done as well. It is real simple to implement. Since just about every unit uses controls.pp I have added the utrace unit to controls.pp. It only needs to be added once.

+++++++++++++++++++++++++++++++++++++

+++ What needs to be added +++

At the beginning of the .pp file (not the inc's but the pp file that calls the inc's) add these lines

{$ifdef Trace}
   {$ASSERTIONS ON}
{$endif}

This is the switch that will turn Assertions on in the file. If you define Trace globally as in the make command:

make OPT=-dTrace

then every file that is compiled will turn this switch on and use Assertions. However, if you only want to do tracing in the file in which you are working. Just add the line:

{$ASSERTIONS ON}

somewhere at the top of your file and then only that file will output trace statements.

+++ What needs to be changed +++

Now for the Trace statements themselves. All you need is a standard Assert line with on caveat.

Assert(False, 'Trace:Your trace message');

Set the check to false so the Assert always gets fired. Then the very beginning of the message MUST START with "Trace:". This is a signal to the AssertErrorProc that this is just a trace statement and it just has to output the information. The only part of the message that does get output is the part AFTER the "Trace:" flag. The word "Trace:" does not get output.

So the above line on the console would be:

Your trace message

NOTE:
If you DO NOT put the "Trace:" flag at the beginning of the message the AssertErrorProc will ASSUME that this is a normal programming Assert call and will call the normal Handler which will output the message and raise an exception. This will allow normal use of the Assert as well as using it for tracing statements.

+++ Where does it output +++

The output itself defaults to the console. However it is possible to have the output go to a file of your choosing. To do this will required that you add the utrace unit to the file you are working with. Then someplace before the Trace statements that you want to see just set the following global variable:

TraceFileName := 'mylogfile';

where 'mylogfile' is of course any file of your choosing.

++++++++++++++++++++++++++++++++

For a simple example of how this works check the buttons.pp file and the buttonimp.inc file.

So now if you just type make to build your applications you don't get any output to the console. Do a "make OPT=-dTrace" and you will get a screen full of messages.

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

Reply by email

Jeff Wormsley
to Unknown author: You may want to change the default behaviour to output to stderr instead of output; this…
Show quoted text 5 lines
You may want to change the default behaviour to output to stderr instead of output; this way you can split the 'normal' output from debug output. stderr is standard defined by FPC. Just standard unix/linux behaviour.

Remember if you do this for a Win32 machine, you won't be able to capture the output by piping to a file, as in "lazarus > debug.txt" because stderr does not get piped out like normal output.

Jeff.

Reply by email

Michael A. Hess
to Unknown author: You may want to change the default behaviour to output to stderr instead of output; this…
You may want to change the default behaviour to output to stderr instead of output; this way you can split the 'normal' output from debug output. stderr is standard defined by FPC.

The reason it doesn't was to simplify coding. If you do an open with the filename '' {empty} it opens to stdout. This way I didn't need to really check the filename just open it and it would go to the correct place. I can of course fource the issue and go to strerr. I'll change it later today. :-)

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

Reply by email

Unknown author
to Michael A. Hess: OK. I finally got the Trace working with Assert and it is committed. I changed all the…
Show quoted text 10 lines
+++ Where does it output +++ The output itself defaults to the console. However it is possible to have the output go to a file of your choosing. To do this will required that you add the utrace unit to the file you are working with. Then someplace before the Trace statements that you want to see just set the following global variable: TraceFileName := 'mylogfile';

You may want to change the default behaviour to output to stderr instead of output; this way you can split the 'normal' output from debug output. stderr is standard defined by FPC.

Just standard unix/linux behaviour.

Michael.

Reply by email

Michael Wood

Hi

Earlier message 31 lines
-----Original Message----- From: Jeff Wormsley To: Date: 29 July 1999 04:00 Subject: Re: [lazarus] Trace via Assert is committed >On 7/29/99, at 2:58 PM, Michael Wood wrote: > >>But you can if you install Cygwin :) >> >>It comes with bash so you can do something like this: >> lazarus 2>debug.txt >> >>just like in Unix/Linux. > >I looked at Cygwin a few weeks ago. I wasn't sure if it was a >good idea to mix environments. Win32 people like to do things >the Win32 way. It's even worse when you mix linux, dos, and NT >all together. You end up with a confusing mishmash of ways to >do things that no one can figure out. Even the makefiles >confuse me sometimes, since I am not familiar with all of the >command line switches that are used for things like rm. My >first thought for the Win32 HowTo was to install Cygwin and >then follow the Linux HowTo ;^) Maybe it's best not to tell everyone to install Cygwin and use the Linux HOWTO :) but for people familiar with Linux, Cygwin can be quite useful. -- Michael Wood | Tel: +27 21 762 0276 | http://www.kingsley.co.za/ | Fax: +27 21 761 9930 | Kingsley Technologies

Reply by email

Michael Wood

Hi

Earlier message 31 lines
-----Original Message----- From: Jeff Wormsley To: Date: 29 July 1999 02:45 Subject: Re: [lazarus] Trace via Assert is committed >On 7/29/99, at 12:08 PM, wrote: > >>You may want to change the default behaviour to output to stderr instead of >>output; this way you can split the 'normal' output from debug output. >>stderr is standard defined by FPC. >> >>Just standard unix/linux behaviour. > >Remember if you do this for a Win32 machine, you won't be able to capture the output by piping to a file, as in "lazarus > debug.txt" because stderr does not get piped out like normal output. But you can if you install Cygwin :) It comes with bash so you can do something like this: lazarus 2>debug.txt just like in Unix/Linux. -- Michael Wood | Tel: +27 21 762 0276 | http://www.kingsley.co.za/ | Fax: +27 21 761 9930 | Kingsley Technologies

Reply by email

Peter Vreman
to Jeff Wormsley: Remember if you do this for a Win32 machine, you won't be able to capture the output by…
you wrote 17 lines
On Thu, 29 Jul 1999, Jeff Wormsley wrote: > On 7/29/99, at 12:08 PM, wrote: > > >You may want to change the default behaviour to output to stderr instead of > >output; this way you can split the 'normal' output from debug output. > >stderr is standard defined by FPC. > > > >Just standard unix/linux behaviour. > > Remember if you do this for a Win32 machine, you won't be able to capture the output by piping to a file, as in "lazarus > debug.txt" because stderr does not get piped out like normal output. Just use the 'redir' program that comes with djgpp, and then it should work fine.

Or use 4dos, then you can do 'lazarus >& file'

Reply by email

Unknown author
to Jeff Wormsley: Remember if you do this for a Win32 machine, you won't be able to capture the output by…
Jeff Wormsley wrote 9 lines
On 7/29/99, at 12:08 PM, wrote: >You may want to change the default behaviour to output to stderr instead of >output; this way you can split the 'normal' output from debug output. >stderr is standard defined by FPC. > >Just standard unix/linux behaviour. Remember if you do this for a Win32 machine, you won't be able to capture the output by piping to a file, as in "lazarus > debug.txt" because stderr does not get piped out like normal output.

Just use the 'redir' program that comes with djgpp, and then it should work fine.

Michael.

Reply by email