Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-19 Thread Pavel Labath via lldb-commits
labath added a comment.

> > Do you have a suggestion where the parsing code to be, if not in the same 
> > directory?

> 

> 

> The parsing code will end up being used by multiple plugins--the new one 
> you're building for Linux and the existing one that's Windows-specific.


I was hoping that we could avoid having a separate plugin for each OS. 
ProcessElfCore already handles linux and freebsd core files. It should be even 
simpler for minidumps, as the format there should be more similar. If that does 
not play out then we will need to move the generic code to a separate place, 
but I am hoping we can keep it in one plugin (maybe we can have a small class 
inside the plugin which abstracts any os-specific details we encounter).

> What I thought would happen would be that you'd write the parsing code first, 
> hook up the Windows-minidump plugin to use it (since the Windows-minidump 
> plugin tests would help validate that your parsing is correct/complete) and 
> then either add a new plugin for non-Windows.  That would argue for the 
> minidump parsing to be in a common location that could be used by both 
> plugins.  I don't have a good idea of where that would go.

> 

> Another approach is to make the Windows plugin platform agnostic once you 
> replace the limited use of the minidump APIs with your own parsing code.

> 

> Food for thought.  No need to hold up this patch for that.  The code can be 
> moved later if appropriate.


We'll see how it goes...



Comment at: source/Plugins/Process/minidump/MinidumpParser.cpp:22
@@ +21,3 @@
+{
+llvm::ArrayRef header_data(m_data_sp->GetBytes(), 
sizeof(MinidumpHeader));
+m_header = MinidumpHeader::Parse(header_data);

You should check whether the data buffer contains more than 
`sizeof(MinidumpHeader)` bytes. Or you can just use `m_data_sp->GetByteSize()` 
for size, and let the parse function deal with that.


Comment at: source/Plugins/Process/minidump/MinidumpParser.cpp:31
@@ +30,3 @@
+Error error;
+llvm::ArrayRef directory_data(m_data_sp->GetBytes() + 
directory_list_offset,
+   sizeof(MinidumpDirectory) * 
m_header.getValue()->streams_count);

Same thing. How do you know this memory exists? Is that checked somewhere?


Comment at: source/Plugins/Process/minidump/MinidumpParser.cpp:60
@@ +59,3 @@
+{
+llvm::DenseMap::iterator iter = 
m_directory_map.find((uint32_t)stream_type);
+if (iter == m_directory_map.end())

Suggestion: `auto iter = ` ?


Comment at: source/Plugins/Process/minidump/MinidumpTypes.h:260
@@ +259,3 @@
+
+uint8_t number_of_processors;
+uint8_t product_type;

dvlahovski wrote:
> amccarth wrote:
> > I'll concede that the static_assert is useful.  Given that, showing the 
> > arithmetic explicitly will be helpful when one of these assertions trips, 
> > because you'll be able to see how it's supposed to correspond to the struct.
> Yes that was my inital insentive to write explicitly the arithmetic
What I did not like about the original approach is that it declared a new 
global variable (in a header, so it is visible to everyone), just to store the 
temporary result. I think we should avoid that. I don't really care whether you 
write `sizeof(FOO) = 47` or `sizeof(FOO) = 4*10+4+3`


https://reviews.llvm.org/D23545



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r279198 - Add StructuredData plugin type; showcase with new DarwinLog feature

2016-08-19 Thread Pavel Labath via lldb-commits
You added LLDB as a subsriber. I don't know what that is, but the
correct name for the list is "lldb-commits".

pl

On 19 August 2016 at 04:54, Todd Fiala via lldb-commits
 wrote:
> Huh, that is totally weird.  I wonder what happened there?
>
> On Thu, Aug 18, 2016 at 8:12 PM, Zachary Turner  wrote:
>>
>> Weird, you linked to a phabricator revision but i never saw it come across
>> to the mailing list
>>
>> On Thu, Aug 18, 2016 at 8:00 PM Todd Fiala via lldb-commits
>>  wrote:
>>>
>>> Author: tfiala
>>> Date: Thu Aug 18 21:52:07 2016
>>> New Revision: 279198
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=279198&view=rev
>>> Log:
>>> Add StructuredData plugin type; showcase with new DarwinLog feature
>>>
>>> See docs/structured_data/StructuredDataPlugins.md for details.
>>>
>>> differential review: https://reviews.llvm.org/D22976
>>>
>>> reviewers: clayborg, jingham
>>>
>>> Added:
>>> lldb/trunk/docs/structured_data/
>>> lldb/trunk/docs/structured_data/DarwinLog.md
>>> lldb/trunk/docs/structured_data/StructuredDataPlugins.md
>>> lldb/trunk/include/lldb/API/SBStructuredData.h
>>> lldb/trunk/include/lldb/Target/StructuredDataPlugin.h
>>> lldb/trunk/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
>>> lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/Makefile
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/main.c
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/common/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/common/darwin_log_common.h
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/Makefile
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/main.c
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/Makefile
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/main.c
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/Makefile
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/main.c
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/Makefile
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/main.c
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/Makefile
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/main.c
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/Makefile
>>>
>>> lldb/trunk/packages/Python/lldbsuite/test/functionalities

Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-19 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 68670.
dvlahovski added a comment.

Adding sanity checks whether the data buffer

contains the amound of bytes that we want to read.
All of the functions that were returning llvm::Optional
now return just const something *
and indicate for failure with the return of nullptr.


https://reviews.llvm.org/D23545

Files:
  cmake/LLDBDependencies.cmake
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/CMakeLists.txt
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-x86_64.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- /dev/null
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -0,0 +1,87 @@
+//===-- MinidumpTypesTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "Plugins/Process/minidump/MinidumpParser.h"
+#include "Plugins/Process/minidump/MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "gtest/gtest.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Host/FileSpec.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+// C includes
+
+// C++ includes
+#include 
+
+extern const char *TestMainArgv0;
+
+using namespace lldb_private;
+using namespace minidump;
+
+class MinidumpParserTest : public testing::Test
+{
+public:
+void
+SetUp() override
+{
+llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0);
+inputs_folder = dmp_folder;
+llvm::sys::path::append(inputs_folder, "Inputs");
+}
+
+void
+SetUpData(const char *minidump_filename)
+{
+llvm::SmallString<128> filename = inputs_folder;
+llvm::sys::path::append(filename, minidump_filename);
+FileSpec minidump_file(filename.c_str(), false);
+lldb::DataBufferSP data_sp(minidump_file.MemoryMapFileContents());
+parser.reset(new MinidumpParser(data_sp));
+ASSERT_GT(parser->GetByteSize(), 0UL);
+ASSERT_TRUE(static_cast(parser));
+}
+
+llvm::SmallString<128> inputs_folder;
+std::unique_ptr parser;
+};
+
+TEST_F(MinidumpParserTest, GetThreads)
+{
+SetUpData("linux-x86_64.dmp");
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_TRUE(thread_list.hasValue());
+ASSERT_EQ(1UL, thread_list->size());
+
+const MinidumpThread *thread = thread_list.getValue()[0];
+ASSERT_EQ(16001UL, thread->thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetArchitecture)
+{
+SetUpData("linux-x86_64.dmp");
+ASSERT_EQ(llvm::Triple::ArchType::x86_64, parser->GetArchitecture().GetTriple().getArch());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfo)
+{
+SetUpData("linux-x86_64.dmp");
+const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+ASSERT_EQ(nullptr, misc_info);
+// linux breakpad generated minidump files don't have misc info stream
+}
Index: unittests/Process/minidump/CMakeLists.txt
===
--- /dev/null
+++ unittests/Process/minidump/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_lldb_unittest(LLDBMinidumpTests
+  MinidumpParserTest.cpp
+  )
+
+set(test_inputs
+   linux-x86_64.dmp)
+
+add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: unittests/Process/CMakeLists.txt
===
--- unittests/Process/CMakeLists.txt
+++ unittests/Process/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(gdb-remote)
+add_subdirectory(minidump)
Index: source/Plugins/Process/minidump/MinidumpTypes.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/MinidumpTypes.h
@@ -0,0 +1,298 @@
+//===-- MinidumpTypes.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_MinidumpTypes_h_
+#define liblldb_MinidumpTypes_h_
+
+// Project includes
+
+// Other libraries and framework includes
+#include "lldb/Core/Error.h"
+
+#include "llvm/ADT/ArrayRef.h"
+#inc

Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-19 Thread Dimitar Vlahovski via lldb-commits
dvlahovski added a comment.

I'm thinking of doing the following approach regarding the plugin 
implementation:
Start writing a new plugin "from scratch", which will be inspired strongly by 
ProcessWinMiniDump and also borrowing stuff from ProcessElfCore.
Also my plan is to make a single cross-platform Minidump plugin. At least for 
now I think that there aren't so many differences between Minidumps
generated on different platforms. (If the code gets messy probably a separate 
plugin for each platform is better.)
Also I think that I could reuse the Windows Minidump tests by pointing them to 
the new plugin and see if we
have at least the same (working) functionality.


https://reviews.llvm.org/D23545



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279232 - Remove the last manually constructed packet from gdb-remote register context + small refactor

2016-08-19 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Aug 19 07:31:49 2016
New Revision: 279232

URL: http://llvm.org/viewvc/llvm-project?rev=279232&view=rev
Log:
Remove the last manually constructed packet from gdb-remote register context + 
small refactor

Summary:
The tricky part here was that the exisiting implementation of WriteAllRegisters 
was expecting
hex-encoded data (as that was what the first implementation I replaced was 
using, but here we had
binary data to begin with. I thought the read/write register functions would be 
more useful if
they handled the hex-encoding themselves (all the other client functions 
provide the responses in
a more-or-less digested form). The read functions return a DataBuffer, so they 
can allocate as
much memory as they need to, while the write functions functions take an 
llvm::ArrayRef, as that
can be constructed from pretty much anything.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D23659

Modified:

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
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=279232&r1=279231&r2=279232&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
Fri Aug 19 07:31:49 2016
@@ -24,6 +24,7 @@
 #include "lldb/Core/State.h"
 #include "lldb/Core/StreamGDBRemote.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Host/StringConvert.h"
 #include "lldb/Host/TimeValue.h"
@@ -3494,45 +3495,58 @@ GDBRemoteCommunicationClient::AvoidGPack
 return m_avoid_g_packets == eLazyBoolYes;
 }
 
-bool
-GDBRemoteCommunicationClient::ReadRegister(lldb::tid_t tid, uint32_t reg, 
StringExtractorGDBRemote &response)
+DataBufferSP
+GDBRemoteCommunicationClient::ReadRegister(lldb::tid_t tid, uint32_t reg)
 {
 StreamString payload;
 payload.Printf("p%x", reg);
-return SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), 
response, false) ==
-   PacketResult::Success;
-}
+StringExtractorGDBRemote response;
+if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), 
response, false) != PacketResult::Success ||
+!response.IsNormalResponse())
+return nullptr;
 
+DataBufferSP buffer_sp(new DataBufferHeap(response.GetStringRef().size() / 
2, 0));
+response.GetHexBytes(buffer_sp->GetBytes(), buffer_sp->GetByteSize(), 
'\xcc');
+return buffer_sp;
+}
 
-bool
-GDBRemoteCommunicationClient::ReadAllRegisters (lldb::tid_t tid, 
StringExtractorGDBRemote &response)
+DataBufferSP
+GDBRemoteCommunicationClient::ReadAllRegisters(lldb::tid_t tid)
 {
 StreamString payload;
 payload.PutChar('g');
-return SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), 
response, false) ==
-   PacketResult::Success;
+StringExtractorGDBRemote response;
+if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), 
response, false) != PacketResult::Success ||
+!response.IsNormalResponse())
+return nullptr;
+
+DataBufferSP buffer_sp(new DataBufferHeap(response.GetStringRef().size() / 
2, 0));
+response.GetHexBytes(buffer_sp->GetBytes(), buffer_sp->GetByteSize(), 
'\xcc');
+return buffer_sp;
 }
 
 bool
