[Lldb-commits] [PATCH] D51208: [DWARF] Fix dwarf5-index-is-used.cpp

2018-09-03 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Ok, thanks!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51208



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


[Lldb-commits] [lldb] r341296 - [DWARF] Fix dwarf5-index-is-used.cpp

2018-09-03 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Mon Sep  3 00:16:06 2018
New Revision: 341296

URL: http://llvm.org/viewvc/llvm-project?rev=341296&view=rev
Log:
[DWARF] Fix dwarf5-index-is-used.cpp

Summary:
`dwarf5-index-is-used.cpp` have been failing after rL340206, because `clang`
have stopped to emit pubnames by default after that change. Current patch adds
`-gpubnames` option to the `clang` command line in the test to emit pubnames.

Reviewers: labath, dblaikie

Reviewed By: labath

Subscribers: clayborg, probinson, teemperor, lldb-commits, aprantl, 
JDevlieghere, abidh, stella.stamenova

Tags: #lldb

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

Modified:
lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp

Modified: lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp?rev=341296&r1=341295&r2=341296&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp Mon Sep  3 
00:16:06 2018
@@ -2,7 +2,7 @@
 
 // REQUIRES: lld
 
-// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm 
-accel-tables=Dwarf
+// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm 
-accel-tables=Dwarf -gpubnames
 // RUN: ld.lld %t.o -o %t
 // RUN: lldb-test symbols %t | FileCheck %s
 


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


[Lldb-commits] [PATCH] D51208: [DWARF] Fix dwarf5-index-is-used.cpp

2018-09-03 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341296: [DWARF] Fix dwarf5-index-is-used.cpp (authored by 
aleksandr.urakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51208?vs=162336&id=163657#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51208

Files:
  lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp


Index: lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
===
--- lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
+++ lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
@@ -2,7 +2,7 @@
 
 // REQUIRES: lld
 
-// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm 
-accel-tables=Dwarf
+// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm 
-accel-tables=Dwarf -gpubnames
 // RUN: ld.lld %t.o -o %t
 // RUN: lldb-test symbols %t | FileCheck %s
 


Index: lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
===
--- lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
+++ lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
@@ -2,7 +2,7 @@
 
 // REQUIRES: lld
 
-// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
+// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf -gpubnames
 // RUN: ld.lld %t.o -o %t
 // RUN: lldb-test symbols %t | FileCheck %s
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51578: DWARFConcatenatingDataExtractor for D32167

2018-09-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 163663.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-forward.h
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFConcatenatingDataExtractor.cpp
  source/Plugins/SymbolFile/DWARF/DWARFConcatenatingDataExtractor.h
  source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -36,6 +36,7 @@
 #include "lldb/lldb-private.h"
 
 // Project includes
+#include "DWARFConcatenatingDataExtractor.h"
 #include "DWARFDataExtractor.h"
 #include "DWARFDefines.h"
 #include "DWARFIndex.h"
@@ -252,6 +253,9 @@
   const lldb_private::DWARFDataExtractor &get_apple_objc_data();
   const lldb_private::DWARFDataExtractor &get_gnu_debugaltlink();
 
+  const lldb_private::DWARFConcatenatingDataExtractor &
+  get_debug_concatenated_data();
+
   DWARFDebugAbbrev *DebugAbbrev();
 
   const DWARFDebugAbbrev *DebugAbbrev() const;
@@ -459,6 +463,8 @@
   std::unique_ptr m_dwp_symfile;
 
   lldb_private::DWARFDataExtractor m_dwarf_data;
+  llvm::once_flag m_concatenated_data_once;
+  lldb_private::DWARFConcatenatingDataExtractor m_concatenated_data;
 
   DWARFDataSegment m_data_debug_abbrev;
   DWARFDataSegment m_data_debug_addr;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -580,24 +580,8 @@
 const DWARFDataExtractor &
 SymbolFileDWARF::GetCachedSectionData(lldb::SectionType sect_type,
   DWARFDataSegment &data_segment) {
-  llvm::call_once(data_segment.m_flag, [&] {
+  llvm::call_once(data_segment.m_flag, [this, sect_type, &data_segment] {
 this->LoadSectionData(sect_type, std::ref(data_segment.m_data));
-if (sect_type == eSectionTypeDWARFDebugTypes) {
-  // To add .debug_types support in DWARF 4 and earlier with minimally
-  // invasive changes to the current DWARF parsing code, we pretend that
-  // any DIEs in .debug_types start at the end of the .debug_info section.
-  // All info in .debug_types is relative and has no external DIE
-  // references unless thay are DW_AT_signature references, so the DIE
-  // offset for things in the .debug_types. If we do this, then we can
-  // just add the type units to the compile units collection and treat all
-  // information just as we do for all other information in the DWARF and
-  // everything just works. If we were to try to split this out, we would
-  // end up having to change a TON of code. Also DWARF 5 will have compile
-  // and type units in the .debug_info, so coding it this way will prepare
-  // use for an easy transition to DWARF 5.
-  uint64_t debug_info_size = get_debug_info_data().GetByteSize();
-  data_segment.m_data.OffsetData(debug_info_size);
-}
   });
   return data_segment.m_data;
 }
@@ -695,6 +679,15 @@
   m_data_gnu_debugaltlink);
 }
 
+const DWARFConcatenatingDataExtractor &
+SymbolFileDWARF::get_debug_concatenated_data() {
+  llvm::call_once(m_concatenated_data_once, [&] {
+m_concatenated_data.AppendDWARFDataExtractor(get_debug_info_data());
+m_concatenated_data.AppendDWARFDataExtractor(get_debug_types_data());
+  });
+  return m_concatenated_data;
+}
+
 DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
   if (m_abbr.get() == NULL) {
 const DWARFDataExtractor &debug_abbrev_data = get_debug_abbrev_data();
@@ -3239,10 +3232,12 @@
   auto debug_info_data = die.GetData();
   if (DWARFFormValue::IsBlockForm(form_value.Form())) {
 // Retrieve the value as a bloc

[Lldb-commits] [PATCH] D51587: [Symtab][NFC] Added llvm_unreachable to supress compiler warning

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 created this revision.
xbolva00 added a reviewer: JDevlieghere.
Herald added a subscriber: lldb-commits.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51587

Files:
  source/Symbol/Symtab.cpp


Index: source/Symbol/Symtab.cpp
===
--- source/Symbol/Symtab.cpp
+++ source/Symbol/Symtab.cpp
@@ -249,6 +249,7 @@
   case Mangled::eManglingSchemeNone:
 return true;
   }
+  llvm_unreachable("unknown scheme!");
 }
 
 void Symtab::InitNameIndexes() {


Index: source/Symbol/Symtab.cpp
===
--- source/Symbol/Symtab.cpp
+++ source/Symbol/Symtab.cpp
@@ -249,6 +249,7 @@
   case Mangled::eManglingSchemeNone:
 return true;
   }
+  llvm_unreachable("unknown scheme!");
 }
 
 void Symtab::InitNameIndexes() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51587: [Symtab][NFC] Added llvm_unreachable to supress compiler warning

2018-09-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Looks reasonable. Did you run into this or is it just an improvement as you 
came across the code?


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51587



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


[Lldb-commits] [PATCH] D51587: [Symtab][NFC] Added llvm_unreachable to supress compiler warning

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 added a comment.

In https://reviews.llvm.org/D51587#1222009, @JDevlieghere wrote:

> Looks reasonable. Did you run into this or is it just an improvement as you 
> came across the code?


I just saw it as one of many GCC warnings when building lldb trunk.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51587



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


[Lldb-commits] [PATCH] D51591: [PseudoTerminal] Use llvm errno helpers

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 created this revision.
xbolva00 added a reviewer: JDevlieghere.
Herald added subscribers: lldb-commits, abidh.

LLVM provide (str)errno helpers, so convert code to use it.

Also fixes warning:
/home/xbolva00/LLVM/llvm/tools/lldb/source/Host/common/PseudoTerminal.cpp:248:25:
 warning: ignoring return value of ‘char* strerror_r(int, char*, size_t)’, 
declared with attribute warn_unused_result [-Wunused-result]

  ::strerror_r(errno, error_str, error_len);


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51591

Files:
  source/Host/common/PseudoTerminal.cpp

Index: source/Host/common/PseudoTerminal.cpp
===
--- source/Host/common/PseudoTerminal.cpp
+++ source/Host/common/PseudoTerminal.cpp
@@ -10,6 +10,8 @@
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/Config.h"
 
+#include "llvm/Support/Errno.h"
+
 #include 
 #include 
 #include 
@@ -83,27 +85,34 @@
   if (error_str)
 error_str[0] = '\0';
 
+  std::string strerror;
 #if !defined(LLDB_DISABLE_POSIX)
   // Open the master side of a pseudo terminal
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 return false;
   }
 
   // Grant access to the slave pseudo terminal
   if (::grantpt(m_master_fd) < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 CloseMasterFileDescriptor();
 return false;
   }
 
   // Clear the lock flag on the slave pseudo terminal
   if (::unlockpt(m_master_fd) < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 CloseMasterFileDescriptor();
 return false;
   }
@@ -131,6 +140,7 @@
   if (error_str)
 error_str[0] = '\0';
 
+  std::string strerror;
   CloseSlaveFileDescriptor();
 
   // Open the master side of a pseudo terminal
@@ -142,8 +152,10 @@
   m_slave_fd = ::open(slave_name, oflag);
 
   if (m_slave_fd < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 return false;
   }
 
@@ -166,16 +178,19 @@
   if (error_str)
 error_str[0] = '\0';
 
+  std::string strerror;
   if (m_master_fd < 0) {
 if (error_str)
   ::snprintf(error_str, error_len, "%s",
  "master file descriptor is invalid");
 return nullptr;
   }
   const char *slave_name = ::ptsname(m_master_fd);
 
-  if (error_str && slave_name == nullptr)
-::strerror_r(errno, error_str, error_len);
+  if (error_str && slave_name == nullptr) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 
   return slave_name;
 }
@@ -202,6 +217,8 @@
 lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
   if (error_str)
 error_str[0] = '\0';
+
+  std::string strerror;
   pid_t pid = LLDB_INVALID_PROCESS_ID;
 #if !defined(LLDB_DISABLE_POSIX)
   int flags = O_RDWR;
@@ -212,8 +229,10 @@
 pid = ::fork();
 if (pid < 0) {
   // Fork failed
-  if (error_str)
-::strerror_r(errno, error_str, error_len);
+  if (error_str) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 } else if (pid == 0) {
   // Child Process
   ::setsid();
@@ -228,24 +247,32 @@
 #if defined(TIOCSCTTY)
 // Acquire the controlling terminal
 if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) {
-  if (error_str)
-::strerror_r(errno, error_str, error_len);
+  if (error_str) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 #endif
 // Duplicate all stdio file descriptors to the slave pseudo terminal
 if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 
 if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  

[Lldb-commits] [PATCH] D51587: [Symtab][NFC] Added llvm_unreachable to supress compiler warning

2018-09-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Alright, thanks for the fix!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51587



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


[Lldb-commits] [PATCH] D51591: [PseudoTerminal] Use llvm errno helpers

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 updated this revision to Diff 163705.
xbolva00 added a comment.

- Moved variable into #if block


https://reviews.llvm.org/D51591

Files:
  source/Host/common/PseudoTerminal.cpp

Index: source/Host/common/PseudoTerminal.cpp
===
--- source/Host/common/PseudoTerminal.cpp
+++ source/Host/common/PseudoTerminal.cpp
@@ -10,6 +10,8 @@
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/Config.h"
 
+#include "llvm/Support/Errno.h"
+
 #include 
 #include 
 #include 
@@ -84,26 +86,33 @@
 error_str[0] = '\0';
 
 #if !defined(LLDB_DISABLE_POSIX)
+  std::string strerror;
   // Open the master side of a pseudo terminal
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 return false;
   }
 
   // Grant access to the slave pseudo terminal
   if (::grantpt(m_master_fd) < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 CloseMasterFileDescriptor();
 return false;
   }
 
   // Clear the lock flag on the slave pseudo terminal
   if (::unlockpt(m_master_fd) < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 CloseMasterFileDescriptor();
 return false;
   }
@@ -131,6 +140,7 @@
   if (error_str)
 error_str[0] = '\0';
 
+  std::string strerror;
   CloseSlaveFileDescriptor();
 
   // Open the master side of a pseudo terminal
@@ -142,8 +152,10 @@
   m_slave_fd = ::open(slave_name, oflag);
 
   if (m_slave_fd < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 return false;
   }
 
@@ -166,16 +178,19 @@
   if (error_str)
 error_str[0] = '\0';
 
+  std::string strerror;
   if (m_master_fd < 0) {
 if (error_str)
   ::snprintf(error_str, error_len, "%s",
  "master file descriptor is invalid");
 return nullptr;
   }
   const char *slave_name = ::ptsname(m_master_fd);
 
-  if (error_str && slave_name == nullptr)
-::strerror_r(errno, error_str, error_len);
+  if (error_str && slave_name == nullptr) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 
   return slave_name;
 }
@@ -204,16 +219,19 @@
 error_str[0] = '\0';
   pid_t pid = LLDB_INVALID_PROCESS_ID;
 #if !defined(LLDB_DISABLE_POSIX)
+  std::string strerror;
   int flags = O_RDWR;
   flags |= O_CLOEXEC;
   if (OpenFirstAvailableMaster(flags, error_str, error_len)) {
 // Successfully opened our master pseudo terminal
 
 pid = ::fork();
 if (pid < 0) {
   // Fork failed
-  if (error_str)
-::strerror_r(errno, error_str, error_len);
+  if (error_str) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 } else if (pid == 0) {
   // Child Process
   ::setsid();
@@ -228,24 +246,32 @@
 #if defined(TIOCSCTTY)
 // Acquire the controlling terminal
 if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) {
-  if (error_str)
-::strerror_r(errno, error_str, error_len);
+  if (error_str) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 #endif
 // Duplicate all stdio file descriptors to the slave pseudo terminal
 if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 
 if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 
 if (::dup2(m_slave_fd, STDERR_FILENO) != STDERR_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
  

[Lldb-commits] [PATCH] D51591: [PseudoTerminal] Use llvm errno helpers

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 updated this revision to Diff 163706.
xbolva00 added a comment.

- Removed include errno.h


https://reviews.llvm.org/D51591

Files:
  source/Host/common/PseudoTerminal.cpp

Index: source/Host/common/PseudoTerminal.cpp
===
--- source/Host/common/PseudoTerminal.cpp
+++ source/Host/common/PseudoTerminal.cpp
@@ -10,7 +10,8 @@
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/Config.h"
 
-#include 
+#include "llvm/Support/Errno.h"
+
 #include 
 #include 
 #include 
@@ -84,26 +85,33 @@
 error_str[0] = '\0';
 
 #if !defined(LLDB_DISABLE_POSIX)
+  std::string strerror;
   // Open the master side of a pseudo terminal
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 return false;
   }
 
   // Grant access to the slave pseudo terminal
   if (::grantpt(m_master_fd) < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 CloseMasterFileDescriptor();
 return false;
   }
 
   // Clear the lock flag on the slave pseudo terminal
   if (::unlockpt(m_master_fd) < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 CloseMasterFileDescriptor();
 return false;
   }
@@ -131,6 +139,7 @@
   if (error_str)
 error_str[0] = '\0';
 
+  std::string strerror;
   CloseSlaveFileDescriptor();
 
   // Open the master side of a pseudo terminal
@@ -142,8 +151,10 @@
   m_slave_fd = ::open(slave_name, oflag);
 
   if (m_slave_fd < 0) {
-if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+if (error_str) {
+  strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
 return false;
   }
 
@@ -166,16 +177,19 @@
   if (error_str)
 error_str[0] = '\0';
 
+  std::string strerror;
   if (m_master_fd < 0) {
 if (error_str)
   ::snprintf(error_str, error_len, "%s",
  "master file descriptor is invalid");
 return nullptr;
   }
   const char *slave_name = ::ptsname(m_master_fd);
 
-  if (error_str && slave_name == nullptr)
-::strerror_r(errno, error_str, error_len);
+  if (error_str && slave_name == nullptr) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 
   return slave_name;
 }
@@ -204,16 +218,19 @@
 error_str[0] = '\0';
   pid_t pid = LLDB_INVALID_PROCESS_ID;
 #if !defined(LLDB_DISABLE_POSIX)
+  std::string strerror;
   int flags = O_RDWR;
   flags |= O_CLOEXEC;
   if (OpenFirstAvailableMaster(flags, error_str, error_len)) {
 // Successfully opened our master pseudo terminal
 
 pid = ::fork();
 if (pid < 0) {
   // Fork failed
-  if (error_str)
-::strerror_r(errno, error_str, error_len);
+  if (error_str) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 } else if (pid == 0) {
   // Child Process
   ::setsid();
@@ -228,24 +245,32 @@
 #if defined(TIOCSCTTY)
 // Acquire the controlling terminal
 if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) {
-  if (error_str)
-::strerror_r(errno, error_str, error_len);
+  if (error_str) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 #endif
 // Duplicate all stdio file descriptors to the slave pseudo terminal
 if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 
 if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 }
 
 if (::dup2(m_slave_fd, STDERR_FILENO) != STDERR_FILENO) {
-  if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+  if (error_str && !error_str[0]) {
+strerror = llvm::sys::StrError();
+::snprintf(error_str, error_len, "%s", strerror.c_str());
+  }
 

[Lldb-commits] [PATCH] D51162: [PDB] Restore AST from PDB symbols

2018-09-03 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 163708.
aleksandr.urakov added a comment.

Added the dumping AST ability to `lldb-test`; adding a corresponding test for 
the patch.


https://reviews.llvm.org/D51162

Files:
  include/lldb/Symbol/ClangASTContext.h
  lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp
  lit/SymbolFile/PDB/ast-restore.test
  lit/SymbolFile/PDB/class-layout.test
  lit/SymbolFile/PDB/func-symbols.test
  lit/SymbolFile/PDB/pointers.test
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  source/Plugins/SymbolFile/PDB/PDBASTParser.h
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  source/Symbol/ClangASTContext.cpp
  tools/lldb-test/lldb-test.cpp

Index: tools/lldb-test/lldb-test.cpp
===
--- tools/lldb-test/lldb-test.cpp
+++ tools/lldb-test/lldb-test.cpp
@@ -148,6 +148,10 @@
   return Result;
 }
 
+static cl::opt DumpAST("dump-ast",
+ cl::desc("Dump AST restored from symbols."),
+ cl::sub(SymbolsSubcommand));
+
 static cl::opt Verify("verify", cl::desc("Verify symbol information."),
 cl::sub(SymbolsSubcommand));
 
@@ -165,6 +169,7 @@
 static Error findTypes(lldb_private::Module &Module);
 static Error findVariables(lldb_private::Module &Module);
 static Error dumpModule(lldb_private::Module &Module);
+static Error dumpAST(lldb_private::Module &Module);
 static Error verify(lldb_private::Module &Module);
 
 static Expected getAction();
@@ -509,6 +514,34 @@
   return Error::success();
 }
 
+Error opts::symbols::dumpAST(lldb_private::Module &Module) {
+  SymbolVendor &plugin = *Module.GetSymbolVendor();
+
+  auto symfile = plugin.GetSymbolFile();
+  if (!symfile)
+return make_string_error("Module has no symbol file.");
+
+  auto clang_ast_ctx = llvm::dyn_cast_or_null(
+  symfile->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus));
+  if (!clang_ast_ctx)
+return make_string_error("Can't retrieve Clang AST context.");
+
+  auto ast_ctx = clang_ast_ctx->getASTContext();
+  if (!ast_ctx)
+return make_string_error("Can't retrieve AST context.");
+
+  auto tu = ast_ctx->getTranslationUnitDecl();
+  if (!tu)
+return make_string_error("Can't retrieve translation unit declaration.");
+
+  symfile->ParseDeclsForContext(CompilerDeclContext(
+  clang_ast_ctx, static_cast(tu)));
+
+  tu->print(outs());
+
+  return Error::success();
+}
+
 Error opts::symbols::verify(lldb_private::Module &Module) {
   SymbolVendor &plugin = *Module.GetSymbolVendor();
 
@@ -562,6 +595,10 @@
 }
 
 Expected opts::symbols::getAction() {
+  if (Verify && DumpAST)
+return make_string_error(
+"Cannot both verify symbol information and dump AST.");
+
   if (Verify) {
 if (Find != FindType::None)
   return make_string_error(
@@ -574,6 +611,18 @@
 return verify;
   }
 
+  if (DumpAST) {
+if (Find != FindType::None)
+  return make_string_error(
+  "Cannot both search and dump AST.");
+if (Regex || !Context.empty() || !Name.empty() || !File.empty() ||
+Line != 0)
+  return make_string_error(
+  "-regex, -context, -name, -file and -line options are not "
+  "applicable for dumping AST.");
+return dumpAST;
+  }
+
   if (Regex && !Context.empty())
 return make_string_error(
 "Cannot search using both regular expressions and context.");
@@ -632,6 +681,8 @@
"using line numbers.");
 return findVariables;
   }
+
+  llvm_unreachable("Unsupported symbol action.");
 }
 
 int opts::symbols::dumpSymbols(Debugger &Dbg) {
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -2212,6 +2212,9 @@
   false);// IsFixed
 
   if (enum_decl) {
+if (decl_ctx)
+  decl_ctx->addDecl(enum_decl);
+
 // TODO: check if we should be setting the promotion type too?
 enum_decl->setIntegerType(ClangUtil::GetQualType(integer_clang_type));
 
@@ -4739,6 +4742,8 @@
 
 decl->setAccess(clang::AS_public); // TODO respect proper access specifier
 
+decl_ctx->addDecl(decl);
+
 // Get a uniqued clang::QualType for the typedef decl type
 return CompilerType(clang_ast, clang_ast->getTypedefType(decl));
   }
@@ -7746,6 +7751,15 @@
 return qual_type->getAsTagDecl();
 }
 
+clang::TypedefNameDecl *
+ClangASTContext::GetAsTypedefDecl(const CompilerType &type) {
+  const clang::TypedefType *typedef_type =
+  llvm::dyn_cast(ClangUtil::GetQualType(type));
+  if (typedef_type)
+return typedef_type->getDecl();
+  return nullptr;
+}
+
 clang::CXXRecordDecl *
 ClangASTContext::GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type) {
   return GetCanonicalQualType(type)->getAsCXXRecordDecl();
@@ -8831,7 +8845,7 @@
   return false;
 }
 
-bool ClangASTContext::AddEnumeratio

[Lldb-commits] [PATCH] D51591: [PseudoTerminal][NFC] Use llvm errno helpers

2018-09-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Any chance we could wrap this in a helper function?


https://reviews.llvm.org/D51591



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


[Lldb-commits] [PATCH] D51594: [ARC] Make char unsigned by default

2018-09-03 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov created this revision.
apolyakov added a reviewer: tatyana-krasnukha.

This patch specifies 'char' default sign on ARC.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51594

Files:
  source/Utility/ArchSpec.cpp


Index: source/Utility/ArchSpec.cpp
===
--- source/Utility/ArchSpec.cpp
+++ source/Utility/ArchSpec.cpp
@@ -815,6 +815,7 @@
   case llvm::Triple::ppc64le:
   case llvm::Triple::systemz:
   case llvm::Triple::xcore:
+  case llvm::Triple::arc:
 return false;
   }
 }


Index: source/Utility/ArchSpec.cpp
===
--- source/Utility/ArchSpec.cpp
+++ source/Utility/ArchSpec.cpp
@@ -815,6 +815,7 @@
   case llvm::Triple::ppc64le:
   case llvm::Triple::systemz:
   case llvm::Triple::xcore:
+  case llvm::Triple::arc:
 return false;
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51591: [PseudoTerminal][NFC] Use llvm errno helpers

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 updated this revision to Diff 163712.
xbolva00 added a comment.

- Added helper function


https://reviews.llvm.org/D51591

Files:
  source/Host/common/PseudoTerminal.cpp

Index: source/Host/common/PseudoTerminal.cpp
===
--- source/Host/common/PseudoTerminal.cpp
+++ source/Host/common/PseudoTerminal.cpp
@@ -10,7 +10,8 @@
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/Config.h"
 
-#include 
+#include "llvm/Support/Errno.h"
+
 #include 
 #include 
 #include 
@@ -27,6 +28,14 @@
 using namespace lldb_private;
 
 //--
+// Write string describing error number
+//--
+static void ErrnoToStr(char *error_str, size_t error_len) {
+  std::string strerror = llvm::sys::StrError();
+  ::snprintf(error_str, error_len, "%s", strerror.c_str());
+}
+
+//--
 // PseudoTerminal constructor
 //--
 PseudoTerminal::PseudoTerminal()
@@ -88,22 +97,22 @@
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 return false;
   }
 
   // Grant access to the slave pseudo terminal
   if (::grantpt(m_master_fd) < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 CloseMasterFileDescriptor();
 return false;
   }
 
   // Clear the lock flag on the slave pseudo terminal
   if (::unlockpt(m_master_fd) < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 CloseMasterFileDescriptor();
 return false;
   }
@@ -143,7 +152,7 @@
 
   if (m_slave_fd < 0) {
 if (error_str)
-  ::strerror_r(errno, error_str, error_len);
+  ErrnoToStr(error_str, error_len);
 return false;
   }
 
@@ -175,7 +184,7 @@
   const char *slave_name = ::ptsname(m_master_fd);
 
   if (error_str && slave_name == nullptr)
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 
   return slave_name;
 }
@@ -213,7 +222,7 @@
 if (pid < 0) {
   // Fork failed
   if (error_str)
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 } else if (pid == 0) {
   // Child Process
   ::setsid();
@@ -229,23 +238,23 @@
 // Acquire the controlling terminal
 if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) {
   if (error_str)
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
 #endif
 // Duplicate all stdio file descriptors to the slave pseudo terminal
 if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) {
   if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
 
 if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) {
   if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
 
 if (::dup2(m_slave_fd, STDERR_FILENO) != STDERR_FILENO) {
   if (error_str && !error_str[0])
-::strerror_r(errno, error_str, error_len);
+ErrnoToStr(error_str, error_len);
 }
   }
 } else {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51594: [ARC] Make char unsigned by default

2018-09-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha accepted this revision.
tatyana-krasnukha added a subscriber: clayborg.
tatyana-krasnukha added a comment.
This revision is now accepted and ready to land.

Good to me, if no one is confused about absent general support of ARC target. 
Please, add @clayborg to reviewers.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51594



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


[Lldb-commits] [PATCH] D51591: [PseudoTerminal][NFC] Use llvm errno helpers

2018-09-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM, thx!


https://reviews.llvm.org/D51591



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


[Lldb-commits] [PATCH] D51600: [NFC] Fixed enum constant in boolean context error

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 created this revision.
xbolva00 added a reviewer: JDevlieghere.
Herald added subscribers: lldb-commits, abidh.

/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:656:59:
 warning: enum constant in boolean context [-Wint-in-bool-context]

  if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
^~~~

/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:658:62:
 warning: enum constant in boolean context [-Wint-in-bool-context]

  if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51600

Files:
  source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp


Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
===
--- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -652,11 +652,12 @@
 
   llvm::MachO::mach_header mh;
   size_t size_to_read = 512;
-  if (ReadMachHeader (m_load_address, process, mh)) {
-if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
-  size_to_read = sizeof (llvm::MachO::mach_header) + mh.sizeofcmds;
-if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)
-  size_to_read = sizeof (llvm::MachO::mach_header_64) + mh.sizeofcmds;
+  if (ReadMachHeader(m_load_address, process, mh)) {
+if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC)
+  size_to_read = sizeof(llvm::MachO::mach_header) + mh.sizeofcmds;
+if (mh.magic == llvm::MachO::MH_CIGAM_64 ||
+mh.magic == llvm::MachO::MH_MAGIC_64)
+  size_to_read = sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
   }
 
   ModuleSP memory_module_sp =


Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
===
--- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -652,11 +652,12 @@
 
   llvm::MachO::mach_header mh;
   size_t size_to_read = 512;
-  if (ReadMachHeader (m_load_address, process, mh)) {
-if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
-  size_to_read = sizeof (llvm::MachO::mach_header) + mh.sizeofcmds;
-if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)
-  size_to_read = sizeof (llvm::MachO::mach_header_64) + mh.sizeofcmds;
+  if (ReadMachHeader(m_load_address, process, mh)) {
+if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC)
+  size_to_read = sizeof(llvm::MachO::mach_header) + mh.sizeofcmds;
+if (mh.magic == llvm::MachO::MH_CIGAM_64 ||
+mh.magic == llvm::MachO::MH_MAGIC_64)
+  size_to_read = sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
   }
 
   ModuleSP memory_module_sp =
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51557: Replace uses of LazyBool with LazyBool template

2018-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 163741.
teemperor marked an inline comment as done.
teemperor added a comment.

- Now using a typedef instead of a macro.
- Using LLVM code style in Lazy.h
- Renamed UpdateX to CalculateX


https://reviews.llvm.org/D51557

Files:
  include/lldb/DataFormatters/ValueObjectPrinter.h
  include/lldb/Symbol/CompileUnit.h
  include/lldb/Target/ObjCLanguageRuntime.h
  include/lldb/Utility/Lazy.h
  source/DataFormatters/ValueObjectPrinter.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Symbol/CompileUnit.cpp
  source/Target/ObjCLanguageRuntime.cpp
  unittests/Utility/CMakeLists.txt
  unittests/Utility/LazyTest.cpp

Index: unittests/Utility/LazyTest.cpp
===
--- /dev/null
+++ unittests/Utility/LazyTest.cpp
@@ -0,0 +1,72 @@
+//===-- LazyTest.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Utility/Lazy.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+namespace {
+class LazyClass {
+  bool UpdateFoo() {
+++m_updates_called;
+return m_foo_value;
+  }
+
+public:
+  LazyBoolMember m_foo;
+  bool getFoo() { return m_foo.get(*this); }
+  bool m_foo_value = true;
+  int m_updates_called = 0;
+};
+} // namespace
+
+TEST(LazyTest, UpdateCount) {
+  LazyClass l;
+  EXPECT_EQ(0, l.m_updates_called);
+
+  l.getFoo();
+  EXPECT_EQ(1, l.m_updates_called);
+  l.getFoo();
+  EXPECT_EQ(1, l.m_updates_called);
+  l.getFoo();
+  EXPECT_EQ(1, l.m_updates_called);
+}
+
+TEST(LazyTest, Value) {
+  {
+LazyClass l1;
+EXPECT_EQ(l1.m_foo_value, l1.getFoo());
+  }
+
+  {
+LazyClass l2;
+bool old_value = l2.m_foo_value;
+l2.m_foo_value = !l2.m_foo_value;
+EXPECT_NE(old_value, l2.getFoo());
+  }
+}
+
+TEST(LazyTest, Reset) {
+  LazyClass l;
+  EXPECT_EQ(0, l.m_updates_called);
+  l.m_foo.reset();
+  EXPECT_EQ(0, l.m_updates_called);
+
+  l.getFoo();
+  EXPECT_EQ(1, l.m_updates_called);
+
+  l.m_foo.reset();
+  EXPECT_EQ(1, l.m_updates_called);
+
+  l.getFoo();
+  EXPECT_EQ(2, l.m_updates_called);
+  l.getFoo();
+  EXPECT_EQ(2, l.m_updates_called);
+}
Index: unittests/Utility/CMakeLists.txt
===
--- unittests/Utility/CMakeLists.txt
+++ unittests/Utility/CMakeLists.txt
@@ -10,6 +10,7 @@
   FileSpecTest.cpp
   FlagsTest.cpp
   JSONTest.cpp
+  LazyTest.cpp
   LogTest.cpp
   NameMatchesTest.cpp
   PredicateTest.cpp
Index: source/Target/ObjCLanguageRuntime.cpp
===
--- source/Target/ObjCLanguageRuntime.cpp
+++ source/Target/ObjCLanguageRuntime.cpp
@@ -35,7 +35,6 @@
 
 ObjCLanguageRuntime::ObjCLanguageRuntime(Process *process)
 : LanguageRuntime(process), m_impl_cache(),
-  m_has_new_literals_and_indexing(eLazyBoolCalculate),
   m_isa_to_descriptor(), m_hash_to_isa_map(), m_type_size_cache(),
   m_isa_to_descriptor_stop_id(UINT32_MAX), m_complete_class_cache(),
   m_negative_complete_class_cache() {}
@@ -154,6 +153,21 @@
 return false;
 }
 
+bool ObjCLanguageRuntime::ClassDescriptor::CalculateKVO() {
+  const char *class_name = GetClassName().AsCString();
+  if (class_name && *class_name)
+return strstr(class_name, "NSKVONotifying_") == class_name;
+  return false;
+}
+
+bool ObjCLanguageRuntime::ClassDescriptor::CalculateCFType() {
+  const char *class_name = GetClassName().AsCString();
+  if (class_name && *class_name)
+return strcmp(class_name, "__NSCFType") == 0 ||
+   strcmp(class_name, "NSCFType") == 0;
+  return false;
+}
+
 ObjCLanguageRuntime::ObjCISA
 ObjCLanguageRuntime::GetISA(const ConstString &name) {
   ISAToDescriptorIterator pos = GetDescriptorIterator(name);
Index: source/Symbol/CompileUnit.cpp
===
--- source/Symbol/CompileUnit.cpp
+++ source/Symbol/CompileUnit.cpp
@@ -23,8 +23,9 @@
  lldb_private::LazyBool is_optimized)
 : ModuleChild(module_sp), FileSpec(pathname, false), UserID(cu_sym_id),
   m_user_data(user_data), m_language(language), m_flags(0),
-  m_support_files(), m_line_table_ap(), m_variables(),
-  m_is_optimized(is_optimized) {
+  m_support_files(), m_line_table_ap(), m_variables() {
+  if (is_optimized != eLazyBoolCalculate)
+m_is_optimized.set(is_optimized == eLazyBoolYes);
   if (language != eLanguageTypeUnknown)
 m_flags.Set(flagsParsedLanguage);
   assert(module_sp);
@@ -36,8 +37,9 @@
  lldb_private::LazyBool is_optimized)
 : ModuleChild(module_sp), FileSpec(fspec), UserID(cu_sym_id),
   m_user_data(user_data

[Lldb-commits] [PATCH] D51601: [NFC] Use llvm_unreachable instead of lldb::assert

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 created this revision.
xbolva00 added a reviewer: JDevlieghere.
Herald added a subscriber: lldb-commits.

Fixes implicit fall through warnings


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51601

Files:
  source/Host/common/Editline.cpp


Index: source/Host/common/Editline.cpp
===
--- source/Host/common/Editline.cpp
+++ source/Host/common/Editline.cpp
@@ -526,7 +526,7 @@
 break;
 
   case lldb::eConnectionStatusInterrupted:
-lldbassert(0 && "Interrupts should have been handled above.");
+llvm_unreachable("Interrupts should have been handled above.");
 
   case lldb::eConnectionStatusError:// Check GetError() for details
   case lldb::eConnectionStatusTimedOut: // Request timed out


Index: source/Host/common/Editline.cpp
===
--- source/Host/common/Editline.cpp
+++ source/Host/common/Editline.cpp
@@ -526,7 +526,7 @@
 break;
 
   case lldb::eConnectionStatusInterrupted:
-lldbassert(0 && "Interrupts should have been handled above.");
+llvm_unreachable("Interrupts should have been handled above.");
 
   case lldb::eConnectionStatusError:// Check GetError() for details
   case lldb::eConnectionStatusTimedOut: // Request timed out
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48704: [LLDB] Fix for "Bug 37950: ExecutionContext::GetByteOrder() always returns endian::InlHostByteOrder()"

2018-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

My question about a good test case template was more directed at everyone :)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D48704



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


[Lldb-commits] [PATCH] D51602: Print the correct error when our DynamicCheckerFunctions fail to install

2018-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: LLDB.
Herald added a subscriber: lldb-commits.

The check is inverted here: If we have error messages, we should print those 
instead
of our default error message. But currently we print the default message when we
actually have a sensible error to print.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51602

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


Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1162,9 +1162,9 @@
 
   if (!dynamic_checkers->Install(install_diagnostics, exe_ctx)) {
 if (install_diagnostics.Diagnostics().size())
-  err.SetErrorString("couldn't install checkers, unknown error");
-else
   err.SetErrorString(install_diagnostics.GetString().c_str());
+else
+  err.SetErrorString("couldn't install checkers, unknown error");
 
 return err;
   }


Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1162,9 +1162,9 @@
 
   if (!dynamic_checkers->Install(install_diagnostics, exe_ctx)) {
 if (install_diagnostics.Diagnostics().size())
-  err.SetErrorString("couldn't install checkers, unknown error");
-else
   err.SetErrorString(install_diagnostics.GetString().c_str());
+else
+  err.SetErrorString("couldn't install checkers, unknown error");
 
 return err;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51602: Print the correct error when our DynamicCheckerFunctions fail to install

2018-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Don't see a way to test this, as this can only be triggered when something in 
LLDB is going really wrong. That piece of code also has zero test coverage, so 
I'll just merge it in a few weeks or so unless someone comes up with a good way 
to test this.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51602



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


[Lldb-commits] [PATCH] D51601: [NFC] Use llvm_unreachable instead of lldb::assert

2018-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51601



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


[Lldb-commits] [PATCH] D51600: [NFC] Fixed enum constant in boolean context error

2018-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

This whole code doesn't seem to have test coverage, so I'll not demand a test 
for this. Also this patch is clearly fixing a typo, so let's get this in.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51600



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


[Lldb-commits] [PATCH] D51604: Terminate debugger if an assert was hit

2018-09-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 created this revision.
xbolva00 added reviewers: JDevlieghere, teemperor.
Herald added a subscriber: lldb-commits.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51604

Files:
  source/Utility/LLDBAssert.cpp


Index: source/Utility/LLDBAssert.cpp
===
--- source/Utility/LLDBAssert.cpp
+++ source/Utility/LLDBAssert.cpp
@@ -28,5 +28,6 @@
 llvm::sys::PrintStackTrace(errs());
 errs() << "please file a bug report against lldb reporting this failure "
   "log, and as many details as possible\n";
+exit(1);  
   }
 }


Index: source/Utility/LLDBAssert.cpp
===
--- source/Utility/LLDBAssert.cpp
+++ source/Utility/LLDBAssert.cpp
@@ -28,5 +28,6 @@
 llvm::sys::PrintStackTrace(errs());
 errs() << "please file a bug report against lldb reporting this failure "
   "log, and as many details as possible\n";
+exit(1);  
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits