-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0504378
commit 9d2d4e3
Showing
11 changed files
with
168 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/*--------------------------------------------------------------------*/ | ||
/*--- Swift demangler ---*/ | ||
/*--------------------------------------------------------------------*/ | ||
|
||
/* | ||
This file is part of Valgrind, a dynamic binary instrumentation | ||
framework. | ||
Copyright (c) 2024-2024 Louis Brunner <louis.brunner.fr@gmail.com> | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License as | ||
published by the Free Software Foundation; either version 2 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
The GNU General Public License is contained in the file COPYING. | ||
*/ | ||
|
||
#include "vg_libciface.h" | ||
|
||
#include "ansidecl.h" | ||
#include "demangle.h" | ||
#include "safe-ctype.h" | ||
|
||
char* swift_demangle (const char *mangled, int options) | ||
{ | ||
UInt prefix_length = 0; | ||
Bool legacy = False; | ||
|
||
if (VG_(strstr)(mangled, "_T0") == mangled || VG_(strstr)(mangled, "_$S") == mangled || VG_(strstr)(mangled, "_$s") == mangled) { | ||
prefix_length = 3; | ||
} | ||
if (VG_(strstr)(mangled, "_T") == mangled) { | ||
prefix_length = 2; | ||
legacy = True; | ||
} | ||
if (VG_(strstr)(mangled, "$S") == mangled || VG_(strstr)(mangled, "$s") == mangled) { | ||
prefix_length = 2; | ||
} | ||
|
||
if (prefix_length == 0) { | ||
return NULL; | ||
} | ||
|
||
mangled += prefix_length; | ||
|
||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Same principle as demangle-rust.c, but for Swift symbols. | ||
|
||
#include <stdlib.h> | ||
|
||
int $sSo13NSFileManagerC10FoundationE28withFileSystemRepresentation3for_xSS_xSPys4Int8VGSgKXEtKlFSDySo0A12AttributeKeyaypG_Tg5(int *p) | ||
{ | ||
free(p); | ||
free(p); | ||
return 1; | ||
} | ||
|
||
int $ss26_SwiftDeferredNSDictionaryC12bridgeValuess20__BridgingHashBufferCSgyF(int* p) | ||
{ | ||
return $sSo13NSFileManagerC10FoundationE28withFileSystemRepresentation3for_xSS_xSPys4Int8VGSgKXEtKlFSDySo0A12AttributeKeyaypG_Tg5(p); | ||
} | ||
|
||
int $sSS7cStringSSSPys4Int8VG_tcfC(int* p) | ||
{ | ||
return $ss26_SwiftDeferredNSDictionaryC12bridgeValuess20__BridgingHashBufferCSgyF(p); | ||
} | ||
|
||
int $s10Foundation16_FileManagerImplV16attributesOfItem6atPathSDySo18NSFileAttributeKeyaypGSS_tKFAHSPys4Int8VGSgKXEfU_TA(size_t s) | ||
{ | ||
return $sSS7cStringSSSPys4Int8VG_tcfC(malloc(s)); | ||
} | ||
|
||
int _TtBv4Bf16_(void) | ||
{ | ||
return $s10Foundation16_FileManagerImplV16attributesOfItem6atPathSDySo18NSFileAttributeKeyaypGSS_tKFAHSPys4Int8VGSgKXEfU_TA(sizeof(int)); | ||
} | ||
|
||
int $ss6SimpleHr(void) | ||
{ | ||
return _TtBv4Bf16_(); | ||
} | ||
|
||
int main(void) | ||
{ | ||
return $ss6SimpleHr(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Invalid free() / delete / delete[] / realloc() | ||
at 0x........: free (vg_replace_malloc.c:...) | ||
by 0x........: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver> (demangle-rust.c:13) | ||
by 0x........: rustc_expand::mbe::macro_parser::parse_tt (demangle-rust.c:20) | ||
by 0x........: core::str::lossy::Utf8Lossy::from_bytes (demangle-rust.c:26) | ||
by 0x........: main (demangle-rust.c:31) | ||
Address 0x........ is 0 bytes inside a block of size 4 free'd | ||
at 0x........: free (vg_replace_malloc.c:...) | ||
by 0x........: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver> (demangle-rust.c:12) | ||
by 0x........: rustc_expand::mbe::macro_parser::parse_tt (demangle-rust.c:20) | ||
by 0x........: core::str::lossy::Utf8Lossy::from_bytes (demangle-rust.c:26) | ||
by 0x........: main (demangle-rust.c:31) | ||
Block was alloc'd at | ||
at 0x........: malloc (vg_replace_malloc.c:...) | ||
by 0x........: main (demangle-rust.c:31) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
prog: demangle-swift | ||
vgopts: -q |