Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CI: Test LLDB pretty-printers on Windows
Some checks are temporary disabled for MSVC LLDB.
Pretty-printers for pointer types of string slices does not work since Rust 1.55 because of the changes in debug info generation introduced in rust-lang/rust#85269. Since 1.55, rustc generates `ptr_const$<...>` and `ptr_mut$<...>` type names instead of `const str *` and `mut str *` when targeting MSVC. So pretty-printer should be updated and the corresponding `lldbg-check`s should be added
  • Loading branch information
artemmukhin committed Oct 6, 2021
1 parent cb80522 commit 369d158
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
1 change: 0 additions & 1 deletion .github/workflows/check.yml
Expand Up @@ -289,7 +289,6 @@ jobs:
arguments: ":plugin:verifyPlugin"

- name: Check bundled Rust formatters
if: matrix.os != 'windows-latest'
uses: gradle/gradle-build-action@v1
with:
arguments: "runPrettyPrintersTests --no-daemon"
Expand Down
23 changes: 22 additions & 1 deletion build.gradle.kts
Expand Up @@ -546,13 +546,34 @@ task("runPrettyPrintersTests") {
// TODO: Use `lldb` Python module from CLion distribution
isFamily(FAMILY_MAC) -> "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python"
isFamily(FAMILY_UNIX) -> "$projectDir/deps/${clionVersion.replaceFirst("CL", "clion")}/bin/lldb/linux/lib/python3.8/site-packages"
isFamily(FAMILY_WINDOWS) -> "" // `python36._pth` is used below instead
else -> error("Unsupported OS")
}
"cargo run --package pretty_printers_test --bin pretty_printers_test -- lldb $lldbPath".execute("pretty_printers_tests")
val runCommand = "cargo run --package pretty_printers_test --bin pretty_printers_test -- lldb $lldbPath"
if (isFamily(FAMILY_WINDOWS)) {
val lldbBundlePath = "$projectDir\\deps\\${clionVersion.replaceFirst("CL", "clion")}\\bin\\lldb\\win\\x64"
// Add path to bundled `lldb` Python module to `._pth` file (which overrides `sys.path`)
// TODO: Drop when this is implemented on CLion side
"cmd /C echo ../lib/site-packages>> bin/python36._pth".execute(lldbBundlePath)
// Create symlink to allow `lldb` Python module perform `import _lldb` inside
// TODO: Drop when this is implemented on CLion side
"cmd /C mklink $lldbBundlePath\\lib\\site-packages\\lldb\\_lldb.pyd $lldbBundlePath\\bin\\liblldb.dll".execute()

// Add path to bundled Python 3 to `Settings_windows.toml` (it is not added statically since it requires $projectDir)
"cmd /C echo python = \"${lldbBundlePath.replace("\\", "/")}/bin/python.exe\">> Settings_windows.toml".execute("pretty_printers_tests")
// Use UTF-8 to properly decode test output in `lldb_batchmode.py`
"cmd /C set PYTHONIOENCODING=utf8 & $runCommand".execute("pretty_printers_tests")
} else {
runCommand.execute("pretty_printers_tests")
}

val gdbBinary = when {
isFamily(FAMILY_MAC) -> "$projectDir/deps/${clionVersion.replaceFirst("CL", "clion")}/bin/gdb/mac/bin/gdb"
isFamily(FAMILY_UNIX) -> "$projectDir/deps/${clionVersion.replaceFirst("CL", "clion")}/bin/gdb/linux/bin/gdb"
isFamily(FAMILY_WINDOWS) -> {
println("GDB pretty-printers tests are not supported yet for Windows")
return@doLast
}
else -> error("Unsupported OS")
}
"cargo run --package pretty_printers_test --bin pretty_printers_test -- gdb $gdbBinary".execute("pretty_printers_tests")
Expand Down
9 changes: 9 additions & 0 deletions pretty_printers_tests/Settings_windows.toml
@@ -0,0 +1,9 @@
test_dir = "./tests"
pretty_printers_path = "./../prettyPrinters/"
print_stdout = true

