From lldb-commits at lists.llvm.org Mon Mar 27 06:53:39 2017 From: lldb-commits at lists.llvm.org (Nitesh Jain via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 13:53:39 +0000 Subject: [Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information In-Reply-To: References: Message-ID: nitesh.jain updated this revision to Diff 93130. nitesh.jain added a comment. Update diff as per suggestion. Thanks https://reviews.llvm.org/D31280 Files: packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/Process/elf-core/ProcessElfCore.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31280.93130.patch Type: text/x-patch Size: 6199 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Mon Mar 27 07:16:52 2017 From: lldb-commits at lists.llvm.org (Francis Ricci via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 14:16:52 +0000 Subject: [Lldb-commits] [PATCH] D31335: Allow getCompiler to return None in the test suite In-Reply-To: References: Message-ID: <4bc688afd6283a3cb5abf50bd2053608@localhost.localdomain> fjricci abandoned this revision. fjricci added a comment. I primarily wrote this because `getArchFlag()` accounts for the possibility that `getCompiler()` can be None. But my problem was unrelated, so I don't need this (and I agree that it would be surprising if anyone did). https://reviews.llvm.org/D31335 From lldb-commits at lists.llvm.org Mon Mar 27 07:54:04 2017 From: lldb-commits at lists.llvm.org (Greg Clayton via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 14:54:04 +0000 Subject: [Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information In-Reply-To: References: Message-ID: clayborg accepted this revision. clayborg added a comment. Looks good https://reviews.llvm.org/D31280 From lldb-commits at lists.llvm.org Mon Mar 27 10:28:18 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 17:28:18 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: <27120dc7939dd135e569a6e42cfe7096@localhost.localdomain> jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. The idea here seems fine, but why does StackFrame have to know the magic $$dereference$$? Why can't it call the Dereference on the synthetic value? https://reviews.llvm.org/D31368 From lldb-commits at lists.llvm.org Mon Mar 27 10:36:13 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 17:36:13 +0000 Subject: [Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default In-Reply-To: References: Message-ID: <637ebfc612d711453e8d7398cae203e1@localhost.localdomain> jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. This test compiles correctly on Darwin if you pass the --std=c++11 flag. lldbtest has a getstdFlag that returns the correct std value in this case. Can you get the test running on Darwin with this? Other than that this looks fine to me. https://reviews.llvm.org/D31366 From lldb-commits at lists.llvm.org Mon Mar 27 12:03:12 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Mon, 27 Mar 2017 19:03:12 -0000 Subject: [Lldb-commits] [lldb] r298874 - Fix the Xcode project for OpenBSD additions. Message-ID: <20170327190312.572202A6C0A9@llvm.org> Author: jingham Date: Mon Mar 27 14:03:11 2017 New Revision: 298874 URL: http://llvm.org/viewvc/llvm-project?rev=298874&view=rev Log: Fix the Xcode project for OpenBSD additions. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=298874&r1=298873&r2=298874&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 27 14:03:11 2017 @@ -735,6 +735,9 @@ 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; }; 4CDB8D6D1DBA91B6006C5B13 /* LibStdcppUniquePointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CDB8D671DBA91A6006C5B13 /* LibStdcppUniquePointer.cpp */; }; 4CDB8D6E1DBA91B6006C5B13 /* LibStdcppTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CDB8D681DBA91A6006C5B13 /* LibStdcppTuple.cpp */; }; + 4CE4EFAA1E8999B900A80C06 /* PlatformOpenBSD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp */; }; + 4CE4EFB31E899A3400A80C06 /* RegisterContextOpenBSD_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */; }; + 4CE4EFB41E899A4000A80C06 /* RegisterContextOpenBSD_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFAD1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.cpp */; }; 4CE4F673162C971A00F75CB3 /* SBExpressionOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CE4F672162C971A00F75CB3 /* SBExpressionOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4CE4F675162C973F00F75CB3 /* SBExpressionOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4F674162C973F00F75CB3 /* SBExpressionOptions.cpp */; }; 4CF3D80C15AF4DC800845BF3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDB919B414F6F10D008FF64B /* Security.framework */; }; @@ -2549,6 +2552,12 @@ 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectDynamicValue.cpp; path = source/Core/ValueObjectDynamicValue.cpp; sourceTree = ""; }; 4CDB8D671DBA91A6006C5B13 /* LibStdcppUniquePointer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibStdcppUniquePointer.cpp; path = Language/CPlusPlus/LibStdcppUniquePointer.cpp; sourceTree = ""; }; 4CDB8D681DBA91A6006C5B13 /* LibStdcppTuple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibStdcppTuple.cpp; path = Language/CPlusPlus/LibStdcppTuple.cpp; sourceTree = ""; }; + 4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformOpenBSD.cpp; sourceTree = ""; }; + 4CE4EFA71E8999B000A80C06 /* PlatformOpenBSD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformOpenBSD.h; sourceTree = ""; }; + 4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextOpenBSD_i386.cpp; path = Utility/RegisterContextOpenBSD_i386.cpp; sourceTree = ""; }; + 4CE4EFAC1E899A1200A80C06 /* RegisterContextOpenBSD_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextOpenBSD_i386.h; path = Utility/RegisterContextOpenBSD_i386.h; sourceTree = ""; }; + 4CE4EFAD1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextOpenBSD_x86_64.cpp; path = Utility/RegisterContextOpenBSD_x86_64.cpp; sourceTree = ""; }; + 4CE4EFAE1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextOpenBSD_x86_64.h; path = Utility/RegisterContextOpenBSD_x86_64.h; sourceTree = ""; }; 4CE4F672162C971A00F75CB3 /* SBExpressionOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBExpressionOptions.h; path = include/lldb/API/SBExpressionOptions.h; sourceTree = ""; }; 4CE4F674162C973F00F75CB3 /* SBExpressionOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBExpressionOptions.cpp; path = source/API/SBExpressionOptions.cpp; sourceTree = ""; }; 4CE4F676162CE1E100F75CB3 /* SBExpressionOptions.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBExpressionOptions.i; sourceTree = ""; }; @@ -4575,6 +4584,10 @@ 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */, 262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */, 262D24E513FB8710002D1960 /* RegisterContextMemory.h */, + 4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */, + 4CE4EFAC1E899A1200A80C06 /* RegisterContextOpenBSD_i386.h */, + 4CE4EFAD1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.cpp */, + 4CE4EFAE1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.h */, 256CBDBE1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.cpp */, 256CBDBF1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.h */, E7723D4A1AC4A944002BA082 /* RegisterContextPOSIX_arm64.cpp */, @@ -5364,6 +5377,7 @@ 2694E99F14FC0BBD0076DE67 /* Linux */, 26C5577F132575C8008FD8FE /* MacOSX */, 26EFB6151BFE8D3E00544801 /* NetBSD */, + 4CE4EFA51E89998800A80C06 /* OpenBSD */, 9457596415349416005A9070 /* POSIX */, 490A36BA180F0E6F00BA31F8 /* Windows */, ); @@ -5816,6 +5830,15 @@ path = AppleObjCRuntime; sourceTree = ""; }; + 4CE4EFA51E89998800A80C06 /* OpenBSD */ = { + isa = PBXGroup; + children = ( + 4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp */, + 4CE4EFA71E8999B000A80C06 /* PlatformOpenBSD.h */, + ); + path = OpenBSD; + sourceTree = ""; + }; 4CEE62F71145F1C70064CF93 /* GDB Remote */ = { isa = PBXGroup; children = ( @@ -7223,6 +7246,7 @@ 2689007813353E1A00698AC0 /* CFCMutableArray.cpp in Sources */, 9418EBCD1AA910910058B02E /* VectorType.cpp in Sources */, 4C4EB7811E6A4DCC002035C0 /* DumpDataExtractor.cpp in Sources */, + 4CE4EFB31E899A3400A80C06 /* RegisterContextOpenBSD_i386.cpp in Sources */, 2689007913353E1A00698AC0 /* CFCMutableDictionary.cpp in Sources */, 2689007A13353E1A00698AC0 /* CFCMutableSet.cpp in Sources */, 26764C971E48F482008D3573 /* ConstString.cpp in Sources */, @@ -7289,6 +7313,7 @@ 3FDFED2D19C257A0009756A7 /* HostProcess.cpp in Sources */, 268900B513353E5000698AC0 /* StopInfoMachException.cpp in Sources */, 268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */, + 4CE4EFB41E899A4000A80C06 /* RegisterContextOpenBSD_x86_64.cpp in Sources */, 268900B713353E5F00698AC0 /* DWARFAbbreviationDeclaration.cpp in Sources */, 268900B813353E5F00698AC0 /* DWARFCompileUnit.cpp in Sources */, 268900B913353E5F00698AC0 /* DWARFDebugAbbrev.cpp in Sources */, @@ -7448,6 +7473,7 @@ 6D95DC011B9DC057000E318A /* HashedNameToDIE.cpp in Sources */, 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */, 23D065911D4A7BEE0008EDE6 /* RenderScriptx86ABIFixups.cpp in Sources */, + 4CE4EFAA1E8999B900A80C06 /* PlatformOpenBSD.cpp in Sources */, 26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */, 3FDFED0B19B7C8DE009756A7 /* HostThreadMacOSX.mm in Sources */, 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */, From lldb-commits at lists.llvm.org Mon Mar 27 12:17:44 2017 From: lldb-commits at lists.llvm.org (Chris Bieneman via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 19:17:44 +0000 Subject: [Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver In-Reply-To: References: Message-ID: <0f528fae6ac941d6986d18a3a757ae8e@localhost.localdomain> beanz updated this revision to Diff 93165. beanz added a comment. Fleshed out the unit test logic to be more meaningful. https://reviews.llvm.org/D31357 Files: tools/debugserver/source/CMakeLists.txt tools/debugserver/source/MacOSX/CMakeLists.txt unittests/CMakeLists.txt unittests/debugserver/CMakeLists.txt unittests/debugserver/RNBSocketTest.cpp unittests/debugserver/debugserver_LogCallback.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31357.93165.patch Type: text/x-patch Size: 12114 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Mon Mar 27 12:12:25 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Mon, 27 Mar 2017 19:12:25 -0000 Subject: [Lldb-commits] [lldb] r298876 - In FileSpec::Equal, short-cut GetNormalizedPath. Message-ID: <20170327191225.725E72A6C0A9@llvm.org> Author: jingham Date: Mon Mar 27 14:12:25 2017 New Revision: 298876 URL: http://llvm.org/viewvc/llvm-project?rev=298876&view=rev Log: In FileSpec::Equal, short-cut GetNormalizedPath. GetNormalizedPath seems to be slow, so it's worth shortcutting it if possible. This change does so when the filenames and not equal and we can tell GetNormalizedPath would not make them equal. Also added a test for "." final component since that was missing. Modified: lldb/trunk/source/Utility/FileSpec.cpp lldb/trunk/unittests/Host/FileSpecTest.cpp Modified: lldb/trunk/source/Utility/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=298876&r1=298875&r2=298876&view=diff ============================================================================== --- lldb/trunk/source/Utility/FileSpec.cpp (original) +++ lldb/trunk/source/Utility/FileSpec.cpp Mon Mar 27 14:12:25 2017 @@ -401,11 +401,36 @@ int FileSpec::Compare(const FileSpec &a, bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full, bool remove_backups) { + static ConstString g_dot_string("."); + static ConstString g_dot_dot_string(".."); + // case sensitivity of equality test const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive(); + + bool filenames_equal = ConstString::Equals(a.m_filename, + b.m_filename, + case_sensitive); + + // The only way two FileSpecs can be equal if their filenames are + // unequal is if we are removing backups and one or the other filename + // is a backup string: + + if (!filenames_equal && !remove_backups) + return false; + + bool last_component_is_dot = ConstString::Equals(a.m_filename, g_dot_string) + || ConstString::Equals(a.m_filename, + g_dot_dot_string) + || ConstString::Equals(b.m_filename, + g_dot_string) + || ConstString::Equals(b.m_filename, + g_dot_dot_string); + + if (!filenames_equal && !last_component_is_dot) + return false; if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty())) - return ConstString::Equals(a.m_filename, b.m_filename, case_sensitive); + return filenames_equal; if (remove_backups == false) return a == b; Modified: lldb/trunk/unittests/Host/FileSpecTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/FileSpecTest.cpp?rev=298876&r1=298875&r2=298876&view=diff ============================================================================== --- lldb/trunk/unittests/Host/FileSpecTest.cpp (original) +++ lldb/trunk/unittests/Host/FileSpecTest.cpp Mon Mar 27 14:12:25 2017 @@ -164,6 +164,7 @@ TEST(FileSpecTest, EqualDotsWindows) { {R"(C:/bar/baz)", R"(C:\foo\..\bar\baz)"}, {R"(C:\bar)", R"(C:\foo\..\bar)"}, {R"(C:\foo\bar)", R"(C:\foo\.\bar)"}, + {R"(C:\foo\bar)", R"(C:\foo\bar\.)"}, }; for(const auto &test: tests) { @@ -187,6 +188,7 @@ TEST(FileSpecTest, EqualDotsPosix) { {R"(/bar/baz)", R"(/foo/../bar/baz)"}, {R"(/bar)", R"(/foo/../bar)"}, {R"(/foo/bar)", R"(/foo/./bar)"}, + {R"(/foo/bar)", R"(/foo/bar/.)"}, }; for(const auto &test: tests) { From lldb-commits at lists.llvm.org Mon Mar 27 12:32:35 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 19:32:35 +0000 Subject: [Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver In-Reply-To: References: Message-ID: jingham added a comment. It's a little weird to have the unit tests for debugserver in the top-level lldb directory. debugserver really is a stand-alone tool that shares no code with lldb proper. How hard would it be to put the tests under debugserver? https://reviews.llvm.org/D31357 From lldb-commits at lists.llvm.org Mon Mar 27 12:34:54 2017 From: lldb-commits at lists.llvm.org (Chris Bieneman via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 19:34:54 +0000 Subject: [Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver In-Reply-To: References: Message-ID: beanz added a comment. @jingham I put the unit tests at the top because they depend on LLDB's Host library (at least the current tests do). I'm attempting to write tests which cover the socket communication between LLDB and debugserver by sending data between the two using each side of the API. https://reviews.llvm.org/D31357 From lldb-commits at lists.llvm.org Mon Mar 27 12:42:43 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 19:42:43 +0000 Subject: [Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver In-Reply-To: References: Message-ID: <1dec1190bd9d80e12fe33ebb5e3652fe@localhost.localdomain> jingham added a comment. debugserver only runs on darwin and we have no intentions of using it elsewhere. lldb-server is the way to do debugserver for new platforms. I don't think you need the generality provided by host to test debugserver, OTOH, if using those classes saves you lots of time over writing macOS specific code, then I'm mostly concerned that it is clear that debugserver isn't the way to do debug servers for lldb, lldb-server is... https://reviews.llvm.org/D31357 From lldb-commits at lists.llvm.org Mon Mar 27 12:54:08 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 19:54:08 +0000 Subject: [Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default In-Reply-To: References: Message-ID: <445016975ed58c3eca99d307738d8608@localhost.localdomain> tberghammer requested review of this revision. tberghammer added a comment. I am trying to compile it with the following command on OSX but I wasn't able to get it working: clang -std=c++11 -g -O0 -fno-builtin -arch x86_64 -fno-limit-debug-info -I$LLVM_ROOT/lldb/packages/Python/lldbsuite/test/make/../../../../../include -include $LLVM_ROOT/lldb/packages/Python/lldbsuite/test/make/test_common.h -stdlib=libstdc++ -DLLDB_USING_LIBSTDCPP --driver-mode=g++ -c -o main.o main.cpp Compile error (first few): main.cpp:12:8: error: no member named 'unique_ptr' in namespace 'std' std::unique_ptr nup; ~~~~~^ main.cpp:12:23: error: expected '(' for function-style cast or type construction std::unique_ptr nup; ~~~~^ main.cpp:12:25: error: use of undeclared identifier 'nup'; did you mean 'dup'? std::unique_ptr nup; ^~~ dup /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/unistd.h:438:6: note: 'dup' declared here int dup(int); ^ main.cpp:13:8: error: no member named 'unique_ptr' in namespace 'std' std::unique_ptr iup(new int{123}); ~~~~~^ main.cpp:13:22: error: expected '(' for function-style cast or type construction std::unique_ptr iup(new int{123}); ~~~^ main.cpp:13:24: error: use of undeclared identifier 'iup'; did you mean 'dup'? std::unique_ptr iup(new int{123}); ^~~ dup /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/unistd.h:438:6: note: 'dup' declared here int dup(int); I think the problem is that this is testing libstdc++ what is not available on OSX. Clang version: Apple LLVM version 7.3.0 (clang-703.0.31) Target: x86_64-apple-darwin16.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin https://reviews.llvm.org/D31366 From lldb-commits at lists.llvm.org Mon Mar 27 15:55:22 2017 From: lldb-commits at lists.llvm.org (Chris Bieneman via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 22:55:22 +0000 Subject: [Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver In-Reply-To: References: Message-ID: <5aaed5a64ab27842f36871391b1b9e78@localhost.localdomain> beanz updated this revision to Diff 93190. beanz added a comment. Added a note to the unit test CMake file about why the tests are where they are. Generally we isolate debugserver from the rest of LLDB, and this comment explains the breach of isolation. https://reviews.llvm.org/D31357 Files: tools/debugserver/source/CMakeLists.txt tools/debugserver/source/MacOSX/CMakeLists.txt unittests/CMakeLists.txt unittests/debugserver/CMakeLists.txt unittests/debugserver/RNBSocketTest.cpp unittests/debugserver/debugserver_LogCallback.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31357.93190.patch Type: text/x-patch Size: 12483 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Mon Mar 27 16:12:08 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Mon, 27 Mar 2017 23:12:08 +0000 Subject: [Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default In-Reply-To: References: Message-ID: <93c9e30900d11efcfe4d8239a4c1e01e@localhost.localdomain> jingham added a comment. There's no reason you couldn't build the gnu libstdc++ on Darwin. Anyway, if that's the problem, I'm pretty sure the testsuite has a way to conditionalize on which stdlib(s) are available. That would be clearer than conditionalizing on platform. https://reviews.llvm.org/D31366 From lldb-commits at lists.llvm.org Mon Mar 27 19:46:59 2017 From: lldb-commits at lists.llvm.org (Eric Fiselier via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 02:46:59 +0000 Subject: [Lldb-commits] [PATCH] D30984: Centralize libc++ test skipping logic In-Reply-To: References: Message-ID: <175b18ba2f4be46aecbc95f4ae899554@localhost.localdomain> EricWF added a comment. I don't see anything wrong with this, but I only know libc++ and not LLDB. > libc++'s atomic does not play well with gcc on linux It should... Can you elaborate on this issue? I suspect this may be a libc++ bug. https://reviews.llvm.org/D30984 From lldb-commits at lists.llvm.org Tue Mar 28 06:53:17 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 13:53:17 +0000 Subject: [Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default In-Reply-To: References: Message-ID: <50590fd81ce840ffe8dfb198190f0589@localhost.localdomain> tberghammer added a comment. My understanding (don't have an OSX machine at hand right now to try out) is that OSX ships with the libstdc++ belonging to gcc-4.2.1 and that version of libstdc++ is too old to support c++11 features such as std::unique_ptr. Regarding skipping tests I am not aware of any way to skip a test based on the STL library we are using (Pavel is working on it for libc++ at https://reviews.llvm.org/D30984) and actually the problem here is that the version of libstdc++ shipping on OSX is too old so I think skipIfDarwin is the correct decorator (we do it in several other tests as well). Alternative option could be to try to compile the source code and skip the test if compilation fails but that seems a bit flaky and might cause false negatives on other systems where we expect the test to pass. https://reviews.llvm.org/D31366 From lldb-commits at lists.llvm.org Tue Mar 28 07:48:40 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 14:48:40 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: <7d4c2d01797f86aab7b8aac6984c63af@localhost.localdomain> tberghammer updated this revision to Diff 93241. tberghammer added a comment. Changed StackFrame to use Dereference instead of accessing the $$dereference$$ magic field. https://reviews.llvm.org/D31368 Files: packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py source/Core/ValueObject.cpp source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp source/Target/StackFrame.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31368.93241.patch Type: text/x-patch Size: 5120 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Tue Mar 28 09:00:05 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 16:00:05 +0000 Subject: [Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support In-Reply-To: References: Message-ID: <3935e95dfb23373649de2e670d32b12b@localhost.localdomain> labath added inline comments. ================ Comment at: source/CMakeLists.txt:25 +include_directories( + Plugins/Process/POSIX + ) ---------------- krytarowski wrote: > @labath are the includes for Plugins/Process/FreeBSD and Plugins/Process/FreeBSD necessary? I don't need to add Plugins/Process/NetBSD in order to make things work. > > (it's not related to OpenBSD patch here) You probably need the ProcessPosixLog file at least. However, the only thing which this affects is how you need to include them, so if you use the long `Plugins/Process/POSIX/XXX` path, you are fine. As a matter of fact, we should probably use that path everywhere, and then these can go away. (future cleanup idea). https://reviews.llvm.org/D31131 From lldb-commits at lists.llvm.org Tue Mar 28 09:21:09 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 16:21:09 +0000 Subject: [Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver In-Reply-To: References: Message-ID: <89567cf07d2ec4f3fa1a2ea8604a744e@localhost.localdomain> labath added a comment. I am afraid I will be away for two weeks as well.. :( The FileLogCallback thingy seems a bit unfortunate, but I don't see anything too controversial based on a quick scan.. https://reviews.llvm.org/D31357 From lldb-commits at lists.llvm.org Tue Mar 28 09:40:42 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 16:40:42 +0000 Subject: [Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD In-Reply-To: References: Message-ID: labath added a comment. I wasn't able to go into this too deeply, but here is what I have after a quick pass. I won't be able to review this thoroughly that soon, but I think it can go in after you take my comments into consideration. ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:450 + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + LLDB_LOG(log, "selecting running thread for interrupt target"); + ---------------- this comment does not make sense in this context ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:620 + lldb::addr_t &addr) { + return Error(); +} ---------------- This will return a success value. You probably wan't `return Error("Unimplemented");` or something like that. ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:624 +Error NativeProcessNetBSD::DeallocateMemory(lldb::addr_t addr) { + return Error(); +} ---------------- same here ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:666 + FileSpec &file_spec) { + FileSpec module_file_spec(module_path, true); + ---------------- `return Error("Unimplemented");` ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:801 + int status; + ::pid_t wait_pid = waitpid(WAIT_ANY, &status, WALLSIG | WNOHANG); + ---------------- you could probably use process id instead of WAIT_ANY. The reason we needed -1 on linux is because each thread is reported separately. ================ Comment at: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp:32 + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); + if (log) + log->Printf("NativeThreadNetBSD::%s called with signal 0x%02" PRIx32, ---------------- How about using LLDB_LOG here? ================ Comment at: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp:142 + uint32_t watch_flags, bool hardware) { + return Error(); +} ---------------- "Unimplemented" (and below as well). Repository: rL LLVM https://reviews.llvm.org/D31374 From lldb-commits at lists.llvm.org Tue Mar 28 10:32:17 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 17:32:17 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. This seems great. The only remaining thing is to document this in the Synthetic Children section of the Variable Formatting page (www/varformats.html). https://reviews.llvm.org/D31368 From lldb-commits at lists.llvm.org Tue Mar 28 11:19:12 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 18:19:12 +0000 Subject: [Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD In-Reply-To: References: Message-ID: krytarowski added a comment. In https://reviews.llvm.org/D31374#712221, @labath wrote: > I wasn't able to go into this too deeply, but here is what I have after a quick pass. I won't be able to review this thoroughly that soon, but I think it can go in after you take my comments into consideration. Thank you! I will apply the changes as suggested. Repository: rL LLVM https://reviews.llvm.org/D31374 From lldb-commits at lists.llvm.org Tue Mar 28 11:56:13 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 18:56:13 +0000 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: Message-ID: <476ce4fac9d2c80a13f10553630d7938@localhost.localdomain> jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. If SetName is the wrong thing to use for synthetic child providers, then we need to make Clone available to the SB API's as well. In any case where they want to return an extant ValueObject with a different name - as opposed to making one up out of whole cloth - won't they need the same operation? Also, probably should document this requirement in the varformats.html. ================ Comment at: include/lldb/Core/ValueObject.h:607-610 + // Creates a copy of the ValueObject with a new name setting he current value + // object as its parent. It should be used when we want to chane the name of a + // value object without modifying the actul value object (e.g. sythetic child + // provider). ---------------- Spelling... "he" -> "the", "chane" -> "change", "actul" -> "actual" https://reviews.llvm.org/D31371 From lldb-commits at lists.llvm.org Tue Mar 28 15:16:13 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 22:16:13 +0000 Subject: [Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD In-Reply-To: References: Message-ID: <8be1263dafd015990e0aa6627eaf8723@localhost.localdomain> krytarowski updated this revision to Diff 93312. krytarowski added a comment. Apply changes from review. Repository: rL LLVM https://reviews.llvm.org/D31374 Files: source/Plugins/Process/NetBSD/CMakeLists.txt source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp source/Plugins/Process/NetBSD/NativeProcessNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D31374.93312.patch Type: text/x-patch Size: 64726 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Tue Mar 28 15:20:49 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 22:20:49 +0000 Subject: [Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD In-Reply-To: References: Message-ID: <49e84f1f58131c54cf033cee85ac0a57@localhost.localdomain> krytarowski added a comment. This code is used as a base for further improvements, I'm going to commit it... debugging hello world still works. $ lldb ./hello (lldb) target create "./hello" Current executable set to './hello' (x86_64). (lldb) r Process 3955 launched: './hello' (x86_64) Hello world! Process 3955 exited with status = 0 (0x00000000) (lldb) version lldb version 5.0.0 (http://llvm.org/svn/llvm-project/lldb/trunk revision 298810) (lldb) platform status Platform: host Triple: x86_64-unknown-netbsd7.99 OS Version: 7.99.66 (0799006600) Kernel: NetBSD 7.99.66 (GENERIC) #5: Tue Mar 28 17:42:09 CEST 2017 root at chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC Hostname: 127.0.0.1 WorkingDir: /public/lldb_devel Kernel: NetBSD Release: 7.99.66 Version: NetBSD 7.99.66 (GENERIC) #5: Tue Mar 28 17:42:09 CEST 2017 root at chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC (lldb) Repository: rL LLVM https://reviews.llvm.org/D31374 From lldb-commits at lists.llvm.org Tue Mar 28 15:43:17 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via lldb-commits) Date: Tue, 28 Mar 2017 22:43:17 -0000 Subject: [Lldb-commits] [lldb] r298953 - Add support for tracing hello-world application on NetBSD Message-ID: <20170328224318.2ECF32A6C0AB@llvm.org> Author: kamil Date: Tue Mar 28 17:43:17 2017 New Revision: 298953 URL: http://llvm.org/viewvc/llvm-project?rev=298953&view=rev Log: Add support for tracing hello-world application on NetBSD Summary: This patch is a stripped down from features a NetBSD process code (patch is kept under 2k LOC). This code has assumption that there is only one thread within a debugged process. The only debugger trap supported is software breakpoint (TRAP_BRKPT). The generic platform code requires to add dummy function for watchpoints etc. These functions are currently empty. This code is not the final platform support as is and it's treated as a base to extend, refactor and address issues afterwards. Supported features: - handle software breakpoints, - correctly attach to a tracee, - support NetBSD specific ptrace(2), - monitor process termination, - monitor SIGTRAP events, - monitor SIGSTOP events, - monitor other signals events, - resume the whole process, - get memory region info perms, - read memory from tracee, - write memory to tracee, - read ELF AUXV, - x86_64 GPR read and write code For the generic framework include: - halt, - detach, - signal, - kill, - allocatememory, - deallocatememory, - update threads, - getarchitecture, - getfileloadaddress, - and others. This code has preliminary AddThread code. Out of interest in this patch: - exec() traps, - hardware debug register traps, - single step trap, - thread creation/termination trap, - process fork(2), vfork(2) and vfork(2) done traps, - syscall entry and exit trap, - threads, - FPR registers, - retrieving tracee's thread name, - non x86_64 support. This code can be used to start a hello world application and trace it. This code can be used by other BSD systems as a starting point to get similar capabilities. Sponsored by Reviewers: emaste, joerg, kettenis, labath Subscribers: mgorny, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D31374 Added: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h Modified: lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h Modified: lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt?rev=298953&r1=298952&r2=298953&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt Tue Mar 28 17:43:17 2017 @@ -5,6 +5,7 @@ include_directories(../Utility) add_lldb_library(lldbPluginProcessNetBSD PLUGIN NativeProcessNetBSD.cpp NativeRegisterContextNetBSD.cpp + NativeRegisterContextNetBSD_x86_64.cpp NativeThreadNetBSD.cpp LINK_LIBS Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp?rev=298953&r1=298952&r2=298953&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Tue Mar 28 17:43:17 2017 @@ -14,18 +14,77 @@ // C++ Includes // Other libraries and framework includes - #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" +#include "lldb/Core/State.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/common/NativeBreakpoint.h" +#include "lldb/Host/common/NativeRegisterContext.h" +#include "lldb/Host/posix/ProcessLauncherPosixFork.h" +#include "lldb/Target/Process.h" // System includes - They have to be included after framework includes because // they define some // macros which collide with variable names in other modules +// clang-format off +#include +#include +#include +#include +#include +#include +#include +// clang-format on using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_netbsd; using namespace llvm; +static ExitType convert_pid_status_to_exit_type(int status) { + if (WIFEXITED(status)) + return ExitType::eExitTypeExit; + else if (WIFSIGNALED(status)) + return ExitType::eExitTypeSignal; + else if (WIFSTOPPED(status)) + return ExitType::eExitTypeStop; + else { + // We don't know what this is. + return ExitType::eExitTypeInvalid; + } +} + +static int convert_pid_status_to_return_code(int status) { + if (WIFEXITED(status)) + return WEXITSTATUS(status); + else if (WIFSIGNALED(status)) + return WTERMSIG(status); + else if (WIFSTOPPED(status)) + return WSTOPSIG(status); + else { + // We don't know what this is. + return ExitType::eExitTypeInvalid; + } +} + +// Simple helper function to ensure flags are enabled on the given file +// descriptor. +static Error EnsureFDFlags(int fd, int flags) { + Error error; + + int status = fcntl(fd, F_GETFL); + if (status == -1) { + error.SetErrorToErrno(); + return error; + } + + if (fcntl(fd, F_SETFL, status | flags) == -1) { + error.SetErrorToErrno(); + return error; + } + + return error; +} + // ----------------------------------------------------------------------------- // Public Static Methods // ----------------------------------------------------------------------------- @@ -34,13 +93,68 @@ Error NativeProcessProtocol::Launch( ProcessLaunchInfo &launch_info, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) { - return Error(); + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + + Error error; + + // Verify the working directory is valid if one was specified. + FileSpec working_dir{launch_info.GetWorkingDirectory()}; + if (working_dir && (!working_dir.ResolvePath() || + !llvm::sys::fs::is_directory(working_dir.GetPath()))) { + error.SetErrorStringWithFormat("No such file or directory: %s", + working_dir.GetCString()); + return error; + } + + // Create the NativeProcessNetBSD in launch mode. + native_process_sp.reset(new NativeProcessNetBSD()); + + if (!native_process_sp->RegisterNativeDelegate(native_delegate)) { + native_process_sp.reset(); + error.SetErrorStringWithFormat("failed to register the native delegate"); + return error; + } + + error = std::static_pointer_cast(native_process_sp) + ->LaunchInferior(mainloop, launch_info); + + if (error.Fail()) { + native_process_sp.reset(); + LLDB_LOG(log, "failed to launch process: {0}", error); + return error; + } + + launch_info.SetProcessID(native_process_sp->GetID()); + + return error; } Error NativeProcessProtocol::Attach( lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) { - return Error(); + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + LLDB_LOG(log, "pid = {0:x}", pid); + + // Retrieve the architecture for the running process. + ArchSpec process_arch; + Error error = ResolveProcessArchitecture(pid, process_arch); + if (!error.Success()) + return error; + + std::shared_ptr native_process_netbsd_sp( + new NativeProcessNetBSD()); + + if (!native_process_netbsd_sp->RegisterNativeDelegate(native_delegate)) { + error.SetErrorStringWithFormat("failed to register the native delegate"); + return error; + } + + native_process_netbsd_sp->AttachToInferior(mainloop, pid, error); + if (!error.Success()) + return error; + + native_process_sp = native_process_netbsd_sp; + return error; } // ----------------------------------------------------------------------------- @@ -48,4 +162,830 @@ Error NativeProcessProtocol::Attach( // ----------------------------------------------------------------------------- NativeProcessNetBSD::NativeProcessNetBSD() - : NativeProcessProtocol(LLDB_INVALID_PROCESS_ID) {} + : NativeProcessProtocol(LLDB_INVALID_PROCESS_ID), m_arch(), + m_supports_mem_region(eLazyBoolCalculate), m_mem_region_cache() {} + +// Handles all waitpid events from the inferior process. +void NativeProcessNetBSD::MonitorCallback(lldb::pid_t pid, int signal) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + + switch (signal) { + case SIGTRAP: + return MonitorSIGTRAP(pid); + case SIGSTOP: + return MonitorSIGSTOP(pid); + default: + return MonitorSignal(pid, signal); + } +} + +void NativeProcessNetBSD::MonitorExited(lldb::pid_t pid, int signal, + int status) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + + LLDB_LOG(log, "got exit signal({0}) , pid = {1}", signal, pid); + + /* Stop Tracking All Threads attached to Process */ + m_threads.clear(); + + SetExitStatus(convert_pid_status_to_exit_type(status), + convert_pid_status_to_return_code(status), nullptr, true); + + // Notify delegate that our process has exited. + SetState(StateType::eStateExited, true); +} + +void NativeProcessNetBSD::MonitorSIGSTOP(lldb::pid_t pid) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + ptrace_siginfo_t info; + + const auto siginfo_err = + PtraceWrapper(PT_GET_SIGINFO, pid, &info, sizeof(info)); + + // Get details on the signal raised. + if (siginfo_err.Success()) { + // Handle SIGSTOP from LLGS (LLDB GDB Server) + if (info.psi_siginfo.si_code == SI_USER && + info.psi_siginfo.si_pid == ::getpid()) { + /* Stop Tracking All Threads attached to Process */ + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStoppedBySignal( + SIGSTOP, &info.psi_siginfo); + } + } + } +} + +void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + ptrace_siginfo_t info; + + const auto siginfo_err = + PtraceWrapper(PT_GET_SIGINFO, pid, &info, sizeof(info)); + + // Get details on the signal raised. + if (siginfo_err.Success()) { + switch (info.psi_siginfo.si_code) { + case TRAP_BRKPT: + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp) + ->SetStoppedByBreakpoint(); + FixupBreakpointPCAsNeeded( + *static_pointer_cast(thread_sp)); + } + SetState(StateType::eStateStopped, true); + break; + } + } +} + +void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + + ptrace_siginfo_t info; + const auto siginfo_err = + PtraceWrapper(PT_GET_SIGINFO, pid, &info, sizeof(info)); + + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStoppedBySignal( + info.psi_siginfo.si_signo, &info.psi_siginfo); + } + SetState(StateType::eStateStopped, true); +} + +Error NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, + int data, int *result) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + Error error; + int ret; + + errno = 0; + ret = ptrace(req, static_cast<::pid_t>(pid), addr, data); + + if (ret == -1) + error.SetErrorToErrno(); + + if (result) + *result = ret; + + LLDB_LOG(log, "ptrace({0}, {1}, {2}, {3})={4:x}", req, pid, addr, data, ret); + + if (error.Fail()) + LLDB_LOG(log, "ptrace() failed: {0}", error); + + return error; +} + +Error NativeProcessNetBSD::GetSoftwareBreakpointPCOffset( + uint32_t &actual_opcode_size) { + // FIXME put this behind a breakpoint protocol class that can be + // set per architecture. Need ARM, MIPS support here. + static const uint8_t g_i386_opcode[] = {0xCC}; + switch (m_arch.GetMachine()) { + case llvm::Triple::x86_64: + actual_opcode_size = static_cast(sizeof(g_i386_opcode)); + return Error(); + default: + assert(false && "CPU type not supported!"); + return Error("CPU type not supported"); + } +} + +Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded( + NativeThreadNetBSD &thread) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); + Error error; + // Find out the size of a breakpoint (might depend on where we are in the + // code). + NativeRegisterContextSP context_sp = thread.GetRegisterContext(); + if (!context_sp) { + error.SetErrorString("cannot get a NativeRegisterContext for the thread"); + LLDB_LOG(log, "failed: {0}", error); + return error; + } + uint32_t breakpoint_size = 0; + error = GetSoftwareBreakpointPCOffset(breakpoint_size); + if (error.Fail()) { + LLDB_LOG(log, "GetBreakpointSize() failed: {0}", error); + return error; + } else + LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size); + // First try probing for a breakpoint at a software breakpoint location: PC - + // breakpoint size. + const lldb::addr_t initial_pc_addr = + context_sp->GetPCfromBreakpointLocation(); + lldb::addr_t breakpoint_addr = initial_pc_addr; + if (breakpoint_size > 0) { + // Do not allow breakpoint probe to wrap around. + if (breakpoint_addr >= breakpoint_size) + breakpoint_addr -= breakpoint_size; + } + // Check if we stopped because of a breakpoint. + NativeBreakpointSP breakpoint_sp; + error = m_breakpoint_list.GetBreakpoint(breakpoint_addr, breakpoint_sp); + if (!error.Success() || !breakpoint_sp) { + // We didn't find one at a software probe location. Nothing to do. + LLDB_LOG(log, + "pid {0} no lldb breakpoint found at current pc with " + "adjustment: {1}", + GetID(), breakpoint_addr); + return Error(); + } + // If the breakpoint is not a software breakpoint, nothing to do. + if (!breakpoint_sp->IsSoftwareBreakpoint()) { + LLDB_LOG( + log, + "pid {0} breakpoint found at {1:x}, not software, nothing to adjust", + GetID(), breakpoint_addr); + return Error(); + } + // + // We have a software breakpoint and need to adjust the PC. + // + // Sanity check. + if (breakpoint_size == 0) { + // Nothing to do! How did we get here? + LLDB_LOG(log, + "pid {0} breakpoint found at {1:x}, it is software, but the " + "size is zero, nothing to do (unexpected)", + GetID(), breakpoint_addr); + return Error(); + } + // + // We have a software breakpoint and need to adjust the PC. + // + // Sanity check. + if (breakpoint_size == 0) { + // Nothing to do! How did we get here? + LLDB_LOG(log, + "pid {0} breakpoint found at {1:x}, it is software, but the " + "size is zero, nothing to do (unexpected)", + GetID(), breakpoint_addr); + return Error(); + } + // Change the program counter. + LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(), + thread.GetID(), initial_pc_addr, breakpoint_addr); + error = context_sp->SetPC(breakpoint_addr); + if (error.Fail()) { + LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(), + thread.GetID(), error); + return error; + } + return error; +} + +Error NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + LLDB_LOG(log, "pid {0}", GetID()); + + const auto &thread_sp = m_threads[0]; + const ResumeAction *const action = + resume_actions.GetActionForThread(thread_sp->GetID(), true); + + if (action == nullptr) { + LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(), + thread_sp->GetID()); + return Error(); + } + + switch (action->state) { + case eStateRunning: { + // Run the thread, possibly feeding it the signal. + Error error = NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(), + (void *)1, action->signal); + if (!error.Success()) + return error; + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetRunning(); + } + SetState(eStateRunning, true); + break; + } + case eStateStepping: + return Error("Not implemented"); + break; + + case eStateSuspended: + case eStateStopped: + llvm_unreachable("Unexpected state"); + + default: + return Error("NativeProcessLinux::%s (): unexpected state %s specified " + "for pid %" PRIu64 ", tid %" PRIu64, + __FUNCTION__, StateAsCString(action->state), GetID(), + thread_sp->GetID()); + } + + return Error(); +} + +Error NativeProcessNetBSD::Halt() { + Error error; + + if (kill(GetID(), SIGSTOP) != 0) + error.SetErrorToErrno(); + + return error; +} + +Error NativeProcessNetBSD::Detach() { + Error error; + + // Stop monitoring the inferior. + m_sigchld_handle.reset(); + + // Tell ptrace to detach from the process. + if (GetID() == LLDB_INVALID_PROCESS_ID) + return error; + + return PtraceWrapper(PT_DETACH, GetID()); +} + +Error NativeProcessNetBSD::Signal(int signo) { + Error error; + + if (kill(GetID(), signo)) + error.SetErrorToErrno(); + + return error; +} + +Error NativeProcessNetBSD::Kill() { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + LLDB_LOG(log, "pid {0}", GetID()); + + Error error; + + switch (m_state) { + case StateType::eStateInvalid: + case StateType::eStateExited: + case StateType::eStateCrashed: + case StateType::eStateDetached: + case StateType::eStateUnloaded: + // Nothing to do - the process is already dead. + LLDB_LOG(log, "ignored for PID {0} due to current state: {1}", GetID(), + StateAsCString(m_state)); + return error; + + case StateType::eStateConnected: + case StateType::eStateAttaching: + case StateType::eStateLaunching: + case StateType::eStateStopped: + case StateType::eStateRunning: + case StateType::eStateStepping: + case StateType::eStateSuspended: + // We can try to kill a process in these states. + break; + } + + if (kill(GetID(), SIGKILL) != 0) { + error.SetErrorToErrno(); + return error; + } + + return error; +} + +Error NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) { + + if (m_supports_mem_region == LazyBool::eLazyBoolNo) { + // We're done. + return Error("unsupported"); + } + + Error error = PopulateMemoryRegionCache(); + if (error.Fail()) { + return error; + } + + lldb::addr_t prev_base_address = 0; + // FIXME start by finding the last region that is <= target address using + // binary search. Data is sorted. + // There can be a ton of regions on pthreads apps with lots of threads. + for (auto it = m_mem_region_cache.begin(); it != m_mem_region_cache.end(); + ++it) { + MemoryRegionInfo &proc_entry_info = it->first; + // Sanity check assumption that memory map entries are ascending. + assert((proc_entry_info.GetRange().GetRangeBase() >= prev_base_address) && + "descending memory map entries detected, unexpected"); + prev_base_address = proc_entry_info.GetRange().GetRangeBase(); + UNUSED_IF_ASSERT_DISABLED(prev_base_address); + // If the target address comes before this entry, indicate distance to next + // region. + if (load_addr < proc_entry_info.GetRange().GetRangeBase()) { + range_info.GetRange().SetRangeBase(load_addr); + range_info.GetRange().SetByteSize( + proc_entry_info.GetRange().GetRangeBase() - load_addr); + range_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo); + range_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo); + range_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo); + range_info.SetMapped(MemoryRegionInfo::OptionalBool::eNo); + return error; + } else if (proc_entry_info.GetRange().Contains(load_addr)) { + // The target address is within the memory region we're processing here. + range_info = proc_entry_info; + return error; + } + // The target memory address comes somewhere after the region we just + // parsed. + } + // If we made it here, we didn't find an entry that contained the given + // address. Return the + // load_addr as start and the amount of bytes betwwen load address and the end + // of the memory as + // size. + range_info.GetRange().SetRangeBase(load_addr); + range_info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS); + range_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo); + range_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo); + range_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo); + range_info.SetMapped(MemoryRegionInfo::OptionalBool::eNo); + return error; +} + +Error NativeProcessNetBSD::PopulateMemoryRegionCache() { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + // If our cache is empty, pull the latest. There should always be at least + // one memory region if memory region handling is supported. + if (!m_mem_region_cache.empty()) { + LLDB_LOG(log, "reusing {0} cached memory region entries", + m_mem_region_cache.size()); + return Error(); + } + + struct kinfo_vmentry *vm; + size_t count, i; + vm = kinfo_getvmmap(GetID(), &count); + if (vm == NULL) { + m_supports_mem_region = LazyBool::eLazyBoolNo; + Error error; + error.SetErrorString("not supported"); + return error; + } + for (i = 0; i < count; i++) { + MemoryRegionInfo info; + info.Clear(); + info.GetRange().SetRangeBase(vm[i].kve_start); + info.GetRange().SetRangeEnd(vm[i].kve_end); + info.SetMapped(MemoryRegionInfo::OptionalBool::eYes); + + if (vm[i].kve_protection & VM_PROT_READ) + info.SetReadable(MemoryRegionInfo::OptionalBool::eYes); + else + info.SetReadable(MemoryRegionInfo::OptionalBool::eNo); + + if (vm[i].kve_protection & VM_PROT_WRITE) + info.SetWritable(MemoryRegionInfo::OptionalBool::eYes); + else + info.SetWritable(MemoryRegionInfo::OptionalBool::eNo); + + if (vm[i].kve_protection & VM_PROT_EXECUTE) + info.SetExecutable(MemoryRegionInfo::OptionalBool::eYes); + else + info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo); + + if (vm[i].kve_path[0]) + info.SetName(vm[i].kve_path); + + m_mem_region_cache.emplace_back( + info, FileSpec(info.GetName().GetCString(), true)); + } + free(vm); + + if (m_mem_region_cache.empty()) { + // No entries after attempting to read them. This shouldn't happen. + // Assume we don't support map entries. + LLDB_LOG(log, "failed to find any vmmap entries, assuming no support " + "for memory region metadata retrieval"); + m_supports_mem_region = LazyBool::eLazyBoolNo; + Error error; + error.SetErrorString("not supported"); + return error; + } + LLDB_LOG(log, "read {0} memory region entries from process {1}", + m_mem_region_cache.size(), GetID()); + // We support memory retrieval, remember that. + m_supports_mem_region = LazyBool::eLazyBoolYes; + return Error(); +} + +Error NativeProcessNetBSD::AllocateMemory(size_t size, uint32_t permissions, + lldb::addr_t &addr) { + return Error("Unimplemented"); +} + +Error NativeProcessNetBSD::DeallocateMemory(lldb::addr_t addr) { + return Error("Unimplemented"); +} + +lldb::addr_t NativeProcessNetBSD::GetSharedLibraryInfoAddress() { + // punt on this for now + return LLDB_INVALID_ADDRESS; +} + +size_t NativeProcessNetBSD::UpdateThreads() { return m_threads.size(); } + +bool NativeProcessNetBSD::GetArchitecture(ArchSpec &arch) const { + arch = m_arch; + return true; +} + +Error NativeProcessNetBSD::SetBreakpoint(lldb::addr_t addr, uint32_t size, + bool hardware) { + if (hardware) + return Error("NativeProcessNetBSD does not support hardware breakpoints"); + else + return SetSoftwareBreakpoint(addr, size); +} + +Error NativeProcessNetBSD::GetSoftwareBreakpointTrapOpcode( + size_t trap_opcode_size_hint, size_t &actual_opcode_size, + const uint8_t *&trap_opcode_bytes) { + static const uint8_t g_i386_opcode[] = {0xCC}; + + switch (m_arch.GetMachine()) { + case llvm::Triple::x86: + case llvm::Triple::x86_64: + trap_opcode_bytes = g_i386_opcode; + actual_opcode_size = sizeof(g_i386_opcode); + return Error(); + default: + assert(false && "CPU type not supported!"); + return Error("CPU type not supported"); + } +} + +Error NativeProcessNetBSD::GetLoadedModuleFileSpec(const char *module_path, + FileSpec &file_spec) { + return Error("Unimplemented"); +} + +Error NativeProcessNetBSD::GetFileLoadAddress(const llvm::StringRef &file_name, + lldb::addr_t &load_addr) { + load_addr = LLDB_INVALID_ADDRESS; + return Error(); +} + +Error NativeProcessNetBSD::LaunchInferior(MainLoop &mainloop, + ProcessLaunchInfo &launch_info) { + Error error; + m_sigchld_handle = mainloop.RegisterSignal( + SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, error); + if (!m_sigchld_handle) + return error; + + SetState(eStateLaunching); + + ::pid_t pid = ProcessLauncherPosixFork() + .LaunchProcess(launch_info, error) + .GetProcessId(); + if (error.Fail()) + return error; + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + + // Wait for the child process to trap on its call to execve. + ::pid_t wpid; + int status; + if ((wpid = waitpid(pid, &status, 0)) < 0) { + error.SetErrorToErrno(); + LLDB_LOG(log, "waitpid for inferior failed with %s", error); + + // Mark the inferior as invalid. + // FIXME this could really use a new state - eStateLaunchFailure. For now, + // using eStateInvalid. + SetState(StateType::eStateInvalid); + + return error; + } + assert(WIFSTOPPED(status) && (wpid == static_cast<::pid_t>(pid)) && + "Could not sync with inferior process."); + + LLDB_LOG(log, "inferior started, now in stopped state"); + + // Release the master terminal descriptor and pass it off to the + // NativeProcessNetBSD instance. Similarly stash the inferior pid. + m_terminal_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor(); + m_pid = pid; + launch_info.SetProcessID(pid); + + if (m_terminal_fd != -1) { + error = EnsureFDFlags(m_terminal_fd, O_NONBLOCK); + if (error.Fail()) { + LLDB_LOG(log, + "inferior EnsureFDFlags failed for ensuring terminal " + "O_NONBLOCK setting: {0}", + error); + + // Mark the inferior as invalid. + // FIXME this could really use a new state - eStateLaunchFailure. For + // now, using eStateInvalid. + SetState(StateType::eStateInvalid); + + return error; + } + } + + LLDB_LOG(log, "adding pid = {0}", pid); + + ResolveProcessArchitecture(m_pid, m_arch); + + /* Initialize threads */ + struct ptrace_lwpinfo info = {}; + error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); + if (error.Fail()) { + SetState(StateType::eStateInvalid); + return error; + } + while (info.pl_lwpid != 0) { + NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid); + thread_sp->SetStoppedBySignal(SIGSTOP); + error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); + if (error.Fail()) { + SetState(StateType::eStateInvalid); + return error; + } + } + + /* Set process stopped */ + SetState(StateType::eStateStopped); + + if (error.Fail()) + LLDB_LOG(log, "inferior launching failed {0}", error); + return error; +} + +void NativeProcessNetBSD::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, + Error &error) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + LLDB_LOG(log, "pid = {0:x}", pid); + + m_sigchld_handle = mainloop.RegisterSignal( + SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, error); + if (!m_sigchld_handle) + return; + + error = ResolveProcessArchitecture(pid, m_arch); + if (!error.Success()) + return; + + // Set the architecture to the exe architecture. + LLDB_LOG(log, "pid = {0:x}, detected architecture {1}", pid, + m_arch.GetArchitectureName()); + + m_pid = pid; + SetState(eStateAttaching); + + Attach(pid, error); +} + +void NativeProcessNetBSD::SigchldHandler() { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + // Process all pending waitpid notifications. + int status; + ::pid_t wait_pid = waitpid(GetID(), &status, WALLSIG | WNOHANG); + + if (wait_pid == 0) + return; // We are done. + + if (wait_pid == -1) { + if (errno == EINTR) + return; + + Error error(errno, eErrorTypePOSIX); + LLDB_LOG(log, "waitpid ({0}, &status, _) failed: {1}", GetID(), error); + } + + bool exited = false; + int signal = 0; + int exit_status = 0; + const char *status_cstr = nullptr; + if (WIFSTOPPED(status)) { + signal = WSTOPSIG(status); + status_cstr = "STOPPED"; + } else if (WIFEXITED(status)) { + exit_status = WEXITSTATUS(status); + status_cstr = "EXITED"; + exited = true; + } else if (WIFSIGNALED(status)) { + signal = WTERMSIG(status); + status_cstr = "SIGNALED"; + if (wait_pid == static_cast<::pid_t>(GetID())) { + exited = true; + exit_status = -1; + } + } else + status_cstr = "(\?\?\?)"; + + LLDB_LOG(log, + "waitpid ({0}, &status, _) => pid = {1}, status = {2:x} " + "({3}), signal = {4}, exit_state = {5}", + GetID(), wait_pid, status, status_cstr, signal, exit_status); + + if (exited) + MonitorExited(wait_pid, signal, exit_status); + else + MonitorCallback(wait_pid, signal); +} + +NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) { + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + LLDB_LOG(log, "pid {0} adding thread with tid {1}", GetID(), thread_id); + + assert(!HasThreadNoLock(thread_id) && + "attempted to add a thread by id that already exists"); + + // If this is the first thread, save it as the current thread + if (m_threads.empty()) + SetCurrentThreadID(thread_id); + + auto thread_sp = std::make_shared(this, thread_id); + m_threads.push_back(thread_sp); + return thread_sp; +} + +::pid_t NativeProcessNetBSD::Attach(lldb::pid_t pid, Error &error) { + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); + + // Use a map to keep track of the threads which we have attached/need to + // attach. + Host::TidMap tids_to_attach; + if (pid <= 1) { + error.SetErrorToGenericError(); + error.SetErrorString("Attaching to process 1 is not allowed."); + return -1; + } + + // Attach to the requested process. + // An attach will cause the thread to stop with a SIGSTOP. + error = PtraceWrapper(PT_ATTACH, pid); + if (error.Fail()) + return -1; + + int status; + // Need to use WALLSIG otherwise we receive an error with errno=ECHLD + // At this point we should have a thread stopped if waitpid succeeds. + if ((status = waitpid(pid, NULL, WALLSIG)) < 0) + return -1; + + m_pid = pid; + + /* Initialize threads */ + struct ptrace_lwpinfo info = {}; + error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); + if (error.Fail()) { + SetState(StateType::eStateInvalid); + return -1; + } + while (info.pl_lwpid != 0) { + NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid); + thread_sp->SetStoppedBySignal(SIGSTOP); + error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); + if (error.Fail()) { + SetState(StateType::eStateInvalid); + return -1; + } + } + + // Let our process instance know the thread has stopped. + SetState(StateType::eStateStopped); + + return pid; +} + +Error NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read) { + unsigned char *dst = static_cast(buf); + struct ptrace_io_desc io; + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); + LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); + + bytes_read = 0; + io.piod_op = PIOD_READ_D; + io.piod_len = size; + + do { + io.piod_offs = (void *)(addr + bytes_read); + io.piod_addr = dst + bytes_read; + + Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); + if (error.Fail()) + return error; + + bytes_read = io.piod_len; + io.piod_len = size - bytes_read; + } while (bytes_read < size); + + return Error(); +} + +Error NativeProcessNetBSD::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, + size_t size, + size_t &bytes_read) { + Error error = ReadMemory(addr, buf, size, bytes_read); + if (error.Fail()) + return error; + return m_breakpoint_list.RemoveTrapsFromBuffer(addr, buf, size); +} + +Error NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf, + size_t size, size_t &bytes_written) { + const unsigned char *src = static_cast(buf); + Error error; + struct ptrace_io_desc io; + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); + LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); + + bytes_written = 0; + io.piod_op = PIOD_WRITE_D; + io.piod_len = size; + + do { + io.piod_addr = (void *)(src + bytes_written); + io.piod_offs = (void *)(addr + bytes_written); + + Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); + if (error.Fail()) + return error; + + bytes_written = io.piod_len; + io.piod_len = size - bytes_written; + } while (bytes_written < size); + + return error; +} + +llvm::ErrorOr> +NativeProcessNetBSD::GetAuxvData() const { + /* + * ELF_AUX_ENTRIES is currently restricted to kernel + * ( r. 1.155 specifies 15) + * + * ptrace(2) returns the whole AUXV including extra fiels after AT_NULL this + * information isn't needed. + */ + size_t auxv_size = 100 * sizeof(AuxInfo); + + ErrorOr> buf = + llvm::MemoryBuffer::getNewMemBuffer(auxv_size); + + struct ptrace_io_desc io = {.piod_op = PIOD_READ_AUXV, + .piod_offs = 0, + .piod_addr = (void *)buf.get()->getBufferStart(), + .piod_len = auxv_size}; + + Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); + + if (error.Fail()) + return std::error_code(error.GetError(), std::generic_category()); + + if (io.piod_len < 1) + return std::error_code(ECANCELED, std::generic_category()); + + return buf; +} Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h?rev=298953&r1=298952&r2=298953&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h Tue Mar 28 17:43:17 2017 @@ -39,8 +39,98 @@ class NativeProcessNetBSD : public Nativ lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop, NativeProcessProtocolSP &process_sp); +public: + // --------------------------------------------------------------------- + // NativeProcessProtocol Interface + // --------------------------------------------------------------------- + Error Resume(const ResumeActionList &resume_actions) override; + + Error Halt() override; + + Error Detach() override; + + Error Signal(int signo) override; + + Error Kill() override; + + Error GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) override; + + Error ReadMemory(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read) override; + + Error ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read) override; + + Error WriteMemory(lldb::addr_t addr, const void *buf, size_t size, + size_t &bytes_written) override; + + Error AllocateMemory(size_t size, uint32_t permissions, + lldb::addr_t &addr) override; + + Error DeallocateMemory(lldb::addr_t addr) override; + + lldb::addr_t GetSharedLibraryInfoAddress() override; + + size_t UpdateThreads() override; + + bool GetArchitecture(ArchSpec &arch) const override; + + Error SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override; + + Error GetLoadedModuleFileSpec(const char *module_path, + FileSpec &file_spec) override; + + Error GetFileLoadAddress(const llvm::StringRef &file_name, + lldb::addr_t &load_addr) override; + + llvm::ErrorOr> + GetAuxvData() const override; + + // --------------------------------------------------------------------- + // Interface used by NativeRegisterContext-derived classes. + // --------------------------------------------------------------------- + static Error PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, + int data = 0, int *result = nullptr); + +protected: + // --------------------------------------------------------------------- + // NativeProcessProtocol protected interface + // --------------------------------------------------------------------- + + Error + GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint, + size_t &actual_opcode_size, + const uint8_t *&trap_opcode_bytes) override; + private: + MainLoop::SignalHandleUP m_sigchld_handle; + ArchSpec m_arch; + LazyBool m_supports_mem_region; + std::vector> m_mem_region_cache; + + // --------------------------------------------------------------------- + // Private Instance Methods + // --------------------------------------------------------------------- NativeProcessNetBSD(); + + NativeThreadNetBSDSP AddThread(lldb::tid_t thread_id); + + Error LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info); + void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Error &error); + + void MonitorCallback(lldb::pid_t pid, int signal); + void MonitorExited(lldb::pid_t pid, int signal, int status); + void MonitorSIGSTOP(lldb::pid_t pid); + void MonitorSIGTRAP(lldb::pid_t pid); + void MonitorSignal(lldb::pid_t pid, int signal); + + Error GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); + Error FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread); + Error PopulateMemoryRegionCache(); + void SigchldHandler(); + + ::pid_t Attach(lldb::pid_t pid, Error &error); }; } // namespace process_netbsd Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp?rev=298953&r1=298952&r2=298953&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp Tue Mar 28 17:43:17 2017 @@ -9,11 +9,58 @@ #include "NativeRegisterContextNetBSD.h" +#include "lldb/Host/common/NativeProcessProtocol.h" + using namespace lldb_private; using namespace lldb_private::process_netbsd; +// clang-format off +#include +#include +// clang-format on + NativeRegisterContextNetBSD::NativeRegisterContextNetBSD( NativeThreadProtocol &native_thread, uint32_t concrete_frame_idx, RegisterInfoInterface *reg_info_interface_p) : NativeRegisterContextRegisterInfo(native_thread, concrete_frame_idx, reg_info_interface_p) {} + +Error NativeRegisterContextNetBSD::ReadGPR() { + void *buf = GetGPRBuffer(); + if (!buf) + return Error("GPR buffer is NULL"); + + return DoReadGPR(buf); +} + +Error NativeRegisterContextNetBSD::WriteGPR() { + void *buf = GetGPRBuffer(); + if (!buf) + return Error("GPR buffer is NULL"); + + return DoWriteGPR(buf); +} + +Error NativeRegisterContextNetBSD::DoReadGPR(void *buf) { + return NativeProcessNetBSD::PtraceWrapper(PT_GETREGS, GetProcessPid(), buf, + m_thread.GetID()); +} + +Error NativeRegisterContextNetBSD::DoWriteGPR(void *buf) { + return NativeProcessNetBSD::PtraceWrapper(PT_SETREGS, GetProcessPid(), buf, + m_thread.GetID()); +} + +NativeProcessNetBSD &NativeRegisterContextNetBSD::GetProcess() { + auto process_sp = + std::static_pointer_cast(m_thread.GetProcess()); + assert(process_sp); + return *process_sp; +} + +::pid_t NativeRegisterContextNetBSD::GetProcessPid() { + NativeProcessNetBSD &process = GetProcess(); + lldb::pid_t pid = process.GetID(); + + return pid; +} Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h?rev=298953&r1=298952&r2=298953&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h Tue Mar 28 17:43:17 2017 @@ -33,6 +33,19 @@ public: CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch, NativeThreadProtocol &native_thread, uint32_t concrete_frame_idx); + +protected: + virtual Error ReadGPR(); + virtual Error WriteGPR(); + virtual void *GetGPRBuffer() { return nullptr; } + virtual size_t GetGPRSize() { + return GetRegisterInfoInterface().GetGPRSize(); + } + virtual Error DoReadGPR(void *buf); + virtual Error DoWriteGPR(void *buf); + + virtual NativeProcessNetBSD &GetProcess(); + virtual ::pid_t GetProcessPid(); }; } // namespace process_netbsd Added: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp?rev=298953&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp (added) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp Tue Mar 28 17:43:17 2017 @@ -0,0 +1,477 @@ +//===-- NativeRegisterContextNetBSD_x86_64.cpp ---------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if defined(__x86_64__) + +#include "NativeRegisterContextNetBSD_x86_64.h" + +#include "lldb/Core/RegisterValue.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/Error.h" +#include "lldb/Utility/Log.h" + +#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h" + +#include + +using namespace lldb_private; +using namespace lldb_private::process_netbsd; + +// ---------------------------------------------------------------------------- +// Private namespace. +// ---------------------------------------------------------------------------- + +namespace { +// x86 64-bit general purpose registers. +static const uint32_t g_gpr_regnums_x86_64[] = { + lldb_rax_x86_64, lldb_rbx_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64, + lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rbp_x86_64, lldb_rsp_x86_64, + lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64, + lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64, + lldb_rip_x86_64, lldb_rflags_x86_64, lldb_cs_x86_64, lldb_fs_x86_64, + lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, + lldb_eax_x86_64, lldb_ebx_x86_64, lldb_ecx_x86_64, lldb_edx_x86_64, + lldb_edi_x86_64, lldb_esi_x86_64, lldb_ebp_x86_64, lldb_esp_x86_64, + lldb_r8d_x86_64, // Low 32 bits or r8 + lldb_r9d_x86_64, // Low 32 bits or r9 + lldb_r10d_x86_64, // Low 32 bits or r10 + lldb_r11d_x86_64, // Low 32 bits or r11 + lldb_r12d_x86_64, // Low 32 bits or r12 + lldb_r13d_x86_64, // Low 32 bits or r13 + lldb_r14d_x86_64, // Low 32 bits or r14 + lldb_r15d_x86_64, // Low 32 bits or r15 + lldb_ax_x86_64, lldb_bx_x86_64, lldb_cx_x86_64, lldb_dx_x86_64, + lldb_di_x86_64, lldb_si_x86_64, lldb_bp_x86_64, lldb_sp_x86_64, + lldb_r8w_x86_64, // Low 16 bits or r8 + lldb_r9w_x86_64, // Low 16 bits or r9 + lldb_r10w_x86_64, // Low 16 bits or r10 + lldb_r11w_x86_64, // Low 16 bits or r11 + lldb_r12w_x86_64, // Low 16 bits or r12 + lldb_r13w_x86_64, // Low 16 bits or r13 + lldb_r14w_x86_64, // Low 16 bits or r14 + lldb_r15w_x86_64, // Low 16 bits or r15 + lldb_ah_x86_64, lldb_bh_x86_64, lldb_ch_x86_64, lldb_dh_x86_64, + lldb_al_x86_64, lldb_bl_x86_64, lldb_cl_x86_64, lldb_dl_x86_64, + lldb_dil_x86_64, lldb_sil_x86_64, lldb_bpl_x86_64, lldb_spl_x86_64, + lldb_r8l_x86_64, // Low 8 bits or r8 + lldb_r9l_x86_64, // Low 8 bits or r9 + lldb_r10l_x86_64, // Low 8 bits or r10 + lldb_r11l_x86_64, // Low 8 bits or r11 + lldb_r12l_x86_64, // Low 8 bits or r12 + lldb_r13l_x86_64, // Low 8 bits or r13 + lldb_r14l_x86_64, // Low 8 bits or r14 + lldb_r15l_x86_64, // Low 8 bits or r15 + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; +static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) - + 1 == + k_num_gpr_registers_x86_64, + "g_gpr_regnums_x86_64 has wrong number of register infos"); + +// Number of register sets provided by this context. +enum { k_num_extended_register_sets = 2, k_num_register_sets = 4 }; + +// Register sets for x86 64-bit. +static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = { + {"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64, + g_gpr_regnums_x86_64}, +}; + +#define REG_CONTEXT_SIZE (GetRegisterInfoInterface().GetGPRSize()) + +} // namespace + +NativeRegisterContextNetBSD * +NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD( + const ArchSpec &target_arch, NativeThreadProtocol &native_thread, + uint32_t concrete_frame_idx) { + return new NativeRegisterContextNetBSD_x86_64(target_arch, native_thread, + concrete_frame_idx); +} + +// ---------------------------------------------------------------------------- +// NativeRegisterContextNetBSD_x86_64 members. +// ---------------------------------------------------------------------------- + +static RegisterInfoInterface * +CreateRegisterInfoInterface(const ArchSpec &target_arch) { + assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) && + "Register setting path assumes this is a 64-bit host"); + // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the + // x86_64 register context. + return new RegisterContextNetBSD_x86_64(target_arch); +} + +NativeRegisterContextNetBSD_x86_64::NativeRegisterContextNetBSD_x86_64( + const ArchSpec &target_arch, NativeThreadProtocol &native_thread, + uint32_t concrete_frame_idx) + : NativeRegisterContextNetBSD(native_thread, concrete_frame_idx, + CreateRegisterInfoInterface(target_arch)), + m_gpr_x86_64() {} + +// CONSIDER after local and llgs debugging are merged, register set support can +// be moved into a base x86-64 class with IsRegisterSetAvailable made virtual. +uint32_t NativeRegisterContextNetBSD_x86_64::GetRegisterSetCount() const { + uint32_t sets = 0; + for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) { + if (GetSetForNativeRegNum(set_index) != -1) + ++sets; + } + + return sets; +} + +const RegisterSet * +NativeRegisterContextNetBSD_x86_64::GetRegisterSet(uint32_t set_index) const { + switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) { + case llvm::Triple::x86_64: + return &g_reg_sets_x86_64[set_index]; + default: + assert(false && "Unhandled target architecture."); + return nullptr; + } + + return nullptr; +} + +int NativeRegisterContextNetBSD_x86_64::GetSetForNativeRegNum( + int reg_num) const { + if (reg_num < lldb_fctrl_x86_64) + return GPRegSet; + else + return -1; +} + +int NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) { + switch (set) { + case GPRegSet: + ReadGPR(); + return 0; + default: + break; + } + return -1; +} +int NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) { + switch (set) { + case GPRegSet: + WriteGPR(); + return 0; + default: + break; + } + return -1; +} + +Error NativeRegisterContextNetBSD_x86_64::ReadRegister( + const RegisterInfo *reg_info, RegisterValue ®_value) { + Error error; + + if (!reg_info) { + error.SetErrorString("reg_info NULL"); + return error; + } + + const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB]; + if (reg == LLDB_INVALID_REGNUM) { + // This is likely an internal register for lldb use only and should not be + // directly queried. + error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb " + "register, cannot read directly", + reg_info->name); + return error; + } + + int set = GetSetForNativeRegNum(reg); + if (set == -1) { + // This is likely an internal register for lldb use only and should not be + // directly queried. + error.SetErrorStringWithFormat("register \"%s\" is in unrecognized set", + reg_info->name); + return error; + } + + if (ReadRegisterSet(set) != 0) { + // This is likely an internal register for lldb use only and should not be + // directly queried. + error.SetErrorStringWithFormat( + "reading register set for register \"%s\" failed", reg_info->name); + return error; + } + + switch (reg) { + case lldb_rax_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RAX]; + break; + case lldb_rbx_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RBX]; + break; + case lldb_rcx_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RCX]; + break; + case lldb_rdx_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RDX]; + break; + case lldb_rdi_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RDI]; + break; + case lldb_rsi_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RSI]; + break; + case lldb_rbp_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RBP]; + break; + case lldb_rsp_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RSP]; + break; + case lldb_r8_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R8]; + break; + case lldb_r9_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R9]; + break; + case lldb_r10_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R10]; + break; + case lldb_r11_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R11]; + break; + case lldb_r12_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R12]; + break; + case lldb_r13_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R13]; + break; + case lldb_r14_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R14]; + break; + case lldb_r15_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R15]; + break; + case lldb_rip_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RIP]; + break; + case lldb_rflags_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RFLAGS]; + break; + case lldb_cs_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_CS]; + break; + case lldb_fs_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_FS]; + break; + case lldb_gs_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_GS]; + break; + case lldb_ss_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_SS]; + break; + case lldb_ds_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_DS]; + break; + case lldb_es_x86_64: + reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_ES]; + break; + } + + return error; +} + +Error NativeRegisterContextNetBSD_x86_64::WriteRegister( + const RegisterInfo *reg_info, const RegisterValue ®_value) { + + Error error; + + if (!reg_info) { + error.SetErrorString("reg_info NULL"); + return error; + } + + const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB]; + if (reg == LLDB_INVALID_REGNUM) { + // This is likely an internal register for lldb use only and should not be + // directly queried. + error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb " + "register, cannot read directly", + reg_info->name); + return error; + } + + int set = GetSetForNativeRegNum(reg); + if (set == -1) { + // This is likely an internal register for lldb use only and should not be + // directly queried. + error.SetErrorStringWithFormat("register \"%s\" is in unrecognized set", + reg_info->name); + return error; + } + + if (ReadRegisterSet(set) != 0) { + // This is likely an internal register for lldb use only and should not be + // directly queried. + error.SetErrorStringWithFormat( + "reading register set for register \"%s\" failed", reg_info->name); + return error; + } + + switch (reg) { + case lldb_rax_x86_64: + m_gpr_x86_64.regs[_REG_RAX] = reg_value.GetAsUInt64(); + break; + case lldb_rbx_x86_64: + m_gpr_x86_64.regs[_REG_RBX] = reg_value.GetAsUInt64(); + break; + case lldb_rcx_x86_64: + m_gpr_x86_64.regs[_REG_RCX] = reg_value.GetAsUInt64(); + break; + case lldb_rdx_x86_64: + m_gpr_x86_64.regs[_REG_RDX] = reg_value.GetAsUInt64(); + break; + case lldb_rdi_x86_64: + m_gpr_x86_64.regs[_REG_RDI] = reg_value.GetAsUInt64(); + break; + case lldb_rsi_x86_64: + m_gpr_x86_64.regs[_REG_RSI] = reg_value.GetAsUInt64(); + break; + case lldb_rbp_x86_64: + m_gpr_x86_64.regs[_REG_RBP] = reg_value.GetAsUInt64(); + break; + case lldb_rsp_x86_64: + m_gpr_x86_64.regs[_REG_RSP] = reg_value.GetAsUInt64(); + break; + case lldb_r8_x86_64: + m_gpr_x86_64.regs[_REG_R8] = reg_value.GetAsUInt64(); + break; + case lldb_r9_x86_64: + m_gpr_x86_64.regs[_REG_R9] = reg_value.GetAsUInt64(); + break; + case lldb_r10_x86_64: + m_gpr_x86_64.regs[_REG_R10] = reg_value.GetAsUInt64(); + break; + case lldb_r11_x86_64: + m_gpr_x86_64.regs[_REG_R11] = reg_value.GetAsUInt64(); + break; + case lldb_r12_x86_64: + m_gpr_x86_64.regs[_REG_R12] = reg_value.GetAsUInt64(); + break; + case lldb_r13_x86_64: + m_gpr_x86_64.regs[_REG_R13] = reg_value.GetAsUInt64(); + break; + case lldb_r14_x86_64: + m_gpr_x86_64.regs[_REG_R14] = reg_value.GetAsUInt64(); + break; + case lldb_r15_x86_64: + m_gpr_x86_64.regs[_REG_R15] = reg_value.GetAsUInt64(); + break; + case lldb_rip_x86_64: + m_gpr_x86_64.regs[_REG_RIP] = reg_value.GetAsUInt64(); + break; + case lldb_rflags_x86_64: + m_gpr_x86_64.regs[_REG_RFLAGS] = reg_value.GetAsUInt64(); + break; + case lldb_cs_x86_64: + m_gpr_x86_64.regs[_REG_CS] = reg_value.GetAsUInt64(); + break; + case lldb_fs_x86_64: + m_gpr_x86_64.regs[_REG_FS] = reg_value.GetAsUInt64(); + break; + case lldb_gs_x86_64: + m_gpr_x86_64.regs[_REG_GS] = reg_value.GetAsUInt64(); + break; + case lldb_ss_x86_64: + m_gpr_x86_64.regs[_REG_SS] = reg_value.GetAsUInt64(); + break; + case lldb_ds_x86_64: + m_gpr_x86_64.regs[_REG_DS] = reg_value.GetAsUInt64(); + break; + case lldb_es_x86_64: + m_gpr_x86_64.regs[_REG_ES] = reg_value.GetAsUInt64(); + break; + } + + if (WriteRegisterSet(set) != 0) + error.SetErrorStringWithFormat("failed to write register set"); + + return error; +} + +Error NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues( + lldb::DataBufferSP &data_sp) { + Error error; + + data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); + if (!data_sp) { + error.SetErrorStringWithFormat( + "failed to allocate DataBufferHeap instance of size %" PRIu64, + REG_CONTEXT_SIZE); + return error; + } + + error = ReadGPR(); + if (error.Fail()) + return error; + + uint8_t *dst = data_sp->GetBytes(); + if (dst == nullptr) { + error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 + " returned a null pointer", + REG_CONTEXT_SIZE); + return error; + } + + ::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize()); + dst += GetRegisterInfoInterface().GetGPRSize(); + + RegisterValue value((uint64_t)-1); + const RegisterInfo *reg_info = + GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax"); + if (reg_info == nullptr) + reg_info = GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax"); + return error; +} + +Error NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues( + const lldb::DataBufferSP &data_sp) { + Error error; + + if (!data_sp) { + error.SetErrorStringWithFormat( + "NativeRegisterContextNetBSD_x86_64::%s invalid data_sp provided", + __FUNCTION__); + return error; + } + + if (data_sp->GetByteSize() != REG_CONTEXT_SIZE) { + error.SetErrorStringWithFormat( + "NativeRegisterContextNetBSD_x86_64::%s data_sp contained mismatched " + "data size, expected %" PRIu64 ", actual %" PRIu64, + __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize()); + return error; + } + + uint8_t *src = data_sp->GetBytes(); + if (src == nullptr) { + error.SetErrorStringWithFormat("NativeRegisterContextNetBSD_x86_64::%s " + "DataBuffer::GetBytes() returned a null " + "pointer", + __FUNCTION__); + return error; + } + ::memcpy(&m_gpr_x86_64, src, GetRegisterInfoInterface().GetGPRSize()); + + error = WriteGPR(); + if (error.Fail()) + return error; + src += GetRegisterInfoInterface().GetGPRSize(); + + return error; +} + +#endif // defined(__x86_64__) Added: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h?rev=298953&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h (added) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h Tue Mar 28 17:43:17 2017 @@ -0,0 +1,70 @@ +//===-- NativeRegisterContextNetBSD_x86_64.h --------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if defined(__x86_64__) + +#ifndef lldb_NativeRegisterContextNetBSD_x86_64_h +#define lldb_NativeRegisterContextNetBSD_x86_64_h + +// clang-format off +#include +#include +#include +// clang-format on + +#include "Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h" +#include "Plugins/Process/Utility/RegisterContext_x86.h" +#include "Plugins/Process/Utility/lldb-x86-register-enums.h" + +namespace lldb_private { +namespace process_netbsd { + +class NativeProcessNetBSD; + +class NativeRegisterContextNetBSD_x86_64 : public NativeRegisterContextNetBSD { +public: + NativeRegisterContextNetBSD_x86_64(const ArchSpec &target_arch, + NativeThreadProtocol &native_thread, + uint32_t concrete_frame_idx); + uint32_t GetRegisterSetCount() const override; + + const RegisterSet *GetRegisterSet(uint32_t set_index) const override; + + Error ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) override; + + Error WriteRegister(const RegisterInfo *reg_info, + const RegisterValue ®_value) override; + + Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; + + Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; + +protected: + void *GetGPRBuffer() override { return &m_gpr_x86_64; } + +private: + // Private member types. + enum { GPRegSet }; + + // Private member variables. + struct reg m_gpr_x86_64; + + int GetSetForNativeRegNum(int reg_num) const; + + int ReadRegisterSet(uint32_t set); + int WriteRegisterSet(uint32_t set); +}; + +} // namespace process_netbsd +} // namespace lldb_private + +#endif // #ifndef lldb_NativeRegisterContextNetBSD_x86_64_h + +#endif // defined(__x86_64__) Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp?rev=298953&r1=298952&r2=298953&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp Tue Mar 28 17:43:17 2017 @@ -12,10 +12,131 @@ #include "NativeProcessNetBSD.h" +#include "Plugins/Process/POSIX/CrashReason.h" +#include "Plugins/Process/POSIX/ProcessPOSIXLog.h" +#include "lldb/Core/RegisterValue.h" +#include "lldb/Core/State.h" + using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_netbsd; NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid) - : NativeThreadProtocol(process, tid) {} + : NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid), + m_stop_info(), m_reg_context_sp(), m_stop_description() {} + +void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo, + const siginfo_t *info) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + LLDB_LOG(log, "tid = {0} in called with signal {1}", GetID(), signo); + + SetStopped(); + + m_stop_info.reason = StopReason::eStopReasonSignal; + m_stop_info.details.signal.signo = signo; + + m_stop_description.clear(); + if (info) { + switch (signo) { + case SIGSEGV: + case SIGBUS: + case SIGFPE: + case SIGILL: + const auto reason = GetCrashReason(*info); + m_stop_description = GetCrashReasonString(reason, *info); + break; + } + } +} + +void NativeThreadNetBSD::SetStoppedByBreakpoint() { + SetStopped(); + m_stop_info.reason = StopReason::eStopReasonBreakpoint; + m_stop_info.details.signal.signo = SIGTRAP; +} + +void NativeThreadNetBSD::SetStopped() { + const StateType new_state = StateType::eStateStopped; + m_state = new_state; + m_stop_description.clear(); +} + +void NativeThreadNetBSD::SetRunning() { + m_state = StateType::eStateRunning; + m_stop_info.reason = StopReason::eStopReasonNone; +} + +std::string NativeThreadNetBSD::GetName() { return std::string(""); } + +lldb::StateType NativeThreadNetBSD::GetState() { return m_state; } + +bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info, + std::string &description) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + + description.clear(); + + switch (m_state) { + case eStateStopped: + case eStateCrashed: + case eStateExited: + case eStateSuspended: + case eStateUnloaded: + stop_info = m_stop_info; + description = m_stop_description; + + return true; + + case eStateInvalid: + case eStateConnected: + case eStateAttaching: + case eStateLaunching: + case eStateRunning: + case eStateStepping: + case eStateDetached: + LLDB_LOG(log, "tid = {0} in state {1} cannot answer stop reason", GetID(), + StateAsCString(m_state)); + return false; + } + llvm_unreachable("unhandled StateType!"); +} + +NativeRegisterContextSP NativeThreadNetBSD::GetRegisterContext() { + // Return the register context if we already created it. + if (m_reg_context_sp) + return m_reg_context_sp; + + NativeProcessProtocolSP m_process_sp = m_process_wp.lock(); + if (!m_process_sp) + return NativeRegisterContextSP(); + + ArchSpec target_arch; + if (!m_process_sp->GetArchitecture(target_arch)) + return NativeRegisterContextSP(); + + const uint32_t concrete_frame_idx = 0; + m_reg_context_sp.reset( + NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD( + target_arch, *this, concrete_frame_idx)); + + return m_reg_context_sp; +} + +Error NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size, + uint32_t watch_flags, bool hardware) { + return Error("Unimplemented"); +} + +Error NativeThreadNetBSD::RemoveWatchpoint(lldb::addr_t addr) { + return Error("Unimplemented"); +} + +Error NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr, + size_t size) { + return Error("Unimplemented"); +} + +Error NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) { + return Error("Unimplemented"); +} Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h?rev=298953&r1=298952&r2=298953&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h Tue Mar 28 17:43:17 2017 @@ -22,6 +22,45 @@ class NativeThreadNetBSD : public Native public: NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid); + + // --------------------------------------------------------------------- + // NativeThreadProtocol Interface + // --------------------------------------------------------------------- + std::string GetName() override; + + lldb::StateType GetState() override; + + bool GetStopReason(ThreadStopInfo &stop_info, + std::string &description) override; + + NativeRegisterContextSP GetRegisterContext() override; + + Error SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, + bool hardware) override; + + Error RemoveWatchpoint(lldb::addr_t addr) override; + + Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override; + + Error RemoveHardwareBreakpoint(lldb::addr_t addr) override; + +private: + // --------------------------------------------------------------------- + // Interface for friend classes + // --------------------------------------------------------------------- + + void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr); + void SetStoppedByBreakpoint(); + void SetStopped(); + void SetRunning(); + + // --------------------------------------------------------------------- + // Member Variables + // --------------------------------------------------------------------- + lldb::StateType m_state; + ThreadStopInfo m_stop_info; + NativeRegisterContextSP m_reg_context_sp; + std::string m_stop_description; }; typedef std::shared_ptr NativeThreadNetBSDSP; From lldb-commits at lists.llvm.org Tue Mar 28 15:55:44 2017 From: lldb-commits at lists.llvm.org (Phabricator via Phabricator via lldb-commits) Date: Tue, 28 Mar 2017 22:55:44 +0000 Subject: [Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD In-Reply-To: References: Message-ID: <50d35bbf4bc9f95b1b9f00ce8b5a1158@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rL298953: Add support for tracing hello-world application on NetBSD (authored by kamil). Changed prior to commit: https://reviews.llvm.org/D31374?vs=93312&id=93315#toc Repository: rL LLVM https://reviews.llvm.org/D31374 Files: lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D31374.93315.patch Type: text/x-patch Size: 65139 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Tue Mar 28 16:25:34 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Tue, 28 Mar 2017 23:25:34 -0000 Subject: [Lldb-commits] [lldb] r298958 - Print the error if dsymForUUID sometimes produces bad plists. Message-ID: <20170328232534.76C952A6C0AB@llvm.org> Author: jingham Date: Tue Mar 28 18:25:34 2017 New Revision: 298958 URL: http://llvm.org/viewvc/llvm-project?rev=298958&view=rev Log: Print the error if dsymForUUID sometimes produces bad plists. Not much we can do about it but at least we can print the bad plist and the error. Modified: lldb/trunk/examples/python/crashlog.py Modified: lldb/trunk/examples/python/crashlog.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/crashlog.py?rev=298958&r1=298957&r2=298958&view=diff ============================================================================== --- lldb/trunk/examples/python/crashlog.py (original) +++ lldb/trunk/examples/python/crashlog.py Tue Mar 28 18:25:34 2017 @@ -259,7 +259,11 @@ class CrashLog(symbolication.Symbolicato self.dsymForUUIDBinary, uuid_str) s = commands.getoutput(dsym_for_uuid_command) if s: - plist_root = plistlib.readPlistFromString(s) + try: + plist_root = plistlib.readPlistFromString(s) + except: + print("Got exception: ", sys.exc_value, " handling dsymForUUID output: \n", s) + raise if plist_root: plist = plist_root[uuid_str] if plist: From lldb-commits at lists.llvm.org Tue Mar 28 18:10:21 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via lldb-commits) Date: Wed, 29 Mar 2017 01:10:21 -0000 Subject: [Lldb-commits] [lldb] r298970 - Remove dead include from the NetBSD code. Message-ID: <20170329011021.F248C2A6C0AB@llvm.org> Author: kamil Date: Tue Mar 28 20:10:21 2017 New Revision: 298970 URL: http://llvm.org/viewvc/llvm-project?rev=298970&view=rev Log: Remove dead include from the NetBSD code. Modified: lldb/trunk/source/Host/netbsd/Host.cpp Modified: lldb/trunk/source/Host/netbsd/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/Host.cpp?rev=298970&r1=298969&r2=298970&view=diff ============================================================================== --- lldb/trunk/source/Host/netbsd/Host.cpp (original) +++ lldb/trunk/source/Host/netbsd/Host.cpp Tue Mar 28 20:10:21 2017 @@ -1,5 +1,4 @@ -//===-- source/Host/netbsd/Host.cpp ------------------------------*- C++ -//-*-===// +//===-- source/Host/netbsd/Host.cpp -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,7 +14,6 @@ #include #include #include -#include #include From lldb-commits at lists.llvm.org Tue Mar 28 20:22:08 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 03:22:08 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements Message-ID: krytarowski created this revision. krytarowski added a project: LLDB. Include initial support for: - single step mode (PT_STEP) - single step trap handling (TRAP_TRACE) - exec() trap (TRAP_EXEC) - add placeholder interfaces for FPR - initial code for NetBSD core(5) files - minor tweaks While there improve style of altered elf-core/ files. This code raises the number of passing tests on NetBSD to around 50% (600+/1200+). The introduced code is subject to improve afterwards for additional features and bug fixes. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31450 Files: source/Host/common/Host.cpp source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h source/Plugins/Process/elf-core/ProcessElfCore.cpp source/Plugins/Process/elf-core/ThreadElfCore.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31450.93334.patch Type: text/x-patch Size: 15891 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Tue Mar 28 20:27:55 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 03:27:55 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: krytarowski added a comment. Next: watchpoints, FPR. Current core(5) file format is a subject to change (AUXV can be shortened)... I'm working on the final nits for the NetBSD-8 interfaces. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Tue Mar 28 21:02:00 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 04:02:00 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <81807c16adf15caada91bdd9aa5fd9eb@localhost.localdomain> krytarowski added a reviewer: jingham. krytarowski added a comment. Adding Jim as a reviewer, since Pavel is mostly out of the keyboard for longer time. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Tue Mar 28 23:28:23 2017 From: lldb-commits at lists.llvm.org (Ilia K via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 06:28:23 +0000 Subject: [Lldb-commits] [PATCH] D31073: Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope In-Reply-To: References: Message-ID: <360ee35dcff04ee676684d3a87f14aed@localhost.localdomain> ki.stfu requested changes to this revision. ki.stfu added a comment. This revision now requires changes to proceed. Hi. LGTM. Just fix a few minor issues before committing. Thank you for your contribution to LLDB project! ================ Comment at: packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/Makefile:1 +LEVEL = ../../../make + ---------------- Rename directory to lexical**_**scope. ================ Comment at: packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py:1 +# coding=utf8 +""" ---------------- Remove please. We don't specify encoding in other files. ================ Comment at: packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py:1 +# coding=utf8 +""" ---------------- ki.stfu wrote: > Remove please. We don't specify encoding in other files. Rename this to packages/Python/lldbsuite/test/tools/lldb-mi/lexical**_**scope/Test**Mi**LexicalScope.py. https://reviews.llvm.org/D31073 From lldb-commits at lists.llvm.org Wed Mar 29 02:06:29 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 09:06:29 +0000 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: Message-ID: <4a0927b65d62c7d075c9be00bad1c5de@localhost.localdomain> tberghammer added a comment. SBValue::SetName is not part of the SB API (what is the right decision IMO as an SBValue should be mostly immutable) so this issue doesn't effect it. I looked through the code in examples/synthetic/gnu_libstdcpp.py and it is always using one of the SBValue::Create* method to produce new SBValue what will create a new value object one way or the other. Considering that nobody complained about the missing SetName method at the SB API level I don't see a big need for exposing the Clone method there. At the same line if SetName/Clone isn't part of the SB API then I think we shouldn't document it at the webpage. (I will upload a fix for the spelling errors later) https://reviews.llvm.org/D31371 From lldb-commits at lists.llvm.org Wed Mar 29 06:39:31 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 13:39:31 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: labath added inline comments. ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:249 + // Initialize new thread + struct ptrace_lwpinfo info = {}; + Error error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); ---------------- This is the third place i'm seeing this code. Any chance of turning it into a function? ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:447 + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStepping(); + } ---------------- I guess you should be playing with the pt_suspend/resume here to step only the requested thread(s). Is that something you plan to do as a follow up? Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Wed Mar 29 07:00:21 2017 From: lldb-commits at lists.llvm.org (Igor Kulaychuk via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 14:00:21 +0000 Subject: [Lldb-commits] [PATCH] D31073: Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope In-Reply-To: References: Message-ID: ayuckhulk updated this revision to Diff 93369. ayuckhulk added a comment. Thank you for the review! I've updated the patch with requested changes: - renamed `lexical-scope` to `lexical_scope`, - renamed `TestLexicalScope.py` to `TestMiLexicalScope.py` - removed utf8 encoding string https://reviews.llvm.org/D31073 Files: packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp tools/lldb-mi/MICmdCmdStack.cpp tools/lldb-mi/MICmdCmdVar.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31073.93369.patch Type: text/x-patch Size: 6218 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Wed Mar 29 07:09:38 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 14:09:38 +0000 Subject: [Lldb-commits] [PATCH] D31461: Add NetBSD path for Debugging Information in Separate Files Message-ID: krytarowski created this revision. krytarowski added a project: LLDB. Herald added a subscriber: aprantl. NetBSD stores debug information files in the `/usr/libdata/debug` path. This change fixes debugging distribution executables, e.g. `look`(1): $ lldb /usr/bin/look (lldb) target create "/usr/bin/look" Current executable set to '/usr/bin/look' (x86_64). (lldb) b main Breakpoint 1: where = look`main + 22 at look.c:107, address = 0x0000000000000da6 (lldb) r Process 23473 launched: '/usr/bin/look' (x86_64) Process 23473 stopped * thread #1, stop reason = breakpoint 1.1 frame #0: 0x0000000186600da6 look`main(argc=1, argv=0x00007f7fffc7c488) at look.c:107 104 105 string = NULL; 106 file = _PATH_WORDS; -> 107 termchar = '\0'; 108 while ((ch = getopt(argc, argv, "dft:")) != -1) 109 switch(ch) { 110 case 'd': (lldb) There is no `/usr/lib/debug` path on NeBSD, so remove it from search. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31461 Files: source/Host/common/Symbols.cpp Index: source/Host/common/Symbols.cpp =================================================================== --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -212,8 +212,13 @@ debug_file_search_paths.AppendIfUnique(FileSpec(".", true)); #ifndef LLVM_ON_WIN32 +#if defined(__NetBSD__) + // Add /usr/libdata/debug directory. + debug_file_search_paths.AppendIfUnique(FileSpec("/usr/libdata/debug", true)); +#else // Add /usr/lib/debug directory. debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true)); +#endif #endif // LLVM_ON_WIN32 std::string uuid_str; -------------- next part -------------- A non-text attachment was scrubbed... Name: D31461.93371.patch Type: text/x-patch Size: 624 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Wed Mar 29 07:24:43 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 14:24:43 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <804a17998383c357af2ac5adf9e2f2d5@localhost.localdomain> krytarowski added inline comments. ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:249 + // Initialize new thread + struct ptrace_lwpinfo info = {}; + Error error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); ---------------- labath wrote: > This is the third place i'm seeing this code. Any chance of turning it into a function? Everything that touches threads will be refactored in future. I suspect that at the end this code will lost its capability to iterate threads after exec() as all of them are terminated. Here is a code that handles it in an expanded way and fore 1 thread only. ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:447 + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStepping(); + } ---------------- labath wrote: > I guess you should be playing with the pt_suspend/resume here to step only the requested thread(s). Is that something you plan to do as a follow up? I'm planning to reuse PT_RESUME/PT_SUSPEND to select thread/s for execution. And reuse PT_SETSTEP/PT_CLEARSTEP to mark them optionally for single-step mode. And at the end use global PT_CONTINUE as it has option to emit a signal (PT_STEP cannot send a signal). Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Wed Mar 29 07:27:12 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 14:27:12 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <269b8a4a09df54ac8e3e6628fd31068c@localhost.localdomain> krytarowski added a comment. I think I will start the threading segment with proper handling of core(5) files. It looks like the simplest start point. OpenBSD uses very similar format and can catch up quickly. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Wed Mar 29 07:32:04 2017 From: lldb-commits at lists.llvm.org (Mark Kettenis via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 14:32:04 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <504bc819e73eddd709eb1bc8aaca8458@localhost.localdomain> kettenis added a comment. The core file reading bits look ok to me. ================ Comment at: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp:383 // On Linux the executable is indicated by an empty path in the entry. On // FreeBSD and on Android it is the full path to the executable. ---------------- Probably should update this comment ================ Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:456 +} + // Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details. ---------------- Unfortunate that the note numbers are different from architecture to architecture on NetBSD. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Wed Mar 29 07:42:12 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 14:42:12 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <431589ec85882d302876e707faa6e467@localhost.localdomain> krytarowski added inline comments. ================ Comment at: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp:383 // On Linux the executable is indicated by an empty path in the entry. On // FreeBSD and on Android it is the full path to the executable. ---------------- kettenis wrote: > Probably should update this comment Right! ================ Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:456 +} + // Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details. ---------------- kettenis wrote: > Unfortunate that the note numbers are different from architecture to architecture on NetBSD. Yes, we reuse `PT_GETREGS` and `PT_GETFPREGS` per port variables. This is placeholder to start working on amd64 with threading support. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Wed Mar 29 08:10:39 2017 From: lldb-commits at lists.llvm.org (Ilia K via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 15:10:39 +0000 Subject: [Lldb-commits] [PATCH] D31073: Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope In-Reply-To: References: Message-ID: <7757cd65971e47f587c65fa8209778e4@localhost.localdomain> ki.stfu accepted this revision. ki.stfu added a comment. This revision is now accepted and ready to land. Would you like me to commit it? https://reviews.llvm.org/D31073 From lldb-commits at lists.llvm.org Wed Mar 29 08:28:53 2017 From: lldb-commits at lists.llvm.org (Igor Kulaychuk via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 15:28:53 +0000 Subject: [Lldb-commits] [PATCH] D31073: Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope In-Reply-To: References: Message-ID: <9efe82523fffa9ffeb1268a60ff185ee@localhost.localdomain> ayuckhulk added a comment. Yes, please do. https://reviews.llvm.org/D31073 From lldb-commits at lists.llvm.org Wed Mar 29 10:11:55 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Wed, 29 Mar 2017 10:11:55 -0700 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: <4a0927b65d62c7d075c9be00bad1c5de@localhost.localdomain> References: <4a0927b65d62c7d075c9be00bad1c5de@localhost.localdomain> Message-ID: <982C83F9-BB48-41FA-8C9A-45DD5CD6B7E5@apple.com> > On Mar 29, 2017, at 2:06 AM, Tamas Berghammer via Phabricator wrote: > > tberghammer added a comment. > > SBValue::SetName is not part of the SB API (what is the right decision IMO as an SBValue should be mostly immutable) so this issue doesn't effect it. I looked through the code in examples/synthetic/gnu_libstdcpp.py and it is always using one of the SBValue::Create* method to produce new SBValue what will create a new value object one way or the other. Considering that nobody complained about the missing SetName method at the SB API level I don't see a big need for exposing the Clone method there. At the same line if SetName/Clone isn't part of the SB API then I think we shouldn't document it at the webpage. Seems like vending one of the actual backing objects as a synthetic object is a reasonable thing to do (it's what you are doing internally). But if we don't allow a way to do that currently, then there's no reason to add one. Jim > > (I will upload a fix for the spelling errors later) > > > https://reviews.llvm.org/D31371 > > > From lldb-commits at lists.llvm.org Wed Mar 29 12:32:59 2017 From: lldb-commits at lists.llvm.org (Sean Callanan via lldb-commits) Date: Wed, 29 Mar 2017 19:32:59 -0000 Subject: [Lldb-commits] [lldb] r299020 - Move the definition of SBListener::GetSP() to SBListener.cpp. Message-ID: <20170329193300.009DC2A6C02B@llvm.org> Author: spyffe Date: Wed Mar 29 14:32:59 2017 New Revision: 299020 URL: http://llvm.org/viewvc/llvm-project?rev=299020&view=rev Log: Move the definition of SBListener::GetSP() to SBListener.cpp. This is the requirement for all functions in the public API, to eliminate weak symbol definitions. Modified: lldb/trunk/include/lldb/API/SBListener.h lldb/trunk/source/API/SBListener.cpp Modified: lldb/trunk/include/lldb/API/SBListener.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBListener.h?rev=299020&r1=299019&r2=299020&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBListener.h (original) +++ lldb/trunk/include/lldb/API/SBListener.h Wed Mar 29 14:32:59 2017 @@ -89,7 +89,7 @@ protected: SBListener(const lldb::ListenerSP &listener_sp); - lldb::ListenerSP GetSP() { return m_opaque_sp; } + lldb::ListenerSP GetSP(); private: lldb_private::Listener *operator->() const; Modified: lldb/trunk/source/API/SBListener.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBListener.cpp?rev=299020&r1=299019&r2=299020&view=diff ============================================================================== --- lldb/trunk/source/API/SBListener.cpp (original) +++ lldb/trunk/source/API/SBListener.cpp Wed Mar 29 14:32:59 2017 @@ -302,6 +302,8 @@ bool SBListener::HandleBroadcastEvent(co return false; } +lldb::ListenerSP SBListener::GetSP() { return m_opaque_sp; } + Listener *SBListener::operator->() const { return m_opaque_sp.get(); } Listener *SBListener::get() const { return m_opaque_sp.get(); } From lldb-commits at lists.llvm.org Wed Mar 29 13:04:31 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 20:04:31 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: labath added inline comments. ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:249 + // Initialize new thread + struct ptrace_lwpinfo info = {}; + Error error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); ---------------- krytarowski wrote: > labath wrote: > > This is the third place i'm seeing this code. Any chance of turning it into a function? > Everything that touches threads will be refactored in future. > > I suspect that at the end this code will lost its capability to iterate threads after exec() as all of them are terminated. > > Here is a code that handles it in an expanded way and fore 1 thread only. That's fine, but if they're identical right now, you could still merge them together, right? (A lot of the temporary things have a tendency to become permanent). ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:447 + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStepping(); + } ---------------- krytarowski wrote: > labath wrote: > > I guess you should be playing with the pt_suspend/resume here to step only the requested thread(s). Is that something you plan to do as a follow up? > I'm planning to reuse PT_RESUME/PT_SUSPEND to select thread/s for execution. > > And reuse PT_SETSTEP/PT_CLEARSTEP to mark them optionally for single-step mode. > > And at the end use global PT_CONTINUE as it has option to emit a signal (PT_STEP cannot send a signal). Ok, as long as you're aware of that, I'm fine. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Wed Mar 29 12:52:24 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via lldb-commits) Date: Wed, 29 Mar 2017 19:52:24 -0000 Subject: [Lldb-commits] [lldb] r299023 - Add NetBSD path for Debugging Information in Separate Files Message-ID: <20170329195225.0AB612A6C02B@llvm.org> Author: kamil Date: Wed Mar 29 14:52:24 2017 New Revision: 299023 URL: http://llvm.org/viewvc/llvm-project?rev=299023&view=rev Log: Add NetBSD path for Debugging Information in Separate Files Summary: NetBSD stores debug information files in the `/usr/libdata/debug` path. This change fixes debugging distribution executables, e.g. `look`(1): ``` $ lldb /usr/bin/look (lldb) target create "/usr/bin/look" Current executable set to '/usr/bin/look' (x86_64). (lldb) b main Breakpoint 1: where = look`main + 22 at look.c:107, address = 0x0000000000000da6 (lldb) r Process 23473 launched: '/usr/bin/look' (x86_64) Process 23473 stopped * thread #1, stop reason = breakpoint 1.1 frame #0: 0x0000000186600da6 look`main(argc=1, argv=0x00007f7fffc7c488) at look.c:107 104 105 string = NULL; 106 file = _PATH_WORDS; -> 107 termchar = '\0'; 108 while ((ch = getopt(argc, argv, "dft:")) != -1) 109 switch(ch) { 110 case 'd': (lldb) ``` There is no `/usr/lib/debug` path on NeBSD, so remove it from search. Sponsored by Reviewers: jingham, emaste, kettenis, labath, joerg Reviewed By: labath Subscribers: aprantl, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D31461 Modified: lldb/trunk/source/Host/common/Symbols.cpp Modified: lldb/trunk/source/Host/common/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Symbols.cpp?rev=299023&r1=299022&r2=299023&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Symbols.cpp (original) +++ lldb/trunk/source/Host/common/Symbols.cpp Wed Mar 29 14:52:24 2017 @@ -212,8 +212,13 @@ FileSpec Symbols::LocateExecutableSymbol debug_file_search_paths.AppendIfUnique(FileSpec(".", true)); #ifndef LLVM_ON_WIN32 +#if defined(__NetBSD__) + // Add /usr/libdata/debug directory. + debug_file_search_paths.AppendIfUnique(FileSpec("/usr/libdata/debug", true)); +#else // Add /usr/lib/debug directory. debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true)); +#endif #endif // LLVM_ON_WIN32 std::string uuid_str; From lldb-commits at lists.llvm.org Wed Mar 29 13:11:35 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 20:11:35 +0000 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: References: Message-ID: labath added a comment. We don't depend on the RuntimeDyld component of llvm directy -- we only use it indirectly through the ExecutionEngine component. Shouldn't that be reflected as a dependency in the build system somehow, so that the former can be pulled in directly ? RuntimeDyld is listed as a dependency of ExecutionEngine in lib/ExecutionEngine/LLVMBuild.txt, but that does not seem to be reflected in the cmake? Is that a bug on the llvm side? Repository: rL LLVM https://reviews.llvm.org/D31367 From lldb-commits at lists.llvm.org Wed Mar 29 13:24:36 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 20:24:36 +0000 Subject: [Lldb-commits] [PATCH] D30984: Centralize libc++ test skipping logic In-Reply-To: References: Message-ID: <9e58509ce49db976eacccf3d667fe22e@localhost.localdomain> labath added a comment. In https://reviews.llvm.org/D30984#711806, @EricWF wrote: > I don't see anything wrong with this, but I only know libc++ and not LLDB. I'm not sure why you ended up here. I think you have too wide phabricator filter somewhere. :) > > >> libc++'s atomic does not play well with gcc on linux > > It should... Can you elaborate on this issue? I suspect this may be a libc++ bug. It checks for `#if __has_feature(cxx_atomic)` and then aborts if it is not found. However, this is in the system libc++ on ubuntu (lldb uses system libc++ for reasons which are too long to go into right now), which is quite old. I don't see a similar check in the current trunk, so it's possible that has been fixed since then. https://reviews.llvm.org/D30984 From lldb-commits at lists.llvm.org Wed Mar 29 14:10:44 2017 From: lldb-commits at lists.llvm.org (Eric Fiselier via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 21:10:44 +0000 Subject: [Lldb-commits] [PATCH] D30984: Centralize libc++ test skipping logic In-Reply-To: References: Message-ID: EricWF added a comment. In https://reviews.llvm.org/D30984#713490, @labath wrote: > In https://reviews.llvm.org/D30984#711806, @EricWF wrote: > > > I don't see anything wrong with this, but I only know libc++ and not LLDB. > > > I'm not sure why you ended up here. I think you have too wide phabricator filter somewhere. :) > > > > > > >> libc++'s atomic does not play well with gcc on linux > > > > It should... Can you elaborate on this issue? I suspect this may be a libc++ bug. > > It checks for `#if __has_feature(cxx_atomic)` and then aborts if it is not found. However, this is in the system libc++ on ubuntu (lldb uses system libc++ for reasons which are too long to go into right now), which is quite old. I don't see a similar check in the current trunk, so it's possible that has been fixed since then. GCC support has been present since ~2015, so I suspect the issue has since been fixed. And the libc++ version on is unbelievable old. https://reviews.llvm.org/D30984 From lldb-commits at lists.llvm.org Wed Mar 29 14:01:15 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via lldb-commits) Date: Wed, 29 Mar 2017 21:01:15 -0000 Subject: [Lldb-commits] [lldb] r299028 - Centralize libc++ test skipping logic Message-ID: <20170329210116.3CC5D2A6C02B@llvm.org> Author: labath Date: Wed Mar 29 16:01:14 2017 New Revision: 299028 URL: http://llvm.org/viewvc/llvm-project?rev=299028&view=rev Log: Centralize libc++ test skipping logic Summary: This aims to replace the different decorators we've had on each libc++ test with a single solution. Each libc++ will be assigned to the "libc++" category and a single central piece of code will decide whether we are actually able to run libc++ test in the given configuration by enabling or disabling the category (while giving the user the opportunity to override this). I started this effort because I wanted to get libc++ tests running on android, and none of the existing decorators worked for this use case: - skipIfGcc - incorrect, we can build libc++ executables on android with gcc (in fact, after this, we can now do it on linux as well) - lldbutil.skip_if_library_missing - this checks whether libc++.so is loaded in the proces, which fails in case of a statically linked libc++ (this makes copying executables to the remote target easier to manage). To make this work I needed to split out the pseudo_barrier code from the force-included file, as libc++'s atomic does not play well with gcc on linux, and this made every test fail, even though we need the code only in the threading tests. So far, I am only annotating one of the tests with this category. If this does not break anything, I'll proceed to update the rest. Reviewers: jingham, zturner, EricWF Subscribers: srhines, lldb-commits Differential Revision: https://reviews.llvm.org/D30984 Added: lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h lldb/trunk/packages/Python/lldbsuite/test/test_categories.py Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Wed Mar 29 16:01:14 2017 @@ -1061,6 +1061,29 @@ def checkCompiler(): configuration.compiler = cmd_output.split('\n')[0] print("'xcrun -find %s' returning %s" % (c, configuration.compiler)) +def canRunLibcxxTests(): + from lldbsuite.test import lldbplatformutil + + platform = lldbplatformutil.getPlatform() + + if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin(): + return True, "libc++ always present" + + if platform == "linux": + if not os.path.isdir("/usr/include/c++/v1"): + return False, "Unable to find libc++ installation" + return True, "Headers found, let's hope they work" + + return False, "Don't know how to build with libc++ on %s" % platform + +def checkLibcxxSupport(): + result, reason = canRunLibcxxTests() + if result: + return # libc++ supported + if "libc++" in configuration.categoriesList: + return # libc++ category explicitly requested, let it run. + print("Libc++ tests will not be run because: " + reason) + configuration.skipCategories.append("libc++") def run_suite(): # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults @@ -1164,6 +1187,8 @@ def run_suite(): target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] + checkLibcxxSupport() + # Don't do debugserver tests on everything except OS X. configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py Wed Mar 29 16:01:14 2017 @@ -23,9 +23,10 @@ class LibcxxStringDataFormatterTestCase( TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') + ns = 'ndk' if lldbplatformutil.target_is_android() else '' + self.namespace = 'std::__' + ns + '1' - @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @add_test_categories(["libc++"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() @@ -36,9 +37,6 @@ class LibcxxStringDataFormatterTestCase( self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing( - self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs=['stopped', @@ -58,17 +56,18 @@ class LibcxxStringDataFormatterTestCase( # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) + ns = self.namespace self.expect( "frame variable", substrs=[ - '(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!"', + '(%s::wstring) s = L"hello world! מזל טוב!"'%ns, + '(%s::wstring) S = L"!!!!"'%ns, '(const wchar_t *) mazeltov = 0x', 'L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + '(%s::string) q = "hello world"'%ns, + '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns, + '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns, + '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns]) self.runCmd("n") @@ -91,11 +90,11 @@ class LibcxxStringDataFormatterTestCase( self.expect( "frame variable", substrs=[ - '(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!!"', + '(%s::wstring) s = L"hello world! מזל טוב!"'%ns, + '(%s::wstring) S = L"!!!!!"'%ns, '(const wchar_t *) mazeltov = 0x', 'L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + '(%s::string) q = "hello world"'%ns, + '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns, + '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns, + '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns]) Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp Wed Mar 29 16:01:14 2017 @@ -9,7 +9,7 @@ // This test verifies the correct handling of child thread exits. -#include +#include "pseudo_barrier.h" #include #include Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp Wed Mar 29 16:01:14 2017 @@ -9,7 +9,7 @@ // This test verifies the correct handling of child thread exits. -#include +#include "pseudo_barrier.h" #include #include Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp Wed Mar 29 16:01:14 2017 @@ -13,7 +13,7 @@ // breakpoint is hit. The test case should be flexible enough to treat that // as success. -#include +#include "pseudo_barrier.h" #include #include Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp Wed Mar 29 16:01:14 2017 @@ -13,7 +13,7 @@ // the main thread (before any worker threads are spawned) and modify variables // which control the number of threads that are spawned for each action. -#include +#include "pseudo_barrier.h" #include using namespace std; Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp Wed Mar 29 16:01:14 2017 @@ -10,7 +10,7 @@ // This test is intended to create a situation in which one thread will be // created while the debugger is stepping in another thread. -#include +#include "pseudo_barrier.h" #include #define do_nothing() Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp Wed Mar 29 16:01:14 2017 @@ -13,7 +13,7 @@ // breakpoint is hit. The test case should be flexible enough to treat that // as success. -#include +#include "pseudo_barrier.h" #include #include Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp Wed Mar 29 16:01:14 2017 @@ -10,6 +10,7 @@ // This test is intended to create a situation in which one thread will exit // while the debugger is stepping in another thread. +#include "pseudo_barrier.h" #include #define do_nothing() Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp Wed Mar 29 16:01:14 2017 @@ -12,7 +12,7 @@ // the breakpoint in the second thread will be hit while the breakpoint handler // in the first thread is trying to stop all threads. -#include +#include "pseudo_barrier.h" #include pseudo_barrier_t g_barrier; Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp Wed Mar 29 16:01:14 2017 @@ -10,7 +10,7 @@ // This test is intended to create a situation in which two threads are stopped // at a breakpoint and the debugger issues a step-out command. -#include +#include "pseudo_barrier.h" #include pseudo_barrier_t g_barrier; Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp Wed Mar 29 16:01:14 2017 @@ -9,7 +9,7 @@ // This test verifies the correct handling of child thread exits. -#include +#include "pseudo_barrier.h" #include pseudo_barrier_t g_barrier1; Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py Wed Mar 29 16:01:14 2017 @@ -52,12 +52,12 @@ def _run_adb_command(cmd, device_id): return p.returncode, stdout, stderr -def _target_is_android(): - if not hasattr(_target_is_android, 'result'): +def target_is_android(): + if not hasattr(target_is_android, 'result'): triple = lldb.DBG.GetSelectedPlatform().GetTriple() match = re.match(".*-.*-.*-android", triple) - _target_is_android.result = match is not None - return _target_is_android.result + target_is_android.result = match is not None + return target_is_android.result def android_device_api(): @@ -84,7 +84,7 @@ def android_device_api(): def match_android_device(device_arch, valid_archs=None, valid_api_levels=None): - if not _target_is_android(): + if not target_is_android(): return False if valid_archs is not None and device_arch not in valid_archs: return False @@ -95,7 +95,7 @@ def match_android_device(device_arch, va def finalize_build_dictionary(dictionary): - if _target_is_android(): + if target_is_android(): if dictionary is None: dictionary = {} dictionary["OS"] = "Android" Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules (original) +++ lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules Wed Mar 29 16:01:14 2017 @@ -72,7 +72,7 @@ ifeq (1,$(USE_LIBCPP)) ARCH_LDFLAGS += \ -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ - -l$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a + $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a else ARCH_CFLAGS += \ -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \ Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original) +++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Wed Mar 29 16:01:14 2017 @@ -202,7 +202,7 @@ else CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include endif -CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(ARCH_CFLAGS) +CFLAGS += -include $(THIS_FILE_DIR)test_common.h -I$(THIS_FILE_DIR) $(ARCH_CFLAGS) # Use this one if you want to build one part of the result without debug information: ifeq "$(OS)" "Darwin" @@ -324,23 +324,21 @@ ifeq (1,$(USE_LIBSTDCPP)) endif ifeq (1,$(USE_LIBCPP)) - # Clang requires an extra flag: -stdlib=libstdc++ - ifneq (,$(findstring clang,$(CC))) - CXXFLAGS += -DLLDB_USING_LIBCPP - ifeq "$(OS)" "Linux" - # This is the default install location on Ubuntu 14.04 - ifneq ($(wildcard /usr/include/c++/v1/.),) - CXXFLAGS += -stdlib=libc++ - LDFLAGS += -stdlib=libc++ - CXXFLAGS += -I/usr/include/c++/v1 - endif - else ifeq "$(OS)" "Android" - # Nothing to do, this is already handled in - # Android.rules. - else + CXXFLAGS += -DLLDB_USING_LIBCPP + ifeq "$(OS)" "Linux" + ifneq (,$(findstring clang,$(CC))) CXXFLAGS += -stdlib=libc++ LDFLAGS += -stdlib=libc++ + else + CXXFLAGS += -isystem /usr/include/c++/v1 + LDFLAGS += -lc++ endif + else ifeq "$(OS)" "Android" + # Nothing to do, this is already handled in + # Android.rules. + else + CXXFLAGS += -stdlib=libc++ + LDFLAGS += -stdlib=libc++ endif endif Added: lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h?rev=299028&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h (added) +++ lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h Wed Mar 29 16:01:14 2017 @@ -0,0 +1,20 @@ +#include + +// Note that although hogging the CPU while waiting for a variable to change +// would be terrible in production code, it's great for testing since it +// avoids a lot of messy context switching to get multiple threads synchronized. + +typedef std::atomic pseudo_barrier_t; +#define pseudo_barrier_wait(barrier) \ + do \ + { \ + --(barrier); \ + while ((barrier).load() > 0) \ + ; \ + } while (0) + +#define pseudo_barrier_init(barrier, count) \ + do \ + { \ + (barrier) = (count); \ + } while (0) Modified: lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h (original) +++ lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h Wed Mar 29 16:01:14 2017 @@ -45,34 +45,3 @@ #define lldb_enable_attach() #endif - -#if defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP) - -// on Darwin, libstdc++ is missing , so this would cause any test to fail building -// since this header file is being included in every C-family test case, we need to not include it -// on Darwin, most tests use libc++ by default, so this will only affect tests that explicitly require libstdc++ - -#else -#ifdef __cplusplus -#include - -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. - -typedef std::atomic pseudo_barrier_t; -#define pseudo_barrier_wait(barrier) \ - do \ - { \ - --(barrier); \ - while ((barrier).load() > 0) \ - ; \ - } while (0) - -#define pseudo_barrier_init(barrier, count) \ - do \ - { \ - (barrier) = (count); \ - } while (0) -#endif // __cplusplus -#endif // defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP) Modified: lldb/trunk/packages/Python/lldbsuite/test/test_categories.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/test_categories.py?rev=299028&r1=299027&r2=299028&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/test_categories.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/test_categories.py Wed Mar 29 16:01:14 2017 @@ -25,6 +25,7 @@ all_categories = { 'dsym': 'Tests that can be run with DSYM debug information', 'gmodules': 'Tests that can be run with -gmodules debug information', 'expression': 'Tests related to the expression parser', + 'libc++': 'Test for libc++ data formatters', 'objc': 'Tests related to the Objective-C programming language support', 'pyapi': 'Tests related to the Python API', 'basic_process': 'Basic process execution sniff tests.', From lldb-commits at lists.llvm.org Wed Mar 29 14:13:46 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Wed, 29 Mar 2017 21:13:46 +0000 Subject: [Lldb-commits] [PATCH] D30984: Centralize libc++ test skipping logic In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rL299028: Centralize libc++ test skipping logic (authored by labath). Changed prior to commit: https://reviews.llvm.org/D30984?vs=91878&id=93407#toc Repository: rL LLVM https://reviews.llvm.org/D30984 Files: lldb/trunk/packages/Python/lldbsuite/test/dotest.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h lldb/trunk/packages/Python/lldbsuite/test/test_categories.py -------------- next part -------------- A non-text attachment was scrubbed... Name: D30984.93407.patch Type: text/x-patch Size: 18400 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Wed Mar 29 17:12:34 2017 From: lldb-commits at lists.llvm.org (Alex Langford via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 00:12:34 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient Message-ID: xiaobai created this revision. This aims to verify the validity of the response from the debugging server in GDBRemoteCommunicationClient::GetMemoryRegionInfo. I was working with ds2 (https://github.com/facebook/ds2) and encountered a bug that caused the server's response to have a 'size' value of 0, which caused lldb to behave incorrectly. https://reviews.llvm.org/D31485 Files: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1503,6 +1503,11 @@ } } + // We got an invalid address range back + if (!region_info.GetRange().IsValid()) { + error.SetErrorString("Server returned invalid range"); + } + // We got a valid address range back but no permissions -- which means // this is an unmapped page if (region_info.GetRange().IsValid() && saw_permissions == false) { -------------- next part -------------- A non-text attachment was scrubbed... Name: D31485.93427.patch Type: text/x-patch Size: 687 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Wed Mar 29 17:23:47 2017 From: lldb-commits at lists.llvm.org (Jason Molenda via lldb-commits) Date: Thu, 30 Mar 2017 00:23:47 -0000 Subject: [Lldb-commits] [lldb] r299040 - Mask out EXC_SYSCALL exceptions as well. Message-ID: <20170330002347.AB0D42A6C02B@llvm.org> Author: jmolenda Date: Wed Mar 29 19:23:46 2017 New Revision: 299040 URL: http://llvm.org/viewvc/llvm-project?rev=299040&view=rev Log: Mask out EXC_SYSCALL exceptions as well. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp?rev=299040&r1=299039&r2=299040&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp Wed Mar 29 19:23:46 2017 @@ -410,7 +410,7 @@ void MachException::Data::Dump() const { #define EXC_MASK_RESOURCE (1 << EXC_RESOURCE) #endif -#define LLDB_EXC_MASK (EXC_MASK_ALL & ~EXC_MASK_RESOURCE) +#define LLDB_EXC_MASK (EXC_MASK_ALL & ~EXC_MASK_RESOURCE & ~EXC_MASK_SYSCALL) kern_return_t MachException::PortInfo::Save(task_t task) { DNBLogThreadedIf(LOG_EXCEPTIONS | LOG_VERBOSE, From lldb-commits at lists.llvm.org Wed Mar 29 17:40:28 2017 From: lldb-commits at lists.llvm.org (Sean Callanan via lldb-commits) Date: Wed, 29 Mar 2017 17:40:28 -0700 Subject: [Lldb-commits] [lldb] r298189 - Remove some dead code from DumpValueObjectOptions::PointerDepth In-Reply-To: <20170318173300.9DA193128009@llvm.org> References: <20170318173300.9DA193128009@llvm.org> Message-ID: This is not dead code in Swift-enabled LLDB, as I just found out doing a merge. I'm going to use Default and see what breaks. Sean > On Mar 18, 2017, at 10:33 AM, Tamas Berghammer via lldb-commits wrote: > > Author: tberghammer > Date: Sat Mar 18 12:33:00 2017 > New Revision: 298189 > > URL: http://llvm.org/viewvc/llvm-project?rev=298189&view=rev > Log: > Remove some dead code from DumpValueObjectOptions::PointerDepth > > Modified: > lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h > lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp > > Modified: lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h?rev=298189&r1=298188&r2=298189&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h (original) > +++ lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h Sat Mar 18 12:33:00 2017 > @@ -27,7 +27,7 @@ namespace lldb_private { > class DumpValueObjectOptions { > public: > struct PointerDepth { > - enum class Mode { Always, Formatters, Default, Never } m_mode; > + enum class Mode { Always, Default, Never } m_mode; > uint32_t m_count; > > PointerDepth operator--() const { > @@ -37,9 +37,6 @@ public: > } > > bool CanAllowExpansion() const; > - > - bool CanAllowExpansion(bool is_root, TypeSummaryImpl *entry, > - ValueObject *valobj, const std::string &summary); > }; > > struct PointerAsArraySettings { > > Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=298189&r1=298188&r2=298189&view=diff > ============================================================================== > --- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original) > +++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Sat Mar 18 12:33:00 2017 > @@ -468,32 +468,11 @@ bool ValueObjectPrinter::PrintObjectDesc > return true; > } > > -bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion( > - bool is_root, TypeSummaryImpl *entry, ValueObject *valobj, > - const std::string &summary) { > - switch (m_mode) { > - case Mode::Always: > - return (m_count > 0); > - case Mode::Never: > - return false; > - case Mode::Default: > - if (is_root) > - m_count = std::min(m_count, 1); > - return m_count > 0; > - case Mode::Formatters: > - if (!entry || entry->DoesPrintChildren(valobj) || summary.empty()) > - return m_count > 0; > - return false; > - } > - return false; > -} > - > bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const { > switch (m_mode) { > case Mode::Always: > case Mode::Default: > - case Mode::Formatters: > - return (m_count > 0); > + return m_count > 0; > case Mode::Never: > return false; > } > @@ -546,8 +525,7 @@ bool ValueObjectPrinter::ShouldPrintChil > return true; > } > > - return curr_ptr_depth.CanAllowExpansion(false, entry, m_valobj, > - m_summary); > + return curr_ptr_depth.CanAllowExpansion(); > } > > return (!entry || entry->DoesPrintChildren(m_valobj) || m_summary.empty()); > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits From lldb-commits at lists.llvm.org Wed Mar 29 19:01:46 2017 From: lldb-commits at lists.llvm.org (Eugene Zemtsov via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 02:01:46 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: <92518e28283a8ca339021b7d24b0d55f@localhost.localdomain> eugene updated this revision to Diff 93438. eugene added reviewers: labath, zturner, jingham. eugene changed the visibility from "eugene (Eugene Zemtsov)" to "Public (No Login Required)". eugene changed the edit policy from "eugene (Eugene Zemtsov)" to "All Users". eugene added a subscriber: lldb-commits. eugene added a comment. Herald added a subscriber: mgorny. Improve template method parsing accuracy. https://reviews.llvm.org/D31451 Files: source/Plugins/Language/CPlusPlus/CMakeLists.txt source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31451.93438.patch Type: text/x-patch Size: 41538 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Wed Mar 29 19:02:46 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 02:02:46 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <23ec9900d123e2b3286d1eb53c8ec209@localhost.localdomain> krytarowski added inline comments. ================ Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:249 + // Initialize new thread + struct ptrace_lwpinfo info = {}; + Error error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); ---------------- labath wrote: > krytarowski wrote: > > labath wrote: > > > This is the third place i'm seeing this code. Any chance of turning it into a function? > > Everything that touches threads will be refactored in future. > > > > I suspect that at the end this code will lost its capability to iterate threads after exec() as all of them are terminated. > > > > Here is a code that handles it in an expanded way and fore 1 thread only. > That's fine, but if they're identical right now, you could still merge them together, right? (A lot of the temporary things have a tendency to become permanent). I will merge this. Even if this is temporary solution. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Wed Mar 29 22:38:20 2017 From: lldb-commits at lists.llvm.org (Stephane Sezer via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 05:38:20 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: sas added a reviewer: clayborg. sas added a subscriber: clayborg. sas added a comment. Doing additional checking on the packets returned over the wire seems decent to me. CC'ing @clayborg to see what he thinks about it also. https://reviews.llvm.org/D31485 From lldb-commits at lists.llvm.org Thu Mar 30 07:13:29 2017 From: lldb-commits at lists.llvm.org (=?utf-8?Q?Micha=C5=82_G=C3=B3rny_via_Phabricator?= via lldb-commits) Date: Thu, 30 Mar 2017 14:13:29 +0000 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: References: Message-ID: mgorny added a comment. In https://reviews.llvm.org/D31367#713472, @labath wrote: > We don't depend on the RuntimeDyld component of llvm directy -- we only use it indirectly through the ExecutionEngine component. Shouldn't that be reflected as a dependency in the build system somehow, so that the former can be pulled in directly ? > RuntimeDyld is listed as a dependency of ExecutionEngine in lib/ExecutionEngine/LLVMBuild.txt, but that does not seem to be reflected in the cmake? Is that a bug on the llvm side? I think it's not that simple. If that was a plain missing dependency in ExecutionEngine, then linking of shared ExecutionEngine would fail due to missing symbols. Since it doesn't, and it makes LLDB libraries fail, I presume this is the kind of indirect dependency that somehow forces a direct dependency via the headers. If you can confirm it's that, and that we want to implicitly force linking RuntimeDyld to all ExecutionEngine consumers, then I'll look if we can do that properly within LLVM CMake files or extend our support for dependencies for that. However, I think that only makes sense if the dependency is indeed frequently indirectly exposed and not e.g. dependent on use of some uncommon thingy. Repository: rL LLVM https://reviews.llvm.org/D31367 From lldb-commits at lists.llvm.org Thu Mar 30 08:43:39 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 15:43:39 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: <4a972c84db8c0bb9d9265646cb03c53a@localhost.localdomain> labath added a comment. The additional check sounds fine. There's a test for this class in unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp where you can add a test for this behavior. https://reviews.llvm.org/D31485 From lldb-commits at lists.llvm.org Thu Mar 30 09:38:37 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 16:38:37 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: <30edee35bfa8a4e6d8e2c48a2aefb808@localhost.localdomain> labath added a comment. I cant help but feel that this could have been done in a simpler way, but then again, some of the cases you have dug up are quite tricky. I think we should do some performance measurements to see whether this needs more optimising or it's fine as is. I propose the following benchmark: bin/lldb bin/clang - make sure clang is statically linked breakpoint set --name non_exisiting_function Clang needs to be statically linked so we can access all its symbols without running​ it (which would skew the benchmark) -- this is the reason we cannot use lldb itself as most of its symbols are in liblldb. Setting the breakpoint on a nonexistent function avoids us timing the breakpoint setting machinery, while still getting every symbol in the executable parsed. If the performance is ok i am quite happy with this, apart from some stylistic nits. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:94 if (!m_parsed && m_full) { - // ConstString mangled; - // m_full.GetMangledCounterpart(mangled); - // printf ("\n parsing = '%s'\n", m_full.GetCString()); - // if (mangled) - // printf (" mangled = '%s'\n", mangled.GetCString()); - m_parse_error = false; - m_parsed = true; - llvm::StringRef full(m_full.GetCString()); - - size_t arg_start, arg_end; - llvm::StringRef parens("()", 2); - if (ReverseFindMatchingChars(full, parens, arg_start, arg_end)) { - m_arguments = full.substr(arg_start, arg_end - arg_start + 1); - if (arg_end + 1 < full.size()) - m_qualifiers = full.substr(arg_end + 1); - if (arg_start > 0) { - size_t basename_end = arg_start; - size_t context_start = 0; - size_t context_end = llvm::StringRef::npos; - if (basename_end > 0 && full[basename_end - 1] == '>') { - // TODO: handle template junk... - // Templated function - size_t template_start, template_end; - llvm::StringRef lt_gt("<>", 2); - if (ReverseFindMatchingChars(full, lt_gt, template_start, - template_end, basename_end)) { - // Check for templated functions that include return type like: - // 'void foo()' - context_start = full.rfind(' ', template_start); - if (context_start == llvm::StringRef::npos) - context_start = 0; - else - ++context_start; - - context_end = full.rfind(':', template_start); - if (context_end == llvm::StringRef::npos || - context_end < context_start) - context_end = context_start; - } else { - context_end = full.rfind(':', basename_end); - } - } else if (context_end == llvm::StringRef::npos) { - context_end = full.rfind(':', basename_end); - } - - if (context_end == llvm::StringRef::npos) - m_basename = full.substr(0, basename_end); - else { - if (context_start < context_end) - m_context = - full.substr(context_start, context_end - 1 - context_start); - const size_t basename_begin = context_end + 1; - m_basename = - full.substr(basename_begin, basename_end - basename_begin); - } - m_type = eTypeUnknownMethod; - } else { - m_parse_error = true; - return; - } - - if (!IsValidBasename(m_basename)) { - // The C++ basename doesn't match our regular expressions so this can't - // be a valid C++ method, clear everything out and indicate an error - m_context = llvm::StringRef(); - m_basename = llvm::StringRef(); - m_arguments = llvm::StringRef(); - m_qualifiers = llvm::StringRef(); - m_parse_error = true; - } + CPlusPlusNameParser parser(m_full.GetStringRef()); + auto function = parser.ParseAsFunctionDefinition(); ---------------- How about the following api: ``` if (auto function​ = CPlusPlusNameParser::ParseAsFunctionDefinition(m_full.GetStringRef())) { ... ``` ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:160 + auto full_name = parser.ParseAsFullName(); + if (full_name.hasValue()) { + identifier = full_name.getValue().m_basename; ---------------- Same here ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:62 +bool CPlusPlusNameParser::HasMoreTokens() { + return m_next_token_index < static_cast(m_tokens.size()); +} ---------------- Wouldn't it be better to change the type of m_next_token_index to size_t? ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:188 + // as arithmetic or shift operators not as template brackets. + // Examples: std::enable_if<(10u)<(64), bool> + // f> ---------------- Is this really the case for the types we are interested in? I would have hoped that this would get simplified to `std::enable_if before it reaches us? ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:572 + clang::SourceLocation end_location = last_token.getLocation(); + const char *begin_ptr = m_text.data() + begin_location.getRawEncoding(); + const char *end_ptr = ---------------- Could this be written as: `m_text.take_front(end_pos).drop_front(start_pos)`? ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h:33 + + struct ParsedName { + llvm::StringRef m_basename; ---------------- I think we dont put m_ for fields of dumb structs that are meant to be accessed directly. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h:94 + // when destructed unless it's manually removed with Remove(). + class Bookmark { + public: ---------------- Please make the type move-only. Otherwise you will have a fun time debugging accidental copies. (You already have one, although it is benign now) ================ Comment at: unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp:106 + EXPECT_EQ(test.qualifiers, method.GetQualifiers()) + << method.GetQualifiers(); EXPECT_EQ(test.scope_qualified_name, method.GetScopeQualifiedName()); ---------------- Would defining operator<< for std::ostream and StringRef ( local tomthis test) enable you to get rid of these? I've ran into this before but was never annoyed enough to actually do it.. :/ https://reviews.llvm.org/D31451 From lldb-commits at lists.llvm.org Thu Mar 30 10:06:01 2017 From: lldb-commits at lists.llvm.org (Chris Bieneman via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 17:06:01 +0000 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: References: Message-ID: beanz added a comment. This is definitely not the right fix. Please revert. ExecutionEngine's LLVMBuild.txt file explicitly lists that RuntimeDyld is a required library of ExecutionEngine (as well as a few others). LLVM's CMake should be connecting that as an explicit dependency, and for some reason it isn't. Adding over-specified dependencies in LLDB to workaround bugs in LLVM is not the right approach, and masks problems instead of resolving them. Repository: rL LLVM https://reviews.llvm.org/D31367 From lldb-commits at lists.llvm.org Thu Mar 30 11:00:15 2017 From: lldb-commits at lists.llvm.org (Chris Bieneman via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 18:00:15 +0000 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: References: Message-ID: beanz added a comment. Please revert your patch. It is *not* the right solution and is masking underlying problems. ExecutionEngine headers directly reference symbols from RuntimeDyld, so we should enforce a requirement that anyone using ExeuctionEngine also link RuntimeDyld. This works today as expected for static archive builds. It is only broken with `BUILD_SHARED_LIBS`. I suspect the problem is that when built as a DSO ExecutionEngine has no unresolved symbols against RuntimeDyld, and the linker probably isn't including the reference to RuntimeDyld in the produced ExecutionEngine DSO. Regardless of the underlying cause, this is not the correct solution, it merely hides a problem that could occur in other consumers of ExecutionEngine. Repository: rL LLVM https://reviews.llvm.org/D31367 From lldb-commits at lists.llvm.org Thu Mar 30 11:24:07 2017 From: lldb-commits at lists.llvm.org (Michal Gorny via lldb-commits) Date: Thu, 30 Mar 2017 18:24:07 -0000 Subject: [Lldb-commits] [lldb] r299095 - Revert r298776 - Expression: add missing linkage to RuntimeDyld ... Message-ID: <20170330182407.635CE2A6C02B@llvm.org> Author: mgorny Date: Thu Mar 30 13:24:07 2017 New Revision: 299095 URL: http://llvm.org/viewvc/llvm-project?rev=299095&view=rev Log: Revert r298776 - Expression: add missing linkage to RuntimeDyld ... This needs to be addressed within LLVM itself. Modified: lldb/trunk/source/Expression/CMakeLists.txt Modified: lldb/trunk/source/Expression/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/CMakeLists.txt?rev=299095&r1=299094&r2=299095&view=diff ============================================================================== --- lldb/trunk/source/Expression/CMakeLists.txt (original) +++ lldb/trunk/source/Expression/CMakeLists.txt Thu Mar 30 13:24:07 2017 @@ -34,6 +34,5 @@ add_lldb_library(lldbExpression LINK_COMPONENTS Core ExecutionEngine - RuntimeDyld Support ) From lldb-commits at lists.llvm.org Thu Mar 30 11:41:55 2017 From: lldb-commits at lists.llvm.org (=?utf-8?Q?Micha=C5=82_G=C3=B3rny_via_Phabricator?= via lldb-commits) Date: Thu, 30 Mar 2017 18:41:55 +0000 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: References: Message-ID: mgorny added a comment. In https://reviews.llvm.org/D31367#714305, @beanz wrote: > Please revert your patch. It is *not* the right solution and is masking underlying problems. Reverted in r299095. Now I'd really appreciate some help in figuring out how to fix it properly. > ExecutionEngine headers directly reference symbols from RuntimeDyld, so we should enforce a requirement that anyone using ExeuctionEngine also link RuntimeDyld. This works today as expected for static archive builds. It is only broken with `BUILD_SHARED_LIBS`. I suspect the problem is that when built as a DSO ExecutionEngine has no unresolved symbols against RuntimeDyld, and the linker probably isn't including the reference to RuntimeDyld in the produced ExecutionEngine DSO. The DSO is linking to RuntimeDyld. However, obviously the `PRIVATE` linkage forced in `llvm_add_library` is not the correct solution when the symbols are explicitly used in the headers. It should be `PUBLIC` for that particular component. Any suggestion on how to fix that API? Should I add an additional `PUBLIC_LINK_COMPONENTS` (and `PUBLIC_LINK_LIBS`)? Repository: rL LLVM https://reviews.llvm.org/D31367 From lldb-commits at lists.llvm.org Thu Mar 30 12:32:29 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 19:32:29 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: krytarowski updated this revision to Diff 93524. krytarowski added a comment. Herald added a subscriber: srhines. Apply changes from review. No visible regressions in "check-lldb". Repository: rL LLVM https://reviews.llvm.org/D31450 Files: source/Host/common/Host.cpp source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp source/Plugins/Process/NetBSD/NativeProcessNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h source/Plugins/Process/elf-core/ProcessElfCore.cpp source/Plugins/Process/elf-core/ThreadElfCore.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31450.93524.patch Type: text/x-patch Size: 18170 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Thu Mar 30 12:37:41 2017 From: lldb-commits at lists.llvm.org (Joerg Sonnenberger via lldb-commits) Date: Thu, 30 Mar 2017 21:37:41 +0200 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: References: Message-ID: <20170330193741.GA25324@britannica.bec.de> On Thu, Mar 30, 2017 at 06:00:15PM +0000, Chris Bieneman via Phabricator wrote: > ExecutionEngine headers directly reference symbols from RuntimeDyld, > so we should enforce a requirement that anyone using ExeuctionEngine > also link RuntimeDyld. This works today as expected for static archive > builds. It is only broken with `BUILD_SHARED_LIBS`. Welcome to the brave new world of newer ELF linkers. Just because a library pulls in a symbol into the namespace doesn't mean you can just use that symbol. They want you to explicitly specify the dependency... This does happen for static archives though. Joerg From lldb-commits at lists.llvm.org Thu Mar 30 12:40:00 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 19:40:00 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: tberghammer updated this revision to Diff 93525. tberghammer added a comment. Add documentation to the website https://reviews.llvm.org/D31368 Files: packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py source/Core/ValueObject.cpp source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp source/Target/StackFrame.cpp www/varformats.html -------------- next part -------------- A non-text attachment was scrubbed... Name: D31368.93525.patch Type: text/x-patch Size: 6699 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Thu Mar 30 12:40:20 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 19:40:20 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <7a3cec27cc898acc140552dfe79ade34@localhost.localdomain> jingham resigned from this revision. jingham added a comment. Kyril, I haven't been involved in the lldb-server parts of lldb. Greg sketched out those interfaces and mostly folks working on Windows & Linux have fleshed them out. I haven't been following the design discussions for lldb-server, and am not in a position to study them now. So I'm not a good person to review these changes. You might try adding Greg as a reviewer, though I don't know how much time he will have right now, since he's starting a new job. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Thu Mar 30 12:45:34 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 19:45:34 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: <8cdd7b7e9a70552bd0474bc874c0adc0@localhost.localdomain> jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. One grammar comment in the docs, and then this is good. ================ Comment at: www/varformats.html:1071 [3] This method is optional (starting with SVN revision 219330). The SBValue you return here will most likely be a numeric type (int, float, ...) as its value bytes will be used as-if they were the value of the root SBValue proper. As a shortcut for this, you can inherit from lldb.SBSyntheticValueProvider, and just define get_value as other methods are defaulted in the superclass as returning default no-children responses. +

A sythetic child provider can supply a special child named $$dereference$$ what will be used when evaluating opertaor* and operator-> in the frame variable command and related SB API functions.

For examples of how synthetic children are created, you are encouraged to look at examples/synthetic in the LLDB trunk. Please, be aware that the code in those files (except bitfield/) ---------------- grammar: "what will be" -> "which will be" Though I think it would be clearer to say: If a synthetic child provider supplies a special child named $$dereference$$ it will be... https://reviews.llvm.org/D31368 From lldb-commits at lists.llvm.org Thu Mar 30 12:47:18 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 19:47:18 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <649b8dfe737b00e5e9c27f7f4159f9a5@localhost.localdomain> krytarowski added a comment. Thanks! Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Thu Mar 30 12:51:41 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via lldb-commits) Date: Thu, 30 Mar 2017 19:51:41 +0000 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: <982C83F9-BB48-41FA-8C9A-45DD5CD6B7E5@apple.com> References: <4a0927b65d62c7d075c9be00bad1c5de@localhost.localdomain> <982C83F9-BB48-41FA-8C9A-45DD5CD6B7E5@apple.com> Message-ID: It is possible to vend one of the actual backing object as a synthetic child using the SB API. What is not possible from the SB API at the moment (we might want to fix it) is to vend one of the actual backing object with a different name then the underlying object itself. You can still say that object X has a child named "foobar" (so X.foobar will work) but the name of the actual child will be something like "_M_baz" when displayed. On Wed, Mar 29, 2017 at 10:16 AM Jim Ingham wrote: > > > On Mar 29, 2017, at 2:06 AM, Tamas Berghammer via Phabricator < > reviews at reviews.llvm.org> wrote: > > > > tberghammer added a comment. > > > > SBValue::SetName is not part of the SB API (what is the right decision > IMO as an SBValue should be mostly immutable) so this issue doesn't effect > it. I looked through the code in examples/synthetic/gnu_libstdcpp.py and it > is always using one of the SBValue::Create* method to produce new SBValue > what will create a new value object one way or the other. Considering that > nobody complained about the missing SetName method at the SB API level I > don't see a big need for exposing the Clone method there. At the same line > if SetName/Clone isn't part of the SB API then I think we shouldn't > document it at the webpage. > > Seems like vending one of the actual backing objects as a synthetic object > is a reasonable thing to do (it's what you are doing internally). But if > we don't allow a way to do that currently, then there's no reason to add > one. > > Jim > > > > > > (I will upload a fix for the spelling errors later) > > > > > > https://reviews.llvm.org/D31371 > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lldb-commits at lists.llvm.org Thu Mar 30 12:56:46 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 19:56:46 +0000 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: Message-ID: tberghammer updated this revision to Diff 93528. tberghammer added a comment. Fix typos in the comments https://reviews.llvm.org/D31371 Files: include/lldb/Core/ValueObject.h source/Core/ValueObject.cpp source/DataFormatters/VectorType.cpp source/Plugins/Language/CPlusPlus/LibCxxMap.cpp source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31371.93528.patch Type: text/x-patch Size: 5462 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Thu Mar 30 12:59:30 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 19:59:30 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: <07c088f36231545afa4a5a67585e16d1@localhost.localdomain> tberghammer updated this revision to Diff 93529. tberghammer added a comment. Fix grammer for the html documentation. https://reviews.llvm.org/D31368 Files: packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py source/Core/ValueObject.cpp source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp source/Target/StackFrame.cpp www/varformats.html -------------- next part -------------- A non-text attachment was scrubbed... Name: D31368.93529.patch Type: text/x-patch Size: 6704 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Thu Mar 30 13:01:45 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 20:01:45 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: <2d02b9cd5532b0e733f517bbd670f72b@localhost.localdomain> jingham accepted this revision. jingham added a comment. This revision is now accepted and ready to land. Excellent! https://reviews.llvm.org/D31368 From lldb-commits at lists.llvm.org Thu Mar 30 12:59:05 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Thu, 30 Mar 2017 12:59:05 -0700 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: <4a0927b65d62c7d075c9be00bad1c5de@localhost.localdomain> <982C83F9-BB48-41FA-8C9A-45DD5CD6B7E5@apple.com> Message-ID: <04CE388B-FB77-42CF-97EB-6F74D78AE229@apple.com> I see. Might be worth filing an enhancement request to expose Clone so you can do this in a Python synthetic child provider. But there's no reason that lack should block this change. Jim > On Mar 30, 2017, at 12:51 PM, Tamas Berghammer wrote: > > It is possible to vend one of the actual backing object as a synthetic child using the SB API. What is not possible from the SB API at the moment (we might want to fix it) is to vend one of the actual backing object with a different name then the underlying object itself. You can still say that object X has a child named "foobar" (so X.foobar will work) but the name of the actual child will be something like "_M_baz" when displayed. > > On Wed, Mar 29, 2017 at 10:16 AM Jim Ingham wrote: > > > On Mar 29, 2017, at 2:06 AM, Tamas Berghammer via Phabricator wrote: > > > > tberghammer added a comment. > > > > SBValue::SetName is not part of the SB API (what is the right decision IMO as an SBValue should be mostly immutable) so this issue doesn't effect it. I looked through the code in examples/synthetic/gnu_libstdcpp.py and it is always using one of the SBValue::Create* method to produce new SBValue what will create a new value object one way or the other. Considering that nobody complained about the missing SetName method at the SB API level I don't see a big need for exposing the Clone method there. At the same line if SetName/Clone isn't part of the SB API then I think we shouldn't document it at the webpage. > > Seems like vending one of the actual backing objects as a synthetic object is a reasonable thing to do (it's what you are doing internally). But if we don't allow a way to do that currently, then there's no reason to add one. > > Jim > > > > > > (I will upload a fix for the spelling errors later) > > > > > > https://reviews.llvm.org/D31371 > > > > > > > From lldb-commits at lists.llvm.org Thu Mar 30 13:04:30 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 20:04:30 +0000 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: Message-ID: jingham accepted this revision. jingham added a comment. This revision is now accepted and ready to land. Good. https://reviews.llvm.org/D31371 From lldb-commits at lists.llvm.org Thu Mar 30 13:10:00 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 20:10:00 +0000 Subject: [Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default In-Reply-To: References: Message-ID: tberghammer added a comment. I tried it out on OSX and the problem is that version of libstdc++ shipping with every recent OSX version (don't know about old ones) is 4.2.1 (last version with GPL v2) what doesn't support std::unique_ptr (supported since 4.3). Because of this I think the correct skip condition would be something like "skip if libstdc++ is older then 4.3" but I don't think we have a good way to specify that. https://reviews.llvm.org/D31366 From lldb-commits at lists.llvm.org Thu Mar 30 13:16:29 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via lldb-commits) Date: Thu, 30 Mar 2017 20:16:29 +0000 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: Message-ID: Created bug for exposing ValueObject::Clone as SB API: http://bugs.llvm.org/show_bug.cgi?id=32477 On Thu, Mar 30, 2017 at 1:04 PM Jim Ingham via Phabricator < reviews at reviews.llvm.org> wrote: > jingham accepted this revision. > jingham added a comment. > This revision is now accepted and ready to land. > > Good. > > > https://reviews.llvm.org/D31371 > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lldb-commits at lists.llvm.org Thu Mar 30 13:22:47 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 20:22:47 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <33948cb0689ee909610fa8110e76950f@localhost.localdomain> labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Thank you. Keep up the good work. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Thu Mar 30 13:28:58 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 20:28:58 +0000 Subject: [Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default In-Reply-To: References: Message-ID: jingham accepted this revision. jingham added a comment. This revision is now accepted and ready to land. MacOS hasn't shipped with gcc for a while now. If you were serious about using gcc & its STL implementation you would install your own copies of the tools & libraries. So what's on the system isn't really determinative... But this is a minor point, if there's no way to check the library version we can just leave the test off for Darwin. https://reviews.llvm.org/D31366 From lldb-commits at lists.llvm.org Thu Mar 30 13:26:30 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Thu, 30 Mar 2017 13:26:30 -0700 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: Message-ID: <160E5A0B-9AAD-4C58-A4AA-152162387CDA@apple.com> Thanks. Jim > On Mar 30, 2017, at 1:16 PM, Tamas Berghammer wrote: > > Created bug for exposing ValueObject::Clone as SB API: http://bugs.llvm.org/show_bug.cgi?id=32477 > > On Thu, Mar 30, 2017 at 1:04 PM Jim Ingham via Phabricator wrote: > jingham accepted this revision. > jingham added a comment. > This revision is now accepted and ready to land. > > Good. > > > https://reviews.llvm.org/D31371 > > > From lldb-commits at lists.llvm.org Thu Mar 30 13:25:30 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via lldb-commits) Date: Thu, 30 Mar 2017 20:25:30 -0000 Subject: [Lldb-commits] [lldb] r299109 - Battery of NetBSD support improvements Message-ID: <20170330202530.83A672A6C02B@llvm.org> Author: kamil Date: Thu Mar 30 15:25:29 2017 New Revision: 299109 URL: http://llvm.org/viewvc/llvm-project?rev=299109&view=rev Log: Battery of NetBSD support improvements Summary: Include initial support for: - single step mode (PT_STEP) - single step trap handling (TRAP_TRACE) - exec() trap (TRAP_EXEC) - add placeholder interfaces for FPR - initial code for NetBSD core(5) files - minor tweaks While there improve style of altered elf-core/ files. This code raises the number of passing tests on NetBSD to around 50% (600+/1200+). The introduced code is subject to improve afterwards for additional features and bug fixes. Sponsored by Reviewers: labath, joerg, emaste, kettenis Reviewed By: labath Subscribers: srhines, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D31450 Modified: lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Thu Mar 30 15:25:29 2017 @@ -679,7 +679,7 @@ Error Host::LaunchProcessPosixSpawn(cons sigemptyset(&no_signals); sigfillset(&all_signals); ::posix_spawnattr_setsigmask(&attr, &no_signals); -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ::posix_spawnattr_setsigdefault(&attr, &no_signals); #else ::posix_spawnattr_setsigdefault(&attr, &all_signals); Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp Thu Mar 30 15:25:29 2017 @@ -379,12 +379,13 @@ bool DYLDRendezvous::RemoveSOEntries() { } bool DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry) { - // On Linux the executable is indicated by an empty path in the entry. On - // FreeBSD and on Android it is the full path to the executable. + // On some systes the executable is indicated by an empty path in the entry. + // On others it is the full path to the executable. auto triple = m_process->GetTarget().GetArchitecture().GetTriple(); switch (triple.getOS()) { case llvm::Triple::FreeBSD: + case llvm::Triple::NetBSD: return entry.file_spec == m_exe_file_spec; case llvm::Triple::Linux: if (triple.isAndroid()) Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Thu Mar 30 15:25:29 2017 @@ -235,6 +235,24 @@ void NativeProcessNetBSD::MonitorSIGTRAP } SetState(StateType::eStateStopped, true); break; + case TRAP_TRACE: + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStoppedByTrace(); + } + SetState(StateType::eStateStopped, true); + break; + case TRAP_EXEC: { + Error error = ReinitializeThreads(); + if (error.Fail()) { + SetState(StateType::eStateInvalid); + return; + } + + // Let our delegate know we have just exec'd. + NotifyDidExec(); + + SetState(StateType::eStateStopped, true); + } break; } } } @@ -389,11 +407,13 @@ Error NativeProcessNetBSD::Resume(const return Error(); } + Error error; + switch (action->state) { case eStateRunning: { // Run the thread, possibly feeding it the signal. - Error error = NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(), - (void *)1, action->signal); + error = NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(), (void *)1, + action->signal); if (!error.Success()) return error; for (const auto &thread_sp : m_threads) { @@ -403,7 +423,15 @@ Error NativeProcessNetBSD::Resume(const break; } case eStateStepping: - return Error("Not implemented"); + // Run the thread, possibly feeding it the signal. + error = NativeProcessNetBSD::PtraceWrapper(PT_STEP, GetID(), (void *)1, + action->signal); + if (!error.Success()) + return error; + for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStepping(); + } + SetState(eStateStepping, true); break; case eStateSuspended: @@ -732,22 +760,11 @@ Error NativeProcessNetBSD::LaunchInferio ResolveProcessArchitecture(m_pid, m_arch); - /* Initialize threads */ - struct ptrace_lwpinfo info = {}; - error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); + error = ReinitializeThreads(); if (error.Fail()) { SetState(StateType::eStateInvalid); return error; } - while (info.pl_lwpid != 0) { - NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid); - thread_sp->SetStoppedBySignal(SIGSTOP); - error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); - if (error.Fail()) { - SetState(StateType::eStateInvalid); - return error; - } - } /* Set process stopped */ SetState(StateType::eStateStopped); @@ -850,9 +867,6 @@ NativeThreadNetBSDSP NativeProcessNetBSD ::pid_t NativeProcessNetBSD::Attach(lldb::pid_t pid, Error &error) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); - // Use a map to keep track of the threads which we have attached/need to - // attach. - Host::TidMap tids_to_attach; if (pid <= 1) { error.SetErrorToGenericError(); error.SetErrorString("Attaching to process 1 is not allowed."); @@ -874,21 +888,11 @@ NativeThreadNetBSDSP NativeProcessNetBSD m_pid = pid; /* Initialize threads */ - struct ptrace_lwpinfo info = {}; - error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); + error = ReinitializeThreads(); if (error.Fail()) { SetState(StateType::eStateInvalid); return -1; } - while (info.pl_lwpid != 0) { - NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid); - thread_sp->SetStoppedBySignal(SIGSTOP); - error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); - if (error.Fail()) { - SetState(StateType::eStateInvalid); - return -1; - } - } // Let our process instance know the thread has stopped. SetState(StateType::eStateStopped); @@ -989,3 +993,26 @@ NativeProcessNetBSD::GetAuxvData() const return buf; } + +Error NativeProcessNetBSD::ReinitializeThreads() { + // Clear old threads + m_threads.clear(); + + // Initialize new thread + struct ptrace_lwpinfo info = {}; + Error error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info)); + if (error.Fail()) { + return error; + } + // Reinitialize from scratch threads and register them in process + while (info.pl_lwpid != 0) { + NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid); + thread_sp->SetStoppedByExec(); + error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info)); + if (error.Fail()) { + return error; + } + } + + return error; +} Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h Thu Mar 30 15:25:29 2017 @@ -131,6 +131,8 @@ private: void SigchldHandler(); ::pid_t Attach(lldb::pid_t pid, Error &error); + + Error ReinitializeThreads(); }; } // namespace process_netbsd Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp Thu Mar 30 15:25:29 2017 @@ -41,6 +41,22 @@ Error NativeRegisterContextNetBSD::Write return DoWriteGPR(buf); } +Error NativeRegisterContextNetBSD::ReadFPR() { + void *buf = GetFPRBuffer(); + if (!buf) + return Error("FPR buffer is NULL"); + + return DoReadFPR(buf); +} + +Error NativeRegisterContextNetBSD::WriteFPR() { + void *buf = GetFPRBuffer(); + if (!buf) + return Error("FPR buffer is NULL"); + + return DoWriteFPR(buf); +} + Error NativeRegisterContextNetBSD::DoReadGPR(void *buf) { return NativeProcessNetBSD::PtraceWrapper(PT_GETREGS, GetProcessPid(), buf, m_thread.GetID()); @@ -51,6 +67,16 @@ Error NativeRegisterContextNetBSD::DoWri m_thread.GetID()); } +Error NativeRegisterContextNetBSD::DoReadFPR(void *buf) { + return NativeProcessNetBSD::PtraceWrapper(PT_GETFPREGS, GetProcessPid(), buf, + m_thread.GetID()); +} + +Error NativeRegisterContextNetBSD::DoWriteFPR(void *buf) { + return NativeProcessNetBSD::PtraceWrapper(PT_SETFPREGS, GetProcessPid(), buf, + m_thread.GetID()); +} + NativeProcessNetBSD &NativeRegisterContextNetBSD::GetProcess() { auto process_sp = std::static_pointer_cast(m_thread.GetProcess()); Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h Thu Mar 30 15:25:29 2017 @@ -37,13 +37,24 @@ public: protected: virtual Error ReadGPR(); virtual Error WriteGPR(); + + virtual Error ReadFPR(); + virtual Error WriteFPR(); + virtual void *GetGPRBuffer() { return nullptr; } virtual size_t GetGPRSize() { return GetRegisterInfoInterface().GetGPRSize(); } + + virtual void *GetFPRBuffer() { return nullptr; } + virtual size_t GetFPRSize() { return 0; } + virtual Error DoReadGPR(void *buf); virtual Error DoWriteGPR(void *buf); + virtual Error DoReadFPR(void *buf); + virtual Error DoWriteFPR(void *buf); + virtual NativeProcessNetBSD &GetProcess(); virtual ::pid_t GetProcessPid(); }; Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp Thu Mar 30 15:25:29 2017 @@ -154,6 +154,9 @@ int NativeRegisterContextNetBSD_x86_64:: case GPRegSet: ReadGPR(); return 0; + case FPRegSet: + ReadFPR(); + return 0; default: break; } @@ -164,6 +167,9 @@ int NativeRegisterContextNetBSD_x86_64:: case GPRegSet: WriteGPR(); return 0; + case FPRegSet: + WriteFPR(); + return 0; default: break; } Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h Thu Mar 30 15:25:29 2017 @@ -48,13 +48,15 @@ public: protected: void *GetGPRBuffer() override { return &m_gpr_x86_64; } + void *GetFPRBuffer() override { return &m_fpr_x86_64; } private: // Private member types. - enum { GPRegSet }; + enum { GPRegSet, FPRegSet }; // Private member variables. struct reg m_gpr_x86_64; + struct fpreg m_fpr_x86_64; int GetSetForNativeRegNum(int reg_num) const; Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp Thu Mar 30 15:25:29 2017 @@ -56,6 +56,18 @@ void NativeThreadNetBSD::SetStoppedByBre m_stop_info.details.signal.signo = SIGTRAP; } +void NativeThreadNetBSD::SetStoppedByTrace() { + SetStopped(); + m_stop_info.reason = StopReason::eStopReasonTrace; + m_stop_info.details.signal.signo = SIGTRAP; +} + +void NativeThreadNetBSD::SetStoppedByExec() { + SetStopped(); + m_stop_info.reason = StopReason::eStopReasonExec; + m_stop_info.details.signal.signo = SIGTRAP; +} + void NativeThreadNetBSD::SetStopped() { const StateType new_state = StateType::eStateStopped; m_state = new_state; @@ -67,6 +79,11 @@ void NativeThreadNetBSD::SetRunning() { m_stop_info.reason = StopReason::eStopReasonNone; } +void NativeThreadNetBSD::SetStepping() { + m_state = StateType::eStateStepping; + m_stop_info.reason = StopReason::eStopReasonNone; +} + std::string NativeThreadNetBSD::GetName() { return std::string(""); } lldb::StateType NativeThreadNetBSD::GetState() { return m_state; } Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h Thu Mar 30 15:25:29 2017 @@ -51,8 +51,11 @@ private: void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr); void SetStoppedByBreakpoint(); + void SetStoppedByTrace(); + void SetStoppedByExec(); void SetStopped(); void SetRunning(); + void SetStepping(); // --------------------------------------------------------------------- // Member Variables Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original) +++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Thu Mar 30 15:25:29 2017 @@ -62,8 +62,8 @@ lldb::ProcessSP ProcessElfCore::CreateIn // to ignore possible presence of the header extension. const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr); - auto data_sp = - DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0); + auto data_sp = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), + header_size, 0); if (data_sp && data_sp->GetByteSize() == header_size && elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) { elf::ELFHeader elf_header; @@ -223,7 +223,7 @@ Error ProcessElfCore::DoLoadCore() { bool siginfo_signal_found = false; bool prstatus_signal_found = false; // Check we found a signal in a SIGINFO note. - for (const auto &thread_data: m_thread_data) { + for (const auto &thread_data : m_thread_data) { if (thread_data.signo != 0) siginfo_signal_found = true; if (thread_data.prstatus_sig != 0) @@ -233,7 +233,7 @@ Error ProcessElfCore::DoLoadCore() { // If we don't have signal from SIGINFO use the signal from each threads // PRSTATUS note. if (prstatus_signal_found) { - for (auto &thread_data: m_thread_data) + for (auto &thread_data : m_thread_data) thread_data.signo = thread_data.prstatus_sig; } else if (m_thread_data.size() > 0) { // If all else fails force the first thread to be SIGSTOP @@ -449,6 +449,11 @@ enum { }; } +namespace NETBSD { + +enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 }; +} + // Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details. static void ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data, ArchSpec &arch) { @@ -485,13 +490,23 @@ static void ParseFreeBSDThrMisc(ThreadDa thread_data.name = data.GetCStr(&offset, 20); } -static void ParseOpenBSDProcInfo(ThreadData &thread_data, DataExtractor &data) -{ +static void ParseNetBSDProcInfo(ThreadData &thread_data, DataExtractor &data) { + lldb::offset_t offset = 0; + + int version = data.GetU32(&offset); + if (version != 1) + return; + + offset += 4; + thread_data.signo = data.GetU32(&offset); +} + +static void ParseOpenBSDProcInfo(ThreadData &thread_data, DataExtractor &data) { lldb::offset_t offset = 0; - + int version = data.GetU32(&offset); if (version != 1) - return; + return; offset += 4; thread_data.signo = data.GetU32(&offset); @@ -585,23 +600,38 @@ Error ProcessElfCore::ParseThreadContext default: break; } + } else if (note.n_name.substr(0, 11) == "NetBSD-CORE") { + // NetBSD per-thread information is stored in notes named + // "NetBSD-CORE at nnn" so match on the initial part of the string. + m_os = llvm::Triple::NetBSD; + if (note.n_type == NETBSD::NT_PROCINFO) { + ParseNetBSDProcInfo(*thread_data, note_data); + } else if (note.n_type == NETBSD::NT_AUXV) { + m_auxv = DataExtractor(note_data); + } else if (arch.GetMachine() == llvm::Triple::x86_64 && + note.n_type == NETBSD::NT_AMD64_REGS) { + thread_data->gpregset = note_data; + } else if (arch.GetMachine() == llvm::Triple::x86_64 && + note.n_type == NETBSD::NT_AMD64_FPREGS) { + thread_data->fpregset = note_data; + } } else if (note.n_name.substr(0, 7) == "OpenBSD") { // OpenBSD per-thread information is stored in notes named // "OpenBSD at nnn" so match on the initial part of the string. m_os = llvm::Triple::OpenBSD; switch (note.n_type) { case NT_OPENBSD_PROCINFO: - ParseOpenBSDProcInfo(*thread_data, note_data); - break; + ParseOpenBSDProcInfo(*thread_data, note_data); + break; case NT_OPENBSD_AUXV: - m_auxv = DataExtractor(note_data); - break; + m_auxv = DataExtractor(note_data); + break; case NT_OPENBSD_REGS: - thread_data->gpregset = note_data; - break; + thread_data->gpregset = note_data; + break; case NT_OPENBSD_FPREGS: - thread_data->fpregset = note_data; - break; + thread_data->fpregset = note_data; + break; } } else if (note.n_name == "CORE") { switch (note.n_type) { Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp?rev=299109&r1=299108&r2=299109&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp (original) +++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Thu Mar 30 15:25:29 2017 @@ -21,6 +21,7 @@ #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" +#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h" #include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h" #include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h" #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h" @@ -112,6 +113,17 @@ ThreadElfCore::CreateRegisterContextForF break; } + case llvm::Triple::NetBSD: { + switch (arch.GetMachine()) { + case llvm::Triple::x86_64: + reg_interface = new RegisterContextNetBSD_x86_64(arch); + break; + default: + break; + } + break; + } + case llvm::Triple::Linux: { switch (arch.GetMachine()) { case llvm::Triple::arm: @@ -144,8 +156,8 @@ ThreadElfCore::CreateRegisterContextForF reg_interface = new RegisterInfoPOSIX_arm(arch); break; case llvm::Triple::x86: - reg_interface = new RegisterContextOpenBSD_i386(arch); - break; + reg_interface = new RegisterContextOpenBSD_i386(arch); + break; case llvm::Triple::x86_64: reg_interface = new RegisterContextOpenBSD_x86_64(arch); break; @@ -260,7 +272,6 @@ Error ELFLinuxPrStatus::Parse(DataExtrac pr_cstime.tv_sec = data.GetPointer(&offset); pr_cstime.tv_usec = data.GetPointer(&offset); - return error; } @@ -317,9 +328,7 @@ Error ELFLinuxPrPsInfo::Parse(DataExtrac //---------------------------------------------------------------- // Parse SIGINFO from NOTE entry //---------------------------------------------------------------- -ELFLinuxSigInfo::ELFLinuxSigInfo() { - memset(this, 0, sizeof(ELFLinuxSigInfo)); -} +ELFLinuxSigInfo::ELFLinuxSigInfo() { memset(this, 0, sizeof(ELFLinuxSigInfo)); } Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) { Error error; From lldb-commits at lists.llvm.org Thu Mar 30 13:47:39 2017 From: lldb-commits at lists.llvm.org (=?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= via lldb-commits) Date: Thu, 30 Mar 2017 22:47:39 +0200 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: <20170330193741.GA25324@britannica.bec.de> References: <20170330193741.GA25324@britannica.bec.de> Message-ID: <1490906859.12326.0.camel@gentoo.org> On czw, 2017-03-30 at 21:37 +0200, Joerg Sonnenberger wrote: > On Thu, Mar 30, 2017 at 06:00:15PM +0000, Chris Bieneman via Phabricator wrote: > > ExecutionEngine headers directly reference symbols from RuntimeDyld, > > so we should enforce a requirement that anyone using ExeuctionEngine > > also link RuntimeDyld. This works today as expected for static archive > > builds. It is only broken with `BUILD_SHARED_LIBS`. > > Welcome to the brave new world of newer ELF linkers. Just because a > library pulls in a symbol into the namespace doesn't mean you can just > use that symbol. They want you to explicitly specify the dependency... > This does happen for static archives though. This is expected and desired. Just because some random library you're using is using zlib does not mean you should skip linking zlib when your program is using it too. -- Best regards, Michał Górny -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 963 bytes Desc: This is a digitally signed message part URL: From lldb-commits at lists.llvm.org Thu Mar 30 13:55:15 2017 From: lldb-commits at lists.llvm.org (Chris Bieneman via lldb-commits) Date: Thu, 30 Mar 2017 13:55:15 -0700 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: References: Message-ID: <5842F165-591E-4281-8441-7877CE349CEB@apple.com> I had a talk with Lang about the ExecutionEngine library structuring, and it sounds like there are some problems there that need to be worked out. Luckily for this specific case, I think the solution is actually quite simple: ``` diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index f68337c..cc99f94 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -15,7 +15,6 @@ #ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H #define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H -#include "RuntimeDyld.h" #include "llvm-c/ExecutionEngine.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -49,6 +48,7 @@ class ObjectCache; class RTDyldMemoryManager; class Triple; class Type; +class JITSymbolResolver; namespace object { class Archive; ``` It seems to me that there is no reason why ExecutionEngine.h needs to include RuntimeDyld.h. a forward declaration of the JITSymbolResolver class will suffice. -Chris > On Mar 30, 2017, at 11:41 AM, Michał Górny via Phabricator wrote: > > mgorny added a comment. > > In https://reviews.llvm.org/D31367#714305, @beanz wrote: > >> Please revert your patch. It is *not* the right solution and is masking underlying problems. > > > Reverted in r299095. Now I'd really appreciate some help in figuring out how to fix it properly. > >> ExecutionEngine headers directly reference symbols from RuntimeDyld, so we should enforce a requirement that anyone using ExeuctionEngine also link RuntimeDyld. This works today as expected for static archive builds. It is only broken with `BUILD_SHARED_LIBS`. I suspect the problem is that when built as a DSO ExecutionEngine has no unresolved symbols against RuntimeDyld, and the linker probably isn't including the reference to RuntimeDyld in the produced ExecutionEngine DSO. > > The DSO is linking to RuntimeDyld. However, obviously the `PRIVATE` linkage forced in `llvm_add_library` is not the correct solution when the symbols are explicitly used in the headers. It should be `PUBLIC` for that particular component. Any suggestion on how to fix that API? Should I add an additional `PUBLIC_LINK_COMPONENTS` (and `PUBLIC_LINK_LIBS`)? > > > Repository: > rL LLVM > > https://reviews.llvm.org/D31367 > > > From lldb-commits at lists.llvm.org Thu Mar 30 14:13:40 2017 From: lldb-commits at lists.llvm.org (=?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= via lldb-commits) Date: Thu, 30 Mar 2017 23:13:40 +0200 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: <5842F165-591E-4281-8441-7877CE349CEB@apple.com> References: <5842F165-591E-4281-8441-7877CE349CEB@apple.com> Message-ID: <1490908420.12326.6.camel@gentoo.org> On czw, 2017-03-30 at 13:55 -0700, Chris Bieneman wrote: > I had a talk with Lang about the ExecutionEngine library structuring, and it sounds like there are some problems there that need to be worked out. > > Luckily for this specific case, I think the solution is actually quite simple: > > ``` > diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h > index f68337c..cc99f94 100644 > --- a/include/llvm/ExecutionEngine/ExecutionEngine.h > +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h > @@ -15,7 +15,6 @@ > #ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H > #define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H > > -#include "RuntimeDyld.h" > #include "llvm-c/ExecutionEngine.h" > #include "llvm/ADT/SmallVector.h" > #include "llvm/ADT/StringRef.h" > @@ -49,6 +48,7 @@ class ObjectCache; > class RTDyldMemoryManager; > class Triple; > class Type; > +class JITSymbolResolver; > > namespace object { > class Archive; > ``` > > It seems to me that there is no reason why ExecutionEngine.h needs to include RuntimeDyld.h. a forward declaration of the JITSymbolResolver class will suffice. > Thanks, I'll test this patch and get back to you. -- Best regards, Michał Górny -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 963 bytes Desc: This is a digitally signed message part URL: From lldb-commits at lists.llvm.org Thu Mar 30 14:19:40 2017 From: lldb-commits at lists.llvm.org (Greg Clayton via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 21:19:40 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: clayborg requested changes to this revision. clayborg added a comment. This revision now requires changes to proceed. Simple logic change so we don't check the range validity more than once. ================ Comment at: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp:1506-1510 + // We got an invalid address range back + if (!region_info.GetRange().IsValid()) { + error.SetErrorString("Server returned invalid range"); + } + ---------------- Logic is fine, but I would work this into the if statement below. Something like: ``` if (region_info.GetRange().IsValid()) { if (!saw_permissions) { region_info.SetReadable(MemoryRegionInfo::eNo); region_info.SetWritable(MemoryRegionInfo::eNo); region_info.SetExecutable(MemoryRegionInfo::eNo); region_info.SetMapped(MemoryRegionInfo::eNo); } } else { // We got an invalid address range back error.SetErrorString("Server returned invalid range"); } ``` https://reviews.llvm.org/D31485 From lldb-commits at lists.llvm.org Thu Mar 30 14:27:51 2017 From: lldb-commits at lists.llvm.org (Tim Hammerquist via lldb-commits) Date: Thu, 30 Mar 2017 21:27:51 -0000 Subject: [Lldb-commits] [lldb] r299116 - add NetBSD files to Xcode project to resolve failure from r299109 Message-ID: <20170330212752.42D752A6C02B@llvm.org> Author: penryu Date: Thu Mar 30 16:27:51 2017 New Revision: 299116 URL: http://llvm.org/viewvc/llvm-project?rev=299116&view=rev Log: add NetBSD files to Xcode project to resolve failure from r299109 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=299116&r1=299115&r2=299116&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Mar 30 16:27:51 2017 @@ -880,6 +880,7 @@ 9AC70390117675270086C050 /* SBInstructionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038F117675270086C050 /* SBInstructionList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; }; 9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; }; + 9AD9449F1E8DB26C004796ED /* RegisterContextNetBSD_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AD9449B1E8DB267004796ED /* RegisterContextNetBSD_x86_64.cpp */; }; A36FF33C17D8E94600244D40 /* OptionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A36FF33B17D8E94600244D40 /* OptionParser.cpp */; }; AE44FB301BB07EB20033EB62 /* GoUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2C1BB07DD80033EB62 /* GoUserExpression.cpp */; }; AE44FB311BB07EB80033EB62 /* GoLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2A1BB07DD80033EB62 /* GoLexer.cpp */; }; @@ -2851,6 +2852,8 @@ 9AC7038F117675270086C050 /* SBInstructionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBInstructionList.h; path = include/lldb/API/SBInstructionList.h; sourceTree = ""; }; 9AC703AE117675410086C050 /* SBInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInstruction.cpp; path = source/API/SBInstruction.cpp; sourceTree = ""; }; 9AC703B0117675490086C050 /* SBInstructionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInstructionList.cpp; path = source/API/SBInstructionList.cpp; sourceTree = ""; }; + 9AD9449B1E8DB267004796ED /* RegisterContextNetBSD_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextNetBSD_x86_64.cpp; path = Utility/RegisterContextNetBSD_x86_64.cpp; sourceTree = ""; }; + 9AD9449C1E8DB267004796ED /* RegisterContextNetBSD_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextNetBSD_x86_64.h; path = Utility/RegisterContextNetBSD_x86_64.h; sourceTree = ""; }; 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBreakpoint.cpp; path = source/API/SBBreakpoint.cpp; sourceTree = ""; }; 9AF16A9E11402D69007A7B3F /* SBBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBreakpoint.h; path = include/lldb/API/SBBreakpoint.h; sourceTree = ""; }; 9AF16CC611408686007A7B3F /* SBBreakpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBreakpointLocation.h; path = include/lldb/API/SBBreakpointLocation.h; sourceTree = ""; }; @@ -4517,6 +4520,8 @@ 26B4666E11A2080F00CF6220 /* Utility */ = { isa = PBXGroup; children = ( + 9AD9449B1E8DB267004796ED /* RegisterContextNetBSD_x86_64.cpp */, + 9AD9449C1E8DB267004796ED /* RegisterContextNetBSD_x86_64.h */, 23F403471926C8D50046DC9B /* NativeRegisterContextRegisterInfo.h */, 23F403481926CC250046DC9B /* NativeRegisterContextRegisterInfo.cpp */, B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */, @@ -7354,6 +7359,7 @@ 268900D013353E6F00698AC0 /* Block.cpp in Sources */, 268900D113353E6F00698AC0 /* ClangASTContext.cpp in Sources */, 265192C61BA8E905002F08F6 /* CompilerDecl.cpp in Sources */, + 9AD9449F1E8DB26C004796ED /* RegisterContextNetBSD_x86_64.cpp in Sources */, 268900D213353E6F00698AC0 /* CompilerType.cpp in Sources */, 945261C11B9A11FC00BF138D /* LibCxxInitializerList.cpp in Sources */, 268900D313353E6F00698AC0 /* ClangExternalASTSourceCallbacks.cpp in Sources */, From lldb-commits at lists.llvm.org Thu Mar 30 15:38:43 2017 From: lldb-commits at lists.llvm.org (Joerg Sonnenberger via lldb-commits) Date: Fri, 31 Mar 2017 00:38:43 +0200 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: <1490906859.12326.0.camel@gentoo.org> References: <20170330193741.GA25324@britannica.bec.de> <1490906859.12326.0.camel@gentoo.org> Message-ID: <20170330223843.GA19924@britannica.bec.de> On Thu, Mar 30, 2017 at 10:47:39PM +0200, Michał Górny wrote: > On czw, 2017-03-30 at 21:37 +0200, Joerg Sonnenberger wrote: > > On Thu, Mar 30, 2017 at 06:00:15PM +0000, Chris Bieneman via Phabricator wrote: > > > ExecutionEngine headers directly reference symbols from RuntimeDyld, > > > so we should enforce a requirement that anyone using ExeuctionEngine > > > also link RuntimeDyld. This works today as expected for static archive > > > builds. It is only broken with `BUILD_SHARED_LIBS`. > > > > Welcome to the brave new world of newer ELF linkers. Just because a > > library pulls in a symbol into the namespace doesn't mean you can just > > use that symbol. They want you to explicitly specify the dependency... > > This does happen for static archives though. > > This is expected and desired. Just because some random library you're > using is using zlib does not mean you should skip linking zlib when your > program is using it too. That justification never made that much sense. The linker simply does not know whether the dependency is considered part of the ABI contract of the library or not. Hint: the symbol lookup rules for ELF is recursive. Having different rules for link-time vs run-time is a very good sign that something is very fishy. But let's not get distracted. The behavior change of GNU linkers (and anything following them) is exactly why the original patch was correct here. Symbols from RuntimeDyld are directly used -- as such the library should be an explicit declared dependency. If no such reference is created, i.e. due to not using any of the header functions references such symbols, no such dependency is necessary. ExecutionEngine can't tell in advance. Joerg From lldb-commits at lists.llvm.org Thu Mar 30 16:51:25 2017 From: lldb-commits at lists.llvm.org (Alex Langford via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 23:51:25 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: <8723cddc099ed7da9fc9bbc9a25f8a2b@localhost.localdomain> xiaobai updated this revision to Diff 93566. xiaobai added a comment. Added unit tests for the method and changed the logic according to clayborg's suggestion. https://reviews.llvm.org/D31485 Files: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Index: unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp =================================================================== --- unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -13,6 +13,7 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StructuredData.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/DataBuffer.h" #include "llvm/ADT/ArrayRef.h" @@ -331,3 +332,45 @@ HandlePacket(server, "QPassSignals:", "OK"); EXPECT_TRUE(result.get().Success()); } + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0xa000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + // name is: /foo/bar.so + HandlePacket(server, + "qMemoryRegionInfo:a000", + "start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;"); + EXPECT_TRUE(result.get().Success()); + +} + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0x4000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;"); + EXPECT_FALSE(result.get().Success()); + + result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); +} Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1503,13 +1503,18 @@ } } - // We got a valid address range back but no permissions -- which means - // this is an unmapped page - if (region_info.GetRange().IsValid() && saw_permissions == false) { - region_info.SetReadable(MemoryRegionInfo::eNo); - region_info.SetWritable(MemoryRegionInfo::eNo); - region_info.SetExecutable(MemoryRegionInfo::eNo); - region_info.SetMapped(MemoryRegionInfo::eNo); + if (region_info.GetRange().IsValid()) { + // We got a valid address range back but no permissions -- which means + // this is an unmapped page + if (!saw_permissions) { + region_info.SetReadable(MemoryRegionInfo::eNo); + region_info.SetWritable(MemoryRegionInfo::eNo); + region_info.SetExecutable(MemoryRegionInfo::eNo); + region_info.SetMapped(MemoryRegionInfo::eNo); + } + } else { + // We got an invalid address range back + error.SetErrorString("Server returned invalid range"); } } else { m_supports_memory_region_info = eLazyBoolNo; -------------- next part -------------- A non-text attachment was scrubbed... Name: D31485.93566.patch Type: text/x-patch Size: 3283 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Thu Mar 30 16:52:20 2017 From: lldb-commits at lists.llvm.org (Alex Langford via Phabricator via lldb-commits) Date: Thu, 30 Mar 2017 23:52:20 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: <6236579d3ac4afe78e4e0722cc746fb7@localhost.localdomain> xiaobai marked an inline comment as done. xiaobai added inline comments. ================ Comment at: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp:1506-1510 + // We got an invalid address range back + if (!region_info.GetRange().IsValid()) { + error.SetErrorString("Server returned invalid range"); + } + ---------------- clayborg wrote: > Logic is fine, but I would work this into the if statement below. Something like: > > ``` > if (region_info.GetRange().IsValid()) { > if (!saw_permissions) { > region_info.SetReadable(MemoryRegionInfo::eNo); > region_info.SetWritable(MemoryRegionInfo::eNo); > region_info.SetExecutable(MemoryRegionInfo::eNo); > region_info.SetMapped(MemoryRegionInfo::eNo); > } > } else { > // We got an invalid address range back > error.SetErrorString("Server returned invalid range"); > } > ``` Thanks for pointing that out! https://reviews.llvm.org/D31485 From lldb-commits at lists.llvm.org Thu Mar 30 18:04:31 2017 From: lldb-commits at lists.llvm.org (Eugene Zemtsov via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 01:04:31 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: <2280d6756674bd747bcee8c78be1c25b@localhost.localdomain> eugene updated this revision to Diff 93572. eugene added a comment. Addressing code-review comments. Most notable change: MethodName::Parse() tries simple version of name parser, before invoking full power of CPlusPlusNameParser. It really helps with the perf. https://reviews.llvm.org/D31451 Files: source/Plugins/Language/CPlusPlus/CMakeLists.txt source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31451.93572.patch Type: text/x-patch Size: 43273 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Thu Mar 30 18:23:22 2017 From: lldb-commits at lists.llvm.org (Kamil Rytarowski via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 01:23:22 +0000 Subject: [Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements In-Reply-To: References: Message-ID: <695c40e3616fc4edd43b8c7e6f41e829@localhost.localdomain> krytarowski added a comment. Thanks! I noted that I introduced some bugs.. but I will fix them in future revisions. I will move on to threads now. FPR/watchpoints will be done later, on the cost on adding some code for cores and helping out with base system work. LLDB/NetBSD is now out of the box functional as a debugger for a single thread. Repository: rL LLVM https://reviews.llvm.org/D31450 From lldb-commits at lists.llvm.org Thu Mar 30 18:31:01 2017 From: lldb-commits at lists.llvm.org (Greg Clayton via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 01:31:01 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Looks good. https://reviews.llvm.org/D31485 From lldb-commits at lists.llvm.org Thu Mar 30 18:42:14 2017 From: lldb-commits at lists.llvm.org (Eugene Zemtsov via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 01:42:14 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: eugene marked 4 inline comments as done. eugene added a comment. > I think we should do some performance measurements to see whether this needs more optimising or it's fine as is. > > I propose the following benchmark: > > bin/lldb bin/clang > > make sure clang is statically linked > breakpoint set --name non_exisiting_function > > Setting the breakpoint on a nonexistent function avoids us timing the breakpoint setting machinery, while still getting every symbol in the executable parsed. I did some micro-benchmarking and on average new parser is ~3 time slower than the old one. (new parser - ~200k string/s, old parser - ~700k string/s) clang::Lexer appears to be the slowest part of it. On the clang breakpoint benchmark you proposed, it is hard to notice much of a difference. clang binary has about 500k functions. With new parser it takes about 11s to try to set a breakpoint, on the old one it's about 10s. (release version of LLDB, debug static version of clang) I decided to use a hybrid approach, when we use old parsing code for simple cases and call new parser only when it fails. 80% of clang functions are simple enough that we don't really need the new parser, so it helped to bring clang breakpoint test back to 10s. I think it's reasonable to assume that similar distribution is true for most programs, and most of their functions can be parsed with the old code. I don't think we can really improve performance of a new parser without giving up on clang::Lexer, and I'm reluctant to do it. So I propose to keep hybrid approach and call a new parser only for complicated cases. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:94 if (!m_parsed && m_full) { - // ConstString mangled; - // m_full.GetMangledCounterpart(mangled); - // printf ("\n parsing = '%s'\n", m_full.GetCString()); - // if (mangled) - // printf (" mangled = '%s'\n", mangled.GetCString()); - m_parse_error = false; - m_parsed = true; - llvm::StringRef full(m_full.GetCString()); - - size_t arg_start, arg_end; - llvm::StringRef parens("()", 2); - if (ReverseFindMatchingChars(full, parens, arg_start, arg_end)) { - m_arguments = full.substr(arg_start, arg_end - arg_start + 1); - if (arg_end + 1 < full.size()) - m_qualifiers = full.substr(arg_end + 1); - if (arg_start > 0) { - size_t basename_end = arg_start; - size_t context_start = 0; - size_t context_end = llvm::StringRef::npos; - if (basename_end > 0 && full[basename_end - 1] == '>') { - // TODO: handle template junk... - // Templated function - size_t template_start, template_end; - llvm::StringRef lt_gt("<>", 2); - if (ReverseFindMatchingChars(full, lt_gt, template_start, - template_end, basename_end)) { - // Check for templated functions that include return type like: - // 'void foo()' - context_start = full.rfind(' ', template_start); - if (context_start == llvm::StringRef::npos) - context_start = 0; - else - ++context_start; - - context_end = full.rfind(':', template_start); - if (context_end == llvm::StringRef::npos || - context_end < context_start) - context_end = context_start; - } else { - context_end = full.rfind(':', basename_end); - } - } else if (context_end == llvm::StringRef::npos) { - context_end = full.rfind(':', basename_end); - } - - if (context_end == llvm::StringRef::npos) - m_basename = full.substr(0, basename_end); - else { - if (context_start < context_end) - m_context = - full.substr(context_start, context_end - 1 - context_start); - const size_t basename_begin = context_end + 1; - m_basename = - full.substr(basename_begin, basename_end - basename_begin); - } - m_type = eTypeUnknownMethod; - } else { - m_parse_error = true; - return; - } - - if (!IsValidBasename(m_basename)) { - // The C++ basename doesn't match our regular expressions so this can't - // be a valid C++ method, clear everything out and indicate an error - m_context = llvm::StringRef(); - m_basename = llvm::StringRef(); - m_arguments = llvm::StringRef(); - m_qualifiers = llvm::StringRef(); - m_parse_error = true; - } + CPlusPlusNameParser parser(m_full.GetStringRef()); + auto function = parser.ParseAsFunctionDefinition(); ---------------- labath wrote: > How about the following api: > ``` > if (auto function​ = CPlusPlusNameParser::ParseAsFunctionDefinition(m_full.GetStringRef())) { > ... > ``` If you don't mind I'll leave it as it is. I understand that it's very tempting to have two simple functions ParseAsFunctionDefinition and ParseAsFullName instead of a class, but I can imagine calling second one if first one fails, and in this case it'll be good that parser doesn't need to tokenize string all over again. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:160 + auto full_name = parser.ParseAsFullName(); + if (full_name.hasValue()) { + identifier = full_name.getValue().m_basename; ---------------- labath wrote: > Same here see above ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:62 +bool CPlusPlusNameParser::HasMoreTokens() { + return m_next_token_index < static_cast(m_tokens.size()); +} ---------------- labath wrote: > Wouldn't it be better to change the type of m_next_token_index to size_t? Unsigned types are dangerous. I prefer to avoid them wherever I can. As far as I remember many members of C++ standard commit publicly regretted the fact that .size() returns an unsigned type. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:188 + // as arithmetic or shift operators not as template brackets. + // Examples: std::enable_if<(10u)<(64), bool> + // f> ---------------- labath wrote: > Is this really the case for the types we are interested in? I would have hoped that this would get simplified to `std::enable_if before it reaches us? Yes. I was very surprised as well. But apparently compiler sometimes is being lazy and doesn't simplify everything :( Running: ~$ nm -C --defined-only clang | grep std::enable_if Gives a few symbols like this: std::enable_if<(10u)<(64), bool>::type llvm::isUInt<10u>(unsigned long) ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:572 + clang::SourceLocation end_location = last_token.getLocation(); + const char *begin_ptr = m_text.data() + begin_location.getRawEncoding(); + const char *end_ptr = ---------------- labath wrote: > Could this be written as: > `m_text.take_front(end_pos).drop_front(start_pos)`? Thanks! I still have a lot to learn about llvm classes. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h:94 + // when destructed unless it's manually removed with Remove(). + class Bookmark { + public: ---------------- labath wrote: > Please make the type move-only. Otherwise you will have a fun time debugging accidental copies. (You already have one, although it is benign now) Good catch! Thanks! ================ Comment at: unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp:106 + EXPECT_EQ(test.qualifiers, method.GetQualifiers()) + << method.GetQualifiers(); EXPECT_EQ(test.scope_qualified_name, method.GetScopeQualifiedName()); ---------------- labath wrote: > Would defining operator<< for std::ostream and StringRef ( local tomthis test) enable you to get rid of these? > I've ran into this before but was never annoyed enough to actually do it.. :/ I tried to to it, but it didn't work for me after a few tries. I decided to just convert it to std::string, it solves the same problem. https://reviews.llvm.org/D31451 From lldb-commits at lists.llvm.org Thu Mar 30 18:32:57 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Fri, 31 Mar 2017 01:32:57 -0000 Subject: [Lldb-commits] [lldb] r299147 - Don't add a newline if the object description already has one. Message-ID: <20170331013257.D83AC2A6C04C@llvm.org> Author: jingham Date: Thu Mar 30 20:32:57 2017 New Revision: 299147 URL: http://llvm.org/viewvc/llvm-project?rev=299147&view=rev Log: Don't add a newline if the object description already has one. Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=299147&r1=299146&r2=299147&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original) +++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Thu Mar 30 20:32:57 2017 @@ -457,7 +457,12 @@ bool ValueObjectPrinter::PrintObjectDesc else object_desc = GetDescriptionForDisplay(); if (object_desc && *object_desc) { - m_stream->Printf("%s\n", object_desc); + // If the description already ends with a \n don't add another one. + size_t object_end = strlen(object_desc) - 1; + if (object_desc[object_end] == '\n') + m_stream->Printf("%s", object_desc); + else + m_stream->Printf("%s\n", object_desc); return true; } else if (value_printed == false && summary_printed == false) return true; From lldb-commits at lists.llvm.org Fri Mar 31 02:14:06 2017 From: lldb-commits at lists.llvm.org (=?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= via lldb-commits) Date: Fri, 31 Mar 2017 11:14:06 +0200 Subject: [Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component In-Reply-To: <5842F165-591E-4281-8441-7877CE349CEB@apple.com> References: <5842F165-591E-4281-8441-7877CE349CEB@apple.com> Message-ID: <1490951646.8050.1.camel@gentoo.org> On czw, 2017-03-30 at 13:55 -0700, Chris Bieneman wrote: > I had a talk with Lang about the ExecutionEngine library structuring, and it sounds like there are some problems there that need to be worked out. > > Luckily for this specific case, I think the solution is actually quite simple: > > ``` > diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h > index f68337c..cc99f94 100644 > --- a/include/llvm/ExecutionEngine/ExecutionEngine.h > +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h > @@ -15,7 +15,6 @@ > #ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H > #define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H > > -#include "RuntimeDyld.h" > #include "llvm-c/ExecutionEngine.h" > #include "llvm/ADT/SmallVector.h" > #include "llvm/ADT/StringRef.h" > @@ -49,6 +48,7 @@ class ObjectCache; > class RTDyldMemoryManager; > class Triple; > class Type; > +class JITSymbolResolver; > > namespace object { > class Archive; > ``` > > It seems to me that there is no reason why ExecutionEngine.h needs to include RuntimeDyld.h. a forward declaration of the JITSymbolResolver class will suffice. > This does not solve the problem: lib64/liblldbExpression.a(IRExecutionUnit.cpp.o):IRExecutionUnit.cpp:function llvm::RTDyldMemoryManager::deregisterEHFrames(unsigned char*, unsigned long, unsigned long): error: undefined reference to 'llvm::RTDyldMemoryManager::deregisterEHFramesInProcess(unsigned char*, unsigned long)' lib64/liblldbExpression.a(IRExecutionUnit.cpp.o):IRExecutionUnit.cpp:vtable for lldb_private::IRExecutionUnit::MemoryManager: error: undefined reference to 'llvm::RuntimeDyld::MemoryManager::anchor()' lib64/liblldbExpression.a(IRExecutionUnit.cpp.o):IRExecutionUnit.cpp:vtable for lldb_private::IRExecutionUnit::MemoryManager: error: undefined reference to 'llvm::JITSymbolResolver::anchor()' collect2: error: ld returned 1 exit status -- Best regards, Michał Górny -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 963 bytes Desc: This is a digitally signed message part URL: From lldb-commits at lists.llvm.org Fri Mar 31 03:00:25 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 10:00:25 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: <29aeb7bec68911f4c6e5bc3f39b57070@localhost.localdomain> labath accepted this revision. labath added a comment. Thank you for adding the test. Lgtm, assuming the second getmemoryregioninfo call is accidental. ================ Comment at: unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp:373 + + result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); ---------------- This seems out of place. Should we delete it? https://reviews.llvm.org/D31485 From lldb-commits at lists.llvm.org Fri Mar 31 03:55:56 2017 From: lldb-commits at lists.llvm.org (Nitesh Jain via lldb-commits) Date: Fri, 31 Mar 2017 10:55:56 -0000 Subject: [Lldb-commits] [lldb] r299196 - [LLDB][MIPS] Check if memory_info.GetName() is empty before finding corresponding module. Message-ID: <20170331105556.4230B2A6C04E@llvm.org> Author: nitesh.jain Date: Fri Mar 31 05:55:55 2017 New Revision: 299196 URL: http://llvm.org/viewvc/llvm-project?rev=299196&view=rev Log: [LLDB][MIPS] Check if memory_info.GetName() is empty before finding corresponding module. Reviewers: labath, clayborg Subscribers: jaydeep, bhushan, lldb-commits, slthakur Differential Revision: https://reviews.llvm.org/D30454 Modified: lldb/trunk/source/Core/DynamicLoader.cpp Modified: lldb/trunk/source/Core/DynamicLoader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DynamicLoader.cpp?rev=299196&r1=299195&r2=299196&view=diff ============================================================================== --- lldb/trunk/source/Core/DynamicLoader.cpp (original) +++ lldb/trunk/source/Core/DynamicLoader.cpp Fri Mar 31 05:55:55 2017 @@ -189,7 +189,8 @@ ModuleSP DynamicLoader::LoadModuleAtAddr MemoryRegionInfo memory_info; Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info); if (error.Success() && memory_info.GetMapped() && - memory_info.GetRange().GetRangeBase() == base_addr) { + memory_info.GetRange().GetRangeBase() == base_addr && + !(memory_info.GetName().IsEmpty())) { ModuleSpec new_module_spec( FileSpec(memory_info.GetName().AsCString(), false), target.GetArchitecture()); From lldb-commits at lists.llvm.org Fri Mar 31 04:08:19 2017 From: lldb-commits at lists.llvm.org (Nitesh Jain via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 11:08:19 +0000 Subject: [Lldb-commits] [PATCH] D30454: [LLDB][MIPS] Check if memory_info.GetName() is empty before finding corresponding module. In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rL299196: [LLDB][MIPS] Check if memory_info.GetName() is empty before finding… (authored by nitesh.jain). Changed prior to commit: https://reviews.llvm.org/D30454?vs=91855&id=93614#toc Repository: rL LLVM https://reviews.llvm.org/D30454 Files: lldb/trunk/source/Core/DynamicLoader.cpp Index: lldb/trunk/source/Core/DynamicLoader.cpp =================================================================== --- lldb/trunk/source/Core/DynamicLoader.cpp +++ lldb/trunk/source/Core/DynamicLoader.cpp @@ -189,7 +189,8 @@ MemoryRegionInfo memory_info; Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info); if (error.Success() && memory_info.GetMapped() && - memory_info.GetRange().GetRangeBase() == base_addr) { + memory_info.GetRange().GetRangeBase() == base_addr && + !(memory_info.GetName().IsEmpty())) { ModuleSpec new_module_spec( FileSpec(memory_info.GetName().AsCString(), false), target.GetArchitecture()); -------------- next part -------------- A non-text attachment was scrubbed... Name: D30454.93614.patch Type: text/x-patch Size: 701 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 04:06:26 2017 From: lldb-commits at lists.llvm.org (Nitesh Jain via lldb-commits) Date: Fri, 31 Mar 2017 11:06:26 -0000 Subject: [Lldb-commits] [lldb] r299199 - [LLDB][MIPS] Fix Core file Architecture and OS information. Message-ID: <20170331110626.923762A6C04E@llvm.org> Author: nitesh.jain Date: Fri Mar 31 06:06:25 2017 New Revision: 299199 URL: http://llvm.org/viewvc/llvm-project?rev=299199&view=rev Log: [LLDB][MIPS] Fix Core file Architecture and OS information. Reviewers: labath, clayborg Subscribers: jaydeep, bhushan, lldb-commits, slthakur Differential Revision: https://reviews.llvm.org/D31280 Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out (with props) lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out (with props) lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out (with props) Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=299199&r1=299198&r2=299199&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py Fri Mar 31 06:06:25 2017 @@ -21,10 +21,14 @@ class LinuxCoreTestCase(TestBase): _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 + _mips64_n64_pid = 25619 + _mips64_n32_pid = 3670 + _mips_o32_pid = 3532 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 + _mips_regions = 5 def setUp(self): super(LinuxCoreTestCase, self).setUp() @@ -40,6 +44,18 @@ class LinuxCoreTestCase(TestBase): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("linux-i386", self._i386_pid, self._i386_regions) + def test_mips_o32(self): + """Test that lldb can read the process information from an MIPS O32 linux core file.""" + self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, self._mips_regions) + + def test_mips_n32(self): + """Test that lldb can read the process information from an MIPS N32 linux core file """ + self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, self._mips_regions) + + def test_mips_n64(self): + """Test that lldb can read the process information from an MIPS N64 linux core file """ + self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, self._mips_regions) + @skipIf(oslist=['windows']) @skipIf(triple='^mips') def test_x86_64(self): Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core?rev=299199&view=auto ============================================================================== Binary files lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core (added) and lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core Fri Mar 31 06:06:25 2017 differ Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out?rev=299199&view=auto ============================================================================== Binary files lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out (added) and lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out Fri Mar 31 06:06:25 2017 differ Propchange: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out ------------------------------------------------------------------------------ svn:executable = * Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core?rev=299199&view=auto ============================================================================== Binary files lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core (added) and lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core Fri Mar 31 06:06:25 2017 differ Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out?rev=299199&view=auto ============================================================================== Binary files lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out (added) and lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out Fri Mar 31 06:06:25 2017 differ Propchange: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out ------------------------------------------------------------------------------ svn:executable = * Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core?rev=299199&view=auto ============================================================================== Binary files lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core (added) and lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core Fri Mar 31 06:06:25 2017 differ Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out?rev=299199&view=auto ============================================================================== Binary files lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out (added) and lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out Fri Mar 31 06:06:25 2017 differ Propchange: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out ------------------------------------------------------------------------------ svn:executable = * Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=299199&r1=299198&r2=299199&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Mar 31 06:06:25 2017 @@ -288,10 +288,26 @@ static uint32_t kalimbaVariantFromElfFla return kal_arch_variant; } -static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags, - uint32_t endian) { - const uint32_t mips_arch = e_flags & llvm::ELF::EF_MIPS_ARCH; +static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) { + const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH; + uint32_t endian = header.e_ident[EI_DATA]; uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown; + uint32_t fileclass = header.e_ident[EI_CLASS]; + + // If there aren't any elf flags available (e.g core elf file) then return default + // 32 or 64 bit arch (without any architecture revision) based on object file's class. + if (header.e_type == ET_CORE) { + switch (fileclass) { + case llvm::ELF::ELFCLASS32: + return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el + : ArchSpec::eMIPSSubType_mips32; + case llvm::ELF::ELFCLASS64: + return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips64el + : ArchSpec::eMIPSSubType_mips64; + default: + return arch_variant; + } + } switch (mips_arch) { case llvm::ELF::EF_MIPS_ARCH_1: @@ -326,7 +342,7 @@ static uint32_t mipsVariantFromElfFlags( static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) { if (header.e_machine == llvm::ELF::EM_MIPS) - return mipsVariantFromElfFlags(header.e_flags, header.e_ident[EI_DATA]); + return mipsVariantFromElfFlags(header); return llvm::ELF::EM_CSR_KALIMBA == header.e_machine ? kalimbaVariantFromElfFlags(header.e_flags) @@ -1349,6 +1365,10 @@ ObjectFileELF::RefineModuleDetailsFromNo } break; } + if (arch_spec.IsMIPS() && + arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS) + // The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform + arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); } // Process NetBSD ELF notes. else if ((note.n_name == LLDB_NT_OWNER_NETBSD) && @@ -1450,6 +1470,12 @@ ObjectFileELF::RefineModuleDetailsFromNo break; } } + if (arch_spec.IsMIPS() && + arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS) + // In case of MIPSR6, the LLDB_NT_OWNER_GNU note is missing + // for some cases (e.g. compile with -nostdlib) + // Hence set OS to Linux + arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); } } Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=299199&r1=299198&r2=299199&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original) +++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Fri Mar 31 06:06:25 2017 @@ -214,9 +214,12 @@ Error ProcessElfCore::DoLoadCore() { // Even if the architecture is set in the target, we need to override // it to match the core file which is always single arch. ArchSpec arch(m_core_module_sp->GetArchitecture()); - if (arch.IsValid()) - GetTarget().SetArchitecture(arch); + ArchSpec target_arch = GetTarget().GetArchitecture(); + ArchSpec core_arch(m_core_module_sp->GetArchitecture()); + target_arch.MergeFrom(core_arch); + GetTarget().SetArchitecture(target_arch); + SetUnixSignals(UnixSignals::Create(GetArchitecture())); // Ensure we found at least one thread that was stopped on a signal. @@ -370,6 +373,10 @@ size_t ProcessElfCore::DoReadMemory(lldb lldb::addr_t bytes_left = 0; // Number of bytes available in the core file from the given address + // Don't proceed if core file doesn't contain the actual data for this address range. + if (file_start == file_end) + return 0; + // Figure out how many on-disk bytes remain in this segment // starting at the given offset if (file_end > file_start + offset) @@ -652,6 +659,8 @@ Error ProcessElfCore::ParseThreadContext // The result from FXSAVE is in NT_PRXFPREG for i386 core files if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64) thread_data->fpregset = note_data; + else if(arch.IsMIPS()) + thread_data->fpregset = note_data; break; case NT_PRPSINFO: have_prpsinfo = true; @@ -719,6 +728,12 @@ ArchSpec ProcessElfCore::GetArchitecture (ObjectFileELF *)(m_core_module_sp->GetObjectFile()); ArchSpec arch; core_file->GetArchitecture(arch); + + ArchSpec target_arch = GetTarget().GetArchitecture(); + + if (target_arch.IsMIPS()) + return target_arch; + return arch; } From lldb-commits at lists.llvm.org Fri Mar 31 04:18:54 2017 From: lldb-commits at lists.llvm.org (Nitesh Jain via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 11:18:54 +0000 Subject: [Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information In-Reply-To: References: Message-ID: <83dfba0413fcd77d8d0c835b40ba21f8@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rL299199: [LLDB][MIPS] Fix Core file Architecture and OS information. (authored by nitesh.jain). Changed prior to commit: https://reviews.llvm.org/D31280?vs=93130&id=93615#toc Repository: rL LLVM https://reviews.llvm.org/D31280 Files: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31280.93615.patch Type: text/x-patch Size: 6298 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 04:14:03 2017 From: lldb-commits at lists.llvm.org (Nitesh Jain via lldb-commits) Date: Fri, 31 Mar 2017 11:14:03 -0000 Subject: [Lldb-commits] [lldb] r299200 - [LLDB][MIPS] Core Dump Support. Message-ID: <20170331111404.819E82A6C04E@llvm.org> Author: nitesh.jain Date: Fri Mar 31 06:14:02 2017 New Revision: 299200 URL: http://llvm.org/viewvc/llvm-project?rev=299200&view=rev Log: [LLDB][MIPS] Core Dump Support. Reviewers: labath, emaste Subscribers: jaydeep, bhushan, lldb-commits, slthakur Differential Revision: https://reviews.llvm.org/D30457 Modified: lldb/trunk/source/Core/ArchSpec.cpp lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h Modified: lldb/trunk/source/Core/ArchSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Core/ArchSpec.cpp (original) +++ lldb/trunk/source/Core/ArchSpec.cpp Fri Mar 31 06:14:02 2017 @@ -1380,7 +1380,7 @@ static bool cores_match(const ArchSpec:: if (core2 >= ArchSpec::kCore_mips32el_first && core2 <= ArchSpec::kCore_mips32el_last) return true; - try_inverse = false; + try_inverse = true; } break; Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h Fri Mar 31 06:14:02 2017 @@ -11,6 +11,7 @@ #define liblldb_RegisterContextPOSIXProcessMonitor_mips64_H_ #include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h" +#include "Plugin/Process/Utility/lldb-mips-freebsd-register-enums.h" #include "RegisterContextPOSIX.h" class RegisterContextPOSIXProcessMonitor_mips64 @@ -72,6 +73,8 @@ protected: uint32_t NumSupportedHardwareWatchpoints(); private: + uint64_t + m_gpr_mips64[k_num_gpr_registers_mips64]; // general purpose registers. ProcessMonitor &GetMonitor(); }; Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp Fri Mar 31 06:14:02 2017 @@ -80,152 +80,6 @@ struct pt_watch_regs default_watch_regs; using namespace lldb_private; using namespace lldb_private::process_linux; -// ---------------------------------------------------------------------------- -// Private namespace. -// ---------------------------------------------------------------------------- - -namespace { -// mips general purpose registers. -const uint32_t g_gp_regnums_mips[] = { - gpr_zero_mips, gpr_r1_mips, gpr_r2_mips, gpr_r3_mips, - gpr_r4_mips, gpr_r5_mips, gpr_r6_mips, gpr_r7_mips, - gpr_r8_mips, gpr_r9_mips, gpr_r10_mips, gpr_r11_mips, - gpr_r12_mips, gpr_r13_mips, gpr_r14_mips, gpr_r15_mips, - gpr_r16_mips, gpr_r17_mips, gpr_r18_mips, gpr_r19_mips, - gpr_r20_mips, gpr_r21_mips, gpr_r22_mips, gpr_r23_mips, - gpr_r24_mips, gpr_r25_mips, gpr_r26_mips, gpr_r27_mips, - gpr_gp_mips, gpr_sp_mips, gpr_r30_mips, gpr_ra_mips, - gpr_sr_mips, gpr_mullo_mips, gpr_mulhi_mips, gpr_badvaddr_mips, - gpr_cause_mips, gpr_pc_mips, gpr_config5_mips, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; - -static_assert((sizeof(g_gp_regnums_mips) / sizeof(g_gp_regnums_mips[0])) - 1 == - k_num_gpr_registers_mips, - "g_gp_regnums_mips has wrong number of register infos"); - -// mips floating point registers. -const uint32_t g_fp_regnums_mips[] = { - fpr_f0_mips, fpr_f1_mips, fpr_f2_mips, fpr_f3_mips, - fpr_f4_mips, fpr_f5_mips, fpr_f6_mips, fpr_f7_mips, - fpr_f8_mips, fpr_f9_mips, fpr_f10_mips, fpr_f11_mips, - fpr_f12_mips, fpr_f13_mips, fpr_f14_mips, fpr_f15_mips, - fpr_f16_mips, fpr_f17_mips, fpr_f18_mips, fpr_f19_mips, - fpr_f20_mips, fpr_f21_mips, fpr_f22_mips, fpr_f23_mips, - fpr_f24_mips, fpr_f25_mips, fpr_f26_mips, fpr_f27_mips, - fpr_f28_mips, fpr_f29_mips, fpr_f30_mips, fpr_f31_mips, - fpr_fcsr_mips, fpr_fir_mips, fpr_config5_mips, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; - -static_assert((sizeof(g_fp_regnums_mips) / sizeof(g_fp_regnums_mips[0])) - 1 == - k_num_fpr_registers_mips, - "g_fp_regnums_mips has wrong number of register infos"); - -// mips MSA registers. -const uint32_t g_msa_regnums_mips[] = { - msa_w0_mips, msa_w1_mips, msa_w2_mips, msa_w3_mips, - msa_w4_mips, msa_w5_mips, msa_w6_mips, msa_w7_mips, - msa_w8_mips, msa_w9_mips, msa_w10_mips, msa_w11_mips, - msa_w12_mips, msa_w13_mips, msa_w14_mips, msa_w15_mips, - msa_w16_mips, msa_w17_mips, msa_w18_mips, msa_w19_mips, - msa_w20_mips, msa_w21_mips, msa_w22_mips, msa_w23_mips, - msa_w24_mips, msa_w25_mips, msa_w26_mips, msa_w27_mips, - msa_w28_mips, msa_w29_mips, msa_w30_mips, msa_w31_mips, - msa_fcsr_mips, msa_fir_mips, msa_mcsr_mips, msa_mir_mips, - msa_config5_mips, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; - -static_assert((sizeof(g_msa_regnums_mips) / sizeof(g_msa_regnums_mips[0])) - - 1 == - k_num_msa_registers_mips, - "g_msa_regnums_mips has wrong number of register infos"); - -// mips64 general purpose registers. -const uint32_t g_gp_regnums_mips64[] = { - gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64, - gpr_r3_mips64, gpr_r4_mips64, gpr_r5_mips64, - gpr_r6_mips64, gpr_r7_mips64, gpr_r8_mips64, - gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64, - gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64, - gpr_r15_mips64, gpr_r16_mips64, gpr_r17_mips64, - gpr_r18_mips64, gpr_r19_mips64, gpr_r20_mips64, - gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64, - gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64, - gpr_r27_mips64, gpr_gp_mips64, gpr_sp_mips64, - gpr_r30_mips64, gpr_ra_mips64, gpr_sr_mips64, - gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64, - gpr_cause_mips64, gpr_pc_mips64, gpr_config5_mips64, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; - -static_assert((sizeof(g_gp_regnums_mips64) / sizeof(g_gp_regnums_mips64[0])) - - 1 == - k_num_gpr_registers_mips64, - "g_gp_regnums_mips64 has wrong number of register infos"); - -// mips64 floating point registers. -const uint32_t g_fp_regnums_mips64[] = { - fpr_f0_mips64, fpr_f1_mips64, fpr_f2_mips64, fpr_f3_mips64, - fpr_f4_mips64, fpr_f5_mips64, fpr_f6_mips64, fpr_f7_mips64, - fpr_f8_mips64, fpr_f9_mips64, fpr_f10_mips64, fpr_f11_mips64, - fpr_f12_mips64, fpr_f13_mips64, fpr_f14_mips64, fpr_f15_mips64, - fpr_f16_mips64, fpr_f17_mips64, fpr_f18_mips64, fpr_f19_mips64, - fpr_f20_mips64, fpr_f21_mips64, fpr_f22_mips64, fpr_f23_mips64, - fpr_f24_mips64, fpr_f25_mips64, fpr_f26_mips64, fpr_f27_mips64, - fpr_f28_mips64, fpr_f29_mips64, fpr_f30_mips64, fpr_f31_mips64, - fpr_fcsr_mips64, fpr_fir_mips64, fpr_config5_mips64, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; - -static_assert((sizeof(g_fp_regnums_mips64) / sizeof(g_fp_regnums_mips64[0])) - - 1 == - k_num_fpr_registers_mips64, - "g_fp_regnums_mips64 has wrong number of register infos"); - -// mips64 MSA registers. -const uint32_t g_msa_regnums_mips64[] = { - msa_w0_mips64, msa_w1_mips64, msa_w2_mips64, msa_w3_mips64, - msa_w4_mips64, msa_w5_mips64, msa_w6_mips64, msa_w7_mips64, - msa_w8_mips64, msa_w9_mips64, msa_w10_mips64, msa_w11_mips64, - msa_w12_mips64, msa_w13_mips64, msa_w14_mips64, msa_w15_mips64, - msa_w16_mips64, msa_w17_mips64, msa_w18_mips64, msa_w19_mips64, - msa_w20_mips64, msa_w21_mips64, msa_w22_mips64, msa_w23_mips64, - msa_w24_mips64, msa_w25_mips64, msa_w26_mips64, msa_w27_mips64, - msa_w28_mips64, msa_w29_mips64, msa_w30_mips64, msa_w31_mips64, - msa_fcsr_mips64, msa_fir_mips64, msa_mcsr_mips64, msa_mir_mips64, - msa_config5_mips64, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; - -static_assert((sizeof(g_msa_regnums_mips64) / sizeof(g_msa_regnums_mips64[0])) - - 1 == - k_num_msa_registers_mips64, - "g_msa_regnums_mips64 has wrong number of register infos"); - -// Number of register sets provided by this context. -enum { k_num_register_sets = 3 }; - -// Register sets for mips. -static const RegisterSet g_reg_sets_mips[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_mips, - g_gp_regnums_mips}, - {"Floating Point Registers", "fpu", k_num_fpr_registers_mips, - g_fp_regnums_mips}, - {"MSA Registers", "msa", k_num_msa_registers_mips, g_msa_regnums_mips}}; - -// Register sets for mips64. -static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64, - g_gp_regnums_mips64}, - {"Floating Point Registers", "fpu", k_num_fpr_registers_mips64, - g_fp_regnums_mips64}, - {"MSA Registers", "msa", k_num_msa_registers_mips64, g_msa_regnums_mips64}, -}; - -} // end of anonymous namespace - NativeRegisterContextLinux * NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux( const ArchSpec &target_arch, NativeThreadProtocol &native_thread, @@ -244,15 +98,12 @@ NativeRegisterContextLinux::CreateHostNa static RegisterInfoInterface * CreateRegisterInfoInterface(const ArchSpec &target_arch) { - if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) { + if ((target_arch.GetMachine() == llvm::Triple::mips) || + (target_arch.GetMachine() == llvm::Triple::mipsel)) { // 32-bit hosts run with a RegisterContextLinux_mips context. return new RegisterContextLinux_mips( target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable()); } else { - assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) && - "Register setting path assumes this is a 64-bit host"); - // mips64 hosts know how to work with 64-bit and 32-bit EXEs using the - // mips64 register context. return new RegisterContextLinux_mips64( target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable()); } @@ -307,7 +158,22 @@ NativeRegisterContextLinux_mips64::Nativ } uint32_t NativeRegisterContextLinux_mips64::GetRegisterSetCount() const { - return k_num_register_sets; + switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) { + case llvm::Triple::mips64: + case llvm::Triple::mips64el: { + const auto context = static_cast + (GetRegisterInfoInterface()); + return context.GetRegisterSetCount(); + } + case llvm::Triple::mips: + case llvm::Triple::mipsel: { + const auto context = static_cast + (GetRegisterInfoInterface()); + return context.GetRegisterSetCount(); + } + default: + llvm_unreachable("Unhandled target architecture."); + } } lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation( @@ -357,16 +223,22 @@ lldb::addr_t NativeRegisterContextLinux_ const RegisterSet * NativeRegisterContextLinux_mips64::GetRegisterSet(uint32_t set_index) const { - if (set_index >= k_num_register_sets) + if (set_index >= GetRegisterSetCount()) return nullptr; switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) { case llvm::Triple::mips64: - case llvm::Triple::mips64el: - return &g_reg_sets_mips64[set_index]; + case llvm::Triple::mips64el: { + const auto context = static_cast + (GetRegisterInfoInterface()); + return context.GetRegisterSet(set_index); + } case llvm::Triple::mips: - case llvm::Triple::mipsel: - return &g_reg_sets_mips[set_index]; + case llvm::Triple::mipsel: { + const auto context = static_cast + (GetRegisterInfoInterface()); + return context.GetRegisterSet(set_index); + } default: llvm_unreachable("Unhandled target architecture."); } Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp Fri Mar 31 06:14:02 2017 @@ -9,11 +9,33 @@ #include "RegisterContextFreeBSD_mips64.h" #include "RegisterContextPOSIX_mips64.h" +#include "lldb-mips-freebsd-register-enums.h" #include using namespace lldb_private; using namespace lldb; +static const uint32_t g_gpr_regnums[] = { + gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64, gpr_r3_mips64, + gpr_r4_mips64, gpr_r5_mips64, gpr_r6_mips64, gpr_r7_mips64, + gpr_r8_mips64, gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64, + gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64, gpr_r15_mips64, + gpr_r16_mips64, gpr_r17_mips64, gpr_r18_mips64, gpr_r19_mips64, + gpr_r20_mips64, gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64, + gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64, gpr_r27_mips64, + gpr_gp_mips64, gpr_sp_mips64, gpr_r30_mips64, gpr_ra_mips64, + gpr_sr_mips64, gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64, + gpr_cause_mips64, gpr_pc_mips64, gpr_ic_mips64, gpr_dummy_mips64}; + +// Number of register sets provided by this context. +constexpr size_t k_num_register_sets = 1; + +static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = { + {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64, + g_gpr_regnums}, +}; + + // http://svnweb.freebsd.org/base/head/sys/mips/include/regnum.h typedef struct _GPR { uint64_t zero; @@ -74,6 +96,19 @@ size_t RegisterContextFreeBSD_mips64::Ge return sizeof(GPR_freebsd_mips); } +const RegisterSet * +RegisterContextFreeBSD_mips64::GetRegisterSet(size_t set) const { + // Check if RegisterSet is available + if (set < k_num_register_sets) + return &g_reg_sets_mips64[set]; + return nullptr; +} + +size_t +RegisterContextFreeBSD_mips64::GetRegisterSetCount() const { + return k_num_register_sets; +} + const RegisterInfo *RegisterContextFreeBSD_mips64::GetRegisterInfo() const { assert(m_target_arch.GetCore() == ArchSpec::eCore_mips64); return g_register_infos_mips64; Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h Fri Mar 31 06:14:02 2017 @@ -19,6 +19,10 @@ public: size_t GetGPRSize() const override; + const lldb_private::RegisterSet *GetRegisterSet(size_t set) const; + + size_t GetRegisterSetCount() const; + const lldb_private::RegisterInfo *GetRegisterInfo() const override; uint32_t GetRegisterCount() const override; Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp Fri Mar 31 06:14:02 2017 @@ -29,6 +29,73 @@ using namespace lldb; #include "RegisterInfos_mips.h" #undef DECLARE_REGISTER_INFOS_MIPS_STRUCT +// mips general purpose registers. +const uint32_t g_gp_regnums_mips[] = { + gpr_zero_mips, gpr_r1_mips, gpr_r2_mips, gpr_r3_mips, + gpr_r4_mips, gpr_r5_mips, gpr_r6_mips, gpr_r7_mips, + gpr_r8_mips, gpr_r9_mips, gpr_r10_mips, gpr_r11_mips, + gpr_r12_mips, gpr_r13_mips, gpr_r14_mips, gpr_r15_mips, + gpr_r16_mips, gpr_r17_mips, gpr_r18_mips, gpr_r19_mips, + gpr_r20_mips, gpr_r21_mips, gpr_r22_mips, gpr_r23_mips, + gpr_r24_mips, gpr_r25_mips, gpr_r26_mips, gpr_r27_mips, + gpr_gp_mips, gpr_sp_mips, gpr_r30_mips, gpr_ra_mips, + gpr_sr_mips, gpr_mullo_mips, gpr_mulhi_mips, gpr_badvaddr_mips, + gpr_cause_mips, gpr_pc_mips, gpr_config5_mips, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +static_assert((sizeof(g_gp_regnums_mips) / sizeof(g_gp_regnums_mips[0])) - 1 == + k_num_gpr_registers_mips, + "g_gp_regnums_mips has wrong number of register infos"); +// mips floating point registers. +const uint32_t g_fp_regnums_mips[] = { + fpr_f0_mips, fpr_f1_mips, fpr_f2_mips, fpr_f3_mips, + fpr_f4_mips, fpr_f5_mips, fpr_f6_mips, fpr_f7_mips, + fpr_f8_mips, fpr_f9_mips, fpr_f10_mips, fpr_f11_mips, + fpr_f12_mips, fpr_f13_mips, fpr_f14_mips, fpr_f15_mips, + fpr_f16_mips, fpr_f17_mips, fpr_f18_mips, fpr_f19_mips, + fpr_f20_mips, fpr_f21_mips, fpr_f22_mips, fpr_f23_mips, + fpr_f24_mips, fpr_f25_mips, fpr_f26_mips, fpr_f27_mips, + fpr_f28_mips, fpr_f29_mips, fpr_f30_mips, fpr_f31_mips, + fpr_fcsr_mips, fpr_fir_mips, fpr_config5_mips, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +static_assert((sizeof(g_fp_regnums_mips) / sizeof(g_fp_regnums_mips[0])) - 1 == + k_num_fpr_registers_mips, + "g_fp_regnums_mips has wrong number of register infos"); + +// mips MSA registers. +const uint32_t g_msa_regnums_mips[] = { + msa_w0_mips, msa_w1_mips, msa_w2_mips, msa_w3_mips, + msa_w4_mips, msa_w5_mips, msa_w6_mips, msa_w7_mips, + msa_w8_mips, msa_w9_mips, msa_w10_mips, msa_w11_mips, + msa_w12_mips, msa_w13_mips, msa_w14_mips, msa_w15_mips, + msa_w16_mips, msa_w17_mips, msa_w18_mips, msa_w19_mips, + msa_w20_mips, msa_w21_mips, msa_w22_mips, msa_w23_mips, + msa_w24_mips, msa_w25_mips, msa_w26_mips, msa_w27_mips, + msa_w28_mips, msa_w29_mips, msa_w30_mips, msa_w31_mips, + msa_fcsr_mips, msa_fir_mips, msa_mcsr_mips, msa_mir_mips, + msa_config5_mips, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +static_assert((sizeof(g_msa_regnums_mips) / sizeof(g_msa_regnums_mips[0])) - + 1 == + k_num_msa_registers_mips, + "g_msa_regnums_mips has wrong number of register infos"); + +// Number of register sets provided by this context. +constexpr size_t k_num_register_sets = 3; + +// Register sets for mips. +static const RegisterSet g_reg_sets_mips[k_num_register_sets] = { + {"General Purpose Registers", "gpr", k_num_gpr_registers_mips, + g_gp_regnums_mips}, + {"Floating Point Registers", "fpu", k_num_fpr_registers_mips, + g_fp_regnums_mips}, + {"MSA Registers", "msa", k_num_msa_registers_mips, g_msa_regnums_mips}}; + uint32_t GetUserRegisterInfoCount(bool msa_present) { if (msa_present) return static_cast(k_num_user_registers_mips); @@ -56,6 +123,25 @@ const RegisterInfo *RegisterContextLinux } } +const RegisterSet * +RegisterContextLinux_mips::GetRegisterSet(size_t set) const { + if (set >= k_num_register_sets) + return nullptr; + switch (m_target_arch.GetMachine()) { + case llvm::Triple::mips: + case llvm::Triple::mipsel: + return &g_reg_sets_mips[set]; + default: + assert(false && "Unhandled target architecture."); + return nullptr; + } +} + +size_t +RegisterContextLinux_mips::GetRegisterSetCount() const { + return k_num_register_sets; +} + uint32_t RegisterContextLinux_mips::GetRegisterCount() const { return static_cast(sizeof(g_register_infos_mips) / sizeof(g_register_infos_mips[0])); Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h Fri Mar 31 06:14:02 2017 @@ -22,6 +22,10 @@ public: const lldb_private::RegisterInfo *GetRegisterInfo() const override; + const lldb_private::RegisterSet *GetRegisterSet(size_t set) const; + + size_t GetRegisterSetCount() const; + uint32_t GetRegisterCount() const override; uint32_t GetUserRegisterCount() const override; Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp Fri Mar 31 06:14:02 2017 @@ -7,7 +7,6 @@ // //===---------------------------------------------------------------------===// -#if defined(__mips__) #include #include @@ -41,6 +40,101 @@ using namespace lldb_private; #include "RegisterInfos_mips.h" #undef DECLARE_REGISTER_INFOS_MIPS_STRUCT +// mips64 general purpose registers. +const uint32_t g_gp_regnums_mips64[] = { + gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64, + gpr_r3_mips64, gpr_r4_mips64, gpr_r5_mips64, + gpr_r6_mips64, gpr_r7_mips64, gpr_r8_mips64, + gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64, + gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64, + gpr_r15_mips64, gpr_r16_mips64, gpr_r17_mips64, + gpr_r18_mips64, gpr_r19_mips64, gpr_r20_mips64, + gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64, + gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64, + gpr_r27_mips64, gpr_gp_mips64, gpr_sp_mips64, + gpr_r30_mips64, gpr_ra_mips64, gpr_sr_mips64, + gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64, + gpr_cause_mips64, gpr_pc_mips64, gpr_config5_mips64, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +static_assert((sizeof(g_gp_regnums_mips64) / sizeof(g_gp_regnums_mips64[0])) - + 1 == + k_num_gpr_registers_mips64, + "g_gp_regnums_mips64 has wrong number of register infos"); + +// mips64 floating point registers. +const uint32_t g_fp_regnums_mips64[] = { + fpr_f0_mips64, fpr_f1_mips64, fpr_f2_mips64, fpr_f3_mips64, + fpr_f4_mips64, fpr_f5_mips64, fpr_f6_mips64, fpr_f7_mips64, + fpr_f8_mips64, fpr_f9_mips64, fpr_f10_mips64, fpr_f11_mips64, + fpr_f12_mips64, fpr_f13_mips64, fpr_f14_mips64, fpr_f15_mips64, + fpr_f16_mips64, fpr_f17_mips64, fpr_f18_mips64, fpr_f19_mips64, + fpr_f20_mips64, fpr_f21_mips64, fpr_f22_mips64, fpr_f23_mips64, + fpr_f24_mips64, fpr_f25_mips64, fpr_f26_mips64, fpr_f27_mips64, + fpr_f28_mips64, fpr_f29_mips64, fpr_f30_mips64, fpr_f31_mips64, + fpr_fcsr_mips64, fpr_fir_mips64, fpr_config5_mips64, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +static_assert((sizeof(g_fp_regnums_mips64) / sizeof(g_fp_regnums_mips64[0])) - + 1 == + k_num_fpr_registers_mips64, + "g_fp_regnums_mips64 has wrong number of register infos"); + +// mips64 MSA registers. +const uint32_t g_msa_regnums_mips64[] = { + msa_w0_mips64, msa_w1_mips64, msa_w2_mips64, msa_w3_mips64, + msa_w4_mips64, msa_w5_mips64, msa_w6_mips64, msa_w7_mips64, + msa_w8_mips64, msa_w9_mips64, msa_w10_mips64, msa_w11_mips64, + msa_w12_mips64, msa_w13_mips64, msa_w14_mips64, msa_w15_mips64, + msa_w16_mips64, msa_w17_mips64, msa_w18_mips64, msa_w19_mips64, + msa_w20_mips64, msa_w21_mips64, msa_w22_mips64, msa_w23_mips64, + msa_w24_mips64, msa_w25_mips64, msa_w26_mips64, msa_w27_mips64, + msa_w28_mips64, msa_w29_mips64, msa_w30_mips64, msa_w31_mips64, + msa_fcsr_mips64, msa_fir_mips64, msa_mcsr_mips64, msa_mir_mips64, + msa_config5_mips64, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +static_assert((sizeof(g_msa_regnums_mips64) / sizeof(g_msa_regnums_mips64[0])) - + 1 == + k_num_msa_registers_mips64, + "g_msa_regnums_mips64 has wrong number of register infos"); + +// Number of register sets provided by this context. +constexpr size_t k_num_register_sets = 3; + +// Register sets for mips64. +static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = { + {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64, + g_gp_regnums_mips64}, + {"Floating Point Registers", "fpu", k_num_fpr_registers_mips64, + g_fp_regnums_mips64}, + {"MSA Registers", "msa", k_num_msa_registers_mips64, g_msa_regnums_mips64}, +}; + +const RegisterSet * +RegisterContextLinux_mips64::GetRegisterSet(size_t set) const { + if (set >= k_num_register_sets) + return nullptr; + + switch (m_target_arch.GetMachine()) { + case llvm::Triple::mips64: + case llvm::Triple::mips64el: + return &g_reg_sets_mips64[set]; + default: + assert(false && "Unhandled target architecture."); + return nullptr; + } + return nullptr; +} + +size_t +RegisterContextLinux_mips64::GetRegisterSetCount() const { + return k_num_register_sets; +} + static const RegisterInfo *GetRegisterInfoPtr(const ArchSpec &target_arch) { switch (target_arch.GetMachine()) { case llvm::Triple::mips64: @@ -116,4 +210,3 @@ uint32_t RegisterContextLinux_mips64::Ge return m_user_register_count; } -#endif Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h Fri Mar 31 06:14:02 2017 @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#if defined(__mips__) - #ifndef liblldb_RegisterContextLinux_mips64_H_ #define liblldb_RegisterContextLinux_mips64_H_ @@ -24,6 +22,10 @@ public: const lldb_private::RegisterInfo *GetRegisterInfo() const override; + const lldb_private::RegisterSet *GetRegisterSet(size_t set) const; + + size_t GetRegisterSetCount() const; + uint32_t GetRegisterCount() const override; uint32_t GetUserRegisterCount() const override; @@ -36,4 +38,3 @@ private: #endif -#endif Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp Fri Mar 31 06:14:02 2017 @@ -22,36 +22,22 @@ #include "Plugins/Process/elf-core/ProcessElfCore.h" #include "RegisterContextPOSIX_mips64.h" +#include "RegisterContextFreeBSD_mips64.h" +#include "RegisterContextLinux_mips64.h" +#include "RegisterContextLinux_mips.h" using namespace lldb_private; using namespace lldb; -static const uint32_t g_gpr_regnums[] = { - gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64, gpr_r3_mips64, - gpr_r4_mips64, gpr_r5_mips64, gpr_r6_mips64, gpr_r7_mips64, - gpr_r8_mips64, gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64, - gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64, gpr_r15_mips64, - gpr_r16_mips64, gpr_r17_mips64, gpr_r18_mips64, gpr_r19_mips64, - gpr_r20_mips64, gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64, - gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64, gpr_r27_mips64, - gpr_gp_mips64, gpr_sp_mips64, gpr_r30_mips64, gpr_ra_mips64, - gpr_sr_mips64, gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64, - gpr_cause_mips64, gpr_pc_mips64, gpr_ic_mips64, gpr_dummy_mips64}; - -// Number of register sets provided by this context. -enum { k_num_register_sets = 1 }; - -static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64, - g_gpr_regnums}, -}; - bool RegisterContextPOSIX_mips64::IsGPR(unsigned reg) { - return reg <= k_num_gpr_registers_mips64; // GPR's come first. + return reg < m_registers_count[gpr_registers_count]; // GPR's come first. } bool RegisterContextPOSIX_mips64::IsFPR(unsigned reg) { - // XXX + int set = GetRegisterSetCount(); + if (set > 1) + return reg < (m_registers_count[fpr_registers_count] + + m_registers_count[gpr_registers_count]); return false; } @@ -60,6 +46,18 @@ RegisterContextPOSIX_mips64::RegisterCon RegisterInfoInterface *register_info) : RegisterContext(thread, concrete_frame_idx) { m_register_info_ap.reset(register_info); + m_num_registers = GetRegisterCount(); + int set = GetRegisterSetCount(); + + const RegisterSet *reg_set_ptr; + for(int i = 0; i < set; ++i) { + reg_set_ptr = GetRegisterSet(i); + m_registers_count[i] = reg_set_ptr->num_registers; + } + + assert(m_num_registers == m_registers_count[gpr_registers_count] + + m_registers_count[fpr_registers_count] + + m_registers_count[msa_registers_count]); // elf-core yet to support ReadFPR() ProcessSP base = CalculateProcess(); @@ -74,18 +72,17 @@ void RegisterContextPOSIX_mips64::Invali void RegisterContextPOSIX_mips64::InvalidateAllRegisters() {} unsigned RegisterContextPOSIX_mips64::GetRegisterOffset(unsigned reg) { - assert(reg < k_num_registers_mips64 && "Invalid register number."); + assert(reg < m_num_registers && "Invalid register number."); return GetRegisterInfo()[reg].byte_offset; } unsigned RegisterContextPOSIX_mips64::GetRegisterSize(unsigned reg) { - assert(reg < k_num_registers_mips64 && "Invalid register number."); + assert(reg < m_num_registers && "Invalid register number."); return GetRegisterInfo()[reg].byte_size; } size_t RegisterContextPOSIX_mips64::GetRegisterCount() { - size_t num_registers = k_num_registers_mips64; - return num_registers; + return m_register_info_ap->GetRegisterCount(); } size_t RegisterContextPOSIX_mips64::GetGPRSize() { @@ -101,31 +98,59 @@ const RegisterInfo *RegisterContextPOSIX const RegisterInfo * RegisterContextPOSIX_mips64::GetRegisterInfoAtIndex(size_t reg) { - if (reg < k_num_registers_mips64) + if (reg < m_num_registers) return &GetRegisterInfo()[reg]; else return NULL; } size_t RegisterContextPOSIX_mips64::GetRegisterSetCount() { - size_t sets = 0; - for (size_t set = 0; set < k_num_register_sets; ++set) { - if (IsRegisterSetAvailable(set)) - ++sets; + ArchSpec target_arch = m_register_info_ap->GetTargetArchitecture(); + switch (target_arch.GetTriple().getOS()) { + case llvm::Triple::Linux: { + if ((target_arch.GetMachine() == llvm::Triple::mipsel) || + (target_arch.GetMachine() == llvm::Triple::mips)) { + const auto *context = static_cast + (m_register_info_ap.get()); + return context->GetRegisterSetCount(); + } + const auto *context = static_cast + (m_register_info_ap.get()); + return context->GetRegisterSetCount(); + } + default: { + const auto *context = static_cast + (m_register_info_ap.get()); + return context->GetRegisterSetCount(); + } + } - - return sets; } const RegisterSet *RegisterContextPOSIX_mips64::GetRegisterSet(size_t set) { - if (IsRegisterSetAvailable(set)) - return &g_reg_sets_mips64[set]; - else - return NULL; + ArchSpec target_arch = m_register_info_ap->GetTargetArchitecture(); + switch (target_arch.GetTriple().getOS()) { + case llvm::Triple::Linux: { + if ((target_arch.GetMachine() == llvm::Triple::mipsel) || + (target_arch.GetMachine() == llvm::Triple::mips)) { + const auto *context = static_cast + (m_register_info_ap.get()); + return context->GetRegisterSet(set); + } + const auto *context = static_cast + (m_register_info_ap.get()); + return context->GetRegisterSet(set); + } + default: { + const auto *context = static_cast + (m_register_info_ap.get()); + return context->GetRegisterSet(set); + } + } } const char *RegisterContextPOSIX_mips64::GetRegisterName(unsigned reg) { - assert(reg < k_num_registers_mips64 && "Invalid register offset."); + assert(reg < m_num_registers && "Invalid register offset."); return GetRegisterInfo()[reg].name; } @@ -141,7 +166,7 @@ lldb::ByteOrder RegisterContextPOSIX_mip } bool RegisterContextPOSIX_mips64::IsRegisterSetAvailable(size_t set_index) { - size_t num_sets = k_num_register_sets; + size_t num_sets = GetRegisterSetCount(); return (set_index < num_sets); } @@ -150,7 +175,7 @@ bool RegisterContextPOSIX_mips64::IsRegi // object file sections that contain register numbers in them. uint32_t RegisterContextPOSIX_mips64::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { - const uint32_t num_regs = GetRegisterCount(); + const uint32_t num_regs = m_num_registers; assert(kind < kNumRegisterKinds); for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h Fri Mar 31 06:14:02 2017 @@ -16,7 +16,6 @@ // Project includes #include "RegisterContext_mips.h" #include "RegisterInfoInterface.h" -#include "lldb-mips-freebsd-register-enums.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/Log.h" @@ -26,6 +25,14 @@ class ProcessMonitor; class RegisterContextPOSIX_mips64 : public lldb_private::RegisterContext { public: + + enum Register_count{ + gpr_registers_count = 0, + fpr_registers_count, + msa_registers_count, + register_set_count + }; + RegisterContextPOSIX_mips64( lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info); @@ -56,8 +63,8 @@ public: uint32_t num) override; protected: - uint64_t - m_gpr_mips64[k_num_gpr_registers_mips64]; // general purpose registers. + uint32_t m_num_registers; + uint8_t m_registers_count[register_set_count]; std::unique_ptr m_register_info_ap; // Register Info Interface (FreeBSD or Linux) Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp (original) +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp Fri Mar 31 06:14:02 2017 @@ -22,6 +22,10 @@ RegisterContextCorePOSIX_mips64::Registe new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize())); m_gpr.SetData(m_gpr_buffer); m_gpr.SetByteOrder(gpregset.GetByteOrder()); + m_fpr_buffer.reset( + new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize())); + m_fpr.SetData(m_fpr_buffer); + m_fpr.SetByteOrder(fpregset.GetByteOrder()); } RegisterContextCorePOSIX_mips64::~RegisterContextCorePOSIX_mips64() {} @@ -42,12 +46,24 @@ bool RegisterContextCorePOSIX_mips64::Wr bool RegisterContextCorePOSIX_mips64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) { + lldb::offset_t offset = reg_info->byte_offset; - uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size); - if (offset == reg_info->byte_offset + reg_info->byte_size) { + lldb_private::ArchSpec arch = m_register_info_ap->GetTargetArchitecture(); + uint64_t v; + if (IsGPR(reg_info->kinds[lldb::eRegisterKindLLDB])) { + if (reg_info->byte_size == 4 && !(arch.GetMachine() == llvm::Triple::mips64el)) + // In case of 32bit core file, the register data are placed at 4 byte + // offset. + offset = offset / 2; + v = m_gpr.GetMaxU64(&offset, reg_info->byte_size); value = v; return true; - } + } else if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) { + offset = offset - sizeof(GPR_linux_mips); + v =m_fpr.GetMaxU64(&offset, reg_info->byte_size); + value = v; + return true; + } return false; } Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h (original) +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h Fri Mar 31 06:14:02 2017 @@ -51,7 +51,9 @@ protected: private: lldb::DataBufferSP m_gpr_buffer; + lldb::DataBufferSP m_fpr_buffer; lldb_private::DataExtractor m_gpr; + lldb_private::DataExtractor m_fpr; }; #endif // liblldb_RegisterContextCorePOSIX_mips64_h_ Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp (original) +++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Fri Mar 31 06:14:02 2017 @@ -18,6 +18,8 @@ #include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h" +#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h" +#include "Plugins/Process/Utility/RegisterContextLinux_mips.h" #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" @@ -132,6 +134,14 @@ ThreadElfCore::CreateRegisterContextForF case llvm::Triple::aarch64: reg_interface = new RegisterInfoPOSIX_arm64(arch); break; + case llvm::Triple::mipsel: + case llvm::Triple::mips: + reg_interface = new RegisterContextLinux_mips(arch); + break; + case llvm::Triple::mips64el: + case llvm::Triple::mips64: + reg_interface = new RegisterContextLinux_mips64(arch); + break; case llvm::Triple::systemz: reg_interface = new RegisterContextLinux_s390x(arch); break; @@ -187,7 +197,13 @@ ThreadElfCore::CreateRegisterContextForF m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm( *this, reg_interface, m_gpregset_data, m_fpregset_data)); break; + case llvm::Triple::mipsel: + case llvm::Triple::mips: + m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64( + *this, reg_interface, m_gpregset_data, m_fpregset_data)); + break; case llvm::Triple::mips64: + case llvm::Triple::mips64el: m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64( *this, reg_interface, m_gpregset_data, m_fpregset_data)); break; @@ -233,6 +249,31 @@ ELFLinuxPrStatus::ELFLinuxPrStatus() { memset(this, 0, sizeof(ELFLinuxPrStatus)); } +size_t ELFLinuxPrStatus::GetSize(lldb_private::ArchSpec &arch) { + constexpr size_t mips_linux_pr_status_size_o32 = 96; + constexpr size_t mips_linux_pr_status_size_n32 = 72; + if (arch.IsMIPS()) { + std::string abi = arch.GetTargetABI(); + assert(!abi.empty() && "ABI is not set"); + if (!abi.compare("n64")) + return sizeof(ELFLinuxPrStatus); + else if (!abi.compare("o32")) + return mips_linux_pr_status_size_o32; + // N32 ABI + return mips_linux_pr_status_size_n32; + } + switch (arch.GetCore()) { + case lldb_private::ArchSpec::eCore_s390x_generic: + case lldb_private::ArchSpec::eCore_x86_64_x86_64: + return sizeof(ELFLinuxPrStatus); + case lldb_private::ArchSpec::eCore_x86_32_i386: + case lldb_private::ArchSpec::eCore_x86_32_i486: + return 72; + default: + return 0; + } +} + Error ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch) { Error error; if (GetSize(arch) > data.GetByteSize()) { @@ -282,6 +323,27 @@ ELFLinuxPrPsInfo::ELFLinuxPrPsInfo() { memset(this, 0, sizeof(ELFLinuxPrPsInfo)); } +size_t ELFLinuxPrPsInfo::GetSize(lldb_private::ArchSpec &arch) { + constexpr size_t mips_linux_pr_psinfo_size_o32_n32 = 128; + if (arch.IsMIPS()) { + uint8_t address_byte_size = arch.GetAddressByteSize(); + if (address_byte_size == 8) + return sizeof(ELFLinuxPrPsInfo); + return mips_linux_pr_psinfo_size_o32_n32; + } + + switch (arch.GetCore()) { + case lldb_private::ArchSpec::eCore_s390x_generic: + case lldb_private::ArchSpec::eCore_x86_64_x86_64: + return sizeof(ELFLinuxPrPsInfo); + case lldb_private::ArchSpec::eCore_x86_32_i386: + case lldb_private::ArchSpec::eCore_x86_32_i486: + return 124; + default: + return 0; + } +} + Error ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch) { Error error; ByteOrder byteorder = data.GetByteOrder(); @@ -305,9 +367,15 @@ Error ELFLinuxPrPsInfo::Parse(DataExtrac pr_flag = data.GetPointer(&offset); + if (arch.IsMIPS()) { + // The pr_uid and pr_gid is always 32 bit irrespective of platforms + pr_uid = data.GetU32(&offset); + pr_gid = data.GetU32(&offset); + } else { // 16 bit on 32 bit platforms, 32 bit on 64 bit platforms pr_uid = data.GetMaxU64(&offset, data.GetAddressByteSize() >> 1); pr_gid = data.GetMaxU64(&offset, data.GetAddressByteSize() >> 1); + } pr_pid = data.GetU32(&offset); pr_ppid = data.GetU32(&offset); @@ -330,6 +398,21 @@ Error ELFLinuxPrPsInfo::Parse(DataExtrac //---------------------------------------------------------------- ELFLinuxSigInfo::ELFLinuxSigInfo() { memset(this, 0, sizeof(ELFLinuxSigInfo)); } +size_t ELFLinuxSigInfo::GetSize(const lldb_private::ArchSpec &arch) { + if (arch.IsMIPS()) + return sizeof(ELFLinuxSigInfo); + switch (arch.GetCore()) { + case lldb_private::ArchSpec::eCore_x86_64_x86_64: + return sizeof(ELFLinuxSigInfo); + case lldb_private::ArchSpec::eCore_s390x_generic: + case lldb_private::ArchSpec::eCore_x86_32_i386: + case lldb_private::ArchSpec::eCore_x86_32_i486: + return 12; + default: + return 0; + } +} + Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) { Error error; if (GetSize(arch) > data.GetByteSize()) { Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h?rev=299200&r1=299199&r2=299200&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h (original) +++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h Fri Mar 31 06:14:02 2017 @@ -65,18 +65,7 @@ struct ELFLinuxPrStatus { // 32 bit - hardcoded because we are reusing the struct, but some of the // members are smaller - // so the layout is not the same - static size_t GetSize(lldb_private::ArchSpec &arch) { - switch (arch.GetCore()) { - case lldb_private::ArchSpec::eCore_s390x_generic: - case lldb_private::ArchSpec::eCore_x86_64_x86_64: - return sizeof(ELFLinuxPrStatus); - case lldb_private::ArchSpec::eCore_x86_32_i386: - case lldb_private::ArchSpec::eCore_x86_32_i486: - return 72; - default: - return 0; - } - } + static size_t GetSize(lldb_private::ArchSpec &arch); }; static_assert(sizeof(ELFLinuxPrStatus) == 112, @@ -97,18 +86,7 @@ struct ELFLinuxSigInfo { // 32 bit - hardcoded because we are reusing the struct, but some of the // members are smaller - // so the layout is not the same - static size_t GetSize(const lldb_private::ArchSpec &arch) { - switch (arch.GetCore()) { - case lldb_private::ArchSpec::eCore_x86_64_x86_64: - return sizeof(ELFLinuxSigInfo); - case lldb_private::ArchSpec::eCore_s390x_generic: - case lldb_private::ArchSpec::eCore_x86_32_i386: - case lldb_private::ArchSpec::eCore_x86_32_i486: - return 12; - default: - return 0; - } - } + static size_t GetSize(const lldb_private::ArchSpec &arch); }; static_assert(sizeof(ELFLinuxSigInfo) == 12, @@ -143,18 +121,7 @@ struct ELFLinuxPrPsInfo { // 32 bit - hardcoded because we are reusing the struct, but some of the // members are smaller - // so the layout is not the same - static size_t GetSize(lldb_private::ArchSpec &arch) { - switch (arch.GetCore()) { - case lldb_private::ArchSpec::eCore_s390x_generic: - case lldb_private::ArchSpec::eCore_x86_64_x86_64: - return sizeof(ELFLinuxPrPsInfo); - case lldb_private::ArchSpec::eCore_x86_32_i386: - case lldb_private::ArchSpec::eCore_x86_32_i486: - return 124; - default: - return 0; - } - } + static size_t GetSize(lldb_private::ArchSpec &arch); }; static_assert(sizeof(ELFLinuxPrPsInfo) == 136, From lldb-commits at lists.llvm.org Fri Mar 31 04:26:36 2017 From: lldb-commits at lists.llvm.org (Nitesh Jain via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 11:26:36 +0000 Subject: [Lldb-commits] [PATCH] D30457: [LLDB][MIPS] Core Dump Support In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rL299200: [LLDB][MIPS] Core Dump Support. (authored by nitesh.jain). Changed prior to commit: https://reviews.llvm.org/D30457?vs=92768&id=93616#toc Repository: rL LLVM https://reviews.llvm.org/D30457 Files: lldb/trunk/source/Core/ArchSpec.cpp lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D30457.93616.patch Type: text/x-patch Size: 44401 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 09:12:11 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 16:12:11 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: labath added a comment. In https://reviews.llvm.org/D31451#714850, @eugene wrote: > I did some micro-benchmarking and on average new parser is ~3 time slower than the old one. (new parser - ~200k string/s, old parser - ~700k string/s) > clang::Lexer appears to be the slowest part of it. > > On the clang breakpoint benchmark you proposed, it is hard to notice much of a difference. clang binary has about 500k functions. > With new parser it takes about 11s to try to set a breakpoint, on the old one it's about 10s. (release version of LLDB, debug static version of clang) > > I decided to use a hybrid approach, when we use old parsing code for simple cases and call new parser only when it fails. > 80% of clang functions are simple enough that we don't really need the new parser, so it helped to bring clang breakpoint test back to 10s. > I think it's reasonable to assume that similar distribution is true for most programs, and most of their functions can be parsed with the old code. > > I don't think we can really improve performance of a new parser without giving up on clang::Lexer, and I'm reluctant to do it. > So I propose to keep hybrid approach and call a new parser only for complicated cases. I like that idea. Let's go with that. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:94 if (!m_parsed && m_full) { - // ConstString mangled; - // m_full.GetMangledCounterpart(mangled); - // printf ("\n parsing = '%s'\n", m_full.GetCString()); - // if (mangled) - // printf (" mangled = '%s'\n", mangled.GetCString()); - m_parse_error = false; - m_parsed = true; - llvm::StringRef full(m_full.GetCString()); - - size_t arg_start, arg_end; - llvm::StringRef parens("()", 2); - if (ReverseFindMatchingChars(full, parens, arg_start, arg_end)) { - m_arguments = full.substr(arg_start, arg_end - arg_start + 1); - if (arg_end + 1 < full.size()) - m_qualifiers = full.substr(arg_end + 1); - if (arg_start > 0) { - size_t basename_end = arg_start; - size_t context_start = 0; - size_t context_end = llvm::StringRef::npos; - if (basename_end > 0 && full[basename_end - 1] == '>') { - // TODO: handle template junk... - // Templated function - size_t template_start, template_end; - llvm::StringRef lt_gt("<>", 2); - if (ReverseFindMatchingChars(full, lt_gt, template_start, - template_end, basename_end)) { - // Check for templated functions that include return type like: - // 'void foo()' - context_start = full.rfind(' ', template_start); - if (context_start == llvm::StringRef::npos) - context_start = 0; - else - ++context_start; - - context_end = full.rfind(':', template_start); - if (context_end == llvm::StringRef::npos || - context_end < context_start) - context_end = context_start; - } else { - context_end = full.rfind(':', basename_end); - } - } else if (context_end == llvm::StringRef::npos) { - context_end = full.rfind(':', basename_end); - } - - if (context_end == llvm::StringRef::npos) - m_basename = full.substr(0, basename_end); - else { - if (context_start < context_end) - m_context = - full.substr(context_start, context_end - 1 - context_start); - const size_t basename_begin = context_end + 1; - m_basename = - full.substr(basename_begin, basename_end - basename_begin); - } - m_type = eTypeUnknownMethod; - } else { - m_parse_error = true; - return; - } - - if (!IsValidBasename(m_basename)) { - // The C++ basename doesn't match our regular expressions so this can't - // be a valid C++ method, clear everything out and indicate an error - m_context = llvm::StringRef(); - m_basename = llvm::StringRef(); - m_arguments = llvm::StringRef(); - m_qualifiers = llvm::StringRef(); - m_parse_error = true; - } + CPlusPlusNameParser parser(m_full.GetStringRef()); + auto function = parser.ParseAsFunctionDefinition(); ---------------- eugene wrote: > labath wrote: > > How about the following api: > > ``` > > if (auto function​ = CPlusPlusNameParser::ParseAsFunctionDefinition(m_full.GetStringRef())) { > > ... > > ``` > If you don't mind I'll leave it as it is. > > I understand that it's very tempting to have two simple functions ParseAsFunctionDefinition and ParseAsFullName instead of a class, but I can imagine calling second one if first one fails, and in this case it'll be good that parser doesn't need to tokenize string all over again. Ok, that makes sense -- I didn't expect that would actually work. I suppose one can always write `CPlusPlusNameParser(foo).ParseAsFunctionDefinition()` when he wants to make it a one-liner and doesn't care about tokenization reuse. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:62 +bool CPlusPlusNameParser::HasMoreTokens() { + return m_next_token_index < static_cast(m_tokens.size()); +} ---------------- eugene wrote: > labath wrote: > > Wouldn't it be better to change the type of m_next_token_index to size_t? > Unsigned types are dangerous. I prefer to avoid them wherever I can. > > As far as I remember many members of C++ standard commit publicly regretted the fact that .size() returns an unsigned type. Well... they are most dangerous when you try to combine them with signed types, which is exactly what you are doing now... :) It's also contrary to how things are done in other parts of the code base and goes against the principle of having as few nonsensical values for your variables as possible. So, I still think this (and all other variables you use for token indexes) should be size_t. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:18 +using namespace lldb_private; +using llvm::Optional; +using llvm::None; ---------------- Are these necessary? You seem to prefix every occurence of Optional and None anyway... ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:257 + if (HasMoreTokens() && Peek().is(tok::raw_identifier) && + Peek().getRawIdentifier() == g_anonymous.GetStringRef()) { + Advance(); ---------------- You don't need to go `ConstString` here. If you wanted to avoid strlen computation, just make this `constexpr StringLiteral`. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h:94 + // when destructed unless it's manually removed with Remove(). + class Bookmark { + public: ---------------- eugene wrote: > labath wrote: > > Please make the type move-only. Otherwise you will have a fun time debugging accidental copies. (You already have one, although it is benign now) > Good catch! Thanks! Please also delete the assignment operator.. Having copy constructor deleted and assignment operator working is confusing, https://reviews.llvm.org/D31451 From lldb-commits at lists.llvm.org Fri Mar 31 09:34:36 2017 From: lldb-commits at lists.llvm.org (Alex Langford via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 16:34:36 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: <3237d4e91e13723fa8146b35fd425ddb@localhost.localdomain> xiaobai marked an inline comment as done. xiaobai added a comment. I'll resubmit after removing the extra code in the test and get somebody to commit for me. ================ Comment at: unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp:373 + + result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); ---------------- labath wrote: > This seems out of place. Should we delete it? Whoops! I was going to extend this test further but I decided not to in the end and forgot to remove this. Thanks for pointing it out. https://reviews.llvm.org/D31485 From lldb-commits at lists.llvm.org Fri Mar 31 09:40:23 2017 From: lldb-commits at lists.llvm.org (Alex Langford via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 16:40:23 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: xiaobai updated this revision to Diff 93674. xiaobai added a comment. Removed extra code in unit test https://reviews.llvm.org/D31485 Files: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Index: unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp =================================================================== --- unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -13,6 +13,7 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StructuredData.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/DataBuffer.h" #include "llvm/ADT/ArrayRef.h" @@ -331,3 +332,41 @@ HandlePacket(server, "QPassSignals:", "OK"); EXPECT_TRUE(result.get().Success()); } + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0xa000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + // name is: /foo/bar.so + HandlePacket(server, + "qMemoryRegionInfo:a000", + "start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;"); + EXPECT_TRUE(result.get().Success()); + +} + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0x4000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;"); + EXPECT_FALSE(result.get().Success()); +} Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1503,13 +1503,18 @@ } } - // We got a valid address range back but no permissions -- which means - // this is an unmapped page - if (region_info.GetRange().IsValid() && saw_permissions == false) { - region_info.SetReadable(MemoryRegionInfo::eNo); - region_info.SetWritable(MemoryRegionInfo::eNo); - region_info.SetExecutable(MemoryRegionInfo::eNo); - region_info.SetMapped(MemoryRegionInfo::eNo); + if (region_info.GetRange().IsValid()) { + // We got a valid address range back but no permissions -- which means + // this is an unmapped page + if (!saw_permissions) { + region_info.SetReadable(MemoryRegionInfo::eNo); + region_info.SetWritable(MemoryRegionInfo::eNo); + region_info.SetExecutable(MemoryRegionInfo::eNo); + region_info.SetMapped(MemoryRegionInfo::eNo); + } + } else { + // We got an invalid address range back + error.SetErrorString("Server returned invalid range"); } } else { m_supports_memory_region_info = eLazyBoolNo; -------------- next part -------------- A non-text attachment was scrubbed... Name: D31485.93674.patch Type: text/x-patch Size: 3166 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 11:00:48 2017 From: lldb-commits at lists.llvm.org (Stephane Sezer via lldb-commits) Date: Fri, 31 Mar 2017 18:00:48 -0000 Subject: [Lldb-commits] [lldb] r299239 - Verify memory address range validity in GDBRemoteCommunicationClient Message-ID: <20170331180049.0229F3128009@llvm.org> Author: sas Date: Fri Mar 31 13:00:48 2017 New Revision: 299239 URL: http://llvm.org/viewvc/llvm-project?rev=299239&view=rev Log: Verify memory address range validity in GDBRemoteCommunicationClient Summary: This aims to verify the validity of the response from the debugging server in GDBRemoteCommunicationClient::GetMemoryRegionInfo. I was working with ds2 (https://github.com/facebook/ds2) and encountered a bug that caused the server's response to have a 'size' value of 0, which caused lldb to behave incorrectly. Reviewers: k8stone, labath, clayborg Reviewed By: labath, clayborg Subscribers: clayborg, sas, lldb-commits Differential Revision: https://reviews.llvm.org/D31485 Change by Alex Langford Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=299239&r1=299238&r2=299239&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Mar 31 13:00:48 2017 @@ -1503,13 +1503,18 @@ Error GDBRemoteCommunicationClient::GetM } } - // We got a valid address range back but no permissions -- which means - // this is an unmapped page - if (region_info.GetRange().IsValid() && saw_permissions == false) { - region_info.SetReadable(MemoryRegionInfo::eNo); - region_info.SetWritable(MemoryRegionInfo::eNo); - region_info.SetExecutable(MemoryRegionInfo::eNo); - region_info.SetMapped(MemoryRegionInfo::eNo); + if (region_info.GetRange().IsValid()) { + // We got a valid address range back but no permissions -- which means + // this is an unmapped page + if (!saw_permissions) { + region_info.SetReadable(MemoryRegionInfo::eNo); + region_info.SetWritable(MemoryRegionInfo::eNo); + region_info.SetExecutable(MemoryRegionInfo::eNo); + region_info.SetMapped(MemoryRegionInfo::eNo); + } + } else { + // We got an invalid address range back + error.SetErrorString("Server returned invalid range"); } } else { m_supports_memory_region_info = eLazyBoolNo; Modified: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp?rev=299239&r1=299238&r2=299239&view=diff ============================================================================== --- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp (original) +++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Fri Mar 31 13:00:48 2017 @@ -13,6 +13,7 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StructuredData.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/DataBuffer.h" #include "llvm/ADT/ArrayRef.h" @@ -331,3 +332,41 @@ TEST_F(GDBRemoteCommunicationClientTest, HandlePacket(server, "QPassSignals:", "OK"); EXPECT_TRUE(result.get().Success()); } + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0xa000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + // name is: /foo/bar.so + HandlePacket(server, + "qMemoryRegionInfo:a000", + "start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;"); + EXPECT_TRUE(result.get().Success()); + +} + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0x4000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;"); + EXPECT_FALSE(result.get().Success()); +} From lldb-commits at lists.llvm.org Fri Mar 31 11:13:20 2017 From: lldb-commits at lists.llvm.org (Stephane Sezer via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 18:13:20 +0000 Subject: [Lldb-commits] [PATCH] D31485: Verify memory address range validity in GDBRemoteCommunicationClient In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rL299239: Verify memory address range validity in GDBRemoteCommunicationClient (authored by sas). Changed prior to commit: https://reviews.llvm.org/D31485?vs=93674&id=93685#toc Repository: rL LLVM https://reviews.llvm.org/D31485 Files: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Index: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp =================================================================== --- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -13,6 +13,7 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StructuredData.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/DataBuffer.h" #include "llvm/ADT/ArrayRef.h" @@ -331,3 +332,41 @@ HandlePacket(server, "QPassSignals:", "OK"); EXPECT_TRUE(result.get().Success()); } + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0xa000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + // name is: /foo/bar.so + HandlePacket(server, + "qMemoryRegionInfo:a000", + "start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;"); + EXPECT_TRUE(result.get().Success()); + +} + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0x4000; + MemoryRegionInfo region_info; + std::future result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;"); + EXPECT_FALSE(result.get().Success()); +} Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1503,13 +1503,18 @@ } } - // We got a valid address range back but no permissions -- which means - // this is an unmapped page - if (region_info.GetRange().IsValid() && saw_permissions == false) { - region_info.SetReadable(MemoryRegionInfo::eNo); - region_info.SetWritable(MemoryRegionInfo::eNo); - region_info.SetExecutable(MemoryRegionInfo::eNo); - region_info.SetMapped(MemoryRegionInfo::eNo); + if (region_info.GetRange().IsValid()) { + // We got a valid address range back but no permissions -- which means + // this is an unmapped page + if (!saw_permissions) { + region_info.SetReadable(MemoryRegionInfo::eNo); + region_info.SetWritable(MemoryRegionInfo::eNo); + region_info.SetExecutable(MemoryRegionInfo::eNo); + region_info.SetMapped(MemoryRegionInfo::eNo); + } + } else { + // We got an invalid address range back + error.SetErrorString("Server returned invalid range"); } } else { m_supports_memory_region_info = eLazyBoolNo; -------------- next part -------------- A non-text attachment was scrubbed... Name: D31485.93685.patch Type: text/x-patch Size: 3232 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 12:30:15 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 19:30:15 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: tberghammer added a comment. One note on benchmarking: A did some performance profiling on LLDB using a similar approach to what Pavel suggested and if I remember correctly only ~10% of the time was spent on C++ name parsing (~15% was C++ demangling, ~50% was debug_info parsing, rest of them was fairly well distributed). Because of this I think some targeted micro benchmark will be much more useful to measure the performance of this code then an end-to-end test as an e2e test would have low signal to noise ratio. https://reviews.llvm.org/D31451 From lldb-commits at lists.llvm.org Fri Mar 31 12:48:05 2017 From: lldb-commits at lists.llvm.org (Eugene Zemtsov via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 19:48:05 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: <979cab05339757328e9b5609fe367ae7@localhost.localdomain> eugene updated this revision to Diff 93693. eugene marked 3 inline comments as done. eugene added a comment. Addressing review commnets https://reviews.llvm.org/D31451 Files: source/Plugins/Language/CPlusPlus/CMakeLists.txt source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31451.93693.patch Type: text/x-patch Size: 43422 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 12:52:08 2017 From: lldb-commits at lists.llvm.org (Eugene Zemtsov via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 19:52:08 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: <7a5c904764784464c4eda8c7db02f319@localhost.localdomain> eugene updated this revision to Diff 93694. eugene marked an inline comment as done. https://reviews.llvm.org/D31451 Files: source/Plugins/Language/CPlusPlus/CMakeLists.txt source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31451.93694.patch Type: text/x-patch Size: 43418 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 12:57:28 2017 From: lldb-commits at lists.llvm.org (Eugene Zemtsov via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 19:57:28 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: <82350e28929c107b0f6d04dc7461d15e@localhost.localdomain> eugene added a subscriber: labath. eugene marked 2 inline comments as done. eugene added a comment. In https://reviews.llvm.org/D31451#715649, @tberghammer wrote: > Because of this I think some targeted micro benchmark will be much more useful to measure the performance of this code then an end-to-end test as an e2e test would have low signal to noise ratio. I did some micro-benchmarking and on average new parser is ~3 time slower than the old one. (new parser - ~200k string/s, old parser - ~700k string/s) clang::Lexer appears to be the slowest part of it. I mitigate this performance loss, by calling simplified parsing code for simple cases and calling new parser only when the old one fails. ================ Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp:18 +using namespace lldb_private; +using llvm::Optional; +using llvm::None; ---------------- labath wrote: > Are these necessary? You seem to prefix every occurence of Optional and None anyway... Well, I used None. Now I use Optional as well. https://reviews.llvm.org/D31451 From lldb-commits at lists.llvm.org Fri Mar 31 13:07:20 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via lldb-commits) Date: Fri, 31 Mar 2017 20:07:20 -0000 Subject: [Lldb-commits] [lldb] r299249 - Do not dereference std::unique_ptr by default Message-ID: <20170331200720.B6D5F3128009@llvm.org> Author: tberghammer Date: Fri Mar 31 15:07:20 2017 New Revision: 299249 URL: http://llvm.org/viewvc/llvm-project?rev=299249&view=rev Log: Do not dereference std::unique_ptr by default Summary: Displaying the object pointed by the unique_ptr can cause an infinite recursion when we have a pointer loop so this change stops that behavior. Additionally it makes the unique_ptr act more like a class containing a pointer (what is the underlying truth) instead of some "magic" class. Reviewers: labath, jingham Differential Revision: https://reviews.llvm.org/D31366 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py?rev=299249&r1=299248&r2=299249&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py Fri Mar 31 15:07:20 2017 @@ -34,13 +34,13 @@ class StdUniquePtrDataFormatterTestCase( self.assertTrue(frame.IsValid()) self.expect("frame variable nup", substrs=['nup = nullptr']) - self.expect("frame variable iup", substrs=['iup = 0x', 'object = 123']) - self.expect("frame variable sup", substrs=['sup = 0x', 'object = "foobar"']) + self.expect("frame variable iup", substrs=['iup = 0x']) + self.expect("frame variable sup", substrs=['sup = 0x']) self.expect("frame variable ndp", substrs=['ndp = nullptr']) - self.expect("frame variable idp", substrs=['idp = 0x', 'object = 456', 'deleter = ', 'a = 1', 'b = 2']) - self.expect("frame variable sdp", substrs=['sdp = 0x', 'object = "baz"', 'deleter = ', 'a = 3', 'b = 4']) - + self.expect("frame variable idp", substrs=['idp = 0x', 'deleter = ', 'a = 1', 'b = 2']) + self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 'a = 3', 'b = 4']) + self.assertEqual(123, frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned()) self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid()) @@ -59,3 +59,32 @@ class StdUniquePtrDataFormatterTestCase( self.assertTrue(sdp_deleter.IsValid()) self.assertEqual(3, sdp_deleter.GetChildMemberWithName("a").GetValueAsUnsigned()) self.assertEqual(4, sdp_deleter.GetChildMemberWithName("b").GetValueAsUnsigned()) + + @skipIfFreeBSD + @skipIfWindows # libstdcpp not ported to Windows + @skipIfDarwin # doesn't compile on Darwin + def test_recursive_unique_ptr(self): + # Tests that LLDB can handle when we have a loop in the unique_ptr + # reference chain and that it correctly handles the different options + # for the frame variable command in this case. + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") + self.runCmd("run", RUN_SUCCEEDED) + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) + + self.expect("frame variable f1->fp", + substrs=['fp = 0x']) + self.expect("frame variable --ptr-depth=1 f1->fp", + substrs=['data = 2', 'fp = 0x']) + self.expect("frame variable --ptr-depth=2 f1->fp", + substrs=['data = 2', 'fp = 0x', 'data = 1']) + + frame = self.frame() + self.assertTrue(frame.IsValid()) + self.assertEqual(2, frame.GetValueForVariablePath("f1->fp.object.data").GetValueAsUnsigned()) + self.assertEqual(1, frame.GetValueForVariablePath("f1->fp.object.fp.object.data").GetValueAsUnsigned()) + Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp?rev=299249&r1=299248&r2=299249&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp Fri Mar 31 15:07:20 2017 @@ -8,6 +8,11 @@ struct Deleter { int b; }; +struct Foo { + int data; + std::unique_ptr fp; +}; + int main() { std::unique_ptr nup; std::unique_ptr iup(new int{123}); @@ -18,5 +23,13 @@ int main() { std::unique_ptr sdp(new std::string("baz"), Deleter{3, 4}); + std::unique_ptr fp(new Foo{3}); + + // Set up a structure where we have a loop in the unique_ptr chain. + Foo* f1 = new Foo{1}; + Foo* f2 = new Foo{2}; + f1->fp.reset(f2); + f2->fp.reset(f1); + return 0; // Set break point at this line. } Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp?rev=299249&r1=299248&r2=299249&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Fri Mar 31 15:07:20 2017 @@ -94,29 +94,27 @@ bool LibStdcppUniquePtrSyntheticFrontEnd lldb::ValueObjectSP LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) { if (idx == 0) - return m_obj_obj; + return m_ptr_obj; if (idx == 1) return m_del_obj; if (idx == 2) - return m_ptr_obj; + return m_obj_obj; return lldb::ValueObjectSP(); } size_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() { if (m_del_obj) return 2; - if (m_ptr_obj && m_ptr_obj->GetValueAsUnsigned(0) != 0) - return 1; - return 0; + return 1; } size_t LibStdcppUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName( const ConstString &name) { - if (name == ConstString("obj") || name == ConstString("object")) + if (name == ConstString("ptr") || name == ConstString("pointer")) return 0; if (name == ConstString("del") || name == ConstString("deleter")) return 1; - if (name == ConstString("ptr") || name == ConstString("pointer")) + if (name == ConstString("obj") || name == ConstString("object")) return 2; return UINT32_MAX; } From lldb-commits at lists.llvm.org Fri Mar 31 13:19:48 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 20:19:48 +0000 Subject: [Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rL299249: Do not dereference std::unique_ptr by default (authored by tberghammer). Changed prior to commit: https://reviews.llvm.org/D31366?vs=93039&id=93699#toc Repository: rL LLVM https://reviews.llvm.org/D31366 Files: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31366.93699.patch Type: text/x-patch Size: 5621 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 13:23:22 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via lldb-commits) Date: Fri, 31 Mar 2017 20:23:22 -0000 Subject: [Lldb-commits] [lldb] r299251 - Add support for sythetic operator dereference Message-ID: <20170331202323.5B1803128009@llvm.org> Author: tberghammer Date: Fri Mar 31 15:23:22 2017 New Revision: 299251 URL: http://llvm.org/viewvc/llvm-project?rev=299251&view=rev Log: Add support for sythetic operator dereference Summary: After this change a sythetic child provider can generate a special child named "$$dereference$$" what if present is used when "operator*" or "operator->" used on a ValueObject. The goal of the change is to make expressions like "up->foo" work inside the "frame variable" command. Reviewers: labath, jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D31368 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/www/varformats.html Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py?rev=299251&r1=299250&r2=299251&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py Fri Mar 31 15:23:22 2017 @@ -42,13 +42,17 @@ class StdUniquePtrDataFormatterTestCase( self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 'a = 3', 'b = 4']) self.assertEqual(123, frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned()) + self.assertEqual(123, frame.GetValueForVariablePath("*iup").GetValueAsUnsigned()) self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid()) self.assertEqual('"foobar"', frame.GetValueForVariablePath("sup.object").GetSummary()) + self.assertEqual('"foobar"', frame.GetValueForVariablePath("*sup").GetSummary()) self.assertFalse(frame.GetValueForVariablePath("sup.deleter").IsValid()) self.assertEqual(456, frame.GetValueForVariablePath("idp.object").GetValueAsUnsigned()) + self.assertEqual(456, frame.GetValueForVariablePath("*idp").GetValueAsUnsigned()) self.assertEqual('"baz"', frame.GetValueForVariablePath("sdp.object").GetSummary()) + self.assertEqual('"baz"', frame.GetValueForVariablePath("*sdp").GetSummary()) idp_deleter = frame.GetValueForVariablePath("idp.deleter") self.assertTrue(idp_deleter.IsValid()) @@ -86,5 +90,7 @@ class StdUniquePtrDataFormatterTestCase( frame = self.frame() self.assertTrue(frame.IsValid()) self.assertEqual(2, frame.GetValueForVariablePath("f1->fp.object.data").GetValueAsUnsigned()) + self.assertEqual(2, frame.GetValueForVariablePath("f1->fp->data").GetValueAsUnsigned()) self.assertEqual(1, frame.GetValueForVariablePath("f1->fp.object.fp.object.data").GetValueAsUnsigned()) + self.assertEqual(1, frame.GetValueForVariablePath("f1->fp->fp->data").GetValueAsUnsigned()) Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=299251&r1=299250&r2=299251&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Mar 31 15:23:22 2017 @@ -2889,6 +2889,11 @@ ValueObjectSP ValueObject::Dereference(E child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid, language_flags); } + } else if (HasSyntheticValue()) { + m_deref_valobj = + GetSyntheticValue() + ->GetChildMemberWithName(ConstString("$$dereference$$"), true) + .get(); } if (m_deref_valobj) { Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp?rev=299251&r1=299250&r2=299251&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Fri Mar 31 15:23:22 2017 @@ -114,7 +114,8 @@ size_t LibStdcppUniquePtrSyntheticFrontE return 0; if (name == ConstString("del") || name == ConstString("deleter")) return 1; - if (name == ConstString("obj") || name == ConstString("object")) + if (name == ConstString("obj") || name == ConstString("object") || + name == ConstString("$$dereference$$")) return 2; return UINT32_MAX; } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=299251&r1=299250&r2=299251&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Fri Mar 31 15:23:22 2017 @@ -606,8 +606,10 @@ ValueObjectSP StackFrame::GetValueForVar // Calculate the next separator index ahead of time ValueObjectSP child_valobj_sp; const char separator_type = var_expr[0]; + bool expr_is_ptr = false; switch (separator_type) { case '-': + expr_is_ptr = true; if (var_expr.size() >= 2 && var_expr[1] != '>') return ValueObjectSP(); @@ -624,11 +626,32 @@ ValueObjectSP StackFrame::GetValueForVar return ValueObjectSP(); } } + + // If we have a non pointer type with a sythetic value then lets check if + // we have an sythetic dereference specified. + if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) { + Error deref_error; + if (valobj_sp->GetCompilerType().IsReferenceType()) { + valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error); + if (error.Fail()) { + error.SetErrorStringWithFormatv( + "Failed to dereference reference type: %s", deref_error); + return ValueObjectSP(); + } + } + + valobj_sp = valobj_sp->Dereference(deref_error); + if (error.Fail()) { + error.SetErrorStringWithFormatv( + "Failed to dereference sythetic value: %s", deref_error); + return ValueObjectSP(); + } + expr_is_ptr = false; + } + var_expr = var_expr.drop_front(); // Remove the '-' LLVM_FALLTHROUGH; case '.': { - const bool expr_is_ptr = var_expr[0] == '>'; - var_expr = var_expr.drop_front(); // Remove the '.' or '>' separator_idx = var_expr.find_first_of(".-["); ConstString child_name(var_expr.substr(0, var_expr.find_first_of(".-["))); Modified: lldb/trunk/www/varformats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=299251&r1=299250&r2=299251&view=diff ============================================================================== --- lldb/trunk/www/varformats.html (original) +++ lldb/trunk/www/varformats.html Fri Mar 31 15:23:22 2017 @@ -1068,6 +1068,7 @@ def function (valobj,internal_dict):
[2] This method is optional (starting with SVN rev166495/LLDB-175). While implementing it in terms of num_children is acceptable, implementors are encouraged to look for optimized coding alternatives whenever reasonable.
[3] This method is optional (starting with SVN revision 219330). The SBValue you return here will most likely be a numeric type (int, float, ...) as its value bytes will be used as-if they were the value of the root SBValue proper. As a shortcut for this, you can inherit from lldb.SBSyntheticValueProvider, and just define get_value as other methods are defaulted in the superclass as returning default no-children responses. +

If a synthetic child provider supplies a special child named $$dereference$$ then it will be used when evaluating opertaor* and operator-> in the frame variable command and related SB API functions.

For examples of how synthetic children are created, you are encouraged to look at examples/synthetic in the LLDB trunk. Please, be aware that the code in those files (except bitfield/) is legacy code and is not maintained. You may especially want to begin looking at this example to get From lldb-commits at lists.llvm.org Fri Mar 31 13:35:56 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 20:35:56 +0000 Subject: [Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rL299251: Add support for sythetic operator dereference (authored by tberghammer). Changed prior to commit: https://reviews.llvm.org/D31368?vs=93529&id=93701#toc Repository: rL LLVM https://reviews.llvm.org/D31368 Files: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/www/varformats.html -------------- next part -------------- A non-text attachment was scrubbed... Name: D31368.93701.patch Type: text/x-patch Size: 6869 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 13:58:33 2017 From: lldb-commits at lists.llvm.org (Pavel Labath via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 20:58:33 +0000 Subject: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic In-Reply-To: References: Message-ID: <68b195dd766d128971872a3794ccdabd@localhost.localdomain> labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Thank you In https://reviews.llvm.org/D31451#715664, @eugene wrote: > In https://reviews.llvm.org/D31451#715649, @tberghammer wrote: > > > Because of this I think some targeted micro benchmark will be much more useful to measure the performance of this code then an end-to-end test as an e2e test would have low signal to noise ratio. > > > I did some micro-benchmarking and on average new parser is ~3 time slower than the old one. (new parser - ~200k string/s, old parser - ~700k string/s) > clang::Lexer appears to be the slowest part of it. > I mitigate this performance loss, by calling simplified parsing code for simple cases and calling new parser only when the old one fails. It was pretty clear that the new parser will be slower than the old one, even if I couldn't tell whether it would be 2x or 20x. That's why I wanted a macro benchmark to see whether that matters on the grand scale of things. If you say that 10% of time is name parsing, then we definitely don't want to make that 30%, which means the decision to use two parsers was correct. https://reviews.llvm.org/D31451 From lldb-commits at lists.llvm.org Fri Mar 31 13:48:01 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via lldb-commits) Date: Fri, 31 Mar 2017 20:48:01 -0000 Subject: [Lldb-commits] [lldb] r299259 - Stop calling ValueObject::SetName from synthetic child providers Message-ID: <20170331204801.742423128009@llvm.org> Author: tberghammer Date: Fri Mar 31 15:48:00 2017 New Revision: 299259 URL: http://llvm.org/viewvc/llvm-project?rev=299259&view=rev Log: Stop calling ValueObject::SetName from synthetic child providers Summary: Calling ValueObject::SetName from a sythetic child provider would change the underying value object used for the non-synthetic child as well what is clearly unintentional. Reviewers: jingham, labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D31371 Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/DataFormatters/VectorType.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=299259&r1=299258&r2=299259&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Mar 31 15:48:00 2017 @@ -553,6 +553,9 @@ public: lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); } + // Change the name of the current ValueObject. Should *not* be used from a + // synthetic child provider as it would change the name of the non synthetic + // child as well. void SetName(const ConstString &name); virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, @@ -601,6 +604,12 @@ public: virtual lldb::ValueObjectSP Dereference(Error &error); + // Creates a copy of the ValueObject with a new name and setting the current + // ValueObject as its parent. It should be used when we want to change the + // name of a ValueObject without modifying the actual ValueObject itself + // (e.g. sythetic child provider). + virtual lldb::ValueObjectSP Clone(const ConstString &new_name); + virtual lldb::ValueObjectSP AddressOf(Error &error); virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; } Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=299259&r1=299258&r2=299259&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Mar 31 15:48:00 2017 @@ -2962,6 +2962,10 @@ ValueObjectSP ValueObject::Cast(const Co return ValueObjectCast::Create(*this, GetName(), compiler_type); } +lldb::ValueObjectSP ValueObject::Clone(const ConstString &new_name) { + return ValueObjectCast::Create(*this, new_name, GetCompilerType()); +} + ValueObjectSP ValueObject::CastPointerType(const char *name, CompilerType &compiler_type) { ValueObjectSP valobj_sp; Modified: lldb/trunk/source/DataFormatters/VectorType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/VectorType.cpp?rev=299259&r1=299258&r2=299259&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/VectorType.cpp (original) +++ lldb/trunk/source/DataFormatters/VectorType.cpp Fri Mar 31 15:48:00 2017 @@ -204,14 +204,12 @@ public: if (idx >= CalculateNumChildren()) return lldb::ValueObjectSP(); auto offset = idx * m_child_type.GetByteSize(nullptr); - ValueObjectSP child_sp( - m_backend.GetSyntheticChildAtOffset(offset, m_child_type, true)); - if (!child_sp) - return child_sp; - StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); - child_sp->SetName(ConstString(idx_name.GetString())); + ValueObjectSP child_sp(m_backend.GetSyntheticChildAtOffset( + offset, m_child_type, true, ConstString(idx_name.GetString()))); + if (!child_sp) + return child_sp; child_sp->SetFormat(m_item_format); Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp?rev=299259&r1=299258&r2=299259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Fri Mar 31 15:48:00 2017 @@ -406,7 +406,7 @@ lldb_private::formatters::LibcxxStdMapSy case 1: { auto child0_sp = potential_child_sp->GetChildAtIndex(0, true); if (child0_sp && child0_sp->GetName() == g___cc) - potential_child_sp = child0_sp; + potential_child_sp = child0_sp->Clone(ConstString(name.GetString())); break; } case 2: { @@ -414,11 +414,10 @@ lldb_private::formatters::LibcxxStdMapSy auto child1_sp = potential_child_sp->GetChildAtIndex(1, true); if (child0_sp && child0_sp->GetName() == g___cc && child1_sp && child1_sp->GetName() == g___nc) - potential_child_sp = child0_sp; + potential_child_sp = child0_sp->Clone(ConstString(name.GetString())); break; } } - potential_child_sp->SetName(ConstString(name.GetString())); } m_iterators[idx] = iterator; return potential_child_sp; Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp?rev=299259&r1=299258&r2=299259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp Fri Mar 31 15:48:00 2017 @@ -73,9 +73,7 @@ bool LibStdcppTupleSyntheticFrontEnd::Up if (value_sp) { StreamString name; name.Printf("[%zd]", m_members.size()); - value_sp->SetName(ConstString(name.GetString())); - - m_members.push_back(value_sp); + m_members.push_back(value_sp->Clone(ConstString(name.GetString()))); } } } Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp?rev=299259&r1=299258&r2=299259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Fri Mar 31 15:48:00 2017 @@ -70,19 +70,19 @@ bool LibStdcppUniquePtrSyntheticFrontEnd std::unique_ptr tuple_frontend( LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp)); - m_ptr_obj = tuple_frontend->GetChildAtIndex(0); - if (m_ptr_obj) - m_ptr_obj->SetName(ConstString("pointer")); + ValueObjectSP ptr_obj = tuple_frontend->GetChildAtIndex(0); + if (ptr_obj) + m_ptr_obj = ptr_obj->Clone(ConstString("pointer")); - m_del_obj = tuple_frontend->GetChildAtIndex(1); - if (m_del_obj) - m_del_obj->SetName(ConstString("deleter")); + ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1); + if (del_obj) + m_del_obj = del_obj->Clone(ConstString("deleter")); if (m_ptr_obj) { Error error; - m_obj_obj = m_ptr_obj->Dereference(error); + ValueObjectSP obj_obj = m_ptr_obj->Dereference(error); if (error.Success()) { - m_obj_obj->SetName(ConstString("object")); + m_obj_obj = obj_obj->Clone(ConstString("object")); } } From lldb-commits at lists.llvm.org Fri Mar 31 14:00:30 2017 From: lldb-commits at lists.llvm.org (Tamas Berghammer via Phabricator via lldb-commits) Date: Fri, 31 Mar 2017 21:00:30 +0000 Subject: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rL299259: Stop calling ValueObject::SetName from synthetic child providers (authored by tberghammer). Changed prior to commit: https://reviews.llvm.org/D31371?vs=93528&id=93704#toc Repository: rL LLVM https://reviews.llvm.org/D31371 Files: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/DataFormatters/VectorType.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D31371.93704.patch Type: text/x-patch Size: 5662 bytes Desc: not available URL: From lldb-commits at lists.llvm.org Fri Mar 31 14:03:58 2017 From: lldb-commits at lists.llvm.org (Tim Hammerquist via lldb-commits) Date: Fri, 31 Mar 2017 21:03:58 -0000 Subject: [Lldb-commits] [lldb] r299261 - add more RegisterContext files to xcode project Message-ID: <20170331210359.2FE173128009@llvm.org> Author: penryu Date: Fri Mar 31 16:03:58 2017 New Revision: 299261 URL: http://llvm.org/viewvc/llvm-project?rev=299261&view=rev Log: add more RegisterContext files to xcode project Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=299261&r1=299260&r2=299261&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Mar 31 16:03:58 2017 @@ -864,6 +864,7 @@ 966C6B7A18E6A56A0093F5EC /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 966C6B7818E6A56A0093F5EC /* libz.dylib */; }; 966C6B7C18E6A56A0093F5EC /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 966C6B7818E6A56A0093F5EC /* libz.dylib */; }; 9694FA711B32AA64005EBB16 /* ABISysV_mips.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9694FA6F1B32AA64005EBB16 /* ABISysV_mips.cpp */; }; + 9A0FDEA71E8EF5110086B2F5 /* RegisterContextLinux_mips.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0FDE971E8EF5010086B2F5 /* RegisterContextLinux_mips.cpp */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; 9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */; }; @@ -2795,6 +2796,13 @@ 966C6B7818E6A56A0093F5EC /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = ""; }; 9694FA6F1B32AA64005EBB16 /* ABISysV_mips.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ABISysV_mips.cpp; path = "SysV-mips/ABISysV_mips.cpp"; sourceTree = ""; }; 9694FA701B32AA64005EBB16 /* ABISysV_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ABISysV_mips.h; path = "SysV-mips/ABISysV_mips.h"; sourceTree = ""; }; + 9A0FDE951E8EF5010086B2F5 /* RegisterContext_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContext_mips.h; path = Utility/RegisterContext_mips.h; sourceTree = ""; }; + 9A0FDE961E8EF5010086B2F5 /* RegisterContext_s390x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContext_s390x.h; path = Utility/RegisterContext_s390x.h; sourceTree = ""; }; + 9A0FDE971E8EF5010086B2F5 /* RegisterContextLinux_mips.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextLinux_mips.cpp; path = Utility/RegisterContextLinux_mips.cpp; sourceTree = ""; }; + 9A0FDE981E8EF5010086B2F5 /* RegisterContextLinux_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextLinux_mips.h; path = Utility/RegisterContextLinux_mips.h; sourceTree = ""; }; + 9A0FDE991E8EF5010086B2F5 /* RegisterInfos_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_arm.h; path = Utility/RegisterInfos_arm.h; sourceTree = ""; }; + 9A0FDE9A1E8EF5010086B2F5 /* RegisterInfos_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_arm64.h; path = Utility/RegisterInfos_arm64.h; sourceTree = ""; }; + 9A0FDE9B1E8EF5010086B2F5 /* RegisterInfos_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_mips.h; path = Utility/RegisterInfos_mips.h; sourceTree = ""; }; 9A19A6A51163BB7E00E0D453 /* SBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBValue.h; path = include/lldb/API/SBValue.h; sourceTree = ""; }; 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBValue.cpp; path = source/API/SBValue.cpp; sourceTree = ""; }; 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulateInstructionARM.cpp; sourceTree = ""; }; @@ -4520,6 +4528,13 @@ 26B4666E11A2080F00CF6220 /* Utility */ = { isa = PBXGroup; children = ( + 9A0FDE951E8EF5010086B2F5 /* RegisterContext_mips.h */, + 9A0FDE961E8EF5010086B2F5 /* RegisterContext_s390x.h */, + 9A0FDE971E8EF5010086B2F5 /* RegisterContextLinux_mips.cpp */, + 9A0FDE981E8EF5010086B2F5 /* RegisterContextLinux_mips.h */, + 9A0FDE991E8EF5010086B2F5 /* RegisterInfos_arm.h */, + 9A0FDE9A1E8EF5010086B2F5 /* RegisterInfos_arm64.h */, + 9A0FDE9B1E8EF5010086B2F5 /* RegisterInfos_mips.h */, 9AD9449B1E8DB267004796ED /* RegisterContextNetBSD_x86_64.cpp */, 9AD9449C1E8DB267004796ED /* RegisterContextNetBSD_x86_64.h */, 23F403471926C8D50046DC9B /* NativeRegisterContextRegisterInfo.h */, @@ -7246,6 +7261,7 @@ 2689007413353E1A00698AC0 /* Terminal.cpp in Sources */, 6D0F61431C80AAAE00A4ECEE /* JavaASTContext.cpp in Sources */, 2689007613353E1A00698AC0 /* CFCBundle.cpp in Sources */, + 9A0FDEA71E8EF5110086B2F5 /* RegisterContextLinux_mips.cpp in Sources */, 94BA8B70176F97CE005A91B5 /* CommandHistory.cpp in Sources */, 2689007713353E1A00698AC0 /* CFCData.cpp in Sources */, 2689007813353E1A00698AC0 /* CFCMutableArray.cpp in Sources */, From lldb-commits at lists.llvm.org Fri Mar 31 15:39:55 2017 From: lldb-commits at lists.llvm.org (Jim Ingham via lldb-commits) Date: Fri, 31 Mar 2017 22:39:55 -0000 Subject: [Lldb-commits] [lldb] r299276 - DisassembleRange can return an empty DisassemblerSP Message-ID: <20170331223955.809533128009@llvm.org> Author: jingham Date: Fri Mar 31 17:39:55 2017 New Revision: 299276 URL: http://llvm.org/viewvc/llvm-project?rev=299276&view=rev Log: DisassembleRange can return an empty DisassemblerSP check for it. Modified: lldb/trunk/source/Target/StackFrame.cpp Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=299276&r1=299275&r2=299276&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Fri Mar 31 17:39:55 2017 @@ -1314,7 +1314,7 @@ lldb::ValueObjectSP StackFrame::GuessVal DisassemblerSP disassembler_sp = Disassembler::DisassembleRange( target_arch, plugin_name, flavor, exe_ctx, pc_range, prefer_file_cache); - if (!disassembler_sp->GetInstructionList().GetSize()) { + if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) { return ValueObjectSP(); } From lldb-commits at lists.llvm.org Sun Apr 2 17:59:48 2017 From: lldb-commits at lists.llvm.org (Jason Molenda via lldb-commits) Date: Mon, 03 Apr 2017 00:59:48 -0000 Subject: [Lldb-commits] [lldb] r299345 - Back out temporary masking of EXC_SYSCALL mach exceptions. Message-ID: <20170403005948.502F43128009@llvm.org> Author: jmolenda Date: Sun Apr 2 19:59:47 2017 New Revision: 299345 URL: http://llvm.org/viewvc/llvm-project?rev=299345&view=rev Log: Back out temporary masking of EXC_SYSCALL mach exceptions. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp?rev=299345&r1=299344&r2=299345&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp Sun Apr 2 19:59:47 2017 @@ -410,7 +410,7 @@ void MachException::Data::Dump() const { #define EXC_MASK_RESOURCE (1 << EXC_RESOURCE) #endif -#define LLDB_EXC_MASK (EXC_MASK_ALL & ~EXC_MASK_RESOURCE & ~EXC_MASK_SYSCALL) +#define LLDB_EXC_MASK (EXC_MASK_ALL & ~EXC_MASK_RESOURCE) kern_return_t MachException::PortInfo::Save(task_t task) { DNBLogThreadedIf(LOG_EXCEPTIONS | LOG_VERBOSE,