Merge pull request #2897 from keymanapp/fix/windows/sentry-cleanups

fix(windows): show error if tsysinfo fails to start; kmcomapi reporting
This commit is contained in:
Marc Durdin 2020-03-27 12:03:00 +11:00 committed by GitHub
commit 9fcfdf81ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 634 additions and 167 deletions

View file

@ -8,7 +8,6 @@ uses
DebugPaths in '..\..\global\delphi\general\DebugPaths.pas',
ErrorControlledRegistry in '..\..\global\delphi\vcl\ErrorControlledRegistry.pas',
VersionInfo in '..\..\global\delphi\general\VersionInfo.pas',
ErrLogPath in '..\..\global\delphi\general\ErrLogPath.pas',
utilsystem in '..\..\global\delphi\general\utilsystem.pas',
utilexecute in '..\..\global\delphi\general\utilexecute.pas',
Unicode in '..\..\global\delphi\general\Unicode.pas',

View file

@ -111,7 +111,6 @@
<DCCReference Include="..\..\global\delphi\general\DebugPaths.pas"/>
<DCCReference Include="..\..\global\delphi\vcl\ErrorControlledRegistry.pas"/>
<DCCReference Include="..\..\global\delphi\general\VersionInfo.pas"/>
<DCCReference Include="..\..\global\delphi\general\ErrLogPath.pas"/>
<DCCReference Include="..\..\global\delphi\general\utilsystem.pas"/>
<DCCReference Include="..\..\global\delphi\general\utilexecute.pas"/>
<DCCReference Include="..\..\global\delphi\general\Unicode.pas"/>

View file

@ -70,7 +70,6 @@ uses
utilcheckfonts in '..\..\global\delphi\general\utilcheckfonts.pas',
wininet5 in '..\..\global\delphi\general\wininet5.pas',
GlobalProxySettings in '..\..\global\delphi\general\GlobalProxySettings.pas',
ErrLogPath in '..\..\global\delphi\general\ErrLogPath.pas',
UFixupMissingFile in '..\..\global\delphi\ui\UFixupMissingFile.pas',
UImportOlderVersionKeyboards in 'main\UImportOlderVersionKeyboards.pas',
UImportOlderKeyboardUtils in 'main\UImportOlderKeyboardUtils.pas',

View file

@ -197,7 +197,6 @@
<DCCReference Include="..\..\global\delphi\general\utilcheckfonts.pas"/>
<DCCReference Include="..\..\global\delphi\general\wininet5.pas"/>
<DCCReference Include="..\..\global\delphi\general\GlobalProxySettings.pas"/>
<DCCReference Include="..\..\global\delphi\general\ErrLogPath.pas"/>
<DCCReference Include="..\..\global\delphi\ui\UFixupMissingFile.pas"/>
<DCCReference Include="main\UImportOlderVersionKeyboards.pas"/>
<DCCReference Include="main\UImportOlderKeyboardUtils.pas"/>

View file

@ -69,9 +69,9 @@ implementation
uses
Winapi.Messages,
ErrLogPath,
GetOsVersion,
IniFiles,
KeymanPaths,
kmpinffile,
Keyman.System.UpgradeRegistryKeys,
KPInstallFontKMShell,
@ -384,7 +384,7 @@ begin
FAdmin := AAdmin; // I2361
for i := 0 to 5 do
try
FLogFile := TFileStream.Create(GetErrLogFileName('keymanimport'), fmCreate); // I2792
FLogFile := TFileStream.Create(TKeymanPaths.ErrorLogPath('keymanimport'), fmCreate); // I2792
Break;
except
on E:EFCreateError do

View file

@ -136,7 +136,6 @@ uses
jwawintype,
bootstrapmain,
errlogpath,
GetOsVersion,
HTTPUploader,
Keyman.System.UpgradeRegistryKeys,
@ -288,7 +287,7 @@ begin
ShowMessageW(msg);
if not Assigned(FErrorLog) then
begin
path := GetErrLogPath + 'setup.log'; // I2314
path := TKeymanPaths.ErrorLogPath + 'setup.log'; // I2314
if SysUtils.FileExists(path) then
begin
@ -636,7 +635,7 @@ begin
{ Log the install to the diag folder }
FLogFileName := GetErrLogFileName(ChangeFileExt(ExtractFileName(FInstallInfo.MSIFileName), '')); // I1610 // I2755 // I2792
FLogFileName := TKeymanPaths.ErrorLogPath(ChangeFileExt(ExtractFileName(FInstallInfo.MSIFileName), '')); // I1610 // I2755 // I2792
//ForceDirectories(GetErrLogPath); // I2768
MsiEnableLogW(INSTALLLOGMODE_VERBOSE, PWideChar(FLogFileName), 0);

View file

@ -25,7 +25,6 @@ uses
UfrmRunDesktop in 'UfrmRunDesktop.pas' {frmRunDesktop},
UfrmInstallOptions in 'UfrmInstallOptions.pas' {frmInstallOptions},
RunTools in 'RunTools.pas',
ErrLogPath in '..\..\global\delphi\general\ErrLogPath.pas',
ShellUserRegistry in '..\..\global\delphi\general\ShellUserRegistry.pas',
RegistryHelpers in 'RegistryHelpers.pas',
ErrorControlledRegistry in '..\..\global\delphi\vcl\ErrorControlledRegistry.pas',

View file

@ -7,7 +7,7 @@
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Console</AppType>
<FrameworkType>VCL</FrameworkType>
<ProjectVersion>18.4</ProjectVersion>
<ProjectVersion>18.8</ProjectVersion>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
@ -122,7 +122,6 @@
<Form>frmInstallOptions</Form>
</DCCReference>
<DCCReference Include="RunTools.pas"/>
<DCCReference Include="..\..\global\delphi\general\ErrLogPath.pas"/>
<DCCReference Include="..\..\global\delphi\general\ShellUserRegistry.pas"/>
<DCCReference Include="RegistryHelpers.pas"/>
<DCCReference Include="..\..\global\delphi\vcl\ErrorControlledRegistry.pas"/>
@ -249,7 +248,6 @@
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>0</Operation>
</Platform>
</DeployClass>
@ -258,6 +256,20 @@
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidFileProvider">
<Platform Name="Android">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidGDBServer">
<Platform Name="Android">
@ -270,90 +282,242 @@
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiv7aFile">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeMipsFile">
<Platform Name="Android">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashImageDef">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStyles">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStylesV21">
<Platform Name="Android">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Colors">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_DefaultAppIcon">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon144">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon24">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage426">
<Platform Name="Android">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage470">
<Platform Name="Android">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage640">
<Platform Name="Android">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage960">
<Platform Name="Android">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Strings">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DebugSymbols">
<Platform Name="iOSSimulator">
@ -371,6 +535,10 @@
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
@ -380,6 +548,10 @@
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
@ -402,6 +574,10 @@
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.bpl</Extensions>
@ -411,6 +587,9 @@
<Platform Name="Android">
<Operation>0</Operation>
</Platform>
<Platform Name="Android64">
<Operation>0</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>0</Operation>
</Platform>
@ -423,6 +602,9 @@
<Platform Name="OSX32">
<Operation>0</Operation>
</Platform>
<Platform Name="OSX64">
<Operation>0</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
@ -438,6 +620,17 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1024x768">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1536">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -449,6 +642,39 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1536x2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1668">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1668x2388">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -460,6 +686,61 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048x1536">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048x2732">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2224">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2388x1668">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2732x2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch768">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -471,6 +752,116 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch768x1024">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1125">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1136x640">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1242">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1242x2688">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1334">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1792">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2208">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2436">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2688x1242">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch320">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
@ -504,10 +895,35 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch750">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch828">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectAndroidManifest">
<Platform Name="Android">
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
@ -533,6 +949,7 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXDebug"/>
<DeployClass Name="ProjectOSXEntitlements"/>
<DeployClass Name="ProjectOSXInfoPList"/>
<DeployClass Name="ProjectOSXResource">
@ -540,12 +957,20 @@
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSX64">
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Required="true" Name="ProjectOutput">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
@ -561,10 +986,19 @@
<Platform Name="OSX32">
<Operation>1</Operation>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectUWPManifest">
<Platform Name="Win32">
<Operation>1</Operation>
@ -600,7 +1034,9 @@
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
</Deployment>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>

View file

@ -167,7 +167,6 @@ uses
wininet5 in '..\..\global\delphi\general\wininet5.pas',
TextFileTemplates in 'main\TextFileTemplates.pas',
GlobalProxySettings in '..\..\global\delphi\general\GlobalProxySettings.pas',
ErrLogPath in '..\..\global\delphi\general\ErrLogPath.pas',
UfrmFontHelper in 'dialogs\UfrmFontHelper.pas' {Form1},
VKeyChars in '..\..\global\delphi\general\VKeyChars.pas',
usp10 in '..\..\global\delphi\general\usp10.pas',

View file

