[Lldb-commits] [lldb] db5074d - [lldb][NFC] Give some parameters in CommandInterpreter more descriptive names

2019-11-05 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-05T09:21:10+01:00
New Revision: db5074dc10222a8202adcd7c1da1acd2828fbecb

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

LOG: [lldb][NFC] Give some parameters in CommandInterpreter more descriptive 
names

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 3b98b2a521dd..080d635716f1 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -443,13 +443,13 @@ class CommandInterpreter : public Broadcaster,
 
   bool GetPromptOnQuit() const;
 
-  void SetPromptOnQuit(bool b);
+  void SetPromptOnQuit(bool enable);
 
   bool GetEchoCommands() const;
-  void SetEchoCommands(bool b);
+  void SetEchoCommands(bool enable);
 
   bool GetEchoCommentCommands() const;
-  void SetEchoCommentCommands(bool b);
+  void SetEchoCommentCommands(bool enable);
 
   /// Specify if the command interpreter should allow that the user can
   /// specify a custom exit code when calling 'quit'.

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 0c059096c6cd..e02248148413 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -137,9 +137,9 @@ bool CommandInterpreter::GetPromptOnQuit() const {
   nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
-void CommandInterpreter::SetPromptOnQuit(bool b) {
+void CommandInterpreter::SetPromptOnQuit(bool enable) {
   const uint32_t idx = ePropertyPromptOnQuit;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
 bool CommandInterpreter::GetEchoCommands() const {
@@ -148,9 +148,9 @@ bool CommandInterpreter::GetEchoCommands() const {
   nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
-void CommandInterpreter::SetEchoCommands(bool b) {
+void CommandInterpreter::SetEchoCommands(bool enable) {
   const uint32_t idx = ePropertyEchoCommands;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
 bool CommandInterpreter::GetEchoCommentCommands() const {
@@ -159,9 +159,9 @@ bool CommandInterpreter::GetEchoCommentCommands() const {
   nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
-void CommandInterpreter::SetEchoCommentCommands(bool b) {
+void CommandInterpreter::SetEchoCommentCommands(bool enable) {
   const uint32_t idx = ePropertyEchoCommentCommands;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
 void CommandInterpreter::AllowExitCodeOnQuit(bool allow) {



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


[Lldb-commits] [PATCH] D69793: Bundle libedit-compatible readline replacement

2019-11-05 Thread serge via Phabricator via lldb-commits
serge-sans-paille updated this revision to Diff 227823.
serge-sans-paille marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69793

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -17,6 +17,7 @@
 
 #include "PythonDataObjects.h"
 #include "PythonExceptionState.h"
+#include "PythonReadline.h"
 #include "ScriptInterpreterPythonImpl.h"
 
 #include "lldb/API/SBFrame.h"
@@ -207,6 +208,22 @@
 
 InitializePythonHome();
 
+#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
+// Python's readline is incompatible with libedit being linked into lldb.
+// Provide a patched version local to the embedded interpreter.
+bool ReadlinePatched = false;
+for (auto *p = PyImport_Inittab; p->name != NULL; p++) {
+  if (strcmp(p->name, "readline") == 0) {
+p->initfunc = initlldb_readline;
+break;
+  }
+}
+if (!ReadlinePatched) {
+  PyImport_AppendInittab("readline", initlldb_readline);
+  ReadlinePatched = true;
+}
+#endif
+
 // Register _lldb as a built-in module.
 PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -0,0 +1,26 @@
+//===-- PythonReadline.h *- 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
+//
+//===--===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
+
+#if !defined(LLDB_DISABLE_LIBEDIT) && !defined(__APPLE__)
+// NOTE: Since Python may define some pre-processor definitions which affect the
+// standard headers on some systems, you must include Python.h before any
+// standard headers are included.
+#include "Python.h"
+
+// no need to hack into Python's readline module if libedit isn't used.
+//
+#define LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE 1
+
+extern "C" PyMODINIT_FUNC initlldb_readline(void);
+
+#endif
+
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
@@ -0,0 +1,80 @@
+#include "PythonReadline.h"
+
+#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
+
+#include 
+
+#include 
+
+// Simple implementation of the Python readline module using libedit.
+// In the event that libedit is excluded from the build, this turns
+// back into a null implementation that blocks the module from pulling
+// in the GNU readline shared lib, which causes linkage confusion when
+// both readline and libedit's readline compatibility symbols collide.
+//
+// Currently it only installs a PyOS_ReadlineFunctionPointer, without
+// implementing any of the readline module methods. This is meant to
+// work around LLVM pr18841 to avoid seg faults in the stock Python
+// readline.so linked against GNU readline.
+//
+// Bug on the cpython side: https://bugs.python.org/issue38634
+
+PyDoc_STRVAR(moduleDocumentation,
+ "Simple readline module implementation based on libedit.");
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef readline_module = {
+PyModuleDef_HEAD_INIT, // m_base
+"lldb_editline",   // m_name
+moduleDocumentation,   // m_doc
+-1,// m_size
+nullptr,   // m_methods
+nullptr,   // m_reload
+nullptr,   // m_traverse
+nullptr,   // m_clear
+nullptr,   // m_free
+};
+#else
+static struct PyMethodDef moduleMethods[] = {{nullptr, nullptr, 0, nullptr}};
+#endif
+
+static char *
+#if PY_MAJOR_VERSION >= 3
+simple_readline(FILE *stdin, FILE *stdout, const char *prompt)
+#else
+simple_readline(FILE *stdin, FILE *stdout, char *prompt)
+#endif
+{
+  rl_instream = stdin;
+  rl_outstream = stdout;
+  char *line = readline(prompt);
+  if (!line) {
+char *ret = (char *)PyMem_RawMalloc(1);
+if

[Lldb-commits] [PATCH] D69106: MemoryRegion: Print "don't know" permission values as such

2019-11-05 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28cf9698abd3: MemoryRegion: Print "don't 
know" permission values as such (authored by labath).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D69106?vs=225410&id=227830#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69106

Files:
  lldb/include/lldb/Target/MemoryRegionInfo.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Target/MemoryRegionInfo.cpp
  lldb/test/Shell/Minidump/memory-region-from-module.yaml

Index: lldb/test/Shell/Minidump/memory-region-from-module.yaml
===
--- lldb/test/Shell/Minidump/memory-region-from-module.yaml
+++ lldb/test/Shell/Minidump/memory-region-from-module.yaml
@@ -19,8 +19,7 @@
 # ALL: [0x-0x4000) ---
 # ALL-LABEL: (lldb) memory region 0x4000
 # CHECK1: [0x4000-0x40b0) r-x {{.*}}memory-region-from-module.exe PT_LOAD[0]
-# TODO: This output does not give any indication that the region is only "potentially" writable.
-# CHECK2: [0x4000-0x4010) rwx
+# CHECK2: [0x4000-0x4010) r??
 # ALL-LABEL: (lldb) memory region 0x5000
 # ALL: [0x5000-0x505c) rw- {{.*}}memory-region-from-module.exe PT_LOAD[1]
 # ALL-LABEL: (lldb) memory region 0x6000
Index: lldb/source/Target/MemoryRegionInfo.cpp
===
--- lldb/source/Target/MemoryRegionInfo.cpp
+++ lldb/source/Target/MemoryRegionInfo.cpp
@@ -8,13 +8,33 @@
 
 #include "lldb/Target/MemoryRegionInfo.h"
 
+using namespace lldb_private;
+
 llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &OS,
 const MemoryRegionInfo &Info) {
-  return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2}, {3}, {4}, {5}, "
- "`{6}`, {7}, {8})",
+  return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2:r}{3:w}{4:x}, "
+ "{5}, `{6}`, {7}, {8})",
  Info.GetRange().GetRangeBase(),
  Info.GetRange().GetRangeEnd(), Info.GetReadable(),
  Info.GetWritable(), Info.GetExecutable(),
  Info.GetMapped(), Info.GetName(), Info.GetFlash(),
  Info.GetBlocksize());
 }
+
+void llvm::format_provider::format(
+const MemoryRegionInfo::OptionalBool &B, raw_ostream &OS,
+StringRef Options) {
+  assert(Options.size() <= 1);
+  bool Empty = Options.empty();
+  switch (B) {
+  case lldb_private::MemoryRegionInfo::eNo:
+OS << (Empty ? "no" : "-");
+return;
+  case lldb_private::MemoryRegionInfo::eYes:
+OS << (Empty ? "yes" : Options);
+return;
+  case lldb_private::MemoryRegionInfo::eDontKnow:
+OS << (Empty ? "don't know" : "?");
+return;
+  }
+}
Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -1730,15 +1730,12 @@
   section_name = section_sp->GetName();
 }
   }
-  result.AppendMessageWithFormat(
-  "[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") %c%c%c%s%s%s%s\n",
+  result.AppendMessageWithFormatv(
+  "[{0:x16}-{1:x16}) {2:r}{3:w}{4:x}{5}{6}{7}{8}\n",
   range_info.GetRange().GetRangeBase(),
-  range_info.GetRange().GetRangeEnd(),
-  range_info.GetReadable() ? 'r' : '-',
-  range_info.GetWritable() ? 'w' : '-',
-  range_info.GetExecutable() ? 'x' : '-', name ? " " : "",
-  name.AsCString(""), section_name ? " " : "",
-  section_name.AsCString(""));
+  range_info.GetRange().GetRangeEnd(), range_info.GetReadable(),
+  range_info.GetWritable(), range_info.GetExecutable(),
+  name ? " " : "", name, section_name ? " " : "", section_name);
   m_prev_end_addr = range_info.GetRange().GetRangeEnd();
   result.SetStatus(eReturnStatusSuccessFinishResult);
 } else {
Index: lldb/include/lldb/Target/MemoryRegionInfo.h
===
--- lldb/include/lldb/Target/MemoryRegionInfo.h
+++ lldb/include/lldb/Target/MemoryRegionInfo.h
@@ -133,21 +133,13 @@
 
 namespace llvm {
 template <>
+/// If Options is empty, prints a textual representation of the value. If
+/// Options is a single character, it uses that character for the "yes" value,
+/// while "no" is printed as "-", and "don't know" as "?". This can be used to
+/// print the permissions in the traditional "rwx" form.
 struct format_provider {
   static void format(const 

[Lldb-commits] [lldb] 28cf969 - MemoryRegion: Print "don't know" permission values as such

2019-11-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-05T11:17:27+01:00
New Revision: 28cf9698abd39221001ace885a7d1c1f488b967c

URL: 
https://github.com/llvm/llvm-project/commit/28cf9698abd39221001ace885a7d1c1f488b967c
DIFF: 
https://github.com/llvm/llvm-project/commit/28cf9698abd39221001ace885a7d1c1f488b967c.diff

LOG: MemoryRegion: Print "don't know" permission values as such

Summary:
The permissions in a memory region have ternary states (yes, no, don't
know), but the memory region command only prints in binary, treating
"don't know" as "yes", which is particularly confusing as for instance
the unwinder will treat an unknown value as "no".

This patch makes is so that we distinguish all three states when
printing the values, using "?" to indicate the lack of information. It
is implemented via a special argument to the format provider for the
OptionalBool enumeration.

Reviewers: clayborg, jingham

Subscribers: lldb-commits

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

Added: 


Modified: 
lldb/include/lldb/Target/MemoryRegionInfo.h
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Target/MemoryRegionInfo.cpp
lldb/test/Shell/Minidump/memory-region-from-module.yaml

Removed: 




diff  --git a/lldb/include/lldb/Target/MemoryRegionInfo.h 
b/lldb/include/lldb/Target/MemoryRegionInfo.h
index c6c4e080f8df..07e50188843e 100644
--- a/lldb/include/lldb/Target/MemoryRegionInfo.h
+++ b/lldb/include/lldb/Target/MemoryRegionInfo.h
@@ -133,21 +133,13 @@ class MemoryRegionInfos : public 
std::vector {
 
 namespace llvm {
 template <>
+/// If Options is empty, prints a textual representation of the value. If
+/// Options is a single character, it uses that character for the "yes" value,
+/// while "no" is printed as "-", and "don't know" as "?". This can be used to
+/// print the permissions in the traditional "rwx" form.
 struct format_provider {
   static void format(const lldb_private::MemoryRegionInfo::OptionalBool &B,
- raw_ostream &OS, StringRef Options) {
-switch(B) {
-case lldb_private::MemoryRegionInfo::eNo:
-  OS << "no";
-  return;
-case lldb_private::MemoryRegionInfo::eYes:
-  OS << "yes";
-  return;
-case lldb_private::MemoryRegionInfo::eDontKnow:
-  OS << "don't know";
-  return;
-}
-  }
+ raw_ostream &OS, StringRef Options);
 };
 }
 

diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index 679a7b6a9983..a20290f94bf5 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1730,15 +1730,12 @@ class CommandObjectMemoryRegion : public 
CommandObjectParsed {
   section_name = section_sp->GetName();
 }
   }
-  result.AppendMessageWithFormat(
-  "[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") %c%c%c%s%s%s%s\n",
+  result.AppendMessageWithFormatv(
+  "[{0:x16}-{1:x16}) {2:r}{3:w}{4:x}{5}{6}{7}{8}\n",
   range_info.GetRange().GetRangeBase(),
-  range_info.GetRange().GetRangeEnd(),
-  range_info.GetReadable() ? 'r' : '-',
-  range_info.GetWritable() ? 'w' : '-',
-  range_info.GetExecutable() ? 'x' : '-', name ? " " : "",
-  name.AsCString(""), section_name ? " " : "",
-  section_name.AsCString(""));
+  range_info.GetRange().GetRangeEnd(), range_info.GetReadable(),
+  range_info.GetWritable(), range_info.GetExecutable(),
+  name ? " " : "", name, section_name ? " " : "", section_name);
   m_prev_end_addr = range_info.GetRange().GetRangeEnd();
   result.SetStatus(eReturnStatusSuccessFinishResult);
 } else {

diff  --git a/lldb/source/Target/MemoryRegionInfo.cpp 
b/lldb/source/Target/MemoryRegionInfo.cpp
index 1feb84bffc58..2c31563786aa 100644
--- a/lldb/source/Target/MemoryRegionInfo.cpp
+++ b/lldb/source/Target/MemoryRegionInfo.cpp
@@ -8,13 +8,33 @@
 
 #include "lldb/Target/MemoryRegionInfo.h"
 
+using namespace lldb_private;
+
 llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &OS,
 const MemoryRegionInfo &Info) {
-  return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2}, {3}, {4}, {5}, 
"
- "`{6}`, {7}, {8})",
+  return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2:r}{3:w}{4:x}, "
+ "{5}, `{6}`, {7}, {8})",
  Info.GetRange().GetRangeBase(),
  Info.GetRange().GetRangeEnd(), Info.GetReadable(),
  Info.GetWritable(), Info.GetExecutable(),
  Info.GetMapped(), Info.GetName(), Info.GetFlash(),
  Info.GetBlocksize());
 }
+
+void llvm::format_provider::format

[Lldb-commits] [PATCH] D69793: Bundle libedit-compatible readline replacement

2019-11-05 Thread serge via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9357b5d08497: Revert and patch "[Python] Remove 
readline module" (authored by serge-sans-paille).

Changed prior to commit:
  https://reviews.llvm.org/D69793?vs=227823&id=227834#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69793

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -16,6 +16,7 @@
 #include "lldb-python.h"
 
 #include "PythonDataObjects.h"
+#include "PythonReadline.h"
 #include "ScriptInterpreterPythonImpl.h"
 
 #include "lldb/API/SBFrame.h"
@@ -217,6 +218,22 @@
 
 InitializePythonHome();
 
+#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
+// Python's readline is incompatible with libedit being linked into lldb.
+// Provide a patched version local to the embedded interpreter.
+bool ReadlinePatched = false;
+for (auto *p = PyImport_Inittab; p->name != NULL; p++) {
+  if (strcmp(p->name, "readline") == 0) {
+p->initfunc = initlldb_readline;
+break;
+  }
+}
+if (!ReadlinePatched) {
+  PyImport_AppendInittab("readline", initlldb_readline);
+  ReadlinePatched = true;
+}
+#endif
+
 // Register _lldb as a built-in module.
 PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -0,0 +1,26 @@
+//===-- PythonReadline.h *- 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
+//
+//===--===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
+
+#if !defined(LLDB_DISABLE_LIBEDIT) && !defined(__APPLE__)
+// NOTE: Since Python may define some pre-processor definitions which affect the
+// standard headers on some systems, you must include Python.h before any
+// standard headers are included.
+#include "Python.h"
+
+// no need to hack into Python's readline module if libedit isn't used.
+//
+#define LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE 1
+
+extern "C" PyMODINIT_FUNC initlldb_readline(void);
+
+#endif
+
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
@@ -0,0 +1,80 @@
+#include "PythonReadline.h"
+
+#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
+
+#include 
+
+#include 
+
+// Simple implementation of the Python readline module using libedit.
+// In the event that libedit is excluded from the build, this turns
+// back into a null implementation that blocks the module from pulling
+// in the GNU readline shared lib, which causes linkage confusion when
+// both readline and libedit's readline compatibility symbols collide.
+//
+// Currently it only installs a PyOS_ReadlineFunctionPointer, without
+// implementing any of the readline module methods. This is meant to
+// work around LLVM pr18841 to avoid seg faults in the stock Python
+// readline.so linked against GNU readline.
+//
+// Bug on the cpython side: https://bugs.python.org/issue38634
+
+PyDoc_STRVAR(moduleDocumentation,
+ "Simple readline module implementation based on libedit.");
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef readline_module = {
+PyModuleDef_HEAD_INIT, // m_base
+"lldb_editline",   // m_name
+moduleDocumentation,   // m_doc
+-1,// m_size
+nullptr,   // m_methods
+nullptr,   // m_reload
+nullptr,   // m_traverse
+nullptr,   // m_clear
+nullptr,   // m_free
+};
+#else
+static struct PyMethodDef moduleMethods[] = {{nullptr, nullptr, 0, nullptr}};
+#endif
+
+static char *
+#if PY_MAJOR_VERSION >= 3
+simple_readline(FILE *stdin, FILE *stdout, const char *prompt)
+#else
+simple_readline(FILE *stdin, FILE *stdout, char *prompt)
+#en

[Lldb-commits] [lldb] 4ecff91 - lldb/minidump: Add support for the alternate ARM64 constant

2019-11-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-05T11:26:06+01:00
New Revision: 4ecff91ed1df05edbdb55cb2ccdf58466f1333b0

URL: 
https://github.com/llvm/llvm-project/commit/4ecff91ed1df05edbdb55cb2ccdf58466f1333b0
DIFF: 
https://github.com/llvm/llvm-project/commit/4ecff91ed1df05edbdb55cb2ccdf58466f1333b0.diff

LOG: lldb/minidump: Add support for the alternate ARM64 constant

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml
lldb/source/Plugins/Process/minidump/MinidumpParser.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml
 
b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml
index 680ad623361e..3c0961eba077 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.yaml
@@ -1,7 +1,7 @@
 --- !minidump
 Streams: 
   - Type:SystemInfo
-Processor Arch:  BP_ARM64
+Processor Arch:  ARM64
 Platform ID: Linux
 CSD Version: '15E216'
 CPU: 

diff  --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp 
b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
index 99717e7fe34a..3c0e1cb49d1d 100644
--- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -173,6 +173,7 @@ ArchSpec MinidumpParser::GetArchitecture() {
   case ProcessorArchitecture::ARM:
 triple.setArch(llvm::Triple::ArchType::arm);
 break;
+  case ProcessorArchitecture::ARM64:
   case ProcessorArchitecture::BP_ARM64:
 triple.setArch(llvm::Triple::ArchType::aarch64);
 break;



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


[Lldb-commits] [PATCH] D69793: Bundle libedit-compatible readline replacement

2019-11-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

> 1. use PyMem_RawMalloc instead of PyMem_Malloc, as expected by PyOS_Readline 
> (prevents to segfault upon exit of interactive session)

It looks like this is failing on python2, because it has no RawMalloc function 
https://docs.python.org/2.7/c-api/memory.html. I guess this bit should be 
`#ifdef PY2` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69793



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


[Lldb-commits] [lldb] f71e35d - lldb/breakpad: add suppport for the "x86_64h" architecture

2019-11-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-05T11:41:20+01:00
New Revision: f71e35dc1f3ea9b368b1d4626ee9bf7993839084

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

LOG: lldb/breakpad: add suppport for the "x86_64h" architecture

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp 
b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
index de17d986a860..b83b2efb492f 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
@@ -72,7 +72,7 @@ llvm::Triple::ArchType 
stringTo(llvm::StringRef Str) {
   .Case("sparc", Triple::sparc)
   .Case("sparcv9", Triple::sparcv9)
   .Case("x86", Triple::x86)
-  .Case("x86_64", Triple::x86_64)
+  .Cases("x86_64", "x86_64h", Triple::x86_64)
   .Default(Triple::UnknownArch);
 }
 

diff  --git 
a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms 
b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms
index 069b79cc57d9..558a69c961d1 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms
+++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms
@@ -1,4 +1,4 @@
-MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out
+MODULE Linux x86_64h 761550E08086333960A9074A9CE2895C0 a.out
 INFO CODE_ID E05015768680393360A9074A9CE2895C
 FILE 0 /tmp/a.c
 a0 1 1 0



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


[Lldb-commits] [lldb] 9357b5d - Revert and patch "[Python] Remove readline module"

2019-11-05 Thread via lldb-commits

Author: serge-sans-paille
Date: 2019-11-05T11:39:19+01:00
New Revision: 9357b5d08497326a1895cab6c1d712bf12a34519

URL: 
https://github.com/llvm/llvm-project/commit/9357b5d08497326a1895cab6c1d712bf12a34519
DIFF: 
https://github.com/llvm/llvm-project/commit/9357b5d08497326a1895cab6c1d712bf12a34519.diff

LOG: Revert and patch "[Python] Remove readline module"

Fix https://bugs.llvm.org/show_bug.cgi?id=43830 while avoiding polluting the
global Python namespace.

This both reverts r357277 to rebundle a version of Python's readline module
based on libedit.

However, this patch also provides two improvements over the previous
implementation:

1. use PyMem_RawMalloc instead of PyMem_Malloc, as expected by PyOS_Readline
   (prevents to segfault upon exit of interactive session)
2. patch the readline module upon embedded interpreter loading, instead of
   patching it globally, which should prevent any side effect on other
   modules/packages
3. only activate the patched module if libedit is actually linked in lldb

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

Added: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h

Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt 
b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index 54b5c236f752..6febb0385781 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -5,6 +5,7 @@ 
add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
 
 add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
   PythonDataObjects.cpp
+  PythonReadline.cpp
   ScriptInterpreterPython.cpp
 
   LINK_LIBS

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
new file mode 100644
index ..616522f9de90
--- /dev/null
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
@@ -0,0 +1,80 @@
+#include "PythonReadline.h"
+
+#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
+
+#include 
+
+#include 
+
+// Simple implementation of the Python readline module using libedit.
+// In the event that libedit is excluded from the build, this turns
+// back into a null implementation that blocks the module from pulling
+// in the GNU readline shared lib, which causes linkage confusion when
+// both readline and libedit's readline compatibility symbols collide.
+//
+// Currently it only installs a PyOS_ReadlineFunctionPointer, without
+// implementing any of the readline module methods. This is meant to
+// work around LLVM pr18841 to avoid seg faults in the stock Python
+// readline.so linked against GNU readline.
+//
+// Bug on the cpython side: https://bugs.python.org/issue38634
+
+PyDoc_STRVAR(moduleDocumentation,
+ "Simple readline module implementation based on libedit.");
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef readline_module = {
+PyModuleDef_HEAD_INIT, // m_base
+"lldb_editline",   // m_name
+moduleDocumentation,   // m_doc
+-1,// m_size
+nullptr,   // m_methods
+nullptr,   // m_reload
+nullptr,   // m_traverse
+nullptr,   // m_clear
+nullptr,   // m_free
+};
+#else
+static struct PyMethodDef moduleMethods[] = {{nullptr, nullptr, 0, nullptr}};
+#endif
+
+static char *
+#if PY_MAJOR_VERSION >= 3
+simple_readline(FILE *stdin, FILE *stdout, const char *prompt)
+#else
+simple_readline(FILE *stdin, FILE *stdout, char *prompt)
+#endif
+{
+  rl_instream = stdin;
+  rl_outstream = stdout;
+  char *line = readline(prompt);
+  if (!line) {
+char *ret = (char *)PyMem_RawMalloc(1);
+if (ret != NULL)
+  *ret = '\0';
+return ret;
+  }
+  if (*line)
+add_history(line);
+  int n = strlen(line);
+  char *ret = (char *)PyMem_RawMalloc(n + 2);
+  if (ret) {
+strncpy(ret, line, n);
+free(line);
+ret[n] = '\n';
+ret[n + 1] = '\0';
+  }
+  return ret;
+}
+
+PyMODINIT_FUNC initlldb_readline(void) {
+  PyOS_ReadlineFunctionPointer = simple_readline;
+
+#if PY_MAJOR_VERSION >= 3
+  return PyModule_Create(&readline_module);
+#else
+  Py_InitModule4("lldb_readline", moduleMethods, moduleDocumentation,
+ static_cast(NULL), PYTHON_API_VERSION);
+#endif
+}
+#endif

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
new file mode 100644
index ..20242e2324d8
--- /dev/null
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -0,0 +1,

[Lldb-commits] [lldb] d590498 - [lldb] Fix readline/libedit compat patch for py2

2019-11-05 Thread via lldb-commits

Author: serge-sans-paille
Date: 2019-11-05T14:16:39+01:00
New Revision: d590498829d8c0d4f4f673569949fa3850485c9c

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

LOG: [lldb] Fix readline/libedit compat patch for py2

This is a follow-up to https://reviews.llvm.org/D69793

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
index 616522f9de90..674ec9b6140a 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
@@ -49,7 +49,11 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt)
   rl_outstream = stdout;
   char *line = readline(prompt);
   if (!line) {
+#if PY_MAJOR_VERSION >= 3
 char *ret = (char *)PyMem_RawMalloc(1);
+#else
+char *ret = (char *)PyMem_Malloc(1);
+#endif
 if (ret != NULL)
   *ret = '\0';
 return ret;
@@ -57,7 +61,11 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt)
   if (*line)
 add_history(line);
   int n = strlen(line);
+#if PY_MAJOR_VERSION >= 3
   char *ret = (char *)PyMem_RawMalloc(n + 2);
+#else
+  char *ret = (char *)PyMem_Malloc(n + 2);
+#endif
   if (ret) {
 strncpy(ret, line, n);
 free(line);
@@ -73,7 +81,7 @@ PyMODINIT_FUNC initlldb_readline(void) {
 #if PY_MAJOR_VERSION >= 3
   return PyModule_Create(&readline_module);
 #else
-  Py_InitModule4("lldb_readline", moduleMethods, moduleDocumentation,
+  Py_InitModule4("readline", moduleMethods, moduleDocumentation,
  static_cast(NULL), PYTHON_API_VERSION);
 #endif
 }



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


[Lldb-commits] [PATCH] D69793: Bundle libedit-compatible readline replacement

2019-11-05 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

In D69793#1733672 , @labath wrote:

> > 1. use PyMem_RawMalloc instead of PyMem_Malloc, as expected by 
> > PyOS_Readline (prevents to segfault upon exit of interactive session)
>
> It looks like this is failing on python2, because it has no RawMalloc 
> function https://docs.python.org/2.7/c-api/memory.html. I guess this bit 
> should be `#ifdef PY2` ?


Should be fixed by 590498829d8c0d4f4f673569949fa3850485c9c, at least this one 
make it work for both py2 and py3 on my laptop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69793



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


[Lldb-commits] [PATCH] D69793: Bundle libedit-compatible readline replacement

2019-11-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D69793#1733774 , @serge-sans-paille 
wrote:

> In D69793#1733672 , @labath wrote:
>
> > > 1. use PyMem_RawMalloc instead of PyMem_Malloc, as expected by 
> > > PyOS_Readline (prevents to segfault upon exit of interactive session)
> >
> > It looks like this is failing on python2, because it has no RawMalloc 
> > function https://docs.python.org/2.7/c-api/memory.html. I guess this bit 
> > should be `#ifdef PY2` ?
>
>
> Should be fixed by 590498829d8c0d4f4f673569949fa3850485c9c, at least this one 
> make it work for both py2 and py3 on my laptop.


Works for me. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69793



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


[Lldb-commits] [PATCH] D69793: Bundle libedit-compatible readline replacement

2019-11-05 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Ok, this is breaking build on NetBSD:

http://lab.llvm.org:8014/builders/netbsd-amd64/builds/92/steps/ninja%20build%20local/logs/stdio

Header location is not the only problem, the code fails to build after fixing 
that.

FWICS, the previous module was built only for subset of systems:

  -# build the Python readline suppression module only on Linux
  -if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL 
"GNU" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "kFreeBSD")
  -   add_subdirectory(readline)
  -endif()

I suppose the new one needs to be adjusted accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69793



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


[Lldb-commits] [PATCH] D69843: Expression eval lookup - prune methods without parsing

2019-11-05 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin created this revision.
jarin added a reviewer: labath.
jarin added a project: LLDB.
Herald added subscribers: lldb-commits, aprantl.

In large codebases, we sometimes see Module::FindFunctions (when called from
ClangExpressionDeclMap::FindExternalVisibleDecls) returning huge amounts of
functions. For example, a simple unreal engine example contains

> 1 of functions with the name 'operator*'. Evaluating an expression "*x",

where x is an instance of a class, will cause all those function's decl
contexts to be parsed, taking multiple seconds. However, most of those
parsed contexts will be immediately thrown away because most of the
functions are methods.

With this patch, I am trying to avoid the parsing by checking method-ness
directly from debug info rather than from parsed contexts. This helps a lot:
our unreal engine expression evaluation pause goes roughly from 4.5s to 0.3s.

However, my patch feels wrong - ideally, we would ignore methods already
during lookup (in ManualDWARFIndex::GetFunctions).

A resonable solution would be to change the meaning of
eFunctionNameTypeFull to only mean mangled names, and if the caller
wanted methods and basenames, they would have to call with
eFunctionNameTypeFull | eFunctionNameTypeMethod |
eFunctionNameTypeBase. This would require some amount churn at
(Get|Find)Functions call sites. Also, I am not sure about implications
for Apple's lookup index.

Thoughts?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69843

Files:
  lldb/include/lldb/Symbol/Function.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Symbol/Function.cpp


Index: lldb/source/Symbol/Function.cpp
===
--- lldb/source/Symbol/Function.cpp
+++ lldb/source/Symbol/Function.cpp
@@ -454,6 +454,16 @@
   return CompilerDeclContext();
 }
 
+bool Function::CanBeMethod() {
+  ModuleSP module_sp = CalculateSymbolContextModule();
+
+  if (module_sp) {
+if (SymbolFile *sym_file = module_sp->GetSymbolFile())
+  return sym_file->CanBeMethod(GetID());
+  }
+  return true;
+}
+
 Type *Function::GetType() {
   if (m_type == nullptr) {
 SymbolContext sc;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -144,6 +144,8 @@
   lldb_private::CompilerDeclContext
   GetDeclContextContainingUID(lldb::user_id_t uid) override;
 
+  bool CanBeMethod(lldb::user_id_t uid) override;
+
   void
   ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override;
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1314,6 +1314,16 @@
   return CompilerDeclContext();
 }
 
+bool SymbolFileDWARF::CanBeMethod(lldb::user_id_t uid) {
+  std::lock_guard guard(GetModuleMutex());
+  // Anytime we have a lldb::user_id_t, we must get the DIE by calling
+  // SymbolFileDWARF::GetDIE(). See comments inside the
+  // SymbolFileDWARF::GetDIE() for details.
+  if (DWARFDIE die = GetDIE(uid))
+return die.IsMethod();
+  return true;
+}
+
 Type *SymbolFileDWARF::ResolveTypeUID(lldb::user_id_t type_uid) {
   std::lock_guard guard(GetModuleMutex());
   // Anytime we have a lldb::user_id_t, we must get the DIE by calling
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1292,6 +1292,8 @@
   // Filter out functions without declaration contexts, as well as
   // class/instance methods, since they'll be skipped in the code that
   // follows anyway.
+  if (function->CanBeMethod())
+continue;
   CompilerDeclContext func_decl_context = function->GetDeclContext();
   if (!func_decl_context ||
   func_decl_context.IsClassMethod(nullptr, nullptr, nullptr))
Index: lldb/include/lldb/Symbol/SymbolFile.h
===
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -164,6 +164,7 @@
   virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) 
{
 return CompilerDeclContext();
   }
+  virtual bool CanBeMethod(lldb::user_id_t uid) { return true; }
   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
   

[Lldb-commits] [PATCH] D69846: [lldb] [Python] Build readline override module only on Linux

2019-11-05 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: serge-sans-paille, labath, JDevlieghere, krytarowski.

Restrict building the readline override to Linux only.  It both does not
build on *BSD systems, and is largely irrelevant since they default to
using libedit over readline anyway.  This restores the behavior
of the old readline override that also was built only on Linux.


https://reviews.llvm.org/D69846

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h


Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -9,7 +9,7 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 
-#if !defined(LLDB_DISABLE_LIBEDIT) && !defined(__APPLE__)
+#if !defined(LLDB_DISABLE_LIBEDIT) && defined(__linux__)
 // NOTE: Since Python may define some pre-processor definitions which affect 
the
 // standard headers on some systems, you must include Python.h before any
 // standard headers are included.


Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -9,7 +9,7 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 
-#if !defined(LLDB_DISABLE_LIBEDIT) && !defined(__APPLE__)
+#if !defined(LLDB_DISABLE_LIBEDIT) && defined(__linux__)
 // NOTE: Since Python may define some pre-processor definitions which affect the
 // standard headers on some systems, you must include Python.h before any
 // standard headers are included.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69793: Bundle libedit-compatible readline replacement

2019-11-05 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Made D69846  for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69793



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


[Lldb-commits] [PATCH] D69846: [lldb] [Python] Build readline override module only on Linux

2019-11-05 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Makes sense to me.


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

https://reviews.llvm.org/D69846



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


[Lldb-commits] [PATCH] D69846: [lldb] [Python] Build readline override module only on Linux

2019-11-05 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf3ae1eb296d: [lldb] [Python] Build readline override module 
only on Linux (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69846

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h


Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -9,7 +9,7 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 
-#if !defined(LLDB_DISABLE_LIBEDIT) && !defined(__APPLE__)
+#if !defined(LLDB_DISABLE_LIBEDIT) && defined(__linux__)
 // NOTE: Since Python may define some pre-processor definitions which affect 
the
 // standard headers on some systems, you must include Python.h before any
 // standard headers are included.


Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -9,7 +9,7 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONREADLINE_H
 
-#if !defined(LLDB_DISABLE_LIBEDIT) && !defined(__APPLE__)
+#if !defined(LLDB_DISABLE_LIBEDIT) && defined(__linux__)
 // NOTE: Since Python may define some pre-processor definitions which affect the
 // standard headers on some systems, you must include Python.h before any
 // standard headers are included.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69843: Expression eval lookup - prune methods without parsing

2019-11-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added reviewers: aprantl, clayborg.
labath added a comment.

> A resonable solution would be to change the meaning of
>  eFunctionNameTypeFull to only mean mangled names, and if the caller
>  wanted methods and basenames, they would have to call with
>  eFunctionNameTypeFull | eFunctionNameTypeMethod |
>  eFunctionNameTypeBase. This would require some amount churn at
>  (Get|Find)Functions call sites. Also, I am not sure about implications
>  for Apple's lookup index.

This sounds like a good path forward to me. I remember being bothered by the 
fact that we were returning `ns::foo`, when someone asked for a function with a 
"full" name `foo` when I worked on this code last time. However, I didn't do 
anything about that back when I was working on this code, as it wasn't that 
relevant for me then...

Unfortunately, just simply removing the

>   m_set.function_basenames.Find(name, offsets);
>   m_set.function_methods.Find(name, offsets);

lines from the manual dwarf index causes a number of tests to fail, so it looks 
like there are thing which do depend on us returning the extra things here. 
These need to be tracked down and fixed (possibly by adding ` | 
eFunctionNameTypeMethod | eFunctionNameTypeBase` to the FindFunctions call, 
possibly in another way...). As for the Apple (and debug_names) indexes, they 
can not avoid looking at the dwarf DIE to eliminate methods (because the 
accelerator tables don't store this information), but they can definitely check 
whether something is a method *after* looking at the DWARF but *before* 
returning from the GetFunctions method (which should still be a major 
improvement over status quo).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69843



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


[Lldb-commits] [PATCH] D69846: [lldb] [Python] Build readline override module only on Linux

2019-11-05 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

Thanks for the fix o/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69846



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


[Lldb-commits] [PATCH] D69843: Expression eval lookup - prune methods without parsing

2019-11-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I thought about something similar in the context of 
https://reviews.llvm.org/D68678 (that's for FIndTypes, but it we the same kind 
of problems there). Like Pavel said, it would be valuable to be able to filter 
after the accelerator table lookup, but before building, e.g., clang AST nodes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69843



___
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-05 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



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

aprantl wrote:
> 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.
Great catch!



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')

aprantl wrote:
> Is `___Z` really only used for blocks or is it used for other clang 
> extensions, too?
This is solely for block invocations.



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

aprantl wrote:
> Just FYI, this will create a merge conflict with swift-lldb. You might want 
> to think about how to resolve it ahead of committing.
It does not look too bad.



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

aprantl wrote:
> 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.
There is an old comment akin to that in `IsCPPMangledName`. I did not want to 
stray too far off into refactoring in this PR.


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] [lldb] a997003 - [lldb] Fix Python 3 incompatibility in API/lit.cfg.py

2019-11-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-11-05T10:13:01-08:00
New Revision: a9970036d43b4fb8622d7179603722b539756457

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

LOG: [lldb] Fix Python 3 incompatibility in API/lit.cfg.py

This code path is only taken on the sanitized bot, where it caused a
TypeError: "Can't mix strings and bytes in path components".

Added: 


Modified: 
lldb/test/API/lit.cfg.py

Removed: 




diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f29d9047e24e..06125a1aaedd 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -27,7 +27,8 @@
   if 'Darwin' in config.host_os and 'x86' in config.host_triple:
 import subprocess
 resource_dir = subprocess.check_output(
-[config.cmake_cxx_compiler, '-print-resource-dir']).strip()
+[config.cmake_cxx_compiler,
+ '-print-resource-dir']).decode('utf-8').strip()
 runtime = os.path.join(resource_dir, 'lib', 'darwin',
'libclang_rt.asan_osx_dynamic.dylib')
 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
@@ -66,9 +67,9 @@ def find_shlibpath_var():
 # lit complains if the value is set but it is not supported.
 supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
 if supported:
-lit_config.maxIndividualTestTime = 600
+  lit_config.maxIndividualTestTime = 600
 else:
-lit_config.warning("Could not set a default per-test timeout. " + errormsg)
+  lit_config.warning("Could not set a default per-test timeout. " + errormsg)
 
 # Build dotest command.
 dotest_cmd = [config.dotest_path]



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


[Lldb-commits] [lldb] 3606b56 - ValueObject: Upstream early-exit from swift-lldb. (NFC)

2019-11-05 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-11-05T10:53:57-08:00
New Revision: 3606b567849a935ef6bf627dec2e6100a8f25c4b

URL: 
https://github.com/llvm/llvm-project/commit/3606b567849a935ef6bf627dec2e6100a8f25c4b
DIFF: 
https://github.com/llvm/llvm-project/commit/3606b567849a935ef6bf627dec2e6100a8f25c4b.diff

LOG: ValueObject: Upstream early-exit from swift-lldb. (NFC)

Added: 


Modified: 
lldb/source/Core/Value.cpp

Removed: 




diff  --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index aa713d58dace..c70ab98dcdfa 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -322,6 +322,12 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, 
DataExtractor &data,
   AddressType address_type = eAddressTypeFile;
   Address file_so_addr;
   const CompilerType &ast_type = GetCompilerType();
+  llvm::Optional type_size = ast_type.GetByteSize(
+  exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
+  // Nothing to be done for a zero-sized type.
+  if (type_size && *type_size == 0)
+return error;
+
   switch (m_value_type) {
   case eValueTypeVector:
 if (ast_type.IsValid())
@@ -340,9 +346,8 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, 
DataExtractor &data,
 
 uint32_t limit_byte_size = UINT32_MAX;
 
-if (llvm::Optional size = ast_type.GetByteSize(
-exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
-  limit_byte_size = *size;
+if (type_size)
+  limit_byte_size = *type_size;
 
 if (limit_byte_size <= m_value.GetByteSize()) {
   if (m_value.GetData(data, limit_byte_size))



___
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-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



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

shafik wrote:
> aprantl wrote:
> > 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.
> There is an old comment akin to that in `IsCPPMangledName`. I did not want to 
> stray too far off into refactoring in this PR.
I think IsCPPMangledName should be called IsMangledName and every language 
plugin should define one. The fact that you forgot to make the same bugfix in 
CPlusPlusLanguage::IsCPPMangledName should be motivation enough to not 
implement the same functionality in two places :-)



Comment at: lldb/source/Core/Mangled.cpp:36
+static inline bool cstring_is_mangled(llvm::StringRef s) {
+  return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
 }

I was going to say, the function name doesn't make sense any more, but really 
we probably don't need this function at all, right?


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] [lldb] 2ff545e - Modernize add-dsym test Makefile

2019-11-05 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-05T12:22:59-08:00
New Revision: 2ff545e76d11bc4fdd7663945d6ac343575530fe

URL: 
https://github.com/llvm/llvm-project/commit/2ff545e76d11bc4fdd7663945d6ac343575530fe
DIFF: 
https://github.com/llvm/llvm-project/commit/2ff545e76d11bc4fdd7663945d6ac343575530fe.diff

LOG: Modernize add-dsym test Makefile

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile 
b/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile
index 5abcf02738c4..4e1ec2202d0b 100644
--- a/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile
+++ b/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile
@@ -1,24 +1,14 @@
-CC ?= clang
-ifeq "$(ARCH)" ""
-   ARCH = x86_64
-endif
-
-ifeq "$(OS)" ""
-   OS = $(shell uname -s)
-endif
+C_SOURCES = main.c
 
-CFLAGS ?= -g -O0
+include Makefile.rules
 
-ifeq "$(OS)" "Darwin"
-   CFLAGS += -arch $(ARCH)
-endif
+all: a.out.dSYM hide.app/Contents/a.out.dSYM
 
-all: main.c clean
+hide.app/Contents/a.out.dSYM:
mkdir hide.app
mkdir hide.app/Contents
-   $(CC) $(CFLAGS) -g $<
mv a.out.dSYM hide.app/Contents
strip -x a.out
-
-clean:
-   rm -rf a.out a.out.dSYM hide.app
+ifneq "$(CODESIGN)" ""
+   $(CODESIGN) -fs - a.out
+endif



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


[Lldb-commits] [lldb] 270fe47 - testsuite: skipIfNoSBHeaders should skip when running remotely

2019-11-05 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-05T12:22:59-08:00
New Revision: 270fe47aae4ac0bf72251161ad3320de56055c3a

URL: 
https://github.com/llvm/llvm-project/commit/270fe47aae4ac0bf72251161ad3320de56055c3a
DIFF: 
https://github.com/llvm/llvm-project/commit/270fe47aae4ac0bf72251161ad3320de56055c3a.diff

LOG: testsuite: skipIfNoSBHeaders should skip when running remotely

The LLDB dylib/framework will not be available on the remote host, it makes
no sense to try to run those tests in a remote scenario.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 5d9838f2f58a..2816cb7e39a5 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -517,6 +517,9 @@ def is_remote():
 def skipIfNoSBHeaders(func):
 """Decorate the item to mark tests that should be skipped when LLDB is 
built with no SB API headers."""
 def are_sb_headers_missing():
+if lldb.remote_platform:
+return "skip because SBHeaders tests make no sense remotely"
+
 if lldbplatformutil.getHostPlatform() == 'darwin':
 header = os.path.join(
 os.environ["LLDB_LIB_DIR"],



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


[Lldb-commits] [lldb] 2abcf44 - [Reproducer] Add test case for expression evaluation

2019-11-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-11-05T12:33:21-08:00
New Revision: 2abcf44f4c91a326d1f4513fb5c25fec51c6ca66

URL: 
https://github.com/llvm/llvm-project/commit/2abcf44f4c91a326d1f4513fb5c25fec51c6ca66
DIFF: 
https://github.com/llvm/llvm-project/commit/2abcf44f4c91a326d1f4513fb5c25fec51c6ca66.diff

LOG: [Reproducer] Add test case for expression evaluation

Added: 
lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test

Modified: 


Removed: 




diff  --git 
a/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in 
b/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
new file mode 100644
index ..8887c201d92e
--- /dev/null
+++ b/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
@@ -0,0 +1,10 @@
+breakpoint set -f foo.cpp -l 11
+run
+p foo
+next
+p Foo(2, 3.33);
+p $1
+p foo = Foo(3, 4.44);
+p foo
+cont
+reproducer generate

diff  --git 
a/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test 
b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
new file mode 100644
index ..d826a47cb245
--- /dev/null
+++ b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
@@ -0,0 +1,18 @@
+# UNSUPPORTED: system-windows, system-freebsd
+
+# This tests that expression evaluation continues to work when replaying a
+# reproducer.
+
+# RUN: rm -rf %t.repro
+# RUN: %clangxx_host %S/Inputs/foo.cpp -g -o %t.out
+
+# RUN: %lldb -x -b -s %S/Inputs/ExpressionEvaluation.in --capture 
--capture-path %t.repro %t.out | FileCheck %s
+# RUN: %lldb --replay %t.repro | FileCheck %s
+
+# CHECK: stop reason = breakpoint 1.1
+# CHECK: (Foo) $0 = (m_i = 0, m_d = 0)
+# CHECK: stop reason = step over
+# CHECK: (Foo) $1 = (m_i = 2, m_d = 3)
+# CHECK: (Foo) $1 = (m_i = 2, m_d = 3)
+# CHECK: (Foo) $2 = (m_i = 3, m_d = 4)
+# CHECK: (Foo) $3 = (m_i = 3, m_d = 4)



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


[Lldb-commits] [lldb] de5417f - [ValueObject] Upstream initialization from swift-lldb.

2019-11-05 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-11-05T12:36:14-08:00
New Revision: de5417f81d4e0ca732810e3b5565253b73b9e339

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

LOG: [ValueObject] Upstream initialization from swift-lldb.

This is a non-Swift-specific change in swift-lldb that seems to be
useful for remote debugging. If does in fact turn out to be redundant
we can remove it from llvm.org and then it will disappear in
swift-lldb, too.

Added: 


Modified: 
lldb/source/Core/ValueObject.cpp

Removed: 




diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index 7b4034c06400..ecb5a41ea8a0 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -100,6 +100,8 @@ ValueObject::ValueObject(ValueObject &parent)
   m_did_calculate_complete_objc_class_type(false),
   m_is_synthetic_children_generated(
   parent.m_is_synthetic_children_generated) {
+  m_data.SetByteOrder(parent.GetDataExtractor().GetByteOrder());
+  m_data.SetAddressByteSize(parent.GetDataExtractor().GetAddressByteSize());
   m_manager->ManageObject(this);
 }
 
@@ -126,6 +128,14 @@ ValueObject::ValueObject(ExecutionContextScope *exe_scope,
   m_is_getting_summary(false),
   m_did_calculate_complete_objc_class_type(false),
   m_is_synthetic_children_generated(false) {
+  if (exe_scope) {
+TargetSP target_sp(exe_scope->CalculateTarget());
+if (target_sp) {
+  const ArchSpec &arch = target_sp->GetArchitecture();
+  m_data.SetByteOrder(arch.GetByteOrder());
+  m_data.SetAddressByteSize(arch.GetAddressByteSize());
+}
+  }
   m_manager = new ValueObjectManager();
   m_manager->ManageObject(this);
 }



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


[Lldb-commits] [lldb] 3ac6863 - [ValueObject] Upstream early exit from swift-lldb. (NFC)

2019-11-05 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-11-05T12:43:00-08:00
New Revision: 3ac6863efbbfa27175588670e3b3715b0351ff4e

URL: 
https://github.com/llvm/llvm-project/commit/3ac6863efbbfa27175588670e3b3715b0351ff4e
DIFF: 
https://github.com/llvm/llvm-project/commit/3ac6863efbbfa27175588670e3b3715b0351ff4e.diff

LOG: [ValueObject] Upstream early exit from swift-lldb. (NFC)

Added: 


Modified: 
lldb/source/Core/ValueObject.cpp

Removed: 




diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index ecb5a41ea8a0..02453001a87f 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -589,6 +589,10 @@ ValueObjectSP 
ValueObject::GetChildMemberWithName(ConstString name,
 
   std::vector child_indexes;
   bool omit_empty_base_classes = true;
+
+  if (!GetCompilerType().IsValid())
+return ValueObjectSP();
+
   const size_t num_child_indexes =
   GetCompilerType().GetIndexOfChildMemberWithName(
   name.GetCString(), omit_empty_base_classes, child_indexes);



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


[Lldb-commits] [lldb] 6a79e08 - [lldb] Add a install target for lldb python on darwin

2019-11-05 Thread Haibo Huang via lldb-commits

Author: Haibo Huang
Date: 2019-11-05T13:25:38-08:00
New Revision: 6a79e083a0d131e741ac8f48badbb0481491e47f

URL: 
https://github.com/llvm/llvm-project/commit/6a79e083a0d131e741ac8f48badbb0481491e47f
DIFF: 
https://github.com/llvm/llvm-project/commit/6a79e083a0d131e741ac8f48badbb0481491e47f.diff

LOG: [lldb] Add a install target for lldb python on darwin

Summary: Similar to D68370 but for darwin framework build.

Reviewers: aadsm

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/CMakeLists.txt

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 388bcf76e662..128130621ba0 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -216,18 +216,21 @@ if (NOT LLDB_DISABLE_PYTHON)
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH 
${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries 
dir so that Windows can find it when launching



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


[Lldb-commits] [PATCH] D69834: [lldb] Add a install target for lldb python on darwin

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a79e083a0d1: [lldb] Add a install target for lldb python on 
darwin (authored by hhb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69834

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH 
${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries 
dir so that Windows can find it when launching


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69834: [lldb] Add a install target for lldb python on darwin

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227956.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69834

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH 
${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries 
dir so that Windows can find it when launching


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227958.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69589

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt

Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -54,4 +54,5 @@
   ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
 )
+set_target_properties(swig_wrapper PROPERTIES FOLDER "lldb misc")
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -103,77 +103,105 @@
 
   # Add a Post-Build Event to copy over Python files and create the symlink
   # to liblldb.so for the Python API(hardlink on Windows).
-  add_custom_target(finish_swig ALL VERBATIM
-COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_build_path}
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
+  add_custom_target(finish_swig ALL
+COMMENT "Copy over Python files and create symlinks for LLDB Python API.")
+  set_target_properties(finish_swig PROPERTIES FOLDER "lldb misc")
+
+  function(add_copy_file_target Name)
+cmake_parse_arguments(ARG "" "DEST_DIR;DEST_FILE_NAME" "FILES" ${ARGN})
+add_custom_command(OUTPUT ${ARG_DEST_DIR} VERBATIM
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DEST_DIR})
+foreach(src_file ${ARG_FILES})
+  if(ARG_DEST_FILE_NAME)
+set(file_name ${ARG_DEST_FILE_NAME})
+  else()
+get_filename_component(file_name ${src_file} NAME)
+  endif()
+  set(dest_file ${ARG_DEST_DIR}/${file_name})
+  list(APPEND DEST_FILES ${dest_file})
+  add_custom_command(OUTPUT ${dest_file} VERBATIM
+COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dest_file}
+DEPENDS ${ARG_DEST_DIR} ${src_file})
+endforeach()
+add_custom_target(${Name} DEPENDS ${DEST_FILES} ${ARG_DEST_DIR})
+  endfunction()
 
   if(NOT LLDB_USE_SYSTEM_SIX)
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
-"${lldb_python_build_path}/../six.py")
+add_copy_file_target(lldb_python_six
+  FILES"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
+  DEST_DIR "${lldb_python_build_path}/..")
+add_dependencies(finish_swig lldb_python_six)
   endif()
 
-  add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-COMMAND ${CMAKE_COMMAND} -E copy
-  "${lldb_scripts_dir}/lldb.py"
-  "${lldb_python_build_path}/__init__.py")
+  add_copy_file_target(lldb_python_init
+FILES  "${lldb_scripts_dir}/lldb.py"
+DEST_DIR   "${lldb_python_build_path}"
+DEST_FILE_NAME "__init__.py")
+  add_dependencies(finish_swig lldb_python_init)
 
   if(APPLE)
-SET(lldb_python_heap_dir "${lldb_python_build_path}/macosx/heap")
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_heap_dir}
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
-${lldb_python_heap_dir})
+add_copy_file_target(lldb_python_heap
+  FILES"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
+   "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
+  DEST_DIR "${lldb_python_build_path}/macosx/heap")
+add_dependencies(finish_swig lldb_python_heap)
   endif()
 
-  function(create_python_package target pkg_dir)
+  add_copy_file_target(lldb_python_embeded_interpreter
+FILES"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py"
+DEST_DIR "${lldb_python_build_path}")
+  add_dependencies(finish_swig lldb_python_embeded_interpreter)
+
+  function(add_lldb_python_package_target Name PKG_DIR)
 cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
-if(ARG_FILES)
-  set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
-endif()
-add_custom_command(TARGET ${target} POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${pkg_dir}
-  ${copy_cmd}
+set(ABS_PKG_DIR "${lldb_python_build_path}/${PKG_DIR}")
+add_copy_file_target("${Name}_srcs" FILES ${ARG_FILES} DEST_DIR ${ABS_PKG_DIR})
+add_custom_command(OUTPUT "${ABS_PKG_DIR}/__init__.py" VERBATIM
   COMMAND ${PYTHON_EXECUTABLE} "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
-${pkg_dir} ${ARG_FILES}
-  WORKING_DIRECTORY ${lldb_python_build_path})
+${PKG_DIR} ${ARG_FILES}
+  WORKING_DIRECTORY ${lldb_python_build_path}
+  DEPENDS "${Name}_srcs")
+add_custom_target(${Name} DEPENDS "${ABS_P

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

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

Let's do the refactoring in a follow-up commit.


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] [lldb] 40f3d13 - [TestMTCSimple] Disable the test if you don't have libMTC

2019-11-05 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2019-11-05T14:11:26-08:00
New Revision: 40f3d1307cfd66e6dc1a921eec42559a6691b393

URL: 
https://github.com/llvm/llvm-project/commit/40f3d1307cfd66e6dc1a921eec42559a6691b393
DIFF: 
https://github.com/llvm/llvm-project/commit/40f3d1307cfd66e6dc1a921eec42559a6691b393.diff

LOG: [TestMTCSimple] Disable the test if you don't have libMTC

If you are running on macOS and have the CommandLineTools installed of
Xcode, this test will fail because CommandLineTools doesn't ship with
libMainThreadChecker. Skip the test if you don't have it installed.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py
index e530c47d2d39..e3751e02c45f 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py
@@ -17,12 +17,16 @@ class MTCSimpleTestCase(TestBase):
 @skipUnlessDarwin
 def test(self):
 self.mtc_dylib_path = findMainThreadCheckerDylib()
-self.assertTrue(self.mtc_dylib_path != "")
+if self.mtc_dylib_path == "":
+self.skipTest("This test requires libMainThreadChecker.dylib")
+
 self.build()
 self.mtc_tests()
 
 @skipIf(archs=['i386'])
 def mtc_tests(self):
+self.assertTrue(self.mtc_dylib_path != "")
+
 # Load the test
 exe = self.getBuildArtifact("a.out")
 self.expect("file " + exe, patterns=["Current executable set to 
.*a.out"])



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


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227974.
hhb added a comment.

Fix some naming


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69589

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt

Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -54,4 +54,5 @@
   ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
 )
+set_target_properties(swig_wrapper PROPERTIES FOLDER "lldb misc")
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -103,77 +103,105 @@
 
   # Add a Post-Build Event to copy over Python files and create the symlink
   # to liblldb.so for the Python API(hardlink on Windows).
-  add_custom_target(finish_swig ALL VERBATIM
-COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_build_path}
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
+  add_custom_target(finish_swig ALL
+COMMENT "Copy over Python files and create symlinks for LLDB Python API.")
+  set_target_properties(finish_swig PROPERTIES FOLDER "lldb misc")
+
+  function(add_copy_file_target name)
+cmake_parse_arguments(ARG "" "DEST_DIR;DEST_FILE_NAME" "FILES" ${ARGN})
+add_custom_command(OUTPUT ${ARG_DEST_DIR} VERBATIM
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DEST_DIR})
+foreach(src_file ${ARG_FILES})
+  if(ARG_DEST_FILE_NAME)
+set(file_name ${ARG_DEST_FILE_NAME})
+  else()
+get_filename_component(file_name ${src_file} NAME)
+  endif()
+  set(dest_file ${ARG_DEST_DIR}/${file_name})
+  list(APPEND DEST_FILES ${dest_file})
+  add_custom_command(OUTPUT ${dest_file} VERBATIM
+COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dest_file}
+DEPENDS ${ARG_DEST_DIR} ${src_file})
+endforeach()
+add_custom_target(${name} DEPENDS ${DEST_FILES} ${ARG_DEST_DIR})
+  endfunction()
 
   if(NOT LLDB_USE_SYSTEM_SIX)
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
-"${lldb_python_build_path}/../six.py")
+add_copy_file_target(lldb_python_six
+  FILES"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
+  DEST_DIR "${lldb_python_build_path}/..")
+add_dependencies(finish_swig lldb_python_six)
   endif()
 
-  add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-COMMAND ${CMAKE_COMMAND} -E copy
-  "${lldb_scripts_dir}/lldb.py"
-  "${lldb_python_build_path}/__init__.py")
+  add_copy_file_target(lldb_python_init
+FILES  "${lldb_scripts_dir}/lldb.py"
+DEST_DIR   "${lldb_python_build_path}"
+DEST_FILE_NAME "__init__.py")
+  add_dependencies(finish_swig lldb_python_init)
 
   if(APPLE)
-SET(lldb_python_heap_dir "${lldb_python_build_path}/macosx/heap")
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_heap_dir}
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
-${lldb_python_heap_dir})
+add_copy_file_target(lldb_python_heap
+  FILES"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
+   "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
+  DEST_DIR "${lldb_python_build_path}/macosx/heap")
+add_dependencies(finish_swig lldb_python_heap)
   endif()
 
-  function(create_python_package target pkg_dir)
+  add_copy_file_target(lldb_python_embeded_interpreter
+FILES"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py"
+DEST_DIR "${lldb_python_build_path}")
+  add_dependencies(finish_swig lldb_python_embeded_interpreter)
+
+  function(add_lldb_python_package_target name pkg_dir)
 cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
-if(ARG_FILES)
-  set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
-endif()
-add_custom_command(TARGET ${target} POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${pkg_dir}
-  ${copy_cmd}
+set(ABS_PKG_DIR "${lldb_python_build_path}/${pkg_dir}")
+add_copy_file_target("${name}_srcs" FILES ${ARG_FILES} DEST_DIR ${ABS_PKG_DIR})
+add_custom_command(OUTPUT "${ABS_PKG_DIR}/__init__.py" VERBATIM
   COMMAND ${PYTHON_EXECUTABLE} "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
 ${pkg_dir} ${ARG_FILES}
-  WORKING_DIRECTORY ${lldb_python_build_path})
+  WORKING_DIRECTORY ${lldb_python_build_path}
+  DEPENDS "${name}_srcs")
+add_custom_target(${name} DEPENDS "${ABS_PKG_DIR}/__init__.py" "${

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69589#1733567 , @aadsm wrote:

> @hhb fwiw, I still get the same error with this diff (after applying it on 
> top of D69834 ). But D69834 
>  by itself works great!


Hmmm this change should not break it again... I rebased and cleaned up a 
little. Can you help try again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69589



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


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-05 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

@hhb I just did, and get the same error as well :(
`ninja: error: 'bin/LLDB.framework/LLDB', needed by 
'bin/LLDB.framework/Resources/Python/lldb/_lldb.so', missing and no known rule 
to make it`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69589



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


[Lldb-commits] [PATCH] D69871: crashlog.py: Improve regular expressions

2019-11-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, jasonmolenda.
Herald added a subscriber: kristof.beyls.
aprantl edited the summary of this revision.

This is yet another change to the regular expressions in crashlog.py that fix a 
few edge cases, and attempt to improve the readability quite a bit in the 
process. My last change to support spaces in filenames introduced a bug that 
caused the version/archspec field to be parsed as part of the image name.

So in `0x111 - 0x2 +MyApp Pro arm64  <01234>`, the name of the image 
was recognized as `MyApp Pro arm64` instead of `MyApp Pro` with a "version" of 
`arm64`.

The bugfix makes the space following an optional field mandatory *inside* the 
optional group.

rdar://problem/56883435


https://reviews.llvm.org/D69871

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/Python/crashlog.test

Index: lldb/test/Shell/Python/crashlog.test
===
--- lldb/test/Shell/Python/crashlog.test
+++ lldb/test/Shell/Python/crashlog.test
@@ -32,8 +32,8 @@
 "0x111 - 0x2 +MyApp Pro arm64  <01234> /tmp/MyApp Pro.app/MyApp Pro",
 # CHECK: 0x111
 # CHECK: 0x2
-# CHECK: MyApp Pro arm64
-# CHECK: None
+# CHECK: MyApp Pro
+# CHECK: arm64
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
 
@@ -45,13 +45,25 @@
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
 
-"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib"
+"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib",
 # CHECK: 0x7fff63f2
 # CHECK: 0x7fff63f77ff7
 # CHECK: libc++.1.dylib
+# CHECK: 4
 # CHECK: (400.9.4)
 # CHECK: None
+# CHECK: None
 # CHECK: /usr/lib/libc++.1.dylib
+
+"0x1047b8000 - 0x10481 dyld arm64e   /usr/lib/dyld"
+# CHECK: 0x1047b8000
+# CHECK: 0x10481
+# CHECK: dyld
+# CHECK: a
+# CHECK: arm64e
+# CHECK: )? (.*)')
+version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
+frame_regex = re.compile(r'^([0-9]+)' r'\s'# id
+ r'+(.+?)'r'\s+'   # img_name
+ r'(' +version+ r')?'  # img_version
+ r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
+ r' +(.*)' # offs
+)
+null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'   '[-\s]+' # img_lo
+  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
+  r'[+]?(.+?)'r'\s+' # img_name
+  r'(' +version+ ')?'# img_version
+  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(.*)'# img_path
+ )
 empty_line_regex = re.compile('^$')
 
 class Thread:
@@ -489,18 +500,20 @@
 continue
 frame_match = self.frame_regex.search(line)
 if frame_match:
-ident = frame_match.group(2)
+(frame_id, frame_img_name, _, frame_img_version, _,
+ frame_addr, frame_ofs) = frame_match.groups()
+ident = frame_img_name
 thread.add_ident(ident)
 if ident not in self.idents:
 self.idents.append(ident)
-thread.frames.append(CrashLog.Frame(int(frame_match.group(1)), int(
-frame_match.group(3), 0), frame_match.group(4)))
+thread.frames.append(CrashLog.Frame(int(frame_id), int(
+frame_addr, 0), frame_ofs))
 else:
 print('error: frame regex failed for line: "%s"' % line)
 elif parse_mode == PARSE_MODE_IMAGES:
 image_match = self.image_regex_uuid.search(line)
 if image_match:
-(img_lo, img_hi, img_name, img_version,
+(img_lo, img_hi, img_name, _, img_version, _,
  _, img_uuid, img_path) = image_match.groups()
 image = CrashLog.DarwinImage(int(img_lo, 0), int(img_hi, 0),
  img_name.strip(),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69873: [lldb-vscode] support the completion request

2019-11-05 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: clayborg, aadsm.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
wallace edited the summary of this revision.

The DAP has a completion request that has been unimplemented. It allows showing 
autocompletion tokens inside the Debug Console.
I implemented it in a very simple fashion mimicking what the user would see 
when autocompleting an expression inside the CLI.
There are two cases: normal variables and commands. The latter occurs when a 
text is prepepended with ` in the Debug Console.
These two cases work well and have tests.

F10634758: image.png 
F10634762: image.png 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69873

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -821,6 +821,151 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "CompletionsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Returns a list of possible completions for a given caret position and text.\nThe CompletionsRequest may only be called if the 'supportsCompletionsRequest' capability exists and is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "completions" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/CompletionsArguments"
+//   }
+// },
+// "required": [ "command", "arguments"  ]
+//   }]
+// },
+// "CompletionsArguments": {
+//   "type": "object",
+//   "description": "Arguments for 'completions' request.",
+//   "properties": {
+// "frameId": {
+//   "type": "integer",
+//   "description": "Returns completions in the scope of this stack frame. If not specified, the completions are returned for the global scope."
+// },
+// "text": {
+//   "type": "string",
+//   "description": "One or more source lines. Typically this is the text a user has typed into the debug console before he asked for completion."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "The character position for which to determine the completion proposals."
+// },
+// "line": {
+//   "type": "integer",
+//   "description": "An optional line for which to determine the completion proposals. If missing the first line of the text is assumed."
+// }
+//   },
+//   "required": [ "text", "column" ]
+// },
+// "CompletionsResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to 'completions' request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "targets": {
+// "type": "array",
+// "items": {
+//   "$ref": "#/definitions/CompletionItem"
+// },
+// "description": "The possible completions for ."
+//   }
+// },
+// "required": [ "targets" ]
+//   }
+// },
+// "required": [ "body" ]
+//   }]
+// },
+// "CompletionItem": {
+//   "type": "object",
+//   "description": "CompletionItems are the suggestions returned from the CompletionsRequest.",
+//   "properties": {
+// "label": {
+//   "type": "string",
+//   "description": "The label of this completion item. By default this is also the text that is inserted when selecting this completion."
+// },
+// "text": {
+//   "type": "string",
+//   "description": "If text is not falsy then it is inserted instead of the label."
+// },
+// "sortText": {
+//   "type": "string",
+//   "description": "A string that should be used when comparing this item with other items. When `falsy` the label is used."
+// },
+// "type": {
+//   "$ref": "#/definitions/CompletionItemType",
+//   "description": "The item's type. Typically the client uses this information to render the item in the UI with an icon."
+// },
+// "start": {
+//   "type": "integer",
+//   "description": "This value determines the location (in the CompletionsRequest's 'text' attribute) where the completion text is added.\nIf missing the text is adde

[Lldb-commits] [PATCH] D69871: crashlog.py: Improve regular expressions

2019-11-05 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

I'll be honest I'm having trouble thinking of all the possible problems these 
regexes might have just by looking at them, but overall this looks good to me.

Should we add a couple of extra file-check tests for variations in the version 
number part of the binary list in a crash report? Looking around some random 
crash reports, I see number-number "(6.9 - 1674.102)" I see one where the 
framework name is in there "(1.11 - FrameworkName 1.11)" and hah a random hand 
built lldb crash I have on my system has "(7.0.0svn - 7.0.0svn)".


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

https://reviews.llvm.org/D69871



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