Sign in Join

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

Mailing lists / lazarus / 2012-02

Add notification to callstack change.

14 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Everton Vieira

Hi there.

I know very little about notifications, and maybe what i know is wrong, so any help would be useful.

I`m trying to add some kind of notication that triggers an event when the callstack of the application is changed.

By example, the Application.onException is trigged when an exception happens, some event similar to triggers when the callstack is changed, in other words, when the execution go to the next line of the code.

Please help, any help will be usefull.

Reply by email

Sven Barth
to Everton Vieira
Everton Vieira wrote 9 lines
Hi there. I know very little about notifications, and maybe what i know is wrong, so any help would be useful. I`m trying to add some kind of notication that triggers an event when the callstack of the application is changed. By example, the Application.onException is trigged when an exception happens, some event similar to triggers when the callstack is changed, in other words, when the execution go to the next line of the code. Please help, any help will be usefull.

You can't do this in an application itself. You need to use a debugger for that. Or do you mean interfacing with Lazarus' debugger interface?

Regards,
Sven

Reply by email

Everton Vieira
to Sven Barth

But, by example, if is possible to do a log with the exception back trace must be some how to do also a log of the call stack of the application. I think the Watch debugger has the know how for, the problem is to understand.

Sven Barth wrote 22 lines
Am 08.02.2012 15:00, schrieb Everton Vieira: > Hi there. > > I know very little about notifications, and maybe what i know is wrong, so any help would be useful. > > I`m trying to add some kind of notication that triggers an event when the callstack of the application is changed. > > By example, the Application.onException is trigged when an exception happens, some event similar to triggers when the callstack is changed, in other words, when the execution go to the next line of the code. > > Please help, any help will be usefull. You can't do this in an application itself. You need to use a debugger for that. Or do you mean interfacing with Lazarus' debugger interface? Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Everton Vieira
to Sven Barth: You can't do this in an application itself. You need to use a debugger for that. Or do…

The case is: I have an enviroment that i can`t use the debugger of the lazarus, if i could i would by sure, then i`m trying to make some kind of log of some units, that times works out pretty well and some times don't. Here in my machine works out pretty well. I have already an to dame primitive function that makes that log that i need but i been thinking in how to make that log in a better way.

Sven Barth wrote 22 lines
Am 08.02.2012 15:00, schrieb Everton Vieira: > Hi there. > > I know very little about notifications, and maybe what i know is wrong, so any help would be useful. > > I`m trying to add some kind of notication that triggers an event when the callstack of the application is changed. > > By example, the Application.onException is trigged when an exception happens, some event similar to triggers when the callstack is changed, in other words, when the execution go to the next line of the code. > > Please help, any help will be usefull. You can't do this in an application itself. You need to use a debugger for that. Or do you mean interfacing with Lazarus' debugger interface? Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Martin
to Everton Vieira
Everton Vieira wrote
The case is: I have an enviroment that i can`t use the debugger of the lazarus, if i could i would by sure, then i`m trying to make some kind of log of some units, that times works out pretty well and some times don't. Here in my machine works out pretty well. I have already an to dame primitive function that makes that log that i need but i been thinking in how to make that log in a better way.
uses LCLProc;
DumpStack;

Reply by email

Everton Vieira
to Martin

Yes, is some like it i`m already doing. But this mean to put a lot of DumpStacks in the code witch is not nice.

How can the debugger know that a specific line is about to be executed. Must be some listening/event for.

Is in that time i`m been thinking to do some. Some kind that when the line is in the stetted to log units so they make the dumpstack, or something similar, some king of log file, to be able to see in run time what is happen.

Martin wrote 13 lines
On 08/02/2012 15:15, Everton Vieira wrote: > The case is: I have an enviroment that i can`t use the debugger of the lazarus, if i could i would by sure, then i`m trying to make some kind of log of some units, that times works out pretty well and some times don't. Here in my machine works out pretty well. I have already an to dame primitive function that makes that log that i need but i been thinking in how to make that log in a better way. > uses LCLProc; DumpStack; -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Sven Barth
to Everton Vieira
Everton Vieira wrote
Yes, is some like it i`m already doing. But this mean to put a lot of DumpStacks in the code witch is not nice. How can the debugger know that a specific line is about to be executed. Must be some listening/event for.

A debugger uses the debug API provided by the operating system together with some debug information to know which instructions map to which source lines. And no, it won't work if you try to debug an application from within that same application...

Regards,
Sven

Reply by email

Everton Vieira
to Sven Barth

I see. Thanks again! What can be done in this case?

Sven Barth wrote
A debugger uses the debug API provided by the operating system together with some debug information to know which instructions map to which source lines. And no, it won't work if you try to debug an application from within that same application... Regards, Sven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120208/cfef830d/attachment.html>

Reply by email

Everton Vieira
to Everton Vieira

How can a debug an app in run time? Is there some how?

Everton Vieira wrote 9 lines
I see. Thanks again! What can be done in this case? Em 08/02/2012, ?s 14:27, Sven Barth escreveu: > A debugger uses the debug API provided by the operating system together with some debug information to know which instructions map to which source lines. And no, it won't work if you try to debug an application from within that same application... > > Regards, > Sven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120208/50040282/attachment.html>

Reply by email

Martin
to Everton Vieira
Everton Vieira wrote
How can a debug an app in run time? Is there some how?

If you can not use any debugger, then the only way is lots of writeln (or LCLProc.Debugln) and DumpStack...

If it is just you can't use Lazarus to debug => you can still use gdb itself (Lazarus uses gdb too)

For example, if you code is executed in a http-server, gdb can "attach" to the already running server (Lazarus does not yet support that)

Another way is, if you cant debug your code on the life system, write a test case. A stand-alone app, that uses the units, and calls the code in question with simulated data. Then debug the test case

Reply by email

Everton Vieira
to Martin

Can I make the gdb to log the behavior of an app, or some units?

Martin wrote 19 lines
On 08/02/2012 16:36, Everton Vieira wrote: > How can a debug an app in run time? Is there some how? If you can not use any debugger, then the only way is lots of writeln (or LCLProc.Debugln) and DumpStack... If it is just you can't use Lazarus to debug => you can still use gdb itself (Lazarus uses gdb too) For example, if you code is executed in a http-server, gdb can "attach" to the already running server (Lazarus does not yet support that) Another way is, if you cant debug your code on the life system, write a test case. A stand-alone app, that uses the units, and calls the code in question with simulated data. Then debug the test case -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Martin
to Martin: If you can not use any debugger, then the only way is lots of writeln (or…
Martin wrote 17 lines
On 08/02/2012 16:36, Everton Vieira wrote: > How can a debug an app in run time? Is there some how? If you can not use any debugger, then the only way is lots of writeln (or LCLProc.Debugln) and DumpStack... If it is just you can't use Lazarus to debug => you can still use gdb itself (Lazarus uses gdb too) For example, if you code is executed in a http-server, gdb can "attach" to the already running server (Lazarus does not yet support that) Another way is, if you cant debug your code on the life system, write a test case. A stand-alone app, that uses the units, and calls the code in question with simulated data. Then debug the test case

If the problem is that your app must not loose focus, so breakpoints can not be used:
They can. But you need Lazarus 0.9.31to make some use of it

Open the properties of a breakpoint.
deselect "Break"
add "Take snapshot"

Reply by email

Martin
to Everton Vieira: Can I make the gdb to log the behavior of an app, or some units?
Everton Vieira wrote
Can I make the gdb to log the behavior of an app, or some units?

Tracepoints maybe?

http://www.delorie.com/gnu/docs/gdb/gdb_72.html

I havent used them myself, so I cant comment...

See my other mail

You can run your app in lazarus (but you need 0.9.31) and record all sort of thinks, without "stopping" your app

well it will need to pause for a moment to collec the data, but it will not loose focus.
And "DumpStack" takes time too. So real time behaviour is lost either way.

Breakpoints can add snapshots. To do that check the breakpoint properties.

In 0.9.31 is a Debug history window.
(the last 25 are shown (click the camera fore more)

- All watches are recorded
- local variables
- top 5 stack frames (but if you have the stack window open, more than 5)

Reply by email

Everton Vieira
to Martin

Well i`ll use by now the DebugLn similar that i`ve been using despite the hard work to be stetted. In the future i`ll see what can be done.

Thanks Martin, Thanks Sven, Thanks guys, Thanks a lot.

Martin wrote 35 lines
On 08/02/2012 16:52, Everton Vieira wrote: > Can I make the gdb to log the behavior of an app, or some units? > Tracepoints maybe? http://www.delorie.com/gnu/docs/gdb/gdb_72.html I havent used them myself, so I cant comment... See my other mail You can run your app in lazarus (but you need 0.9.31) and record all sort of thinks, without "stopping" your app well it will need to pause for a moment to collec the data, but it will not loose focus. And "DumpStack" takes time too. So real time behaviour is lost either way. Breakpoints can add snapshots. To do that check the breakpoint properties. In 0.9.31 is a Debug history window. (the last 25 are shown (click the camera fore more) - All watches are recorded - local variables - top 5 stack frames (but if you have the stack window open, more than 5) -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email