@ -348,7 +348,6 @@
<DCCReference Include="..\..\global\delphi\general\wininet5.pas"/>
<DCCReference Include="main\TextFileTemplates.pas"/>
<DCCReference Include="..\..\global\delphi\general\GlobalProxySettings.pas"/>
<DCCReference Include="..\..\global\delphi\general\ErrLogPath.pas"/>
<DCCReference Include="dialogs\UfrmFontHelper.pas">
<Form>Form1</Form>
</DCCReference>

View file

@ -75,7 +75,6 @@ uses
utilcheckfonts in '..\..\global\delphi\general\utilcheckfonts.pas',
findfonts in '..\..\global\delphi\general\findfonts.pas',
WideStringClass in '..\..\global\delphi\general\WideStringClass.pas',
ErrLogPath in '..\..\global\delphi\general\ErrLogPath.pas',
UFixupMissingFile in '..\..\global\delphi\ui\UFixupMissingFile.pas',
utiluac in '..\..\global\delphi\general\utiluac.pas',
VKeyChars in '..\..\global\delphi\general\VKeyChars.pas',

View file

@ -179,7 +179,6 @@
<DCCReference Include="..\..\global\delphi\general\utilcheckfonts.pas"/>
<DCCReference Include="..\..\global\delphi\general\findfonts.pas"/>
<DCCReference Include="..\..\global\delphi\general\WideStringClass.pas"/>
<DCCReference Include="..\..\global\delphi\general\ErrLogPath.pas"/>
<DCCReference Include="..\..\global\delphi\ui\UFixupMissingFile.pas"/>
<DCCReference Include="..\..\global\delphi\general\utiluac.pas"/>
<DCCReference Include="..\..\global\delphi\general\VKeyChars.pas"/>
@ -307,9 +306,9 @@
<Platform value="Win64">False</Platform>
</Platforms>
<Deployment Version="3">
<DeployFile LocalName="keyman.exe" Configuration="Debug" Class="ProjectOutput">
<DeployFile LocalName="Profiling\AQtimeModule1.aqt" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteName>keyman.exe</RemoteName>
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
@ -319,9 +318,9 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Profiling\AQtimeModule1.aqt" Configuration="Debug" Class="ProjectFile">
<DeployFile LocalName="keyman.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<RemoteName>keyman.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>

View file

@ -90,7 +90,6 @@ implementation
uses
Classes,
ComServ,
errlogpath,
sysutils,
klog,
utilhandleexception;
@ -102,9 +101,6 @@ procedure TKeyman.Initialize;
begin
KL.MethodEnter(Self, 'Initialize', []);
try
// I1642 move GetErrLogPath out of DllMain - causes memory issues later due to COM calls
ForceDirectories(GetErrLogPath);
inherited;
try
@ -122,7 +118,6 @@ begin
on E:Exception do
begin
LogException('TKeyman', E, ExceptAddr);
SysUtils.ShowException(ExceptObject, ExceptAddr);
FInitialized := False;
end;
end;
@ -245,6 +240,7 @@ end;
function TKeyman.Get_AutoApply: WordBool;
begin
if not FInitialized then raise Exception.Create(SErrorUninitialised);
Result := FControl.AutoApply;
end;
@ -252,6 +248,7 @@ procedure TKeyman.Apply;
var
AutoApply: Boolean;
begin
if not FInitialized then raise Exception.Create(SErrorUninitialised);
AutoApply := FControl.AutoApply;
FControl.AutoApply := False;
try
@ -267,6 +264,7 @@ end;
procedure TKeyman.Set_AutoApply(Value: WordBool);
begin
if not FInitialized then raise Exception.Create(SErrorUninitialised);
FControl.AutoApply := Value;
end;

View file

@ -112,7 +112,6 @@ uses
UnicodeBlocks in '..\..\global\delphi\general\UnicodeBlocks.pas' { UnicodeBlock: CoClass},
IntegerArray in '..\..\global\delphi\general\IntegerArray.pas',
KeymanControlMessages in '..\..\global\delphi\general\KeymanControlMessages.pas',
ErrLogPath in '..\..\global\delphi\general\ErrLogPath.pas',
internalinterfaces in 'util\internalinterfaces.pas',
VKeyChars in '..\..\global\delphi\general\VKeyChars.pas',
UserMessages in '..\..\global\delphi\general\UserMessages.pas',

View file

