[Lldb-commits] [PATCH] D42336: Fix memory leaks in TestArm64InstEmulation
teemperor created this revision. teemperor added a reviewer: jasonmolenda. Herald added subscribers: kristof.beyls, javed.absar, aemerson. We never delete the created instances, so those test fail with the memory sanitizer. https://reviews.llvm.org/D42336 Files: unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp Index: unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp === --- unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp +++ unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp @@ -56,9 +56,9 @@ TEST_F(TestArm64InstEmulation, TestSimpleDarwinFunction) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -152,9 +152,9 @@ TEST_F(TestArm64InstEmulation, TestMediumDarwinFunction) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -314,9 +314,9 @@ TEST_F(TestArm64InstEmulation, TestFramelessThreeEpilogueFunction) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -409,9 +409,9 @@ TEST_F(TestArm64InstEmulation, TestRegisterSavedTwice) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -511,9 +511,9 @@ TEST_F(TestArm64InstEmulation, TestRegisterDoubleSpills) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; Index: unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp === --- unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp +++ unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp @@ -56,9 +56,9 @@ TEST_F(TestArm64InstEmulation, TestSimpleDarwinFunction) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -152,9 +152,9 @@ TEST_F(TestArm64InstEmulation, TestMediumDarwinFunction) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -314,9 +314,9 @@ TEST_F(TestArm64InstEmulation, TestFramelessThreeEpilogueFunction) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -409,9 +409,9 @@ TEST_F(TestArm64InstEmulation, TestRegisterSavedTwice) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; @@ -511,9 +511,9 @@ TEST_F(TestArm64InstEmulation, TestRegisterDoubleSpills) { ArchSpec arch("arm64-apple-ios10"); - UnwindAssemblyInstEmulation *engine = + std::unique_ptr engine( static_cast( - UnwindAssemblyInstEmulation::CreateInstance(arch)); + UnwindAssemblyInstEmulation::CreateInstance(arch))); ASSERT_NE(nullptr, engine); UnwindPlan::RowSP row_sp; ___ lldb-commits mailing list lldb-commits@lists.llvm.org htt
[Lldb-commits] [PATCH] D42338: Fix unrepresentable float value in ScalarTest
teemperor created this revision. teemperor added a reviewer: uweigand. float can't represent the given value in the literal, so we get this UB error: `runtime error: 1.23457e+48 is outside the range of representable values of type 'float'`. The test seems to not rely on this specific value, so let's just choose a smaller one that can be represented. https://reviews.llvm.org/D42338 Files: unittests/Core/ScalarTest.cpp Index: unittests/Core/ScalarTest.cpp === --- unittests/Core/ScalarTest.cpp +++ unittests/Core/ScalarTest.cpp @@ -31,7 +31,7 @@ TEST(ScalarTest, GetBytes) { int a = 0x01020304; long long b = 0x0102030405060708LL; - float c = 1234567.89e42; + float c = 1234567.89e32; double d = 1234567.89e42; char e[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; char f[32] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, Index: unittests/Core/ScalarTest.cpp === --- unittests/Core/ScalarTest.cpp +++ unittests/Core/ScalarTest.cpp @@ -31,7 +31,7 @@ TEST(ScalarTest, GetBytes) { int a = 0x01020304; long long b = 0x0102030405060708LL; - float c = 1234567.89e42; + float c = 1234567.89e32; double d = 1234567.89e42; char e[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; char f[32] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42339: Fix uninitialized variable in GoParser
teemperor created this revision. teemperor added a reviewer: ribrdb. teemperor edited the summary of this revision. `m_last_tok` isn't initialized anywhere before it's used the first time (most likely in the `GoParser::Rule::error` method), which causes most of the GoParser tests to fail with sanitizers enabled with errors like this: GoParser.cpp:52:21: runtime error: load of value , which is not a valid value for type 'GoLexer::TokenType' UndefinedBehaviorSanitizer: undefined-behavior GoParser.cpp:52:21 https://reviews.llvm.org/D42339 Files: source/Plugins/ExpressionParser/Go/GoParser.cpp Index: source/Plugins/ExpressionParser/Go/GoParser.cpp === --- source/Plugins/ExpressionParser/Go/GoParser.cpp +++ source/Plugins/ExpressionParser/Go/GoParser.cpp @@ -67,7 +67,9 @@ size_t m_pos; }; -GoParser::GoParser(const char *src) : m_lexer(src), m_pos(0), m_failed(false) {} +GoParser::GoParser(const char *src) +: m_lexer(src), m_pos(0), m_last_tok(GoLexer::TOK_INVALID), + m_failed(false) {} GoASTStmt *GoParser::Statement() { Rule r("Statement", this); Index: source/Plugins/ExpressionParser/Go/GoParser.cpp === --- source/Plugins/ExpressionParser/Go/GoParser.cpp +++ source/Plugins/ExpressionParser/Go/GoParser.cpp @@ -67,7 +67,9 @@ size_t m_pos; }; -GoParser::GoParser(const char *src) : m_lexer(src), m_pos(0), m_failed(false) {} +GoParser::GoParser(const char *src) +: m_lexer(src), m_pos(0), m_last_tok(GoLexer::TOK_INVALID), + m_failed(false) {} GoASTStmt *GoParser::Statement() { Rule r("Statement", this); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42340: [modules] Fix missing includes/typo in LLDB's includes. [NFC]
teemperor created this revision. teemperor added a reviewer: aprantl. This patch adds missing includes to the LLDB headers inside `include/` as a first step of building LLDB's source with C++ modules. Includes in lldb seem to be commented if the reason for the include is not obvious (`// for addr_t`), so I tried to keep the same style here. It also fixes this single `stds::` typo. https://reviews.llvm.org/D42340 Files: include/lldb/Core/LoadedModuleInfoList.h include/lldb/Core/ThreadSafeDenseSet.h include/lldb/Core/ThreadSafeValue.h include/lldb/DataFormatters/VectorIterator.h include/lldb/Target/ProcessStructReader.h include/lldb/Utility/AnsiTerminal.h include/lldb/Utility/SharedCluster.h Index: include/lldb/Utility/SharedCluster.h === --- include/lldb/Utility/SharedCluster.h +++ include/lldb/Utility/SharedCluster.h @@ -15,6 +15,8 @@ #include "llvm/ADT/SmallPtrSet.h" +#include + namespace lldb_private { namespace imp { Index: include/lldb/Utility/AnsiTerminal.h === --- include/lldb/Utility/AnsiTerminal.h +++ include/lldb/Utility/AnsiTerminal.h @@ -50,6 +50,7 @@ #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" Index: include/lldb/Target/ProcessStructReader.h === --- include/lldb/Target/ProcessStructReader.h +++ include/lldb/Target/ProcessStructReader.h @@ -16,6 +16,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Status.h" Index: include/lldb/DataFormatters/VectorIterator.h === --- include/lldb/DataFormatters/VectorIterator.h +++ include/lldb/DataFormatters/VectorIterator.h @@ -13,6 +13,7 @@ #include "lldb/lldb-forward.h" +#include "lldb/DataFormatters/TypeSynthetic.h" // for SyntheticChildrenFrontEnd #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ConstString.h" Index: include/lldb/Core/ThreadSafeValue.h === --- include/lldb/Core/ThreadSafeValue.h +++ include/lldb/Core/ThreadSafeValue.h @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes +#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN namespace lldb_private { Index: include/lldb/Core/ThreadSafeDenseSet.h === --- include/lldb/Core/ThreadSafeDenseSet.h +++ include/lldb/Core/ThreadSafeDenseSet.h @@ -46,7 +46,7 @@ } void Clear() { -stds::lock_guard<_MutexType> guard(m_mutex); +std::lock_guard<_MutexType> guard(m_mutex); m_set.clear(); } Index: include/lldb/Core/LoadedModuleInfoList.h === --- include/lldb/Core/LoadedModuleInfoList.h +++ include/lldb/Core/LoadedModuleInfoList.h @@ -13,10 +13,13 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes +#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS #include "lldb/lldb-private-forward.h" +#include "lldb/lldb-types.h" // for addr_t namespace lldb_private { class LoadedModuleInfoList { Index: include/lldb/Utility/SharedCluster.h === --- include/lldb/Utility/SharedCluster.h +++ include/lldb/Utility/SharedCluster.h @@ -15,6 +15,8 @@ #include "llvm/ADT/SmallPtrSet.h" +#include + namespace lldb_private { namespace imp { Index: include/lldb/Utility/AnsiTerminal.h === --- include/lldb/Utility/AnsiTerminal.h +++ include/lldb/Utility/AnsiTerminal.h @@ -50,6 +50,7 @@ #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" Index: include/lldb/Target/ProcessStructReader.h === --- include/lldb/Target/ProcessStructReader.h +++ include/lldb/Target/ProcessStructReader.h @@ -16,6 +16,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Status.h" Index: include/lldb/DataFormatters/VectorIterator.h === --- include/lldb/DataFormatters/Vec
Re: [Lldb-commits] [PATCH] D42340: [modules] Fix missing includes/typo in LLDB's includes. [NFC]
The comments were automatically added a long time ago when I tried to run IWYU on LLDB source code. I don't think you need to maintain them. On Sat, Jan 20, 2018 at 2:25 PM Raphael Isemann via Phabricator via lldb-commits wrote: > teemperor created this revision. > teemperor added a reviewer: aprantl. > > This patch adds missing includes to the LLDB headers inside `include/` as > a first step of building LLDB's source with C++ modules. Includes in lldb > seem to be commented if the reason for the include is not obvious (`// for > addr_t`), so I tried to keep the same style here. It also fixes this single > `stds::` typo. > > > https://reviews.llvm.org/D42340 > > Files: > include/lldb/Core/LoadedModuleInfoList.h > include/lldb/Core/ThreadSafeDenseSet.h > include/lldb/Core/ThreadSafeValue.h > include/lldb/DataFormatters/VectorIterator.h > include/lldb/Target/ProcessStructReader.h > include/lldb/Utility/AnsiTerminal.h > include/lldb/Utility/SharedCluster.h > > > Index: include/lldb/Utility/SharedCluster.h > === > --- include/lldb/Utility/SharedCluster.h > +++ include/lldb/Utility/SharedCluster.h > @@ -15,6 +15,8 @@ > > #include "llvm/ADT/SmallPtrSet.h" > > +#include > + > namespace lldb_private { > > namespace imp { > Index: include/lldb/Utility/AnsiTerminal.h > === > --- include/lldb/Utility/AnsiTerminal.h > +++ include/lldb/Utility/AnsiTerminal.h > @@ -50,6 +50,7 @@ > #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END > #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END > > +#include "llvm/ADT/ArrayRef.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/ADT/StringRef.h" > > Index: include/lldb/Target/ProcessStructReader.h > === > --- include/lldb/Target/ProcessStructReader.h > +++ include/lldb/Target/ProcessStructReader.h > @@ -16,6 +16,7 @@ > #include "lldb/Symbol/CompilerType.h" > #include "lldb/Target/Process.h" > #include "lldb/Utility/ConstString.h" > +#include "lldb/Utility/DataBufferHeap.h" > #include "lldb/Utility/DataExtractor.h" > #include "lldb/Utility/Status.h" > > Index: include/lldb/DataFormatters/VectorIterator.h > === > --- include/lldb/DataFormatters/VectorIterator.h > +++ include/lldb/DataFormatters/VectorIterator.h > @@ -13,6 +13,7 @@ > > #include "lldb/lldb-forward.h" > > +#include "lldb/DataFormatters/TypeSynthetic.h" // for > SyntheticChildrenFrontEnd > #include "lldb/Target/ExecutionContext.h" > #include "lldb/Utility/ConstString.h" > > Index: include/lldb/Core/ThreadSafeValue.h > === > --- include/lldb/Core/ThreadSafeValue.h > +++ include/lldb/Core/ThreadSafeValue.h > @@ -17,6 +17,7 @@ > > // Other libraries and framework includes > // Project includes > +#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN > > namespace lldb_private { > > Index: include/lldb/Core/ThreadSafeDenseSet.h > === > --- include/lldb/Core/ThreadSafeDenseSet.h > +++ include/lldb/Core/ThreadSafeDenseSet.h > @@ -46,7 +46,7 @@ >} > >void Clear() { > -stds::lock_guard<_MutexType> guard(m_mutex); > +std::lock_guard<_MutexType> guard(m_mutex); > m_set.clear(); >} > > Index: include/lldb/Core/LoadedModuleInfoList.h > === > --- include/lldb/Core/LoadedModuleInfoList.h > +++ include/lldb/Core/LoadedModuleInfoList.h > @@ -13,10 +13,13 @@ > // C Includes > > // C++ Includes > +#include > #include > > // Other libraries and framework includes > +#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS > #include "lldb/lldb-private-forward.h" > +#include "lldb/lldb-types.h" // for addr_t > > namespace lldb_private { > class LoadedModuleInfoList { > > > ___ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42340: [modules] Fix missing includes/typo in LLDB's includes. [NFC]
teemperor updated this revision to Diff 130784. teemperor added a comment. - Ditched the commented includes. https://reviews.llvm.org/D42340 Files: include/lldb/Core/LoadedModuleInfoList.h include/lldb/Core/ThreadSafeDenseSet.h include/lldb/Core/ThreadSafeValue.h include/lldb/DataFormatters/VectorIterator.h include/lldb/Target/ProcessStructReader.h include/lldb/Utility/AnsiTerminal.h include/lldb/Utility/SharedCluster.h Index: include/lldb/Utility/SharedCluster.h === --- include/lldb/Utility/SharedCluster.h +++ include/lldb/Utility/SharedCluster.h @@ -15,6 +15,8 @@ #include "llvm/ADT/SmallPtrSet.h" +#include + namespace lldb_private { namespace imp { Index: include/lldb/Utility/AnsiTerminal.h === --- include/lldb/Utility/AnsiTerminal.h +++ include/lldb/Utility/AnsiTerminal.h @@ -50,6 +50,7 @@ #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" Index: include/lldb/Target/ProcessStructReader.h === --- include/lldb/Target/ProcessStructReader.h +++ include/lldb/Target/ProcessStructReader.h @@ -16,6 +16,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Status.h" Index: include/lldb/DataFormatters/VectorIterator.h === --- include/lldb/DataFormatters/VectorIterator.h +++ include/lldb/DataFormatters/VectorIterator.h @@ -13,6 +13,7 @@ #include "lldb/lldb-forward.h" +#include "lldb/DataFormatters/TypeSynthetic.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ConstString.h" Index: include/lldb/Core/ThreadSafeValue.h === --- include/lldb/Core/ThreadSafeValue.h +++ include/lldb/Core/ThreadSafeValue.h @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes +#include "lldb/lldb-defines.h" namespace lldb_private { Index: include/lldb/Core/ThreadSafeDenseSet.h === --- include/lldb/Core/ThreadSafeDenseSet.h +++ include/lldb/Core/ThreadSafeDenseSet.h @@ -46,7 +46,7 @@ } void Clear() { -stds::lock_guard<_MutexType> guard(m_mutex); +std::lock_guard<_MutexType> guard(m_mutex); m_set.clear(); } Index: include/lldb/Core/LoadedModuleInfoList.h === --- include/lldb/Core/LoadedModuleInfoList.h +++ include/lldb/Core/LoadedModuleInfoList.h @@ -13,10 +13,13 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes +#include "lldb/lldb-defines.h" #include "lldb/lldb-private-forward.h" +#include "lldb/lldb-types.h" namespace lldb_private { class LoadedModuleInfoList { Index: include/lldb/Utility/SharedCluster.h === --- include/lldb/Utility/SharedCluster.h +++ include/lldb/Utility/SharedCluster.h @@ -15,6 +15,8 @@ #include "llvm/ADT/SmallPtrSet.h" +#include + namespace lldb_private { namespace imp { Index: include/lldb/Utility/AnsiTerminal.h === --- include/lldb/Utility/AnsiTerminal.h +++ include/lldb/Utility/AnsiTerminal.h @@ -50,6 +50,7 @@ #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" Index: include/lldb/Target/ProcessStructReader.h === --- include/lldb/Target/ProcessStructReader.h +++ include/lldb/Target/ProcessStructReader.h @@ -16,6 +16,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Status.h" Index: include/lldb/DataFormatters/VectorIterator.h === --- include/lldb/DataFormatters/VectorIterator.h +++ include/lldb/DataFormatters/VectorIterator.h @@ -13,6 +13,7 @@ #include "lldb/lldb-forward.h" +#include "lldb/DataFormatters/TypeSynthetic.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ConstString.h" Index: include/lldb/Core/ThreadSafeValue.h === --- include/lldb/Core/Thr
[Lldb-commits] [PATCH] D40283: lldb: Use the DWARF linkage name when importing C++ methods
nelhage added a comment. I did a little bit of looking into performance implications today. It looks like `DWARFASTParserClang::ParseTypeFromDWARF` is only called lazily as symbols are needed, which alleviates some of my concerns, and also makes it a bit trickier to construct a convenient benchmark. Does someone with performance concerns have a specific usage pattern or operation or mode that they're concerned by the performance of for me to dig into? https://reviews.llvm.org/D40283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42340: [modules] Fix missing includes/typo in LLDB's includes. [NFC]
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Thanks! This looks generally good/useful as a cleanup, too. Comment at: include/lldb/Core/ThreadSafeDenseSet.h:49 void Clear() { -stds::lock_guard<_MutexType> guard(m_mutex); +std::lock_guard<_MutexType> guard(m_mutex); m_set.clear(); Out of curiosity: Why/how did this work before?? https://reviews.llvm.org/D42340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42340: [modules] Fix missing includes/typo in LLDB's includes. [NFC]
zturner added inline comments. Comment at: include/lldb/Core/ThreadSafeDenseSet.h:49 void Clear() { -stds::lock_guard<_MutexType> guard(m_mutex); +std::lock_guard<_MutexType> guard(m_mutex); m_set.clear(); aprantl wrote: > Out of curiosity: Why/how did this work before?? My guess is nobody is actually using this class so the template was never instantiated. https://reviews.llvm.org/D42340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40283: lldb: Use the DWARF linkage name when importing C++ methods
davide added a comment. In https://reviews.llvm.org/D40283#983057, @nelhage wrote: > I did a little bit of looking into performance implications today. It looks > like `DWARFASTParserClang::ParseTypeFromDWARF` is only called lazily as > symbols are needed, which alleviates some of my concerns, and also makes it a > bit trickier to construct a convenient benchmark. Does someone with > performance concerns have a specific usage pattern or operation or mode that > they're concerned by the performance of for me to dig into? My take is that we should consider going ahead with this. I tried and I confirm your experience (basically std::string in libstdc++ is undebbuggable). Please wait a couple of days in case somebody has comments otherwise I'd say this can go in. BTW, do you need somebody to commit this on your behalf? Thanks! - Davide https://reviews.llvm.org/D40283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40283: lldb: Use the DWARF linkage name when importing C++ methods
nelhage added a comment. Yes, I will need someone else to commit on my behalf -- I don't have commit access. https://reviews.llvm.org/D40283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42345: Make loop counter unsigned in SymbolFilePDB::GetCompileUnitIndex
teemperor created this revision. This fixes a clang warning. https://reviews.llvm.org/D42345 Files: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp === --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -211,7 +211,7 @@ if (!results_up) return; auto uid = pdb_compiland->getSymIndexId(); - for (int cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) { + for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) { auto compiland_up = results_up->getChildAtIndex(cu_idx); if (!compiland_up) continue; Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp === --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -211,7 +211,7 @@ if (!results_up) return; auto uid = pdb_compiland->getSymIndexId(); - for (int cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) { + for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) { auto compiland_up = results_up->getChildAtIndex(cu_idx); if (!compiland_up) continue; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42346: Fix use after free in DiskFilesOrDirectories
teemperor created this revision. teemperor added a reviewer: zturner. We copy the local variable `Resolved` into `Storage` to keep it around. However, we then still let the `SearchDir` ref point to `Resolved` which then is used to access the already freed memory later on. With this patch we point to `Storage` which doesn't get deleted after the current scope exits. Discovered by memory sanitizer in the CompletionTest.DirCompletionUsername test. https://reviews.llvm.org/D42346 Files: source/Commands/CommandCompletions.cpp Index: source/Commands/CommandCompletions.cpp === --- source/Commands/CommandCompletions.cpp +++ source/Commands/CommandCompletions.cpp @@ -165,7 +165,7 @@ // search in the fully resolved directory, but CompletionBuffer keeps the // unmodified form that the user typed. Storage = Resolved; -SearchDir = Resolved; +SearchDir = Storage; } else { SearchDir = path::parent_path(CompletionBuffer); } Index: source/Commands/CommandCompletions.cpp === --- source/Commands/CommandCompletions.cpp +++ source/Commands/CommandCompletions.cpp @@ -165,7 +165,7 @@ // search in the fully resolved directory, but CompletionBuffer keeps the // unmodified form that the user typed. Storage = Resolved; -SearchDir = Resolved; +SearchDir = Storage; } else { SearchDir = path::parent_path(CompletionBuffer); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42347: Fix memory leaks in MinidumpParserTest
teemperor created this revision. teemperor added a reviewer: dvlahovski. We never delete the allocated RegisterContext objects, causing those tests to fail with enabled memory sanitizer. https://reviews.llvm.org/D42347 Files: unittests/Process/minidump/MinidumpParserTest.cpp Index: unittests/Process/minidump/MinidumpParserTest.cpp === --- unittests/Process/minidump/MinidumpParserTest.cpp +++ unittests/Process/minidump/MinidumpParserTest.cpp @@ -315,9 +315,10 @@ llvm::ArrayRef registers(parser->GetThreadContext(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch); + std::unique_ptr reg_interface( + new RegisterContextLinux_i386(arch)); lldb::DataBufferSP buf = - ConvertMinidumpContext_x86_32(registers, reg_interface); + ConvertMinidumpContext_x86_32(registers, reg_interface.get()); ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize()); const RegisterInfo *reg_info = reg_interface->GetRegisterInfo(); @@ -357,9 +358,10 @@ llvm::ArrayRef registers(parser->GetThreadContext(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch); + std::unique_ptr reg_interface( + new RegisterContextLinux_x86_64(arch)); lldb::DataBufferSP buf = - ConvertMinidumpContext_x86_64(registers, reg_interface); + ConvertMinidumpContext_x86_64(registers, reg_interface.get()); ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize()); const RegisterInfo *reg_info = reg_interface->GetRegisterInfo(); @@ -407,9 +409,10 @@ llvm::ArrayRef registers(parser->GetThreadContextWow64(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch); + std::unique_ptr reg_interface( + new RegisterContextLinux_i386(arch)); lldb::DataBufferSP buf = - ConvertMinidumpContext_x86_32(registers, reg_interface); + ConvertMinidumpContext_x86_32(registers, reg_interface.get()); ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize()); const RegisterInfo *reg_info = reg_interface->GetRegisterInfo(); Index: unittests/Process/minidump/MinidumpParserTest.cpp === --- unittests/Process/minidump/MinidumpParserTest.cpp +++ unittests/Process/minidump/MinidumpParserTest.cpp @@ -315,9 +315,10 @@ llvm::ArrayRef registers(parser->GetThreadContext(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch); + std::unique_ptr reg_interface( + new RegisterContextLinux_i386(arch)); lldb::DataBufferSP buf = - ConvertMinidumpContext_x86_32(registers, reg_interface); + ConvertMinidumpContext_x86_32(registers, reg_interface.get()); ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize()); const RegisterInfo *reg_info = reg_interface->GetRegisterInfo(); @@ -357,9 +358,10 @@ llvm::ArrayRef registers(parser->GetThreadContext(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch); + std::unique_ptr reg_interface( + new RegisterContextLinux_x86_64(arch)); lldb::DataBufferSP buf = - ConvertMinidumpContext_x86_64(registers, reg_interface); + ConvertMinidumpContext_x86_64(registers, reg_interface.get()); ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize()); const RegisterInfo *reg_info = reg_interface->GetRegisterInfo(); @@ -407,9 +409,10 @@ llvm::ArrayRef registers(parser->GetThreadContextWow64(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch); + std::unique_ptr reg_interface( + new RegisterContextLinux_i386(arch)); lldb::DataBufferSP buf = - ConvertMinidumpContext_x86_32(registers, reg_interface); + ConvertMinidumpContext_x86_32(registers, reg_interface.get()); ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize()); const RegisterInfo *reg_info = reg_interface->GetRegisterInfo(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42348: Prevent unaligned memory read in parseMinidumpString
teemperor created this revision. teemperor added reviewers: dvlahovski, zturner. It's possible to hit an unaligned memory read when reading `source_length` as the `data` array is only aligned with 2 bytes (it's actually a UTF16 array). This patch memcpy's `source_length` into a local variable to prevent this: MinidumpTypes.cpp:49:23: runtime error: load of misaligned address 0x7f0f4792692a for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment https://reviews.llvm.org/D42348 Files: source/Plugins/Process/minidump/MinidumpTypes.cpp Index: source/Plugins/Process/minidump/MinidumpTypes.cpp === --- source/Plugins/Process/minidump/MinidumpTypes.cpp +++ source/Plugins/Process/minidump/MinidumpTypes.cpp @@ -44,19 +44,24 @@ lldb_private::minidump::parseMinidumpString(llvm::ArrayRef &data) { std::string result; - const uint32_t *source_length; - Status error = consumeObject(data, source_length); - if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0) + const uint32_t *source_length_ptr; + Status error = consumeObject(data, source_length_ptr); + + // Copy non-aligned source_length data into aligned memory. + uint32_t source_length; + std::memcpy(&source_length, source_length_ptr, sizeof(source_length)); + + if (error.Fail() || source_length > data.size() || source_length % 2 != 0) return llvm::None; auto source_start = reinterpret_cast(data.data()); // source_length is the length of the string in bytes // we need the length of the string in UTF-16 characters/code points (16 bits // per char) // that's why it's divided by 2 - const auto source_end = source_start + (*source_length) / 2; + const auto source_end = source_start + source_length / 2; // resize to worst case length - result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2); + result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length / 2); auto result_start = reinterpret_cast(&result[0]); const auto result_end = result_start + result.size(); llvm::ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end, Index: source/Plugins/Process/minidump/MinidumpTypes.cpp === --- source/Plugins/Process/minidump/MinidumpTypes.cpp +++ source/Plugins/Process/minidump/MinidumpTypes.cpp @@ -44,19 +44,24 @@ lldb_private::minidump::parseMinidumpString(llvm::ArrayRef &data) { std::string result; - const uint32_t *source_length; - Status error = consumeObject(data, source_length); - if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0) + const uint32_t *source_length_ptr; + Status error = consumeObject(data, source_length_ptr); + + // Copy non-aligned source_length data into aligned memory. + uint32_t source_length; + std::memcpy(&source_length, source_length_ptr, sizeof(source_length)); + + if (error.Fail() || source_length > data.size() || source_length % 2 != 0) return llvm::None; auto source_start = reinterpret_cast(data.data()); // source_length is the length of the string in bytes // we need the length of the string in UTF-16 characters/code points (16 bits // per char) // that's why it's divided by 2 - const auto source_end = source_start + (*source_length) / 2; + const auto source_end = source_start + source_length / 2; // resize to worst case length - result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2); + result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length / 2); auto result_start = reinterpret_cast(&result[0]); const auto result_end = result_start + result.size(); llvm::ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits