forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demangle symbol names in GotoC (-> .demangled.c) (rust-lang#1303)
- Loading branch information
Showing
8 changed files
with
192 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target/ | ||
Cargo.lock | ||
*.c | ||
build/ |
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,81 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
set -eu | ||
|
||
echo | ||
echo "Starting output file check..." | ||
echo | ||
|
||
# Test for platform | ||
PLATFORM=$(uname -sp) | ||
if [[ $PLATFORM == "Linux x86_64" ]] | ||
then | ||
TARGET="x86_64-unknown-linux-gnu" | ||
elif [[ $PLATFORM == "Darwin i386" ]] | ||
then | ||
TARGET="x86_64-apple-darwin" | ||
elif [[ $PLATFORM == "Darwin arm" ]] | ||
then | ||
TARGET="aarch64-apple-darwin" | ||
else | ||
echo | ||
echo "Test only works on Linux or OSX platforms, skipping..." | ||
echo | ||
exit 0 | ||
fi | ||
|
||
cd $(dirname $0) | ||
|
||
echo "Running single-file check..." | ||
rm -rf *.c | ||
RUST_BACKTRACE=1 kani --gen-c --enable-unstable singlefile.rs --quiet | ||
if ! [ -e singlefile.out.c ] | ||
then | ||
echo "Error: no GotoC file generated. Expected: singlefile.out.c" | ||
exit 1 | ||
fi | ||
|
||
if ! [ -e singlefile.out.demangled.c ] | ||
then | ||
echo "Error: no demangled GotoC file generated. Expected singlefile.out.demangled.c." | ||
exit 1 | ||
fi | ||
|
||
if ! grep -Fq "struct PrettyStruct pretty_function(struct PrettyStruct" singlefile.out.demangled.c; | ||
then | ||
echo "Error: demangled file singlefile.out.demangled.c did not contain expected demangled struct and function name." | ||
exit 1 | ||
fi | ||
echo "Finished single-file check successfully..." | ||
echo | ||
|
||
(cd multifile | ||
echo "Running multi-file check..." | ||
rm -rf build | ||
RUST_BACKTRACE=1 cargo kani --target-dir build --gen-c --enable-unstable --quiet | ||
cd build/${TARGET}/debug/deps/ | ||
|
||
if ! [ -e cbmc-for-main.c ] | ||
then | ||
echo "Error: no GotoC file generated. Expected: build/${TARGET}/debug/deps/cbmc-for-main.c" | ||
exit 1 | ||
fi | ||
|
||
if ! [ -e cbmc-for-main.demangled.c ] | ||
then | ||
echo "Error: no demangled GotoC file generated. Expected build/${TARGET}/debug/deps/cbmc-for-main.demangled.c." | ||
exit 1 | ||
fi | ||
|
||
if ! grep -Fq "struct PrettyStruct pretty_function(struct PrettyStruct" cbmc-for-main.demangled.c; | ||
then | ||
echo "Error: demangled file build/${TARGET}/debug/deps/cbmc-for-main.demangled.c did not contain expected demangled struct and function name." | ||
exit 1 | ||
fi | ||
echo "Finished multi-file check successfully..." | ||
) | ||
|
||
echo "Finished output file check successfully." | ||
echo |
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,11 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
[package] | ||
name = "multifile" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[workspace] | ||
|
||
[dependencies] |
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,13 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
pub struct PrettyStruct; | ||
|
||
#[kani::proof] | ||
fn main() { | ||
pretty_function(PrettyStruct); | ||
} | ||
|
||
pub fn pretty_function(argument: PrettyStruct) -> PrettyStruct { | ||
argument | ||
} |
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,13 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
pub struct PrettyStruct; | ||
|
||
#[kani::proof] | ||
pub fn main() { | ||
pretty_function(PrettyStruct); | ||
} | ||
|
||
pub fn pretty_function(argument: PrettyStruct) -> PrettyStruct { | ||
argument | ||
} |