[Lldb-commits] [PATCH] D29964: Finish breaking the dependency from lldbUtility -> Host
Zachary Turner via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 14 14:23:30 PST 2017
zturner created this revision.
Herald added subscribers: mgorny, srhines, danalbert.
This patch finally gets `lldbUtility` to be dependency-free. This was done through the following changes:
1. `PseudoTerminal.cpp` : `Utility` -> `Host`
2. Introduce a `vasprintf` / `vsnprintf` wrapper into utility, and standardize all callers inside of `Utility` to use this.
With the introduction of #2, we should eventually purge all uses of `vsnprintf` and `vasprintf` from the code and instead rely on `VASprintf` inside of Utility. It is less error prone and more efficient than doing it manually. Unit tests are provided to ensure its correctness, and in writing these unit tests 2 bugs were uncovered in the original implementation, both fixed. (Long term, of course, I would prefer moving to formatv, but in any case, using `lldb_private::VASprintf` for now is better than using `vasprintf` / `vsnprintf`.
After this patch, `UtilityTests` no longer links against any library other than `lldbUtility`, as evidenced by the following:
D:\src\llvmbuild\ninja-mono>ninja -nv UtilityTests
[1/1] cmd.exe /C "cd . && "C:\Program Files (x86)\CMake\bin\cmake.exe" -E vs_link_exe --intdir=tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir --manifests -- C:\PROGRA~2\MICROS~1.0\VC\bin\AMD64_~2\link.exe /nologo tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir\ConstStringTest.cpp.obj tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir\StringExtractorTest.cpp.obj tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir\TaskPoolTest.cpp.obj tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir\TimeoutTest.cpp.obj tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir\UriParserTest.cpp.obj tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir\VASprintfTest.cpp.obj tools\lldb\unittests\Utility\CMakeFiles\UtilityTests.dir\D_\src\llvm-mono\llvm\resources\windows_version_resource.rc.res /out:tools\lldb\unittests\Utility\UtilityTests.exe /implib:tools\lldb\unittests\Utility\UtilityTests.lib /pdb:tools\lldb\unittests\Utility\UtilityTests.pdb /version:0.0 /machine:X86 /STACK:10000000 /debug /INCREMENTAL /subsystem:console lib\LLVMSupport.lib lib\LLVMSupport.lib lib\gtest_main.lib lib\gtest.lib lib\lldbUtility.lib ws2_32.lib rpcrt4.lib lib\LLVMSupport.lib psapi.lib shell32.lib ole32.lib uuid.lib lib\LLVMDemangle.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D D:\src\llvmbuild\ninja-mono\tools\lldb\unittests\Utility && "C:\Program Files (x86)\CMake\bin\cmake.exe" -E make_directory D:/src/llvmbuild/ninja-mono/tools/lldb/unittests/Utility/Inputs""
and I confirmed that introducing a dependency from Utility -> Host causes a linker failure.
lldbUtility.lib(VASprintf.cpp.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl lldb_private::HostInfoWindows::Initialize(void)" (?Initialize at HostInfoWindows@lldb_private@@SAXXZ) referenced in function "void __cdecl lldb_private::VASprintf(class llvm::SmallVectorImpl<char> &,char const *,char *)" (?VASprintf at lldb_private@@YAXAAV?$SmallVectorImpl at D@llvm@@PBDPAD at Z)
https://reviews.llvm.org/D29964
Files:
lldb/include/lldb/Host/PseudoTerminal.h
lldb/include/lldb/Utility/PseudoTerminal.h
lldb/include/lldb/Utility/VASPrintf.h
lldb/source/Host/CMakeLists.txt
lldb/source/Host/common/PseudoTerminal.cpp
lldb/source/Utility/CMakeLists.txt
lldb/source/Utility/Error.cpp
lldb/source/Utility/PseudoTerminal.cpp
lldb/source/Utility/Stream.cpp
lldb/source/Utility/VASprintf.cpp
lldb/unittests/Utility/CMakeLists.txt
lldb/unittests/Utility/VASprintfTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29964.88434.patch
Type: text/x-patch
Size: 55185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170214/e686ae84/attachment-0001.bin>
More information about the lldb-commits
mailing list