Skip to content

feat: Fishhook for C++ Exceptions #5128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
1 change: 1 addition & 0 deletions Samples/macOS-Swift/macOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
SentrySDK.start { options in
options.dsn = "https://[email protected]/5428557"
options.debug = true
options.experimental.enableUnhandledCPPExceptionsV2 = true
options.tracesSampleRate = 1.0

let args = ProcessInfo.processInfo.arguments
Expand Down
48 changes: 36 additions & 12 deletions Samples/macOS-Swift/macOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,10 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="centerX" spacing="12" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fsa-9g-bf3">
<rect key="frame" x="128" y="53" width="224" height="468"/>
<rect key="frame" x="128" y="21" width="224" height="532"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nAm-U5-PON">
<rect key="frame" x="44" y="441" width="136" height="32"/>
<rect key="frame" x="44" y="505" width="136" height="32"/>
<buttonCell key="cell" type="push" title="Add Breadcrumb" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="zk9-d6-mm1">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -723,7 +723,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dzU-Gi-2VZ">
<rect key="frame" x="42" y="409" width="141" height="32"/>
<rect key="frame" x="42" y="473" width="141" height="32"/>
<buttonCell key="cell" type="push" title="Capture Message" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="EQH-kc-eDD">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -733,7 +733,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LiD-mH-Y7l">
<rect key="frame" x="54" y="377" width="116" height="32"/>
<rect key="frame" x="54" y="441" width="116" height="32"/>
<buttonCell key="cell" type="push" title="Capture Error" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Tlg-FD-XnA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -743,7 +743,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zMq-8z-Bqi">
<rect key="frame" x="39" y="345" width="146" height="32"/>
<rect key="frame" x="39" y="409" width="146" height="32"/>
<buttonCell key="cell" type="push" title="Capture Exception" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="PwR-RA-ikK">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -753,7 +753,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ocz-Nk-ZQ2">
<rect key="frame" x="23" y="313" width="178" height="32"/>
<rect key="frame" x="23" y="377" width="178" height="32"/>
<buttonCell key="cell" type="push" title="Capture User Feedback" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="nui-gg-F5o">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -763,7 +763,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="GQW-jy-1TZ">
<rect key="frame" x="42" y="281" width="141" height="32"/>
<rect key="frame" x="42" y="345" width="141" height="32"/>
<buttonCell key="cell" type="push" title="raiseNSException" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="7rF-ep-EYR">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -773,7 +773,7 @@
</buttonCell>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TkR-L2-cU3" userLabel="reportNSException">
<rect key="frame" x="38" y="249" width="149" height="32"/>
<rect key="frame" x="38" y="313" width="149" height="32"/>
<buttonCell key="cell" type="push" title="reportNSException" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="89W-TG-dLd">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -783,7 +783,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HXP-Is-MDM">
<rect key="frame" x="37" y="217" width="150" height="32"/>
<rect key="frame" x="37" y="281" width="150" height="32"/>
<buttonCell key="cell" type="push" title="NSRangeException" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="f0L-i6-NLd">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -793,7 +793,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="c5W-zA-19P">
<rect key="frame" x="37" y="185" width="150" height="32"/>
<rect key="frame" x="37" y="249" width="150" height="32"/>
<buttonCell key="cell" type="push" title="captureTransaction" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="OVU-vi-LRM">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -803,7 +803,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0rS-ee-VAF">
<rect key="frame" x="52" y="153" width="120" height="32"/>
<rect key="frame" x="52" y="217" width="120" height="32"/>
<buttonCell key="cell" type="push" title="Sentry.crash()" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="k1V-IH-Ru7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -813,7 +813,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sxu-g3-vT7" userLabel="CppException">
<rect key="frame" x="51" y="121" width="123" height="32"/>
<rect key="frame" x="51" y="185" width="123" height="32"/>
<buttonCell key="cell" type="push" title="CPP Exception" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="B4S-qm-cMV">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -822,6 +822,26 @@
<action selector="cppException:" target="XfG-lQ-9wD" id="mIk-IE-HEb"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZnH-uX-thg" userLabel="CppExceptionBGThread">
<rect key="frame" x="1" y="153" width="223" height="32"/>
<buttonCell key="cell" type="push" title="CPP Exception from BG Thread" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="sgd-a5-Qm0">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="cppExceptionBGThread:" target="XfG-lQ-9wD" id="ToL-c1-cZI"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6cu-Lb-BKK" userLabel="NoExceptCppException">
<rect key="frame" x="21" y="121" width="182" height="32"/>
<buttonCell key="cell" type="push" title="noexcept CPP Exception" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="9EW-wt-hCC">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="noExceptCppException:" target="XfG-lQ-9wD" id="bbh-Nn-BNZ"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Cfu-21-l6L" userLabel="CppException">
<rect key="frame" x="-7" y="89" width="238" height="32"/>
<buttonCell key="cell" type="push" title="Rethrow No Active CPP Exception" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="YRN-qy-qrz">
Expand Down Expand Up @@ -879,6 +899,8 @@
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
Expand All @@ -896,6 +918,8 @@
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
Expand Down
6 changes: 6 additions & 0 deletions Samples/macOS-Swift/macOS-Swift/CppSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Sentry::CppSample::throwCPPException(void)
internalFunction();
}

void
Sentry::CppSample::noExceptCppException() noexcept
{
throw std::invalid_argument("Invalid Argument.");
}

void
Sentry::CppSample::rethrowNoActiveCPPException(void)
{
Expand Down
1 change: 1 addition & 0 deletions Samples/macOS-Swift/macOS-Swift/CppSample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Sentry {
class CppSample {
public:
void throwCPPException();
void noExceptCppException() noexcept;
void rethrowNoActiveCPPException();
};
}
Expand Down
1 change: 1 addition & 0 deletions Samples/macOS-Swift/macOS-Swift/CppWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@interface CppWrapper : NSObject
- (void)throwCPPException;
- (void)noExceptCppException;
- (void)rethrowNoActiveCPPException;
- (void)throwNSRangeException;
@end
6 changes: 6 additions & 0 deletions Samples/macOS-Swift/macOS-Swift/CppWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ - (void)throwCPPException
cppTool.throwCPPException();
}

- (void)noExceptCppException
{
Sentry::CppSample cppTool;
cppTool.noExceptCppException();
}

- (void)rethrowNoActiveCPPException
{
Sentry::CppSample cppTool;
Expand Down
14 changes: 13 additions & 1 deletion Samples/macOS-Swift/macOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,19 @@ class ViewController: NSViewController {
let wrapper = CppWrapper()
wrapper.throwCPPException()
}


@IBAction func cppExceptionBGThread(_ sender: Any) {
DispatchQueue.global().async {
let wrapper = CppWrapper()
wrapper.throwCPPException()
}
}

@IBAction func noExceptCppException(_ sender: Any) {
let wrapper = CppWrapper()
wrapper.noExceptCppException()
}

@IBAction func rethrowNoActiveCppException(_ sender: Any) {
let wrapper = CppWrapper()
wrapper.rethrowNoActiveCPPException()
Expand Down
Loading
Loading