-
Notifications
You must be signed in to change notification settings - Fork 541
/
Copy pathhelpers.cc
46 lines (38 loc) · 1.13 KB
/
helpers.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <cstdarg>
#include <cstring>
#include <android/set_abort_message.h>
#include "helpers.hh"
#include "log_types.hh"
using namespace xamarin::android;
[[noreturn]] void
Helpers::abort_application (LogCategories category, const char *message, bool log_location, std::source_location sloc) noexcept
{
// Log it, but also...
log_fatal (category, "{}", message);
// ...let android include it in the tombstone, debuggerd output, stack trace etc
android_set_abort_message (message);
if (log_location) {
// We don't want to log the full path, just the file name. libc++ uses full file path here.
const char *file_name = sloc.file_name ();
const char *last_path_sep = strrchr (file_name, '/');
if (last_path_sep == nullptr) [[unlikely]] {
// In case we were built on Windows
last_path_sep = strrchr (file_name, '\\');
}
if (last_path_sep != nullptr) [[likely]] {
last_path_sep++;
if (*last_path_sep != '\0') [[unlikely]] {
file_name = last_path_sep;
}
}
log_fatal (
category,
"Abort at {}:{}:{} ('%s')",
file_name,
sloc.line (),
sloc.column (),
sloc.function_name ()
);
}
std::abort ();
}