Exception callstacks, backtracks...

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Exception callstacks, backtracks...

M. Utku Karataş
Hi all,

Basically I want to get a stack trace and log it when a special
exception occurs. All I could find about was the lineinfo.pas (and -gl
switch) but that does not help much as it interfaces only one procedure
which is no good for client usage. What do I miss; what common things do
you use for your own exception logging&handling?

Actually the ultimate solution would be having something like the
infamous Madexcept or EurokaLog Delphi addins. Are there any similar
attemps I overlooked?

It seems I will be using more and more FPC on my job and I am addicted
to such tools which makes me mad when I need to debug for some crash
just to get a callstack :) So, before I start rolling a solution, what
are your advices and where should my efforts go so that the community
would also benefit?

--
Best regards.

M. Utku Karatas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Exception callstacks, backtracks...

Vincent Snijders
m utku schreef:

> Hi all,
>
> Basically I want to get a stack trace and log it when a special
> exception occurs. All I could find about was the lineinfo.pas (and -gl
> switch) but that does not help much as it interfaces only one procedure
> which is no good for client usage. What do I miss; what common things do
> you use for your own exception logging&handling?
>
> Actually the ultimate solution would be having something like the
> infamous Madexcept or EurokaLog Delphi addins. Are there any similar
> attemps I overlooked?
>
> It seems I will be using more and more FPC on my job and I am addicted
> to such tools which makes me mad when I need to debug for some crash
> just to get a callstack :) So, before I start rolling a solution, what
> are your advices and where should my efforts go so that the community
> would also benefit?
>

I don't know those tools, may Multilog does something similar:
http://wiki.lazarus.freepascal.org/MultiLog

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Exception callstacks, backtracks...

Jonas Maebe-2
In reply to this post by M. Utku Karataş

On 07 Feb 2007, at 22:06, m utku wrote:

> Basically I want to get a stack trace and log it when a special  
> exception occurs.

There's

Procedure Dump_Stack(var f : text;bp:pointer);

in the system unit. You can use it like this:

   dump_stack(stdout,get_frame);

to dump the current call stack to standard output (or to any other  
text file by replacing stdout with something else).


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Exception callstacks, backtracks...

Luiz Americo Pereira Camara-2
In reply to this post by Vincent Snijders
Vincent Snijders wrote:

> m utku schreef:
>> Hi all,
>>
>> Basically I want to get a stack trace and log it when a special
>> exception occurs. All I could find about was the lineinfo.pas (and
>> -gl switch) but that does not help much as it interfaces only one
>> procedure which is no good for client usage. What do I miss; what
>> common things do you use for your own exception logging&handling?
>>
>> Actually the ultimate solution would be having something like the
>> infamous Madexcept or EurokaLog Delphi addins. Are there any similar
>> attemps I overlooked?
>>
>> It seems I will be using more and more FPC on my job and I am
>> addicted to such tools which makes me mad when I need to debug for
>> some crash just to get a callstack :) So, before I start rolling a
>> solution, what are your advices and where should my efforts go so
>> that the community would also benefit?
>>
>
> I don't know those tools, may Multilog does something similar:
> http://wiki.lazarus.freepascal.org/MultiLog
Yes. It has a specialized SendCallStack function.

BTW: I will update it shortly

Luiz
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Exception callstacks, backtracks...

M. Utku Karataş
In reply to this post by M. Utku Karataş
Jonas Maebe <jonas.maebe@...> writes:
 > There's
 >
 > Procedure Dump_Stack(var f : text;bp:pointer);
 >
 > in the system unit. You can use it like this:
 >
 >    dump_stack(stdout,get_frame);
 >

This cleared a lot on my mind, thanks Jonas...

Recently I have tried this:
//------------------------------------------------------
try
    AFunctionThatWillRaiseAnExceptionDeepInside;
except
    Dump_Stack(stdout, ExceptAddr);
end;
//------------------------------------------------------

Unfortunately this did not do what I thought: giving the callstack from the
point of where exception occured. Is there any way for that?

Thanks,
M. Utku Karatas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Re: Exception callstacks, backtracks...

Luiz Americo Pereira Camara-2
m utku escreveu:

> Jonas Maebe <jonas.maebe@...> writes:
> > There's
> >
> > Procedure Dump_Stack(var f : text;bp:pointer);
> >
> > in the system unit. You can use it like this:
> >
> >    dump_stack(stdout,get_frame);
> >
>
> This cleared a lot on my mind, thanks Jonas...
>
> Recently I have tried this:
> //------------------------------------------------------
> try
>    AFunctionThatWillRaiseAnExceptionDeepInside;
> except
>    Dump_Stack(stdout, ExceptAddr);
> end;
> //------------------------------------------------------
>
> Unfortunately this did not do what I thought: giving the callstack
> from the
> point of where exception occured. Is there any way for that?
>
Multilog also provides a SendException method that will give the
exception stack frame along other info

Luiz

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal