[Lldb-commits] [PATCH] D45298: [debugserver] Fix LC_BUILD_VERSION load command handling.

2018-04-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I thing the changes are fine. The only part that worries me is the in-class 
initialization of the simulator variables. I think this will fail on non-apple 
hosts.




Comment at: 
packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py:16-18
+sim_devices_str = subprocess.check_output(['xcrun', 'simctl', 'list', '-j',
+   'devices'])
+sim_devices = json.loads(sim_devices_str)['devices']

I think these will cause a problem as they will be executed even if the test is 
skipped. Will this throw an exception if "xcrun" fails (e.g. because you're on 
linux). It might be best to move this into some function..



Comment at: 
packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py:113
+self.check_simulator_ostype(sdk='watchsimulator',
+platform_names=('watchos',), arch='i386')

If you make this a list (`['watchos']`), you won't have to add the 
weird-looking comma at the end.



Comment at: packages/Python/lldbsuite/test/tools/lldb-server/main.cpp:50
 static const char *const THREAD_COMMAND_SEGFAULT = "segfault";
+static const char *const THREAD_COMMAND_PRINT_PID = "print-pid";
 

I don't think this needs to be a thread command, as the pid is not 
thread-specific. We could just make this a regular command like print-message 
et al.


https://reviews.llvm.org/D45298



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


[Lldb-commits] [lldb] r329296 - Remove unused NativeProcessProtocol.h include from Platform.h

2018-04-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Apr  5 08:17:51 2018
New Revision: 329296

URL: http://llvm.org/viewvc/llvm-project?rev=329296&view=rev
Log:
Remove unused NativeProcessProtocol.h include from Platform.h

After removing it, I got a couple of compile errors because we were
missing some symbols (SIGKILL and such), as their definitions were not
transitively included anymore. I fix this by including csignal from
PosixApi.h, as it's windows version provides a stub definitions of these
symbols. This should make the result of #including PosixApi.h more
consistent across platforms (although in the long run, we should just
get rid of this header).

Modified:
lldb/trunk/include/lldb/Host/PosixApi.h
lldb/trunk/include/lldb/Target/Platform.h

Modified: lldb/trunk/include/lldb/Host/PosixApi.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/PosixApi.h?rev=329296&r1=329295&r2=329296&view=diff
==
--- lldb/trunk/include/lldb/Host/PosixApi.h (original)
+++ lldb/trunk/include/lldb/Host/PosixApi.h Thu Apr  5 08:17:51 2018
@@ -18,6 +18,7 @@
 #include "lldb/Host/windows/PosixApi.h"
 #else
 #include 
+#include 
 #endif
 
 #endif

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=329296&r1=329295&r2=329296&view=diff
==
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Thu Apr  5 08:17:51 2018
@@ -30,10 +30,6 @@
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
-// TODO pull NativeDelegate class out of NativeProcessProtocol so we
-// can just forward ref the NativeDelegate rather than include it here.
-#include "lldb/Host/common/NativeProcessProtocol.h"
-
 namespace lldb_private {
 
 class ModuleCache;


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


[Lldb-commits] [lldb] r329295 - Fix error in QEnableErrorStrings gdb-remote docs

2018-04-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Apr  5 08:17:43 2018
New Revision: 329295

URL: http://llvm.org/viewvc/llvm-project?rev=329295&view=rev
Log:
Fix error in QEnableErrorStrings gdb-remote docs

this probably happened because we changed the name of the packet
mid-review.

Modified:
lldb/trunk/docs/lldb-gdb-remote.txt

Modified: lldb/trunk/docs/lldb-gdb-remote.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=329295&r1=329294&r2=329295&view=diff
==
--- lldb/trunk/docs/lldb-gdb-remote.txt (original)
+++ lldb/trunk/docs/lldb-gdb-remote.txt Thu Apr  5 08:17:43 2018
@@ -148,7 +148,7 @@ This packet can be sent one or more time
 //  are human readable along with an error code.
 //--
 
-send packet: $QErrorStringInPacketSupported
+send packet: $QEnableErrorStrings
 read packet: $OK#00
 
 //--


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


[Lldb-commits] [PATCH] D45298: [debugserver] Fix LC_BUILD_VERSION load command handling.

2018-04-05 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: 
packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py:16-18
+sim_devices_str = subprocess.check_output(['xcrun', 'simctl', 'list', '-j',
+   'devices'])
+sim_devices = json.loads(sim_devices_str)['devices']

labath wrote:
> I think these will cause a problem as they will be executed even if the test 
> is skipped. Will this throw an exception if "xcrun" fails (e.g. because 
> you're on linux). It might be best to move this into some function..
Yep, I coincidentally realized this on my commute this morning. I'll fix it.



Comment at: packages/Python/lldbsuite/test/tools/lldb-server/main.cpp:50
 static const char *const THREAD_COMMAND_SEGFAULT = "segfault";
+static const char *const THREAD_COMMAND_PRINT_PID = "print-pid";
 

labath wrote:
> I don't think this needs to be a thread command, as the pid is not 
> thread-specific. We could just make this a regular command like print-message 
> et al.
No problem.


https://reviews.llvm.org/D45298



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


[Lldb-commits] [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

That's great! Let's go for it then. Could you please doxygen'ify the comments?


https://reviews.llvm.org/D45170



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


[Lldb-commits] [lldb] r329305 - Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-05 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Thu Apr  5 08:52:39 2018
New Revision: 329305

URL: http://llvm.org/viewvc/llvm-project?rev=329305&view=rev
Log:
Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

Many things that were in DWARFCompileUnit actually need to be in DWARFUnit. 
This patch moves all DWARFUnit specific things over into DWARFUnit and fixes 
the layering. This is in preparation for adding DWARFTypeUnit for the 
.debug_types patch.

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


Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=329305&r1=329304&r2=329305&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Apr  5 
08:52:39 2018
@@ -9,36 +9,15 @@
 
 #include "DWARFCompileUnit.h"
 
-#include "lldb/Core/DumpDataExtractor.h"
-#include "lldb/Core/Mangled.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Host/StringConvert.h"
-#include "lldb/Symbol/CompileUnit.h"
-#include "lldb/Symbol/LineTable.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Utility/Stream.h"
-#include "lldb/Utility/StreamString.h"
-#include "lldb/Utility/Timer.h"
-
-#include "DWARFDIECollection.h"
-#include "DWARFDebugAbbrev.h"
-#include "DWARFDebugAranges.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFFormValue.h"
-#include "LogChannelDWARF.h"
-#include "NameToDIE.h"
 #include "SymbolFileDWARF.h"
-#include "SymbolFileDWARFDebugMap.h"
-#include "SymbolFileDWARFDwo.h"
 
 using namespace lldb;
 using namespace lldb_private;
-using namespace std;
 
 extern int g_verbose;
 
 DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data)
-: m_dwarf2Data(dwarf2Data) {}
+: DWARFUnit(dwarf2Data) {}
 
 DWARFUnitSP DWARFCompileUnit::Extract(SymbolFileDWARF *dwarf2Data,
 lldb::offset_t *offset_ptr) {
@@ -81,259 +60,6 @@ DWARFUnitSP DWARFCompileUnit::Extract(Sy
   return nullptr;
 }
 
-void DWARFCompileUnit::ClearDIEs(bool keep_compile_unit_die) {
-  if (m_die_array.size() > 1) {
-// std::vectors never get any smaller when resized to a smaller size,
-// or when clear() or erase() are called, the size will report that it
-// is smaller, but the memory allocated remains intact (call capacity()
-// to see this). So we need to create a temporary vector and swap the
-// contents which will cause just the internal pointers to be swapped
-// so that when "tmp_array" goes out of scope, it will destroy the
-// contents.
-
-// Save at least the compile unit DIE
-DWARFDebugInfoEntry::collection tmp_array;
-m_die_array.swap(tmp_array);
-if (keep_compile_unit_die)
-  m_die_array.push_back(tmp_array.front());
-  }
-
-  if (m_dwo_symbol_file)
-m_dwo_symbol_file->GetCompileUnit()->ClearDIEs(keep_compile_unit_die);
-}
-
-//--
-// ParseCompileUnitDIEsIfNeeded
-//
-// Parses a compile unit and indexes its DIEs if it hasn't already been
-// done.
-//--
-size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) {
-  const size_t initial_die_array_size = m_die_array.size();
-  if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 
1)
-return 0; // Already parsed
-
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(
-  func_cat,
-  "%8.8x: DWARFCompileUnit::ExtractDIEsIfNeeded( cu_die_only = %i )",
-  m_offset, cu_die_only);
-
-  // Set the offset to that of the first DIE and calculate the start of the
-  // next compilation unit header.
-  lldb::offset_t offset = GetFirstDIEOffset();
-  lldb::offset_t next_cu_offset = GetNextCompileUnitOffset();
-
-  DWARFDebugInfoEntry die;
-  // Keep a flat array of the DIE for binary lookup by DIE offset
-  if (!cu_die_only) {
-Log *log(
-LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | 
DWARF_LOG_LOOKUPS));
-if (log) {
-  m_dwarf2Data->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
-  log, "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at "
-   ".debug_info[0x%8.8x]",
-  GetOffset());
-}
-  }
-
-  uint32_t