@ -3,7 +3,7 @@
<ProjectGuid>{A20773C5-2124-434E-9F3C-27DC9EBC85EE}</ProjectGuid>
<MainSource>kmcomapi.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Config Condition="'$(Config)'==''">Release</Config>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Library</AppType>
<FrameworkType>VCL</FrameworkType>
@ -110,12 +110,14 @@
<DCC_SYMBOL_PLATFORM>false</DCC_SYMBOL_PLATFORM>
<DCC_UNIT_PLATFORM>false</DCC_UNIT_PLATFORM>
<VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
<DCC_DebugInformation>2</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_MajorVer>1</VerInfo_MajorVer>
<VerInfo_Build>0</VerInfo_Build>
<DCC_DebugInfoInExe>false</DCC_DebugInfoInExe>
<DCC_DebugInformation>2</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_Define>DEBUG;KLOG;$(DCC_Define)</DCC_Define>
@ -251,7 +253,6 @@
</DCCReference>
<DCCReference Include="..\..\global\delphi\general\IntegerArray.pas"/>
<DCCReference Include="..\..\global\delphi\general\KeymanControlMessages.pas"/>
<DCCReference Include="..\..\global\delphi\general\ErrLogPath.pas"/>
<DCCReference Include="util\internalinterfaces.pas"/>
<DCCReference Include="..\..\global\delphi\general\VKeyChars.pas"/>
<DCCReference Include="..\..\global\delphi\general\UserMessages.pas"/>
@ -348,8 +349,8 @@
<VersionInfoKeys Name="Comments">www.greatis.com</VersionInfoKeys>
</VersionInfoKeys>
<Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k250.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp250.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k260.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp260.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality>
<Platforms>

View file

@ -41,7 +41,6 @@ uses
System.Win.Registry,
Winapi.Windows,
errlogpath,
errorcontrolledregistry,
keymancontext,
keymanerrorcodes,
@ -106,7 +105,7 @@ begin
with TStringStream.Create(FLogText, TEncoding.UTF8) do // I4174
try
SaveToFile(GetErrLogFileName('mcompile-'+ChangeFileExt(ExtractFileName(FileName),'')));
SaveToFile(TKeymanPaths.ErrorLogPath('mcompile-'+ChangeFileExt(ExtractFileName(FileName),'')));
finally
Free;
end;
@ -125,7 +124,7 @@ begin
with TStringStream.Create(FLogText, TEncoding.UTF8) do // I4174
try
SaveToFile(GetErrLogFileName('mcompile-d-'+ChangeFileExt(ExtractFileName(FileName),'')));
SaveToFile(TKeymanPaths.ErrorLogPath('mcompile-d-'+ChangeFileExt(ExtractFileName(FileName),'')));
finally
Free;
end;

View file

@ -388,3 +388,4 @@ begin
end;
end.

View file

@ -32,79 +32,78 @@ implementation
uses
System.Classes,
System.JSON,
Winapi.Windows,
ErrLogPath,
KeymanPaths,
JsonUtil,
KLog,
utildir,
VersionInfo;
function ConvertedExceptAddr(ExceptAddr: Pointer): Pointer;
function GetLogicalAddr( Address: Pointer ): Pointer;
const
CODE_OFFSET = $1000;
begin
{
hard-coded $1000 instead of more correct FPImgHdr^.OptionalHeader.BaseOfCode
because there are problems with corrupted header in packed EXEs
BTW Inprise linkers always set code base = $1000 :)
}
if Address <> nil then Result := Pointer(Cardinal(Address)-CODE_OFFSET)
else Result := nil;
end;
function RtlCaptureStackBackTrace(FramesToSkip, FramesToCapture: DWORD; BackTrace: Pointer; BackTraceHash: PDWORD): WORD; stdcall; external 'ntdll.dll';
//
// Capture a stack trace and include the offending crash address at the top of
// the trace. Apart from skipping frames and the inclusion of TopAddr, this is
// very similar to sentry_event_value_add_stacktrace.
//
function CaptureStackTrace(TopAddr: Pointer; FramesToSkip: DWORD): TJSONArray;
var
Info: TMemoryBasicInformation;
walked_backtrace: array[0..255] of Pointer;
frameCount: Word;
i: Integer;
begin
VirtualQuery(ExceptAddr, Info, sizeof(Info));
if Info.State <> MEM_COMMIT then
Result := GetLogicalAddr(ExceptAddr)
else
Result := GetLogicalAddr( Pointer(Integer(ExceptAddr)-Integer(Info.AllocationBase)) );
Result := TJSONArray.Create;
frameCount := RtlCaptureStackBackTrace(FramesToSkip, 256, @walked_backtrace[0], nil);
if frameCount = 0 then
Exit;
for i := Integer(frameCount) - 1 downto 0 do
Result.Add(Format('0x%x', [NativeUInt(walked_backtrace[i])]));
// Insert the except address at the top of the stack
if TopAddr <> nil then
Result.Add(Format('0x%x', [NativeUInt(TopAddr)]));
end;
procedure LogException(const SourceClassName: string; E: Exception; ExceptAddr: Pointer);
{$IFDEF CPUX64}
const
Size = 1024;
var
msg, errlogfile: string;
errlog: TStringList;
errlogfile: string;
stack: TJSONArray;
o: TJSONObject;
Buffer: array[0..Size-1] of Char;
begin
stack := CaptureStackTrace(ExceptAddr, 0);
errlog := TStringList.Create;
try
if E = nil
then msg := Format('Exception in %s at %p', [SourceClassName, ConvertedExceptAddr(ExceptAddr)])
else msg := Format('Exception in %s at %p (%s): %s', [SourceClassName, ConvertedExceptAddr(ExceptAddr), E.ClassName, (E as Exception).Message]);
KL.LogError(msg);
errlogfile := TKeymanPaths.ErrorLogPath('kmcomapi'); // I2824
errlog := TStringList.Create;
o := TJSONObject.Create;
o.AddPair('sourceClassName', SourceClassName);
o.AddPair('exception', E.ClassName);
if ExceptionErrorMessage(E, ExceptAddr, Buffer, Size) > 0
then o.AddPair('message', Buffer)
else o.AddPair('message', E.Message);
o.AddPair('stack', stack);
PrettyPrintJSON(o, errlog, 2);
with TStringStream.Create(errlog.Text, TEncoding.UTF8) do
try
errlogfile := GetErrLogFileName('kmcomapi'); // I2824
errlog.Text :=
'Crash Identifier: kmcomapi.dll_'+GetVersionString+'_'+IntToHex(Integer(ExceptAddr),8)+#13#10#13#10+
'KMCOMAPI EXCEPTION AT '+FormatDateTime('yyyy-mm-dd hh:nn:ss', Now) + #13#10 +
'kmcomapi.dll version ' + GetVersionString + #13#10 +
msg + #13#10#13#10;
if FileExists(errlogfile) then
with TStringList.Create do
try
LoadFromFile(errlogfile); // use prolog encoding
errlog.Text := Text + errlog.Text;
finally
Free;
end;
errlog.SaveToFile(errlogfile, TEncoding.UTF8); // I3337
// Use TStringStream to avoid BOM from TStringList
SaveToFile(errlogfile);
finally
errlog.Free;
Free;
end;
except
;
finally
errlog.Free;
end;
{$ELSE}
begin
{$MESSAGE HINT 'TODO: Write a raw call stack to diag folder which can then be sucked in by client app and reported'}
{$ENDIF}
end;
procedure LogException(E: Exception);

View file

@ -66,7 +66,6 @@ type
implementation
uses
ErrLogPath,
GlobalProxySettings,
Math,
UfrmProgress,

View file

@ -105,7 +105,7 @@ implementation
uses
// keymanstrings,
ErrLogPath, ActiveX, ComObj,
KeymanPaths, ActiveX, ComObj,
ErrorControlledRegistry, RegistryKeys,
shlobj,
UframeAttachedFiles,
@ -234,7 +234,7 @@ var
m: Integer;
begin
FSIList.Files.Clear;
FPath := GetErrLogPath;
FPath := TKeymanPaths.ErrorLogPath;
if FindFirst(FPath + '*', 0, f) = 0 then
begin
i := 0;

View file

@ -26,7 +26,6 @@ uses
DebugPaths in '..\..\global\delphi\general\DebugPaths.pas',
GetOsVersion in '..\..\global\delphi\general\GetOsVersion.pas',
GlobalProxySettings in '..\..\global\delphi\general\GlobalProxySettings.pas',
ErrLogPath in '..\..\global\delphi\general\ErrLogPath.pas',
klog in '..\..\global\delphi\general\klog.pas',
utildir in '..\..\global\delphi\general\utildir.pas',
utilsystem in '..\..\global\delphi\general\utilsystem.pas',

View file

@ -170,7 +170,6 @@
<DCCReference Include="..\..\global\delphi\general\DebugPaths.pas"/>
<DCCReference Include="..\..\global\delphi\general\GetOsVersion.pas"/>
<DCCReference Include="..\..\global\delphi\general\GlobalProxySettings.pas"/>
<DCCReference Include="..\..\global\delphi\general\ErrLogPath.pas"/>
<DCCReference Include="..\..\global\delphi\general\klog.pas"/>
<DCCReference Include="..\..\global\delphi\general\utildir.pas"/>
<DCCReference Include="..\..\global\delphi\general\utilsystem.pas"/>

