[Lldb-commits] [lldb] r353925 - [lldb] [cmake] Use install directories for LLVM_* variables

2019-02-13 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Wed Feb 13 00:34:46 2019
New Revision: 353925

URL: http://llvm.org/viewvc/llvm-project?rev=353925&view=rev
Log:
[lldb] [cmake] Use install directories for LLVM_* variables

Restore the previous behavior of using install directories for
LLVM_MAIN_INCLUDE_DIR, LLVM_LIBRARY_DIR and LLVM_BINARY_DIR.  The update
from llvm-config to CMake has changed the values of those values to use
LLVM_BUILD_* which is plain wrong and breaks stand-alone builds.
Instead, use the CMake counterparts of the values returned
by llvm-config.

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

Modified:
lldb/trunk/cmake/modules/LLDBStandalone.cmake

Modified: lldb/trunk/cmake/modules/LLDBStandalone.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBStandalone.cmake?rev=353925&r1=353924&r2=353925&view=diff
==
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake Wed Feb 13 00:34:46 2019
@@ -20,9 +20,9 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake 
modules")
 
   set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM 
source tree")
-  set(LLVM_MAIN_INCLUDE_DIR ${LLVM_BUILD_MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_LIBRARY_DIR ${LLVM_BUILD_LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
-  set(LLVM_BINARY_DIR ${LLVM_BUILD_BINARY_DIR} CACHE PATH "Path to LLVM build 
tree")
+  set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
+  set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
   set(LLVM_DEFAULT_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE PATH 
"Path to llvm-lit")
 
   if(CMAKE_CROSSCOMPILING)


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


[Lldb-commits] [PATCH] D57995: [lldb] [cmake] Use install directories for LLVM_* variables

2019-02-13 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353925: [lldb] [cmake] Use install directories for LLVM_* 
variables (authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57995?vs=186427&id=186596#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57995/new/

https://reviews.llvm.org/D57995

Files:
  lldb/trunk/cmake/modules/LLDBStandalone.cmake


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -20,9 +20,9 @@
   set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake 
modules")
 
   set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM 
source tree")
-  set(LLVM_MAIN_INCLUDE_DIR ${LLVM_BUILD_MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_LIBRARY_DIR ${LLVM_BUILD_LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
-  set(LLVM_BINARY_DIR ${LLVM_BUILD_BINARY_DIR} CACHE PATH "Path to LLVM build 
tree")
+  set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
+  set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
   set(LLVM_DEFAULT_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE PATH 
"Path to llvm-lit")
 
   if(CMAKE_CROSSCOMPILING)


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -20,9 +20,9 @@
   set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
 
   set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-  set(LLVM_MAIN_INCLUDE_DIR ${LLVM_BUILD_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
-  set(LLVM_LIBRARY_DIR ${LLVM_BUILD_LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
-  set(LLVM_BINARY_DIR ${LLVM_BUILD_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
+  set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
   set(LLVM_DEFAULT_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE PATH "Path to llvm-lit")
 
   if(CMAKE_CROSSCOMPILING)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D58129: Move UnwindTable from ObjectFile to Module

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 186599.
labath added a comment.
Herald added a subscriber: jdoerfert.

Changed Module::GetUnwindTable to return a referece. I also changed the
UnwindTable to internally store a Module& (instead of ObjectFile&), to make sure
it always has something to hold on to.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58129/new/

https://reviews.llvm.org/D58129

Files:
  include/lldb/Core/Module.h
  include/lldb/Symbol/ObjectFile.h
  include/lldb/Symbol/UnwindTable.h
  source/Commands/CommandObjectTarget.cpp
  source/Core/Module.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  source/Symbol/ObjectFile.cpp
  source/Symbol/UnwindTable.cpp

Index: source/Symbol/UnwindTable.cpp
===
--- source/Symbol/UnwindTable.cpp
+++ source/Symbol/UnwindTable.cpp
@@ -26,8 +26,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
-UnwindTable::UnwindTable(ObjectFile &objfile)
-: m_object_file(objfile), m_unwinds(), m_initialized(false), m_mutex(),
+UnwindTable::UnwindTable(Module &module)
+: m_module(module), m_unwinds(), m_initialized(false), m_mutex(),
   m_eh_frame_up(), m_compact_unwind_up(), m_arm_unwind_up() {}
 
 // We can't do some of this initialization when the ObjectFile is running its
@@ -42,33 +42,36 @@
   if (m_initialized) // check again once we've acquired the lock
 return;
   m_initialized = true;
+  ObjectFile *object_file = m_module.GetObjectFile();
+  if (!object_file)
+return;
 
-  SectionList *sl = m_object_file.GetSectionList();
+  SectionList *sl = object_file->GetSectionList();
   if (!sl)
 return;
 
   SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
   if (sect.get()) {
 m_eh_frame_up.reset(
-new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::EH));
+new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::EH));
   }
 
   sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
   if (sect) {
 m_debug_frame_up.reset(
-new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::DWARF));
+new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::DWARF));
   }
 
   sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
   if (sect) {
-m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect));
+m_compact_unwind_up.reset(new CompactUnwindInfo(*object_file, sect));
   }
 
   sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
   if (sect) {
 SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
 if (sect_extab.get()) {
-  m_arm_unwind_up.reset(new ArmUnwindInfo(m_object_file, sect, sect_extab));
+  m_arm_unwind_up.reset(new ArmUnwindInfo(*object_file, sect, sect_extab));
 }
   }
 }
@@ -148,8 +151,7 @@
 
 void UnwindTable::Dump(Stream &s) {
   std::lock_guard guard(m_mutex);
-  s.Printf("UnwindTable for '%s':\n",
-   m_object_file.GetFileSpec().GetPath().c_str());
+  s.Format("UnwindTable for '{0}':\n", m_module.GetFileSpec());
   const_iterator begin = m_unwinds.begin();
   const_iterator end = m_unwinds.end();
   for (const_iterator pos = begin; pos != end; ++pos) {
@@ -179,10 +181,10 @@
   return m_arm_unwind_up.get();
 }
 
-ArchSpec UnwindTable::GetArchitecture() {
-  return m_object_file.GetArchitecture();
-}
+ArchSpec UnwindTable::GetArchitecture() { return m_module.GetArchitecture(); }
 
 bool UnwindTable::GetAllowAssemblyEmulationUnwindPlans() {
-  return m_object_file.AllowAssemblyEmulationUnwindPlans();
+  if (ObjectFile *object_file = m_module.GetObjectFile())
+return object_file->AllowAssemblyEmulationUnwindPlans();
+  return false;
 }
Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -263,8 +263,7 @@
 : ModuleChild(module_sp),
   m_file(), // This file could be different from the original module's file
   m_type(eTypeInvalid), m_strata(eStrataInvalid),
-  m_file_offset(file_offset), m_length(length), m_data(),
-  m_unwind_table(*this), m_process_wp(),
+  m_file_offset(file_offset), m_length(length), m_data(), m_process_wp(),
   m_memory_addr(LLDB_INVALID_ADDRESS), m_sections_up(), m_symtab_up(),
   m_synthetic_symbol_idx(0) {
   if (file_spec_ptr)
@@ -286,9 +285,8 @@
DataBufferSP &header_data_sp)
 : ModuleChild(module_sp), m_file(), m_type(eTypeInvalid),
   m_strata(eStrataInvalid), m_file_offset(0), m_length(0), m_data(),
-  m_unwind_table(*this), m_process_wp(process_sp),
-  m_memory_addr(header_addr), m_sections_up(), m_symtab_up(),
-  m_synthetic_symbol_idx(0) {
+  m_process_wp(process_sp), m_memory_addr(header_addr), m_sections_up(),
+  m_symtab_up(), m_synthetic_symbol_idx(0) {
   if (header_data_sp)
 m_data.SetDa

[Lldb-commits] [PATCH] D58129: Move UnwindTable from ObjectFile to Module

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added inline comments.



Comment at: include/lldb/Core/Module.h:709
+  //--
+  UnwindTable *GetUnwindTable();
+

clayborg wrote:
> I would vote to return a "UnwindTable&" and make a const and non const 
> version of this. Otherwise we have to NULL check any call to this API.
There isn't much point in having a const version of this, as all UnwindTable 
methods are non-const.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58129/new/

https://reviews.llvm.org/D58129



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


[Lldb-commits] [PATCH] D58167: Refactor user/group name resolving code

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: zturner, clayborg, jingham.
Herald added a subscriber: mgorny.

This creates an abstract base class called "UserIDResolver", which can
be implemented to provide user/group ID resolution capabilities for
various objects. Posix host implement a PosixUserIDResolver, which does
that using posix apis (getpwuid and friends).  PlatformGDBRemote
forwards queries over the gdb-remote link, etc. ProcessInstanceInfo
class is refactored to make use of this interface instead of taking a
platform pointer as an argument. The base resolver class already
implements caching and thread-safety, so implementations don't have to
worry about that.

The main motivating factor for this was to remove external dependencies
from the ProcessInstanceInfo class (so it can be put next to
ProcessLaunchInfo and friends), but it has other benefits too:

- ability to test the user name caching code
- ability to test ProcessInstanceInfo dumping code
- consistent interface for user/group resolution between Platform and Host 
classes.


https://reviews.llvm.org/D58167

Files:
  include/lldb/Host/HostInfoBase.h
  include/lldb/Host/UserIDResolver.h
  include/lldb/Host/posix/HostInfoPosix.h
  include/lldb/Target/Platform.h
  include/lldb/Target/Process.h
  include/lldb/Target/RemoteAwarePlatform.h
  source/Commands/CommandObjectPlatform.cpp
  source/Host/CMakeLists.txt
  source/Host/common/UserIDResolver.cpp
  source/Host/posix/HostInfoPosix.cpp
  source/Plugins/Platform/Kalimba/PlatformKalimba.h
  source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  source/Target/Platform.cpp
  source/Target/Process.cpp
  source/Target/RemoteAwarePlatform.cpp
  unittests/Host/CMakeLists.txt
  unittests/Host/UserIDResolverTest.cpp
  unittests/Target/CMakeLists.txt
  unittests/Target/ProcessInstanceInfoTest.cpp

Index: unittests/Target/ProcessInstanceInfoTest.cpp
===
--- /dev/null
+++ unittests/Target/ProcessInstanceInfoTest.cpp
@@ -0,0 +1,75 @@
+//===-- ProcessInstanceInfoTest.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Target/Process.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+namespace {
+/// A very simple resolver which fails for even ids and returns a simple string
+/// for odd ones.
+class DummyUserIDResolver : public UserIDResolver {
+protected:
+  llvm::Optional DoGetUserName(id_t Uid) {
+if (Uid % 2)
+  return ("user" + llvm::Twine(Uid)).str();
+return llvm::None;
+  }
+
+  llvm::Optional DoGetGroupName(id_t Uid) {
+if (Uid % 2)
+  return ("group" + llvm::Twine(Uid)).str();
+return llvm::None;
+  }
+};
+} // namespace
+
+TEST(ProcessInstanceInfo, Dump) {
+  ProcessInstanceInfo Info("a.out", ArchSpec("x86_64-pc-linux"), 47);
+  Info.SetUserID(1);
+  Info.SetEffectiveUserID(2);
+  Info.SetGroupID(3);
+  Info.SetEffectiveGroupID(4);
+
+  DummyUserIDResolver Resolver;
+  StreamString S;
+  Info.Dump(S, Resolver);
+  EXPECT_STREQ(R"(pid = 47
+   name = a.out
+   file = a.out
+   arch = x86_64-pc-linux
+uid = 1 (user1)
+gid = 3 (group3)
+   euid = 2 ()
+   egid = 4 ()
+)",
+   S.GetData());
+}
+
+TEST(ProcessInstanceInfo, DumpTable) {
+  ProcessInstanceInfo Info("a.out", ArchSpec("x86_64-pc-linux"), 47);
+  Info.SetUserID(1);
+  Info.SetEffectiveUserID(2);
+  Info.SetGroupID(3);
+  Info.SetEffectiveGroupID(4);
+
+  DummyUserIDResolver Resolver;
+  StreamString S;
+
+  const bool show_args = false;
+  const bool verbose = true;
+  ProcessInstanceInfo::DumpTableHeader(S, show_args, verbose);
+  Info.DumpAsTableRow(S, Resolver, show_args, verbose);
+  EXPECT_STREQ(
+  R"(PIDPARENT USER   GROUP  EFF USER   EFF GROUP  TRIPLE   ARGUMENTS
+== == == == == ==  
+47 0  user1  group3 2  4  x86_64-pc-linux  
+)",
+  S.GetData());
+}
Index: unittests/Target/CMakeLists.txt
===
--- unittests/Target/CMakeLists.txt
+++ unittests/Target/CMakeLists.txt
@@ -2,6 +2,7 @@
   MemoryRegionInfoTest.cpp
   ModuleCacheTest.cpp
   PathMappingListTest.cpp
+  ProcessInstanceInfoTest.cpp
 
   LINK_LIBS
   lldbCore
Index: unittests/Host/UserIDResolverTest.cpp
===
--- /dev/null
+++ unittests/Host/UserIDResolverTest.cpp
@@ -0,0 +1,47 @@
+//===-- 

[Lldb-commits] [PATCH] D58172: Embed swig version into lldb.py in a different way

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: zturner, jingham.
Herald added a reviewer: serge-sans-paille.
Herald added a subscriber: jdoerfert.

Instead of doing string chopping on the resulting python file, get swig
to output the version for us. The two things which make slightly
non-trivial are:

- in order to get swig to expand SWIG_VERSION for us, we cannot use %pythoncode 
directly, but we have to go through an intermediate macro.
- SWIG_VERSION is a hex number, but it's components are supposed to be 
interpreted decimally, so there is a bit of integer magic needed to get the 
right number to come out.

I've tested that this approach works both with the latest (3.0.12) and
oldest (1.3.40) supported swig.


https://reviews.llvm.org/D58172

Files:
  scripts/Python/modify-python-lldb.py
  scripts/lldb.swig


Index: scripts/lldb.swig
===
--- scripts/lldb.swig
+++ scripts/lldb.swig
@@ -66,6 +66,21 @@
 
 import six
 %}
+
+// Include the version of swig that was used to generate this interface.
+%define EMBED_VERSION(VERSION)
+%pythoncode%{
+# SWIG_VERSION is written as a single hex number, but the components of it are
+# meant to be interpreted in decimal. So, 0x030012 is swig 3.0.12, and not
+# 3.0.18.
+def _to_int(hex):
+return hex // 0x10 % 0x10 * 10 + hex % 0x10
+swig_version = (_to_int(VERSION // 0x1), _to_int(VERSION // 0x100), 
_to_int(VERSION))
+del _to_int
+%}
+%enddef
+EMBED_VERSION(SWIG_VERSION)
+
 %include "./Python/python-typemaps.swig"
 
 /* C++ headers to be included. */
Index: scripts/Python/modify-python-lldb.py
===
--- scripts/Python/modify-python-lldb.py
+++ scripts/Python/modify-python-lldb.py
@@ -44,11 +44,6 @@
 
 # print "output_name is '" + output_name + "'"
 
-#
-# Version string
-#
-version_line = "swig_version = %s"
-
 #
 # Residues to be removed.
 #
@@ -338,7 +333,6 @@
 isvalid_pattern = re.compile("^def IsValid\(")
 
 # These define the states of our finite state machine.
-EXPECTING_VERSION = 0
 NORMAL = 1
 DEFINING_ITERATOR = 2
 DEFINING_EQUALITY = 4
@@ -364,9 +358,8 @@
 # The FSM, in all possible states, also checks the current input for IsValid()
 # definition, and inserts a __nonzero__() method definition to implement truth
 # value testing and the built-in operation bool().
-state = EXPECTING_VERSION
+state = NORMAL
 
-swig_version_tuple = None
 for line in content.splitlines():
 # Handle the state transition into CLEANUP_DOCSTRING state as it is 
possible
 # to enter this state from either NORMAL or DEFINING_ITERATOR/EQUALITY.
@@ -383,20 +376,6 @@
 else:
 state |= CLEANUP_DOCSTRING
 
-if state == EXPECTING_VERSION:
-# We haven't read the version yet, read it now.
-if swig_version_tuple is None:
-match = version_pattern.search(line)
-if match:
-v = match.group(1)
-swig_version_tuple = tuple(map(int, (v.split("."
-elif not line.startswith('#'):
-# This is the first non-comment line after the header.  Inject the
-# version
-new_line = version_line % str(swig_version_tuple)
-new_content.add_line(new_line)
-state = NORMAL
-
 if state == NORMAL:
 match = class_pattern.search(line)
 # Inserts lldb_helpers and the lldb_iter() definition before the first


Index: scripts/lldb.swig
===
--- scripts/lldb.swig
+++ scripts/lldb.swig
@@ -66,6 +66,21 @@
 
 import six
 %}
+
+// Include the version of swig that was used to generate this interface.
+%define EMBED_VERSION(VERSION)
+%pythoncode%{
+# SWIG_VERSION is written as a single hex number, but the components of it are
+# meant to be interpreted in decimal. So, 0x030012 is swig 3.0.12, and not
+# 3.0.18.
+def _to_int(hex):
+return hex // 0x10 % 0x10 * 10 + hex % 0x10
+swig_version = (_to_int(VERSION // 0x1), _to_int(VERSION // 0x100), _to_int(VERSION))
+del _to_int
+%}
+%enddef
+EMBED_VERSION(SWIG_VERSION)
+
 %include "./Python/python-typemaps.swig"
 
 /* C++ headers to be included. */
Index: scripts/Python/modify-python-lldb.py
===
--- scripts/Python/modify-python-lldb.py
+++ scripts/Python/modify-python-lldb.py
@@ -44,11 +44,6 @@
 
 # print "output_name is '" + output_name + "'"
 
-#
-# Version string
-#
-version_line = "swig_version = %s"
-
 #
 # Residues to be removed.
 #
@@ -338,7 +333,6 @@
 isvalid_pattern = re.compile("^def IsValid\(")
 
 # These define the states of our finite state machine.
-EXPECTING_VERSION = 0
 NORMAL = 1
 DEFINING_ITERATOR = 2
 DEFINING_EQUALITY = 4
@@ -364,9 +358,8 @@
 # The FSM, in all possible states, also checks the current input for IsValid()
 # definition, and inserts a __nonzero__() method definition to implement truth
 # val

[Lldb-commits] [lldb] r353944 - Fix one more string/bytes issue in lldb-server tests

2019-02-13 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Feb 13 04:54:59 2019
New Revision: 353944

URL: http://llvm.org/viewvc/llvm-project?rev=353944&view=rev
Log:
Fix one more string/bytes issue in lldb-server tests

This fixes about a dozen tests with python3.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py?rev=353944&r1=353943&r2=353944&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
 Wed Feb 13 04:54:59 2019
@@ -174,7 +174,7 @@ class SocketPacketPump(object):
 can_read, _, _ = select.select([self._socket], [], [], 0)
 if can_read and self._socket in can_read:
 try:
-new_bytes = self._socket.recv(4096)
+new_bytes = self._socket.recv(4096).decode("utf-8")
 if self._logger and new_bytes and len(new_bytes) > 0:
 self._logger.debug(
 "pump received bytes: {}".format(new_bytes))


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


[Lldb-commits] [lldb] r353945 - Revert "Fix one more string/bytes issue in lldb-server tests"

2019-02-13 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Feb 13 05:06:37 2019
New Revision: 353945

URL: http://llvm.org/viewvc/llvm-project?rev=353945&view=rev
Log:
Revert "Fix one more string/bytes issue in lldb-server tests"

It looks like I was too hasty to submit the previous patch. It does fix
some tests on python3, but it also breaks one tests with python2.

This happens because the gdb-remote protocol can sometimes (but not very
often) contain binary data, and attempting to parse this as utf8
characters fails.

This reverts commit r353944.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py?rev=353945&r1=353944&r2=353945&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
 Wed Feb 13 05:06:37 2019
@@ -174,7 +174,7 @@ class SocketPacketPump(object):
 can_read, _, _ = select.select([self._socket], [], [], 0)
 if can_read and self._socket in can_read:
 try:
-new_bytes = self._socket.recv(4096).decode("utf-8")
+new_bytes = self._socket.recv(4096)
 if self._logger and new_bytes and len(new_bytes) > 0:
 self._logger.debug(
 "pump received bytes: {}".format(new_bytes))


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


[Lldb-commits] [PATCH] D58177: Fix lldb-server test suite for python3

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: davide, zturner.
Herald added a reviewer: serge-sans-paille.

This patch finishes the python3-ification of the lldb-server test suite.
It reverts the partial attempt in r352709 to encode/decode the string
via utf8 before writing to the socket. This wasn't enough because the
gdb-remote protocol can sometimes (but not very often) carry binary
data, and the utf8 codec chokes on that. Instead I add utility functions
to the "seven" module for performing "identity" transformations on the
byte data. This basically drills back the hole in the python type system
that the string/bytes distinction was supposed to plug. That is not
ideal, but was the best solution of the alternatives I could come up
with. The options I considered were:

- make use of the type system to add type safety to the test suite: This 
required making a lot of changes to the test suite, since most of the strings 
would now become byte objects instead, and it was not even fully clear to me 
where to draw the line. One extreme solution would be to just use byte objects 
everywhere, as the protocol doesn't support non-ascii characters anyway. 
However, this appeared to be: a) weird, because most of the protocol actually 
deals with strings, but we would have to prefix everything with 'b' b) clunky, 
because the handling of the bytes objects is sufficiently different in PY2 and 
PY3 (e.g. b'a'[0] is a string in PY2, but an int in PY3).
- using the latin1 codec (which gives an identity transformation for the first 
256 code points of unicode) instead of the custom bytes_to_string functions. 
This almost could work, but it was still slightly different between python 2 
and 3, because in PY2 in would return a unicode object, which would then cause 
problems when combined with regular strings if it contained 8-bit chars.

With this in mind, I think the best solution for the time being is to
just coerce everything into the string type as early as possible, and
have things proceed indentically on both python versions. Once we stop
supporting python3, we can revisit the idea of using bytes objects more
prevasively.


https://reviews.llvm.org/D58177

Files:
  packages/Python/lldbsuite/support/seven.py
  packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
  packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
  packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
  packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py

Index: packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
@@ -9,6 +9,7 @@
 import codecs
 
 from six.moves import queue
+from lldbsuite.support import seven
 
 
 def _handle_output_packet_string(packet_contents):
@@ -19,7 +20,7 @@
 elif packet_contents == "OK":
 return None
 else:
-return packet_contents[1:].decode("hex")
+return seven.unhexlify(packet_contents[1:])
 
 
 def _dump_queue(the_queue):
@@ -174,7 +175,7 @@
 can_read, _, _ = select.select([self._socket], [], [], 0)
 if can_read and self._socket in can_read:
 try:
-new_bytes = self._socket.recv(4096)
+new_bytes = seven.bytes_to_string(self._socket.recv(4096))
 if self._logger and new_bytes and len(new_bytes) > 0:
 self._logger.debug(
 "pump received bytes: {}".format(new_bytes))
Index: packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -412,7 +412,7 @@
 value = value >> 8
 if byte_size:
 # Add zero-fill to the right/end (MSB side) of the value.
-retval += "00" * (byte_size - len(retval) / 2)
+retval += "00" * (byte_size - len(retval) // 2)
 return retval
 
 elif endian == 'big':
@@ -422,7 +422,7 @@
 value = value >> 8
 if byte_size:
 # Add zero-fill to the left/front (MSB side) of the value.
-retval = ("00" * (byte_size - len(retval) / 2)) + retval
+retval = ("00" * (byte_size - len(retval) // 2)) + retval
 return retval
 
 else:
Index: packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/g

[Lldb-commits] [PATCH] D58177: Fix lldb-server test suite for python3

2019-02-13 Thread serge via Phabricator via lldb-commits
serge-sans-paille added inline comments.



Comment at: 
packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py:415
 # Add zero-fill to the right/end (MSB side) of the value.
-retval += "00" * (byte_size - len(retval) / 2)
+retval += "00" * (byte_size - len(retval) // 2)
 return retval

Maybe `from __future__ import division` to make sure the `/` operator behaves 
consistently across versions? That way it may uncover missed `/` to `//` 
conversion?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58177/new/

https://reviews.llvm.org/D58177



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


[Lldb-commits] [PATCH] D58172: Embed swig version into lldb.py in a different way

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 186676.
labath added a comment.

Include a basic test for this functionality I forgot to add


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58172/new/

https://reviews.llvm.org/D58172

Files:
  packages/Python/lldbsuite/test/python_api/lldbutil/TestSwigVersion.py
  scripts/Python/modify-python-lldb.py
  scripts/lldb.swig

Index: scripts/lldb.swig
===
--- scripts/lldb.swig
+++ scripts/lldb.swig
@@ -66,6 +66,21 @@
 
 import six
 %}
+
+// Include the version of swig that was used to generate this interface.
+%define EMBED_VERSION(VERSION)
+%pythoncode%{
+# SWIG_VERSION is written as a single hex number, but the components of it are
+# meant to be interpreted in decimal. So, 0x030012 is swig 3.0.12, and not
+# 3.0.18.
+def _to_int(hex):
+return hex // 0x10 % 0x10 * 10 + hex % 0x10
+swig_version = (_to_int(VERSION // 0x1), _to_int(VERSION // 0x100), _to_int(VERSION))
+del _to_int
+%}
+%enddef
+EMBED_VERSION(SWIG_VERSION)
+
 %include "./Python/python-typemaps.swig"
 
 /* C++ headers to be included. */
Index: scripts/Python/modify-python-lldb.py
===
--- scripts/Python/modify-python-lldb.py
+++ scripts/Python/modify-python-lldb.py
@@ -44,11 +44,6 @@
 
 # print "output_name is '" + output_name + "'"
 
-#
-# Version string
-#
-version_line = "swig_version = %s"
-
 #
 # Residues to be removed.
 #
@@ -338,7 +333,6 @@
 isvalid_pattern = re.compile("^def IsValid\(")
 
 # These define the states of our finite state machine.
-EXPECTING_VERSION = 0
 NORMAL = 1
 DEFINING_ITERATOR = 2
 DEFINING_EQUALITY = 4
@@ -364,9 +358,8 @@
 # The FSM, in all possible states, also checks the current input for IsValid()
 # definition, and inserts a __nonzero__() method definition to implement truth
 # value testing and the built-in operation bool().
-state = EXPECTING_VERSION
+state = NORMAL
 
-swig_version_tuple = None
 for line in content.splitlines():
 # Handle the state transition into CLEANUP_DOCSTRING state as it is possible
 # to enter this state from either NORMAL or DEFINING_ITERATOR/EQUALITY.
@@ -383,20 +376,6 @@
 else:
 state |= CLEANUP_DOCSTRING
 
-if state == EXPECTING_VERSION:
-# We haven't read the version yet, read it now.
-if swig_version_tuple is None:
-match = version_pattern.search(line)
-if match:
-v = match.group(1)
-swig_version_tuple = tuple(map(int, (v.split("."
-elif not line.startswith('#'):
-# This is the first non-comment line after the header.  Inject the
-# version
-new_line = version_line % str(swig_version_tuple)
-new_content.add_line(new_line)
-state = NORMAL
-
 if state == NORMAL:
 match = class_pattern.search(line)
 # Inserts lldb_helpers and the lldb_iter() definition before the first
Index: packages/Python/lldbsuite/test/python_api/lldbutil/TestSwigVersion.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/python_api/lldbutil/TestSwigVersion.py
@@ -0,0 +1,28 @@
+"""
+Test that we embed the swig version into the lldb module
+"""
+
+from __future__ import print_function
+
+"""
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbutil
+"""
+from lldbsuite.test.lldbtest import *
+
+class SwigVersionTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_lldb_iter_module(self):
+self.assertTrue(getattr(lldb, "swig_version"))
+self.assertIsInstance(lldb.swig_version, tuple)
+self.assertEqual(len(lldb.swig_version), 3)
+self.assertGreaterEqual(lldb.swig_version[0], 1)
+for v in lldb.swig_version:
+self.assertGreaterEqual(v, 0)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r353778 - Define _ENABLE_EXTENDED_ALIGNED_STORAGE on Windows.

2019-02-13 Thread Jonas Devlieghere via lldb-commits
Hi Pavel,

I think the offending struct is XSAVE in RegisterContext_x86.h. I don't
really know this code, would you mind having a look? It looks like you
touched the alignment in the past and seems to know what this this is doing
:-)

tree f8fc1af1c62b728260b6c950649c55f7aba513f6
parent 6857692687979d934e188d117eadc93f48d52a0c
author Pavel Labath  Wed Sep 12 08:50:08 2018 +
committer Pavel Labath  Wed Sep 12 08:50:08 2018 +

Reduce alignment on struct XSAVE, fixing a gcc warning

The warning is about heap-allocating a struct with bigger alignment
requirements than the standard heap allocator provides.

AFAICT, all uses of the XSAVE struct are already heap-allocated, so this
high alignment does not actually have any effect and removing it should
be NFC.

I have also done some digging in the commit history. This alignment
requirement was since the XSAVE struct was introduced in r180572 when
adding AVX register support for linux. It does not mention the alignment
specifically, so I am guessing this was just put there because the
corresponging XSAVE cpu instruction requires its buffer to be 64-byte
aligned. However, LLDB will not be normally reading this struct via the
XSAVE instruction directly. Instead we will ask the kernel to copy the
buffer saved when suspeding the inferior. This should not require such
strict alignment (in fact, linux kernel will happily do this for any
alignment).

llvm-svn: 342029





On Mon, Feb 11, 2019 at 10:55 PM Pavel Labath  wrote:

> On 12/02/2019 01:30, Jonas Devlieghere via lldb-commits wrote:
> > Author: jdevlieghere
> > Date: Mon Feb 11 16:30:21 2019
> > New Revision: 353778
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=353778&view=rev
> > Log:
> > Define _ENABLE_EXTENDED_ALIGNED_STORAGE on Windows.
> >
> > Apparently there are multiple places where MSVC complains about
> > instantiations with extended aligment. I think it's better to define
> > `_ENABLE_EXTENDED_ALIGNED_STORAGE` as suggested by the error message.
> >
> > I don't have access to a Windows machine so this is all speculative.
> >
>
> I think it would be worth investigating where is this large alignment
> coming from (my guess: something inside the RegisterContextDarwin
> structs). We've had a case in the past where we were heap-allocating a
> struct with a 64-byte alignment. MSVC would give a warning there, but
> gcc&clang would silently under-align the result.
>
> In that case, the large alignment was actually unneeded, so I fixed both
> issues by just lowering it. I suspect something similar may be possible
> here.
>
> pl
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D58090: Deserialize Clang module search path from DWARF

2019-02-13 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I think the problem was that I had an incompletely built libcxx in my build 
directory.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58090/new/

https://reviews.llvm.org/D58090



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


[Lldb-commits] [PATCH] D58193: Do not explicitly depend on llvm tools during standalone build

2019-02-13 Thread serge via Phabricator via lldb-commits
serge-sans-paille created this revision.
serge-sans-paille added a reviewer: labath.
Herald added subscribers: lldb-commits, mgorny.
Herald added a reviewer: alexshap.
Herald added a project: LLDB.

When building lldb in standalone mode, the llvm-nm, llvm-objdump etc target are 
not available, so only conditionnaly include them.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D58193

Files:
  lit/CMakeLists.txt


Index: lit/CMakeLists.txt
===
--- lit/CMakeLists.txt
+++ lit/CMakeLists.txt
@@ -19,18 +19,23 @@
 
 list(APPEND LLDB_TEST_DEPS
   LLDBUnitTests
-  dsymutil
-  llc
   lldb
   lldb-test
-  llvm-config
-  llvm-mc
-  llvm-objcopy
-  FileCheck
-  count
-  not
   )
 
+if (NOT LLDB_BUILT_STANDALONE)
+  list(APPEND LLDB_TEST_DEPS
+dsymutil
+llc
+llvm-config
+llvm-mc
+llvm-objcopy
+FileCheck
+count
+not
+)
+endif()
+
 if(TARGET lld)
   list(APPEND LLDB_TEST_DEPS lld)
 endif()


Index: lit/CMakeLists.txt
===
--- lit/CMakeLists.txt
+++ lit/CMakeLists.txt
@@ -19,18 +19,23 @@
 
 list(APPEND LLDB_TEST_DEPS
   LLDBUnitTests
-  dsymutil
-  llc
   lldb
   lldb-test
-  llvm-config
-  llvm-mc
-  llvm-objcopy
-  FileCheck
-  count
-  not
   )
 
+if (NOT LLDB_BUILT_STANDALONE)
+  list(APPEND LLDB_TEST_DEPS
+dsymutil
+llc
+llvm-config
+llvm-mc
+llvm-objcopy
+FileCheck
+count
+not
+)
+endif()
+
 if(TARGET lld)
   list(APPEND LLDB_TEST_DEPS lld)
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r353961 - Deserialize Clang module search path from DWARF

2019-02-13 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Feb 13 10:10:41 2019
New Revision: 353961

URL: http://llvm.org/viewvc/llvm-project?rev=353961&view=rev
Log:
Deserialize Clang module search path from DWARF

This patch properly extracts the full submodule path as well as its
search paths from DWARF import decls and passes it on to the
ClangModulesDeclVendor.

rdar://problem/47970144

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

Added:
lldb/trunk/include/lldb/Symbol/SourceModule.h
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/modules-import/
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/modules-import/Foo.h
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/modules-import/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap
Modified:
lldb/trunk/include/lldb/Symbol/CompileUnit.h
lldb/trunk/include/lldb/Symbol/SymbolFile.h
lldb/trunk/include/lldb/Symbol/SymbolVendor.h
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
lldb/trunk/source/Symbol/CompileUnit.cpp
lldb/trunk/source/Symbol/SymbolVendor.cpp

Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompileUnit.h?rev=353961&r1=353960&r2=353961&view=diff
==
--- lldb/trunk/include/lldb/Symbol/CompileUnit.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompileUnit.h Wed Feb 13 10:10:41 2019
@@ -266,7 +266,7 @@ public:
   /// @return
   /// A list of imported module names.
   //--
-  const std::vector &GetImportedModules();
+  const std::vector &GetImportedModules();
 
   //--
   /// Get the SymbolFile plug-in user data.
@@ -414,28 +414,29 @@ public:
   size_t GetNumFunctions() const { return m_functions_by_uid.size(); }
 
 protected:
-  void *m_user_data; ///< User data for the SymbolFile parser to store
- ///information into.
-  lldb::LanguageType
-  m_language; ///< The programming language enumeration value.
-  Flags m_flags;  ///< Compile unit flags that help with partial parsing.
-
+  /// User data for the SymbolFile parser to store information into.
+  void *m_user_data;
+  /// The programming language enumeration value.
+  lldb::LanguageType m_language;
+  /// Compile unit flags that help with partial parsing.
+  Flags m_flags;
   /// Maps UIDs to functions.
   llvm::DenseMap m_functions_by_uid;
-  std::vector m_imported_modules; ///< All modules, including the
-   ///current module, imported by
-   ///this
-   ///< compile unit.
-  FileSpecList m_support_files; ///< Files associated with this compile unit's
-///line table and declarations.
-  std::unique_ptr
-  m_line_table_up; ///< Line table that will get parsed on demand.
-  DebugMacrosSP
-  m_debug_macros_sp; ///< Debug macros that will get parsed on demand.
-  lldb::VariableListSP m_variables; ///< Global and static variable list that
-///will get parsed on demand.
-  lldb_private::LazyBool m_is_optimized; /// eLazyBoolYes if this compile unit
- /// was compiled with optimization.
+  /// All modules, including the current module, imported by this
+  /// compile unit.
+  std::vector m_imported_modules;
+  /// Files associated with this compile unit's line table and
+  /// declarations.
+  FileSpecList m_support_files;
+  /// Line table that will get parsed on demand.
+  std::unique_ptr m_line_table_up;
+  /

[Lldb-commits] [PATCH] D58177: Fix lldb-server test suite for python3

2019-02-13 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58177/new/

https://reviews.llvm.org/D58177



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


[Lldb-commits] [PATCH] D58090: Deserialize Clang module search path from DWARF

2019-02-13 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB353961: Deserialize Clang module search path from DWARF 
(authored by adrian, committed by ).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D58090?vs=186571&id=186691#toc

Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58090/new/

https://reviews.llvm.org/D58090

Files:
  include/lldb/Symbol/CompileUnit.h
  include/lldb/Symbol/SourceModule.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/SymbolVendor.h
  packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h
  packages/Python/lldbsuite/test/lang/cpp/modules-import/Foo.h
  packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile
  packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py
  packages/Python/lldbsuite/test/lang/cpp/modules-import/main.cpp
  packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
  source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
  source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
  source/Symbol/CompileUnit.cpp
  source/Symbol/SymbolVendor.cpp

Index: source/Symbol/SymbolVendor.cpp
===
--- source/Symbol/SymbolVendor.cpp
+++ source/Symbol/SymbolVendor.cpp
@@ -185,7 +185,7 @@
 }
 
 bool SymbolVendor::ParseImportedModules(
-const SymbolContext &sc, std::vector &imported_modules) {
+const SymbolContext &sc, std::vector &imported_modules) {
   ModuleSP module_sp(GetModule());
   if (module_sp) {
 std::lock_guard guard(module_sp->GetMutex());
Index: source/Symbol/CompileUnit.cpp
===
--- source/Symbol/CompileUnit.cpp
+++ source/Symbol/CompileUnit.cpp
@@ -390,7 +390,7 @@
   m_variables = variables;
 }
 
-const std::vector &CompileUnit::GetImportedModules() {
+const std::vector &CompileUnit::GetImportedModules() {
   if (m_imported_modules.empty() &&
   m_flags.IsClear(flagsParsedImportedModules)) {
 m_flags.Set(flagsParsedImportedModules);
Index: source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -28,6 +28,7 @@
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/SourceModule.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBAssert.h"
@@ -71,7 +72,7 @@
 
   ~ClangModulesDeclVendorImpl() override = default;
 
-  bool AddModule(ModulePath &path, ModuleVector *exported_modules,
+  bool AddModule(const SourceModule &module, ModuleVector *exported_modules,
  Stream &error_stream) override;
 
   bool AddModulesForCompileUnit(CompileUnit &cu, ModuleVector &exported_modules,
@@ -184,7 +185,7 @@
   }
 }
 
-bool ClangModulesDeclVendorImpl::AddModule(ModulePath &path,
+bool ClangModulesDeclVendorImpl::AddModule(const SourceModule &module,
ModuleVector *exported_modules,
Stream &error_stream) {
   // Fail early.
@@ -199,7 +200,7 @@
 
   std::vector imported_module;
 
-  for (ConstString path_component : path) {
+  for (ConstString path_component : module.path) {
 imported_module.push_back(path_component);
   }
 
@@ -214,11 +215,34 @@
 }
   }
 
-  if (!m_compiler_instance->getPreprocessor()
-   .getHeaderSearchInfo()
-   .lookupModule(path[0].GetStringRef())) {
+  clang::HeaderSearch &HS =
+m_compiler_instance->getPreprocessor().getHeaderSearchInfo();
+
+  if (module.search_path) {
+auto path_begin = llvm::sys::path::begin(module.search_path.GetStringRef());
+auto path_end = llvm::sys::path::end(module.search_path.GetStringRef());
+auto sysroot_begin = llvm::sys::path::begin(module.sysroot.GetStringRef());
+auto sysroot_end = llvm::sys::path::end(module.sysroot.GetStringRef());
+// FIXME: Use C++14 std::equal(it, it, it, it) variant once it's available.
+bool is_system_module = (std::distance(p

[Lldb-commits] [PATCH] D58177: Fix lldb-server test suite for python3

2019-02-13 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova requested changes to this revision.
stella.stamenova added inline comments.
This revision now requires changes to proceed.



Comment at: packages/Python/lldbsuite/support/seven.py:28
+
+def bytes_to_string(b):
+"""Take a string(PY2) or a bytes(PY3) object and return a string."""

There are other places in the lldb test suite and lit where similar functions 
are defined. Rather than just adding new ones here, can you normalize them and 
perhaps use your functions everywhere instead of ending up with two (or three) 
solutions?

One place that comes to mind is lit\helper\build.py: to_string. There are 
others as well that implement conversions in-place and usually use isinstance 
to determine what to do.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58177/new/

https://reviews.llvm.org/D58177



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


[Lldb-commits] [PATCH] D58090: Deserialize Clang module search path from DWARF

2019-02-13 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

This looks to have broken the windows build:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/1665


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58090/new/

https://reviews.llvm.org/D58090



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


[Lldb-commits] [PATCH] D57402: build: remove custom variables

2019-02-13 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd added a comment.

@labath - absolutely, that I don't have a problem with.  I think that having 
the additional LLDB specific paths with `LLDB_PATH_TO_*` is better done by 
using the standard CMake mechanisms.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57402/new/

https://reviews.llvm.org/D57402



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


[Lldb-commits] [PATCH] D58167: Refactor user/group name resolving code

2019-02-13 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

You are using a mix of llvm & lldb naming conventions for local variables and 
arguments and the ivars of UserIDResolver (lots of "Uid", etc...)  Probably 
better to stick with the lldb convention.

Other than that it looks good to me.




Comment at: 
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp:439
   if (uid != UINT32_MAX) {
-std::string name;
-if (HostInfo::LookupUserName(uid, name)) {
+if (auto name = HostInfo::GetUserIDResolver().GetUserName(uid)) {
   StreamString response;

Do we need auto here?  Since we have a bunch of API's returning StringRef's now 
when I see strings returned I get paranoid about their lifespan.  auto hides 
the fact that I don't need to worry...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58167/new/

https://reviews.llvm.org/D58167



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


[Lldb-commits] [lldb] r353971 - Add missing include

2019-02-13 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Feb 13 11:29:22 2019
New Revision: 353971

URL: http://llvm.org/viewvc/llvm-project?rev=353971&view=rev
Log:
Add missing include

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h?rev=353971&r1=353970&r2=353971&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h 
Wed Feb 13 11:29:22 2019
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/ClangForward.h"
 #include "lldb/Symbol/DeclVendor.h"
+#include "lldb/Symbol/SourceModule.h"
 #include "lldb/Target/Platform.h"
 
 #include 


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


[Lldb-commits] [PATCH] D58090: Deserialize Clang module search path from DWARF

2019-02-13 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I attempted to fix it in r353971, but I'm not sure.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58090/new/

https://reviews.llvm.org/D58090



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


[Lldb-commits] [PATCH] D58167: Refactor user/group name resolving code

2019-02-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: include/lldb/Host/UserIDResolver.h:24
+public:
+  typedef uint32_t id_t;
+  virtual ~UserIDResolver(); // anchor

make this 64 bit for future proofing? And if so, just use lldb::user_id_t?



Comment at: include/lldb/Host/UserIDResolver.h:27
+
+  llvm::Optional GetUserName(id_t Uid) {
+return Get(Uid, UidCache, &UserIDResolver::DoGetUserName);

If we are storing this as an optional std::string, why hand it out as a 
StringRef?



Comment at: include/lldb/Host/UserIDResolver.h:49-51
+  std::mutex Mutex;
+  Map UidCache;
+  Map GidCache;

prefix with "m_", make lower case and separate by "_"



Comment at: source/Commands/CommandObjectPlatform.cpp:1154
 if (platform_sp->GetProcessInfo(pid, proc_info)) {
-  ProcessInstanceInfo::DumpTableHeader(ostrm, platform_sp.get(),
-   m_options.show_args,
+  ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);

Why are we not passing the platform in still? What if we need it for something 
else?



Comment at: source/Commands/CommandObjectPlatform.cpp:1156
m_options.verbose);
-  proc_info.DumpAsTableRow(ostrm, platform_sp.get(),
+  proc_info.DumpAsTableRow(ostrm, platform_sp->GetUserIDResolver(),
m_options.show_args, m_options.verbose);

Ditto



Comment at: source/Host/CMakeLists.txt:23
   common/FileCache.cpp
+  common/File.cpp
   common/FileSystem.cpp

remove whitespace change unless it is needed?



Comment at: source/Host/CMakeLists.txt:37
   common/NativeThreadProtocol.cpp
+  common/NativeWatchpointList.cpp
   common/OptionParser.cpp

remove whitespace change unless it is needed?



Comment at: source/Host/CMakeLists.txt:45
   common/SocketAddress.cpp
+  common/Socket.cpp
   common/StringConvert.cpp

remove whitespace change unless it is needed?



Comment at: source/Target/Process.cpp:281
 
-void ProcessInstanceInfo::Dump(Stream &s, Platform *platform) const {
-  const char *cstr;
+void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const {
   if (m_pid != LLDB_INVALID_PROCESS_ID)

So we are currently only using the platform for the user ID resolving, but it 
might be nice to keep the platform as the argument in case we need it for 
something else in the future?



Comment at: source/Target/Process.cpp:352
 
-void ProcessInstanceInfo::DumpAsTableRow(Stream &s, Platform *platform,
+void ProcessInstanceInfo::DumpAsTableRow(Stream &s, UserIDResolver &resolver,
  bool show_args, bool verbose) const {

Ditto


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58167/new/

https://reviews.llvm.org/D58167



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


[Lldb-commits] [PATCH] D58129: Move UnwindTable from ObjectFile to Module

2019-02-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Just a question of if we need an optional unwind table instance instead of just 
an instance. I am fine either way.




Comment at: include/lldb/Core/Module.h:1108-1110
+  llvm::Optional m_unwind_table; /// < Table of FuncUnwinders
+  /// objects created for this
+  /// Module's functions

Any reason to not just have a UnwindTable instance here? The accessor can't 
fail, so one must be created anyway right?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58129/new/

https://reviews.llvm.org/D58129



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


[Lldb-commits] [PATCH] D58193: Do not explicitly depend on llvm tools during standalone build

2019-02-13 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a reviewer: sgraenitz.
xiaobai added a comment.

I think you might need to rebase this patch because D57233 
 seems to accomplish part of what this patch 
does, but I don't see those changes here.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58193/new/

https://reviews.llvm.org/D58193



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


[Lldb-commits] [lldb] r353978 - [CMake] Make lldb-test-deps a dependency of check-lldb

2019-02-13 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Feb 13 12:51:13 2019
New Revision: 353978

URL: http://llvm.org/viewvc/llvm-project?rev=353978&view=rev
Log:
[CMake] Make lldb-test-deps a dependency of check-lldb

We have a custom target for lldb's test dependencies but it must have
gotten lost in one of the recent CMake refactorings.

Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/test/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=353978&r1=353977&r2=353978&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed Feb 13 12:51:13 2019
@@ -128,7 +128,7 @@ if(LLDB_INCLUDE_TESTS)
 list(APPEND LLDB_TEST_DEPS dsymutil)
   endif()
 
-  add_custom_target(lldb-test-depends DEPENDS ${LLDB_TEST_DEPS})
+  add_custom_target(lldb-test-deps DEPENDS ${LLDB_TEST_DEPS})
 
   add_subdirectory(test)
   add_subdirectory(unittests)

Modified: lldb/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=353978&r1=353977&r2=353978&view=diff
==
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Wed Feb 13 12:51:13 2019
@@ -115,6 +115,9 @@ add_python_test_target(check-lldb-single
 # output is desired (i.e. in continuous integration contexts) 
check-lldb-single is a better target.
 add_custom_target(check-lldb)
 
+# Make check-lldb depend on all test dependencies.
+add_dependencies(check-lldb lldb-test-deps)
+
 # If we're building with an in-tree clang, then list clang as a dependency
 # to run tests.
 if (TARGET clang)


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


[Lldb-commits] [lldb] r353979 - Add missing include

2019-02-13 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Feb 13 12:52:41 2019
New Revision: 353979

URL: http://llvm.org/viewvc/llvm-project?rev=353979&view=rev
Log:
Add missing include

Modified:
lldb/trunk/include/lldb/Symbol/CompileUnit.h

Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompileUnit.h?rev=353979&r1=353978&r2=353979&view=diff
==
--- lldb/trunk/include/lldb/Symbol/CompileUnit.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompileUnit.h Wed Feb 13 12:52:41 2019
@@ -13,6 +13,7 @@
 #include "lldb/Core/ModuleChild.h"
 #include "lldb/Symbol/DebugMacros.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SourceModule.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-enumerations.h"


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


[Lldb-commits] [PATCH] D58219: [dotest] Fix compiler version number comparison

2019-02-13 Thread Frederic Riss via Phabricator via lldb-commits
friss created this revision.
friss added reviewers: zturner, labath.
Herald added a reviewer: serge-sans-paille.
Herald added a subscriber: jdoerfert.

dotest's version comparision function is just a lexicographical compare
of the version strings. This is obviously wrong. This patch implements
a numerical comparision of the individual version components instead.

Python is not my language of choice, please suggest a better implementation!


https://reviews.llvm.org/D58219

Files:
  packages/Python/lldbsuite/test/lldbtest.py


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1351,14 +1351,31 @@
 
 if (version is None):
 return True
+
+def compare_version_strings(v1, v2):
+split1 = v1.split('.')
+split2 = v2.split('.')
+while len(split1) > len(split2):
+split2.append("0")
+while len(split2) > len(split1):
+split1.append("0")
+
+versions = zip(split1, split2)
+for (subv1, subv2) in versions:
+diff = int(subv1) - int(subv2)
+if diff != 0:
+return diff
+
+return 0
+
 if (operator == '>'):
-return self.getCompilerVersion() > version
+return compare_version_strings(self.getCompilerVersion(), version) 
> 0
 if (operator == '>=' or operator == '=>'):
-return self.getCompilerVersion() >= version
+return compare_version_strings(self.getCompilerVersion(), version) 
>= 0
 if (operator == '<'):
-return self.getCompilerVersion() < version
+return compare_version_strings(self.getCompilerVersion(), version) 
< 0
 if (operator == '<=' or operator == '=<'):
-return self.getCompilerVersion() <= version
+return compare_version_strings(self.getCompilerVersion(), version) 
<= 0
 if (operator == '!=' or operator == '!' or operator == 'not'):
 return str(version) not in str(self.getCompilerVersion())
 return str(version) in str(self.getCompilerVersion())


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1351,14 +1351,31 @@
 
 if (version is None):
 return True
+
+def compare_version_strings(v1, v2):
+split1 = v1.split('.')
+split2 = v2.split('.')
+while len(split1) > len(split2):
+split2.append("0")
+while len(split2) > len(split1):
+split1.append("0")
+
+versions = zip(split1, split2)
+for (subv1, subv2) in versions:
+diff = int(subv1) - int(subv2)
+if diff != 0:
+return diff
+
+return 0
+
 if (operator == '>'):
-return self.getCompilerVersion() > version
+return compare_version_strings(self.getCompilerVersion(), version) > 0
 if (operator == '>=' or operator == '=>'):
-return self.getCompilerVersion() >= version
+return compare_version_strings(self.getCompilerVersion(), version) >= 0
 if (operator == '<'):
-return self.getCompilerVersion() < version
+return compare_version_strings(self.getCompilerVersion(), version) < 0
 if (operator == '<=' or operator == '=<'):
-return self.getCompilerVersion() <= version
+return compare_version_strings(self.getCompilerVersion(), version) <= 0
 if (operator == '!=' or operator == '!' or operator == 'not'):
 return str(version) not in str(self.getCompilerVersion())
 return str(version) in str(self.getCompilerVersion())
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D58219: [dotest] Fix compiler version number comparison

2019-02-13 Thread Zachary Turner via lldb-commits
Try `import distutils.LooseVersion` and use that to do the comparison.
On Wed, Feb 13, 2019 at 4:49 PM Frederic Riss via Phabricator <
revi...@reviews.llvm.org> wrote:

> friss created this revision.
> friss added reviewers: zturner, labath.
> Herald added a reviewer: serge-sans-paille.
> Herald added a subscriber: jdoerfert.
>
> dotest's version comparision function is just a lexicographical compare
> of the version strings. This is obviously wrong. This patch implements
> a numerical comparision of the individual version components instead.
>
> Python is not my language of choice, please suggest a better
> implementation!
>
>
> https://reviews.llvm.org/D58219
>
> Files:
>   packages/Python/lldbsuite/test/lldbtest.py
>
>
> Index: packages/Python/lldbsuite/test/lldbtest.py
> ===
> --- packages/Python/lldbsuite/test/lldbtest.py
> +++ packages/Python/lldbsuite/test/lldbtest.py
> @@ -1351,14 +1351,31 @@
>
>  if (version is None):
>  return True
> +
> +def compare_version_strings(v1, v2):
> +split1 = v1.split('.')
> +split2 = v2.split('.')
> +while len(split1) > len(split2):
> +split2.append("0")
> +while len(split2) > len(split1):
> +split1.append("0")
> +
> +versions = zip(split1, split2)
> +for (subv1, subv2) in versions:
> +diff = int(subv1) - int(subv2)
> +if diff != 0:
> +return diff
> +
> +return 0
> +
>  if (operator == '>'):
> -return self.getCompilerVersion() > version
> +return compare_version_strings(self.getCompilerVersion(),
> version) > 0
>  if (operator == '>=' or operator == '=>'):
> -return self.getCompilerVersion() >= version
> +return compare_version_strings(self.getCompilerVersion(),
> version) >= 0
>  if (operator == '<'):
> -return self.getCompilerVersion() < version
> +return compare_version_strings(self.getCompilerVersion(),
> version) < 0
>  if (operator == '<=' or operator == '=<'):
> -return self.getCompilerVersion() <= version
> +return compare_version_strings(self.getCompilerVersion(),
> version) <= 0
>  if (operator == '!=' or operator == '!' or operator == 'not'):
>  return str(version) not in str(self.getCompilerVersion())
>  return str(version) in str(self.getCompilerVersion())
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D57402: build: remove custom variables

2019-02-13 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd updated this revision to Diff 186780.
compnerd added a comment.

Add HINTS


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57402/new/

https://reviews.llvm.org/D57402

Files:
  cmake/modules/LLDBStandalone.cmake


Index: cmake/modules/LLDBStandalone.cmake
===
--- cmake/modules/LLDBStandalone.cmake
+++ cmake/modules/LLDBStandalone.cmake
@@ -5,16 +5,8 @@
 
   option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)
 
-  set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH "Path to LLVM build tree")
-  set(LLDB_PATH_TO_CLANG_BUILD "${LLDB_PATH_TO_LLVM_BUILD}" CACHE PATH "Path 
to Clang build tree")
-
-  file(TO_CMAKE_PATH "${LLDB_PATH_TO_LLVM_BUILD}" LLDB_PATH_TO_LLVM_BUILD)
-  file(TO_CMAKE_PATH "${LLDB_PATH_TO_CLANG_BUILD}" LLDB_PATH_TO_CLANG_BUILD)
-
-  find_package(LLVM REQUIRED CONFIG
-HINTS "${LLDB_PATH_TO_LLVM_BUILD}" NO_CMAKE_FIND_ROOT_PATH)
-  find_package(Clang REQUIRED CONFIG
-HINTS "${LLDB_PATH_TO_CLANG_BUILD}" NO_CMAKE_FIND_ROOT_PATH)
+  find_package(LLVM REQUIRED CONFIG NO_CMAKE_FIND_ROOT_PATH)
+  find_package(Clang REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
 
   # We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when 
building SVNVersion.inc
   set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake 
modules")
@@ -26,7 +18,7 @@
   set(LLVM_DEFAULT_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE PATH 
"Path to llvm-lit")
 
   if(CMAKE_CROSSCOMPILING)
-set(LLVM_NATIVE_BUILD "${LLDB_PATH_TO_LLVM_BUILD}/NATIVE")
+set(LLVM_NATIVE_BUILD "${LLVM_BINARY_DIR}/NATIVE")
 if (NOT EXISTS "${LLVM_NATIVE_BUILD}")
   message(FATAL_ERROR
 "Attempting to cross-compile LLDB standalone but no native LLVM build


Index: cmake/modules/LLDBStandalone.cmake
===
--- cmake/modules/LLDBStandalone.cmake
+++ cmake/modules/LLDBStandalone.cmake
@@ -5,16 +5,8 @@
 
   option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
-  set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH "Path to LLVM build tree")
-  set(LLDB_PATH_TO_CLANG_BUILD "${LLDB_PATH_TO_LLVM_BUILD}" CACHE PATH "Path to Clang build tree")
-
-  file(TO_CMAKE_PATH "${LLDB_PATH_TO_LLVM_BUILD}" LLDB_PATH_TO_LLVM_BUILD)
-  file(TO_CMAKE_PATH "${LLDB_PATH_TO_CLANG_BUILD}" LLDB_PATH_TO_CLANG_BUILD)
-
-  find_package(LLVM REQUIRED CONFIG
-HINTS "${LLDB_PATH_TO_LLVM_BUILD}" NO_CMAKE_FIND_ROOT_PATH)
-  find_package(Clang REQUIRED CONFIG
-HINTS "${LLDB_PATH_TO_CLANG_BUILD}" NO_CMAKE_FIND_ROOT_PATH)
+  find_package(LLVM REQUIRED CONFIG NO_CMAKE_FIND_ROOT_PATH)
+  find_package(Clang REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
 
   # We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc
   set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
@@ -26,7 +18,7 @@
   set(LLVM_DEFAULT_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE PATH "Path to llvm-lit")
 
   if(CMAKE_CROSSCOMPILING)
-set(LLVM_NATIVE_BUILD "${LLDB_PATH_TO_LLVM_BUILD}/NATIVE")
+set(LLVM_NATIVE_BUILD "${LLVM_BINARY_DIR}/NATIVE")
 if (NOT EXISTS "${LLVM_NATIVE_BUILD}")
   message(FATAL_ERROR
 "Attempting to cross-compile LLDB standalone but no native LLVM build
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D58219: [dotest] Fix compiler version number comparison

2019-02-13 Thread Frederic Riss via Phabricator via lldb-commits
friss updated this revision to Diff 186782.
friss added a comment.

Use LooseVersion as suggested by Zachary


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58219/new/

https://reviews.llvm.org/D58219

Files:
  packages/Python/lldbsuite/test/lldbtest.py


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -37,6 +37,7 @@
 # System modules
 import abc
 import collections
+from distutils.version import LooseVersion
 from functools import wraps
 import gc
 import glob
@@ -1351,14 +1352,15 @@
 
 if (version is None):
 return True
+
 if (operator == '>'):
-return self.getCompilerVersion() > version
+return LooseVersion(self.getCompilerVersion()) > 
LooseVersion(version)
 if (operator == '>=' or operator == '=>'):
-return self.getCompilerVersion() >= version
+return LooseVersion(self.getCompilerVersion()) >= 
LooseVersion(version)
 if (operator == '<'):
-return self.getCompilerVersion() < version
+return LooseVersion(self.getCompilerVersion()) < 
LooseVersion(version)
 if (operator == '<=' or operator == '=<'):
-return self.getCompilerVersion() <= version
+return LooseVersion(self.getCompilerVersion()) <= 
LooseVersion(version)
 if (operator == '!=' or operator == '!' or operator == 'not'):
 return str(version) not in str(self.getCompilerVersion())
 return str(version) in str(self.getCompilerVersion())


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -37,6 +37,7 @@
 # System modules
 import abc
 import collections
+from distutils.version import LooseVersion
 from functools import wraps
 import gc
 import glob
@@ -1351,14 +1352,15 @@
 
 if (version is None):
 return True
+
 if (operator == '>'):
-return self.getCompilerVersion() > version
+return LooseVersion(self.getCompilerVersion()) > LooseVersion(version)
 if (operator == '>=' or operator == '=>'):
-return self.getCompilerVersion() >= version
+return LooseVersion(self.getCompilerVersion()) >= LooseVersion(version)
 if (operator == '<'):
-return self.getCompilerVersion() < version
+return LooseVersion(self.getCompilerVersion()) < LooseVersion(version)
 if (operator == '<=' or operator == '=<'):
-return self.getCompilerVersion() <= version
+return LooseVersion(self.getCompilerVersion()) <= LooseVersion(version)
 if (operator == '!=' or operator == '!' or operator == 'not'):
 return str(version) not in str(self.getCompilerVersion())
 return str(version) in str(self.getCompilerVersion())
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D58222: [ClangExpressionParser] Reuse the FileManager from the compiler instance.

2019-02-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: shafik, teemperor, clayborg.
JDevlieghere added a project: LLDB.
Herald added a subscriber: jdoerfert.

I was looking at the ClangExpressionParser and noticed that we have a 
FileManager owned by the expression parser and later ask the compiler instance 
to create a new FileManager, owned by the clang CI. Looking at the code I don't 
see a good reason for having two instances. This patch removes the one owned by 
LLDB.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D58222

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -178,8 +178,6 @@
 
   std::unique_ptr
   m_llvm_context; ///< The LLVM context to generate IR into
-  std::unique_ptr
-  m_file_manager; ///< The Clang file manager object used by the compiler
   std::unique_ptr
   m_compiler; ///< The Clang compiler used to parse expressions into IR
   std::unique_ptr
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -11,7 +11,6 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Basic/DiagnosticIDs.h"
-#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/Version.h"
@@ -489,15 +488,12 @@
 
   m_compiler->getDiagnostics().setClient(new ClangDiagnosticManagerAdapter);
 
-  // 7. Set up the source management objects inside the compiler
-
-  clang::FileSystemOptions file_system_options;
-  m_file_manager.reset(new clang::FileManager(file_system_options));
+  m_compiler->createFileManager();
 
+  // 7. Set up the source management objects inside the compiler
   if (!m_compiler->hasSourceManager())
-m_compiler->createSourceManager(*m_file_manager);
+m_compiler->createSourceManager(m_compiler->getFileManager());
 
-  m_compiler->createFileManager();
   m_compiler->createPreprocessor(TU_Complete);
 
   if (ClangModulesDeclVendor *decl_vendor =
@@ -855,9 +851,9 @@
   if (file.Write(expr_text, bytes_written).Success()) {
 if (bytes_written == expr_text_len) {
   file.Close();
-  source_mgr.setMainFileID(
-  source_mgr.createFileID(m_file_manager->getFile(result_path),
-  SourceLocation(), SrcMgr::C_User));
+  source_mgr.setMainFileID(source_mgr.createFileID(
+  m_compiler->getFileManager().getFile(result_path),
+  SourceLocation(), SrcMgr::C_User));
   created_main_file = true;
 }
   }


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -178,8 +178,6 @@
 
   std::unique_ptr
   m_llvm_context; ///< The LLVM context to generate IR into
-  std::unique_ptr
-  m_file_manager; ///< The Clang file manager object used by the compiler
   std::unique_ptr
   m_compiler; ///< The Clang compiler used to parse expressions into IR
   std::unique_ptr
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -11,7 +11,6 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Basic/DiagnosticIDs.h"
-#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/Version.h"
@@ -489,15 +488,12 @@
 
   m_compiler->getDiagnostics().setClient(new ClangDiagnosticManagerAdapter);
 
-  // 7. Set up the source management objects inside the compiler
-
-  clang::FileSystemOptions file_system_options;
-  m_file_manager.reset(new clang::FileManager(file_system_options));
+  m_compiler->createFileManager();
 
+  // 7. Set up the source management objects inside the compiler
   if (!m_compiler->hasSourceManager())
-m_compiler->createSourceManager(*m_file_manager);
+m_compiler->createSourceManager(m_compiler->getFileManager());
 
-  m_compiler->createFileManager();
   m_compiler->createPreprocessor(TU_Complete);
 
   if (ClangModulesDec

[Lldb-commits] [PATCH] D58222: [ClangExpressionParser] Reuse the FileManager from the compiler instance.

2019-02-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 186794.
JDevlieghere added a comment.

Keep/move the comment in the right place.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58222/new/

https://reviews.llvm.org/D58222

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -178,8 +178,6 @@
 
   std::unique_ptr
   m_llvm_context; ///< The LLVM context to generate IR into
-  std::unique_ptr
-  m_file_manager; ///< The Clang file manager object used by the compiler
   std::unique_ptr
   m_compiler; ///< The Clang compiler used to parse expressions into IR
   std::unique_ptr
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -11,7 +11,6 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Basic/DiagnosticIDs.h"
-#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/Version.h"
@@ -490,14 +489,9 @@
   m_compiler->getDiagnostics().setClient(new ClangDiagnosticManagerAdapter);
 
   // 7. Set up the source management objects inside the compiler
-
-  clang::FileSystemOptions file_system_options;
-  m_file_manager.reset(new clang::FileManager(file_system_options));
-
-  if (!m_compiler->hasSourceManager())
-m_compiler->createSourceManager(*m_file_manager);
-
   m_compiler->createFileManager();
+  if (!m_compiler->hasSourceManager())
+m_compiler->createSourceManager(m_compiler->getFileManager());
   m_compiler->createPreprocessor(TU_Complete);
 
   if (ClangModulesDeclVendor *decl_vendor =
@@ -855,9 +849,9 @@
   if (file.Write(expr_text, bytes_written).Success()) {
 if (bytes_written == expr_text_len) {
   file.Close();
-  source_mgr.setMainFileID(
-  source_mgr.createFileID(m_file_manager->getFile(result_path),
-  SourceLocation(), SrcMgr::C_User));
+  source_mgr.setMainFileID(source_mgr.createFileID(
+  m_compiler->getFileManager().getFile(result_path),
+  SourceLocation(), SrcMgr::C_User));
   created_main_file = true;
 }
   }


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -178,8 +178,6 @@
 
   std::unique_ptr
   m_llvm_context; ///< The LLVM context to generate IR into
-  std::unique_ptr
-  m_file_manager; ///< The Clang file manager object used by the compiler
   std::unique_ptr
   m_compiler; ///< The Clang compiler used to parse expressions into IR
   std::unique_ptr
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -11,7 +11,6 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Basic/DiagnosticIDs.h"
-#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/Version.h"
@@ -490,14 +489,9 @@
   m_compiler->getDiagnostics().setClient(new ClangDiagnosticManagerAdapter);
 
   // 7. Set up the source management objects inside the compiler
-
-  clang::FileSystemOptions file_system_options;
-  m_file_manager.reset(new clang::FileManager(file_system_options));
-
-  if (!m_compiler->hasSourceManager())
-m_compiler->createSourceManager(*m_file_manager);
-
   m_compiler->createFileManager();
+  if (!m_compiler->hasSourceManager())
+m_compiler->createSourceManager(m_compiler->getFileManager());
   m_compiler->createPreprocessor(TU_Complete);
 
   if (ClangModulesDeclVendor *decl_vendor =
@@ -855,9 +849,9 @@
   if (file.Write(expr_text, bytes_written).Success()) {
 if (bytes_written == expr_text_len) {
   file.Close();
-  source_mgr.setMainFileID(
-  source_mgr.createFileID(m_file_manager->getFile(result_path),
-  SourceLocation(), SrcMgr::C_User));
+  source_mgr.setMainFileID(source_mgr.createFileID(
+  m_compiler->ge

[Lldb-commits] [PATCH] D56237: Implement GetLoadAddress for the Windows process plugin

2019-02-13 Thread Aaron Smith via Phabricator via lldb-commits
asmith updated this revision to Diff 186796.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56237/new/

https://reviews.llvm.org/D56237

Files:
  source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
  source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
  source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  source/Plugins/Process/Windows/Common/ProcessWindows.h

Index: source/Plugins/Process/Windows/Common/ProcessWindows.h
===
--- source/Plugins/Process/Windows/Common/ProcessWindows.h
+++ source/Plugins/Process/Windows/Common/ProcessWindows.h
@@ -16,6 +16,7 @@
 #include "llvm/Support/Mutex.h"
 
 #include "IDebugDelegate.h"
+#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
 
 namespace lldb_private {
 
@@ -90,6 +91,8 @@
 
   lldb::addr_t GetImageInfoAddress() override;
 
+  DynamicLoaderWindowsDYLD *GetDynamicLoader();
+
   // IDebugDelegate overrides.
   void OnExitProcess(uint32_t exit_code) override;
   void OnDebuggerConnected(lldb::addr_t image_base) override;
Index: source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -864,6 +864,13 @@
 return LLDB_INVALID_ADDRESS;
 }
 
+DynamicLoaderWindowsDYLD *ProcessWindows::GetDynamicLoader() {
+  if (m_dyld_ap.get() == NULL)
+m_dyld_ap.reset(DynamicLoader::FindPlugin(
+this, DynamicLoaderWindowsDYLD::GetPluginNameStatic().GetCString()));
+  return static_cast(m_dyld_ap.get());
+}
+
 void ProcessWindows::OnExitProcess(uint32_t exit_code) {
   // No need to acquire the lock since m_session_data isn't accessed.
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
@@ -916,12 +923,10 @@
 GetTarget().SetExecutableModule(module, eLoadDependentsNo);
   }
 
-  bool load_addr_changed;
-  module->SetLoadAddress(GetTarget(), image_base, false, load_addr_changed);
-
-  ModuleList loaded_modules;
-  loaded_modules.Append(module);
-  GetTarget().ModulesDidLoad(loaded_modules);
+  if (auto dyld = GetDynamicLoader())
+dyld->OnLoadModule(
+ModuleSpec(module->GetFileSpec(), module->GetArchitecture()),
+image_base);
 
   // Add the main executable module to the list of pending module loads.  We
   // can't call GetTarget().ModulesDidLoad() here because we still haven't
@@ -1027,29 +1032,13 @@
 
 void ProcessWindows::OnLoadDll(const ModuleSpec &module_spec,
lldb::addr_t module_addr) {
-  // Confusingly, there is no Target::AddSharedModule.  Instead, calling
-  // GetSharedModule() with a new module will add it to the module list and
-  // return a corresponding ModuleSP.
-  Status error;
-  ModuleSP module = GetTarget().GetSharedModule(module_spec, &error);
-  bool load_addr_changed = false;
-  module->SetLoadAddress(GetTarget(), module_addr, false, load_addr_changed);
-
-  ModuleList loaded_modules;
-  loaded_modules.Append(module);
-  GetTarget().ModulesDidLoad(loaded_modules);
+  if (auto dyld = GetDynamicLoader())
+dyld->OnLoadModule(module_spec, module_addr);
 }
 
 void ProcessWindows::OnUnloadDll(lldb::addr_t module_addr) {
-  Address resolved_addr;
-  if (GetTarget().ResolveLoadAddress(module_addr, resolved_addr)) {
-ModuleSP module = resolved_addr.GetModule();
-if (module) {
-  ModuleList unloaded_modules;
-  unloaded_modules.Append(module);
-  GetTarget().ModulesDidUnload(unloaded_modules, false);
-}
-  }
+  if (auto dyld = GetDynamicLoader())
+dyld->OnUnloadModule(module_addr);
 }
 
 void ProcessWindows::OnDebugString(const std::string &string) {}
Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
===
--- source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
+++ source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
@@ -12,6 +12,8 @@
 #include "lldb/Target/DynamicLoader.h"
 #include "lldb/lldb-forward.h"
 
+#include 
+
 namespace lldb_private {
 
 class DynamicLoaderWindowsDYLD : public DynamicLoader {
@@ -27,6 +29,9 @@
 
   static DynamicLoader *CreateInstance(Process *process, bool force);
 
+  void OnLoadModule(const ModuleSpec &module_spec, lldb::addr_t module_addr);
+  void OnUnloadModule(lldb::addr_t module_addr);
+
   void DidAttach() override;
   void DidLaunch() override;
   Status CanLoadImage() override;
@@ -35,6 +40,12 @@
 
   ConstString GetPluginName() override;
   uint32_t GetPluginVersion() override;
+
+protected:
+  lldb::addr_t GetLoadAddress(lldb::ModuleSP executable);
+
+private:
+  std::map m_loaded_modules;
 };
 
 } // namespace lldb_private
Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
===
--- sour

[Lldb-commits] [lldb] r354010 - [lldb-server] Add remote platform capabilities for Windows

2019-02-13 Thread Aaron Smith via lldb-commits
Author: asmith
Date: Wed Feb 13 21:34:46 2019
New Revision: 354010

URL: http://llvm.org/viewvc/llvm-project?rev=354010&view=rev
Log:
[lldb-server] Add remote platform capabilities for Windows

Summary:
Implement a few routines for Windows to support some basic process interaction 
and file system operations.


Reviewers: zturner, llvm-commits, labath, jingham

Reviewed By: labath

Subscribers: emaste, jdoerfert, Hui, labath, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Target/RemoteAwarePlatform.h
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/trunk/source/Target/RemoteAwarePlatform.cpp

Modified: lldb/trunk/include/lldb/Target/RemoteAwarePlatform.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/RemoteAwarePlatform.h?rev=354010&r1=354009&r2=354010&view=diff
==
--- lldb/trunk/include/lldb/Target/RemoteAwarePlatform.h (original)
+++ lldb/trunk/include/lldb/Target/RemoteAwarePlatform.h Wed Feb 13 21:34:46 
2019
@@ -21,6 +21,41 @@ public:
 
   bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
  ModuleSpec &module_spec) override;
+
+  lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
+   uint32_t mode, Status &error) override;
+
+  bool CloseFile(lldb::user_id_t fd, Status &error) override;
+
+  uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
+uint64_t dst_len, Status &error) override;
+
+  uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
+ uint64_t src_len, Status &error) override;
+
+  lldb::user_id_t GetFileSize(const FileSpec &file_spec) override;
+
+  Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override;
+
+  bool GetFileExists(const FileSpec &file_spec) override;
+
+  Status Unlink(const FileSpec &file_spec) override;
+
+  FileSpec GetRemoteWorkingDirectory() override;
+
+  bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override;
+
+  Status MakeDirectory(const FileSpec &file_spec, uint32_t mode) override;
+
+  Status GetFilePermissions(const FileSpec &file_spec,
+uint32_t &file_permissions) override;
+
+  Status SetFilePermissions(const FileSpec &file_spec,
+uint32_t file_permissions) override;
+
+  bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+uint64_t &high) override;
+
   Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
  FileSpec &local_file) override;
 
@@ -29,6 +64,11 @@ public:
   bool GetRemoteOSKernelDescription(std::string &s) override;
   ArchSpec GetRemoteSystemArchitecture() override;
 
+  Status RunShellCommand(const char *command, const FileSpec &working_dir,
+ int *status_ptr, int *signo_ptr,
+ std::string *command_output,
+ const Timeout &timeout) override;
+
   const char *GetHostname() override;
   const char *GetUserName(uint32_t uid) override;
   const char *GetGroupName(uint32_t gid) override;
@@ -39,8 +79,16 @@ public:
   bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) 
override;
   uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
  ProcessInstanceInfoList &process_infos) override;
+
+  lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name,
+ Debugger &debugger, Target *target,
+ Status &error) override;
+
   Status LaunchProcess(ProcessLaunchInfo &launch_info) override;
 
+  Status KillProcess(const lldb::pid_t pid) override;
+
 protected:
   lldb::PlatformSP m_remote_platform_sp;
 };

Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=354010&r1=354009&r2=354010&view=diff
==
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Wed Feb 13 
21:34:46 2019
@@ -68,28 +68,6 @@ lldb_private::OptionGroupOptions *Platfo
   return m_options.at(&interpreter).get();
 }
 
-lldb_private::Status PlatformPOSIX::RunShellCommand(
-const char *command, // Shouldn't be NULL
-const FileSpec &
-working_dir, // Pass empty FileSpec to use the current working 
directory
-int *status_ptr, // Pass NULL if you don't want the pr

[Lldb-commits] [PATCH] D56237: Implement GetLoadAddress for the Windows process plugin

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looks good to me now. I think that, for completeness, you ought to add the DYLD 
plugin to the list of dependencies for in the CMakeLists.txt for 
ProcessWindows. Thanks for putting up with me.




Comment at: source/Plugins/Process/Windows/Common/ProcessWindows.h:94
 
+  DynamicLoaderWindowsDYLD *GetDynamicLoader();
+

add `override`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56237/new/

https://reviews.llvm.org/D56237



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


[Lldb-commits] [PATCH] D58193: Do not explicitly depend on llvm tools during standalone build

2019-02-13 Thread Pavel Labath via Phabricator via lldb-commits
labath resigned from this revision.
labath added a comment.

Alex and Stefan are the standalone build experts these days, so I'll let them 
do the reviewing here.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58193/new/

https://reviews.llvm.org/D58193



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