Skip to content

Debugger pretty printer for MSVC.#464

Open
MarekKnapek wants to merge 2 commits into
cppalliance:developfrom
MarekKnapek:debugger-formatter
Open

Debugger pretty printer for MSVC.#464
MarekKnapek wants to merge 2 commits into
cppalliance:developfrom
MarekKnapek:debugger-formatter

Conversation

@MarekKnapek

Copy link
Copy Markdown
Contributor

Fix for #463.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.12%. Comparing base (b2de777) to head (874e551).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #464   +/-   ##
========================================
  Coverage    96.12%   96.12%           
========================================
  Files           87       87           
  Lines         7566     7566           
  Branches      2739     2739           
========================================
  Hits          7273     7273           
  Misses          44       44           
  Partials       249      249           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mborland

Copy link
Copy Markdown
Member

Hi, thank you for continuing to work on this. How does someone use this? I assume it's different than the current registration instructions found in the doc: https://github.com/cppalliance/int128/blob/develop/doc/modules/ROOT/pages/printer.adoc. Could you also post a screenshot of what the values look like in your debugger so I can drop that in the doc update as well?

Add separate dec and hex views.
@MarekKnapek

Copy link
Copy Markdown
Contributor Author

There are two competing technologies used. One is pure NATVIS declarative XML based one. The second one is imperative one executing arbitrary code from a DLL. I think both have their pros and cons and both could stay in the repo.

The XML one is "safe" meaning the users will not be scared executing arbitrary code. There might be some company-wide rules in place, antivirus software and so on. Less powerful. DLL based approach is more powerful at the cost of loading arbitrary DLL into the Visual Studio IDE process.

How to use this? "Somehow" build the DLL and "somehow" tell your project to use that DLL.

Building: Use whatever means you know about building a DLL. Be it make, cmake, nmake, clicking in IDE, MSBuild or whatever. If you don't know any, use the batch script I included, it will search for Visual Studio 2026 and build the DLL for you. Even if the DLL is built by Visual Studio 2026, it should work just fine with older Visual Studio versions. Porting to a 32bit Visual Studio should be trivial. It has minimal run-time dependencies (if you have Windows - it should work), no need to install VCRedist or any other package when copy & pasting this DLL to another machine. Yes, it could be built once and then copy & pasted to other developer's machine in a company or in a team.

Using: Again, there are multiple ways how to load this IDE add-in. One way is to add dependency on int128_printer_msvc.natvis to your project (I did this via clicking in the IDE, cmake could do it too). Visual Studio will then load the DLL from the boost directory. The same directory the XML is located in. Other way how to do it, is to copy & paste the int128_printer_msvc.natvis into your project, then copy & paste the DLL to the same place. Yet another way could be storing the DLL in some computer-wide place, regardless on which project you are currently working on, I did not explore this route.

Screenshots:

I used this sample program to generate some interesting 128bit values. I did this for both, signed and unsigned.

#include <boost/int128.hpp>

int main()
{
	int idx;
	boost::int128::uint128_t numbers[12];

	idx = 0;

	// zero
	numbers[idx++ / 2].low  = 0x0000000000000000ull;
	numbers[idx++ / 2].high = 0x0000000000000000ull;

	// zero plus 42
	numbers[idx++ / 2].low  = 0x0000000000000000ull + 42;
	numbers[idx++ / 2].high = 0x0000000000000000ull;

	// (2^64)-1 minus 42
	numbers[idx++ / 2].low  = 0xffffffffffffffffull - 42;
	numbers[idx++ / 2].high = 0x0000000000000000ull;

	// (2^64)-1
	numbers[idx++ / 2].low  = 0xffffffffffffffffull;
	numbers[idx++ / 2].high = 0x0000000000000000ull;

	// 2^64
	numbers[idx++ / 2].low  = 0x0000000000000000ull;
	numbers[idx++ / 2].high = 0x0000000000000000ull + 1;

	// 2^64 plus 42
	numbers[idx++ / 2].low  = 0x0000000000000000ull + 42;
	numbers[idx++ / 2].high = 0x0000000000000000ull + 1;

	// (2^127)-1 minus 42
	numbers[idx++ / 2].low  = 0xffffffffffffffffull - 42;
	numbers[idx++ / 2].high = 0x7fffffffffffffffull;

	// (2^127)-1
	numbers[idx++ / 2].low  = 0xffffffffffffffffull;
	numbers[idx++ / 2].high = 0x7fffffffffffffffull;

	// 2^127
	numbers[idx++ / 2].low  = 0x0000000000000000ull;
	numbers[idx++ / 2].high = 0x8000000000000000ull;

	// 2^127 plus 42
	numbers[idx++ / 2].low  = 0x0000000000000000ull + 42;
	numbers[idx++ / 2].high = 0x8000000000000000ull;

	// (2^128)-1 minus 42
	numbers[idx++ / 2].low  = 0xffffffffffffffffull - 42;
	numbers[idx++ / 2].high = 0xffffffffffffffffull;

	// (2^128)-1
	numbers[idx++ / 2].low  = 0xffffffffffffffffull;
	numbers[idx++ / 2].high = 0xffffffffffffffffull;
}
version2-unsigned version2-signed

Visual Studio has a button in the IDE for switching HEX view on and off. Both the NATVIS visualizer and this DLL debugger add-in do not respect this button. So I added two what's called a view. Usage on screenshot below:

version2-views

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants