[Lldb-commits] [lldb] r290117 - Expression evaluation for overloaded C functions (redux)

2016-12-19 Thread Luke Drummond via lldb-commits
Author: ldrumm
Date: Mon Dec 19 11:22:44 2016
New Revision: 290117

URL: http://llvm.org/viewvc/llvm-project?rev=290117&view=rev
Log:
Expression evaluation for overloaded C functions (redux)

This is a redux of [Ewan's patch](https://reviews.llvm.org/D17957) , refactored
to properly substitute primitive  types using a hook in the itanium demangler,
and updated after the previous patch went stale

The new `SubsPrimitiveParmItanium` function takes a symbol name and replacement
primitive type parameter as before but parses it using the FastDemangler, which
has been modified to be able to notify clients of parse events (primitive types
at this point).

Additionally, we now use a `set` of `ConstStrings` instead of a `vector` so
that we don't try and resolve the same invalid candidate multiple times.

Differential Revision: https://reviews.llvm.org/D27223
Subscribers: lldb-commits


Modified:
lldb/trunk/include/lldb/Core/FastDemangle.h
lldb/trunk/source/Core/FastDemangle.cpp
lldb/trunk/source/Expression/IRExecutionUnit.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h

Modified: lldb/trunk/include/lldb/Core/FastDemangle.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FastDemangle.h?rev=290117&r1=290116&r2=290117&view=diff
==
--- lldb/trunk/include/lldb/Core/FastDemangle.h (original)
+++ lldb/trunk/include/lldb/Core/FastDemangle.h Mon Dec 19 11:22:44 2016
@@ -10,11 +10,17 @@
 #ifndef liblldb_FastDemangle_h_
 #define liblldb_FastDemangle_h_
 
+#include 
+
+#include 
+
 namespace lldb_private {
 
 char *FastDemangle(const char *mangled_name);
 
-char *FastDemangle(const char *mangled_name, long mangled_name_length);
+char *
+FastDemangle(const char *mangled_name, size_t mangled_name_length,
+ std::function primitive_type_hook = nullptr);
 }
 
 #endif

Modified: lldb/trunk/source/Core/FastDemangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FastDemangle.cpp?rev=290117&r1=290116&r2=290117&view=diff
==
--- lldb/trunk/source/Core/FastDemangle.cpp (original)
+++ lldb/trunk/source/Core/FastDemangle.cpp Mon Dec 19 11:22:44 2016
@@ -11,6 +11,9 @@
 #include 
 #include 
 
+#include 
+
+#include "lldb/Core/FastDemangle.h"
 #include "lldb/lldb-private.h"
 
 //#define DEBUG_FAILURES 1
@@ -119,7 +122,9 @@ public:
   /// @param storage_size Number of bytes of space available scratch memory
   /// referenced by storage_ptr
 
-  SymbolDemangler(void *storage_ptr, int storage_size) {
+  SymbolDemangler(void *storage_ptr, size_t storage_size,
+  std::function builtins_hook = nullptr)
+  : m_builtins_hook(builtins_hook) {
 // Use up to 1/8th of the provided space for rewrite ranges
 m_rewrite_ranges_size = (storage_size >> 3) / sizeof(BufferRange);
 m_rewrite_ranges = (BufferRange *)storage_ptr;
@@ -509,6 +514,9 @@ private:
   //::= u # vendor extended type
 
   const char *TryParseBuiltinType() {
+if (m_builtins_hook)
+  m_builtins_hook(m_read_ptr);
+
 switch (*m_read_ptr++) {
 case 'v':
   return "void";
@@ -1150,6 +1158,23 @@ private:
 return RewriteTemplateArg(count + 1);
   }
 
+  // 
+  // Dv  _ 
+  bool TryParseVectorType() {
+const int dimension = TryParseNumber();
+if (dimension == -1)
+  return false;
+
+if (*m_read_ptr++ != '_')
+  return false;
+
+char vec_dimens[32] = {'\0'};
+::snprintf(vec_dimens, sizeof vec_dimens - 1, " __vector(%d)", dimension);
+ParseType();
+Write(vec_dimens);
+return true;
+  }
+
   //  ::= 
   //::= 
   //::= 
@@ -1191,9 +1216,12 @@ private:
 if (!ParseType())
   return false;
 break;
+  case 'v':
+if (!TryParseVectorType())
+  return false;
+break;
   case 'T':
   case 't':
-  case 'v':
   default:
 #ifdef DEBUG_FAILURES
 printf("*** Unsupported type: %.3s\n", failed_type);
@@ -2346,6 +2374,7 @@ private:
   char *m_write_ptr;
   int m_next_template_arg_index;
   int m_next_substitute_index;
+  std::function m_builtins_hook;
 };
 
 } // Anonymous namespace
@@ -2358,9 +2387,10 @@ char *FastDemangle(const char *mangled_n
   return demangler.GetDemangledCopy(mangled_name);
 }
 
-char *FastDemangle(const char *mangled_name, long mangled_name_length) {
+char *FastDemangle(const char *mangled_name, size_t mangled_name_length,
+   std::function builtins_hook) {
   char buffer[16384];
-  SymbolDemangler demangler(buffer, sizeof(buffer));
+  SymbolDemangler demangler(buffer, sizeof(buffer), builtins_hook);
   return demangler.GetDemangledCopy(mangled_name, mangled_name_length);
 }
 } // lldb_p

[Lldb-commits] [PATCH] D27223: Expression evaluation for overloaded C functions (redux)

2016-12-19 Thread Luke Drummond via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290117: Expression evaluation for overloaded C functions 
(redux) (authored by ldrumm).

Changed prior to commit:
  https://reviews.llvm.org/D27223?vs=81753&id=81967#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27223

Files:
  lldb/trunk/include/lldb/Core/FastDemangle.h
  lldb/trunk/source/Core/FastDemangle.cpp
  lldb/trunk/source/Expression/IRExecutionUnit.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h

Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -12,6 +12,7 @@
 
 // C Includes
 // C++ Includes
+#include 
 #include 
 
 // Other libraries and framework includes
@@ -93,7 +94,6 @@
   }
 
   std::unique_ptr GetTypeScavenger() override;
-  
   lldb::TypeCategoryImplSP GetFormatters() override;
 
   HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override;
@@ -142,6 +142,12 @@
   static uint32_t FindEquivalentNames(ConstString type_name,
   std::vector &equivalents);
 
+  // Given a mangled function name, calculates some alternative manglings since
+  // the compiler mangling may not line up with the symbol we are expecting
+  static uint32_t
+  FindAlternateFunctionManglings(const ConstString mangled,
+ std::set &candidates);
+
   //--
   // PluginInterface protocol
   //--
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -10,17 +10,22 @@
 #include "CPlusPlusLanguage.h"
 
 // C Includes
-// C++ Includes
 #include 
 #include 
+
+// C++ Includes
 #include 
+#include 
 #include 
+#include 
 
 // Other libraries and framework includes
 #include "llvm/ADT/StringRef.h"
 
 // Project includes
 #include "lldb/Core/ConstString.h"
+#include "lldb/Core/FastDemangle.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/UniqueCStringMap.h"
@@ -440,6 +445,101 @@
   return count;
 }
 
+/// Given a mangled function `mangled`, replace all the primitive function type
+/// arguments of `search` with type `replace`.
+static ConstString SubsPrimitiveParmItanium(llvm::StringRef mangled,
+llvm::StringRef search,
+llvm::StringRef replace) {
+  Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
+
+  const size_t max_len =
+  mangled.size() + mangled.count(search) * replace.size() + 1;
+
+  // Make a temporary buffer to fix up the mangled parameter types and copy the
+  // original there
+  std::string output_buf;
+  output_buf.reserve(max_len);
+  output_buf.insert(0, mangled.str());
+  ptrdiff_t replaced_offset = 0;
+
+  auto swap_parms_hook = [&](const char *parsee) {
+if (!parsee || !*parsee)
+  return;
+
+// Check whether we've found a substitutee
+llvm::StringRef s(parsee);
+if (s.startswith(search)) {
+  // account for the case where a replacement is of a different length to
+  // the original
+  replaced_offset += replace.size() - search.size();
+
+  ptrdiff_t replace_idx = (mangled.size() - s.size()) + replaced_offset;
+  output_buf.erase(replace_idx, search.size());
+  output_buf.insert(replace_idx, replace.str());
+}
+  };
+
+  // FastDemangle will call our hook for each instance of a primitive type,
+  // allowing us to perform substitution
+  const char *const demangled =
+  FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook);
+
+  if (log)
+log->Printf("substituted mangling for %s:{%s} %s:{%s}\n",
+mangled.str().c_str(), demangled, output_buf.c_str(),
+FastDemangle(output_buf.c_str()));
+
+  return output_buf == mangled ? ConstString() : ConstString(output_buf);
+}
+
+uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
+const ConstString mangled_name, std::set &alternates) {
+  const auto start_size = alternates.size();
+  /// Get a basic set of alternative manglings for the given symbol `name`, by
+  /// making a few basic possible substitutions on basic types, storage duration
+  /// and `const`ness for the given symbol. The output parameter `alternates`
+  /// is filled with a best-gu

[Lldb-commits] Buildbot numbers for the week of 12/04/2016 - 12/10/2016

2016-12-19 Thread Galina Kistanova via lldb-commits
Hello everyone,

Below are some buildbot numbers for the week of 12/04/2016 - 12/10/2016.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 clang-x86_64-linux-selfhost-modules-2  | 59:28:33
 lldb-x86_64-darwin-13.4| 59:11:44
 clang-native-aarch64-full  | 55:06:28
 sanitizer-x86_64-linux-bootstrap   | 33:22:08
 clang-x86_64-linux-selfhost-modules| 25:16:27
 sanitizer-x86_64-linux | 22:55:48
 lld-x86_64-win7| 13:35:17
 llvm-avr-linux | 13:29:20
 sanitizer-x86_64-linux-fuzzer  | 12:13:58
 lldb-windows7-android  | 09:27:48
 lldb-x86_64-ubuntu-14.04-cmake | 08:40:59
 lldb-x86_64-ubuntu-14.04-android   | 08:32:39
 clang-cmake-armv7-a15-selfhost-neon| 07:29:45
 perf-x86_64-penryn-O3-polly-fast   | 07:27:18
 llvm-mips-linux| 06:45:40
 clang-cmake-mips   | 06:38:02
 perf-x86_64-penryn-O3  | 06:20:14
 clang-with-lto-ubuntu  | 05:48:35
 clang-3stage-ubuntu| 05:28:25
 clang-with-thin-lto-ubuntu | 05:16:37
 clang-native-arm-lnt   | 04:33:53
 clang-cmake-aarch64-full   | 04:20:01
 clang-cmake-armv7-a15-selfhost | 04:18:34
 clang-x86_64-debian-fast   | 04:17:51
 clang-cmake-armv7-a15  | 04:16:21
 clang-x86-windows-msvc2015 | 04:10:27
 clang-x64-ninja-win7   | 03:59:04
 sanitizer-x86_64-linux-autoconf| 03:45:55
 sanitizer-x86_64-linux-fast| 03:44:29
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 03:29:23
 polly-amd64-linux  | 03:25:21
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 03:24:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan | 03:24:45
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu | 03:24:34
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 03:24:05
 clang-ppc64be-linux-multistage | 03:11:06
 sanitizer-ppc64le-linux| 03:08:30
 lld-x86_64-darwin13| 03:08:12
 lldb-x86_64-ubuntu-14.04-buildserver   | 03:07:52
 clang-ppc64le-linux-lnt| 03:06:55
 sanitizer-ppc64be-linux| 03:03:37
 clang-cmake-aarch64-lld| 02:47:55
 lldb-amd64-ninja-netbsd7   | 02:44:48
 perf-x86_64-penryn-O3-polly-parallel-fast  | 02:41:17
 clang-bpf-build| 02:38:44
 clang-cmake-aarch64-39vma  | 02:38:13
 clang-cmake-thumbv7-a15-full-sh| 02:27:23
 clang-ppc64be-linux| 02:20:54
 clang-cmake-aarch64-42vma  | 02:19:46
 clang-cmake-aarch64-quick  | 02:18:46
 clang-hexagon-elf  | 02:16:59
 clang-s390x-linux  | 02:15:05
 clang-atom-d525-fedora-rel | 02:13:22
 clang-ppc64be-linux-lnt| 02:13:06
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 02:10:42
 clang-ppc64le-linux| 02:08:55
 llvm-hexagon-elf   | 02:06:34
 lld-x86_64-freebsd | 02:04:33
 clang-cmake-thumbv7-a15| 02:04:04
 clang-x86_64-linux-abi-test  

[Lldb-commits] buildbot numbers for the week of 12/11/2016 - 12/17/2016

2016-12-19 Thread Galina Kistanova via lldb-commits
Hello everyone,

Below are some buildbot numbers for the last week of 12/11/2016 -
12/17/2016.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 clang-cuda-build   | 91:11:26
 clang-ppc64le-linux-multistage | 62:07:22
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 54:32:40
 clang-3stage-ubuntu| 53:57:51
 sanitizer-x86_64-linux-autoconf| 45:37:38
 sanitizer-x86_64-linux | 42:49:24
 clang-x86-windows-msvc2015 | 42:27:27
 sanitizer-windows  | 42:07:49
 clang-native-arm-lnt   | 41:12:15
 sanitizer-x86_64-linux-fast| 39:41:57
 sanitizer-x86_64-linux-bootstrap   | 38:35:49
 lldb-x86_64-ubuntu-14.04-android   | 38:04:19
 lldb-x86_64-darwin-13.4| 26:14:11
 clang-native-aarch64-full  | 24:25:06
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 15:10:30
 clang-ppc64be-linux-multistage | 14:49:15
 clang-s390x-linux  | 14:24:17
 clang-ppc64be-linux-lnt| 14:12:40
 clang-ppc64be-linux| 14:11:52
 perf-x86_64-penryn-O3  | 10:37:15
 clang-x86_64-linux-selfhost-modules-2  | 10:34:56
 polly-amd64-linux  | 10:26:03
 clang-x86_64-linux-selfhost-modules| 10:10:19
 perf-x86_64-penryn-O3-polly| 10:08:41
 clang-cmake-thumbv7-a15-full-sh| 10:01:45
 clang-cmake-armv7-a15-selfhost-neon| 09:59:07
 clang-cmake-armv7-a15-full | 09:37:24
 clang-x64-ninja-win7   | 09:22:34
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 08:48:40
 clang-cmake-aarch64-lld| 07:28:40
 clang-with-lto-ubuntu  | 07:21:48
 perf-x86_64-penryn-O3-polly-fast   | 07:09:00
 sanitizer-ppc64be-linux| 07:03:33
 clang-cmake-armv7-a15-selfhost | 06:10:17
 perf-x86_64-penryn-O3-polly-unprofitable   | 05:50:36
 perf-x86_64-penryn-O3-polly-parallel-fast  | 05:40:33
 clang-ppc64le-linux-lnt| 05:32:39
 clang-ppc64le-linux| 05:18:00
 lldb-windows7-android  | 05:13:26
 sanitizer-ppc64le-linux| 05:12:02
 clang-cmake-armv7-a15  | 05:04:57
 clang-with-thin-lto-ubuntu | 04:55:29
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 04:31:11
 clang-hexagon-elf  | 04:26:52
 clang-cmake-thumbv7-a15| 04:23:15
 clang-cmake-aarch64-39vma  | 04:15:01
 libcxx-libcxxabi-libunwind-aarch64-linux   | 03:49:54
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 03:41:24
 lldb-x86_64-ubuntu-14.04-buildserver   | 03:27:16
 clang-cmake-aarch64-full   | 03:21:56
 clang-cmake-aarch64-quick  | 03:15:39
 clang-atom-d525-fedora-rel | 03:01:46
 clang-cmake-aarch64-42vma  | 02:52:57
 clang-x86_64-debian-fast   | 02:28:53
 llvm-hexagon-elf   | 02:21:00
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 02:17:45
 sanitizer-x86_64-linux-fuzzer  | 02:15:28
 llvm-avr-linux | 01:30:53
 lldb-amd64-ninja-netbsd7   | 01:27:55
 lld-x86_64-freebsd  

[Lldb-commits] [lldb] r290163 - Change the timeout in CallBoardSystemServiceOpenApplication to

2016-12-19 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Mon Dec 19 22:54:04 2016
New Revision: 290163

URL: http://llvm.org/viewvc/llvm-project?rev=290163&view=rev
Log:
Change the timeout in CallBoardSystemServiceOpenApplication to 
30 seconds to match the old springboard timeout; the launcher
should time out before that and we will hopefully get back
an informative error message instead of timing out ourselves.

Modified:
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=290163&r1=290162&r2=290163&view=diff
==
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Mon Dec 19 
22:54:04 2016
@@ -157,7 +157,7 @@ static bool CallBoardSystemServiceOpenAp
 
   ];
 
-  const uint32_t timeout_secs = 20;
+  const uint32_t timeout_secs = 30;
 
   dispatch_time_t timeout =
   dispatch_time(DISPATCH_TIME_NOW, timeout_secs * NSEC_PER_SEC);


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