Nerixyz 91b90652bb
Reland "[CodeView] Generate S_DEFRANGE_REGISTER_REL_INDIR" (#189401)
Initially added in #187709. It was reverted in #188833, because
[llvm-clang-x86_64-sie-win](https://lab.llvm.org/buildbot/#/builders/46/builds/32873)
was failing in
`cross-project-tests/debuginfo-tests/dexter-tests/nrvo.cpp`.

The test passed for me locally. After checking on another machine, I
found that `S_DEFRANGE_REGISTER_REL_INDIR` is only supported by
dbgeng/WinDbg from Windows 10.0 Build 19041 (released 2020) onwards.
SDKs before this will fail to read the value. That buildbot is on
Windows 10.0 Build 17763.

I'm not sure if we should make the generation of that record
conditional. Debuggers that can't read the record will skip it. They'll
still see that there's some local variable, but won't be able to display
the value.

As far as I know, users of older Windows 10 builds should be able to
install a newer Windows SDK and use the WinDbg from that version. But I
haven't tested that.
2026-04-02 12:15:11 +02:00

41 lines
997 B
C++

// This ensures that DW_OP_deref is inserted when necessary, such as when NRVO
// of a string object occurs in C++.
//
// REQUIRES: system-windows, dbgeng-10-19041
//
// RUN: %clang_cl /Z7 /Zi %s -o %t
// RUN: %dexter --fail-lt 1.0 -w --binary %t --debugger 'dbgeng' -- %s
struct string {
string() {}
string(int i) : i(i) {}
~string() {}
int i = 0;
};
string get_string() {
string unused;
string result = 3;
return result; // DexLabel('readresult1')
}
void some_function(int) {}
struct string2 {
string2() = default;
string2(string2 &&other) { i = other.i; }
int i;
};
string2 get_string2() {
string2 result;
result.i = 5;
some_function(result.i);
// Test that the debugger can get the value of result after another
// function is called.
return result; // DexLabel('readresult2')
}
int main() {
get_string();
get_string2();
}
// DexExpectWatchValue('result.i', 3, on_line=ref('readresult1'))
// DexExpectWatchValue('result.i', 5, on_line=ref('readresult2'))