Re: [fpc-pascal] FPC Backtrace

2022-01-04 Thread James Richters via fpc-pascal
Thanks for the information.

I've used breakpoints before, but for this issue, it was happening on a 
computer where I did not have the compiler, so I wanted something compiled into 
the program that I could run on the computer with the issue and get the 
backtrace information.. it worked great.

Just in case anyone comes across this trying to do the same thing, the command 
I used was:
dump_stack(stdout,0); 
sending it to stdout as a way to get it to the console screen is not 
immediately obvious from the documentation at:
https://www.freepascal.org/docs-html/rtl/system/dump_stack.html
but it works great without needing to have my own file to write to.

I didn't know about setting a conditional breakpoint though, so thanks for 
pointing that out.. there are quite a few times I avoid breakpoints because 
they happen too often.. a conditional break could be handy.. I don't know if 
the FPC text mode IDE does that or not... unfortunately the main big project I 
work on all the time refuses to compile in Lazarus.  I don't remember why... it 
can't find some units or something I've tried several times to go in and 
address whatever it causing it to not work and I always hit a roadblock where I 
just don't know how to make it work... and then I need to get some real work 
done, so I just open the FPC Text IDE and everything is fine.

James

-Original Message-
From: fpc-pascal  On Behalf Of Graeme 
Geldenhuys via fpc-pascal
Sent: Monday, January 3, 2022 7:01 PM
To: fpc-pascal@lists.freepascal.org
Cc: Graeme Geldenhuys 
Subject: Re: [fpc-pascal] FPC Backtrace

On 2022-01-03 23:45, Graeme Geldenhuys wrote:
> On 2022-01-03 13:28, James Richters via fpc-pascal wrote:
>> I’m curious if there is some way, perhaps with some directive or 
>> something to force a debug backtrace to happen, but without an error.
> 
> Christo already offered you a solution, but to offer an alternative 
> solution... Most IDE debugging functionality (or even GDB directly) 
> allows you to set a Breakpoint with iteration count or some other 
> expression.


Here is the details for Lazarus breakpoint properties, if that might help.
 
https://wiki.freepascal.org/IDE_Window:_Breakpoints#Breakpoint_properties



Regards,
   Graeme


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC Backtrace

2022-01-03 Thread Graeme Geldenhuys via fpc-pascal

On 2022-01-03 23:45, Graeme Geldenhuys wrote:

On 2022-01-03 13:28, James Richters via fpc-pascal wrote:
I’m curious if there is some way, perhaps with some directive or 
something to force a debug backtrace to happen, but without an error.


Christo already offered you a solution, but to offer an alternative 
solution... Most IDE debugging functionality (or even GDB directly) 
allows you to set a Breakpoint with iteration count or some other 
expression.



Here is the details for Lazarus breakpoint properties, if that might help.

https://wiki.freepascal.org/IDE_Window:_Breakpoints#Breakpoint_properties



Regards,
  Graeme


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC Backtrace

2022-01-03 Thread Graeme Geldenhuys via fpc-pascal

On 2022-01-03 13:28, James Richters via fpc-pascal wrote:
I’m curious if there is some way, perhaps with some directive or 
something to force a debug backtrace to happen, but without an error.


Christo already offered you a solution, but to offer an alternative 
solution... Most IDE debugging functionality (or even GDB directly) 
allows you to set a Breakpoint with iteration count or some other 
expression. So instead of the default, triggering the breakpoint 
instantly, you can trigger in with a different criteria. Once the 
breakpoint is triggered, then you can look at the Call Stack and 
evaluate local variables and such.


Regards,
  Graeme

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC Backtrace

2022-01-03 Thread James Richters via fpc-pascal
That works great!!!  
Exactly what I was wanting
 
Thank you,
James
 
 
 
On Mon, Jan 3, 2022 at 3:28 PM James Richters via fpc-pascal 
mailto:fpc-pascal@lists.freepascal.org> > 
wrote:
I’m curious if there is some way, perhaps with some directive or something to 
force a debug backtrace to happen, but without an error
 
Try calling Dump_Stack in your code: 
https://freepascal.org/docs-html/rtl/system/dump_stack.html
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC Backtrace

2022-01-03 Thread Christo Crause via fpc-pascal
On Mon, Jan 3, 2022 at 3:28 PM James Richters via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> I’m curious if there is some way, perhaps with some directive or something
> to force a debug backtrace to happen, but without an error
>

Try calling Dump_Stack in your code:
https://freepascal.org/docs-html/rtl/system/dump_stack.html
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] FPC Backtrace

2022-01-03 Thread James Richters via fpc-pascal
I'm curious if there is some way, perhaps with some directive or something
to force a debug backtrace to happen, but without an error.
 
I have a function that is getting called twice and should only be called
once, so my thought is that if I could go into the routine and 
put something there that outputs a backtrace.. same as when there is an
error in the program.. 
where it shows the entire list of calls, but not because of an error.. then
it would continue to run and I could see the entire chain that resulted in
the call each time.
 
I know there are other ways I can find this, but the issue made me wonder if
there was a way I could ask for my own backtrace with a command inside the
program
Because that would be a quick easy way to find all the call chains that get
to this function.. And it would be cool to be able to do such a thing,
especially on large 
Complicated projects.
 
James
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal