Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic CDB support to debuginfo compiletest s, to help catch *.natvis regressions, like those fixed in #60687. #60970

Merged
merged 3 commits into from
May 23, 2019

Conversation

MaulingMonkey
Copy link
Contributor

First draft, feedback welcome.

Several Microsoft debuggers (VS, VS Code, WinDbg, CDB, ...) consume the *.natvis files we embed into rust *.pdb files. While this only tests CDB, that test coverage should help for all of them.

Changes

src\bootstrap

  • test.rs: Run CDB debuginfo tests on MSVC targets

src\test\debuginfo

  • issue-13213.rs: CDB has trouble with this, skip for now (newly discovered regression?)
  • pretty-std.rs: Was ignored, re-enable for CDB only to start with, add CDB tests.
  • should-fail.rs: Add CDB tests.

src\tools\compiletest:

  • Added "-cdb" option
  • Added Mode::DebugInfoCdb ("debuginfo-cdb")
  • Added run_debuginfo_cdb_test[_no_opt]
  • Renamed Mode::DebugInfoBoth -> DebugInfoGdbLldb ("debuginfo-gdb+lldb") since it's no longer clear what "Both" means.
  • Find CDB at the default Win10 SDK install path "C:\Program Files (x86)\Windows Kits\10\Debugger\*\cdb.exe"
  • Ignore CDB tests if CDB not found.

Issues

  • compute_stamp_hash: not sure if there's any point in hashing %ProgramFiles(x86)%
  • OsString lacks any *.natvis entries (would be nice to add in a followup changelist)
  • DSTs (array/string slices) which work in VS & VS Code fail in CDB.
  • I've avoided Mode::DebugInfoAll as 3 debuggers leads to pow(2,3)=8 possible combinations.

Reference

CDB is not part of the base Visual Studio install, but can be added via the Windows 10 SDK:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
Installing just "Debugging Tools for Windows" is sufficient.

CDB appears to already be installed on appveyor CI, where this changelist can find it, based on it's use here:

- set PATH=%PATH%;"C:\Program Files (x86)\Windows Kits\10\Debuggers\X64"

CDB commands and command line reference:
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-reference

