Reputation: 37512
I have a large C++ CMake project where a crash reporter is used. The problem is that when a crash is reported, the exact line numbers in the report are not included. So instead of having a nice line number in the call stack, I see something like this:
0000008e`ccffee18 00007ff7`254497ab MyProduct!`anonymous namespace'::abortHandler
0000008e`ccffee20 00007ff7`25454bfc MyProduct!raise+0x227
0000008e`ccffee90 00007ff7`2511a7ba MyProduct!abort+0x18
(Inline Function) --------`-------- MyProduct!utils::levelDb::Database::fatalFailure+0x2d6
0000008e`ccffeec0 00007ff7`2506f231 MyProduct!utils::levelDb::Database::repair+0x44a
(Inline Function) --------`-------- MyProduct!utils::levelDb::Database::{ctor}+0xd1
0000008e`ccfff040 00007ff7`25077bd8 MyProduct!std::make_unique<utils::levelDb::Database,IReporting * &,boost::filesystem::path,0>+0x141
0000008e`ccfff100 00007ff7`25078712 MyProduct!`anonymous namespace'::openMetadataDb+0x118
0000008e`ccfff1c0 00007ff7`24f5b75b MyProduct!LevelDbModuleCache::LevelDbModuleCache+0x1e2
It would be nicer to see the exact file and line numbers in these reports instead of just the function name and some offset.
I’ve found this solution to this problem. It seems reasonable. Sadly, it doesn’t work for me. Invoking this command still doesn’t report that the source index is included in the pdb file.
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\srcsrv\pdbstr.exe" -r -p:MyProduct.pdb -s:srcsrv -i:srcsrv
Output is empty and ERRORLEVEL
is 1
. AFAIK this should print lots of data when source index is available.
I've verified that flags are properly set. In build logs I can see something like this:
cmake --build . --config Release -v -j 4
....
18>ClCompile:
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\CL.exe /c
/IF:\repos\MyProduct\Src\CMake\..\..\..\.. /IF:\repos\MyProduct\Src\SomePart1
/IF:\repos\MyProduct\Src\CMake\..\..\..\..\Shared\Library\set_nod /IF:\repos\MyProduct\Src\CommonPart
/IF:\repos\MyProduct\Src\CommonPart\.. /I"F:\repos\MyProduct\Src\CommonPart\..\3rdparty\MariaDB ConnectorC\include"
/IF:\repos\MyProduct\Src\build_64\CommonPart /IF:\repos\MyProduct\Src\build_64\CommonPart\..
/IF:\repos\MyProduct\Src\build_64\CommonPart\mc /IF:\repos\MyProduct\Src\build_64\CommonPart\SqlStatements
/IF:\repos\MyProduct\Src\build_64\CommonPart\Localization
/IF:\repos\MyProduct\Src\build_64\CommonPart\DatabaseUpdater\sourceFiles
/IF:\repos\MyProduct\Src\build_64\CommonPart\EsetProtectIntegration\gRPC
/IF:\repos\MyProduct\Src\build_64\CommonPart\EpxIntegration\gRPC /IF:\repos\MyProduct\Src\CMake\..\..\..\..\Shared\Library
/IF:\repos\MyProduct\Src\CommonPart2 /IF:\repos\MyProduct\Src\CommonPart2\.. /Zi /nologo /W2 /WX- /diagnostics:column /MP /O2
/Ob2 /Oi /GL /D _UNICODE /D UNICODE /D WIN32 /D _WINDOWS /D NDEBUG /D _UPDATER_STATIC_LIB /D UNICODE /D _UNICODE /D _CONSOLE
/D STRICT /D _SCL_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING /D
_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING /D _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING /D
_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING /D DONT_DISABLE_EXCEPTION_HANDLING /D _NOD_WINDOWS_API /D _NOD_DLL_WRAPPERS /D
DONT_USE_SRC_PRODUCTS /D NODCOMM_NO_NFC_PUMP /D AVVENDOR /D BOOST_DATE_TIME_NO_LIB /D BOOST_REGEX_NO_LIB /D PR_WINDOWS /D
"_NOD_FILE_VERSION=2,3,4253" /D _LIB /D NODCOMM_LEGACY /D ZLIB_CONST /D _ALLOW_DLL_MODULES /D AUTHENTICODE_MSI_SUPPORT /D
UPDATER_DLL_MODULES /D FMT_HEADER_ONLY=1 /D CARES_STATICLIB /D PUGIXML_WCHAR_MODE /D "CMAKE_INTDIR=\"Release\"" /Gm- /EHsc /MT
/GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /std:c++20 /permissive-
/Yu"F:/MyProduct/build_64/SomePart1/CMakeFiles/SomePart1.dir/Release/cmake_pch.hxx"
/Fp"F:/MyProduct/build_64/SomePart1/SomePart1.dir/Release/cmake_pch.pch" /Fo"SomePart1.dir\Release\\"
/Fd"SomePart1.dir\Release\vc143.pdb" /external:W0 /Gd /TP
/FIF:/MyProduct/build_64/SomePart1/CMakeFiles/SomePart1.dir/Release/cmake_pch.hxx /errorReport:queue /external:I
"F:/MyProduct/build_64/vcpkg_installed/x64-windows-static/include" /external:I
"F:/MyProduct/build_64/vcpkg_installed/x64-windows-static/include/httpxx" /w15038 /execution-charset:utf-8
F:\repos\MyProduct\Src\SomePart1\win\Service.cpp
....
18>ResourceCompile:
All outputs are up-to-date.
Link:
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\link.exe
/ERRORREPORT:QUEUE /OUT:"F:\MyPorduct\x64\Release\SomePart.exe" /INCREMENTAL:NO /NOLOGO
F:\MyPorduct\x64\Release\CommonPart1.lib F:\MyPorduct\x64\Release\CommonPart2.lib F:\MyPorduct\x64\Release\CommonPart1.lib
"..\vcpkg_installed\x64-windows-static\lib\grpc++.lib" "..\vcpkg_installed\x64-windows-static\lib\grpc.lib"
"..\vcpkg_installed\x64-windows-static\lib\gpr.lib" "..\vcpkg_installed\x64-windows-static\lib\absl_random_distributions.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_seed_sequences.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_internal_pool_urbg.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_internal_randen.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_internal_randen_hwaes.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_internal_randen_hwaes_impl.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_internal_randen_slow.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_internal_platform.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_internal_seed_material.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_random_seed_gen_exception.lib"
"..\vcpkg_installed\x64-windows-static\lib\upb.lib" "..\vcpkg_installed\x64-windows-static\lib\cares.lib"
"..\vcpkg_installed\x64-windows-static\lib\address_sorting.lib" "..\vcpkg_installed\x64-windows-static\lib\re2.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_raw_hash_set.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_hashtablez_sampler.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_hash.lib" "..\vcpkg_installed\x64-windows-static\lib\absl_city.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_low_level_hash.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_statusor.lib" "..\vcpkg_installed\x64-windows-static\lib\absl_status.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_cord.lib" "..\vcpkg_installed\x64-windows-static\lib\absl_cordz_info.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_cord_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_cordz_functions.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_exponential_biased.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_cordz_handle.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_synchronization.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_graphcycles_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_time.lib" "..\vcpkg_installed\x64-windows-static\lib\absl_civil_time.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_time_zone.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_str_format_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_bad_optional_access.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_stacktrace.lib" "..\vcpkg_installed\x64-windows-static\lib\absl_strerror.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_symbolize.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_malloc_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_debugging_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_demangle_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_strings.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_strings_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_base.lib" "..\vcpkg_installed\x64-windows-static\lib\absl_spinlock_wait.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_int128.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_bad_variant_access.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_throw_delegate.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_raw_logging_internal.lib"
"..\vcpkg_installed\x64-windows-static\lib\absl_log_severity.lib" "-ignore:4221" wsock32.lib gdi32.lib
"..\vcpkg_installed\x64-windows-static\lib\pugixml.lib" F:\MyPorduct\x64\Release\updater.lib Mpr.lib Msi.lib
"..\vcpkg_installed\x64-windows-static\lib\boost_url-vc140-mt.lib" "..\vcpkg_installed\x64-windows-static\lib\gtest.lib"
"..\vcpkg_installed\x64-windows-static\lib\httpxx.lib" "..\vcpkg_installed\x64-windows-static\lib\leveldb.lib"
"..\vcpkg_installed\x64-windows-static\lib\libssl.lib" "..\vcpkg_installed\x64-windows-static\lib\sigar.lib"
"..\vcpkg_installed\x64-windows-static\lib\boost_filesystem-vc140-mt.lib"
"..\vcpkg_installed\x64-windows-static\lib\boost_program_options-vc140-mt.lib"
"..\vcpkg_installed\x64-windows-static\lib\boost_regex-vc140-mt.lib"
"..\vcpkg_installed\x64-windows-static\lib\boost_system-vc140-mt.lib" "..\vcpkg_installed\x64-windows-static\lib\gmock.lib"
"..\vcpkg_installed\x64-windows-static\lib\libcrypto.lib" "F:\MyPorduct\x64\Release\shared-library.lib"
"..\vcpkg_installed\x64-windows-static\lib\libprotobuf.lib" "..\vcpkg_installed\x64-windows-static\lib\zlib.lib" Tdh.lib
/MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG
/PDB:"F:/MyPorduct/x64/Release/SomePart.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG:incremental
/LTCGOUT:"SomePart.dir\Release\SomePart.iobj" /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"F:/MyPorduct/x64/Release/SomePart.lib"
/MACHINE:X64 /machine:x64 SomePart.dir\Release\Resource.res
....
So all recommended flags are visible in logs, so it should work.
Why doesn't the command pdbstr.exe ...
print anything? Am I using this tool correctly to verify that I've fixed the missing source index problem?
If I am using this tool correctly, why doesn't adding compilation and link flags resolve the issue? Should I use different flags? Is there an interaction with other flags that overrides something?
Or am I making some other mistake that I haven't thought of?
Upvotes: 1
Views: 60