View Issue Details

IDProjectCategoryView StatusLast Update
0021370FPCDebuggerpublic2012-02-26 01:00
ReporterEverton Vieira Assigned ToJonas Maebe  
PrioritynormalSeveritymajorReproducibilityalways
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);
var
  I: Integer;
  Frames: PPointer;
  Report: string;
begin
  Report := 'Program exception! ' + LineEnding +
    'Stacktrace:' + LineEnding + LineEnding;
  if E <> nil then begin
    Report := Report + 'Exception class: ' + E.ClassName + LineEnding +
    'Message: ' + E.Message + LineEnding;
  end;
  Report := Report + BackTraceStrFunc(ExceptAddr);
  Frames := ExceptFrames;
  for I := 0 to ExceptFrameCount - 1 do
    Report := Report + LineEnding + BackTraceStrFunc(Frames[I]);
  ShowMessage(Report);
  Halt; // End of program execution
end;
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

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

Activities

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

 

exception.zip (129,570 bytes)

2012-02-24 18:43

 

lib.zip (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.

Try


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



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

TApplication.HandleException
  Stack trace:
  $00430515 line 60 of unit1.pas
  $00521941 line 2664 of include/control.inc
  $0053FCD3 line 62 of include/buttoncontrol.inc
  $005402C6 line 174 of include/buttons.inc
  $00540A91 line 349 of include/buttons.inc
  $0053FB8E line 26 of include/buttoncontrol.inc
  $0040AD9A line 472 of ../inc/objpas.inc
  $00510F98 line 5276 of include/wincontrol.inc
  $0056DD00 line 112 of lclmessageglue.pas
  $004EAC30 line 2404 of win32/win32callback.inc
  $005715AD line 375 of win32/win32wsforms.pp
  $766BFD72
  $766BFE4A
  $766C0943
  $766C0B36
  $7467B4BA
  $7467B51C


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: exception.zip
2012-02-24 18:43 Everton Vieira File Added: lib.zip
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