Giter Club home page Giter Club logo

justaddcode's Introduction

Code snippets from Grijjy's "Just Add Code" blog

Here you will find sample code and other tidbits from Grijjy's Just Add Code blog.

Index

justaddcode's People

Contributors

allendrennan avatar erikvanbilsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

justaddcode's Issues

Why not use RaiseExceptObjProc?

Thank you for your work - it really helped.

But there were some questions left (maybe I'm wrong):

  1. Why not use RaiseExceptObjProc? It seems that it is called in all cases of exceptions.
  2. Also, because ExceptProc is redefined by you, System.SysUtils.ExceptHandler will not be called and therefore the process will not be terminated. I don't think this is a good idea ...

[Question] MacOS ARM Code Hooking

Hello team! First, thanks for the samples and articles, always very useful.

I'm not sure about code hooking on Mac ARM. At the time this article was written, no Mac ARM existed. On an Intel Mac the HookCode is used, but on the Mac ARM the correct is HookVMT, as in iOS?

Question Invalid obj-c call

Hello,
great code, just if i click Invalid obj-c call then your app crashes. Do I miss something or must be there something more done to catch that exception?
Thank you

Make TMulticastEvent parallel using TTask.Run

Would it be possible to add an option to TMulticastEvent so it would call handlers in parallel instead of being stuck by them ?
The second benefit would be that handlers would run in parallel as well in place of being queued. So they don't delay and slow down one another.

In TMulticastEvent.Invoke, the FData.Count loop may use TTask.Run in place of simple calls.

Android + Berlin

Got strange linking problems which at a glance looked like they were coming from libmidas.a.

When looking further and changing from msbuild mode to compiling from IDE i saw references regarding __cxa_demangle which got me to think libgnustl_static wasn't linked.

When i added -lgnustl_static to the linker flags in delphi it compiled.

in Grijjy.ErrorReporting.pas we can not get the stacktrace report of a particular exception we catch in try... except end

in Grijjy.ErrorReporting.pas we can not get the stacktrace report of a particular exception we catch in try... except end. I mean their is no way in a try .. except block to do something like MyReport := BuildExceptionReport(...), the only way is to catch the report in the event message. To handle this i updated the function below :

procedure TgoExceptionReporter.ReportException(const AExceptionObject: TObject;
  const AExceptionAddress: Pointer);
var
  E: Exception;
  ExceptionMessage: String;
  CallStack: TgoCallStack;
  ExceptionLocation: TgoCallStackEntry;
  Report: IgoExceptionReport;
  I: Integer;
begin
  { Ignore exception that occur while we are already reporting another
    exception. That can happen when the original exception left the application
    in such a state that other exceptions would happen (cascading errors). }
  if (FReportingException) then
    Exit;

  FReportingException := True;
  try
    CallStack := nil;
    if (AExceptionObject = nil) then
      ExceptionMessage := 'Unknown Error'
    else if (AExceptionObject is Exception) then
    begin
      E := Exception(AExceptionObject);
      ExceptionMessage := E.Message;
      if (E.StackInfo <> nil) then
      begin
        CallStack := GetCallStack(E.StackInfo);
        for I := 0 to Length(Callstack) - 1 do
        begin
          { If entry in call stack is for this module, then try to translate
            the routine name to Pascal. }
          if (CallStack[I].ModuleAddress = FModuleAddress) then
            CallStack[I].RoutineName := goCppSymbolToPascal(CallStack[I].RoutineName);
        end;
      end;
    end
    else
      ExceptionMessage := 'Unknown Error (' + AExceptionObject.ClassName + ')';

    ExceptionLocation.Clear;
    ExceptionLocation.CodeAddress := UIntPtr(AExceptionAddress);
    GetCallStackEntry(ExceptionLocation);
    if (ExceptionLocation.ModuleAddress = FModuleAddress) then
      ExceptionLocation.RoutineName := goCppSymbolToPascal(ExceptionLocation.RoutineName);

    Report := TgoExceptionReport.Create(ExceptionMessage, ExceptionLocation, CallStack);
    try
      TMessageManager.DefaultManager.SendMessage(Self,
        TgoExceptionReportMessage.Create(Report));
    except
      { Ignore any exceptions in the report message handler. }
    end;
  finally
    FReportingException := False;
  end;
end;

and i replace it by this one :

function TgoExceptionReporter.internalBuildExceptionReport(const AExceptionObject: TObject; const AExceptionAddress: Pointer): IgoExceptionReport;
var
  E: Exception;
  ExceptionMessage: String;
  CallStack: TgoCallStack;
  ExceptionLocation: TgoCallStackEntry;
  I: Integer;
begin

  CallStack := nil;
  if (AExceptionObject = nil) then
    ExceptionMessage := 'Unknown Error'
  else if (AExceptionObject is Exception) then
  begin
    E := Exception(AExceptionObject);
    ExceptionMessage := E.Message;
    if (E.StackInfo <> nil) then
    begin
      CallStack := GetCallStack(E.StackInfo);
      for I := 0 to Length(Callstack) - 1 do
      begin
        { If entry in call stack is for this module, then try to translate
          the routine name to Pascal. }
        if (CallStack[I].ModuleAddress = FModuleAddress) then
          CallStack[I].RoutineName := goCppSymbolToPascal(CallStack[I].RoutineName);
      end;
    end;
  end
  else
    ExceptionMessage := 'Unknown Error (' + AExceptionObject.ClassName + ')';

  ExceptionLocation.Clear;
  ExceptionLocation.CodeAddress := UIntPtr(AExceptionAddress);
  GetCallStackEntry(ExceptionLocation);
  if (ExceptionLocation.ModuleAddress = FModuleAddress) then
    ExceptionLocation.RoutineName := goCppSymbolToPascal(ExceptionLocation.RoutineName);

  result := TgoExceptionReport.Create(ExceptionMessage, ExceptionLocation, CallStack);

end;

procedure TgoExceptionReporter.ReportException(const AExceptionObject: TObject;
  const AExceptionAddress: Pointer);
var
  Report: IgoExceptionReport;
begin
  { Ignore exception that occur while we are already reporting another
    exception. That can happen when the original exception left the application
    in such a state that other exceptions would happen (cascading errors). }
  if (FReportingException) then
    Exit;

  FReportingException := True;
  try

    Report := internalBuildExceptionReport(AExceptionObject, AExceptionAddress);
    try
      TMessageManager.DefaultManager.SendMessage(Self,
        TgoExceptionReportMessage.Create(Report));
    except
      { Ignore any exceptions in the report message handler. }
    end;
  finally
    FReportingException := False;
  end;
end;

class function TgoExceptionReporter.BuildExceptionReport(const AExceptionObject: TObject; const AExceptionAddress: Pointer): IgoExceptionReport;
begin
  if Assigned(FInstance) then
    result := FInstance.internalBuildExceptionReport(AExceptionObject, AExceptionAddress)
  else
    result := nil;
end;

Using linker option --version-script=goExports.vsr prevents Delphi 11.3 from debugging

The error report worked like a charm so far. Thank you for the great work.

But in Delphi 11.3, if you set the linker option "Options passed to LD linker" to "--version-script=goExports.vsr", Delphi cannot debug anymore (turns all breakpoints invalid, no step debug, etc).
Should the goExports.vsr file be updated in anyway? Any hints on that?

Facedetection

Using Android emulator
on
Test 3 detects only the right face.
Test 5 detected none
Test 8 added a detection
device-2021-01-15-101210

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.