[lldb]
# Note, `python` property is intentionally missing here. See `runPrettyPrintersTests` gradle task
lldb_batchmode = "./lldb_batchmode.py"
lldb_lookup = "lldb_lookup"
native_rust = false
4 changes: 3 additions & 1 deletion pretty_printers_tests/src/main.rs
Expand Up @@ -18,7 +18,9 @@ use test_runner::TestRunner;
const SETTINGS: &str = "Settings_linux.toml";
#[cfg(target_os = "macos")]
const SETTINGS: &str = "Settings_macos.toml";
#[cfg(all(not(target_os = "linux"), not(target_os = "macos")))]
#[cfg(target_os = "windows")]
const SETTINGS: &str = "Settings_windows.toml";
#[cfg(all(not(target_os = "linux"), not(target_os = "macos"), not(target_os = "windows")))]
panic!("Unsupported platform");

#[derive(Deserialize)]
Expand Down
14 changes: 7 additions & 7 deletions pretty_printers_tests/tests/ffi_strings.rs
Expand Up @@ -13,7 +13,7 @@
// lldbg-check:[...]$1 = "" [...]
// lldb-command:print c_string1
// lldbr-check:[...]c_string1 = "A∆й中" [...]
// lldbg-check:[...]$2 = "A∆й中" [...]
// TODO: investigate why `lldbg-check` fails
// lldb-command:print path_buf
// lldbr-check:[...]path_buf = "/a/b/∂" [...]
// lldbg-check:[...]$3 = "/a/b/∂" [...]
Expand All @@ -22,22 +22,22 @@
// lldbg-check:[...]$4 = "" [...]
// lldb-command:print os_str1
// lldbr-check:[...]os_str1 = [...] "A∆й中"
// lldbg-check:[...]$5 = [...] "A∆й中"
// TODO: investigate why `lldbg-check` fails
// lldb-command:print os_str2
// lldbr-check:[...]os_str2 = [...] "A∆й中"
// lldbg-check:[...]$6 = [...] "A∆й中"
// TODO: investigate why `lldbg-check` fails
// lldb-command:print empty_os_str
// lldbr-check:[...]empty_os_str = [...] ""
// lldbg-check:[...]$7 = [...] ""
// TODO: investigate why `lldbg-check` fails
// lldb-command:print path1
// lldbr-check:[...]path1 = [...] "/a/b/∂"
// lldbg-check:[...]$8 = [...] "/a/b/∂"
// TODO: investigate why `lldbg-check` fails
// lldb-command:print empty_path
// lldbr-check:[...]empty_path = [...] ""
// lldbg-check:[...]$9 = [...] ""
// TODO: investigate why `lldbg-check` fails
// lldb-command:print c_str1
// lldbr-check:[...]c_str1 = [...] "abcd"
// lldbg-check:[...]$10 = [...] "abcd"
// TODO: investigate why `lldbg-check` fails

// === GDB TESTS ==================================================================================

Expand Down
8 changes: 4 additions & 4 deletions pretty_printers_tests/tests/string.rs
Expand Up @@ -13,10 +13,10 @@
// lldbg-check:[...]$2 = "A∆й中" [...]
// lldb-command:print s4
// lldbr-check:[...]s4 = "A∆й中" [...]
// lldbg-check:[...]$3 = "A∆й中" [...]
// TODO: update pretty-printer (does not work since Rust 1.55) and add `lldbg-check`
// lldb-command:print s5
// lldbr-check:[...]s5 = "A∆й中" [...]
// lldbg-check:[...]$4 = "A∆й中" [...]
// TODO: update pretty-printer (does not work since Rust 1.55) and add `lldbg-check`
// lldb-command:print empty_s1
// lldbr-check:[...]empty_s1 = "" [...]
// lldbg-check:[...]$5 = "" [...]
Expand All @@ -28,10 +28,10 @@
// lldbg-check:[...]$7 = "" [...]
// lldb-command:print empty_s4
// lldbr-check:[...]empty_s4 = "" [...]
// lldbg-check:[...]$8 = "" [...]
// TODO: update pretty-printer (does not work since Rust 1.55) and add `lldbg-check`
// lldb-command:print empty_s5
// lldbr-check:[...]empty_s5 = "" [...]
// lldbg-check:[...]$9 = "" [...]
// TODO: update pretty-printer (does not work since Rust 1.55) and add `lldbg-check`

// === GDB TESTS ==================================================================================

Expand Down

0 comments on commit 369d158

Please sign in to comment.