diff options
author | therzok <marius.ungureanu@xamarin.com> | 2019-10-23 00:24:07 +0300 |
---|---|---|
committer | therzok <marius.ungureanu@xamarin.com> | 2019-10-23 00:24:07 +0300 |
commit | dc4ad691d58fa720e3a65ba04b478c1a6447cad3 (patch) | |
tree | 2add4933f8a14f01480efcbb1848ce152a393f68 | |
parent | e0ac3c6b3b1bb70703d280b75b475913f6dce778 (diff) |
Add example of how to crash from a pinvoke
3 files changed, 21 insertions, 0 deletions
diff --git a/main/build/MacOSX/monostub.mm b/main/build/MacOSX/monostub.mm index f42dd641aa..c99e2cbb8c 100644 --- a/main/build/MacOSX/monostub.mm +++ b/main/build/MacOSX/monostub.mm @@ -227,6 +227,12 @@ load_xammac() } } +extern "C" void crash_me() +{ + void *p = (void*)0x12345; + *(int *)p = 0; +} + int main (int argc, char **argv) { diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs index 54dee68d2b..4c13ba143b 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs @@ -201,5 +201,16 @@ namespace PerformanceDiagnosticsAddIn Thread.Sleep (TimeSpan.FromMinutes(2)); } } + + class InduceNativePInvokeCrashHandler : CommandHandler + { + [DllImport ("__Internal")] + static extern void crash_me (); + + protected override void Run () + { + crash_me (); + } + } #endif } diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/ReliabilityDiagnostics.addin.xml b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/ReliabilityDiagnostics.addin.xml index 8b4b3f04c2..8d5063e822 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/ReliabilityDiagnostics.addin.xml +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/ReliabilityDiagnostics.addin.xml @@ -15,6 +15,9 @@ <Command id="PerformanceDiagnosticsAddIn.InduceHang" defaultHandler="PerformanceDiagnosticsAddIn.InduceHangHandler" _label="Induce Hang" /> + <Command id="PerformanceDiagnosticsAddIn.InduceNativePInvokeCrash" + defaultHandler="PerformanceDiagnosticsAddIn.InduceNativePInvokeCrashHandler" + _label="Induce PInvoke Crash" /> </Extension> <Extension path="/MonoDevelop/Ide/MainMenu/Help"> @@ -24,6 +27,7 @@ <CommandItem id="PerformanceDiagnosticsAddIn.InduceManagedCrash" /> <CommandItem id="PerformanceDiagnosticsAddIn.InduceNativeCrash" /> <CommandItem id="PerformanceDiagnosticsAddIn.InduceHang" /> + <CommandItem id="PerformanceDiagnosticsAddIn.InduceNativePInvokeCrash" /> </ItemSet> </Extension> |