[Lldb-commits] [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329305: Cleanup DWARFCompileUnit and DWARFUnit in 
preparation for adding DWARFTypeUnit (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45170?vs=140638&id=141169#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45170

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -18,114 +18,10 @@
 public:
   static DWARFUnitSP Extract(SymbolFileDWARF *dwarf2Data,
   lldb::offset_t *offset_ptr);
-
-  size_t ExtractDIEsIfNeeded(bool cu_die_only);
-  DWARFDIE LookupAddress(const dw_addr_t address);
-  size_t AppendDIEsWithTag(const dw_tag_t tag,
-   DWARFDIECollection &matching_dies,
-   uint32_t depth = UINT32_MAX) const;
-  bool Verify(lldb_private::Stream *s) const;
-  void Dump(lldb_private::Stream *s) const;
-  lldb::user_id_t GetID() const;
-  dw_offset_t GetAbbrevOffset() const;
-  void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base, dw_offset_t base_obj_offset);
-  void ClearDIEs(bool keep_compile_unit_die);
-  void BuildAddressRangeTable(SymbolFileDWARF *dwarf2Data,
-  DWARFDebugAranges *debug_aranges);
-
-  lldb_private::TypeSystem *GetTypeSystem();
-
-  DWARFDIE
-  GetCompileUnitDIEOnly() { return DWARFDIE(this, GetCompileUnitDIEPtrOnly()); }
-
-  DWARFDIE
-  DIE() { return DWARFDIE(this, DIEPtr()); }
-
-  void AddDIE(DWARFDebugInfoEntry &die) {
-// The average bytes per DIE entry has been seen to be
-// around 14-20 so lets pre-reserve half of that since
-// we are now stripping the NULL tags.
-
-// Only reserve the memory if we are adding children of
-// the main compile unit DIE. The compile unit DIE is always
-// the first entry, so if our size is 1, then we are adding
-// the first compile unit child DIE and should reserve
-// the memory.
-if (m_die_array.empty())
-  m_die_array.reserve(GetDebugInfoSize() / 24);
-m_die_array.push_back(die);
-  }
-
-  void AddCompileUnitDIE(DWARFDebugInfoEntry &die);
-
-  void SetUserData(void *d);
-
-  const DWARFDebugAranges &GetFunctionAranges();
-
-  DWARFProducer GetProducer();
-
-  uint32_t GetProducerVersionMajor();
-
-  uint32_t GetProducerVersionMinor();
-
-  uint32_t GetProducerVersionUpdate();
-
-  lldb::LanguageType GetLanguageType();
-
-  bool GetIsOptimized();
-
-protected:
-  virtual DWARFCompileUnit &Data() override { return *this; }
-  virtual const DWARFCompileUnit &Data() const override { return *this; }
-
-  SymbolFileDWARF *m_dwarf2Data;
-  std::unique_ptr m_dwo_symbol_file;
-  const DWARFAbbreviationDeclarationSet *m_abbrevs;
-  void *m_user_data = nullptr;
-  DWARFDebugInfoEntry::collection
-  m_die_array; // The compile unit debug information entry item
-  std::unique_ptr m_func_aranges_ap; // A table similar to
-// the .debug_aranges
-// table, but this one
-// points to the exact
-// DW_TAG_subprogram
-// DIEs
-  dw_addr_t m_base_addr = 0;
-  dw_offset_t m_length;
-  uint16_t m_version;
-  uint8_t m_addr_size;
-  DWARFProducer m_producer = eProducerInvalid;
-  uint32_t m_producer_version_major = 0;
-  uint32_t m_producer_version_minor = 0;
-  uint32_t m_producer_version_update = 0;
-  lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
-  bool m_is_dwarf64;
-  lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate;
-  dw_addr_t m_addr_base = 0; // Value of DW_AT_addr_base
-  dw_addr_t m_ranges_base = 0;   // Value of DW_AT_ranges_base
-  // If this is a dwo compile unit this is the offset of the base compile unit
-  // in the main object file
-  dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET;
-
-  void ParseProducerInfo();
+  void Dump(lldb_private::Stream *s) const override;
 
 private:
   DWARFCompileUnit(SymbolFileDWARF *dwarf2Data);
-
-  const DWARFDebugInfoEntry *GetCompileUnitDIEPtrOnly

Re: [Lldb-commits] [lldb] r329305 - Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-05 Thread Davide Italiano via lldb-commits
On Thu, Apr 5, 2018 at 8:52 AM, Greg Clayton via lldb-commits
 wrote:
> Author: gclayton
> Date: Thu Apr  5 08:52:39 2018
> New Revision: 329305
>
> URL: http://llvm.org/viewvc/llvm-project?rev=329305&view=rev
> Log:
> Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit
>
> Many things that were in DWARFCompileUnit actually need to be in DWARFUnit. 
> This patch moves all DWARFUnit specific things over into DWARFUnit and fixes 
> the layering. This is in preparation for adding DWARFTypeUnit for the 
> .debug_types patch.
>
> Differential Revision: https://reviews.llvm.org/D45170
>
>
> Modified:
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
>
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=329305&r1=329304&r2=329305&view=diff
> ==
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Apr  
> 5 08:52:39 2018
> @@ -9,36 +9,15 @@
>
>  #include "DWARFCompileUnit.h"
>
> -#include "lldb/Core/DumpDataExtractor.h"
> -#include "lldb/Core/Mangled.h"
> -#include "lldb/Core/Module.h"
> -#include "lldb/Host/StringConvert.h"
> -#include "lldb/Symbol/CompileUnit.h"
> -#include "lldb/Symbol/LineTable.h"
> -#include "lldb/Symbol/ObjectFile.h"
> -#include "lldb/Utility/Stream.h"
> -#include "lldb/Utility/StreamString.h"
> -#include "lldb/Utility/Timer.h"
> -
> -#include "DWARFDIECollection.h"
> -#include "DWARFDebugAbbrev.h"
> -#include "DWARFDebugAranges.h"
> -#include "DWARFDebugInfo.h"
> -#include "DWARFFormValue.h"
> -#include "LogChannelDWARF.h"
> -#include "NameToDIE.h"
>  #include "SymbolFileDWARF.h"
> -#include "SymbolFileDWARFDebugMap.h"
> -#include "SymbolFileDWARFDwo.h"
>
>  using namespace lldb;
>  using namespace lldb_private;
> -using namespace std;
>
>  extern int g_verbose;
>
>  DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data)
> -: m_dwarf2Data(dwarf2Data) {}
> +: DWARFUnit(dwarf2Data) {}
>
>  DWARFUnitSP DWARFCompileUnit::Extract(SymbolFileDWARF *dwarf2Data,
>  lldb::offset_t *offset_ptr) {
> @@ -81,259 +60,6 @@ DWARFUnitSP DWARFCompileUnit::Extract(Sy
>return nullptr;
>  }
>
> -void DWARFCompileUnit::ClearDIEs(bool keep_compile_unit_die) {
> -  if (m_die_array.size() > 1) {
> -// std::vectors never get any smaller when resized to a smaller size,
> -// or when clear() or erase() are called, the size will report that it
> -// is smaller, but the memory allocated remains intact (call capacity()
> -// to see this). So we need to create a temporary vector and swap the
> -// contents which will cause just the internal pointers to be swapped
> -// so that when "tmp_array" goes out of scope, it will destroy the
> -// contents.
> -
> -// Save at least the compile unit DIE
> -DWARFDebugInfoEntry::collection tmp_array;
> -m_die_array.swap(tmp_array);
> -if (keep_compile_unit_die)
> -  m_die_array.push_back(tmp_array.front());
> -  }
> -
> -  if (m_dwo_symbol_file)
> -m_dwo_symbol_file->GetCompileUnit()->ClearDIEs(keep_compile_unit_die);
> -}
> -
> -//--
> -// ParseCompileUnitDIEsIfNeeded
> -//
> -// Parses a compile unit and indexes its DIEs if it hasn't already been
> -// done.
> -//--
> -size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) {
> -  const size_t initial_die_array_size = m_die_array.size();
> -  if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size 
> > 1)
> -return 0; // Already parsed
> -
> -  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
> -  Timer scoped_timer(
> -  func_cat,
> -  "%8.8x: DWARFCompileUnit::ExtractDIEsIfNeeded( cu_die_only = %i )",
> -  m_offset, cu_die_only);
> -
> -  // Set the offset to that of the first DIE and calculate the start of the
> -  // next compilation unit header.
> -  lldb::offset_t offset = GetFirstDIEOffset();
> -  lldb::offset_t next_cu_offset = GetNextCompileUnitOffset();
> -
> -  DWARFDebugInfoEntry die;
> -  // Keep a flat array of the DIE for binary lookup by DIE offset
> -  if (!cu_die_only) {
> -Log *log(
> -LogChannelDWARF::GetLogIfAny(DWARF_LOG_DE

[Lldb-commits] [lldb] r329309 - Fix windows build after r329296

2018-04-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Apr  5 09:23:54 2018
New Revision: 329309

URL: http://llvm.org/viewvc/llvm-project?rev=329309&view=rev
Log:
Fix windows build after r329296

Add a couple of #include s.

Modified:

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=329309&r1=329308&r2=329309&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
 Thu Apr  5 09:23:54 2018
@@ -14,6 +14,7 @@
 // C Includes
 // C++ Includes
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=329309&r1=329308&r2=329309&view=diff
==
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Apr  
5 09:23:54 2018
@@ -24,6 +24,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 #include 
 #include 


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


[Lldb-commits] [lldb] r329314 - One more windows build fix

2018-04-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Apr  5 09:59:36 2018
New Revision: 329314

URL: http://llvm.org/viewvc/llvm-project?rev=329314&view=rev
Log:
One more windows build fix

Modified:
lldb/trunk/source/Target/Platform.cpp

Modified: lldb/trunk/source/Target/Platform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=329314&r1=329313&r2=329314&view=diff
==
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Thu Apr  5 09:59:36 2018
@@ -10,6 +10,7 @@
 // C Includes
 // C++ Includes
 #include 
+#include 
 #include 
 #include 
 


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


[Lldb-commits] [PATCH] D45332: [LIT] Add new LLDB test format

2018-04-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: zturner, labath, davide, aprantl.
Herald added a subscriber: delcypher.
JDevlieghere added a comment.

As discussed in https://reviews.llvm.org/D45215


This adds a new test format to lit which will be used for LLDB.

(If it's possible to define a new format outside the LLVM repo, I'm more than 
happy to move it into the LLDB repo)


Repository:
  rL LLVM

https://reviews.llvm.org/D45332

Files:
  utils/lit/lit/formats/__init__.py
  utils/lit/lit/formats/lldbtest.py


Index: utils/lit/lit/formats/lldbtest.py
===
--- /dev/null
+++ utils/lit/lit/formats/lldbtest.py
@@ -0,0 +1,66 @@
+from __future__ import absolute_import
+import os
+
+import subprocess
+import sys
+
+import lit.Test
+import lit.TestRunner
+import lit.util
+from .base import TestFormat
+
+
+class LLDBTest(TestFormat):
+def __init__(self, dotest_cmd):
+self.dotest_cmd = dotest_cmd
+
+def getTestsInDirectory(self, testSuite, path_in_suite, litConfig,
+localConfig):
+source_path = testSuite.getSourcePath(path_in_suite)
+for filename in os.listdir(source_path):
+# Ignore dot files and excluded tests.
+if (filename.startswith('.') or filename in localConfig.excludes):
+continue
+
+# Ignore files that don't start with 'Test'.
+if not filename.startswith('Test'):
+continue
+
+filepath = os.path.join(source_path, filename)
+if not os.path.isdir(filepath):
+base, ext = os.path.splitext(filename)
+if ext in localConfig.suffixes:
+yield lit.Test.Test(testSuite, path_in_suite +
+(filename, ), localConfig)
+
+def execute(self, test, litConfig):
+if litConfig.noExecute:
+return lit.Test.PASS, ''
+
+if test.config.unsupported:
+return (lit.Test.UNSUPPORTED, 'Test is unsupported')
+
+testPath, testFile = os.path.split(test.getSourcePath())
+testName, testExt = os.path.splitext(testFile)
+cmd = self.dotest_cmd + [testPath, '-p', testName]
+print ' '.join(cmd)
+
+try:
+out, err, exitCode = lit.util.executeCommand(
+cmd,
+env=test.config.environment,
+timeout=litConfig.maxIndividualTestTime)
+except lit.util.ExecuteCommandTimeoutException:
+return (lit.Test.TIMEOUT, 'Reached timeout of {} seconds'.format(
+litConfig.maxIndividualTestTime))
+
+if exitCode:
+return lit.Test.FAIL, out + err
+
+passing_test_line = 'RESULT: PASSED'
+if passing_test_line not in out:
+msg = ('Unable to find %r in dotest output:\n\n%s%s' %
+   (passing_test_line, out, err))
+return lit.Test.UNRESOLVED, msg
+
+return lit.Test.PASS, ''
Index: utils/lit/lit/formats/__init__.py
===
--- utils/lit/lit/formats/__init__.py
+++ utils/lit/lit/formats/__init__.py
@@ -5,4 +5,5 @@
 )
 
 from lit.formats.googletest import GoogleTest  # noqa: F401
+from lit.formats.lldbtest import LLDBTest  # noqa: F401
 from lit.formats.shtest import ShTest  # noqa: F401


Index: utils/lit/lit/formats/lldbtest.py
===
--- /dev/null
+++ utils/lit/lit/formats/lldbtest.py
@@ -0,0 +1,66 @@
+from __future__ import absolute_import
+import os
+
+import subprocess
+import sys
+
+import lit.Test
+import lit.TestRunner
+import lit.util
+from .base import TestFormat
+
+
+class LLDBTest(TestFormat):
+def __init__(self, dotest_cmd):
+self.dotest_cmd = dotest_cmd
+
+def getTestsInDirectory(self, testSuite, path_in_suite, litConfig,
+localConfig):
+source_path = testSuite.getSourcePath(path_in_suite)
+for filename in os.listdir(source_path):
+# Ignore dot files and excluded tests.
+if (filename.startswith('.') or filename in localConfig.excludes):
+continue
+
+# Ignore files that don't start with 'Test'.
+if not filename.startswith('Test'):
+continue
+
+filepath = os.path.join(source_path, filename)
+if not os.path.isdir(filepath):
+base, ext = os.path.splitext(filename)
+if ext in localConfig.suffixes:
+yield lit.Test.Test(testSuite, path_in_suite +
+(filename, ), localConfig)
+
+def execute(self, test, litConfig):
+if litConfig.noExecute:
+return lit.Test.PASS, ''
+
+if test.config.unsupported:
+return (lit.Test.UNSUPPORTED, 'Test is unsupported')
+
+testPath, test

[Lldb-commits] [PATCH] D45332: [LIT] Add new LLDB test format

2018-04-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

As discussed in https://reviews.llvm.org/D45215


Repository:
  rL LLVM

https://reviews.llvm.org/D45332



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


[Lldb-commits] [PATCH] D45333: WIP: [LIT] Have lit run the lldb test suite

2018-04-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: zturner, labath, davide, aprantl.
Herald added subscribers: llvm-commits, mgorny.

This is the initial attempt (v1) to run the lldb test suite with lit, using the 
custom LLDB test format. Here every`Test*.py` is seen as a single test by lit. 
As suggested by pavel this circumvents lldb-dotest (though the configuration 
file now contains part of that logic).


Repository:
  rL LLVM

https://reviews.llvm.org/D45333

Files:
  lit/Suite/lit.cfg
  lit/Suite/lit.site.cfg.in
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -152,6 +152,17 @@
 add_custom_target(lldb-dotest)
 add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
 
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/../lit/Suite/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
+  )
+file(GENERATE
+  OUTPUT
+  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
+  INPUT
+  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
+  )
+
 # If we're building with an in-tree clang, then list clang as a dependency
 # to run tests.
 if (TARGET clang)
Index: lit/Suite/lit.site.cfg.in
===
--- /dev/null
+++ lit/Suite/lit.site.cfg.in
@@ -0,0 +1,28 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.test_exec_root = "@LLVM_BINARY_DIR@"
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.lldb_obj_root = "@LLDB_BINARY_DIR@"
+config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.target_triple = "@TARGET_TRIPLE@"
+config.python_executable = "@PYTHON_EXECUTABLE@"
+config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
+config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
+
+# Support substitution of the tools and libs dirs with user parameters. This is
+# used when we can't determine the tool dir at configuration time.
+try:
+config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
+config.llvm_build_mode = config.llvm_build_mode % lit_config.params
+except KeyError as e:
+key, = e.args
+lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Suite/lit.cfg")
Index: lit/Suite/lit.cfg
===
--- /dev/null
+++ lit/Suite/lit.cfg
@@ -0,0 +1,25 @@
+# -*- Python -*-
+
+# Configuration file for the 'lit' test runner.
+
+import os
+
+import lit.formats
+
+# name: The name of this test suite.
+config.name = 'lldb-Suite'
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = ['.py']
+
+# test_source_root: The root path where tests are located.
+# test_exec_root: The root path where tests should be run.
+config.test_source_root = os.path.join(config.lldb_src_root, 'test', 
'testcases')
+config.test_exec_root = config.test_source_root
+
+# Build dotest command.
+dotest_cmd = [config.dotest_path, '-q']
+dotest_cmd.extend(config.dotest_args_str.split(';'))
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.LLDBTest(dotest_cmd)


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -152,6 +152,17 @@
 add_custom_target(lldb-dotest)
 add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
 
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/../lit/Suite/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
+  )
+file(GENERATE
+  OUTPUT
+  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
+  INPUT
+  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
+  )
+
 # If we're building with an in-tree clang, then list clang as a dependency
 # to run tests.
 if (TARGET clang)
Index: lit/Suite/lit.site.cfg.in
===
--- /dev/null
+++ lit/Suite/lit.site.cfg.in
@@ -0,0 +1,28 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.test_exec_root = "@LLVM_BINARY_DIR@"
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.lldb_obj_root = "@LLDB_BINARY_DIR@"
+config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.target_triple = "@TARGET_TRIPLE@"
+config.python_executable = "@PYTHON_EXECUTABLE@"
+config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
+config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
+
+# Support substitution of the tool

[Lldb-commits] [PATCH] D45332: [LIT] Add new LLDB test format

2018-04-05 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

It should be possible to define it outside the LLVM repo.  Just in 
`llvm/lldb/lit/lit.cfg` replace this line:

  config.test_format = lit.formats.ShTest(execute_external)

with something like this:

  import lldb_format
  config.test_format = lldb_format.LLDBTestFormat()

and that file can live in the lldb repo.


Repository:
  rL LLVM

https://reviews.llvm.org/D45332



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


[Lldb-commits] [PATCH] D45333: WIP: [LIT] Have lit run the lldb test suite

2018-04-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

This isn't meant to be checked-in as is, however I'm looking for feedback as 
early as possible.

There are currently two problems with the current diff:

- `./bin/llvm-lit ../llvm/tools/lldb/lit/Suite/` doesn't work, and I haven't 
figured out why yet.
- We'd run the (do)test-suite twice, once as part lit and once as part of 
`check-lldb`.


Repository:
  rL LLVM

https://reviews.llvm.org/D45333



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


[Lldb-commits] [PATCH] D45215: RFC/WIP: Have lit run the lldb test suite

2018-04-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Please see https://reviews.llvm.org/D45332 for the lldb test format and 
https://reviews.llvm.org/D45333 for how to use that to run the tests.


https://reviews.llvm.org/D45215



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


[Lldb-commits] [PATCH] D45332: [LIT] Add new LLDB test format

2018-04-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D45332#1058914, @zturner wrote:

> It should be possible to define it outside the LLVM repo.  Just in 
> `llvm/lldb/lit/lit.cfg` replace this line:
>
>   config.test_format = lit.formats.ShTest(execute_external)
>
>
> with something like this:
>
>   import lldb_format
>   config.test_format = lldb_format.LLDBTestFormat()
>
>
> and that file can live in the lldb repo.


Probably I'm doing something wrong then because I couldn't get that to work. I 
moved the `lldbtest.py` in the `Suite` dir and then I got an import error.

  ImportError: No module named lldbtest


Repository:
  rL LLVM

https://reviews.llvm.org/D45332



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


[Lldb-commits] [PATCH] D45332: [LIT] Add new LLDB test format

2018-04-05 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

I don't think `sys.path` is set up correctly to be able to find the lldbtest 
package from the `lldb/lit` folder.

These things kind of evolved separately, and the `lldb/lit` folder was created 
as a place to start iterating on LLVM-style lit / FileCheck tests.  These kind 
of tests -- by definition -- don't really use the SB API, so no work was ever 
done to set up paths correctly so that it could write `import lldb` or to 
re-use any of the other stuff from `packages/Python`.

I'm not sure what the best thing to do is, but usually the canonical 
structuring is to have the test files in the same tree as the lit 
configuration.  So perhaps you could put a lit configuration file in 
`lldb/packages/Python/lldbsuite` and have that be separate from `lldb/lit`, 
with the goal of eventually (possibly) merging them.  Then have a separate 
CMake target so you'd still have `check-lldb-lit` which goes into the 
`lldb/lit` directory, and another one like `check-lldb-lit-dotest` which starts 
from the `lldb/packages/Python/lldbsuite` directory.

On the other hand, if you want to see how `dotest.py` sets up its `sys.path`, 
have a look at `lldb/test/dotest.py`  The magic is in this `use_lldb_suite` 
function, which walks backwards through the tree until it finds the root, then 
dives into the `lldbsuite` folder to manually add it to `sys.path`.


Repository:
  rL LLVM

https://reviews.llvm.org/D45332



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


[Lldb-commits] [PATCH] D45332: [LIT] Add new LLDB test format

2018-04-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D45332#1058970, @zturner wrote:

> I don't think `sys.path` is set up correctly to be able to find the lldbtest 
> package from the `lldb/lit` folder.
>
> These things kind of evolved separately, and the `lldb/lit` folder was 
> created as a place to start iterating on LLVM-style lit / FileCheck tests.  
> These kind of tests -- by definition -- don't really use the SB API, so no 
> work was ever done to set up paths correctly so that it could write `import 
> lldb` or to re-use any of the other stuff from `packages/Python`.
>
> I'm not sure what the best thing to do is, but usually the canonical 
> structuring is to have the test files in the same tree as the lit 
> configuration.  So perhaps you could put a lit configuration file in 
> `lldb/packages/Python/lldbsuite` and have that be separate from `lldb/lit`, 
> with the goal of eventually (possibly) merging them.  Then have a separate 
> CMake target so you'd still have `check-lldb-lit` which goes into the 
> `lldb/lit` directory, and another one like `check-lldb-lit-dotest` which 
> starts from the `lldb/packages/Python/lldbsuite` directory.
>
> On the other hand, if you want to see how `dotest.py` sets up its `sys.path`, 
> have a look at `lldb/test/dotest.py`  The magic is in this `use_lldb_suite` 
> function, which walks backwards through the tree until it finds the root, 
> then dives into the `lldbsuite` folder to manually add it to `sys.path`.


Do you feel all that outweighs the alternative of just having the format in 
`llvm/Utils` as is the case in this diff? We already have some LLDB specific 
stuff there and I would argue that conceptually it makes (at least a little) 
sense to have all the format living together.


Repository:
  rL LLVM

https://reviews.llvm.org/D45332



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


[Lldb-commits] [lldb] r329358 - [dotest] --skip-category should append and not override.

2018-04-05 Thread Davide Italiano via lldb-commits
Author: davide
Date: Thu Apr  5 15:46:39 2018
New Revision: 329358

URL: http://llvm.org/viewvc/llvm-project?rev=329358&view=rev
Log:
[dotest] --skip-category should append and not override.



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

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=329358&r1=329357&r2=329358&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Thu Apr  5 15:46:39 2018
@@ -337,7 +337,7 @@ def parseOptionsAndInitTestdirs():
 configuration.categoriesList = []
 
 if args.skipCategories:
-configuration.skipCategories = test_categories.validate(
+configuration.skipCategories += test_categories.validate(
 args.skipCategories, False)
 
 if args.E:


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


[Lldb-commits] [PATCH] D45298: [debugserver] Fix LC_BUILD_VERSION load command handling.

2018-04-05 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

Looks good to me.




Comment at: packages/Python/lldbsuite/test/decorators.py:359
+output = subprocess.check_output(["xcodebuild", "-showsdks"], 
stderr=DEVNULL)
+if re.search('%ssimulator' % platform, output):
+return None

It might be helpful for anyone debugging this if examples of the names this is 
matching were included in a comment.  iphonesimulator, appletvsimulator, 
watchsimulator.  Different capitalization is used in so many places (and 
whether to include "os" suffix or not, and whether to include "apple" prefix or 
not) that it can be hard to know what's expected unless you run the command 
yourself.



Comment at: tools/debugserver/source/MacOSX/MachProcess.mm:584
+cmd == LC_VERSION_MIN_IPHONEOS || cmd == LC_VERSION_MIN_MACOSX;
+#if defined(LC_VERSION_MIN_TVOS)
+  lc_cmd_known |= cmd == LC_VERSION_MIN_TVOS;

Not important, but we're requiring a MacOS SDK of 10.11 or newer and the tvos 
and watchos SDKs were available by then; we could remove these ifdefs.  
(LC_BUILD_VERSION is newer than that & needs to be kept around.)



Comment at: tools/debugserver/source/MacOSX/MachProcess.mm:588
+#if defined(LC_VERSION_MIN_WATCHOS)
+  lc_cmd_known |= cmd == LC_VERSION_MIN_WATCHOS;
+#endif

It's equivalent, no big deal, but this is a bitwise | not a logical ||.


https://reviews.llvm.org/D45298



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


[Lldb-commits] [PATCH] D45348: Don't return error for settings set .experimental. settings that are absent

2018-04-05 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a reviewer: jingham.
jasonmolenda added a project: LLDB.
Herald added a subscriber: llvm-commits.

setting paths that include .experimental. are intended for settings that may be 
promoted to "real" settings in the future, or may be removed.  When users put 
these settings in their ~/.lldbinit files, we don't want to emit an error if 
the setting has gone away.  And if the setting has been promoted to a real 
setting, we want to do the right thing.

The first part of that -- not emitting an error -- did not work correctly.  I 
fixed that, and added tests to check all of these behaviors.


Repository:
  rL LLVM

https://reviews.llvm.org/D45348

Files:
  packages/Python/lldbsuite/test/settings/TestSettings.py
  source/Interpreter/OptionValueProperties.cpp


Index: source/Interpreter/OptionValueProperties.cpp
===
--- source/Interpreter/OptionValueProperties.cpp
+++ source/Interpreter/OptionValueProperties.cpp
@@ -207,12 +207,23 @@
   llvm::StringRef value) {
   Status error;
   const bool will_modify = true;
+  llvm::SmallVector components;
+  name.split(components, '.');
+  bool name_contains_experimental = false;
+  for (const auto &part : components)
+if (Properties::IsSettingExperimental(part))
+  name_contains_experimental = true;
+
+  
   lldb::OptionValueSP value_sp(GetSubValue(exe_ctx, name, will_modify, error));
   if (value_sp)
 error = value_sp->SetValueFromString(value, op);
   else {
-if (error.AsCString() == nullptr)
+// Don't set an error if the path contained .experimental. - those are
+// allowed to be missing and should silently fail.
+if (name_contains_experimental == false && error.AsCString() == nullptr) {
   error.SetErrorStringWithFormat("invalid value path '%s'", 
name.str().c_str());
+}
   }
   return error;
 }
Index: packages/Python/lldbsuite/test/settings/TestSettings.py
===
--- packages/Python/lldbsuite/test/settings/TestSettings.py
+++ packages/Python/lldbsuite/test/settings/TestSettings.py
@@ -524,3 +524,51 @@
  "target.process.extra-startup-command",
  "target.process.thread.step-avoid-regexp",
  "target.process.thread.trace-thread"])
+
+# settings under an ".experimental" domain should have two properties:
+#   1. If the name does not exist with "experimental" in the name path,
+#  the name lookup should try to find it without "experimental".  So
+#  a previously-experimental setting that has been promoted to a 
+#  "real" setting will still be set by the original name.
+#   2. Changing a setting with .experimental., name, where the setting
+#  does not exist either with ".experimental." or without, should
+#  not generate an error.  So if an experimental setting is removed,
+#  people who may have that in their ~/.lldbinit files should not see
+#  any errors.
+def test_experimental_settings(self):
+cmdinterp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+
+# Set target.arg0 to a known value, check that we can retrieve it via
+# the actual name and via .experimental.
+cmdinterp.HandleCommand("settings set target.arg0 first-value", result)
+self.assertEqual(result.Succeeded(), True)
+cmdinterp.HandleCommand("settings show target.arg0", result)
+self.assertEqual(result.Succeeded(), True)
+self.assertTrue("first-value" in result.GetOutput())
+cmdinterp.HandleCommand("settings show target.experimental.arg0", 
result)
+self.assertEqual(result.Succeeded(), True)
+self.assertTrue("first-value" in result.GetOutput())
+
+# Set target.arg0 to a new value via a target.experimental.arg0 name,
+# verify that we can read it back via both .experimental., and not.
+cmdinterp.HandleCommand("settings set target.experimental.arg0 
second-value", result)
+self.assertEqual(result.Succeeded(), True)
+cmdinterp.HandleCommand("settings show target.arg0", result)
+self.assertEqual(result.Succeeded(), True)
+self.assertTrue("second-value" in result.GetOutput())
+cmdinterp.HandleCommand("settings show target.experimental.arg0", 
result)
+self.assertEqual(result.Succeeded(), True)
+self.assertTrue("second-value" in result.GetOutput())
+
+# showing & setting an undefined .experimental. setting should 
generate no errors.
+cmdinterp.HandleCommand("settings show 
target.experimental.setting-which-does-not-exist", result)
+self.assertEqual(result.Succeeded(), True)
+self.assertEqual(result.GetOutput().rstrip(), "")
+cmdinterp.HandleCommand("settings set 
target.e

[Lldb-commits] [PATCH] D45298: [debugserver] Fix LC_BUILD_VERSION load command handling.

2018-04-05 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329374: [debugserver] Fix LC_BUILD_VERSION load command 
handling. (authored by friss, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45298?vs=141083&id=141280#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45298

Files:
  lldb/trunk/packages/Python/lldbsuite/test/decorators.py
  
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
  lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
  lldb/trunk/tools/debugserver/source/DNB.cpp
  lldb/trunk/tools/debugserver/source/DNB.h
  lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
  lldb/trunk/tools/debugserver/source/RNBRemote.cpp

Index: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
===
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
@@ -246,7 +246,10 @@
  uint64_t plo_pthread_tsd_base_address_offset,
  uint64_t plo_pthread_tsd_base_offset,
  uint64_t plo_pthread_tsd_entry_size);
-
+  const char *
+  GetDeploymentInfo(const struct load_command&, uint64_t load_command_address,
+uint32_t& major_version, uint32_t& minor_version,
+uint32_t& patch_version);
   bool GetMachOInformationFromMemory(nub_addr_t mach_o_header_addr,
  int wordsize,
  struct mach_o_information &inf);
Index: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -572,6 +572,68 @@
   plo_pthread_tsd_entry_size);
 }
 
+
+const char *MachProcess::GetDeploymentInfo(const struct load_command& lc,
+   uint64_t load_command_address,
+   uint32_t& major_version,
+   uint32_t& minor_version,
+   uint32_t& patch_version) {
+  uint32_t cmd = lc.cmd & ~LC_REQ_DYLD;
+  bool lc_cmd_known =
+cmd == LC_VERSION_MIN_IPHONEOS || cmd == LC_VERSION_MIN_MACOSX ||
+cmd == LC_VERSION_MIN_TVOS || cmd == LC_VERSION_MIN_WATCHOS;
+
+  if (lc_cmd_known) {
+struct version_min_command vers_cmd;
+if (ReadMemory(load_command_address, sizeof(struct version_min_command),
+   &vers_cmd) != sizeof(struct version_min_command)) {
+  return nullptr;
+}
+major_version = vers_cmd.sdk >> 16;
+minor_version = (vers_cmd.sdk >> 8) & 0xffu;
+patch_version = vers_cmd.sdk & 0xffu;
+
+switch (cmd) {
+case LC_VERSION_MIN_IPHONEOS:
+  return "iphoneos";
+case LC_VERSION_MIN_MACOSX:
+  return "macosx";
+case LC_VERSION_MIN_TVOS:
+  return "tvos";
+case LC_VERSION_MIN_WATCHOS:
+  return "watchos";
+default:
+  return nullptr;
+}
+  }
+#if defined (LC_BUILD_VERSION)
+  if (cmd == LC_BUILD_VERSION) {
+struct build_version_command build_vers;
+if (ReadMemory(load_command_address, sizeof(struct build_version_command),
+   &build_vers) != sizeof(struct build_version_command)) {
+  return nullptr;
+}
+major_version = build_vers.sdk >> 16;;
+minor_version = (build_vers.sdk >> 8) & 0xffu;
+patch_version = build_vers.sdk & 0xffu;
+
+switch (build_vers.platform) {
+case PLATFORM_MACOS:
+  return "macosx";
+case PLATFORM_IOS:
+  return "iphoneos";
+case PLATFORM_TVOS:
+  return "tvos";
+case PLATFORM_WATCHOS:
+  return "watchos";
+case PLATFORM_BRIDGEOS:
+  return "bridgeos";
+}
+  }
+#endif
+  return nullptr;
+}
+
 // Given an address, read the mach-o header and load commands out of memory to
 // fill in
 // the mach_o_information "inf" object.
@@ -670,91 +732,22 @@
   sizeof(struct uuid_command))
 uuid_copy(inf.uuid, uuidcmd.uuid);
 }
-bool lc_cmd_known =
-lc.cmd == LC_VERSION_MIN_IPHONEOS || lc.cmd == LC_VERSION_MIN_MACOSX;
-#if defined(LC_VERSION_MIN_TVOS)
-lc_cmd_known |= lc.cmd == LC_VERSION_MIN_TVOS;
-#endif
-#if defined(LC_VERSION_MIN_WATCHOS)
-lc_cmd_known |= lc.cmd == LC_VERSION_MIN_WATCHOS;
-#endif
-if (lc_cmd_known) {
-  struct version_min_command vers_cmd;
-  if (ReadMemory(load_cmds_p, sizeof(struct version_min_command),
- &vers_cmd) != sizeof(struct version_min_command)) {
-return false;
-  }
-  switch (lc.cmd) {
-  case LC_VERSION_MIN_IPHONEOS:
-inf.min_version_os_name = "iphoneos";
-br

[Lldb-commits] [lldb] r329374 - [debugserver] Fix LC_BUILD_VERSION load command handling.

2018-04-05 Thread Frederic Riss via lldb-commits
Author: friss
Date: Thu Apr  5 21:28:12 2018
New Revision: 329374

URL: http://llvm.org/viewvc/llvm-project?rev=329374&view=rev
Log:
[debugserver] Fix LC_BUILD_VERSION load command handling.

Summary:
In one of the 2 places the LC_BUILD_VERSION load command is handled, there
is a bug preventing us from actually handling them (the address where to
read the load command was not updated). This patch factors reading the
deployment target load commands into a helper and adds testing for the 2
code paths calling the helper.

The testing is a little bit complicated because the only times those load
commands matter is when debugging a simulator process. I added a new
decorator to check that a specific SDK is available. The actual testing was
fairly easy once I knew how to run a simulated process.

Reviewers: jasonmolenda, labath

Subscribers: lldb-commits

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
Modified:
lldb/trunk/packages/Python/lldbsuite/test/decorators.py
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
lldb/trunk/tools/debugserver/source/DNB.cpp
lldb/trunk/tools/debugserver/source/DNB.h
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
lldb/trunk/tools/debugserver/source/RNBRemote.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=329374&r1=329373&r2=329374&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Thu Apr  5 21:28:12 
2018
@@ -344,6 +344,28 @@ def no_debug_info_test(func):
 wrapper.__no_debug_info_test__ = True
 return wrapper
 
+def apple_simulator_test(platform):
+"""
+Decorate the test as a test requiring a simulator for a specific platform.
+
+Consider that a simulator is available if you have the corresponding SDK 
installed.
+The SDK identifiers for simulators are iphonesimulator, appletvsimulator, 
watchsimulator
+"""
+def should_skip_simulator_test():
+if lldbplatformutil.getHostPlatform() != 'darwin':
+return "simulator tests are run only on darwin hosts"
+try:
+DEVNULL = open(os.devnull, 'w')
+output = subprocess.check_output(["xcodebuild", "-showsdks"], 
stderr=DEVNULL)
+if re.search('%ssimulator' % platform, output):
+return None
+else:
+return "%s simulator is not supported on this system." % 
platform
+except subprocess.CalledProcessError:
+return "%s is not supported on this system (xcodebuild failed)." % 
feature
+
+return skipTestIfFn(should_skip_simulator_test)
+
 
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""

Added: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py?rev=329374&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
 Thu Apr  5 21:28:12 2018
@@ -0,0 +1,112 @@
+from __future__ import print_function
+
+
+import gdbremote_testcase
+import lldbgdbserverutils
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+import json
+
+class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def check_simulator_ostype(self, sdk, platform_names, arch='x86_64'):
+sim_devices_str = subprocess.check_output(['xcrun', 'simctl', 'list',
+   '-j', 'devices'])
+sim_devices = json.loads(sim_devices_str)['devices']
+# Find an available simulator for the requested platform
+deviceUDID = None
+for (runtime,devices) in sim_devices.items():
+if not any(p in runtime.lower() for p in platform_names):
+continue
+for device in devices:
+if device['availability'] != '(available)':
+continue
+deviceUDID = device['udid']
+break
+if deviceUDID != None:
+break
+
+# Launch the process using simctl
+self.assertIsNotNone(deviceUDID)
+exe_name = 'test_simulator_platform_{}'.format(platform_names[0])
+sdkroot = subprocess.che