[Lldb-commits] [PATCH] D69425: [lldb] Fix broken -D option for breakpoint set command

2019-11-01 Thread Martin Svensson via Phabricator via lldb-commits
poya updated this revision to Diff 227406.
poya added a comment.

Added a test


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

https://reviews.llvm.org/D69425

Files:
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
  lldb/test/Shell/Breakpoint/dummy-target.test


Index: lldb/test/Shell/Breakpoint/dummy-target.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/dummy-target.test
@@ -0,0 +1,23 @@
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/dummy-target.c -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck %s
+
+breakpoint set -D -n main
+# CHECK: Breakpoint {{[0-9]}}: no locations (pending).
+# CHECK: Breakpoint set in dummy target
+
+breakpoint list
+# CHECK: No breakpoints currently set
+
+breakpoint list -D
+# CHECK: name = 'main', locations = 0 (pending)
+
+target delete
+# CHECK: 1 targets deleted
+
+target create dummy.out
+# CHECK: Current executable set to {{.*}}dummy.out
+
+breakpoint list
+# CHECK: name = 'main', locations = {{[1-9]}}
Index: lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
@@ -0,0 +1 @@
+int main() { return 0; }
Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -180,7 +180,7 @@
 ExecutionContext *execution_context) override {
 Status error;
 const int short_option =
-g_breakpoint_modify_options[option_idx].short_option;
+g_breakpoint_dummy_options[option_idx].short_option;
 
 switch (short_option) {
 case 'D':


Index: lldb/test/Shell/Breakpoint/dummy-target.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/dummy-target.test
@@ -0,0 +1,23 @@
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/dummy-target.c -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck %s
+
+breakpoint set -D -n main
+# CHECK: Breakpoint {{[0-9]}}: no locations (pending).
+# CHECK: Breakpoint set in dummy target
+
+breakpoint list
+# CHECK: No breakpoints currently set
+
+breakpoint list -D
+# CHECK: name = 'main', locations = 0 (pending)
+
+target delete
+# CHECK: 1 targets deleted
+
+target create dummy.out
+# CHECK: Current executable set to {{.*}}dummy.out
+
+breakpoint list
+# CHECK: name = 'main', locations = {{[1-9]}}
Index: lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
@@ -0,0 +1 @@
+int main() { return 0; }
Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -180,7 +180,7 @@
 ExecutionContext *execution_context) override {
 Status error;
 const int short_option =
-g_breakpoint_modify_options[option_idx].short_option;
+g_breakpoint_dummy_options[option_idx].short_option;
 
 switch (short_option) {
 case 'D':
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-11-01 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil requested changes to this revision.
jankratochvil added a comment.
This revision now requires changes to proceed.

On Fedora 31 x86_64 (that is with `python3-3.7.4-5.fc31.x86_64`) I get:

  FAIL: LLDB 
(/quad/home/jkratoch/redhat/llvm-monorepo-clangassertpython3/bin/clang-10-x86_64)
 :: test_ir_interpreter_int_ops (TestIRInterpreter.IRInterpreterTestCase)
  PASS: LLDB 
(/quad/home/jkratoch/redhat/llvm-monorepo-clangassertpython3/bin/clang-10-x86_64)
 :: test_type_conversions (TestIRInterpreter.IRInterpreterTestCase)
  ==
  ERROR: test_ir_interpreter_int_ops (TestIRInterpreter.IRInterpreterTestCase)
  --
  Traceback (most recent call last):
File 
"/home/jkratoch/redhat/llvm-monorepo/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 112, in wrapper
  func(*args, **kwargs)
File 
"/home/jkratoch/redhat/llvm-monorepo/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 112, in wrapper
  func(*args, **kwargs)
File 
"/home/jkratoch/redhat/llvm-monorepo/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 112, in wrapper
  func(*args, **kwargs)
File 
"/home/jkratoch/redhat/llvm-monorepo/lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py",
 line 130, in test_ir_interpreter_int_ops
  if not op.can_handle_operands(var1, var2):
File 
"/home/jkratoch/redhat/llvm-monorepo/lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py",
 line 71, in can_handle_operands
  if rhs.value <= 0 or rhs.value >= 32:
  TypeError: '<=' not supported between instances of 'c_uint' and 'int'
  
Config=x86_64-/quad/home/jkratoch/redhat/llvm-monorepo-clangassertpython3/bin/clang-10
  --




Comment at: 
lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py:69
+# FIXME: This is probably a bug in the IRInterpreter.
+if lhs.value <= 0:
+return False

Why not < 0?



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py:71
+return False
+if rhs.value <= 0 or rhs.value >= 32:
+return False

Why not < 0?


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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D69704: Add IsTypeSystemCompatible method to SBModule to allow checking compatibility between language versions

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.
teemperor added a project: Upstreaming LLDB's downstream patches.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

In Swift there is a check if the compiled module actually fits to our Swift 
version in LLDB. We don't really do this
kind of version checking so far in LLDB as we only have one Clang-based 
TypeSystem for C languages.
C languages don't have this precise version semantic but different standards 
which are expressed as different language types,
so there is no precise version checking needed for them.

This adds the relevant compatibility check to SBModule and adds the relevant 
tests for it. The actual Swift version check is
implemented in Swift's TypeSystem class which is downstream, so we test this 
here with the Clang type system which is
always treating modules as compatible.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69704

Files:
  lldb/include/lldb/API/SBError.h
  lldb/include/lldb/API/SBModule.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/packages/Python/lldbsuite/test/python_api/module_compability/Makefile
  
lldb/packages/Python/lldbsuite/test/python_api/module_compability/TestModuleTypeSystemCompatible.py
  lldb/packages/Python/lldbsuite/test/python_api/module_compability/main.cpp
  lldb/scripts/interface/SBModule.i
  lldb/source/API/SBModule.cpp
  lldb/source/Symbol/TypeSystem.cpp

Index: lldb/source/Symbol/TypeSystem.cpp
===
--- lldb/source/Symbol/TypeSystem.cpp
+++ lldb/source/Symbol/TypeSystem.cpp
@@ -147,6 +147,12 @@
   return false;
 }
 
+Status TypeSystem::IsCompatible() {
+  // Assume a language is compatible. Override this virtual function
+  // in your TypeSystem plug-in if version checking is desired.
+  return Status();
+}
+
 ConstString TypeSystem::DeclGetMangledName(void *opaque_decl) {
   return ConstString();
 }
Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Symbol/Symtab.h"
 #include "lldb/Symbol/TypeSystem.h"
 #include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/Language.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -687,6 +688,27 @@
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+lldb::SBError SBModule::IsTypeSystemCompatible(lldb::LanguageType language) {
+  SBError sb_error;
+  ModuleSP module_sp(GetSP());
+  if (!module_sp) {
+sb_error.SetErrorString("invalid module");
+return sb_error;
+  }
+
+  auto type_system_or_err = module_sp->GetTypeSystemForLanguage(language);
+  if (!type_system_or_err) {
+sb_error.SetErrorStringWithFormat(
+"no type system for language %s",
+Language::GetNameForLanguageType(language));
+llvm::consumeError(type_system_or_err.takeError());
+return sb_error;
+  }
+
+  sb_error.SetError(type_system_or_err->IsCompatible());
+  return sb_error;
+}
+
 namespace lldb_private {
 namespace repro {
 
Index: lldb/scripts/interface/SBModule.i
===
--- lldb/scripts/interface/SBModule.i
+++ lldb/scripts/interface/SBModule.i
@@ -342,6 +342,9 @@
 lldb::SBAddress
 GetObjectFileEntryPointAddress() const;
 
+lldb::SBError
+IsTypeSystemCompatible(lldb::LanguageType language);
+
 %pythoncode %{
 def __len__(self):
 '''Return the number of symbols in a lldb.SBModule object.'''
Index: lldb/packages/Python/lldbsuite/test/python_api/module_compability/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/python_api/module_compability/main.cpp
@@ -0,0 +1 @@
+int main() {}
Index: lldb/packages/Python/lldbsuite/test/python_api/module_compability/TestModuleTypeSystemCompatible.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/python_api/module_compability/TestModuleTypeSystemCompatible.py
@@ -0,0 +1,64 @@
+"""
+Test SBModule's IsTypeSystemCompatible.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ModuleTypeSystemCheckTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def assert_invalid_module_err(self, error):
+self.assertEquals("invalid module", error.GetCString())
+self.assertFalse(error.Success())
+
+# Py3 asserts due to a bug in SWIG.  A fix for this was upstreamed into
+# SWIG 3.0.8.
+@skipIf(py_version=['>=', (3, 0)], swig_version=['<', (3, 0, 8)])
+@add_test_categories(['pyapi'])
+@no_debug_info_test
+def test_default_module(self):
+exe_module = lldb.SBModule()
+self.assert_invalid_module_err(exe_module.IsTypeSystemCompati

[Lldb-commits] [PATCH] D69705: [lldb][NFC] Make test/python_api/module_section test smaller

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: labath, davide, JDevlieghere.
Herald added subscribers: lldb-commits, jfb.
Herald added a project: LLDB.

I don't see why this test needs to compile this rather complicated file for 
just testing module sections. This just removes all this code with a simple
"Hello world!" program which should be faster to compile


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69705

Files:
  lldb/packages/Python/lldbsuite/test/python_api/module_section/main.cpp

Index: lldb/packages/Python/lldbsuite/test/python_api/module_section/main.cpp
===
--- lldb/packages/Python/lldbsuite/test/python_api/module_section/main.cpp
+++ lldb/packages/Python/lldbsuite/test/python_api/module_section/main.cpp
@@ -1,135 +1,5 @@
-//===-- main.cpp *- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-// C includes
 #include 
-#include 
-#include 
-
-// C++ includes
-#include 
-#include 
-#include 
-#include 
-
-std::thread g_thread_1;
-std::thread g_thread_2;
-std::thread g_thread_3;
-std::mutex g_mask_mutex;
-
-enum MaskAction {
-eGet,
-eAssign,
-eClearBits
-};
-
-uint32_t mask_access (MaskAction action, uint32_t mask = 0);
-
-uint32_t
-mask_access (MaskAction action, uint32_t mask)
-{
-static uint32_t g_mask = 0;
-
-std::lock_guard lock(g_mask_mutex);
-switch (action)
-{
-case eGet:
-break;
-
-case eAssign:
-g_mask |= mask;
-break;
-
-case eClearBits:
-g_mask &= ~mask;
-break;
-}
-return g_mask;
-}
-
-void *
-thread_func (void *arg)
-{
-uint32_t thread_index = *((uint32_t *)arg);
-uint32_t thread_mask = (1u << (thread_index));
-printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index);
-
-std::default_random_engine generator;
-std::uniform_int_distribution distribution(0, 300);
-
-while (mask_access(eGet) & thread_mask)
-{
-// random micro second sleep from zero to 3 seconds
-int usec = distribution(generator);
-
-printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec);
-std::chrono::microseconds duration(usec);
-std::this_thread::sleep_for(duration);
-printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line.
-}
-printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index);
-return NULL;
-}
-
-
-int main (int argc, char const *argv[])
-{
-int err;
-void *thread_result = NULL;
-uint32_t thread_index_1 = 1;
-uint32_t thread_index_2 = 2;
-uint32_t thread_index_3 = 3;
-uint32_t thread_mask_1 = (1u << thread_index_1);
-uint32_t thread_mask_2 = (1u << thread_index_2);
-uint32_t thread_mask_3 = (1u << thread_index_3);
-
-// Make a mask that will keep all threads alive
-mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); // And that line.
-
-// Create 3 threads
-g_thread_1 = std::thread(thread_func, (void*)&thread_index_1);
-g_thread_2 = std::thread(thread_func, (void*)&thread_index_2);
-g_thread_3 = std::thread(thread_func, (void*)&thread_index_3);
-
-char line[64];
-while (mask_access(eGet) != 0)
-{
-printf ("Enter thread index to kill or ENTER for all:\n");
-fflush (stdout);
-// Kill threads by index, or ENTER for all threads
-
-if (fgets (line, sizeof(line), stdin))
-{
-if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0')
-{
-printf ("Exiting all threads...\n");
-break;
-}
-int32_t index = strtoul (line, NULL, 0);
-switch (index)
-{
-case 1: mask_access (eClearBits, thread_mask_1); break;
-case 2: mask_access (eClearBits, thread_mask_2); break;
-case 3: mask_access (eClearBits, thread_mask_3); break;
-}
-continue;
-}
-
-break;
-}
-
-// Clear all thread bits to they all exit
-mask_access (eClearBits, UINT32_MAX);
-
-// Join all of our threads
-g_thread_1.join();
-g_thread_2.join();
-g_thread_3.join();
 
-return 0;
+int main() {
+  printf("Hello World\n");
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69710: [lldb][NFC] Remove unused ExpressionParser::Parse

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.
teemperor added a project: Upstreaming LLDB's downstream patches.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

This function is only used internally by ClangExpressionParser. By putting it 
in the ExpressionParser class all languages
that implement ExpressionParser::Parse have to share the same signature (which 
forces us in downstream to add
swift-specific arguments to ExpressionParser::Parse which then propagate to 
ClangExpressionParser and so on).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69710

Files:
  lldb/include/lldb/Expression/ExpressionParser.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -77,7 +77,7 @@
   /// \return
   /// The number of errors encountered during parsing.  0 means
   /// success.
-  unsigned Parse(DiagnosticManager &diagnostic_manager) override;
+  unsigned Parse(DiagnosticManager &diagnostic_manager);
 
   bool RewriteExpression(DiagnosticManager &diagnostic_manager) override;
 
Index: lldb/include/lldb/Expression/ExpressionParser.h
===
--- lldb/include/lldb/Expression/ExpressionParser.h
+++ lldb/include/lldb/Expression/ExpressionParser.h
@@ -76,17 +76,6 @@
   virtual bool Complete(CompletionRequest &request, unsigned line, unsigned 
pos,
 unsigned typed_pos) = 0;
 
-  /// Parse a single expression and convert it to IR using Clang.  Don't wrap
-  /// the expression in anything at all.
-  ///
-  /// \param[in] diagnostic_manager
-  /// The diagnostic manager in which to store the errors and warnings.
-  ///
-  /// \return
-  /// The number of errors encountered during parsing.  0 means
-  /// success.
-  virtual unsigned Parse(DiagnosticManager &diagnostic_manager) = 0;
-
   /// Try to use the FixIts in the diagnostic_manager to rewrite the
   /// expression.  If successful, the rewritten expression is stored in the
   /// diagnostic_manager, get it out with GetFixedExpression.


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -77,7 +77,7 @@
   /// \return
   /// The number of errors encountered during parsing.  0 means
   /// success.
-  unsigned Parse(DiagnosticManager &diagnostic_manager) override;
+  unsigned Parse(DiagnosticManager &diagnostic_manager);
 
   bool RewriteExpression(DiagnosticManager &diagnostic_manager) override;
 
Index: lldb/include/lldb/Expression/ExpressionParser.h
===
--- lldb/include/lldb/Expression/ExpressionParser.h
+++ lldb/include/lldb/Expression/ExpressionParser.h
@@ -76,17 +76,6 @@
   virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos,
 unsigned typed_pos) = 0;
 
-  /// Parse a single expression and convert it to IR using Clang.  Don't wrap
-  /// the expression in anything at all.
-  ///
-  /// \param[in] diagnostic_manager
-  /// The diagnostic manager in which to store the errors and warnings.
-  ///
-  /// \return
-  /// The number of errors encountered during parsing.  0 means
-  /// success.
-  virtual unsigned Parse(DiagnosticManager &diagnostic_manager) = 0;
-
   /// Try to use the FixIts in the diagnostic_manager to rewrite the
   /// expression.  If successful, the rewritten expression is stored in the
   /// diagnostic_manager, get it out with GetFixedExpression.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69710: [lldb][NFC] Remove unused ExpressionParser::Parse

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 227438.
teemperor added a comment.

- Uploaded full diff.


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

https://reviews.llvm.org/D69710

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


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -186,10 +186,10 @@
   lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
   if (jit_process_sp) {
 const bool generate_debug_info = true;
-m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this,
- generate_debug_info));
-
-num_errors = m_parser->Parse(diagnostic_manager);
+auto *clang_parser = new ClangExpressionParser(jit_process_sp.get(), *this,
+   generate_debug_info);
+num_errors = clang_parser->Parse(diagnostic_manager);
+m_parser.reset(clang_parser);
   } else {
 diagnostic_manager.PutString(eDiagnosticSeverityError,
  "no process - unable to inject function");
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -77,7 +77,7 @@
   /// \return
   /// The number of errors encountered during parsing.  0 means
   /// success.
-  unsigned Parse(DiagnosticManager &diagnostic_manager) override;
+  unsigned Parse(DiagnosticManager &diagnostic_manager);
 
   bool RewriteExpression(DiagnosticManager &diagnostic_manager) override;
 
Index: lldb/include/lldb/Expression/ExpressionParser.h
===
--- lldb/include/lldb/Expression/ExpressionParser.h
+++ lldb/include/lldb/Expression/ExpressionParser.h
@@ -76,17 +76,6 @@
   virtual bool Complete(CompletionRequest &request, unsigned line, unsigned 
pos,
 unsigned typed_pos) = 0;
 
-  /// Parse a single expression and convert it to IR using Clang.  Don't wrap
-  /// the expression in anything at all.
-  ///
-  /// \param[in] diagnostic_manager
-  /// The diagnostic manager in which to store the errors and warnings.
-  ///
-  /// \return
-  /// The number of errors encountered during parsing.  0 means
-  /// success.
-  virtual unsigned Parse(DiagnosticManager &diagnostic_manager) = 0;
-
   /// Try to use the FixIts in the diagnostic_manager to rewrite the
   /// expression.  If successful, the rewritten expression is stored in the
   /// diagnostic_manager, get it out with GetFixedExpression.


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -186,10 +186,10 @@
   lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
   if (jit_process_sp) {
 const bool generate_debug_info = true;
-m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this,
- generate_debug_info));
-
-num_errors = m_parser->Parse(diagnostic_manager);
+auto *clang_parser = new ClangExpressionParser(jit_process_sp.get(), *this,
+   generate_debug_info);
+num_errors = clang_parser->Parse(diagnostic_manager);
+m_parser.reset(clang_parser);
   } else {
 diagnostic_manager.PutString(eDiagnosticSeverityError,
  "no process - unable to inject function");
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -77,7 +77,7 @@
   /// \return
   /// The number of errors encountered during parsing.  0 means
   /// success.
-  unsigned Parse(DiagnosticManager &diagnostic_manager) override;
+  unsigned Parse(DiagnosticManager &diagnostic_manager);
 
   bool RewriteExpression(DiagnosticManager &diagnostic_manager) override;
 
Index: lldb/include/lldb/Expression/ExpressionParser.h
===
--- lldb/include/lldb/Expression/ExpressionParser.h
+++ lldb/include/lldb/Expression/ExpressionParser.h
@@ -76,17 +76,6 @@
   virtual bool Complete(CompletionRequest &request

[Lldb-commits] [PATCH] D69713: [lldb] Also disable de-registration of EHFrames in IRExecutionUnit

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.
teemperor added a project: Upstreaming LLDB's downstream patches.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

We disabled registration by providing an empty `registerEHFrames`, so we should 
also provide an empty `deregisterEHFrames`
in case that function relies on `registerEHFrames` being called before. 
Currently `deregisterEHFrames` is a no-op anyway
as it just iterates over the (empty( list of registered EHFrames and then clear 
the empty list.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69713

Files:
  lldb/include/lldb/Expression/IRExecutionUnit.h


Index: lldb/include/lldb/Expression/IRExecutionUnit.h
===
--- lldb/include/lldb/Expression/IRExecutionUnit.h
+++ lldb/include/lldb/Expression/IRExecutionUnit.h
@@ -298,8 +298,10 @@
   return false;
 }
 
+// Ignore any EHFrame registration.
 void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
   size_t Size) override {}
+void deregisterEHFrames() override {}
 
 uint64_t getSymbolAddress(const std::string &Name) override;
 


Index: lldb/include/lldb/Expression/IRExecutionUnit.h
===
--- lldb/include/lldb/Expression/IRExecutionUnit.h
+++ lldb/include/lldb/Expression/IRExecutionUnit.h
@@ -298,8 +298,10 @@
   return false;
 }
 
+// Ignore any EHFrame registration.
 void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
   size_t Size) override {}
+void deregisterEHFrames() override {}
 
 uint64_t getSymbolAddress(const std::string &Name) override;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69714: [lldb] Provide a getter for m_materializer_up in LLVMUserExpression instead of relying on it being accessible.

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.
teemperor added a project: Upstreaming LLDB's downstream patches.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
Herald added a project: LLDB.

Motivated by Swift using the materializer in a few places which requires us to 
add this getter ourselves.
We also need a setter, but let's keep this minimal to unblock the downstream 
reverts in Swift.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69714

Files:
  lldb/include/lldb/Expression/Expression.h
  lldb/include/lldb/Expression/LLVMUserExpression.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -576,7 +576,7 @@
 
   auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
 
-  if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
+  if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
@@ -764,7 +764,7 @@
 
   auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
 
-  if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
+  if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
Index: lldb/include/lldb/Expression/LLVMUserExpression.h
===
--- lldb/include/lldb/Expression/LLVMUserExpression.h
+++ lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -63,6 +63,8 @@
 
   bool CanInterpret() override { return m_can_interpret; }
 
+  Materializer *GetMaterializer() override { return m_materializer_up.get(); }
+
   /// Return the string that the parser should parse.  Must be a full
   /// translation unit.
   const char *Text() override { return m_transformed_text.c_str(); }
Index: lldb/include/lldb/Expression/Expression.h
===
--- lldb/include/lldb/Expression/Expression.h
+++ lldb/include/lldb/Expression/Expression.h
@@ -64,6 +64,10 @@
   /// default, return eLanguageTypeUnknown.
   virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
 
+  /// Return the Materializer that the parser should use when registering
+  /// external values.
+  virtual Materializer *GetMaterializer() { return nullptr; }
+
   /// Return the desired result type of the function, or eResultTypeAny if
   /// indifferent.
   virtual ResultType DesiredResultType() { return eResultTypeAny; }


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -576,7 +576,7 @@
 
   auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
 
-  if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
+  if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
@@ -764,7 +764,7 @@
 
   auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
 
-  if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
+  if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
Index: lldb/include/lldb/Expression/LLVMUserExpression.h
===
--- lldb/include/lldb/Expression/LLVMUserExpression.h
+++ lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -63,6 +63,8 @@
 
   bool CanInterpret() override { return m_can_interpret; }
 
+  Materializer *GetMaterializer() override { return m_materializer_up.get(); }
+
   /// Return the string that the parser should parse.  Must be a full
   /// translation unit.
   const char *Text() override { return m_transformed_text.c_str(); }
Index: lldb/include/lldb/Expression/Expression.h
===
--- lldb/include/lldb/Expression/Expression.h
+++ lldb/include/lldb/Expression/Expression.h
@@ -64,6 +64,10 @@
   /// default, return eLanguageTypeUnknown.
   virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
 
+  /// Return the Materializer that the parser should use when registering
+  /// external values.
+  virtual Materializer *GetMaterializer() { ret

[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-11-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Another problem of the `test_ir_interpreter` is that it fails even when JIT 
fails despite it should test the interpreter.


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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D67227#1730144 , @tatyana-krasnukha 
wrote:

> Another problem of the `test_ir_interpreter` is that it fails even when JIT 
> fails despite it should test the interpreter.


Well, it also tests that the IRInterpreter is equivalent to what we would JIT 
(i.e., our interpreting-vs-JITing optimisation is actually working as intended).


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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D69717: [lldb] Add trailing dots to comments in Value.cpp

2019-11-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a project: Upstreaming LLDB's downstream patches.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69717

Files:
  lldb/source/Core/Value.cpp


Index: lldb/source/Core/Value.cpp
===
--- lldb/source/Core/Value.cpp
+++ lldb/source/Core/Value.cpp
@@ -507,10 +507,10 @@
 return error;
   }
 
-  // If we got here, we need to read the value from memory
+  // If we got here, we need to read the value from memory.
   size_t byte_size = GetValueByteSize(&error, exe_ctx);
 
-  // Bail if we encountered any errors getting the byte size
+  // Bail if we encountered any errors getting the byte size.
   if (error.Fail())
 return error;
 


Index: lldb/source/Core/Value.cpp
===
--- lldb/source/Core/Value.cpp
+++ lldb/source/Core/Value.cpp
@@ -507,10 +507,10 @@
 return error;
   }
 
-  // If we got here, we need to read the value from memory
+  // If we got here, we need to read the value from memory.
   size_t byte_size = GetValueByteSize(&error, exe_ctx);
 
-  // Bail if we encountered any errors getting the byte size
+  // Bail if we encountered any errors getting the byte size.
   if (error.Fail())
 return error;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-11-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

I mean, when a process is not able to allocate memory, it cannot JIT, but still 
can interpret. Should the test report failure in this case?


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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D69425: [lldb] Fix broken -D option for breakpoint set command

2019-11-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D69425



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


[Lldb-commits] [PATCH] D69714: [lldb] Provide a getter for m_materializer_up in LLVMUserExpression instead of relying on it being accessible.

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

LGTM.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69714



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


[Lldb-commits] [PATCH] D69738: Fix handling for the clang name mangling extension for block invocations

2019-11-01 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added reviewers: aprantl, jingham.

clang has a mangling extension for block invocations 

 and currently lldb does not handle it correctly.


https://reviews.llvm.org/D69738

Files:
  lldb/include/lldb/Core/Mangled.h
  lldb/source/Core/Mangled.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
  lldb/unittests/Core/MangledTest.cpp

Index: lldb/unittests/Core/MangledTest.cpp
===
--- lldb/unittests/Core/MangledTest.cpp
+++ lldb/unittests/Core/MangledTest.cpp
@@ -37,6 +37,17 @@
   EXPECT_STREQ(ExpectedResult.GetCString(), TheDemangled.GetCString());
 }
 
+TEST(MangledTest, ResultForBlockInvocation) {
+  ConstString MangledName("___Z1fU13block_pointerFviE_block_invoke");
+  Mangled TheMangled(MangledName);
+  ConstString TheDemangled =
+  TheMangled.GetDemangledName(eLanguageTypeC_plus_plus);
+
+  ConstString ExpectedResult(
+  "invocation function for block in f(void (int) block_pointer)");
+  EXPECT_STREQ(ExpectedResult.GetCString(), TheDemangled.GetCString());
+}
+
 TEST(MangledTest, EmptyForInvalidName) {
   ConstString MangledName("_ZN1a1b1cmxktpEEvm");
   Mangled TheMangled(MangledName);
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -101,7 +101,7 @@
 
   static lldb_private::ConstString GetPluginNameStatic();
 
-  static bool IsCPPMangledName(const char *name);
+  static bool IsCPPMangledName(llvm::StringRef name);
 
   // Extract C++ context and identifier from a string using heuristic matching
   // (as opposed to
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Demangle/ItaniumDemangle.h"
 
+#include "lldb/Core/Mangled.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/UniqueCStringMap.h"
 #include "lldb/DataFormatters/CXXFunctionPointer.h"
@@ -238,18 +239,16 @@
   return res;
 }
 
-bool CPlusPlusLanguage::IsCPPMangledName(const char *name) {
+bool CPlusPlusLanguage::IsCPPMangledName(llvm::StringRef name) {
   // FIXME!! we should really run through all the known C++ Language plugins
   // and ask each one if this is a C++ mangled name
 
-  if (name == nullptr)
-return false;
+  Mangled::ManglingScheme scheme = Mangled::GetManglingScheme(name);
 
-  // MSVC style mangling
-  if (name[0] == '?')
-return true;
+  if (scheme == Mangled::eManglingSchemeNone)
+return false;
 
-  return (name[0] != '\0' && name[0] == '_' && name[1] == 'Z');
+  return true;
 }
 
 bool CPlusPlusLanguage::ExtractContextAndIdentifier(
Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -32,18 +32,8 @@
 #include 
 using namespace lldb_private;
 
-static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
-  if (s) {
-if (s[0] == '?')
-  return Mangled::eManglingSchemeMSVC;
-if (s[0] == '_' && s[1] == 'Z')
-  return Mangled::eManglingSchemeItanium;
-  }
-  return Mangled::eManglingSchemeNone;
-}
-
-static inline bool cstring_is_mangled(const char *s) {
-  return cstring_mangling_scheme(s) != Mangled::eManglingSchemeNone;
+static inline bool cstring_is_mangled(llvm::StringRef s) {
+  return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
 }
 
 static ConstString 
@@ -99,6 +89,23 @@
 
 #pragma mark Mangled
 
+Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef s) {
+  if (s.empty())
+return Mangled::eManglingSchemeNone;
+
+  if (s[0] == '?')
+return Mangled::eManglingSchemeMSVC;
+
+  if (s.size() >= 2 && (s[0] == '_' && s[1] == 'Z'))
+return Mangled::eManglingSchemeItanium;
+
+  // ___Z is a clang extension of block invocations
+  if (s.size() >= 4 && s[0] == '_' && s[1] == '_' && s[2] == '_' && s[3] == 'Z')
+return Mangled::eManglingSchemeItanium;
+
+  return Mangled::eManglingSchemeNone;
+}
+
 Mangled::Mangled(ConstString s) : m_mangled(), m_demangled() {
   if (s)
 SetValue(s);
@@ -159,7 +166,7 @@
 
 void Mangled::SetValue(ConstString name) {
   if (name) {
-if (cstring_is_mangled(name.GetCString())) {
+if (cstring_is_mangled(name.GetStringRef())) {
   m_demangled.Clear();
   m_mangled = name;
 } else {
@@ -232,7 +239,7 @@
   assert(m_mangled);
 
   // Check whether or not we are interested in this name at all.
-  M

[Lldb-commits] [PATCH] D69738: Fix handling for the clang name mangling extension for block invocations

2019-11-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: lldb/source/Core/Mangled.cpp:99
+
+  if (s.size() >= 2 && (s[0] == '_' && s[1] == 'Z'))
+return Mangled::eManglingSchemeItanium;

StringRef has a startswith.  That might be easier to read.


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

https://reviews.llvm.org/D69738



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


[Lldb-commits] [PATCH] D69738: Fix handling for the clang name mangling extension for block invocations

2019-11-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/include/lldb/Core/Mangled.h:264
 
+  static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef s);
+

Doxygen comment?



Comment at: lldb/source/Core/Mangled.cpp:99
+
+  if (s.size() >= 2 && (s[0] == '_' && s[1] == 'Z'))
+return Mangled::eManglingSchemeItanium;

jingham wrote:
> StringRef has a startswith.  That might be easier to read.
Agreed. There should be no performance penalty for using startswith over this 
in an optimized build.



Comment at: lldb/source/Core/Mangled.cpp:102
+
+  // ___Z is a clang extension of block invocations
+  if (s.size() >= 4 && s[0] == '_' && s[1] == '_' && s[2] == '_' && s[3] == 
'Z')

Is `___Z` really only used for blocks or is it used for other clang extensions, 
too?



Comment at: lldb/source/Core/Mangled.cpp:104
+  if (s.size() >= 4 && s[0] == '_' && s[1] == '_' && s[2] == '_' && s[3] == 
'Z')
+return Mangled::eManglingSchemeItanium;
+

Just FYI, this will create a merge conflict with swift-lldb. You might want to 
think about how to resolve it ahead of committing.



Comment at: lldb/source/Core/Mangled.cpp:106
+
+  return Mangled::eManglingSchemeNone;
+}

You don't need to fix this all at once, but I think it would be even better if 
this function did something like
```
for each language plugin { 
  if (mangling_scheme = plugin.isMangledName(...)
...
}
```

I.e., the plugins should be the ones that know about the mangling details.



Comment at: lldb/source/Core/Mangled.cpp:310
 const char *mangled_name = m_mangled.GetCString();
-ManglingScheme mangling_scheme{cstring_mangling_scheme(mangled_name)};
+ManglingScheme 
mangling_scheme{GetManglingScheme(m_mangled.GetStringRef())};
 if (mangling_scheme != eManglingSchemeNone &&

If it's equivalent I'd find 
`ManglingScheme mangling_scheme = GetManglingScheme(m_mangled.GetStringRef());`
easier to read.



Comment at: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h:104
 
-  static bool IsCPPMangledName(const char *name);
+  static bool IsCPPMangledName(llvm::StringRef name);
 

That's a good idea anyway :-)


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

https://reviews.llvm.org/D69738



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


[Lldb-commits] [PATCH] D69667: [lldb] [Process/NetBSD] Add register info for missing register sets

2019-11-01 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 227545.
mgorny added a comment.

Include reenabling fixed test.


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

https://reviews.llvm.org/D69667

Files:
  
lldb/packages/Python/lldbsuite/test/commands/register/register/register_command/TestRegisters.py
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h

Index: lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
===
--- lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
+++ lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
@@ -294,7 +294,8 @@
   lldb_bndstatus_x86_64,
   k_last_mpxc_x86_64 = lldb_bndstatus_x86_64,
 
-  lldb_dr0_x86_64,
+  k_first_dbr_x86_64,
+  lldb_dr0_x86_64 = k_first_dbr_x86_64,
   lldb_dr1_x86_64,
   lldb_dr2_x86_64,
   lldb_dr3_x86_64,
@@ -302,6 +303,7 @@
   lldb_dr5_x86_64,
   lldb_dr6_x86_64,
   lldb_dr7_x86_64,
+  k_last_dbr_x86_64 = lldb_dr7_x86_64,
 
   k_num_registers_x86_64,
   k_num_gpr_registers_x86_64 = k_last_gpr_x86_64 - k_first_gpr_x86_64 + 1,
@@ -312,6 +314,7 @@
 k_num_fpr_registers_x86_64 +
 k_num_avx_registers_x86_64 +
 k_num_mpx_registers_x86_64,
+  k_num_dbr_registers_x86_64 = k_last_dbr_x86_64 - k_first_dbr_x86_64 + 1,
 };
 }
 
Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
===
--- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
+++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
@@ -73,7 +73,7 @@
 
 private:
   // Private member types.
-  enum { GPRegSet, FPRegSet, DBRegSet, XStateRegSet };
+  enum { GPRegSet, FPRegSet, XStateRegSet, DBRegSet };
 
   // Private member variables.
   struct reg m_gpr_x86_64;
Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -84,13 +84,71 @@
   k_num_gpr_registers_x86_64,
   "g_gpr_regnums_x86_64 has wrong number of register infos");
 
+// x86 64-bit floating point registers.
+static const uint32_t g_fpu_regnums_x86_64[] = {
+lldb_fctrl_x86_64, lldb_fstat_x86_64, lldb_ftag_x86_64,
+lldb_fop_x86_64,   lldb_fiseg_x86_64, lldb_fioff_x86_64,
+lldb_foseg_x86_64, lldb_fooff_x86_64, lldb_mxcsr_x86_64,
+lldb_mxcsrmask_x86_64, lldb_st0_x86_64,   lldb_st1_x86_64,
+lldb_st2_x86_64,   lldb_st3_x86_64,   lldb_st4_x86_64,
+lldb_st5_x86_64,   lldb_st6_x86_64,   lldb_st7_x86_64,
+lldb_mm0_x86_64,   lldb_mm1_x86_64,   lldb_mm2_x86_64,
+lldb_mm3_x86_64,   lldb_mm4_x86_64,   lldb_mm5_x86_64,
+lldb_mm6_x86_64,   lldb_mm7_x86_64,   lldb_xmm0_x86_64,
+lldb_xmm1_x86_64,  lldb_xmm2_x86_64,  lldb_xmm3_x86_64,
+lldb_xmm4_x86_64,  lldb_xmm5_x86_64,  lldb_xmm6_x86_64,
+lldb_xmm7_x86_64,  lldb_xmm8_x86_64,  lldb_xmm9_x86_64,
+lldb_xmm10_x86_64, lldb_xmm11_x86_64, lldb_xmm12_x86_64,
+lldb_xmm13_x86_64, lldb_xmm14_x86_64, lldb_xmm15_x86_64,
+LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_fpu_regnums_x86_64) / sizeof(g_fpu_regnums_x86_64[0])) -
+  1 ==
+  k_num_fpr_registers_x86_64,
+  "g_fpu_regnums_x86_64 has wrong number of register infos");
+
+// x86 64-bit registers available via XState.
+static const uint32_t g_xstate_regnums_x86_64[] = {
+lldb_ymm0_x86_64,   lldb_ymm1_x86_64,  lldb_ymm2_x86_64,  lldb_ymm3_x86_64,
+lldb_ymm4_x86_64,   lldb_ymm5_x86_64,  lldb_ymm6_x86_64,  lldb_ymm7_x86_64,
+lldb_ymm8_x86_64,   lldb_ymm9_x86_64,  lldb_ymm10_x86_64, lldb_ymm11_x86_64,
+lldb_ymm12_x86_64,  lldb_ymm13_x86_64, lldb_ymm14_x86_64, lldb_ymm15_x86_64,
+// Note: we currently do not provide them but this is needed to avoid
+// unnamed groups in SBFrame::GetRegisterContext().
+lldb_bnd0_x86_64,lldb_bnd1_x86_64,lldb_bnd2_x86_64,
+lldb_bnd3_x86_64,lldb_bndcfgu_x86_64, lldb_bndstatus_x86_64,
+LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_xstate_regnums_x86_64) / sizeof(g_xstate_regnums_x86_64[0])) -
+  1 ==
+  k_num_avx_registers_x86_64 + k_num_mpx_registers_x86_64,
+  "g_xstate_regnums_x86_64 has wrong number of register infos");
+
+// x86 debug registers.
+static const uint32_t g_dbr_regnums_x86_64[] = {
+lldb_dr0_x86_64,   lldb_dr1_x86_64,  lldb_dr2_x

[Lldb-commits] [lldb] 81cc5d1 - Don't assume that __cxa_current_exception_type exists.

2019-11-01 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2019-11-01T17:20:31-07:00
New Revision: 81cc5d1c7d3f7292e82e8611fcd4a2889278a218

URL: 
https://github.com/llvm/llvm-project/commit/81cc5d1c7d3f7292e82e8611fcd4a2889278a218
DIFF: 
https://github.com/llvm/llvm-project/commit/81cc5d1c7d3f7292e82e8611fcd4a2889278a218.diff

LOG: Don't assume that __cxa_current_exception_type exists.

Normally you shouldn't be able to have a process with an ItaniumABI plugin
that doesn't have this symbol.  But if the loader crashes before loading
libc++abi.dylib (on MacOS), then the symbol might not be present.  So we
should check before accessing the pointer.

There isn't a good way to write a test for this, but the change is obvious.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index 02e62a263286..70b0b51f502c 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -559,6 +559,9 @@ ValueObjectSP 
ItaniumABILanguageRuntime::GetExceptionObjectForThread(
   modules.FindSymbolsWithNameAndType(
   ConstString("__cxa_current_exception_type"), eSymbolTypeCode, contexts);
   contexts.GetContextAtIndex(0, context);
+  if (!context.symbol) {
+return {};
+  }
   Address addr = context.symbol->GetAddress();
 
   Status error;



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


[Lldb-commits] [PATCH] D69742: [LLDB][Python] remove ArgInfo::count

2019-11-01 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: labath, mgorny, JDevlieghere.
Herald added a project: LLDB.

This patch updates the last user of ArgInfo::count and deletes 
it.   I also delete `GetNumInitArguments()` and `GetInitArgInfo()`. 
Classess are callables and `GetArgInfo()` should work on them.

On python 3 it already works, of course. `inspect` is good.

On python 2 we have to add yet another special case.   But hey if 
python 2 wasn't crufty we wouln't need python 3.

I also delete `is_bound_method` becuase it is unused.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69742

Files:
  lldb/scripts/Python/python-wrapper.swig
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
@@ -640,9 +640,7 @@
 auto lambda = Take(o);
 auto arginfo = lambda.GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
-EXPECT_EQ(arginfo.get().count, 1);
 EXPECT_EQ(arginfo.get().max_positional_args, 1u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
   }
 
   {
@@ -652,9 +650,7 @@
 auto lambda = Take(o);
 auto arginfo = lambda.GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
-EXPECT_EQ(arginfo.get().count, 2);
 EXPECT_EQ(arginfo.get().max_positional_args, 2u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
   }
 
   {
@@ -664,9 +660,7 @@
 auto lambda = Take(o);
 auto arginfo = lambda.GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
-EXPECT_EQ(arginfo.get().count, 2);
 EXPECT_EQ(arginfo.get().max_positional_args, 2u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
   }
 
   {
@@ -676,10 +670,8 @@
 auto lambda = Take(o);
 auto arginfo = lambda.GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
-EXPECT_EQ(arginfo.get().count, 2);
 EXPECT_EQ(arginfo.get().max_positional_args,
   PythonCallable::ArgInfo::UNBOUNDED);
-EXPECT_EQ(arginfo.get().has_varargs, true);
   }
 
   {
@@ -689,10 +681,8 @@
 auto lambda = Take(o);
 auto arginfo = lambda.GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
-EXPECT_EQ(arginfo.get().count, 2);
 EXPECT_EQ(arginfo.get().max_positional_args,
   PythonCallable::ArgInfo::UNBOUNDED);
-EXPECT_EQ(arginfo.get().has_varargs, true);
   }
 
   {
@@ -713,6 +703,16 @@
 bar_class   = Foo().classbar
 bar_static  = Foo().staticbar
 bar_unbound = Foo.bar
+
+
+class OldStyle:
+  def __init__(self, one, two, three):
+pass
+
+class NewStyle(object):
+  def __init__(self, one, two, three):
+pass
+
 )";
 PyObject *o =
 PyRun_String(script, Py_file_input, globals.get(), globals.get());
@@ -723,38 +723,43 @@
 ASSERT_THAT_EXPECTED(bar_bound, llvm::Succeeded());
 auto arginfo = bar_bound.get().GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
-EXPECT_EQ(arginfo.get().count, 2); // FIXME, wrong
 EXPECT_EQ(arginfo.get().max_positional_args, 1u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
 
 auto bar_unbound = As(globals.GetItem("bar_unbound"));
 ASSERT_THAT_EXPECTED(bar_unbound, llvm::Succeeded());
 arginfo = bar_unbound.get().GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
-EXPECT_EQ(arginfo.get().count, 2);
 EXPECT_EQ(arginfo.get().max_positional_args, 2u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
 
 auto bar_class = As(globals.GetItem("bar_class"));
 ASSERT_THAT_EXPECTED(bar_class, llvm::Succeeded());
 arginfo = bar_class.get().GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
 EXPECT_EQ(arginfo.get().max_positional_args, 1u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
 
 auto bar_static = As(globals.GetItem("bar_static"));
 ASSERT_THAT_EXPECTED(bar_static, llvm::Succeeded());
 arginfo = bar_static.get().GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
 EXPECT_EQ(arginfo.get().max_positional_args, 1u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
 
 auto obj = As(globals.GetItem("obj"));
 ASSERT_THAT_EXPECTED(obj, llvm::Succeeded());
 arginfo = obj.get().GetArgInfo();
 ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
 EXPECT_EQ(arginfo.get().max_positional_args, 1u);
-EXPECT_EQ(arginfo.get().has_varargs, false);
+
+auto oldstyle = As(globals.GetItem("OldStyle"));
+ASSERT_THAT_EXPECTED(oldstyle, llvm::Succeeded());
+arginfo = oldstyle.get().Ge