-GDBRemoteCommunicationClient::WriteRegister(lldb::tid_t tid, uint32_t reg_num, 
llvm::StringRef data)
+GDBRemoteCommunicationClient::WriteRegister(lldb::tid_t tid, uint32_t reg_num, 
llvm::ArrayRef data)
 {
 StreamString payload;
 payload.Printf("P%x=", reg_num);
 payload.PutBytesAsRawHex8(data.data(), data.size(), 
endian::InlHostByteOrder(), endian::InlHostByteOrder());
 StringExtractorGDBRemote response;
 return SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), 
response, false) ==
-   PacketResult::Success;
+   PacketResult::Success &&
+   response.IsOKResponse();
 }
 
 bool
-GDBRemoteCommunicationClient::WriteAllRegisters(lldb::tid_t tid, 
llvm::StringRef data)
+GDBRemoteCommunicationClient::WriteAllRegisters(lldb::tid_t tid, 
llvm::ArrayRef data)
 {
 

Re: [Lldb-commits] [PATCH] D23659: Remove the last manually constructed packet from gdb-remote register context + small refactor

2016-08-19 Thread Pavel Labath via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279232: Remove the last manually constructed packet from 
gdb-remote register context… (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D23659?vs=68525&id=68676#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23659

Files:
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
  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
@@ -18,6 +18,9 @@
 #include "gtest/gtest.h"
 
 #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include "lldb/Core/DataBuffer.h"
+
+#include "llvm/ADT/ArrayRef.h"
 
 using namespace lldb_private::process_gdb_remote;
 using namespace lldb_private;
@@ -54,7 +57,10 @@
 ASSERT_EQ(PacketResult::Success, server.SendPacket(response));
 }
 
-const char all_registers[] = "404142434445464748494a4b4c4d4e4f";
+uint8_t all_registers[] = {'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'};
+std::string all_registers_hex = "404142434445464748494a4b4c4d4e4f";
+uint8_t one_register[] = {'A', 'B', 'C', 'D'};
+std::string one_register_hex = "41424344";
 
 } // end anonymous namespace
 
@@ -73,16 +79,16 @@
 const lldb::tid_t tid = 0x47;
 const uint32_t reg_num = 4;
 std::future write_result =
-std::async(std::launch::async, [&] { return client.WriteRegister(tid, reg_num, "ABCD"); });
+std::async(std::launch::async, [&] { return client.WriteRegister(tid, reg_num, one_register); });
 
 Handle_QThreadSuffixSupported(server, true);
 
-HandlePacket(server, "P4=41424344;thread:0047;", "OK");
+HandlePacket(server, "P4=" + one_register_hex + ";thread:0047;", "OK");
 ASSERT_TRUE(write_result.get());
 
 write_result = std::async(std::launch::async, [&] { return client.WriteAllRegisters(tid, all_registers); });
 
-HandlePacket(server, std::string("G") + all_registers + ";thread:0047;", "OK");
+HandlePacket(server, "G" + all_registers_hex + ";thread:0047;", "OK");
 ASSERT_TRUE(write_result.get());
 }
 
@@ -97,16 +103,16 @@
 const lldb::tid_t tid = 0x47;
 const uint32_t reg_num = 4;
 std::future write_result =
-std::async(std::launch::async, [&] { return client.WriteRegister(tid, reg_num, "ABCD"); });
+std::async(std::launch::async, [&] { return client.WriteRegister(tid, reg_num, one_register); });
 
 Handle_QThreadSuffixSupported(server, false);
 HandlePacket(server, "Hg47", "OK");
-HandlePacket(server, "P4=41424344", "OK");
+HandlePacket(server, "P4=" + one_register_hex, "OK");
 ASSERT_TRUE(write_result.get());
 
 write_result = std::async(std::launch::async, [&] { return client.WriteAllRegisters(tid, all_registers); });
 
-HandlePacket(server, std::string("G") + all_registers, "OK");
+HandlePacket(server, "G" + all_registers_hex, "OK");
 ASSERT_TRUE(write_result.get());
 }
 
@@ -122,19 +128,21 @@
 const uint32_t reg_num = 4;
 std::future async_result = std::async(std::launch::async, [&] { return client.GetpPacketSupported(tid); });
 Handle_QThreadSuffixSupported(server, true);
-HandlePacket(server, "p0;thread:0047;", "41424344");
+HandlePacket(server, "p0;thread:0047;", one_register_hex);
 ASSERT_TRUE(async_result.get());
 
-StringExtractorGDBRemote response;
-async_result = std::async(std::launch::async, [&] { return client.ReadRegister(tid, reg_num, response); });
+std::future read_result =
+std::async(std::launch::async, [&] { return client.ReadRegister(tid, reg_num); });
 HandlePacket(server, "p4;thread:0047;", "41424344");
-ASSERT_TRUE(async_result.get());
-ASSERT_EQ("41424344", response.GetStringRef());
-
-async_result = std::async(std::launch::async, [&] { return client.ReadAllRegisters(tid, response); });
-HandlePacket(server, "g;thread:0047;", all_registers);
-ASSERT_TRUE(async_result.get());
-ASSERT_EQ(all_registers, response.GetStringRef());
+auto buffer_sp = read_result.get();
+ASSERT_TRUE(bool(buffer_sp));
+ASSERT_EQ(0, memcmp(buffer_sp->GetBytes(), one_register, sizeof one_register));
+
+read_result = std::async(std::launch::async, [&

[Lldb-commits] [lldb] r279234 - Fixing a Darwing test thats failing on windows

2016-08-19 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Fri Aug 19 07:44:53 2016
New Revision: 279234

URL: http://llvm.org/viewvc/llvm-project?rev=279234&view=rev
Log:
Fixing a Darwing test thats failing on windows

The pexpect import should be make after the skip-if-not-darwin part
because pexpect is not available on Windows

Modified:
lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py?rev=279234&r1=279233&r2=279234&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py Fri Aug 19 07:44:53 
2016
@@ -7,7 +7,6 @@ from __future__ import print_function
 
 import json
 import os
-import pexpect
 import platform
 import re
 import sys
@@ -59,6 +58,7 @@ class DarwinLogTestBase(lldbtest.TestBas
 def run_lldb_to_breakpoint(self, exe, source_file, line,
enable_command=None, settings_commands=None):
 
+import pexpect
 # Set self.child_prompt, which is "(lldb) ".
 prompt = self.child_prompt
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-19 Thread Pavel Labath via lldb-commits
labath added a comment.

Looks good as far as I am concerned. You might want to add a test or two that 
makes sure we handle invalid data reasonably. E.g., load only the first X kb of 
the minidump (so that the thread list is not present in the loaded block), and 
make sure getting a thread list fails (and does not crash).



Comment at: source/Plugins/Process/minidump/MinidumpParser.cpp:40
@@ +39,3 @@
+// check if there is enough data for the parsing of the directory list
+if ((directory_list_offset + sizeof(MinidumpDirectory) * 
m_header->streams_count) > m_data_sp->GetByteSize())
+{

Please put this before the construction of the ArrayRef - so we don't create a 
dangling object for no reason.


https://reviews.llvm.org/D23545



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279238 - Fix 32-bit builds after r279232

2016-08-19 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Aug 19 08:14:13 2016
New Revision: 279238

URL: http://llvm.org/viewvc/llvm-project?rev=279238&view=rev
Log:
Fix 32-bit builds after r279232

GetByteSize() of a DataBuffer returns a uint64_t (it probably shouldn't), which 
isn't implicitly
convertible to size_t.

Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=279238&r1=279237&r2=279238&view=diff
==
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
Fri Aug 19 08:14:13 2016
@@ -383,7 +383,7 @@ GDBRemoteRegisterContext::WriteRegisterB
 
 // Set all registers in one packet
 if (gdb_comm.WriteAllRegisters(m_thread.GetProtocolID(),
-   {m_reg_data.GetDataStart(), 
m_reg_data.GetByteSize()}))
+   {m_reg_data.GetDataStart(), 
size_t(m_reg_data.GetByteSize())}))
 
 {
 SetAllRegisterValid (false);
@@ -586,7 +586,8 @@ GDBRemoteRegisterContext::WriteAllRegist
 // The data_sp contains the G response packet.
 if (use_g_packet)
 {
-if (gdb_comm.WriteAllRegisters(m_thread.GetProtocolID(), 
{data_sp->GetBytes(), data_sp->GetByteSize()}))
+if (gdb_comm.WriteAllRegisters(m_thread.GetProtocolID(),
+   {data_sp->GetBytes(), 
size_t(data_sp->GetByteSize())}))
 return true;
 
 uint32_t num_restored = 0;


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-19 Thread Dimitar Vlahovski via lldb-commits
dvlahovski updated this revision to Diff 68690.
dvlahovski added a comment.

Move creation of ArrayRef after sanity check

Add a test that checks that the thread list is not present in a
truncated minidump file


https://reviews.llvm.org/D23545

Files:
  cmake/LLDBDependencies.cmake
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/MinidumpTypes.h
  unittests/Process/CMakeLists.txt
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/linux-x86_64.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- /dev/null
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -0,0 +1,96 @@
+//===-- MinidumpTypesTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Project includes
+#include "Plugins/Process/minidump/MinidumpParser.h"
+#include "Plugins/Process/minidump/MinidumpTypes.h"
+
+// Other libraries and framework includes
+#include "gtest/gtest.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Host/FileSpec.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+// C includes
+
+// C++ includes
+#include 
+
+extern const char *TestMainArgv0;
+
+using namespace lldb_private;
+using namespace minidump;
+
+class MinidumpParserTest : public testing::Test
+{
+public:
+void
+SetUp() override
+{
+llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0);
+inputs_folder = dmp_folder;
+llvm::sys::path::append(inputs_folder, "Inputs");
+}
+
+void
+SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX)
+{
+llvm::SmallString<128> filename = inputs_folder;
+llvm::sys::path::append(filename, minidump_filename);
+FileSpec minidump_file(filename.c_str(), false);
+lldb::DataBufferSP data_sp(minidump_file.MemoryMapFileContents(0, load_size));
+parser.reset(new MinidumpParser(data_sp));
+ASSERT_GT(parser->GetByteSize(), 0UL);
+ASSERT_TRUE(static_cast(parser));
+}
+
+llvm::SmallString<128> inputs_folder;
+std::unique_ptr parser;
+};
+
+TEST_F(MinidumpParserTest, GetThreads)
+{
+SetUpData("linux-x86_64.dmp");
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_TRUE(thread_list.hasValue());
+ASSERT_EQ(1UL, thread_list->size());
+
+const MinidumpThread *thread = thread_list.getValue()[0];
+ASSERT_EQ(16001UL, thread->thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadsTruncatedFile)
+{
+SetUpData("linux-x86_64.dmp", 128);
+llvm::Optional> thread_list;
+
+thread_list = parser->GetThreads();
+ASSERT_FALSE(thread_list.hasValue());
+}
+
+TEST_F(MinidumpParserTest, GetArchitecture)
+{
+SetUpData("linux-x86_64.dmp");
+ASSERT_EQ(llvm::Triple::ArchType::x86_64, parser->GetArchitecture().GetTriple().getArch());
+}
+
+TEST_F(MinidumpParserTest, GetMiscInfo)
+{
+SetUpData("linux-x86_64.dmp");
+const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
+ASSERT_EQ(nullptr, misc_info);
+// linux breakpad generated minidump files don't have misc info stream
+}
Index: unittests/Process/minidump/CMakeLists.txt
===
--- /dev/null
+++ unittests/Process/minidump/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_lldb_unittest(LLDBMinidumpTests
+  MinidumpParserTest.cpp
+  )
+
+set(test_inputs
+   linux-x86_64.dmp)
+
+add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: unittests/Process/CMakeLists.txt
===
--- unittests/Process/CMakeLists.txt
+++ unittests/Process/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(gdb-remote)
+add_subdirectory(minidump)
Index: source/Plugins/Process/minidump/MinidumpTypes.h
===
--- /dev/null
+++ source/Plugins/Process/minidump/MinidumpTypes.h
@@ -0,0 +1,298 @@
+//===-- MinidumpTypes.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_MinidumpTypes_h_
+#define libll

[Lldb-commits] [lldb] r279296 - [lldb][cmake] Remove libclang as an lldbBase dependency (NFCI)

2016-08-19 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Fri Aug 19 13:41:50 2016
New Revision: 279296

URL: http://llvm.org/viewvc/llvm-project?rev=279296&view=rev
Log:
[lldb][cmake] Remove libclang as an lldbBase dependency (NFCI)

It's pulling in all kinds of things it doesn't need (e.g, clang-tidy!).

Eliminating this dependency removes 1056 dependencies from the
'CommandObjectFrame.cpp.o' target and 454 dependencies from the 'lldb'
target. On my machine, this shaves 7 minutes off of a clean build of
lldb.

Thanks to Zachary Turner for pointing out some issues with an earlier
version of this patch!

Differential Revision: https://reviews.llvm.org/D22987

Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/cmake/modules/AddLLDB.cmake

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=279296&r1=279295&r2=279296&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Aug 19 13:41:50 2016
@@ -1,5 +1,6 @@
 cmake_minimum_required(VERSION 3.4.3)
 
+include(cmake/LLDBDependencies.cmake)
 include(cmake/modules/LLDBStandalone.cmake)
 include(cmake/modules/LLDBConfig.cmake)
 include(cmake/modules/AddLLDB.cmake)

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=279296&r1=279295&r2=279296&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Fri Aug 19 13:41:50 2016
@@ -84,10 +84,7 @@ macro(add_lldb_library name)
 endif()
   endif()
 
-  # Hack: only some LLDB libraries depend on the clang autogenerated headers,
-  # but it is simple enough to make all of LLDB depend on some of those
-  # headers without negatively impacting much of anything.
-  add_dependencies(${name} libclang)
+  add_dependencies(${name} ${CLANG_USED_LIBS})
 
   set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
 endmacro(add_lldb_library)


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279315 - Moved #include for lldb-python.h to a distinct group with a reminder comment

2016-08-19 Thread Kate Stone via lldb-commits
Author: kate
Date: Fri Aug 19 15:44:07 2016
New Revision: 279315

URL: http://llvm.org/viewvc/llvm-project?rev=279315&view=rev
Log:
Moved #include for lldb-python.h to a distinct group with a reminder comment
declaring that it must be first.  Failure to do so results in build failures
on macOS due to subtle header conflicts.


Added:
lldb/trunk/packages/Python/lldbsuite/.clang-format
Modified:
lldb/trunk/.clang-format
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Modified: lldb/trunk/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/.clang-format?rev=279315&r1=279314&r2=279315&view=diff
==
--- lldb/trunk/.clang-format (original)
+++ lldb/trunk/.clang-format Fri Aug 19 15:44:07 2016
@@ -1,9 +1 @@
 BasedOnStyle: LLVM
-IndentWidth: 4
-ColumnLimit: 120
-BreakBeforeBraces: Allman
-AlwaysBreakAfterReturnType: All
-AllowShortFunctionsOnASingleLine: Inline
-ConstructorInitializerAllOnOneLineOrOnePerLine: true
-IndentCaseLabels: true
-AccessModifierOffset: -4

Added: lldb/trunk/packages/Python/lldbsuite/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/.clang-format?rev=279315&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/.clang-format (added)
+++ lldb/trunk/packages/Python/lldbsuite/.clang-format Fri Aug 19 15:44:07 2016
@@ -0,0 +1,4 @@
+DisableFormat: true
+
+# Disabling formatting doesn't implicitly disable include sorting
+SortIncludes: false

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h?rev=279315&r1=279314&r2=279315&view=diff
==
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h 
(original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h Fri 
Aug 19 15:44:07 2016
@@ -12,11 +12,13 @@
 
 #ifndef LLDB_DISABLE_PYTHON
 
+// LLDB Python header must be included first
+#include "lldb-python.h"
+
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb-python.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/Flags.h"
 #include "lldb/Core/StructuredData.h"

Modified: 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp?rev=279315&r1=279314&r2=279315&view=diff
==
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp 
(original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp 
Fri Aug 19 15:44:07 2016
@@ -9,7 +9,9 @@
 
 #ifndef LLDB_DISABLE_PYTHON
 
+// LLDB Python header must be included first
 #include "lldb-python.h"
+
 #include "PythonExceptionState.h"
 
 #include "llvm/ADT/StringRef.h"

Modified: 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=279315&r1=279314&r2=279315&view=diff
==
--- 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
Fri Aug 19 15:44:07 2016
@@ -13,7 +13,9 @@
 
 #else
 
+// LLDB Python header must be included first
 #include "lldb-python.h"
+
 #include "ScriptInterpreterPython.h"
 #include "PythonDataObjects.h"
 #include "PythonExceptionState.h"


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279316 - Reverted premature changes to .clang-format

2016-08-19 Thread Kate Stone via lldb-commits
Author: kate
Date: Fri Aug 19 15:46:37 2016
New Revision: 279316

URL: http://llvm.org/viewvc/llvm-project?rev=279316&view=rev
Log:
Reverted premature changes to .clang-format


Removed:
lldb/trunk/packages/Python/lldbsuite/.clang-format
Modified:
lldb/trunk/.clang-format

Modified: lldb/trunk/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/.clang-format?rev=279316&r1=279315&r2=279316&view=diff
==
--- lldb/trunk/.clang-format (original)
+++ lldb/trunk/.clang-format Fri Aug 19 15:46:37 2016
@@ -1 +1,9 @@
 BasedOnStyle: LLVM
+IndentWidth: 4
+ColumnLimit: 120
+BreakBeforeBraces: Allman
+AlwaysBreakAfterReturnType: All
+AllowShortFunctionsOnASingleLine: Inline
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+IndentCaseLabels: true
+AccessModifierOffset: -4

Removed: lldb/trunk/packages/Python/lldbsuite/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/.clang-format?rev=279315&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/.clang-format (original)
+++ lldb/trunk/packages/Python/lldbsuite/.clang-format (removed)
@@ -1,4 +0,0 @@
-DisableFormat: true
-
-# Disabling formatting doesn't implicitly disable include sorting
-SortIncludes: false


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r279234 - Fixing a Darwing test thats failing on windows

2016-08-19 Thread Todd Fiala via lldb-commits
Thanks, Dimitar!

I should have caught that.

On August 19, 2016 at 5:52:52 AM, Dimitar Vlahovski via lldb-commits (
lldb-commits@lists.llvm.org) wrote:

Author: dvlahovski
Date: Fri Aug 19 07:44:53 2016
New Revision: 279234

URL: http://llvm.org/viewvc/llvm-project?rev=279234&view=rev
Log:
Fixing a Darwing test thats failing on windows

The pexpect import should be make after the skip-if-not-darwin part
because pexpect is not available on Windows

Modified:
lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py?rev=279234&r1=279233&r2=279234&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/darwin_log.py Fri Aug 19
07:44:53 2016
@@ -7,7 +7,6 @@ from __future__ import print_function

import json
import os
-import pexpect
import platform
import re
import sys
@@ -59,6 +58,7 @@ class DarwinLogTestBase(lldbtest.TestBas
def run_lldb_to_breakpoint(self, exe, source_file, line,
enable_command=None, settings_commands=None):

+ import pexpect
# Set self.child_prompt, which is "(lldb) ".
prompt = self.child_prompt



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279322 - Revert "[lldb][cmake] Remove libclang as an lldbBase dependency (NFCI)"

2016-08-19 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Fri Aug 19 16:00:40 2016
New Revision: 279322

URL: http://llvm.org/viewvc/llvm-project?rev=279322&view=rev
Log:
Revert "[lldb][cmake] Remove libclang as an lldbBase dependency (NFCI)"

This reverts commit r279296. Including LLDBDependencies breaks the
netbsd lldb bot because it exposes LLDB_USED_LIBS, which causes
lldb_link_common_libs to run to completion in unintended sites, which
results in a malformed call to target_link_libraries.

  http://lab.llvm.org:8011/builders/lldb-amd64-ninja-netbsd7/builds/5989

Thanks to Chris Bieneman for figuring this out!

Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/cmake/modules/AddLLDB.cmake

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=279322&r1=279321&r2=279322&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Aug 19 16:00:40 2016
@@ -1,6 +1,5 @@
 cmake_minimum_required(VERSION 3.4.3)
 
-include(cmake/LLDBDependencies.cmake)
 include(cmake/modules/LLDBStandalone.cmake)
 include(cmake/modules/LLDBConfig.cmake)
 include(cmake/modules/AddLLDB.cmake)

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=279322&r1=279321&r2=279322&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Fri Aug 19 16:00:40 2016
@@ -84,7 +84,10 @@ macro(add_lldb_library name)
 endif()
   endif()
 
-  add_dependencies(${name} ${CLANG_USED_LIBS})
+  # Hack: only some LLDB libraries depend on the clang autogenerated headers,
+  # but it is simple enough to make all of LLDB depend on some of those
+  # headers without negatively impacting much of anything.
+  add_dependencies(${name} libclang)
 
   set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
 endmacro(add_lldb_library)


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D23545: Minidump parsing

2016-08-19 Thread Zachary Turner via lldb-commits
zturner added a comment.

Were you still going to change all the `Optionals` to raw pointers (or even 
better, `llvm::Errors`)



Comment at: source/Plugins/Process/minidump/MinidumpParser.cpp:21
@@ +20,3 @@
+MinidumpParser::MinidumpParser(const lldb::DataBufferSP &data_buf_sp)
+: m_data_sp(data_buf_sp), m_header(nullptr), m_valid_data(true)
+{

I'm not crazy about the idea of allowing the constructor to fail and then 
checking `IsValidData()` after you construct it.  One way LLVM solves this is 
by having a static function that returns `Expected`.  You would use it like 
this:

```
Expected MinidumpParser::create(const lldb::DataBufferSP 
&data_buf_sp) {
  if (data_buf_sp->GetByteSize() < sizeof(MinidumpHeader))
return make_error("Insufficient buffer!");

  MinidumpHeader *header = nullptr;
  if (auto EC = MinidumpHeader::Parse(header_data, header))
return std::move(EC);

   ...

   return MinidumpParser(header, directory_map);
}

auto Parser = MinidumpParser::create(buffer);
if (!Parser) {
  // Handle the error
}
  
```

This way it's impossible to create a MinidumpParser that is invalid.

Up to you whether you want to do this, but I think it is a very good (and safe) 
pattern that I'd love to see LLDB start adopting more often.


https://reviews.llvm.org/D23545



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279327 - [lldb] Use OrcMCJITReplacement rather than MCJIT as the underlying JIT for LLDB

2016-08-19 Thread Lang Hames via lldb-commits
Author: lhames
Date: Fri Aug 19 16:27:16 2016
New Revision: 279327

URL: http://llvm.org/viewvc/llvm-project?rev=279327&view=rev
Log:
[lldb] Use OrcMCJITReplacement rather than MCJIT as the underlying JIT for LLDB
expression evaluation.

OrcMCJITReplacement is a reimplementation of MCJIT using ORC components, and
provides an easy upgrade path to ORC for existing MCJIT clients. There should be
no functional changes resulting from this switch.


Modified:
lldb/trunk/source/Expression/IRExecutionUnit.cpp

Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=279327&r1=279326&r2=279327&view=diff
==
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Fri Aug 19 16:27:16 2016
@@ -308,7 +308,8 @@ IRExecutionUnit::GetRunnableInfo(Error &
 .setRelocationModel(relocModel)
 .setMCJITMemoryManager(std::unique_ptr(new 
MemoryManager(*this)))
 .setCodeModel(codeModel)
-.setOptLevel(llvm::CodeGenOpt::Less);
+.setOptLevel(llvm::CodeGenOpt::Less)
+.setUseOrcMCJITReplacement(true);
 
 llvm::StringRef mArch;
 llvm::StringRef mCPU;


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279345 - Remove a test that depends on knowing all compiler's register allocation schemes.

2016-08-19 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Fri Aug 19 17:58:26 2016
New Revision: 279345

URL: http://llvm.org/viewvc/llvm-project?rev=279345&view=rev
Log:
Remove a test that depends on knowing all compiler's register allocation 
schemes.

This test was using a condition that would compare a variable against the 
register that would hold
it.  It was failing with clang on arm64 because clang put the variable on the 
stack.

This is not a supportable way to write tests.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py?rev=279345&r1=279344&r2=279345&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
 Fri Aug 19 17:58:26 2016
@@ -108,29 +108,6 @@ class BreakpointConditionsTestCase(TestB
 startstr = '(int) val = 1')
 
 self.runCmd("process kill")
-self.runCmd("breakpoint disable")
-
-self.runCmd("breakpoint set -p Loop")
-arch = self.getArchitecture()
-if arch in ['x86_64', 'i386']:
-self.runCmd("breakpoint modify -c ($eax&&i)")
-elif arch in ['aarch64']:
-self.runCmd("breakpoint modify -c ($x0&&i)")
-elif arch in ['arm']:
-self.runCmd("breakpoint modify -c ($r0&&i)")
-elif re.match("mips",arch):
-self.runCmd("breakpoint modify -c ($r2&&i)")
-elif arch in ['s390x']:
-self.runCmd("breakpoint modify -c ($r2&&i)")
-self.runCmd("run")
-
-self.expect("process status", PROCESS_STOPPED,
-patterns = ['Process .* stopped'])
-
-self.runCmd("continue")
-
-self.expect("process status", PROCESS_EXITED,
-patterns = ['Process .* exited'])
 
 def breakpoint_conditions_python(self):
 """Use Python APIs to set breakpoint conditions."""


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r279353 - Add logic to the ObjC runtime in LLDB to extract the pointer values of the two singleton (pairtons?) instances of __NSCFBoolean that represent true and false

2016-08-19 Thread Enrico Granata via lldb-commits
Author: enrico
Date: Fri Aug 19 19:48:11 2016
New Revision: 279353

URL: http://llvm.org/viewvc/llvm-project?rev=279353&view=rev
Log:
Add logic to the ObjC runtime in LLDB to extract the pointer values of the two 
singleton (pairtons?) instances of __NSCFBoolean that represent true and false

This is useful because that knowledge will in turn allow no-code-running 
formatting of boolean NSNumbers; but that's a commit that will have to wait 
Monday..


Modified:

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=279353&r1=279352&r2=279353&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 Fri Aug 19 19:48:11 2016
@@ -350,6 +350,13 @@ AppleObjCRuntime::GetFoundationVersion (
 return m_Foundation_major.getValue();
 }
 
+void
+AppleObjCRuntime::GetValuesForGlobalCFBooleans(lldb::addr_t& cf_true,
+   lldb::addr_t& cf_false)
+{
+cf_true = cf_false = LLDB_INVALID_ADDRESS;
+}
+
 bool
 AppleObjCRuntime::IsModuleObjCLibrary (const ModuleSP &module_sp)
 {

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h?rev=279353&r1=279352&r2=279353&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
 Fri Aug 19 19:48:11 2016
@@ -114,6 +114,10 @@ public:
 uint32_t
 GetFoundationVersion();
 
+virtual void
+GetValuesForGlobalCFBooleans(lldb::addr_t& cf_true,
+ lldb::addr_t& cf_false);
+
 protected:
 // Call CreateInstance instead.
 AppleObjCRuntime(Process *process);

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=279353&r1=279352&r2=279353&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 Fri Aug 19 19:48:11 2016
@@ -395,7 +395,8 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(P
   m_non_pointer_isa_cache_ap(NonPointerISACache::CreateInstance(*this, 
objc_module_sp)),
   m_tagged_pointer_vendor_ap(TaggedPointerVendorV2::CreateInstance(*this, 
objc_module_sp)),
   m_encoding_to_type_sp(),
-  m_noclasses_warning_emitted(false)
+  m_noclasses_warning_emitted(false),
+  m_CFBoolean_values()
 {
 static const ConstString g_gdb_object_getClass("gdb_object_getClass");
 m_has_object_getClass =
@@ -2577,3 +2578,44 @@ AppleObjCRuntimeV2::GetPointerISA (ObjCI
 
 return ret;
 }
+
+bool
+AppleObjCRuntimeV2::GetCFBooleanValuesIfNeeded ()
+{
+if (m_CFBoolean_values)
+return true;
+
+static ConstString g_kCFBooleanFalse("kCFBooleanFalse");
+static ConstString g_kCFBooleanTrue("kCFBooleanTrue");
+
+std::function get_symbol = [this] (ConstString 
sym) -> lldb::addr_t {
+SymbolContextList sc_list;
+if 
(GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(g_kCFBooleanFalse,
 lldb::eSymbolTypeData, sc_list) == 1)
+{
+SymbolContext sc;
+sc_list.GetContextAtIndex(0, sc);
+if (sc.symbol)
+return sc.symbol->GetLoadAddress(&GetProcess()->GetTarget());
+}
+
+return LLDB_INVALID_ADDRESS;
+};
+
+lldb::addr_t false_addr = get_symbol(g_kCFBooleanFalse);
+lldb::addr_t true_addr = get_symbol(g_kCFBooleanTrue);
+
+return (m_CFBoolean_values = {false_addr,true_addr}).operator bool();
+}
+
+void
+AppleObjCRuntimeV2::GetValuesForGlobalCFBooleans(lldb::addr_t& cf_true,
+ lldb::addr_t& cf_false)
+{
+if (GetCFBooleanValuesIfNeeded())
+{
+cf_

[Lldb-commits] [lldb] r279354 - added Xcode lldb-gtest-for-debugging target

2016-08-19 Thread Todd Fiala via lldb-commits
Author: tfiala
Date: Fri Aug 19 19:54:03 2016
New Revision: 279354

URL: http://llvm.org/viewvc/llvm-project?rev=279354&view=rev
Log:
added Xcode lldb-gtest-for-debugging target

The lldb-gtest target is for CI and runs the tests as
part of the build phase.  It does not support debugging
the gtests from Xcode, though, due to the run happening
during the build phase.

This change adds a lldb-gtest-for-debugging target that
can be used to debug gtests.

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=279354&r1=279353&r2=279354&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Aug 19 19:54:03 2016
@@ -106,6 +106,33 @@
23CB14FF1D66CD2900EDDDE1 /* FileSpecTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 23CB14FD1D66CD2400EDDDE1 /* FileSpecTest.cpp */; 
};
23CB15001D66CD3900EDDDE1 /* CPlusPlusLanguageTest.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 23CB14FA1D66CCF100EDDDE1 /* 
CPlusPlusLanguageTest.cpp */; };
23CB150F1D66CF5D00EDDDE1 /* TestClangASTContext.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 23CB150C1D66CF5600EDDDE1 /* 
TestClangASTContext.cpp */; };
+   23CB15331D66DA9300EDDDE1 /* GoParserTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = AEC6FF9F1BE970A2007882C1 /* GoParserTest.cpp */; 
};
+   23CB15341D66DA9300EDDDE1 /* CPlusPlusLanguageTest.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 23CB14FA1D66CCF100EDDDE1 /* 
CPlusPlusLanguageTest.cpp */; };
+   23CB15351D66DA9300EDDDE1 /* UriParserTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 2321F9461BDD346100BA9A93 /* UriParserTest.cpp 
*/; };
+   23CB15361D66DA9300EDDDE1 /* FileSpecTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 23CB14FD1D66CD2400EDDDE1 /* FileSpecTest.cpp */; 
};
+   23CB15371D66DA9300EDDDE1 /* PythonTestSuite.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = AF45E1FC1BF57C8D000563EB /* PythonTestSuite.cpp 
*/; };
+   23CB15381D66DA9300EDDDE1 /* PythonExceptionStateTests.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 3FA093141BF65D3A0037DD08 /* 
PythonExceptionStateTests.cpp */; };
+   23CB15391D66DA9300EDDDE1 /* DataExtractorTest.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 23CB14E81D66CC0E00EDDDE1 /* 
DataExtractorTest.cpp */; };
+   23CB153A1D66DA9300EDDDE1 /* GDBRemoteClientBaseTest.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 2370A37D1D66C587000E7BE6 /* 
GDBRemoteClientBaseTest.cpp */; };
+   23CB153B1D66DA9300EDDDE1 /* SocketTest.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 2321F93A1BDD332400BA9A93 /* SocketTest.cpp */; };
+   23CB153C1D66DA9300EDDDE1 /* TestArgs.cpp in Sources */ = {isa = 
PBXBuildFile; fileRef = 2321F93E1BDD33CE00BA9A93 /* TestArgs.cpp */; };
+   23CB153D1D66DA9300EDDDE1 /* 
GDBRemoteCommunicationClientTest.cpp in Sources */ = {isa = PBXBuildFile; 
fileRef = 2370A37E1D66C587000E7BE6 /* GDBRemoteCommunicationClientTest.cpp */; 
};
+   23CB153E1D66DA9300EDDDE1 /* PythonDataObjectsTests.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 2321F94D1BDD360F00BA9A93 /* 
PythonDataObjectsTests.cpp */; };
+   23CB153F1D66DA9300EDDDE1 /* SymbolsTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 2321F93B1BDD332400BA9A93 /* SymbolsTest.cpp */; 
};
+   23CB15401D66DA9300EDDDE1 /* TestClangASTContext.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 23CB150C1D66CF5600EDDDE1 /* 
TestClangASTContext.cpp */; };
+   23CB15411D66DA9300EDDDE1 /* StringExtractorTest.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 2321F9441BDD346100BA9A93 /* 
StringExtractorTest.cpp */; };
+   23CB15421D66DA9300EDDDE1 /* TaskPoolTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 2321F9451BDD346100BA9A93 /* TaskPoolTest.cpp */; 
};
+   23CB15431D66DA9300EDDDE1 /* BroadcasterTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 23CB14E61D66CC0E00EDDDE1 /* BroadcasterTest.cpp 
*/; };
+   23CB15441D66DA9300EDDDE1 /* ScalarTest.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 23CB14E91D66CC0E00EDDDE1 /* ScalarTest.cpp */; };
+   23CB15451D66DA9300EDDDE1 /* SocketAddressTest.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 2321F9391BDD332400BA9A93 /* 
SocketAddressTest.cpp */; };
+   23CB15461D66DA9300EDDDE1 /* GDBRemoteTestUtils.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 2370A37F1D66C587000E7BE6 /* 
GDBRemoteTestUtils.cpp */; };
+   23CB15471D66DA9300EDDDE1 /* EditlineTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 2326CF511BDD693B00A5CEAC /* Editli