0
votes

abc.exe is using xyz.dll. While running abc.exe(Delphi), getting an Access Violation as following

Project abc.exe raised exception class EAccessViolation with message 'Access Violation at address 39275E81 in module 'xyz.dll'. Write of address 737A24A4".

For some reason, I am unable to debug xyz.dll(which is also delphi). So I would like to trace the code part in xyz.dll using addresses in above message. How to find that code part ? Are there any other alternatives ?

Thanks in advance.

1

1 Answers

0
votes

There are many third party tools to trace exceptions in source code, or you can make your own. This simple one use JCL debug procs:

procedure AnyExceptionNotify(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean);
var
   ExceptLines: TStringList;
begin
   ExceptLines := TStringList.Create;
   try
      JclLastExceptStackListToStrings(ExceptLines, False, False, True);
      ExceptLines.Insert(0, 'ProcessID: ' + IntToStr(GetCurrentProcessID));
      ExceptLines.Insert(1, 'ThreadID: ' + TThread.CurrentThread.ThreadID.ToString);
      ExceptLines.Insert(2, (ExceptObj as Exception).Message);
      ExceptLines.Insert(3, '[begin_stack_trace]');
      ExceptLines.Append('[end_stack_trace]');
      ExceptLines.SaveToFile('ExceptTrace.txt');
   finally
      ExceptLines.Free;
   end;
end;

initialization
   JclStartExceptionTracking;
   JclAddExceptNotifier(AnyExceptionNotify);

This way you will register any exception in your code and store the call stack of exception into file for further analysis.