Skip to content

Commit ead3302

Browse files
authored
feat: Nintendo Switch native support (#2503)
1 parent 41fc9fb commit ead3302

20 files changed

+850
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
- When targeting Android, the capturing native SDK now has its name correctly set ([#2476](https://github.com/getsentry/sentry-unity/pull/2476))
1414
- Automatically captured transactions and spans now have their `Origin` correctly set. ([#2464](https://github.com/getsentry/sentry-unity/pull/2464))
1515

16+
### Features
17+
18+
- Added Nintendo Switch Native Support. The SDK now automatically syncs the scope - tags, breadcrumbs, context - to the native layer, so native crashes have the same rich context as managed events. ([#2503](https://github.com/getsentry/sentry-unity/pull/2503))
19+
1620
### Dependencies
1721

1822
- Bump Java SDK from v8.28.0 to v8.31.0 ([#2462](https://github.com/getsentry/sentry-unity/pull/2462), [#2481](https://github.com/getsentry/sentry-unity/pull/2481), [#2493](https://github.com/getsentry/sentry-unity/pull/2493))
Lines changed: 358 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,358 @@
1+
/*
2+
* Sentry Switch Stubs
3+
*
4+
* No-op stub implementations for sentry-native and Switch helper functions.
5+
* These stubs are used when the user has not provided the actual sentry-switch
6+
* native library, allowing the SDK to compile and run without native crash support.
7+
*
8+
* When the real sentry-switch library is provided by the user at:
9+
* Assets/Plugins/Sentry/Switch/libsentry.a
10+
* Assets/Plugins/Sentry/Switch/SentrySwitchHelpers.cpp
11+
*
12+
* This stub file will be automatically disabled by the build preprocessor,
13+
* and the real library will be linked instead.
14+
*
15+
* All functions here are no-ops that return safe default values.
16+
* The SDK will appear to initialize successfully, but native features
17+
* (crash reporting, native scope sync) will silently do nothing.
18+
* Managed Sentry features continue to work normally.
19+
*/
20+
21+
#include <stddef.h>
22+
#include <stdint.h>
23+
#include <stdarg.h>
24+
25+
/* sentry_value_t is an opaque 64-bit union in sentry-native */
26+
typedef union {
27+
uint64_t _bits;
28+
double _double;
29+
} sentry_value_t;
30+
31+
/* Null value constant */
32+
static const sentry_value_t SENTRY_VALUE_NULL = {0};
33+
34+
/*
35+
* =============================================================================
36+
* sentry-native Core Functions
37+
* =============================================================================
38+
*/
39+
40+
void* sentry_options_new(void)
41+
{
42+
/* Return non-null to indicate "success" - value is opaque anyway */
43+
return (void*)1;
44+
}
45+
46+
int sentry_init(void* options)
47+
{
48+
/* Return 0 to indicate success */
49+
return 0;
50+
}
51+
52+
void sentry_close(void)
53+
{
54+
/* No-op */
55+
}
56+
57+
/*
58+
* =============================================================================
59+
* sentry_options_set_* Functions (No-op)
60+
* =============================================================================
61+
*/
62+
63+
void sentry_options_set_dsn(void* options, const char* dsn)
64+
{
65+
(void)options;
66+
(void)dsn;
67+
}
68+
69+
void sentry_options_set_release(void* options, const char* release)
70+
{
71+
(void)options;
72+
(void)release;
73+
}
74+
75+
void sentry_options_set_environment(void* options, const char* environment)
76+
{
77+
(void)options;
78+
(void)environment;
79+
}
80+
81+
void sentry_options_set_debug(void* options, int debug)
82+
{
83+
(void)options;
84+
(void)debug;
85+
}
86+
87+
void sentry_options_set_sample_rate(void* options, double rate)
88+
{
89+
(void)options;
90+
(void)rate;
91+
}
92+
93+
void sentry_options_set_database_path(void* options, const char* path)
94+
{
95+
(void)options;
96+
(void)path;
97+
}
98+
99+
void sentry_options_set_auto_session_tracking(void* options, int track)
100+
{
101+
(void)options;
102+
(void)track;
103+
}
104+
105+
void sentry_options_set_attach_screenshot(void* options, int attach)
106+
{
107+
(void)options;
108+
(void)attach;
109+
}
110+
111+
void sentry_options_set_logger(void* options, void* logger, void* userdata)
112+
{
113+
(void)options;
114+
(void)logger;
115+
(void)userdata;
116+
}
117+
118+
/*
119+
* =============================================================================
120+
* sentry_value_* Functions
121+
* =============================================================================
122+
*/
123+
124+
sentry_value_t sentry_value_new_null(void)
125+
{
126+
return SENTRY_VALUE_NULL;
127+
}
128+
129+
sentry_value_t sentry_value_new_bool(int value)
130+
{
131+
(void)value;
132+
return SENTRY_VALUE_NULL;
133+
}
134+
135+
sentry_value_t sentry_value_new_int32(int32_t value)
136+
{
137+
(void)value;
138+
return SENTRY_VALUE_NULL;
139+
}
140+
141+
sentry_value_t sentry_value_new_double(double value)
142+
{
143+
(void)value;
144+
return SENTRY_VALUE_NULL;
145+
}
146+
147+
sentry_value_t sentry_value_new_string(const char* value)
148+
{
149+
(void)value;
150+
return SENTRY_VALUE_NULL;
151+
}
152+
153+
sentry_value_t sentry_value_new_object(void)
154+
{
155+
return SENTRY_VALUE_NULL;
156+
}
157+
158+
sentry_value_t sentry_value_new_breadcrumb(const char* type, const char* message)
159+
{
160+
(void)type;
161+
(void)message;
162+
return SENTRY_VALUE_NULL;
163+
}
164+
165+
int sentry_value_set_by_key(sentry_value_t value, const char* k, sentry_value_t v)
166+
{
167+
(void)value;
168+
(void)k;
169+
(void)v;
170+
return 0;
171+
}
172+
173+
int sentry_value_is_null(sentry_value_t value)
174+
{
175+
(void)value;
176+
/* Return 1 (true) - all stub values are effectively null */
177+
return 1;
178+
}
179+
180+
int32_t sentry_value_as_int32(sentry_value_t value)
181+
{
182+
(void)value;
183+
return 0;
184+
}
185+
186+
double sentry_value_as_double(sentry_value_t value)
187+
{
188+
(void)value;
189+
return 0.0;
190+
}
191+
192+
const char* sentry_value_as_string(sentry_value_t value)
193+
{
194+
(void)value;
195+
return NULL;
196+
}
197+
198+
size_t sentry_value_get_length(sentry_value_t value)
199+
{
200+
(void)value;
201+
return 0;
202+
}
203+
204+
sentry_value_t sentry_value_get_by_index(sentry_value_t value, size_t index)
205+
{
206+
(void)value;
207+
(void)index;
208+
return SENTRY_VALUE_NULL;
209+
}
210+
211+
sentry_value_t sentry_value_get_by_key(sentry_value_t value, const char* key)
212+
{
213+
(void)value;
214+
(void)key;
215+
return SENTRY_VALUE_NULL;
216+
}
217+
218+
void sentry_value_decref(sentry_value_t value)
219+
{
220+
(void)value;
221+
}
222+
223+
/*
224+
* =============================================================================
225+
* Scope/Context Functions (No-op)
226+
* =============================================================================
227+
*/
228+
229+
void sentry_set_context(const char* key, sentry_value_t value)
230+
{
231+
(void)key;
232+
(void)value;
233+
}
234+
235+
void sentry_add_breadcrumb(sentry_value_t breadcrumb)
236+
{
237+
(void)breadcrumb;
238+
}
239+
240+
void sentry_set_tag(const char* key, const char* value)
241+
{
242+
(void)key;
243+
(void)value;
244+
}
245+
246+
void sentry_remove_tag(const char* key)
247+
{
248+
(void)key;
249+
}
250+
251+
void sentry_set_user(sentry_value_t user)
252+
{
253+
(void)user;
254+
}
255+
256+
void sentry_remove_user(void)
257+
{
258+
/* No-op */
259+
}
260+
261+
void sentry_set_extra(const char* key, sentry_value_t value)
262+
{
263+
(void)key;
264+
(void)value;
265+
}
266+
267+
void sentry_remove_extra(const char* key)
268+
{
269+
(void)key;
270+
}
271+
272+
void sentry_set_trace(const char* trace_id, const char* parent_span_id)
273+
{
274+
(void)trace_id;
275+
(void)parent_span_id;
276+
}
277+
278+
/*
279+
* =============================================================================
280+
* Crash Detection Functions
281+
* =============================================================================
282+
*/
283+
284+
int sentry_get_crashed_last_run(void)
285+
{
286+
/* Return 0 - no crash detected (since we're not tracking) */
287+
return 0;
288+
}
289+
290+
int sentry_clear_crashed_last_run(void)
291+
{
292+
return 0;
293+
}
294+
295+
void sentry_reinstall_backend(void)
296+
{
297+
/* No-op */
298+
}
299+
300+
sentry_value_t sentry_get_modules_list(void)
301+
{
302+
/* Return null - no modules to report */
303+
return SENTRY_VALUE_NULL;
304+
}
305+
306+
/*
307+
* =============================================================================
308+
* Switch Helper Functions
309+
* =============================================================================
310+
*/
311+
312+
int sentry_switch_utils_mount(void)
313+
{
314+
/* Return 1 to indicate success - allows SDK initialization to proceed */
315+
return 1;
316+
}
317+
318+
const char* sentry_switch_utils_get_cache_path(void)
319+
{
320+
/* Return a valid-looking path */
321+
return "sentry:/";
322+
}
323+
324+
int sentry_switch_utils_is_mounted(void)
325+
{
326+
/* Return 1 - pretend we're mounted */
327+
return 1;
328+
}
329+
330+
void sentry_switch_utils_unmount(void)
331+
{
332+
/* No-op */
333+
}
334+
335+
const char* sentry_switch_utils_get_default_user_id(void)
336+
{
337+
/* Return empty string - no user ID available */
338+
return "";
339+
}
340+
341+
/*
342+
* =============================================================================
343+
* Utility Functions
344+
* =============================================================================
345+
*/
346+
347+
int vsnprintf_sentry(char* buffer, size_t size, const char* format, va_list args)
348+
{
349+
(void)format;
350+
(void)args;
351+
352+
/* Just null-terminate the buffer and return 0 */
353+
if (buffer != NULL && size > 0)
354+
{
355+
buffer[0] = '\0';
356+
}
357+
return 0;
358+
}

0 commit comments

Comments
 (0)