JclDebug不包括行号

时间:2016-09-12 16:27:04

标签: delphi

我最近刚刚从Delphi 7升级到Delphi 10.1 Berlin并安装了jedi vcl 2.8。无法安装32位(未找到bcc32.exe)但64位成功但这是另一个问题。

我正在使用jclDebug捕获错误消息,我正在使用它:https://blog.gurock.com/working-with-delphis-new-exception-stacktrace

unit StackTrace;

interface

uses
SysUtils, Classes, JclDebug;

implementation

function GetExceptionStackInfoProc(P: PExceptionRecord): Pointer;
var
  LLines: TStringList;
  LText: String;
  LResult: PChar;
begin
  LLines := TStringList.Create;
  try
    JclLastExceptStackListToStrings(LLines, True, True, True, True);
    LText := LLines.Text;
    LResult := StrAlloc(Length(LText));
    StrCopy(LResult, PChar(LText));
    Result := LResult;
  finally
    LLines.Free;
  end;
end;

function GetStackInfoStringProc(Info: Pointer): string;
begin
  Result := string(PChar(Info));
end;

procedure CleanUpStackInfoProc(Info: Pointer);
begin
  StrDispose(PChar(Info));
end;

initialization
// Start the Jcl exception tracking and register our Exception
// stack trace provider.
if JclStartExceptionTracking then
begin
  Exception.GetExceptionStackInfoProc := GetExceptionStackInfoProc;
  Exception.GetStackInfoStringProc := GetStackInfoStringProc;
  Exception.CleanUpStackInfoProc := CleanUpStackInfoProc;
  JCLdebug.JclStackTrackingOptions:=[stStack, stRawMode]; // I added this hoping it would help.
end;

finalization
// Stop Jcl exception tracking and unregister our provider.
if JclExceptionTrackingActive then
begin
  Exception.GetExceptionStackInfoProc := nil;
  Exception.GetStackInfoStringProc := nil;
  Exception.CleanUpStackInfoProc := nil;
  JclStopExceptionTracking;
end;
end.

当我捕获异常时,我将其记录到此方法

procedure TLoggerForDynacViews.Log(sLog:wideString; ExceptObj:TObject = nil; displayErrorCaught : Boolean = true);
        var myFile: TextFile;
        sFile : String;
        StrList: TStringList;
        companyId : String;
    begin

      try
        sFile := Globals.LogFileName;
        try
          companyId := Store.CompanyId;
        except
          companyId := 'N/A';
        end;
        try

          AssignFile(myFile, sFile);
          if (FileExists(sFile)) then
            Append(myFile)
          else
            Rewrite(myFile);

          WriteLn(myFile, companyId + ' ('+ExcelApp.Caption +')');
          if (ExceptObj <> nil) then begin
            try
              StrList := TStringList.Create;
              StrList.Add(Format('{ Original Exception - %s }', [Exception(ExceptObj).Message]));
              StrList.Add(Exception(ExceptObj).StackTrace);
              StrList.Add('{ _______End of the exception stact trace block_______ }');
              StrList.Add(' ');
              if displayErrorCaught then
                ShowMessage('Error has been caught.  See DynacViews->About->Log File for details.');
              WriteLn(myFile, FormatDateTime('c',Now) + ' - ' + StrList.Text);
              Exit;
            finally
              StrList.Free;
            end;
          end;


          WriteLn(myFile, FormatDateTime('c',Now) + ' - ' + sLog);
        finally
          CloseFile(myFile);
        end;
      except

      end;
    end;

但我没有得到行号。在Delphi 7中,我得到了非常有用的输出,但是使用最新的delphi和jcldebug,我得到了很多帮助,但并没有尽可能有用。

