auto-differentiation / xad

Powerful automatic differentiation in C++ and Python
https://auto-differentiation.github.io
GNU Affero General Public License v3.0
257 stars 37 forks source link

Add Natvis file to display XAD types as values in Visual Studio debugger #94

Closed dholden3 closed 10 months ago

dholden3 commented 10 months ago

Description

Displays the XAD types as values in the Visual Studio debugger. Works for adjoint, forward, and higher order values. See the screenshot below.

Fixes Issue #55.

image

Type of change

CLAassistant commented 10 months ago

CLA assistant check
All committers have signed the CLA.

coveralls commented 10 months ago

Coverage Status

coverage: 98.56%. remained the same when pulling a9320e268b744d8b44503f93f3c6b4f7b2b2a966 on dholden3:main into 5b22eff32f8fc1d77c5908fd84f1f25decc0a171 on auto-differentiation:main.

github-actions[bot] commented 10 months ago

Test Results

    29 files  ±0      29 suites  ±0   11m 47s :stopwatch: -6s  1 271 tests ±0   1 271 :white_check_mark: ±0  0 :zzz: ±0  0 :x: ±0  36 859 runs  ±0  36 859 :white_check_mark: ±0  0 :zzz: ±0  0 :x: ±0 

Results for commit a9320e26. ± Comparison against base commit 5b22eff3.

:recycle: This comment has been updated with latest results.

auto-differentiation-dev commented 10 months ago

This looks good - thank you for that @dholden3 .

It works well when developing within the XAD repository itself, but it will probably not be found when XAD is linked into another project - either as a subproject or from an installed binary.

Linking the natvis file into the PDB file in Windows should fix that - it becomes part of the built binary (and we install the PDB file along with the library in Windows). MSVC's /NATVIS flag should work for that. Note this should only be done in MSVC/Debug builds (including RelWithDebInfo) - could you give that a try please?

auto-differentiation-dev commented 10 months ago

It looks like the linker flags for /NATVIS don't work with CMake - even with an absolute path to the file. And given that XAD is a static library (the linker does not actually run until building executables), the approach of adding link options to the library is flawed. This needs built-in support in CMake in some future release, but it's not there yet.

However, .natvis files can be added as source files, and at least when using a Visual Studio Generator, it will handle the flags correctly for building the PDB. It looks like there's nothing more we can do about linking / subprojects.

We have made those changes directly - and will merge once the build passes.