Menu ▾ ▴

#218 Filter Exceptions expert and IOS / Android apps

Closed
closed-fixed
None
5
2020-09-27
2020-09-20
No

Hi thomas,
This is related to the "Filter Exceptions expert and IOS / Android apps" post you wrote on the DP forum.
I'm like you, I don't use ios so I can't do any debugging. But I think (not tested) that below code should fix the issue. Even if it doesn't, I highly recommend to merge it because it fixes a wrong check for GetThreadOsInfo which I THINK is the root of the problem
The reason why I posted here instead of DP is because we need someone that can confirm if it fixed the issue.

type
    // Result type for GetThreadOsInfo is Boolean ! 
    TGetThreadOsInfo = function(Thread: TThread; var Buffer: TThreadOsInfoArray): Boolean;

function GetExceptionObjectNew(Thread: TThread; out _ExceptionInformation: TExceptionInformation): TAddress;
type
  PExceptionInformation = ^TExceptionInformation;
var
  Ok: Boolean;
  Src: TThreadOsInfoArray;
  Parsed: TParsedThreadOsInfoArray;
  P: PByte;
  C: Cardinal;
  PE: PExceptionRecord;
  Params: PExceptionInformation;
  I:Integer;
begin
  // this function should be used only with new delphi versions
  Result := 0;
  ZeroMemory(@Src, SizeOf(Src));
  ZeroMemory(@Parsed, SizeOf(Parsed));
  Ok := GetThreadOsInfo(Thread, Src);
  if Ok then
  begin
    C := PCardinal(@Src[0])^;
    case C of
      4, 6, 8, 7, 9, 10:
        Exit;
    end;
    ParseThreadOsInfo(Thread, Src, Parsed);

    // disasm TNativeThread::DoGetExceptionName
    P := @Parsed[0];
    Inc(P, $A8);
    P := PPointer(P)^;
    PE := PExceptionRecord(Integer(P) + $18);
    C := PE.ExceptionCode;
    Params := Pointer(Integer(P) + $30);
    _ExceptionInformation := Params^;
{$IFOPT D+}
    for I := Low(_ExceptionInformation) to High(_ExceptionInformation) do
      SendDebugWarning('_ExceptionInformation[' + IntToStr(I) + '] = ' + IntToHex(_ExceptionInformation[I], SizeOf(_ExceptionInformation[I]) * 2));
{$ENDIF}
    { !!! don't optimize me !!! }

    if (C <> $0EEDFAE6 { cCppBuilderException } ) then
    begin
      if C = $0EEDFADE { cDelphiException } then
      begin
        Inc(P, $38);
        Result := PUInt64(P)^;
      end
      else if C <> $0EEDFAE4 { cNonDelphiException } then
      begin
        Exit; // ==>
      end
      else
      begin
        Inc(P, $38);
        Result := PUInt64(P)^;
      end;
    end
    else
    begin
      C := PCardinal(Integer(P) + $34)^;
      if C <> 0 then
      begin
        Inc(P, $48);
        Result := PUInt64(P)^;
      end
      else
      begin
        C := PCardinal(Integer(P) + $30)^;
        if C <> 1 then
        begin
          Inc(P, $48);
          Result := PUInt64(P)^;
        end
        else
        begin
          Exit;
        end;
      end;
    end;
  end;
end;

Discussion

  • Thomas Mueller

    Thomas Mueller - 2020-09-27
    • status: open --> closed-fixed
    • assigned_to: Thomas Mueller
    • Group: New --> Closed
     
  • Thomas Mueller

    Thomas Mueller - 2020-09-27

    I have implemented this fix, but we need testers. If you are developing for IOS or Android, please post a comment to the original bug report.

     

Log in to post a comment.