12/09/2016 11:59:55 AM - { Original Exception - Access violation at address  0000000012D60027 in module 'DynacViews2b.dll'. Read of address 000000000000002A  }
(00000000006F1E1D){DynacViews2b.dll} [0000000012E62E1D]  JclDebug._ZN8Jcldebug17TJclStackInfoListC3EbiPvbS1_S1_ + $10D
(00000000006F19F8){DynacViews2b.dll} [0000000012E629F8]   JclDebug._ZN8Jcldebug18JclCreateStackListEbiPvbS0_ + $48
(00000000006F1909){DynacViews2b.dll} [0000000012E62909] JclDebug._ZN8Jcldebug21DoExceptionStackTraceEPN6System7TObjectEPvbS3_ + $79
(00000000006F3233){DynacViews2b.dll} [0000000012E64233] JclDebug._ZN8Jcldebug14DoExceptNotifyEPN6System7TObjectEPvbS3_ + $93
(00000000006E4B85){DynacViews2b.dll} [0000000012E55B85] JclHookExcept._ZN13Jclhookexcept13TNotifierItem8DoNotifyEPN6System7TObjectEPvbS4_ + $35
(00000000006E4DCC){DynacViews2b.dll} [0000000012E55DCC] JclHookExcept._ZN13Jclhookexcept14DoExceptNotifyEPN6System7TObjectEPvbS3_ + $BC
(00000000006E4F1E){DynacViews2b.dll} [0000000012E55F1E] JclHookExcept._ZN13Jclhookexcept20HookedRaiseExceptionEjjjPNS_19TExceptionArgumentsE + $6E
(000000000000EBB6){DynacViews2b.dll} [000000001277FBB6] System._ZN6System14_RaiseAtExceptEPNS_7TObjectEPv + $106
(000000000000EBE1){DynacViews2b.dll} [000000001277FBE1] System._ZN6System12_RaiseExceptEPNS_7TObjectE + $11
(0000000000166164){DynacViews2b.dll} [00000000128D7164] System.Win.ComObj._ZN6System3Win6Comobj19DispatchInvokeErrorEiRK12tagEXCEPINFO + $C4
(0000000000165BA5){DynacViews2b.dll} [00000000128D6BA5] System.Win.ComObj._ZN6System3Win6Comobj14DispatchInvokeENS_15DelphiInterfaceI9IDispatchEEPNS_9TCallDescEPNS_11StaticArrayIiLi65536EEEPvPNS_7VariantE + $275
(0000000000166087){DynacViews2b.dll} [00000000128D7087] System.Win.ComObj._ZN6System3Win6Comobj13VarDispInvokeEPNS_7VariantERKS2_PNS_9TCallDescEPv + $B7
(000000000005162E){DynacViews2b.dll} [00000000127C262E] System.Variants._ZN6System8Variants14DispInvokeCoreEP8TVarDataRKS1_PNS_9TCallDescEPv + $BE
(0000000000051731){DynacViews2b.dll} [00000000127C2731] System.Variants._ZN6System8Variants11_DispInvokeEP8TVarDataRKS1_PNS_9TCallDescE + $41
(000000000071A595){DynacViews2b.dll} [0000000012E8B595] ExcelWrapperTypes._ZN17Excelwrappertypes25TCustomDocumentProperties8GetValueEN6System13UnicodeStringERKNS1_7VariantE + $75
(000000000071A7D8){DynacViews2b.dll} [0000000012E8B7D8] ExcelWrapperTypes._ZN17Excelwrappertypes25TCustomDocumentProperties9GetStringEN6System13UnicodeStringES2_ + $78
(0000000000692BFF){DynacViews2b.dll} [0000000012E03BFF] StoreClasses._ZN12Storeclasses8TStorage23loadCustomDocumentPropsEN6System15DelphiInterfaceIN12Excelwrapper9IWorkbookEEE + $72F
(0000000000720329){DynacViews2b.dll} [0000000012E91329] DynacViewForBook._ZN16Dynacviewforbook17TDynacViewForBook14GetViewForBookEN6System15DelphiInterfaceIN9Excel20009_WorkbookEEEb + $69
(0000000000728978){DynacViews2b.dll} [0000000012E99978] AddinMenu._ZN9Addinmenu20TColumnTemplatesMenuC3EPN8Adxaddin19TadxCommandBarPopupEU9__closurePFvN6System13UnicodeStringEE + $E8
(000000000072867A){DynacViews2b.dll} [0000000012E9967A] AddinMenu._ZN9Addinmenu11TColumnMenuC3EPN8Adxaddin15TadxContextMenuEU9__closurePFvN6System13UnicodeStringEE + $13A
(00000000007258DE){DynacViews2b.dll} [0000000012E968DE] AddinMenu._ZN9Addinmenu11TDynacMenus9BuildMenuEU9__closurePFvN6System13UnicodeStringEE + $9E
(000000000075CB3C){DynacViews2b.dll} [0000000012ECDB3C] DynacViewBook._ZN13Dynacviewbook14TDynacViewBook13BuildMainMenuEv + $8C
(0000000000740B02){DynacViews2b.dll} [0000000012EB1B02] DynacViewBook._ZN13Dynacviewbook14TDynacViewBook18OnWorkbookActivateEv + $6F2
(00000000007CE499){DynacViews2b.dll} [0000000012F3F499] DynacViews2b_IMPL._ZN17Dynacviews2b_impl12TAddInModule18OnWorkbookActivateEPN6System7TObjectENS1_15DelphiInterfaceIN9Excel20009_WorkbookEEE + $49
(00000000005A79DA){DynacViews2b.dll} [0000000012D189DA] adxHostAppEvents._ZN16Adxhostappevents18TadxExcelAppEvents11InvokeEventEiRN6System12DynamicArrayINS1_10OleVariantEEE + $A2A
(00000000005A0CC1){DynacViews2b.dll} [0000000012D11CC1] adxHostAppEvents._ZN16Adxhostappevents17TadxEventDispatch6InvokeEiRK5_GUIDitPvS4_S4_S4_ + $151
(00000000002CE49D){EXCEL.EXE   } [000000013F9EF49D] Unknown function at  + $2CF49D
(00000000002CE2E6){EXCEL.EXE   } [000000013F9EF2E6] Unknown function at  + $2CF2E6
(000000000017BA40){EXCEL.EXE   } [000000013F89CA40] Unknown function at  + $17CA40
(0000000000120138){EXCEL.EXE   } [000000013F841138] Unknown function at  + $121138
(000000000011FB65){EXCEL.EXE   } [000000013F840B65] Unknown function at  + $120B65
(000000000011F95F){EXCEL.EXE   } [000000013F84095F] Unknown function at  + $12095F
(0000000000129B75){EXCEL.EXE   } [000000013F84AB75] Unknown function at  + $12AB75
(00000000000E0BD0){EXCEL.EXE   } [000000013F801BD0] Unknown function at  + $E1BD0
(000000000006B44A){EXCEL.EXE   } [000000013F78C44A] Unknown function at  + $6C44A
(0000000000EB6035){EXCEL.EXE   } [00000001405D7035] Unknown function at LinkASPPModelTable + $3F60E5
(0000000000BA53BD){EXCEL.EXE   } [00000001402C63BD] Unknown function at LinkASPPModelTable + $E546D
(00000000000587D5){EXCEL.EXE   } [000000013F7797D5] Unknown function at  + $597D5
(00000000000BE448){EXCEL.EXE   } [000000013F7DF448] Unknown function at  + $BF448
(0000000000019484){EXCEL.EXE   } [000000013F73A484] Unknown function at  + $1A484
(00000000000F1D01){EXCEL.EXE   } [000000013F812D01] Unknown function at  + $F2D01
(00000000000149BD){kernel32.dll} [00000000779E59BD] BaseThreadInitThunk + $D
(00000000000292E1){ntdll.dll   } [0000000077C1A2E1] RtlUserThreadStart + $21

