?
Solved

Exception handler (Callstack like)

Posted on 2003-03-03
6
Medium Priority
?
261 Views
Last Modified: 2010-04-04
Hi,

Does anybody know if their is a easy way to retreive and save debugging informations (i.e Callstack info) when an application crashes ??

I have to develop it by myself and do not use "external" components.

Thanks a lot.

HarmPier
 
0
Comment
Question by:HARMPIER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 8058211
Hello

  Try MadExecpt it's free for non-commercial use.
http://www.madshi.net
0
 
LVL 3

Expert Comment

by:sfock
ID: 8059567
to retrieve the callstack information i'd use the JCL (Jedi Code Library) wich is not a component set.
You can download it at http://www.delphi-jedi.org 
As an example on how to get the info's look at this tread
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20522255.html

at last the storage:

create a new unit lets say myDebug and add code like the following:

unit myDebug;
interface
uses classes;

type
  TDdbgOutput = class(TObject)
  private
    FStream: TFileStream;
  public
    constructor create(FilePathName: String);
    Destructor Destroy; override;
    function DebugOutput(output: String) : string; overload;
    class function OutputDebugString(output: String) : string;
  end;

function OutputDebugString(output: String) : string;

implementation

uses
  SysUtils, JCLDebug, JCLSynch, Windows, COMObj;


var
  theMainDebugOutput : TDdbgOutput;
  LogBasePath        : String;


function OutputDebugString(output: String) : string;
begin
  Result := TDdbgOutput.OutputDebugString(output);
end;

constructor TDdbgOutput.create(FilePathName: String);
begin
  if not FileExists(FilePathName) then
     FileClose(FileCreate(FilePathName));
  FStream := TFileStream.Create(FilePathName, fmOpenWrite     or fmShareDenyWrite);
  FStream.Seek(0,soFromEnd);
end;

function TDdbgOutput.DebugOutput(output: String) : string;
var
  o: String;
begin
  Result := '';
  o := #13#10 +TimeToStr(now)+
    ' TID:'+IntToStr(GetCurrentThreadID)+
    ' PID:'+IntToStr(GetCurrentProcessId)+' '+
  output;
  Result := o;
  FStream.Write(o[1],length(o));
end;

destructor TDdbgOutput.Destroy;
begin
  FreeAndNil(FStream);
  inherited;
end;

class function TDdbgOutput.OutputDebugString(output: String) : string;
begin
  Result := '';
  try
    Result := theMainDebugOutput.DebugOutput(output);
  except
    on E: Exception do
    begin
      Result := 'not possible exception occured : ' + e.ClassName+'-->'+e.Message;
    end; // Don'T allow any Exception here!
  end;
end;

initialization
  CreateDir(LogBasePath);
  theMainDebugOutput := TDdbgOutput.create(LogBasePath+'Debug.out');
  theMainDebugOutput.DebugOutput('-------STARTED Application------'#13#10);

finalization
  theMainDebugOutput.DebugOutput('-------ENDED Application------'#13#10);
  FreeAndNil(theMainDebugOutput);
end.
0
 

Author Comment

by:HARMPIER
ID: 8063091
sfock,

I downloaded a version of the JCL and used it as you shown in the previous ExpertExchange query.

But I have some problems when I try to retreive debbuging information i.e. the function MapOfAddr doesn't return any information, the function JCLLastExceptFrameList always return NIL.

I think that I don't set the right compiler or linker option.

Do you know which options I must use ??

Thanks.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
sfock earned 800 total points
ID: 8063307
set
project->options->linker->map-file to detailed
project->options->compiler->otimisation off
project->options->compiler->Debug informations on
project->options->compiler->local symbols on
project->options->compiler->reference info on
project->options->compiler->definitions only off
project->options->compiler->assertion on

i hope i didn't forgot anything ;-)
0
 

Author Comment

by:HARMPIER
ID: 8063377
I forgot to set the right set of options in the jclStackTrackingOptions variable.

Now all works well.

Thanks a lot.

Pierre.
0
 
LVL 3

Expert Comment

by:sfock
ID: 8063401
you're welcome :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question