From 329b104182f7837538c6f779d14e51ba98baf0ef Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Mon, 14 Dec 2020 21:02:28 -0800 Subject: [PATCH] Standalone and Component Visualizers/VSIXes (#823) * Revert "Remove visualizer from vsix (#792)" This reverts commit d4635e3bb5add242c117c1bca0308ee131ef8932. * Reenabled standalone visualizer and forked component visualizer for VS installer integration * build component and standalone visualizers --- build_test_all.cmd | 3 +- build_vsix.cmd | 9 ++++- natvis/cppwinrtvisualizer.vcxproj | 21 ++++++----- natvis/object_visualizer.cpp | 56 ++++++++++++++++++++++++++--- vsix/UpgradeLog.htm | Bin 31708 -> 0 bytes vsix/source.extension.vsixmanifest | 2 ++ vsix/vsix.csproj | 40 ++++++++++----------- 7 files changed, 96 insertions(+), 35 deletions(-) delete mode 100644 vsix/UpgradeLog.htm diff --git a/build_test_all.cmd b/build_test_all.cmd index 50aab9b2..4529372f 100644 --- a/build_test_all.cmd +++ b/build_test_all.cmd @@ -22,7 +22,8 @@ if "%target_platform%"=="arm64" goto :eof call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:cppwinrt _build\%target_platform%\%target_configuration%\cppwinrt.exe -in local -out _build\%target_platform%\%target_configuration% -verbose -call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln +call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,Deployment=Component;CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln +call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,Deployment=Standalone;CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% test\nuget\NugetTest.sln call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test diff --git a/build_vsix.cmd b/build_vsix.cmd index 265c7c67..bfb47e23 100644 --- a/build_vsix.cmd +++ b/build_vsix.cmd @@ -3,14 +3,17 @@ set this_dir=%~dp0 set target_configuration=%1 set target_version=%2 +set target_deployment=%3 if "%target_configuration%"=="" set target_configuration=Release if "%target_version%"=="" set target_version=1.2.3.4 +if "%target_deployment%"=="" set target_deployment=Standalone if not exist ".\.nuget" mkdir ".\.nuget" if not exist ".\.nuget\nuget.exe" powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\.nuget\nuget.exe" call .nuget\nuget.exe restore cppwinrt.sln" +call .nuget\nuget.exe restore natvis\cppwinrtvisualizer.sln call .nuget\nuget.exe restore test\nuget\NugetTest.sln rem Build fast forwarder libs or all arches @@ -22,8 +25,12 @@ call msbuild /m /p:Configuration=%target_configuration%,Platform=arm64,CppWinRTB rem Build cppwinrt.exe for x86 only call msbuild /m /p:Configuration=%target_configuration%,Platform=x86,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:cppwinrt +rem Build cppwinrt visualizer dll for x86 and x64 +call msbuild /p:Configuration=%target_configuration%,Platform=x64,Deployment=%target_deployment%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln +call msbuild /p:Configuration=%target_configuration%,Platform=x86,Deployment=%target_deployment%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln + rem Build nuget .nuget\nuget.exe pack nuget\Microsoft.Windows.CppWinRT.nuspec -NonInteractive -OutputDirectory %this_dir%_build -Properties Configuration=%target_configuration%;cppwinrt_exe=%this_dir%_build\x86\%target_configuration%\cppwinrt.exe;cppwinrt_fast_fwd_x86=%this_dir%_build\x86\%target_configuration%\cppwinrt_fast_forwarder.lib;cppwinrt_fast_fwd_x64=%this_dir%_build\x64\%target_configuration%\cppwinrt_fast_forwarder.lib;cppwinrt_fast_fwd_arm=%this_dir%_build\arm\%target_configuration%\cppwinrt_fast_forwarder.lib;cppwinrt_fast_fwd_arm64=%this_dir%_build\arm64\%target_configuration%\cppwinrt_fast_forwarder.lib -version %target_version% -Verbosity Detailed rem Build vsix -call msbuild /p:Configuration=%target_configuration%,Platform=x86,CppWinRTVersion=%target_version%,NupkgDir=%this_dir%_build vsix\vsix.sln +call msbuild /p:Configuration=%target_configuration%,Platform=x86,Deployment=%target_deployment%,CppWinRTVersion=%target_version%,NatvisDirx86=%this_dir%natvis\x86\%target_configuration%\%target_deployment%,NatvisDirx64=%this_dir%natvis\x64\%target_configuration%\%target_deployment%,NupkgDir=%this_dir%_build vsix\vsix.sln diff --git a/natvis/cppwinrtvisualizer.vcxproj b/natvis/cppwinrtvisualizer.vcxproj index 6fb31734..72d68340 100644 --- a/natvis/cppwinrtvisualizer.vcxproj +++ b/natvis/cppwinrtvisualizer.vcxproj @@ -77,23 +77,23 @@ true - x86\$(Configuration)\ - x86\$(Configuration)\ + x86\$(Configuration)\$(Deployment)\ + x86\$(Configuration)\$(Deployment)\ true - x64\$(Configuration)\ - x64\$(Configuration)\ + x64\$(Configuration)\$(Deployment)\ + x64\$(Configuration)\$(Deployment)\ false - x86\$(Configuration)\ - x86\$(Configuration)\ + x86\$(Configuration)\$(Deployment)\ + x86\$(Configuration)\$(Deployment)\ false - x64\$(Configuration)\ - x64\$(Configuration)\ + x64\$(Configuration)\$(Deployment)\ + x64\$(Configuration)\$(Deployment)\ @@ -204,6 +204,11 @@ vsdebugeng.dll + + + %(AdditionalOptions) /DCOMPONENT_DEPLOYMENT + + diff --git a/natvis/object_visualizer.cpp b/natvis/object_visualizer.cpp index b26e9108..9b9352f5 100644 --- a/natvis/object_visualizer.cpp +++ b/natvis/object_visualizer.cpp @@ -211,9 +211,14 @@ static HRESULT ObjectToString( _In_ DkmVisualizedExpression* pExpression, _In_ DkmPointerValueHome* pObject, bool isAbiObject, - _Out_ com_ptr& pValue + _Out_ com_ptr& pValue, + bool* unavailable = nullptr ) { + if (unavailable) + { + *unavailable = false; + } if (SUCCEEDED(EvaluatePropertyString({ IID_IStringable, 0, PropertyCategory::String }, pExpression, pObject, isAbiObject, pValue))) { if (pValue && pValue->Length() > 0) @@ -232,6 +237,10 @@ static HRESULT ObjectToString( // VirtualQuery validation failed (as determined by no runtime class name) or an // exception escaped WINRT_abi_val (e.g, bad pointer, which we try to avoid via VirtualQuery) + if (unavailable) + { + *unavailable = true; + } return DkmString::Create(L"", pValue.put()); } @@ -534,18 +543,55 @@ HRESULT object_visualizer::CreateEvaluationResult(_In_ DkmVisualizedExpression* return S_OK; } +#ifdef COMPONENT_DEPLOYMENT +static std::set g_refresh_cache; +bool requires_refresh(UINT64 address, DkmEvaluationFlags_t evalFlags) +{ + auto refreshed = g_refresh_cache.find(address) != g_refresh_cache.end(); + return !refreshed && ((evalFlags & DkmEvaluationFlags::EnableExtendedSideEffects) != DkmEvaluationFlags::EnableExtendedSideEffects); +} +void cache_refresh(UINT64 address) +{ + g_refresh_cache.insert(address); +} +#else +bool requires_refresh(UINT64, DkmEvaluationFlags_t) +{ + return false; +} +void cache_refresh(UINT64) +{ +} +#endif + HRESULT object_visualizer::CreateEvaluationResult(_Deref_out_ DkmEvaluationResult** ppResultObject) { com_ptr pRootVisualizedExpression = m_pVisualizedExpression.as(); auto valueHome = make_com_ptr(m_pVisualizedExpression->ValueHome()); com_ptr pPointerValueHome = valueHome.as(); - + auto address = pPointerValueHome->Address(); + com_ptr pValue; - IF_FAIL_RET(ObjectToString(m_pVisualizedExpression.get(), pPointerValueHome.get(), m_isAbiObject, pValue)); + DkmEvaluationResultFlags_t evalResultFlags = DkmEvaluationResultFlags::ReadOnly; + if (requires_refresh(address, m_pVisualizedExpression->InspectionContext()->EvaluationFlags())) + { + IF_FAIL_RET(DkmString::Create(L"", pValue.put())); + evalResultFlags |= DkmEvaluationResultFlags::EnableExtendedSideEffectsUponRefresh | DkmEvaluationResultFlags::CanEvaluateNow; + } + else + { + cache_refresh(address); + bool unavailable; + IF_FAIL_RET(ObjectToString(m_pVisualizedExpression.get(), pPointerValueHome.get(), m_isAbiObject, pValue, &unavailable)); + if (!unavailable) + { + evalResultFlags |= DkmEvaluationResultFlags::Expandable; + } + } com_ptr pAddress; - IF_FAIL_RET(DkmDataAddress::Create(m_pVisualizedExpression->StackFrame()->RuntimeInstance(), pPointerValueHome->Address(), nullptr, pAddress.put())); + IF_FAIL_RET(DkmDataAddress::Create(m_pVisualizedExpression->StackFrame()->RuntimeInstance(), address, nullptr, pAddress.put())); com_ptr pSuccessEvaluationResult; IF_FAIL_RET(DkmSuccessEvaluationResult::Create( @@ -553,7 +599,7 @@ HRESULT object_visualizer::CreateEvaluationResult(_Deref_out_ DkmEvaluationResul m_pVisualizedExpression->StackFrame(), pRootVisualizedExpression->Name(), pRootVisualizedExpression->FullName(), - DkmEvaluationResultFlags::Expandable | DkmEvaluationResultFlags::ReadOnly, + evalResultFlags, pValue.get(), pValue.get(), pRootVisualizedExpression->Type(), diff --git a/vsix/UpgradeLog.htm b/vsix/UpgradeLog.htm deleted file mode 100644 index df1295ddad40fc4f2536c1e0654eff5b36931d96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31708 zcmeI5`BNLolE?ek-H81kG-ltJS%w>P*w3C2LSW2cE`!bU#0x;&;xOW#dHbjD?&n)c zQQa-ksKw#;VjT*pyQ{0R@~X_Ntm@YP{?A{dpQ5qoV^oTkqA$^0RE`SKPIMX_MAhhB z^dHf`N2<}urx4Ymwdg$Bj4GUOMJLe_wF=Q0XVvI!)E@Ql>5T@WU#Pdv-8104j&`F% zj+@jvof@ZJ_K=-{BqD$B7A^p7Otj2ZCL4M)-IHa@|ZBT!cyK9_xa@?gvnAG@g z0lkxJ;r05a^=b5izSPSmZ7S~kz~Qk5CaP=L>Gv&lH@WVlzZ&PpiPPwqlFjHFrMu9t zTBSt0&S)CghtW1Q*7)6YZM*O7OI*36-|kx;ym2_~0ObS>#I3i$JcY7OI6IgNr={o$ z%;UJ6g8wNT-K3Ylb3B6nNu(brl62McuA^^(t7FbiXw^gCUS?C0j`H-LA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R0 z&xM)hu{x$92vdV?N8hFkJd{gQZ+os~yk43TpF=8P1#Dy~{;fDHvak$tm!9^zemtfR z>F*s`k2uv2ftAb;v^km@L(eDm;X8!J74$l738B^;)C74;tOd0q8%cWC2=@)fLMmrEP28$$4jd z_sbinw~a?w&|95(n{RS8->LH*_FdL{$TS{BXso0>j;v_hZ>HOX46L^|_P&{#(+>5k z{?lGO8Iftus#>y$eg$3}_Vz5;(jE3vzPl}#CR>U8Z=7~n+7L5%IB`$7fDH7{G3wWQ zRBzr>xOeBvtUVY>TTsa^i}b!^zxXGjaWrI{=fJxxUW&{ z_bO@TkoK`j`l58-20lequIajD9lbIU+d3j z6T=)w*#PZ8751jR_I9@96Z+ak;a3yvZP|=#N&ma#owtj}D1Gx5vuSE|wnmsq(QmYSM3{Y3^!_mLrtg$MhMG+vHqpb84&I+~$LW%uM%9kAm*&EIz8!_91PHf>z2Z)Q`(#EIsBV z;djpX%x2t1+~qx+u{mkn;&A_UZBNo-869!Te6BA|{rwhcl98hklodu6Js$Cy5 + + diff --git a/vsix/vsix.csproj b/vsix/vsix.csproj index d0536f3d..9279dee1 100644 --- a/vsix/vsix.csproj +++ b/vsix/vsix.csproj @@ -9,7 +9,7 @@ true - bin\x86\Debug\ + bin\x86\Debug\$(Deployment)\ DEBUG;TRACE full x86 @@ -17,7 +17,7 @@ MinimumRecommendedRules.ruleset - bin\x86\Release\ + bin\x86\Release\$(Deployment)\ TRACE true pdbonly @@ -46,24 +46,6 @@ false false - - true - full - false - bin\Debug\$(Deployment)\ - DEBUG;TRACE - prompt - 4 - False - - - pdbonly - true - bin\Release\$(Deployment)\ - TRACE - prompt - 4 - true @@ -108,6 +90,22 @@ Packages\Microsoft.Windows.CppWinRT.$(CppWinRTVersion).nupkg true + + %(Filename)%(Extension) + true + + + %(Filename)%(Extension) + true + + + x86\%(Filename)%(Extension) + true + + + x64\%(Filename)%(Extension) + true + Designer @@ -139,6 +137,8 @@ + +