虽然以上内容很有帮助但我真的很想念行号。

对于我的项目,Debug Information为true,包含远程调试符号。我不确定需要设置哪些属性。

编辑问题似乎是由于我的地图文件中没有行号。 我的delphi 7地图文件有很多:

Line numbers for DynacViewBook(DynacViewBook.pas) segment .text

但是我的Delphi 10.1地图文件中没有这些。

以下是我关联delphi linker options

的选项

1 个答案:

答案 0 :(得分:2)

所以我终于明白了。当我从Delphi 7迁移到Delphi 10.1时,部分问题是我无法确保正确传输我的编译和链接选项。我假设设置是正确的。

我缺少链接信息的原因是我需要在编译选项使用Debug .DCU的中查看我自己的pas文件和本地符号以查看delphi pas文件以及调试信息

我必须删除我的.dcu并在出现行信息之前重新编译。

编辑:奇怪的是映射文件包含名称

DynacViewBook.TDynacViewBook.OnWorkbookActivate

DynacViewBook.$pdata$_ZN13Dynacviewbook14TDynacViewBook18OnWorkbookActivateEv

StackTrace包含丑陋的方法而不是漂亮的方法名称。我的delphi 7地图文件不包含任何丑陋的名称。

即使是delphi调试信息也是丑陋的名字。必须是一个设置。