…tvis` regressions, like those fixed in rust-lang#60687.

Several Microsoft debuggers (VS, VS Code, WinDbg, CDB, ...) consume the `*.natvis` files we embed into rust `*.pdb` files.
While this only tests CDB, that test coverage should help for all of them.

CHANGES

src\bootstrap
  - test.rs:  Run CDB debuginfo tests on MSVC targets

src\test\debuginfo
  - issue-13213.rs:  CDB has trouble with this, skip for now (newly discovered regression?)
  - pretty-std.rs:  Was ignored, re-enable for CDB only to start with, add CDB tests.
  - should-fail.rs:  Add CDB tests.

src\tools\compiletest:
  - Added "-cdb" option
  - Added Mode::DebugInfoCdb ("debuginfo-cdb")
  - Added run_debuginfo_cdb_test[_no_opt]
  - Renamed Mode::DebugInfoBoth -> DebugInfoGdbLldb ("debuginfo-gdb+lldb") since it's no longer clear what "Both" means.
  - Find CDB at the default Win10 SDK install path "C:\Program Files (x86)\Windows Kits\10\Debugger\*\cdb.exe"
  - Ignore CDB tests if CDB not found.

ISSUES

  - `compute_stamp_hash`: not sure if there's any point in hashing `%ProgramFiles(x86)%`
  - `OsString` lacks any `*.natvis` entries (would be nice to add in a followup changelist)
  - DSTs (array/string slices) which work in VS & VS Code fail in CDB.
  - I've avoided `Mode::DebugInfoAll` as 3 debuggers leads to pow(2,3)=8 possible combinations.

REFERENCE

CDB is not part of the base Visual Studio install, but can be added via the Windows 10 SDK:
  https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
Installing just "Debugging Tools for Windows" is sufficient.

CDB appears to already be installed on appveyor CI, where this changelist can find it, based on it's use here:
  https://github.com/rust-lang/rust/blob/0ffc57311030a1930edfa721fe57d0000a063af4/appveyor.yml#L227

CDB commands and command line reference:
  https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-reference
@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:02ef9050:start=1558311429257100545,finish=1558311518335147427,duration=89078046882
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---

[00:04:01] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:01] tidy error: /checkout/src/test/debuginfo/pretty-std.rs:2: line longer than 100 chars
[00:04:01] tidy error: /checkout/src/test/debuginfo/pretty-std.rs:84: line longer than 100 chars
[00:04:01] tidy error: /checkout/src/test/debuginfo/pretty-std.rs:113: line longer than 100 chars
[00:04:01] tidy error: /checkout/src/tools/compiletest/src/runtest.rs:6: line longer than 100 chars
[00:04:01] tidy error: /checkout/src/tools/compiletest/src/runtest.rs:712: line longer than 100 chars
[00:04:01] tidy error: /checkout/src/tools/compiletest/src/runtest.rs:1971: line longer than 100 chars
[00:04:01] tidy error: /checkout/src/tools/compiletest/src/main.rs:876: line longer than 100 chars
[00:04:06] some tidy checks failed
[00:04:06] 
[00:04:06] 
[00:04:06] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:06] 
[00:04:06] 
[00:04:06] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:06] Build completed unsuccessfully in 0:01:17
[00:04:06] Build completed unsuccessfully in 0:01:17
[00:04:06] Makefile:67: recipe for target 'tidy' failed
[00:04:06] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:00ed7c22
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon May 20 00:22:53 UTC 2019
---
travis_time:end:06696936:start=1558311774591622184,finish=1558311774596566900,duration=4944716
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0012c6b4
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:027f1604
travis_time:start:027f1604
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0baaa217
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me, thanks so much for this @MaulingMonkey! We don't have a great way to test this on AppVeyor before sending through bors, but that's probably ok as it looks like you're probably running the tests locally already and there may just be a CI issue or two to work through on AppVeyor.

}

fn find_cdb(target: &String) -> Option<OsString> {
if cfg!(windows) && is_pc_windows_msvc_target(target) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be inverted to reduce indentation? e.g.:

if !current_condition {
    return None;
}

// ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -1,5 +1,6 @@
#![crate_name = "compiletest"]
#![feature(test)]
#![feature(path_buf_capacity)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use existing stable methods instead of adding a new unstable feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Can't reserve capacity without it, but that's an unimportant optimization at best.

if config.mode == DebugInfoCdb {
match config.cdb {
None => env::var_os("ProgramFiles(x86)").hash(&mut hash),
Some(ref s) if s.is_empty() => env::var_os("ProgramFiles(x86)").hash(&mut hash),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this case in theory be impossible with the previous validation of --cdb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so, yes.

if config.mode == DebugInfoGdb || config.mode == DebugInfoBoth {
if config.mode == DebugInfoCdb {
match config.cdb {
None => env::var_os("ProgramFiles(x86)").hash(&mut hash),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the gdb section does this, I think this is probably fine to just ignore and do nothing in this branch? It seems like this would probably want to just be config.cdb.hash(&mut hash).

(I don't think 100% fidelity is really that necessary here and being simple is probably the best way to go)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me.

- Don't add path_buf_capacity feature.
- Convert `find_cdb` to early return style, reducing indentation
- Simplify `compute_stamp_hash` for CDB to just hash it's path, if any.
@MaulingMonkey
Copy link
Contributor Author

I've been mostly just testing the stage 1 debuginfo tests. If I'm understanding the rustc build pipeline properly this should be sufficient, as I'm not touching the compiler itself here just tests - but if there's anything else I should be testing just let me know:

./x.py test --stage 1 --build x86_64-pc-windows-msvc src/test/debuginfo
./x.py test --stage 1 --build i686-pc-windows-msvc src/test/debuginfo
./x.py test --stage 1 --build x86_64-pc-windows-gnu src/test/debuginfo
./x.py test --stage 1 src/tools/tidy

@alexcrichton
Copy link
Member

@bors: r+

👍

@bors
Copy link
Contributor

bors commented May 21, 2019

📌 Commit 56b18ce has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 21, 2019
Centril added a commit to Centril/rust that referenced this pull request May 22, 2019
…pport, r=alexcrichton

Add basic CDB support to debuginfo compiletest s, to help catch `*.natvis` regressions, like those fixed in rust-lang#60687.

First draft, feedback welcome.

Several Microsoft debuggers (VS, VS Code, WinDbg, CDB, ...) consume the `*.natvis` files we embed into rust `*.pdb` files.  While this only tests CDB, that test coverage should help for all of them.

# Changes

## src\bootstrap
  - test.rs:  Run CDB debuginfo tests on MSVC targets

## src\test\debuginfo
  - issue-13213.rs:  CDB has trouble with this, skip for now (newly discovered regression?)
  - pretty-std.rs:  Was ignored, re-enable for CDB only to start with, add CDB tests.
  - should-fail.rs:  Add CDB tests.

## src\tools\compiletest:
  - Added "-cdb" option
  - Added Mode::DebugInfoCdb ("debuginfo-cdb")
  - Added run_debuginfo_cdb_test[_no_opt]
  - Renamed Mode::DebugInfoBoth -> DebugInfoGdbLldb ("debuginfo-gdb+lldb") since it's no longer clear what "Both" means.
  - Find CDB at the default Win10 SDK install path "C:\Program Files (x86)\Windows Kits\10\Debugger\\*\cdb.exe"
  - Ignore CDB tests if CDB not found.

# Issues

  - `compute_stamp_hash`: not sure if there's any point in hashing `%ProgramFiles(x86)%`
  - `OsString` lacks any `*.natvis` entries (would be nice to add in a followup changelist)
  - DSTs (array/string slices) which work in VS & VS Code fail in CDB.
  - I've avoided `Mode::DebugInfoAll` as 3 debuggers leads to pow(2,3)=8 possible combinations.

# Reference

CDB is not part of the base Visual Studio install, but can be added via the Windows 10 SDK:
  https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
Installing just "Debugging Tools for Windows" is sufficient.

CDB appears to already be installed on appveyor CI, where this changelist can find it, based on it's use here:
  https://github.com/rust-lang/rust/blob/0ffc57311030a1930edfa721fe57d0000a063af4/appveyor.yml#L227

CDB commands and command line reference:
  https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-reference
@Centril
Copy link
Contributor

Centril commented May 23, 2019

@bors rollup=never

@bors
Copy link
Contributor

bors commented May 23, 2019

⌛ Testing commit 56b18ce with merge 79e607c4d5d639d45e74551c51768f202ee431fd...

@varkor
Copy link
Member

varkor commented May 23, 2019

@bors retry

@varkor
Copy link
Member

varkor commented May 23, 2019

(Prioritised #61085.)

@bors
Copy link
Contributor

bors commented May 23, 2019

⌛ Testing commit 56b18ce with merge 8869ee0...

bors added a commit that referenced this pull request May 23, 2019
…excrichton

Add basic CDB support to debuginfo compiletest s, to help catch `*.natvis` regressions, like those fixed in #60687.

First draft, feedback welcome.

Several Microsoft debuggers (VS, VS Code, WinDbg, CDB, ...) consume the `*.natvis` files we embed into rust `*.pdb` files.  While this only tests CDB, that test coverage should help for all of them.

# Changes

## src\bootstrap
  - test.rs:  Run CDB debuginfo tests on MSVC targets

## src\test\debuginfo
  - issue-13213.rs:  CDB has trouble with this, skip for now (newly discovered regression?)
  - pretty-std.rs:  Was ignored, re-enable for CDB only to start with, add CDB tests.
  - should-fail.rs:  Add CDB tests.

## src\tools\compiletest:
  - Added "-cdb" option
  - Added Mode::DebugInfoCdb ("debuginfo-cdb")
  - Added run_debuginfo_cdb_test[_no_opt]
  - Renamed Mode::DebugInfoBoth -> DebugInfoGdbLldb ("debuginfo-gdb+lldb") since it's no longer clear what "Both" means.
  - Find CDB at the default Win10 SDK install path "C:\Program Files (x86)\Windows Kits\10\Debugger\\*\cdb.exe"
  - Ignore CDB tests if CDB not found.

# Issues

  - `compute_stamp_hash`: not sure if there's any point in hashing `%ProgramFiles(x86)%`
  - `OsString` lacks any `*.natvis` entries (would be nice to add in a followup changelist)
  - DSTs (array/string slices) which work in VS & VS Code fail in CDB.
  - I've avoided `Mode::DebugInfoAll` as 3 debuggers leads to pow(2,3)=8 possible combinations.

# Reference

CDB is not part of the base Visual Studio install, but can be added via the Windows 10 SDK:
  https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
Installing just "Debugging Tools for Windows" is sufficient.

CDB appears to already be installed on appveyor CI, where this changelist can find it, based on it's use here:
  https://github.com/rust-lang/rust/blob/0ffc57311030a1930edfa721fe57d0000a063af4/appveyor.yml#L227

CDB commands and command line reference:
  https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-reference
@bors
Copy link
Contributor

bors commented May 23, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: alexcrichton
Pushing 8869ee0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 23, 2019
@bors bors merged commit 56b18ce into rust-lang:master May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants