View Issue Details

IDProjectCategoryView StatusLast Update
0021370FPCDebuggerpublic2012-02-26 01:00
ReporterEverton Vieira Assigned ToJonas Maebe  
Status resolvedResolutionduplicate 
Summary0021370: The debug doesn't generate the info of the error.
DescriptionDoesn't matter what compiler option is seted: -g -gl or the dwarf system also, this code doesn't work:

procedure DumpExceptionCallStack(E: Exception);
  I: Integer;
  Frames: PPointer;
  Report: string;
  Report := 'Program exception! ' + LineEnding +
    'Stacktrace:' + LineEnding + LineEnding;
  if E <> nil then begin
    Report := Report + 'Exception class: ' + E.ClassName + LineEnding +
    'Message: ' + E.Message + LineEnding;
  Report := Report + BackTraceStrFunc(ExceptAddr);
  Frames := ExceptFrames;
  for I := 0 to ExceptFrameCount - 1 do
    Report := Report + LineEnding + BackTraceStrFunc(Frames[I]);
  Halt; // End of program execution
TagsNo tags attached.
Fixed in Revision
Attached Files


duplicate of 0013518 resolvedMichael Van Canneyt Only first backtrace in big program has attached source nad line information 


Vincent Snijders

2012-02-24 14:29

manager   ~0057065

I have no such problem on windows xp (32 bits). What is your OS?

Please attached a complete compilable source application (zipped).

Everton Vieira

2012-02-24 18:29

reporter   ~0057071

I've tested on a several enviroments, a virtualized win xp 32 on a mac host, the mac host it self, on a win 7 64b host and on a win xp 32b also host.

None of them worked.

2012-02-24 18:42 (129,570 bytes)

2012-02-24 18:43 (194,206 bytes)

Everton Vieira

2012-02-24 18:45

reporter   ~0057072

I wasn't able to upload the executable.

Martin Friebe

2012-02-24 21:51

manager   ~0057074

This is the correct behaviour. Though you are right it does not work in your case.


procedure TForm1.Button1Click(Sender: TObject);
  a, b, c: Integer;
  //raise Exception.Create('');
  a := 1;
  b := 0;
  c := a div b;
  on e: Exception do DumpExceptionCallStack(e);

This works.

If you compile your app with -WC (win-console app) then you will see, that the exception handler int application dumps the stack too

  Stack trace:
  $00430515 line 60 of unit1.pas
  $00521941 line 2664 of include/
  $0053FCD3 line 62 of include/
  $005402C6 line 174 of include/
  $00540A91 line 349 of include/
  $0053FB8E line 26 of include/
  $0040AD9A line 472 of ../inc/
  $00510F98 line 5276 of include/
  $0056DD00 line 112 of lclmessageglue.pas
  $004EAC30 line 2404 of win32/
  $005715AD line 375 of win32/win32wsforms.pp

As you can see, this reaches stack frames, that are not in your app, and have no debug info (windows kernel)

The "BackTraceStrFunc" detects this and handles it as fault.

Once the BackTraceStrFunc, encounters a problem it switches itself to the "trace without symbols"
This is for the entire rest of your apps running time.

So once a stack dump was not entirely succesful, it will never again have symbols.

This is part of how FPC deals with this.
It is a safety pre-caution, so that if anything more serious does happen, the BackTraceStrFunc does not get called for an exception it caused itself (danger of endless loop)

If you believe it is to cautious or there are better ways, please report to the fpc team.

As a work around: Take a copy of BackTraceStrFunc at start up

Martin Friebe

2012-02-25 16:03

manager   ~0057082

Since Lazarus (when dumping the Stack) uses the FrameCount provided by FPC, this is an FPC issue.

Moving to FPC, for decision if this is the desired behaviour

Issue History

Date Modified Username Field Change
2012-02-24 13:51 Everton Vieira New Issue
2012-02-24 13:51 Everton Vieira Status new => assigned
2012-02-24 13:51 Everton Vieira Assigned To => Marc Weustink
2012-02-24 13:51 Everton Vieira Widgetset => Win32/Win64
2012-02-24 14:29 Vincent Snijders LazTarget => -
2012-02-24 14:29 Vincent Snijders Note Added: 0057065
2012-02-24 14:29 Vincent Snijders Status assigned => feedback
2012-02-24 18:29 Everton Vieira Note Added: 0057071
2012-02-24 18:42 Everton Vieira File Added:
2012-02-24 18:43 Everton Vieira File Added:
2012-02-24 18:45 Everton Vieira Note Added: 0057072
2012-02-24 21:40 Martin Friebe Status feedback => assigned
2012-02-24 21:40 Martin Friebe Assigned To Marc Weustink => Martin Friebe
2012-02-24 21:51 Martin Friebe Note Added: 0057074
2012-02-24 21:51 Martin Friebe Assigned To Martin Friebe =>
2012-02-24 21:51 Martin Friebe Status assigned => feedback
2012-02-25 16:03 Martin Friebe Note Added: 0057082
2012-02-25 16:03 Martin Friebe Status feedback => new
2012-02-25 16:04 Martin Friebe Project Lazarus => FPC
2012-02-26 01:00 Jonas Maebe Relationship added duplicate of 0013518
2012-02-26 01:00 Jonas Maebe Duplicate ID 0 => 13518
2012-02-26 01:00 Jonas Maebe Status new => resolved
2012-02-26 01:00 Jonas Maebe Resolution open => duplicate
2012-02-26 01:00 Jonas Maebe Assigned To => Jonas Maebe