mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Demangle symbols on assertion failure on Linux as well
While macOS backtrace(3) puts a space directly after the mangled symbol name, some versions of glibc put a + directly after it. This new logic accounts for both situations when trying to demangle. Co-Authored-By: Andreas Kling <kling@serenityos.org>
This commit is contained in:
parent
4cee3b65d3
commit
aa03f73c2e
Notes:
sideshowbarker
2024-07-17 02:37:08 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/aa03f73c2e Pull-request: https://github.com/SerenityOS/serenity/pull/20918
1 changed files with 4 additions and 3 deletions
|
@ -38,8 +38,9 @@ ALWAYS_INLINE void dump_backtrace()
|
|||
syms[i][idx.value() - 1] = '\0';
|
||||
(void)fprintf(stderr, "%s ", syms[i]);
|
||||
|
||||
auto end_of_sym = sym.find(' ', idx.value()).value_or(sym.length() - 1);
|
||||
syms[i][end_of_sym] = '\0';
|
||||
auto sym_substring = sym.substring_view(idx.value());
|
||||
auto end_of_sym = sym_substring.find_any_of("+ "sv).value_or(sym_substring.length() - 1);
|
||||
syms[i][idx.value() + end_of_sym] = '\0';
|
||||
|
||||
size_t buf_size = 128u;
|
||||
char* buf = static_cast<char*>(malloc(buf_size));
|
||||
|
@ -49,7 +50,7 @@ ALWAYS_INLINE void dump_backtrace()
|
|||
(void)fputs(buf ? buf : raw_str, stderr);
|
||||
free(buf);
|
||||
|
||||
(void)fprintf(stderr, " %s", &syms[i][end_of_sym + 1]);
|
||||
(void)fprintf(stderr, " %s", &syms[i][idx.value() + end_of_sym + 1]);
|
||||
} else {
|
||||
(void)fputs(sym.characters_without_null_termination(), stderr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue