Recent

Author Topic: Back-tracing feature if an error happens  (Read 5947 times)

jshand2010

  • Full Member
  • ***
  • Posts: 236
Back-tracing feature if an error happens
« on: March 18, 2012, 01:08:35 am »
it would be a great idea to include within the debugger or codetools a function that records everymove the the running application takes whether correct or error, so you can actually know where to go into your code to fix the problem.

need more info, just ask.

thanks again
OpenSUSE Tumbleweed x86_64, Lazarus 2.2.0RC2 fixes branch, fpc 3.2.3 fixes branch

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Back-tracing feature if an error happens
« Reply #1 on: March 18, 2012, 01:40:06 am »
Well recording every single move would be very very slow.

Anyway Lazarus has a debugger, and that allows you to single step through parts of your app.

How much do you know about debugging?

1) Make sure the debugger is set up correctly
http://wiki.lazarus.freepascal.org/Debugger_Setup

If you press F9, you should see blue dots on the lft side of the editor.

2)
Set a breakpoint. Click the left side of the editor and a red dot appears

Your app will stop whenever it reaches that point.
You can single step using F7/F8

Look at the watches window, or use hints to inspect variables.

Read about some limitations:
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Properties

3)
There is plenty more. Please ask for more details

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Back-tracing feature if an error happens
« Reply #2 on: March 18, 2012, 01:41:27 am »
If you use 0.9.31 there is a "History" window in the debugger.

It allows to take snapshots at breakpoints

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Back-tracing feature if an error happens
« Reply #3 on: March 18, 2012, 01:39:38 pm »
Actually this is what -gl (almost) gives, only the information given is in the form of call stack. You could use TEventLog component to log every possible action, though this should only be activated during debug mode.

jshand2010

  • Full Member
  • ***
  • Posts: 236
Re: Back-tracing feature if an error happens
« Reply #4 on: March 18, 2012, 10:11:31 pm »
hi martin_fr,

i do currently use the 0.9.31 version and i have never come across the history feature.  please tell me how to use it.  it may just save me a lot of time
OpenSUSE Tumbleweed x86_64, Lazarus 2.2.0RC2 fixes branch, fpc 3.2.3 fixes branch

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Back-tracing feature if an error happens
« Reply #5 on: March 18, 2012, 10:51:10 pm »
Select from the view menu, "Debug windows" > History
or ctrl-alt-H

Note, it only records if you pause/break/single-step the app. (watches will be recorded if you pause long enough.)

If the app runs un-interupted, then nothing is recorded.

If you get an exception, then place breakpoints at points that may be of interest.
In the break point properties you can set, that the breakpoint does not stop, but take a snapshot (including stack and watches), and you can inspect the data later.

Codetool can "find references" of a symbol, so you can find places that call/access something

 

TinyPortal © 2005-2018