开源

https://github.com/project-jedi/jcl

 jclDebug

下载jcl,还要下载​​https://github.com/project-jedi/jedi​​里的2个inc文件

放到jcl-master\jcl\source\include\jedi目录里。

运行jcl\install.bat 安装。没有dpk工程文件。


运行bat文件,弹出下面的界面,点install即可。


Delphi JCL JEDI使用 jclDebug_3c


 


like this


http://stackoverflow.com/questions/32881718/installing-jvcl-into-delphi-10-seattle

 Delphi JCL JEDI使用 jclDebug_github_02




 


JclDebug


jcl\source\windows\JclDebug.pas


这包含了个Demo


jcl\examples\windows\debug\stacktrack.dproj


Delphi JCL JEDI使用 jclDebug_ide_03



Delphi JCL JEDI使用 jclDebug_2d_04Delphi JCL JEDI使用 jclDebug_工程文件_05


unit StackTrackDemoMain;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, AppEvnts, ActnList;

type
TMainForm = class(TForm)
ExceptionLogMemo: TMemo;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ListBox1: TListBox;
Button4: TButton;
ApplicationEvents: TApplicationEvents;
Label1: TLabel;
ActionList1: TActionList;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure ApplicationEventsException(Sender: TObject; E: Exception);
private
{ Private declarations }
public
{ Public declarations }
end;

var
MainForm: TMainForm;

implementation

{$R *.DFM}

uses
JclDebug;

{ TMainForm }

//--------------------------------------------------------------------------------------------------
// Simulation of various unhandled exceptions
//--------------------------------------------------------------------------------------------------

procedure TMainForm.Button1Click(Sender: TObject);
begin
PInteger(nil)^ := 0;
end;

procedure TMainForm.Button2Click(Sender: TObject);
begin
ListBox1.Items[1] := 'a';
end;

procedure AAA;
begin
PInteger(nil)^ := 0;
end;

procedure TMainForm.Button3Click(Sender: TObject);
begin
AAA;
end;

procedure TMainForm.Button4Click(Sender: TObject);
begin
ActionList1.Actions[0].Execute;
end;

//--------------------------------------------------------------------------------------------------
// Simple VCL application unhandled exception handler using JclDebug
//--------------------------------------------------------------------------------------------------

procedure TMainForm.ApplicationEventsException(Sender: TObject; E: Exception);
begin
// Log time stamp
ExceptionLogMemo.Lines.Add(DateTimeToStr(Now));

// Log unhandled exception stack info to ExceptionLogMemo
JclLastExceptStackListToStrings(ExceptionLogMemo.Lines, False, True, True, False);

// Insert empty line
ExceptionLogMemo.Lines.Add('');

// Display default VCL unhandled exception dialog
Application.ShowException(E);
end;

//--------------------------------------------------------------------------------------------------
// JclDebug initialization and finalization for VCL application
//--------------------------------------------------------------------------------------------------

initialization

// Enable raw mode (default mode uses stack frames which aren't always generated by the compiler)
Include(JclStackTrackingOptions, stRawMode);
// Disable stack tracking in dynamically loaded modules (it makes stack tracking code a bit faster)
Include(JclStackTrackingOptions, stStaticModuleList);

// Initialize Exception tracking
JclStartExceptionTracking;

finalization

// Uninitialize Exception tracking
JclStopExceptionTracking;

end.

View Code

 

获取当前过程函数的名称

记得把上面的jcl debug的选项打开。

   self.Caption:= JclDebug.GetLocationInfoStr(Caller(1));

http://delphi.wikia.com/wiki/JEDI_Code_Library


Delphi JCL JEDI使用 jclDebug_2d_04Delphi JCL JEDI使用 jclDebug_工程文件_05


unit u_JclDebugTest;

interface

function CurrentFunctionName: string;

type
TSomeClass = class
private
public
constructor Create;
destructor Destroy; override;
procedure Test;
end;

implementation

uses
JclDebug;

{ TSomeClass }

constructor TSomeClass.Create;
begin
WriteLn(CurrentFunctionName);
end;

destructor TSomeClass.Destroy;
begin
WriteLn(CurrentFunctionName);
inherited;
end;

procedure TSomeClass.Test;
begin
WriteLn(CurrentFunctionName);
end;

{$W+}

function CurrentFunctionName: string;
begin
Result := jcldebug.GetLocationInfoStr(Caller(1));
end;

end.


program jcldebugtest;

{$APPTYPE console}

uses
u_JclDebugTest;

procedure SomeProcedure;
begin
WriteLn(CurrentFunctionName);
with TSomeClass.Create do begin
Test;
Free;
end;
end;

begin
WriteLn(CurrentFunctionName);
SomeProcedure;
WriteLn(CurrentFunctionName);
end.

This program will output:

[0042362D] jcldebugtest.jcldebugtest (Line 18, "jcldebugtest.dpr")
[004223A7] jcldebugtest.SomeProcedure (Line 10, "jcldebugtest.dpr")
[0042226C] u_JclDebugTest.TSomeClass.Create (Line 34, "u_JclDebugTest.pas")
[00422352] u_JclDebugTest.TSomeClass.Test (Line 45, "u_JclDebugTest.pas")
[004222E5] u_JclDebugTest.TSomeClass.Destroy (Line 39, "u_JclDebugTest.pas")
[00423651] jcldebugtest.jcldebugtest (Line 20, "jcldebugtest.dpr")

View Code

 http://stackoverflow.com/questions/19450140/combining-log4delphi-and-jcl-debug

http://stackoverflow.com/questions/19496046/get-name-of-the-previous-calling-method