View file

@ -36,7 +36,13 @@ type
TSentryClientEventType = (scetException, scetMessage);
TSentryClientEventAction = (sceaContinue, sceaTerminate);
TSentryClientEvent = procedure(Sender: TObject; EventType: TSentryClientEventType;
TSentryClientBeforeEvent = procedure(Sender: TObject; EventType: TSentryClientEventType;
event: sentry_value_t;
const EventClassName, Message: string;
var EventAction: TSentryClientEventAction) of object;
TSentryClientAfterEvent = procedure(Sender: TObject; EventType: TSentryClientEventType;
const EventID, EventClassName, Message: string;
var EventAction: TSentryClientEventAction) of object;
@ -46,11 +52,12 @@ type
FInstance: TSentryClient;
private
options: psentry_options_t;
FOnBeforeEvent: TSentryClientEvent;
FOnAfterEvent: TSentryClientEvent;
FOnBeforeEvent: TSentryClientBeforeEvent;
FOnAfterEvent: TSentryClientAfterEvent;
procedure DoAfterEvent(const EventID, ExceptionClassName, Message: string;
EventType: TSentryClientEventType);
procedure DoBeforeEvent(const EventID, ExceptionClassName, Message: string;
procedure DoBeforeEvent(event: sentry_value_t;
const ExceptionClassName, Message: string;
EventType: TSentryClientEventType);
procedure DoTerminate;
function EventIDToString(Guid: TGUID): string;
@ -61,8 +68,8 @@ type
function MessageEvent(Level: TSentryLevel; const Logger, Message: string; IncludeStack: Boolean = False): TGUID;
function ExceptionEvent(const ExceptionClassName, Message: string; AExceptAddr: Pointer = nil): TGUID;
property OnBeforeEvent: TSentryClientEvent read FOnBeforeEvent write FOnBeforeEvent;
property OnAfterEvent: TSentryClientEvent read FOnAfterEvent write FOnAfterEvent;
property OnBeforeEvent: TSentryClientBeforeEvent read FOnBeforeEvent write FOnBeforeEvent;
property OnAfterEvent: TSentryClientAfterEvent read FOnAfterEvent write FOnAfterEvent;
end;
TSentryClientClass = class of TSentryClient;
@ -222,7 +229,8 @@ begin
ExitProcess(1);
end;
procedure TSentryClient.DoBeforeEvent(const EventID, ExceptionClassName, Message: string;
procedure TSentryClient.DoBeforeEvent(event: sentry_value_t;
const ExceptionClassName, Message: string;
EventType: TSentryClientEventType);
var
EventAction: TSentryClientEventAction;
@ -230,7 +238,7 @@ begin
if Assigned(FOnBeforeEvent) then
begin
EventAction := sceaContinue;
FOnBeforeEvent(Self, EventType, EventID, ExceptionClassName, Message, EventAction);
FOnBeforeEvent(Self, EventType, event, ExceptionClassName, Message, EventAction);
if EventAction = sceaTerminate then
DoTerminate;
end;
@ -275,16 +283,16 @@ const
// A pseudo-frame is inserted at the top of the stack which points
// to the address of the code that caused the exception
begin
DoBeforeEvent('', ExceptionClassName, Message, scetException);
event := sentry_value_new_event;
DoBeforeEvent(event, ExceptionClassName, Message, scetException);
(*
When we set exception information, the report is corrupted. Not sure why. So
for now we won't create as an exception event. We still get all the information
we want from this.
Investigating this further.
Investigating this further at https://forum.sentry.io/t/corrupted-display-when-exception-data-is-set-using-native-sdk/9167/2
exc := sentry_value_new_object;
sentry_value_set_by_key(exc, 'type', sentry_value_new_string(PAnsiChar(UTF8Encode(ExceptionClassName))));
@ -317,14 +325,14 @@ const
// Sentry.Client.CaptureStackTrace,
// Sentry.Client.TSentryClient.MessageEvent
begin
DoBeforeEvent('', Logger, Message, scetMessage);
event := sentry_value_new_message_event(
{* level *} sentry_level_t(Level),
{* logger *} PAnsiChar(UTF8Encode(Logger)),
{* message *} PAnsiChar(UTF8Encode(Message))
);
DoBeforeEvent(event, Logger, Message, scetMessage);
if IncludeStack then
begin
threads := CaptureStackTrace(nil, FRAMES_TO_SKIP);

View file

@ -81,7 +81,7 @@ uses
Accctrl,
AclApi,
ErrorControlledRegistry,
ErrLogPath,
KeymanPaths,
RegistryKeys,
Unicode;
@ -237,7 +237,7 @@ const
function TDebugLogManager.DebugLogFileName(n: Integer): string;
begin
Result := GetErrLogPath + 'system' + IntToStr(n) + '.etl';
Result := TKeymanPaths.ErrorLogPath + 'system' + IntToStr(n) + '.etl';
end;
procedure TDebugLogManager.FindFirstLogFileName;

View file

@ -1,48 +0,0 @@
(*
Name: ErrLogPath
Copyright: Copyright (C) SIL International.
Documentation:
Description:
Create Date: 28 Jul 2008
Modified Date: 26 Jun 2012
Authors: mcdurdin
Related Files:
Dependencies:
Bugs:
Todo:
Notes:
History: 28 Jul 2008 - mcdurdin - I1574 - Initial version
18 Mar 2011 - mcdurdin - I2768 - Fix crash in installer when Diag folder does not exist
18 Mar 2011 - mcdurdin - I2824 - Consolidate logging of diagnostics to Diag folder in appdata
26 Jun 2012 - mcdurdin - I3379 - KM9 - Remove old Winapi references now in Delphi libraries
*)
unit ErrLogPath;
interface
function GetErrLogPath: string;
function GetErrLogFileName(app: string): string;
implementation
uses
Winapi.ShlObj,
Winapi.Windows,
System.SysUtils,
RegistryKeys,
utilsystem;
function GetErrLogPath: string;
begin
Result := GetFolderPath(CSIDL_LOCAL_APPDATA) + SFolderKeymanEngineDiag + '\';
ForceDirectories(Result); // I2768
end;
function GetErrLogFileName(app: string): string; // I2824
begin
Result := GetErrLogPath + app + '-' + IntToStr(GetCurrentProcessId) + '-' + FormatDateTime('yyyy-mm-dd-hh-nn-ss', Now) + '.log';
end;
end.

View file

@ -19,6 +19,7 @@ type
const EventID, EventClassName, Message: string;
var EventAction: TSentryClientEventAction);
constructor Create(SentryClientClass: TSentryClientClass; AProject: TKeymanSentryClientProject; AFlags: TKeymanSentryClientFlags);
procedure ReportRemoteErrors(const childEventID: string);
public
destructor Destroy; override;
class procedure Start(SentryClientClass: TSentryClientClass; AProject: TKeymanSentryClientProject; AFlags: TKeymanSentryClientFlags = [kscfCaptureExceptions, kscfShowUI, kscfTerminate]);
@ -31,13 +32,18 @@ type
implementation
uses
sentry,
System.Classes,
System.Generics.Collections,
System.JSON,
System.SysUtils,
{$IF NOT DEFINED(CONSOLE)}
System.UITypes,
Vcl.Dialogs,
Vcl.Forms,
{$ENDIF}
sentry,
KeymanPaths,
KeymanVersion,
utilexecute;
@ -83,14 +89,18 @@ var
begin
if EventType = scetException then
begin
// We need to look for a kmcomapi errlog and report that
ReportRemoteErrors(EventID);
if kscfShowUI in FFlags then
begin
{$IF DEFINED(CONSOLE)}
// Write to console
writeln('Fatal error '+EventClassName+': '+Message);
writeln;
writeln(ErrOutput, 'Fatal error '+EventClassName+': '+Message);
writeln(ErrOutput, 'This error has been automatically reported to the Keyman team.');
writeln(ErrOutput);
{$ELSE}
// Launch external gui exception handler.
// Launch external gui exception dialog app.
// Usage: tsysinfo -c <crashid> <appname> <appid> [sentryprojectname [classname [message]]]
AppID := LowerCase(ChangeFileExt(ExtractFileName(ParamStr(0)), ''))+'-'+CKeymanVersionInfo.VersionWithTag;
if Assigned(Application)
@ -114,13 +124,9 @@ begin
if not TUtilExecute.Shell(0, TKeymanPaths.KeymanEngineInstallPath('tsysinfo.exe'), // I3349
TKeymanPaths.KeymanEngineInstallPath(''), CommandLine) then
begin
{$MESSAGE HINT 'Show a message before aborting here?'}
{MessageDlg(Application.Title+' has had a fatal error. An additional error was encountered starting the exception manager ('+SysErrorMessage(GetLastError)+'). '+
#13#10'Error log is stored in '#13#10#13#10+' '+FLogFile+#13#10#13#10+
message+#13#10+
detail+#13#10+
'Please send this information to Keyman Support',
mtError, [mbOK], 0);}
MessageDlg(Application.Title+' has had a fatal error. An additional error was encountered '+
'starting the exception manager ('+SysErrorMessage(GetLastError)+'). '+
'This error has been automatically reported to the Keyman team.', mtError, [mbOK], 0);
end;
{$ENDIF}
end;
@ -130,6 +136,78 @@ begin
end;
end;
procedure TKeymanSentryClient.ReportRemoteErrors(const childEventID: string);
var
errlogfile: string;
o: TJSONObject;
event: sentry_value_t;
stack: TJSONArray;
i: Integer;
frames: sentry_value_t;
stacktrace: sentry_value_t;
threads: sentry_value_t;
thread: sentry_value_t;
frame: sentry_value_t;
begin
errlogfile := TKeymanPaths.ErrorLogPath('kmcomapi'); // I2824
if FileExists(errlogfile) then
begin
// We'll use the Sentry API directly here to construct a crash report from
// kmcomapi.
with TStringStream.Create('', TEncoding.UTF8) do
try
LoadFromFile(errlogfile);
o := TJSONObject.ParseJSONValue(DataString) as TJSONObject;
finally
Free;
end;
DeleteFile(errlogfile);
(*
When we set exception information, the report is corrupted. Not sure why. So
for now we won't create as an exception event. We still get all the information
we want from this.
Investigating this further at https://forum.sentry.io/t/corrupted-display-when-exception-data-is-set-using-native-sdk/9167/2
exc := sentry_value_new_object;
sentry_value_set_by_key(exc, 'type', sentry_value_new_string(PAnsiChar(UTF8Encode(ExceptionClassName))));
sentry_value_set_by_key(exc, 'value', sentry_value_new_string(PAnsiChar(UTF8Encode(Message))));
sentry_value_set_by_key(event, 'exception', exc);
*)
event := sentry_value_new_event;
sentry_value_set_by_key(event, 'message', sentry_value_new_string(PAnsiChar(UTF8Encode(o.Values['message'].Value))));
// Construct the stack trace
stack := o.Values['stack'] as TJSONArray;
frames := sentry_value_new_list;
for i := 0 to stack.Count - 1 do
begin
frame := sentry_value_new_object;
sentry_value_set_by_key(frame, 'instruction_addr', sentry_value_new_string(PAnsiChar(AnsiString(stack.Items[i].Value))));
sentry_value_append(frames, frame);
end;
stacktrace := sentry_value_new_object;
sentry_value_set_by_key(stacktrace, 'frames', frames);
threads := sentry_value_new_list;
thread := sentry_value_new_object;
sentry_value_set_by_key(thread, 'stacktrace', stacktrace);
sentry_value_append(threads, thread);
sentry_value_set_by_key(event, 'threads', threads);
sentry_set_extra('child_event', sentry_value_new_string(PAnsiChar(AnsiString(childEventID))));
sentry_capture_event(event);
end;
end;
constructor TKeymanSentryClient.Create(SentryClientClass: TSentryClientClass; AProject: TKeymanSentryClientProject; AFlags: TKeymanSentryClientFlags);
var
o: TSentryClientOptions;

View file

@ -25,6 +25,7 @@ type
const S_FallbackKeyboardPath = 'Keyboards\';
const S__Package = '_Package\';
const S_MCompileExe = 'mcompile.exe';
class function ErrorLogPath(const app: string = ''): string; static;
class function KeymanDesktopInstallPath(const filename: string = ''): string; static;
class function KeymanEngineInstallPath(const filename: string = ''): string; static;
class function KeymanDesktopInstallDir: string; static;
@ -290,4 +291,12 @@ begin
Result := Result + Filename;
end;
class function TKeymanPaths.ErrorLogPath(const app: string): string;
begin
Result := GetFolderPath(CSIDL_LOCAL_APPDATA) + SFolderKeymanEngineDiag + '\';
ForceDirectories(Result); // I2768
if app <> '' then
Result := Result + app + '-' + IntToStr(GetCurrentProcessId) + '.log';
end;
end.

View file

@ -86,7 +86,7 @@ void keyman_sentry_report_exception(DWORD ExceptionCode, PVOID ExceptionAddress)
for now we won't create as an exception event. We still get all the information
we want from this.
Investigating this further.
Investigating this further at https://forum.sentry.io/t/corrupted-display-when-exception-data-is-set-using-native-sdk/9167/2
sentry_value_t exc = sentry_value_new_object();
sentry_value_set_by_key(exc, "type", sentry_value_new_string("Exception"));