[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223983.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/source/Core/IOHandler.cpp

Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -305,94 +305,145 @@
   m_delegate.IOHandlerDeactivated(*this);
 }
 
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;
+
+// Split out a line from the buffer, if there is a full one to get.
+static Optional SplitLine(std::string _buffer) {
+  size_t pos = line_buffer.find('\n');
+  if (pos == std::string::npos)
+return None;
+  size_t end = pos + 1;
+  while (end > 0 &&
+ (line_buffer[end - 1] == '\n' || line_buffer[end - 1] == '\r'))
+end--;
+  std::string line = line_buffer.substr(0, end);
+  line_buffer = line_buffer.substr(pos + 1);
+  return line;
+}
+
+// Append newchars to the buffer and split out a line.
+static Optional AppendAndSplitLine(std::string _buffer,
+StringRef newchars) {
+  size_t pos = newchars.find('\n');
+  if (pos == StringRef::npos) {
+line_buffer.append(newchars);
+return None;
+  }
+  size_t end = pos + 1;
+  while (end > 0 && (newchars[end - 1] == '\n' || newchars[end - 1] == '\r'))
+end--;
+  std::string line = std::move(line_buffer);
+  line.append(newchars.substr(0, end));
+  line_buffer = newchars.substr(pos + 1);
+  return line;
+}
+
+// If the final line of the file ends without a end-of-line, return
+// it as a line anyway.
+static Optional SplitLineEOF(std::string _buffer) {
+  if (line_buffer.empty())
+return None;
+  if (std::all_of(line_buffer.begin(), line_buffer.end(), isspace))
+return None;
+  std::string line = std::move(line_buffer);
+  line_buffer.clear();
+  return line;
+}
+
 bool IOHandlerEditline::GetLine(std::string , bool ) {
 #ifndef LLDB_DISABLE_LIBEDIT
   if (m_editline_up) {
 bool b = m_editline_up->GetLine(line, interrupted);
-if (m_data_recorder)
+if (b && m_data_recorder)
   m_data_recorder->Record(line, true);
 return b;
-  } else {
+  }
 #endif
-line.clear();
 
-FILE *in = GetInputFILE();
-if (in) {
-  if (GetIsInteractive()) {
-const char *prompt = nullptr;
+  line.clear();
 
-if (m_multi_line && m_curr_line_idx > 0)
-  prompt = GetContinuationPrompt();
+  if (GetIsInteractive()) {
+const char *prompt = nullptr;
 
-if (prompt == nullptr)
-  prompt = GetPrompt();
+if (m_multi_line && m_curr_line_idx > 0)
+  prompt = GetContinuationPrompt();
 
-if (prompt && prompt[0]) {
-  if (m_output_sp) {
-m_output_sp->Printf("%s", prompt);
-m_output_sp->Flush();
-  }
-}
+if (prompt == nullptr)
+  prompt = GetPrompt();
+
+if (prompt && prompt[0]) {
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
+  }
+}
+  }
+
+  Optional got_line = SplitLine(m_line_buffer);
+
+  if (!got_line && !m_input_sp) {
+// No more input file, we are done...
+SetIsDone(true);
+return false;
+  }
+
+  FILE *in = GetInputFILE();
+  char buffer[256];
+
+  if (!got_line && !in && m_input_sp) {
+// there is no FILE*, fall back on just reading bytes from the stream.
+while (!got_line) {
+  size_t bytes_read = sizeof(buffer);
+  Status error = m_input_sp->Read((void *)buffer, bytes_read);
+  if (error.Success() && !bytes_read) {
+got_line = SplitLineEOF(m_line_buffer);
+break;
   }
-  char buffer[256];
-  bool done = false;
-  bool got_line = false;
-  m_editing = true;
-  while (!done) {
+  if (error.Fail())
+break;
+  got_line =
+  AppendAndSplitLine(m_line_buffer, StringRef(buffer, bytes_read));
+}
+  }
+
+  if (!got_line && in) {
+m_editing = true;
+while (!got_line) {
+  char *r = fgets(buffer, sizeof(buffer), in);
 #ifdef _WIN32
-// ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
-// according to the docs on MSDN. However, this has evidently been a
-// known bug since Windows 8. Therefore, we can't detect if a signal
-// interrupted in the fgets. So pressing ctrl-c causes the repl to end
-// and the process to exit. A temporary workaround is just to attempt to
-// fgets twice until this bug is fixed.
-if (fgets(buffer, sizeof(buffer), in) == nullptr &&
-fgets(buffer, sizeof(buffer), in) == nullptr) {
-  // this is the equivalent of EINTR for Windows
-  if (GetLastError() == ERROR_OPERATION_ABORTED)
-   

[Lldb-commits] [PATCH] D68444: remove a smattering of isolated, unnecessary uses of FILE*

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223981.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68444

Files:
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -423,7 +423,7 @@
   .SetBaseLineNumber(m_code.GetSize() + 1);
 }
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->Printf("\n");
 }
   }
 }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -328,10 +328,9 @@
   prompt = GetPrompt();
 
 if (prompt && prompt[0]) {
-  FILE *out = GetOutputFILE();
-  if (out) {
-::fprintf(out, "%s", prompt);
-::fflush(out);
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
   }
 }
   }
@@ -490,10 +489,11 @@
   // Show line numbers if we are asked to
   std::string line;
   if (m_base_line_number > 0 && GetIsInteractive()) {
-FILE *out = GetOutputFILE();
-if (out)
-  ::fprintf(out, "%u%s", m_base_line_number + 
(uint32_t)lines.GetSize(),
-GetPrompt() == nullptr ? " " : "");
+if (m_output_sp) {
+  m_output_sp->Printf("%u%s",
+  m_base_line_number + (uint32_t)lines.GetSize(),
+  GetPrompt() == nullptr ? " " : "");
+}
   }
 
   m_curr_line_idx = lines.GetSize();
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -467,10 +467,8 @@
 
 sb_interpreter.HandleCommand(command, result, false);
 
-if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFile());
-if (GetOutputFileHandle() != nullptr)
-  result.PutOutput(GetOutputFile());
+result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -423,7 +423,7 @@
   .SetBaseLineNumber(m_code.GetSize() + 1);
 }
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->Printf("\n");
 }
   }
 }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -328,10 +328,9 @@
   prompt = GetPrompt();
 
 if (prompt && prompt[0]) {
-  FILE *out = GetOutputFILE();
-  if (out) {
-::fprintf(out, "%s", prompt);
-::fflush(out);
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
   }
 }
   }
@@ -490,10 +489,11 @@
   // Show line numbers if we are asked to
   std::string line;
   if (m_base_line_number > 0 && GetIsInteractive()) {
-FILE *out = GetOutputFILE();
-if (out)
-  ::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(),
-GetPrompt() == nullptr ? " " : "");
+if (m_output_sp) {
+  m_output_sp->Printf("%u%s",
+  m_base_line_number + (uint32_t)lines.GetSize(),
+  GetPrompt() == nullptr ? " " : "");
+}
   }
 
   m_curr_line_idx = lines.GetSize();
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -467,10 +467,8 @@
 
 sb_interpreter.HandleCommand(command, result, false);
 
-if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFile());
-if (GetOutputFileHandle() != nullptr)
-  result.PutOutput(GetOutputFile());
+result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223978.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188

Files:
  lldb/include/lldb/API/SBFile.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig
  lldb/scripts/interface/SBFile.i
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1028,22 +1028,23 @@
   // first-class object type anymore.  `PyFile_FromFd` is just a thin wrapper
   // over `io.open()`, which returns some object derived from `io.IOBase`. As a
   // result, the only way to detect a file in Python 3 is to check whether it
-  // inherits from `io.IOBase`.  Since it is possible for non-files to also
-  // inherit from `io.IOBase`, we additionally verify that it has the `fileno`
-  // attribute, which should guarantee that it is backed by the file system.
-  PythonObject io_module(PyRefType::Owned, PyImport_ImportModule("io"));
-  PythonDictionary io_dict(PyRefType::Borrowed,
-   PyModule_GetDict(io_module.get()));
-  PythonObject io_base_class = io_dict.GetItemForKey(PythonString("IOBase"));
-
-  PythonObject object_type(PyRefType::Owned, PyObject_Type(py_obj));
-
-  if (1 != PyObject_IsSubclass(object_type.get(), io_base_class.get()))
+  // inherits from `io.IOBase`.
+  auto io_module = PythonModule::Import("io");
+  if (!io_module) {
+llvm::consumeError(io_module.takeError());
 return false;
-  if (!object_type.HasAttribute("fileno"))
+  }
+  auto iobase = io_module.get().Get("IOBase");
+  if (!iobase) {
+llvm::consumeError(iobase.takeError());
 return false;
-
-  return true;
+  }
+  int r = PyObject_IsInstance(py_obj, iobase.get().get());
+  if (r < 0) {
+llvm::consumeError(exception()); // clear the exception and log it.
+return false;
+  }
+  return !!r;
 #endif
 }
 
@@ -1096,6 +1097,20 @@
   return file;
 }
 
+namespace {
+class GIL {
+public:
+  GIL() {
+m_state = PyGILState_Ensure();
+assert(!PyErr_Occurred());
+  }
+  ~GIL() { PyGILState_Release(m_state); }
+
+protected:
+  PyGILState_STATE m_state;
+};
+} // namespace
+
 const char *PythonException::toCString() const {
   if (!m_repr_bytes)
 return "unknown exception";
@@ -1150,4 +1165,371 @@
 
 char PythonException::ID = 0;
 
+llvm::Expected GetOptionsForPyObject(const PythonObject ) {
+  uint32_t options = 0;
+#if PY_MAJOR_VERSION >= 3
+  auto readable = As(obj.CallMethod("readable"));
+  if (!readable)
+return readable.takeError();
+  auto writable = As(obj.CallMethod("writable"));
+  if (!writable)
+return writable.takeError();
+  if (readable.get())
+options |= File::eOpenOptionRead;
+  if (writable.get())
+options |= File::eOpenOptionWrite;
+#else
+  PythonString py_mode = obj.GetAttributeValue("mode").AsType();
+  options = File::GetOptionsFromMode(py_mode.GetString());
+#endif
+  return options;
+}
+
+// Base class template for python files.   All it knows how to do
+// is hold a reference to the python object and close or flush it
+// when the File is closed.
+namespace {
+template  class OwnedPythonFile : public Base {
+public:
+  template 
+  OwnedPythonFile(const PythonFile , bool borrowed, Args... args)
+  : Base(args...), m_py_obj(file), m_borrowed(borrowed) {
+assert(m_py_obj);
+  }
+
+  ~OwnedPythonFile() override {
+assert(m_py_obj);
+GIL takeGIL;
+Close();
+m_py_obj.Reset();
+  }
+
+  bool IsPythonSideValid() const {
+GIL takeGIL;
+auto closed = As(m_py_obj.GetAttribute("closed"));
+if (!closed) {
+  llvm::consumeError(closed.takeError());
+  return false;
+}
+return !closed.get();
+  }
+
+  bool IsValid() const override {
+return IsPythonSideValid() && Base::IsValid();
+  }
+
+  Status Close() override {
+assert(m_py_obj);
+Status py_error, base_error;
+GIL takeGIL;
+if (!m_borrowed) {
+  auto r = m_py_obj.CallMethod("close");
+  if (!r)
+py_error = Status(r.takeError());
+}
+base_error = Base::Close();
+if (py_error.Fail())
+  return py_error;
+return base_error;
+  };
+
+protected:
+  PythonFile m_py_obj;
+  bool m_borrowed;
+};
+} // namespace
+
+// A SimplePythonFile is a OwnedPythonFile that just does all I/O as
+// a NativeFile
+namespace {
+class SimplePythonFile : public OwnedPythonFile {
+public:
+  SimplePythonFile(const PythonFile , bool borrowed, int fd,
+   uint32_t options)
+  : OwnedPythonFile(file, borrowed, fd, options, false) {}
+};
+} // namespace
+
+#if PY_MAJOR_VERSION 

[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223980.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434

Files:
  lldb/include/lldb/API/SBCommandReturnObject.h
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/Interpreter/CommandReturnObject.h
  lldb/include/lldb/Utility/ReproducerInstrumentation.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/interface/SBCommandReturnObject.i
  lldb/source/API/SBCommandReturnObject.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -11,6 +11,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBFile.h"
 #include "lldb/API/SBHostOS.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBReproducer.h"
@@ -499,16 +500,16 @@
   SBCommandReturnObject result;
   sb_interpreter.SourceInitFileInHomeDirectory(result);
   if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFileHandle());
-result.PutOutput(m_debugger.GetOutputFileHandle());
+result.PutError(m_debugger.GetErrorFile());
+result.PutOutput(m_debugger.GetOutputFile());
   }
 
   // Source the local .lldbinit file if it exists and we're allowed to source.
   // Here we want to always print the return object because it contains the
   // warning and instructions to load local lldbinit files.
   sb_interpreter.SourceInitFileInCurrentWorkingDirectory(result);
-  result.PutError(m_debugger.GetErrorFileHandle());
-  result.PutOutput(m_debugger.GetOutputFileHandle());
+  result.PutError(m_debugger.GetErrorFile());
+  result.PutOutput(m_debugger.GetOutputFile());
 
   // We allow the user to specify an exit code when calling quit which we will
   // return when exiting.
@@ -574,8 +575,8 @@
   }
 
   if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFileHandle());
-result.PutOutput(m_debugger.GetOutputFileHandle());
+result.PutError(m_debugger.GetErrorFile());
+result.PutOutput(m_debugger.GetOutputFile());
   }
 
   const bool handle_events = true;
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -879,8 +879,9 @@
   ::setbuf(outfile_handle, nullptr);
 
 result->SetImmediateOutputFile(
-debugger.GetOutputFile().GetStream());
-result->SetImmediateErrorFile(debugger.GetErrorFile().GetStream());
+debugger.GetOutputStream().GetFileSP());
+result->SetImmediateErrorFile(
+debugger.GetErrorStream().GetFileSP());
   }
 }
   }
Index: lldb/source/API/SBFile.cpp
===
--- lldb/source/API/SBFile.cpp
+++ lldb/source/API/SBFile.cpp
@@ -23,12 +23,13 @@
 SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); }
 
 SBFile::SBFile(FILE *file, bool transfer_ownership) {
+  LLDB_RECORD_DUMMY(void, SBFile, (FILE *, bool), file, transfer_ownership);
   m_opaque_sp = std::make_shared(file, transfer_ownership);
 }
 
 SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) {
-  LLDB_RECORD_CONSTRUCTOR(SBFile, (int, const char *, bool), fd, mode,
-  transfer_owndership);
+  LLDB_RECORD_DUMMY(void, SBFile, (int, const char *, bool), fd, mode,
+transfer_owndership);
   auto options = File::GetOptionsFromMode(mode);
   m_opaque_sp = std::make_shared(fd, options, transfer_owndership);
 }
@@ -104,9 +105,9 @@
 
 namespace lldb_private {
 namespace repro {
+
 template <> void RegisterMethods(Registry ) {
-  LLDB_REGISTER_CONSTRUCTOR(SBFile, ());
-  LLDB_REGISTER_CONSTRUCTOR(SBFile, (int, const char *, bool));
+
   LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,());
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -468,9 +468,9 @@
 sb_interpreter.HandleCommand(command, result, false);
 
 if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFileHandle());
+  result.PutError(GetErrorFile());
 if (GetOutputFileHandle() != nullptr)
-  

[Lldb-commits] [PATCH] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223982.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546

Files:
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/API/SBProcess.h
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_process.py
  lldb/scripts/interface/SBDebugger.i
  lldb/scripts/interface/SBProcess.i
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBProcess.cpp

Index: lldb/source/API/SBProcess.cpp
===
--- lldb/source/API/SBProcess.cpp
+++ lldb/source/API/SBProcess.cpp
@@ -29,11 +29,11 @@
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Stream.h"
 
-
 #include "lldb/API/SBBroadcaster.h"
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEvent.h"
+#include "lldb/API/SBFile.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBMemoryRegionInfo.h"
 #include "lldb/API/SBMemoryRegionInfoList.h"
@@ -331,23 +331,37 @@
   return LLDB_RECORD_RESULT(trace_instance);
 }
 
+void SBProcess::ReportEventState(const SBEvent , SBFile out) const {
+  LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+   (const SBEvent &, SBFile), event, out);
+
+  return ReportEventState(event, out.m_opaque_sp);
+}
+
 void SBProcess::ReportEventState(const SBEvent , FILE *out) const {
   LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
(const lldb::SBEvent &, FILE *), event, out);
+  FileSP outfile = std::make_shared(out, false);
+  return ReportEventState(event, outfile);
+}
 
-  if (out == nullptr)
+void SBProcess::ReportEventState(const SBEvent , FileSP out) const {
+
+  LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+   (const SBEvent &, FileSP), event, out);
+
+  if (!out || !out->IsValid())
 return;
 
   ProcessSP process_sp(GetSP());
   if (process_sp) {
 const StateType event_state = SBProcess::GetStateFromEvent(event);
 char message[1024];
-int message_len = ::snprintf(
+size_t message_len = ::snprintf(
 message, sizeof(message), "Process %" PRIu64 " %s\n",
 process_sp->GetID(), SBDebugger::StateAsCString(event_state));
-
 if (message_len > 0)
-  ::fwrite(message, 1, message_len, out);
+  out->Write((void *)message, message_len);
   }
 }
 
@@ -1310,6 +1324,10 @@
(lldb::SBTraceOptions &, lldb::SBError &));
   LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
  (const lldb::SBEvent &, FILE *));
+  LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, FileSP));
+  LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, SBFile));
   LLDB_REGISTER_METHOD(
   void, SBProcess, AppendEventStateReport,
   (const lldb::SBEvent &, lldb::SBCommandReturnObject &));
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -479,8 +479,7 @@
 while (lldb_listener_sp->GetEventForBroadcaster(
 process_sp.get(), event_sp, std::chrono::seconds(0))) {
   SBEvent event(event_sp);
-  HandleProcessEvent(process, event, GetOutputFileHandle(),
- GetErrorFileHandle());
+  HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
 }
   }
 }
@@ -497,6 +496,17 @@
   return LLDB_RECORD_RESULT(sb_listener);
 }
 
+void SBDebugger::HandleProcessEvent(const SBProcess ,
+const SBEvent , SBFile out,
+SBFile err) {
+  LLDB_RECORD_METHOD(
+  void, SBDebugger, HandleProcessEvent,
+  (const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile), process,
+  event, out, err);
+
+  return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp);
+}
+
 void SBDebugger::HandleProcessEvent(const SBProcess ,
 const SBEvent , FILE *out,
 FILE *err) {
@@ -505,6 +515,20 @@
   (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process,
   event, out, err);
 
+  FileSP outfile = std::make_shared(out, false);
+  FileSP errfile = std::make_shared(err, false);
+  return HandleProcessEvent(process, event, outfile, errfile);
+}
+
+void SBDebugger::HandleProcessEvent(const SBProcess ,
+const SBEvent , FileSP out_sp,
+FileSP err_sp) {
+
+  

[Lldb-commits] [PATCH] D68677: protect libedit and LLDB gui from receiving null FILE* streams

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223984.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68677

Files:
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Core/IOHandler.cpp


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -266,7 +266,8 @@
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
 m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
Index: lldb/source/Commands/CommandObjectGUI.cpp
===
--- lldb/source/Commands/CommandObjectGUI.cpp
+++ lldb/source/Commands/CommandObjectGUI.cpp
@@ -29,7 +29,9 @@
 Debugger  = GetDebugger();
 
 File  = debugger.GetInputFile();
-if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+File  = debugger.GetOutputFile();
+if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
 debugger.PushIOHandler(io_handler_sp);


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -266,7 +266,8 @@
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
 m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
Index: lldb/source/Commands/CommandObjectGUI.cpp
===
--- lldb/source/Commands/CommandObjectGUI.cpp
+++ lldb/source/Commands/CommandObjectGUI.cpp
@@ -29,7 +29,9 @@
 Debugger  = GetDebugger();
 
 File  = debugger.GetInputFile();
-if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+File  = debugger.GetOutputFile();
+if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
 debugger.PushIOHandler(io_handler_sp);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68433: SBFile: add a bunch of tests that should eventually work.

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223979.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68433

Files:
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig

Index: lldb/scripts/Python/python-typemaps.swig
===
--- lldb/scripts/Python/python-typemaps.swig
+++ lldb/scripts/Python/python-typemaps.swig
@@ -444,19 +444,19 @@
   $1 = nullptr;
else if (!lldb_private::PythonFile::Check($input)) {
   int fd = PyObject_AsFileDescriptor($input);
+  if (fd < 0 || PyErr_Occurred())
+return nullptr;
   PythonObject py_input(PyRefType::Borrowed, $input);
   PythonString py_mode = py_input.GetAttributeValue("mode").AsType();
-
-  if (-1 != fd && py_mode.IsValid()) {
- FILE *f;
- if ((f = fdopen(fd, py_mode.GetString().str().c_str(
-$1 = f;
- else
-PyErr_SetString(PyExc_TypeError, strerror(errno));
-  } else {
- PyErr_SetString(PyExc_TypeError,"not a file-like object");
- return nullptr;
-  }
+  if (!py_mode.IsValid() || PyErr_Occurred())
+return nullptr;
+FILE *f;
+if ((f = fdopen(fd, py_mode.GetString().str().c_str(
+  $1 = f;
+else {
+  PyErr_SetString(PyExc_TypeError, strerror(errno));
+  return nullptr;
+}
}
else
{
Index: lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
+++ lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
@@ -13,7 +13,7 @@
 import lldb
 from lldbsuite.test import  lldbtest
 from lldbsuite.test.decorators import (
-add_test_categories, skipIf, skipIfWindows)
+add_test_categories, skipIf, skipIfWindows, expectedFailure)
 
 class OhNoe(Exception):
 pass
@@ -162,7 +162,9 @@
 with open(self.out_filename, 'w') as f:
 self.debugger.SetErrorFileHandle(f, False)
 self.handleCmd('lolwut', check=False, collect_result=False)
-self.debugger.GetErrorFileHandle().write('FOOBAR\n')
+f2 = self.debugger.GetErrorFileHandle()
+f2.write('FOOBAR\n')
+f2.flush()
 lldb.SBDebugger.Destroy(self.debugger)
 with open(self.out_filename, 'r') as f:
 errors = f.read()
@@ -180,6 +182,16 @@
 self.assertIn("is not a valid command", f.read())
 
 
+@add_test_categories(['pyapi'])
+def test_legacy_file_error(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+debugger.SetErrorFileHandle(f, False)
+self.handleCmd('lolwut', check=False, collect_result=False)
+with open(self.out_filename, 'r') as f:
+errors = f.read()
+self.assertTrue(re.search(r'error:.*lolwut', errors))
+
 @add_test_categories(['pyapi'])
 def test_sbfile_type_errors(self):
 sbf = lldb.SBFile()
@@ -269,6 +281,17 @@
 self.assertTrue(re.search(r'Show a list of all debugger commands', f.read()))
 
 
+@add_test_categories(['pyapi'])
+def test_help(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+status = debugger.SetOutputFile(lldb.SBFile(f))
+self.assertTrue(status.Success())
+self.handleCmd("help help", check=False, collect_result=False)
+with open(self.out_filename, 'r') as f:
+self.assertIn('Show a list of all debugger commands', f.read())
+
+
 @add_test_categories(['pyapi'])
 def test_immediate(self):
 with open(self.out_filename, 'w') as f:
@@ -278,15 +301,44 @@
 interpreter.HandleCommand("help help", ret)
 # make sure the file wasn't closed early.
 f.write("\nQUUX\n")
-
 ret = None # call destructor and flush streams
-
 with open(self.out_filename, 'r') as f:
 output = f.read()
 self.assertTrue(re.search(r'Show a list of all debugger commands', output))
 self.assertTrue(re.search(r'QUUX', output))
 
 
+@add_test_categories(['pyapi'])
+@expectedFailure # FIXME need SBFile interfaces on SBCommandReturnObject
+def test_immediate_string(self):
+f = io.StringIO()
+ret = lldb.SBCommandReturnObject()
+ret.SetImmediateOutputFile(f)
+interpreter = self.debugger.GetCommandInterpreter()
+interpreter.HandleCommand("help help", ret)
+# make sure the file wasn't closed early.
+f.write("\nQUUX\n")
+ret = None # call destructor and flush streams
+output = f.getvalue()
+

[Lldb-commits] [PATCH] D68674: Remove the is_mangled flag from Mangled and Symbol

2019-10-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Neat!


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

https://reviews.llvm.org/D68674



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


[Lldb-commits] [PATCH] D68679: [CMake] Add a cache for iOS.

2019-10-08 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: friss, jasonmolenda.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.

rdar://problem/55916729


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68679

Files:
  lldb/cmake/caches/Apple-lldb-iOS.cmake


Index: lldb/cmake/caches/Apple-lldb-iOS.cmake
===
--- /dev/null
+++ lldb/cmake/caches/Apple-lldb-iOS.cmake
@@ -0,0 +1,17 @@
+include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake)
+
+set(LLDB_BUILD_FRAMEWORK ON CACHE BOOL "")
+set(LLDB_NO_INSTALL_DEFAULT_RPATH ON CACHE BOOL "")
+set(CMAKE_OSX_DEPLOYMENT_TARGET 10.0 CACHE STRING "")
+
+# Install location for LLDB.framework on the enduser machine.
+# DESTDIR will be an extra prefix.
+set(LLDB_FRAMEWORK_INSTALL_DIR /System/Library/PrivateFrameworks CACHE STRING 
"")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  lldb
+  liblldb
+  lldb-argdumper
+  darwin-debug
+  debugserver
+  CACHE STRING "")


Index: lldb/cmake/caches/Apple-lldb-iOS.cmake
===
--- /dev/null
+++ lldb/cmake/caches/Apple-lldb-iOS.cmake
@@ -0,0 +1,17 @@
+include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake)
+
+set(LLDB_BUILD_FRAMEWORK ON CACHE BOOL "")
+set(LLDB_NO_INSTALL_DEFAULT_RPATH ON CACHE BOOL "")
+set(CMAKE_OSX_DEPLOYMENT_TARGET 10.0 CACHE STRING "")
+
+# Install location for LLDB.framework on the enduser machine.
+# DESTDIR will be an extra prefix.
+set(LLDB_FRAMEWORK_INSTALL_DIR /System/Library/PrivateFrameworks CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  lldb
+  liblldb
+  lldb-argdumper
+  darwin-debug
+  debugserver
+  CACHE STRING "")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68678: WIP: Speed up accelerator table lookups

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: JDevlieghere, friss, jasonmolenda, jingham.
Herald added a subscriber: arphaman.

When debugging a large program like clang and doing "frame variable *this", the 
ValueObject pretty printer is doing hundreds of scoped FindTypes lookups. The 
ones that take longest are the ones where the DWARFDeclContext ends in 
something like `::Iterator` which produces many false positives that need to be 
filtered out *after* extracting the DIEs. This patch demonstrates a way to 
filter out false positives at the accerator table lookup step.

With this patch `lldb clang-10 -o "b EmitFunctionStart" -o r -o "f 2" -o "fr v 
*this" -b -- ...`  goes from 5.6s -> 4.83s or wall clock 6.979s -> 5.99s.
There are probably other good heuristics, too, and I should also implement this 
for DWARF 5 debug_names.


https://reviews.llvm.org/D68678

Files:
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,17 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
+  // When searching for "std::vector::const_iterator", reject any
+  // files without "vector" early, since there will be many other
+  // "const_iterators".
+  if (context.GetSize() > 1 && context[1].tag == DW_TAG_class_type) {
+DIEArray class_matches;
+m_apple_types_up->FindByName(context[1].name, class_matches);
+if (class_matches.empty())
+  return;
+  }
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {


Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,17 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
+  // When searching for "std::vector::const_iterator", reject any
+  // files without "vector" early, since there will be many other
+  // "const_iterators".
+  if (context.GetSize() > 1 && context[1].tag == DW_TAG_class_type) {
+DIEArray class_matches;
+m_apple_types_up->FindByName(context[1].name, class_matches);
+if (class_matches.empty())
+  return;
+  }
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68677: protect libedit and LLDB gui from receiving null FILE* streams

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added a project: LLDB.
lawrence_danna added a parent revision: D68188: allow arbitrary python streams 
to be converted to SBFile.

We now have valid files that will return NULL from GetStream().
libedit and the LLDB gui are the only places left that need FILE*
streams.  Both are doing curses-like user interaction that only
make sense with a real terminal anyway, so there is no need to convert
them off of their use of FILE*.   But we should check for null streams
before enabling these features.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68677

Files:
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Core/IOHandler.cpp


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -266,7 +266,8 @@
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
 m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
Index: lldb/source/Commands/CommandObjectGUI.cpp
===
--- lldb/source/Commands/CommandObjectGUI.cpp
+++ lldb/source/Commands/CommandObjectGUI.cpp
@@ -29,7 +29,9 @@
 Debugger  = GetDebugger();
 
 File  = debugger.GetInputFile();
-if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+File  = debugger.GetOutputFile();
+if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
 debugger.PushIOHandler(io_handler_sp);


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -266,7 +266,8 @@
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
 m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
Index: lldb/source/Commands/CommandObjectGUI.cpp
===
--- lldb/source/Commands/CommandObjectGUI.cpp
+++ lldb/source/Commands/CommandObjectGUI.cpp
@@ -29,7 +29,9 @@
 Debugger  = GetDebugger();
 
 File  = debugger.GetInputFile();
-if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+File  = debugger.GetOutputFile();
+if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
 debugger.PushIOHandler(io_handler_sp);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68674: Remove the is_mangled flag from Mangled and Symbol

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

LGTM


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

https://reviews.llvm.org/D68674



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


[Lldb-commits] [PATCH] D68674: Remove the is_mangled flag from Mangled and Symbol

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 223965.
aprantl added a comment.

Updated unit test.


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

https://reviews.llvm.org/D68674

Files:
  lldb/include/lldb/Core/Mangled.h
  lldb/include/lldb/Symbol/Function.h
  lldb/include/lldb/Symbol/Symbol.h
  lldb/source/API/SBType.cpp
  lldb/source/Core/Mangled.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/unittests/Core/MangledTest.cpp

Index: lldb/unittests/Core/MangledTest.cpp
===
--- lldb/unittests/Core/MangledTest.cpp
+++ lldb/unittests/Core/MangledTest.cpp
@@ -29,9 +29,7 @@
 
 TEST(MangledTest, ResultForValidName) {
   ConstString MangledName("_ZN1a1b1cIiiiEEvm");
-  bool IsMangled = true;
-
-  Mangled TheMangled(MangledName, IsMangled);
+  Mangled TheMangled(MangledName);
   ConstString TheDemangled =
   TheMangled.GetDemangledName(eLanguageTypeC_plus_plus);
 
@@ -41,9 +39,7 @@
 
 TEST(MangledTest, EmptyForInvalidName) {
   ConstString MangledName("_ZN1a1b1cmxktpEEvm");
-  bool IsMangled = true;
-
-  Mangled TheMangled(MangledName, IsMangled);
+  Mangled TheMangled(MangledName);
   ConstString TheDemangled =
   TheMangled.GetDemangledName(eLanguageTypeC_plus_plus);
 
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -31,9 +31,8 @@
   m_is_weak(false), m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(),
   m_flags() {}
 
-Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled,
-   SymbolType type, bool external, bool is_debug,
-   bool is_trampoline, bool is_artificial,
+Symbol::Symbol(uint32_t symID, llvm::StringRef name, SymbolType type, bool external,
+   bool is_debug, bool is_trampoline, bool is_artificial,
const lldb::SectionSP _sp, addr_t offset, addr_t size,
bool size_is_valid, bool contains_linker_annotations,
uint32_t flags)
@@ -42,9 +41,9 @@
   m_is_debug(is_debug), m_is_external(external), m_size_is_sibling(false),
   m_size_is_synthesized(false), m_size_is_valid(size_is_valid || size > 0),
   m_demangled_is_synthesized(false),
-  m_contains_linker_annotations(contains_linker_annotations), 
+  m_contains_linker_annotations(contains_linker_annotations),
   m_is_weak(false), m_type(type),
-  m_mangled(ConstString(name), name_is_mangled),
+  m_mangled(name),
   m_addr_range(section_sp, offset, size), m_flags(flags) {}
 
 Symbol::Symbol(uint32_t symID, const Mangled , SymbolType type,
Index: lldb/source/Symbol/Function.cpp
===
--- lldb/source/Symbol/Function.cpp
+++ lldb/source/Symbol/Function.cpp
@@ -59,10 +59,11 @@
   return m_name.MemorySize() + m_declaration.MemorySize();
 }
 
-InlineFunctionInfo::InlineFunctionInfo(const char *name, const char *mangled,
+InlineFunctionInfo::InlineFunctionInfo(const char *name,
+   llvm::StringRef mangled,
const Declaration *decl_ptr,
const Declaration *call_decl_ptr)
-: FunctionInfo(name, decl_ptr), m_mangled(ConstString(mangled), true),
+: FunctionInfo(name, decl_ptr), m_mangled(mangled),
   m_call_decl(call_decl_ptr) {}
 
 InlineFunctionInfo::InlineFunctionInfo(ConstString name,
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1422,7 +1422,6 @@
 symtab.AddSymbol(
 Symbol(pub_symbol->getSymIndexId(),   // symID
pub_symbol->getName().c_str(), // name
-   true,  // name_is_mangled
pub_symbol->isCode() ? eSymbolTypeCode : eSymbolTypeData, // type
true,  // external
false, // is_debug
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -340,8 +340,8 @@
   return;
 }
 symbols.try_emplace(
-address, /*symID*/ 0, Mangled(name, /*is_mangled*/ false),
-eSymbolTypeCode, /*is_global*/ true, /*is_debug*/ false,
+address, /*symID*/ 0, 

[Lldb-commits] [PATCH] D68674: Remove the is_mangled flag from Mangled and Symbol

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added subscribers: MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.

Testing whether a name is mangled or not is extremely cheap and can be done by 
looking at the first two characters. `Mangled` knows how to do it. On the flip 
side, many call sites that currently pass in an `is_mangled` determination do 
not know how to correctly do it (for example, they leave out Swift mangling 
prefixes).

This patch removes this entry point and just forced Mangled to determine the 
mangledness of a string itself.


https://reviews.llvm.org/D68674

Files:
  lldb/include/lldb/Core/Mangled.h
  lldb/include/lldb/Symbol/Function.h
  lldb/include/lldb/Symbol/Symbol.h
  lldb/source/API/SBType.cpp
  lldb/source/Core/Mangled.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Symbol/Symbol.cpp

Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -31,9 +31,8 @@
   m_is_weak(false), m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(),
   m_flags() {}
 
-Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled,
-   SymbolType type, bool external, bool is_debug,
-   bool is_trampoline, bool is_artificial,
+Symbol::Symbol(uint32_t symID, llvm::StringRef name, SymbolType type, bool external,
+   bool is_debug, bool is_trampoline, bool is_artificial,
const lldb::SectionSP _sp, addr_t offset, addr_t size,
bool size_is_valid, bool contains_linker_annotations,
uint32_t flags)
@@ -42,9 +41,9 @@
   m_is_debug(is_debug), m_is_external(external), m_size_is_sibling(false),
   m_size_is_synthesized(false), m_size_is_valid(size_is_valid || size > 0),
   m_demangled_is_synthesized(false),
-  m_contains_linker_annotations(contains_linker_annotations), 
+  m_contains_linker_annotations(contains_linker_annotations),
   m_is_weak(false), m_type(type),
-  m_mangled(ConstString(name), name_is_mangled),
+  m_mangled(name),
   m_addr_range(section_sp, offset, size), m_flags(flags) {}
 
 Symbol::Symbol(uint32_t symID, const Mangled , SymbolType type,
Index: lldb/source/Symbol/Function.cpp
===
--- lldb/source/Symbol/Function.cpp
+++ lldb/source/Symbol/Function.cpp
@@ -59,10 +59,11 @@
   return m_name.MemorySize() + m_declaration.MemorySize();
 }
 
-InlineFunctionInfo::InlineFunctionInfo(const char *name, const char *mangled,
+InlineFunctionInfo::InlineFunctionInfo(const char *name,
+   llvm::StringRef mangled,
const Declaration *decl_ptr,
const Declaration *call_decl_ptr)
-: FunctionInfo(name, decl_ptr), m_mangled(ConstString(mangled), true),
+: FunctionInfo(name, decl_ptr), m_mangled(mangled),
   m_call_decl(call_decl_ptr) {}
 
 InlineFunctionInfo::InlineFunctionInfo(ConstString name,
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1422,7 +1422,6 @@
 symtab.AddSymbol(
 Symbol(pub_symbol->getSymIndexId(),   // symID
pub_symbol->getName().c_str(), // name
-   true,  // name_is_mangled
pub_symbol->isCode() ? eSymbolTypeCode : eSymbolTypeData, // type
true,  // external
false, // is_debug
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -340,8 +340,8 @@
   return;
 }
 symbols.try_emplace(
-address, /*symID*/ 0, Mangled(name, /*is_mangled*/ false),
-eSymbolTypeCode, /*is_global*/ true, /*is_debug*/ false,
+address, /*symID*/ 0, Mangled(name), eSymbolTypeCode,
+/*is_global*/ true, /*is_debug*/ false,
 /*is_trampoline*/ false, /*is_artificial*/ false,
 AddressRange(section_sp, address - section_sp->GetFileAddress(),
  size.getValueOr(0)),
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- 

[Lldb-commits] [PATCH] D68671: Add the ability to pass extra args to a Python breakpoint command function

2019-10-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/include/lldb/API/SBBreakpointLocation.h:59
+  void SetScriptCallbackFunction(const char *callback_function_name,
+ SBStructuredData _args);
+

Could this be a `const &`



Comment at: lldb/include/lldb/API/SBBreakpointName.h:89
+  void SetScriptCallbackFunction(const char *callback_function_name,
+ SBStructuredData _args);
+

Could this be a `const &`


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68671



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


[Lldb-commits] [PATCH] D68533: Explicitly set entry point arch when it's thumb [Second Try]

2019-10-08 Thread António Afonso via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad6690afa3e6: Explicitly set entry point arch when its 
thumb [Second Try] (authored by aadsm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68533

Files:
  lldb/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml
  lldb/lit/SymbolFile/Breakpad/symtab.test
  lldb/lit/SymbolFile/dissassemble-entry-point.s
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Index: lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
===
--- lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -172,3 +172,129 @@
   Uuid.SetFromStringRef("1b8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9", 20);
   EXPECT_EQ(Spec.GetUUID(), Uuid);
 }
+
+TEST_F(ObjectFileELFTest, GetSymtab_NoSymEntryPointArmThumbAddressClass) {
+  /*
+  // nosym-entrypoint-arm-thumb.s
+  .thumb_func
+  _start:
+  mov r0, #42
+  mov r7, #1
+  svc #0
+  // arm-linux-androideabi-as nosym-entrypoint-arm-thumb.s
+  //   -o nosym-entrypoint-arm-thumb.o
+  // arm-linux-androideabi-ld nosym-entrypoint-arm-thumb.o
+  //   -o nosym-entrypoint-arm-thumb -e 0x8075 -s
+  */
+  auto ExpectedFile = TestFile::fromYaml(R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_ARM
+  Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
+  Entry:   0x8075
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x8074
+AddressAlign:0x0002
+Content: 2A20012700DF
+  - Name:.data
+Type:SHT_PROGBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x9000
+AddressAlign:0x0001
+Content: ''
+  - Name:.bss
+Type:SHT_NOBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x9000
+AddressAlign:0x0001
+  - Name:.note.gnu.gold-version
+Type:SHT_NOTE
+AddressAlign:0x0004
+Content: 040009000400474E5500676F6C6420312E313100
+  - Name:.ARM.attributes
+Type:SHT_ARM_ATTRIBUTES
+AddressAlign:0x0001
+Content: '41130061656162690001090006020901'
+...
+)");
+  ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
+
+  ModuleSpec spec{FileSpec(ExpectedFile->name())};
+  spec.GetSymbolFileSpec().SetFile(ExpectedFile->name(),
+   FileSpec::Style::native);
+  auto module_sp = std::make_shared(spec);
+
+  auto entry_point_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
+  ASSERT_TRUE(entry_point_addr.GetOffset() & 1);
+  // Decrease the offsite by 1 to make it into a breakable address since this
+  // is Thumb.
+  entry_point_addr.SetOffset(entry_point_addr.GetOffset() - 1);
+  ASSERT_EQ(entry_point_addr.GetAddressClass(),
+AddressClass::eCodeAlternateISA);
+}
+
+TEST_F(ObjectFileELFTest, GetSymtab_NoSymEntryPointArmAddressClass) {
+  /*
+  // nosym-entrypoint-arm.s
+  _start:
+  movs r0, #42
+  movs r7, #1
+  svc #0
+  // arm-linux-androideabi-as nosym-entrypoint-arm.s
+  //   -o nosym-entrypoint-arm.o
+  // arm-linux-androideabi-ld nosym-entrypoint-arm.o
+  //   -o nosym-entrypoint-arm -e 0x8074 -s
+  */
+  auto ExpectedFile = TestFile::fromYaml(R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_ARM
+  Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
+  Entry:   0x8074
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x8074
+AddressAlign:0x0004
+Content: 2A00A0E30170A0E300EF
+  - Name:.data
+Type:SHT_PROGBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x9000
+AddressAlign:0x0001
+Content: ''
+  - Name:.bss
+Type:SHT_NOBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x9000
+AddressAlign:0x0001
+  - Name:.note.gnu.gold-version
+Type:SHT_NOTE
+AddressAlign:0x0004
+Content: 040009000400474E5500676F6C6420312E313100
+  - Name:.ARM.attributes
+Type:SHT_ARM_ATTRIBUTES
+AddressAlign:0x0001
+  

[Lldb-commits] [lldb] r374132 - Explicitly set entry point arch when it's thumb [Second Try]

2019-10-08 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Tue Oct  8 16:44:49 2019
New Revision: 374132

URL: http://llvm.org/viewvc/llvm-project?rev=374132=rev
Log:
Explicitly set entry point arch when it's thumb [Second Try]

Summary:
This is a redo of D68069 because I reverted it due to some concerns that were 
now addressed along with the new comments that @labath added.

I found a case where the main android binary (app_process32) had thumb code at 
its entry point but no entry in the symbol table indicating this. This made 
lldb set a 4 byte breakpoint at that address (we default to arm code) instead 
of a 2 byte one (like we should for thumb).
The big deal with this is that the expression evaluator uses the entry point as 
a way to know when a JITed expression has finished executing by putting a 
breakpoint there. Because of this, evaluating expressions on certain android 
devices (Google Pixel something) made the process crash.
This was fixed by checking this specific situation when we parse the symbol 
table and add an artificial symbol for this 2 byte range and indicating that 
it's arm thumb.

I created 2 unit tests for this, one to check that now we know that the entry 
point is arm thumb, and the other to make sure we didn't change the behaviour 
for arm code.

I also run the following on the command line with the `app_process32` where I 
found the issue:
**Before:**
```
(lldb) dis -s 0x1640 -e 0x1644
app_process32[0x1640]: .long  0xf0004668; unknown opcode
```
**After:**
```
(lldb) dis -s 0x1640 -e 0x1644
app_process32`:
app_process32[0x1640] <+0>: movr0, sp
app_process32[0x1642]:  andeq  r0, r0, r0
```

Reviewers: clayborg, labath, wallace, espindola

Reviewed By: labath

Subscribers: labath, lldb-commits, MaskRay, kristof.beyls, arichardson, emaste, 
srhines

Tags: #lldb

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

Added:
lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s
Modified:
lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml
lldb/trunk/lit/SymbolFile/Breakpad/symtab.test
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Modified: lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml?rev=374132=374131=374132=diff
==
--- lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml (original)
+++ lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml Tue Oct  8 
16:44:49 2019
@@ -6,7 +6,7 @@ FileHeader:
   Data:ELFDATA2LSB
   Type:ET_EXEC
   Machine: EM_X86_64
-  Entry:   0x004000D0
+  Entry:   0x0040
 Sections:
   - Name:.text1
 Type:SHT_PROGBITS

Modified: lldb/trunk/lit/SymbolFile/Breakpad/symtab.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/symtab.test?rev=374132=374131=374132=diff
==
--- lldb/trunk/lit/SymbolFile/Breakpad/symtab.test (original)
+++ lldb/trunk/lit/SymbolFile/Breakpad/symtab.test Tue Oct  8 16:44:49 2019
@@ -3,12 +3,13 @@
 # RUN:   -s %s | FileCheck %s
 
 # CHECK-LABEL: (lldb) image dump symtab symtab.out
-# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 4:
+# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address
   Size   Flags  Name
-# CHECK: [0]  0   X Code0x004000c0 
   0x0010 0x f2
-# CHECK: [1]  0   X Code0x004000d0 
   0x0022 0x _start
-# CHECK: [2]  0   X Code0x004000a0 
   0x000d 0x func_only
-# CHECK: [3]  0   X Code0x004000b0 
   0x000c 0x f1_func
+# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol1$$symtab.out
+# CHECK: [1]  0   X Code0x004000c0 
   0x0010 0x f2
+# CHECK: [2]  0   X Code0x004000d0 
   0x0022 0x _start
+# CHECK: [3]  0   X Code0x004000a0 
   0x000d 0x func_only
+# CHECK: [4]  0   X Code0x004000b0 
   0x000c 0x f1_func
 
 # CHECK-LABEL: (lldb) image lookup -a 0x4000b0 -v
 # CHECK: Address: symtab.out[0x004000b0] (symtab.out.PT_LOAD[0]..text2 
+ 0)

Added: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s
URL: 

[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223958.
lawrence_danna added a comment.

factor out string splitting stuff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/source/Core/IOHandler.cpp

Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -305,94 +305,145 @@
   m_delegate.IOHandlerDeactivated(*this);
 }
 
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;
+
+// Split out a line from the buffer, if there is a full one to get.
+static Optional SplitLine(std::string _buffer) {
+  size_t pos = line_buffer.find('\n');
+  if (pos == std::string::npos)
+return None;
+  size_t end = pos + 1;
+  while (end > 0 &&
+ (line_buffer[end - 1] == '\n' || line_buffer[end - 1] == '\r'))
+end--;
+  std::string line = line_buffer.substr(0, end);
+  line_buffer = line_buffer.substr(pos + 1);
+  return line;
+}
+
+// Append newchars to the buffer and split out a line.
+static Optional AppendAndSplitLine(std::string _buffer,
+StringRef newchars) {
+  size_t pos = newchars.find('\n');
+  if (pos == StringRef::npos) {
+line_buffer.append(newchars);
+return None;
+  }
+  size_t end = pos + 1;
+  while (end > 0 && (newchars[end - 1] == '\n' || newchars[end - 1] == '\r'))
+end--;
+  std::string line = std::move(line_buffer);
+  line.append(newchars.substr(0, end));
+  line_buffer = newchars.substr(pos + 1);
+  return line;
+}
+
+// If the final line of the file ends without a end-of-line, return
+// it as a line anyway.
+static Optional SplitLineEOF(std::string _buffer) {
+  if (line_buffer.empty())
+return None;
+  if (std::all_of(line_buffer.begin(), line_buffer.end(), isspace))
+return None;
+  std::string line = std::move(line_buffer);
+  line_buffer.clear();
+  return line;
+}
+
 bool IOHandlerEditline::GetLine(std::string , bool ) {
 #ifndef LLDB_DISABLE_LIBEDIT
   if (m_editline_up) {
 bool b = m_editline_up->GetLine(line, interrupted);
-if (m_data_recorder)
+if (b && m_data_recorder)
   m_data_recorder->Record(line, true);
 return b;
-  } else {
+  }
 #endif
-line.clear();
 
-FILE *in = GetInputFILE();
-if (in) {
-  if (GetIsInteractive()) {
-const char *prompt = nullptr;
+  line.clear();
 
-if (m_multi_line && m_curr_line_idx > 0)
-  prompt = GetContinuationPrompt();
+  if (GetIsInteractive()) {
+const char *prompt = nullptr;
 
-if (prompt == nullptr)
-  prompt = GetPrompt();
+if (m_multi_line && m_curr_line_idx > 0)
+  prompt = GetContinuationPrompt();
 
-if (prompt && prompt[0]) {
-  if (m_output_sp) {
-m_output_sp->Printf("%s", prompt);
-m_output_sp->Flush();
-  }
-}
+if (prompt == nullptr)
+  prompt = GetPrompt();
+
+if (prompt && prompt[0]) {
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
+  }
+}
+  }
+
+  Optional got_line = SplitLine(m_line_buffer);
+
+  if (!got_line && !m_input_sp) {
+// No more input file, we are done...
+SetIsDone(true);
+return false;
+  }
+
+  FILE *in = GetInputFILE();
+  char buffer[256];
+
+  if (!got_line && !in && m_input_sp) {
+// there is no FILE*, fall back on just reading bytes from the stream.
+while (!got_line) {
+  size_t bytes_read = sizeof(buffer);
+  Status error = m_input_sp->Read((void *)buffer, bytes_read);
+  if (error.Success() && !bytes_read) {
+got_line = SplitLineEOF(m_line_buffer);
+break;
   }
-  char buffer[256];
-  bool done = false;
-  bool got_line = false;
-  m_editing = true;
-  while (!done) {
+  if (error.Fail())
+break;
+  got_line =
+  AppendAndSplitLine(m_line_buffer, StringRef(buffer, bytes_read));
+}
+  }
+
+  if (!got_line && in) {
+m_editing = true;
+while (!got_line) {
+  char *r = fgets(buffer, sizeof(buffer), in);
 #ifdef _WIN32
-// ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
-// according to the docs on MSDN. However, this has evidently been a
-// known bug since Windows 8. Therefore, we can't detect if a signal
-// interrupted in the fgets. So pressing ctrl-c causes the repl to end
-// and the process to exit. A temporary workaround is just to attempt to
-// fgets twice until this bug is fixed.
-if (fgets(buffer, sizeof(buffer), in) == nullptr &&
-fgets(buffer, sizeof(buffer), in) == nullptr) {
-  // this is the equivalent of EINTR for Windows
-  if (GetLastError() == 

[Lldb-commits] [PATCH] D68671: Add the ability to pass extra args to a Python breakpoint command function

2019-10-08 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: JDevlieghere, clayborg.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

For example, it is pretty easy to write a breakpoint command that implements 
"stop when my caller is Foo", and it is pretty easy to write a breakpoint 
command that implements "stop when my caller is Bar".  But there's no way to 
write a generic "stop when my caller is..." function, and then specify the 
caller when you add the command.  With this patch, you can pass this data in a 
SBStructuredData dictionary.  That will get stored in the PythonCommandBaton 
for the breakpoint, and passed to the implementation function (if it has the 
right signature) when the breakpoint is hit.  Then in lldb, you can say:

(lldb) break com add -F caller_is -k caller_name -v Foo

More generally this will allow us to write reusable Python breakpoint commands.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68671

Files:
  lldb/include/lldb/API/SBBreakpoint.h
  lldb/include/lldb/API/SBBreakpointLocation.h
  lldb/include/lldb/API/SBBreakpointName.h
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py
  lldb/scripts/Python/python-wrapper.swig
  lldb/scripts/interface/SBBreakpoint.i
  lldb/scripts/interface/SBBreakpointLocation.i
  lldb/scripts/interface/SBBreakpointName.i
  lldb/source/API/SBBreakpoint.cpp
  lldb/source/API/SBBreakpointLocation.cpp
  lldb/source/API/SBBreakpointName.cpp
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Commands/CommandObjectBreakpointCommand.cpp
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -62,7 +62,8 @@
 extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
 const char *python_function_name, const char *session_dictionary_name,
 const lldb::StackFrameSP _frame,
-const lldb::BreakpointLocationSP _bp_loc) {
+const lldb::BreakpointLocationSP _bp_loc,
+StructuredDataImpl *args_impl) {
   return false;
 }
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -179,8 +179,10 @@
   Status GenerateFunction(const char *signature,
   const StringList ) override;
 
-  Status GenerateBreakpointCommandCallbackData(StringList ,
-   std::string ) override;
+  Status GenerateBreakpointCommandCallbackData(
+  StringList ,
+  std::string ,
+  StructuredData::ObjectSP extra_args_sp) override;
 
   bool GenerateWatchpointCommandCallbackData(StringList ,
  std::string ) override;
@@ -244,14 +246,21 @@
   Status SetBreakpointCommandCallback(BreakpointOptions *bp_options,
   const char *callback_body) override;
 
-  void SetBreakpointCommandCallbackFunction(BreakpointOptions *bp_options,
-const char *function_name) override;
+  void SetBreakpointCommandCallbackFunction(
+  BreakpointOptions *bp_options,
+  const char *function_name,
+  StructuredData::ObjectSP extra_args_sp) override;
 
   /// This one is for deserialization:
   Status SetBreakpointCommandCallback(
   BreakpointOptions *bp_options,
   std::unique_ptr _up) override;
 
+  Status SetBreakpointCommandCallback(
+  BreakpointOptions *bp_options, 
+   const char *command_body_text,
+   StructuredData::ObjectSP extra_args_sp);
+
   /// Set a one-liner as the callback for the watchpoint.
   void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
 const char *oneliner) override;
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- 

[Lldb-commits] [PATCH] D67994: Modify lldb-test to print out ASTs from symbol file

2019-10-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

In D67994#1697981 , @labath wrote:

> In D67994#1695172 , @shafik wrote:
>
> > In D67994#1692645 , @labath wrote:
> >
> > > Maybe this is my fault since I'm the one who introduced the first bunch 
> > > of arguments here IIRC, but anyway, I have a feeling all of these dumping 
> > > options are getting out of hand. Looking at the argument list, you'd 
> > > expect that -dump-ast, and -dump-clang-ast do something completely 
> > > different, but they actually print the exact same AST, only one allows 
> > > you to print a subset of it, while the other one doesn't.
> > >
> > > Given that the ast dumping is currently incompatible with all/most of the 
> > > other dumping options anyway, maybe we should turn over a clean slate, 
> > > and implement a new subcommand specifically dedicated to dumping clang 
> > > ast (as opposed to the internal lldb representations of 
> > > types/functions/..., which is what the "symbols" subcommand started out 
> > > as, and which is what most of its options are dedicated to).
> > >
> > > OR, and this would-be super cool, if it was actually possible, we could 
> > > try to make ast-dumping compatible with the existing searching options.  
> > > Currently, if you type `lldb-test symbols -find=type -name=foo` it will 
> > > search for types named "foo", and print some summary of the lldb object 
> > > representing that type. What if we made it so that adding `-dump-ast` to 
> > > that command caused the tool to dump the *AST* of the types it has found 
> > > (e.g., in addition to the previous summary)? I think that would make the 
> > > behavior of the tool most natural to a new user, but I am not sure 
> > > whether that would actually fit in with your goals here...
> >
> >
> > The output is actually quite different for example given:
> >
> >   struct A {
> > struct {
> > int x;
> > };
> >   } a;
> >
> >
> > the output of `lldb-test symbols -dump-ast  anon.o` is:
> >
> >   Module: anon.o
> >   struct A;
> >
> >
> > while the output of `lldb-test symbols -dump-clang-ast  anon.o` is:
> >
> >   Module: anon.o
> >   A
> >   CXXRecordDecl 0x7ff3698262c8 <>  struct A 
> > definition
> >   |-DefinitionData pass_in_registers aggregate standard_layout 
> > trivially_copyable pod trivial literal
> >   ...
> >
> >
> > Given they are both working with the Symbol File I believe they both belong 
> > under  the `symbol` command. I feel like `-dump-ast` is a little misleading 
> > but `-dump-clang-ast` feels good.
>
>
> You're right about. I'm sorry, I should have checked what -dump-ast does. It 
> definitely is confusing that it does something completely different than the 
> "dump ast" lldb command.
>
> But what about the second part of my comment? I think it would still be nice 
> if the `lldb-test symbols` options could be somehow factored into two groups:
>
> - a group which selects *what* to dump: this would be `-find`, `-name`, etc.
> - a group which selects *how* to dump it: -dump-clang-ast, -dump-ast :/, the 
> default mode
>
>   would it be somehow possible to hook in this logic into the `findTypes` 
> function in lldb-test, so that instead of calling TypeMap::Dump, it does 
> something else if `-dump-clang-ast` flag is present (this "else" resuling in 
> the printing of clang ast)?


I sympathize with the sentiment that it would be nice to collapse some of the 
arguments. I spent some time trying to see how to combine these features nicely 
and I don't think it will end up being any cleaner.

Folding in the `-dump-ast` and `-dump-clang-ast` into `-find` only seems to 
make sense with `-find=type` or `-find=none` so this feels like shoe horning by 
lumping it with the `-find` option. Since I now need to add error handling for 
the blocks, variables and namespaces

If you look at the switch for `Find` it already has a mess of conflicting 
options :-( for example `-find=block` is the only one that use `-line`.

We won’t be saving much in the way of code just shifting where the if/else will 
be. Each functionality is really providing different information and I can see 
how each one is useful, so I don’t want to remove any of them.

I do think the `-dump-ast`  could use a better name maybe `-print-decl` because 
it end up using `DeclPrinter` while `-dump-clang-ast` end up using `ASTDumper`.

This utility can be probably be refactored to be cleaner but that is a bigger 
change and outside the scope of being able to have the ability to verify fixes 
for how we generate clang ASTs from DWARF which we have no way of doing and I 
need now to be able to verify a fix I have now.


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

https://reviews.llvm.org/D67994



___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I had to revert this. Apparently for very small / gapless programs, clang emits 
single-value DW_AT_low_pc/high_pc in the compile unit, and dsymutil does not 
rewrite that into DW_AT_ranges. Would be a nice speedup though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68655



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


[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-08 Thread Gwen Mittertreiner via Phabricator via lldb-commits
gmittert added a comment.

Thanks! Can someone commit this for me?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68614



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


[Lldb-commits] [PATCH] D68613: [CMake] Fix building without python on Windows

2019-10-08 Thread Alex Langford via Phabricator via lldb-commits
xiaobai closed this revision.
xiaobai added a comment.

rL374100 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68613



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


[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-08 Thread Alex Langford via Phabricator via lldb-commits
xiaobai accepted this revision.
xiaobai added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68614



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


[Lldb-commits] [lldb] r374121 - Revert Trust the arange accelerator tables in dSYMs

2019-10-08 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Oct  8 14:34:22 2019
New Revision: 374121

URL: http://llvm.org/viewvc/llvm-project?rev=374121=rev
Log:
Revert Trust the arange accelerator tables in dSYMs

This reverts r374117 (git commit 6399db2f6fd64fa250093368be40eb5ae3af513b)
while inspecting bot breakage.

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=374121=374120=374121=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Tue Oct  8 
14:34:22 2019
@@ -54,19 +54,13 @@ llvm::Expected DWAR
 
   // Manually build arange data for everything that wasn't in the
   // .debug_aranges table.
-  //
-  // This step is skipped for dSYMs and other debug-info-only
-  // objects, which are always trusted to have a complete table.
-  auto *obj = m_dwarf.GetObjectFile();
-  if (!obj || obj->GetType() != ObjectFile::eTypeDebugInfo) {
-const size_t num_units = GetNumUnits();
-for (size_t idx = 0; idx < num_units; ++idx) {
-  DWARFUnit *cu = GetUnitAtIndex(idx);
+  const size_t num_units = GetNumUnits();
+  for (size_t idx = 0; idx < num_units; ++idx) {
+DWARFUnit *cu = GetUnitAtIndex(idx);
 
-  dw_offset_t offset = cu->GetOffset();
-  if (cus_with_data.find(offset) == cus_with_data.end())
-cu->BuildAddressRangeTable(m_cu_aranges_up.get());
-}
+dw_offset_t offset = cu->GetOffset();
+if (cus_with_data.find(offset) == cus_with_data.end())
+  cu->BuildAddressRangeTable(m_cu_aranges_up.get());
   }
 
   const bool minimize = true;


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


[Lldb-commits] [PATCH] D68134: [LLDB] Use the llvm microsoft demangler instead of the windows dbghelp api

2019-10-08 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.

LGTM after one question.




Comment at: lldb/lit/SymbolFile/PDB/udt-layout.test:1
 REQUIRES: system-windows, lld
 RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp

Is `system-windows` still required after you've removed the dependency on 
dbghelp?


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

https://reviews.llvm.org/D68134



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


[Lldb-commits] [PATCH] D68258: [Windows] Introduce a switch for the `lldb-server` mode on Windows

2019-10-08 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.

Given Pavel's comment, this LGTM.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68258



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


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6399db2f6fd6: Trust the arange accelerator tables in dSYMs 
(authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68655

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -54,13 +54,19 @@
 
   // Manually build arange data for everything that wasn't in the
   // .debug_aranges table.
-  const size_t num_units = GetNumUnits();
-  for (size_t idx = 0; idx < num_units; ++idx) {
-DWARFUnit *cu = GetUnitAtIndex(idx);
-
-dw_offset_t offset = cu->GetOffset();
-if (cus_with_data.find(offset) == cus_with_data.end())
-  cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+  //
+  // This step is skipped for dSYMs and other debug-info-only
+  // objects, which are always trusted to have a complete table.
+  auto *obj = m_dwarf.GetObjectFile();
+  if (!obj || obj->GetType() != ObjectFile::eTypeDebugInfo) {
+const size_t num_units = GetNumUnits();
+for (size_t idx = 0; idx < num_units; ++idx) {
+  DWARFUnit *cu = GetUnitAtIndex(idx);
+
+  dw_offset_t offset = cu->GetOffset();
+  if (cus_with_data.find(offset) == cus_with_data.end())
+cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+}
   }
 
   const bool minimize = true;


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -54,13 +54,19 @@
 
   // Manually build arange data for everything that wasn't in the
   // .debug_aranges table.
-  const size_t num_units = GetNumUnits();
-  for (size_t idx = 0; idx < num_units; ++idx) {
-DWARFUnit *cu = GetUnitAtIndex(idx);
-
-dw_offset_t offset = cu->GetOffset();
-if (cus_with_data.find(offset) == cus_with_data.end())
-  cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+  //
+  // This step is skipped for dSYMs and other debug-info-only
+  // objects, which are always trusted to have a complete table.
+  auto *obj = m_dwarf.GetObjectFile();
+  if (!obj || obj->GetType() != ObjectFile::eTypeDebugInfo) {
+const size_t num_units = GetNumUnits();
+for (size_t idx = 0; idx < num_units; ++idx) {
+  DWARFUnit *cu = GetUnitAtIndex(idx);
+
+  dw_offset_t offset = cu->GetOffset();
+  if (cus_with_data.find(offset) == cus_with_data.end())
+cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+}
   }
 
   const bool minimize = true;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61886: Support member functions construction and lookup in PdbAstBuilder

2019-10-08 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.
Herald added a subscriber: JDevlieghere.

Is this still an active review or has this been abandoned?




Comment at: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp:1047
+function_decl = m_clang.CreateFunctionDeclaration(
   parent, proc_name.str().c_str(), func_ct, storage, false);
+  }

It looks like `CreateFunctionDeclaration` can fail (returning a null pointer).  
Should this bail out if `function_decl` remains null pointer here (rather than 
crashing several lines later, after creating some bad mappings)?  Should we 
assert here to make debugging easier?

Also, nit, check the indentation here.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D61886



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


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D68655#1700314 , @jasonmolenda 
wrote:

> Nice fix.  The real cost of computing the aranges manually is expanding all 
> the line tables and calling GetContiguousFileAddressRanges on them.  I wonder 
> if avoiding the full linetable expansion here is shifting that to a different 
> place for this operation.


No, the total user CPU time reported by Instruments goes from ~7000ms -> 
~3500ms, but the wall clock from ~6s -> ~5s (both ±.5s).


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

https://reviews.llvm.org/D68655



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


[Lldb-commits] [lldb] r374117 - Trust the arange accelerator tables in dSYMs

2019-10-08 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Oct  8 14:14:36 2019
New Revision: 374117

URL: http://llvm.org/viewvc/llvm-project?rev=374117=rev
Log:
Trust the arange accelerator tables in dSYMs

When ingesting aranges from a dSYM it makes sense to always trust the
contents of the accelerator table since it always comes from
dsymutil. According to Instruments, skipping the decoding of all CU
DIEs to get at the DW_AT_ranges attribute removes ~3.5 seconds from
setting a breakpoint by file/line when debugging clang with a
dSYM. Interestingly on the wall clock the speedup is less noticeable,
but still present.

rdar://problem/56057688

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

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=374117=374116=374117=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Tue Oct  8 
14:14:36 2019
@@ -54,13 +54,19 @@ llvm::Expected DWAR
 
   // Manually build arange data for everything that wasn't in the
   // .debug_aranges table.
-  const size_t num_units = GetNumUnits();
-  for (size_t idx = 0; idx < num_units; ++idx) {
-DWARFUnit *cu = GetUnitAtIndex(idx);
+  //
+  // This step is skipped for dSYMs and other debug-info-only
+  // objects, which are always trusted to have a complete table.
+  auto *obj = m_dwarf.GetObjectFile();
+  if (!obj || obj->GetType() != ObjectFile::eTypeDebugInfo) {
+const size_t num_units = GetNumUnits();
+for (size_t idx = 0; idx < num_units; ++idx) {
+  DWARFUnit *cu = GetUnitAtIndex(idx);
 
-dw_offset_t offset = cu->GetOffset();
-if (cus_with_data.find(offset) == cus_with_data.end())
-  cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+  dw_offset_t offset = cu->GetOffset();
+  if (cus_with_data.find(offset) == cus_with_data.end())
+cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+}
   }
 
   const bool minimize = true;


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


[Lldb-commits] [PATCH] D68541: Implement 'up' and 'down' shortcuts in lldb gui

2019-10-08 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D68541#1700398 , @llunak wrote:

> In D68541#1700359 , @clayborg wrote:
>
> > It would be fine to remove the 'd' shortcut for detach and resume if we 
> > need to by moving this functionality up into the menu bar. Right now the 
> > Process menu has "Detach" only, so it might be good to first change the 
> > "Process" menu to have "Detach" or "Detach suspended".  I agree that 
> > accidentally hitting 'd' would be bad.
>
>
> Ok, I can try to do that. And 'k' for "Kill process" should probably move to 
> the menu as well.


Sounds fine to me!

> But another shortcut I'd like to change is 'o' for "Step out", as that one is 
> 'f' for "Finish" in gdb tui, and I'm rather used to that.

I am fine with this as well.

> Unless you'd be willing to accept a patch changing that, can you comment on 
> the idea of making the shortcuts configurable?

Configurability would be nice, happy to accept patches that implement that.

I created "gui" mode many many years ago and hoped people would jump in and 
start making patches, so I am very happy to see this patch and look forward to 
more. It won't take too much work for us to make "gui" mode really useful, just 
a bit of work!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68541



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


[Lldb-commits] [PATCH] D68270: DWARFDebugLoc: Add a function to get the address range of an entry

2019-10-08 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D68270#1700108 , @probinson wrote:

> Do we care whether llvm-dwarfdump's output bears any similarities to the 
> output from GNU readelf or objdump?  There has been a push lately to get the 
> LLVM "binutils" to behave more like GNU's, although AFAIK it hasn't gotten to 
> the DWARF dumping part.


I am not too fond of the readelf output. At least for the .debug_info dumping. 
I like the see indentation. But I do see the appeal of consistent output.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68270



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


[Lldb-commits] [PATCH] D68541: Implement 'up' and 'down' shortcuts in lldb gui

2019-10-08 Thread Luboš Luňák via Phabricator via lldb-commits
llunak added a comment.

In D68541#1700359 , @clayborg wrote:

> It would be fine to remove the 'd' shortcut for detach and resume if we need 
> to by moving this functionality up into the menu bar. Right now the Process 
> menu has "Detach" only, so it might be good to first change the "Process" 
> menu to have "Detach" or "Detach suspended".  I agree that accidentally 
> hitting 'd' would be bad.


Ok, I can try to do that. And 'k' for "Kill process" should probably move to 
the menu as well.

But another shortcut I'd like to change is 'o' for "Step out", as that one is 
'f' for "Finish" in gdb tui, and I'm rather used to that. Unless you'd be 
willing to accept a patch changing that, can you comment on the idea of making 
the shortcuts configurable?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68541



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


[Lldb-commits] [PATCH] D68661: StopInfo/Mach: Delete PPC support

2019-10-08 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
vsk marked an inline comment as done.
Closed by commit rG4805c817c3fa: StopInfo/Mach: Delete PPC support (authored by 
vsk).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68661?vs=223924=223936#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68661

Files:
  lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp

Index: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
===
--- lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -78,21 +78,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 0x101:
-code_desc = "EXC_PPC_VM_PROT_READ";
-break;
-  case 0x102:
-code_desc = "EXC_PPC_BADSPACE";
-break;
-  case 0x103:
-code_desc = "EXC_PPC_UNALIGNED";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -107,30 +92,6 @@
 code_desc = "EXC_I386_INVOP";
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_INVALID_SYSCALL";
-break;
-  case 2:
-code_desc = "EXC_PPC_UNIPL_INST";
-break;
-  case 3:
-code_desc = "EXC_PPC_PRIVINST";
-break;
-  case 4:
-code_desc = "EXC_PPC_PRIVREG";
-break;
-  case 5:
-code_desc = "EXC_PPC_TRACE";
-break;
-  case 6:
-code_desc = "EXC_PPC_PERFMON";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (m_exc_code == 1)
@@ -175,33 +136,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_OVERFLOW";
-break;
-  case 2:
-code_desc = "EXC_PPC_ZERO_DIVIDE";
-break;
-  case 3:
-code_desc = "EXC_PPC_FLT_INEXACT";
-break;
-  case 4:
-code_desc = "EXC_PPC_FLT_ZERO_DIVIDE";
-break;
-  case 5:
-code_desc = "EXC_PPC_FLT_UNDERFLOW";
-break;
-  case 6:
-code_desc = "EXC_PPC_FLT_OVERFLOW";
-break;
-  case 7:
-code_desc = "EXC_PPC_FLT_NOT_A_NUMBER";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -235,15 +169,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_BREAKPOINT";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   switch (m_exc_code) {
@@ -384,30 +309,7 @@
 
   switch (exc_type) {
   case 1: // EXC_BAD_ACCESS
-break;
-
   case 2: // EXC_BAD_INSTRUCTION
-switch (cpu) {
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (exc_code) {
-  case 1: // EXC_PPC_INVALID_SYSCALL
-  case 2: // EXC_PPC_UNIPL_INST
-  case 3: // EXC_PPC_PRIVINST
-  case 4: // EXC_PPC_PRIVREG
-break;
-  case 5: // EXC_PPC_TRACE
-return StopInfo::CreateStopReasonToTrace(thread);
-  case 6: // EXC_PPC_PERFMON
-break;
-  }
-  break;
-
-default:
-  break;
-}
-break;
-
   case 3: // EXC_ARITHMETIC
   case 4: // EXC_EMULATION
 break;
@@ -478,11 +380,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  is_actual_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374114 - StopInfo/Mach: Delete PPC support

2019-10-08 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Tue Oct  8 13:47:44 2019
New Revision: 374114

URL: http://llvm.org/viewvc/llvm-project?rev=374114=rev
Log:
StopInfo/Mach: Delete PPC support

LLDB appears to have at least partial support for PPC, but PPC on Mach
isn't a thing AFAIK.

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

Modified:
lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp

Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=374114=374113=374114=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Tue Oct 
 8 13:47:44 2019
@@ -78,21 +78,6 @@ const char *StopInfoMachException::GetDe
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 0x101:
-code_desc = "EXC_PPC_VM_PROT_READ";
-break;
-  case 0x102:
-code_desc = "EXC_PPC_BADSPACE";
-break;
-  case 0x103:
-code_desc = "EXC_PPC_UNALIGNED";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -107,30 +92,6 @@ const char *StopInfoMachException::GetDe
 code_desc = "EXC_I386_INVOP";
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_INVALID_SYSCALL";
-break;
-  case 2:
-code_desc = "EXC_PPC_UNIPL_INST";
-break;
-  case 3:
-code_desc = "EXC_PPC_PRIVINST";
-break;
-  case 4:
-code_desc = "EXC_PPC_PRIVREG";
-break;
-  case 5:
-code_desc = "EXC_PPC_TRACE";
-break;
-  case 6:
-code_desc = "EXC_PPC_PERFMON";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (m_exc_code == 1)
@@ -175,33 +136,6 @@ const char *StopInfoMachException::GetDe
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_OVERFLOW";
-break;
-  case 2:
-code_desc = "EXC_PPC_ZERO_DIVIDE";
-break;
-  case 3:
-code_desc = "EXC_PPC_FLT_INEXACT";
-break;
-  case 4:
-code_desc = "EXC_PPC_FLT_ZERO_DIVIDE";
-break;
-  case 5:
-code_desc = "EXC_PPC_FLT_UNDERFLOW";
-break;
-  case 6:
-code_desc = "EXC_PPC_FLT_OVERFLOW";
-break;
-  case 7:
-code_desc = "EXC_PPC_FLT_NOT_A_NUMBER";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -235,15 +169,6 @@ const char *StopInfoMachException::GetDe
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_BREAKPOINT";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   switch (m_exc_code) {
@@ -384,30 +309,7 @@ StopInfoSP StopInfoMachException::Create
 
   switch (exc_type) {
   case 1: // EXC_BAD_ACCESS
-break;
-
   case 2: // EXC_BAD_INSTRUCTION
-switch (cpu) {
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (exc_code) {
-  case 1: // EXC_PPC_INVALID_SYSCALL
-  case 2: // EXC_PPC_UNIPL_INST
-  case 3: // EXC_PPC_PRIVINST
-  case 4: // EXC_PPC_PRIVREG
-break;
-  case 5: // EXC_PPC_TRACE
-return StopInfo::CreateStopReasonToTrace(thread);
-  case 6: // EXC_PPC_PERFMON
-break;
-  }
-  break;
-
-default:
-  break;
-}
-break;
-
   case 3: // EXC_ARITHMETIC
   case 4: // EXC_EMULATION
 break;
@@ -478,11 +380,6 @@ StopInfoSP StopInfoMachException::Create
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  is_actual_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (exc_code == 0x102) // EXC_ARM_DA_DEBUG


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


[Lldb-commits] [PATCH] D68549: make ConstString allocate memory in non-tiny chunks

2019-10-08 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

Nice! If we run into any issues we can make this a global debugger setting.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68549



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


[Lldb-commits] [PATCH] D68541: Implement 'up' and 'down' shortcuts in lldb gui

2019-10-08 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

It would be fine to remove the 'd' shortcut for detach and resume if we need to 
by moving this functionality up into the menu bar. Right now the Process menu 
has "Detach" only, so it might be good to first change the "Process" menu to 
have "Detach" or "Detach suspended".  I agree that accidentally hitting 'd' 
would be bad.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68541



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


[Lldb-commits] [PATCH] D68662: Redo D68354 - [platform process list] add a flag for showing the processes of all users

2019-10-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: labath, clayborg, aadsm.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I don't know how the previous version worked on my machine. Maybe something 
changed in the meantime regarding the lldb's communication layer.

Anyway, this passes now and I've improved it. The previous code was not using 
correctly pexpect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68662

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,8 +2176,7 @@
   if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
 packet.Printf("egid:%u;",
   match_info.GetProcessInfo().GetEffectiveGroupID());
-  if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
-packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+  packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
   if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
 const ArchSpec _arch =
 match_info.GetProcessInfo().GetArchitecture();
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -591,6 +591,9 @@
   def platform_process_list_show_args : Option<"show-args", "A">,
 GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
+  def platform_process_list_all_users: Option<"all-users", "x">,
+GroupRange<1,6>,
+Desc<"Show processes matching all user IDs.">;
   def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,6 +1264,10 @@
 verbose = true;
 break;
 
+  case 'x':
+match_info.SetMatchAllUsers(true);
+break;
+
   default:
 llvm_unreachable("Unimplemented option");
   }
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -160,9 +160,34 @@
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
+if packet == "qQueryGDBServer":
+return self.qQueryGDBServer()
+if packet == "qHostInfo":
+return self.qHostInfo()
+if packet == "qGetWorkingDir":
+return self.qGetWorkingDir()
+if packet == "qsProcessInfo":
+return self.qsProcessInfo()
+if packet.startswith("qfProcessInfo"):
+return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
+def qsProcessInfo(self):
+return "E04"
+
+def qfProcessInfo(self, packet):
+raise "E04"
+
+def qGetWorkingDir(self):
+return "2f"
+
+def qHostInfo(self):
+return "ptrsize:8;endian:little;"
+
+def qQueryGDBServer(self):
+return "E04"
+
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -171,7 +196,7 @@
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -425,7 +450,6 @@
 class InvalidPacketException(Exception):
 pass
 
-
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.
Index: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
@@ -0,0 +1,35 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+def 

[Lldb-commits] [PATCH] D68354: [platform process list] add a flag for showing the processes of all users

2019-10-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace closed this revision.
wallace added a comment.

this was reverted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68354



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


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2019-10-08 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

Nice fix.  The real cost of computing the aranges manually is expanding all the 
line tables and calling GetContiguousFileAddressRanges on them.  I wonder if 
avoiding the full linetable expansion here is shifting that to a different 
place for this operation.


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

https://reviews.llvm.org/D68655



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


[Lldb-commits] [PATCH] D68661: StopInfo/Mach: Delete PPC support

2019-10-08 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Yes, I don't think we need to support this anymore.




Comment at: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:387
   case 1: // EXC_BAD_ACCESS
 break;
 

Might as well remove this break too.


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

https://reviews.llvm.org/D68661



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


[Lldb-commits] [PATCH] D68661: StopInfo/Mach: Delete PPC support

2019-10-08 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: jingham, jasonmolenda, JDevlieghere.

LLDB appears to have at least partial support for PPC, but PPC on Mach isn't a 
thing AFAIK.


https://reviews.llvm.org/D68661

Files:
  lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp

Index: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
===
--- lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -78,21 +78,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 0x101:
-code_desc = "EXC_PPC_VM_PROT_READ";
-break;
-  case 0x102:
-code_desc = "EXC_PPC_BADSPACE";
-break;
-  case 0x103:
-code_desc = "EXC_PPC_UNALIGNED";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -107,30 +92,6 @@
 code_desc = "EXC_I386_INVOP";
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_INVALID_SYSCALL";
-break;
-  case 2:
-code_desc = "EXC_PPC_UNIPL_INST";
-break;
-  case 3:
-code_desc = "EXC_PPC_PRIVINST";
-break;
-  case 4:
-code_desc = "EXC_PPC_PRIVREG";
-break;
-  case 5:
-code_desc = "EXC_PPC_TRACE";
-break;
-  case 6:
-code_desc = "EXC_PPC_PERFMON";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (m_exc_code == 1)
@@ -175,33 +136,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_OVERFLOW";
-break;
-  case 2:
-code_desc = "EXC_PPC_ZERO_DIVIDE";
-break;
-  case 3:
-code_desc = "EXC_PPC_FLT_INEXACT";
-break;
-  case 4:
-code_desc = "EXC_PPC_FLT_ZERO_DIVIDE";
-break;
-  case 5:
-code_desc = "EXC_PPC_FLT_UNDERFLOW";
-break;
-  case 6:
-code_desc = "EXC_PPC_FLT_OVERFLOW";
-break;
-  case 7:
-code_desc = "EXC_PPC_FLT_NOT_A_NUMBER";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -235,15 +169,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_BREAKPOINT";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   switch (m_exc_code) {
@@ -387,27 +312,6 @@
 break;
 
   case 2: // EXC_BAD_INSTRUCTION
-switch (cpu) {
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (exc_code) {
-  case 1: // EXC_PPC_INVALID_SYSCALL
-  case 2: // EXC_PPC_UNIPL_INST
-  case 3: // EXC_PPC_PRIVINST
-  case 4: // EXC_PPC_PRIVREG
-break;
-  case 5: // EXC_PPC_TRACE
-return StopInfo::CreateStopReasonToTrace(thread);
-  case 6: // EXC_PPC_PERFMON
-break;
-  }
-  break;
-
-default:
-  break;
-}
-break;
-
   case 3: // EXC_ARITHMETIC
   case 4: // EXC_EMULATION
 break;
@@ -478,11 +382,6 @@
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  is_actual_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374108 - Add test coverage to printing of enums and fix display of unsigned values

2019-10-08 Thread Frederic Riss via lldb-commits
Author: friss
Date: Tue Oct  8 12:52:01 2019
New Revision: 374108

URL: http://llvm.org/viewvc/llvm-project?rev=374108=rev
Log:
Add test coverage to printing of enums and fix display of unsigned values

TestCPP11EnumTypes.py should have covered all our bases when it comes
to typed enums, but it missed the regression introduced in r374066.
The reason it didn't catch it is somewhat funny: the test was copied
over from another test that recompiled a source file with a different
base type every time, but neither the test source nor the python code
was adapted for testing enums. As a result, this test was just running
8 times the exact same checks on the exact same binary.

This commit fixes the coverage and addresses the issue revealed by
the new tests.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py?rev=374108=374107=374108=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
 Tue Oct  8 12:52:01 2019
@@ -19,8 +19,8 @@ class CPP11EnumTypesTestCase(TestBase):
 """Test C++11 enumeration class types as int8_t types."""
 self.build(
 dictionary={
-'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int8_t"'})
-self.image_lookup_for_enum_type()
+'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int8_t"'})
+self.image_lookup_for_enum_type(True)
 
 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527')
 @skipIf(dwarf_version=['<', '4'])
@@ -28,8 +28,8 @@ class CPP11EnumTypesTestCase(TestBase):
 """Test C++11 enumeration class types as int16_t types."""
 self.build(
 dictionary={
-'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int16_t"'})
-self.image_lookup_for_enum_type()
+'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int16_t"'})
+self.image_lookup_for_enum_type(True)
 
 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527')
 @skipIf(dwarf_version=['<', '4'])
@@ -37,8 +37,8 @@ class CPP11EnumTypesTestCase(TestBase):
 """Test C++11 enumeration class types as int32_t types."""
 self.build(
 dictionary={
-'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int32_t"'})
-self.image_lookup_for_enum_type()
+'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int32_t"'})
+self.image_lookup_for_enum_type(True)
 
 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527')
 @skipIf(dwarf_version=['<', '4'])
@@ -46,8 +46,8 @@ class CPP11EnumTypesTestCase(TestBase):
 """Test C++11 enumeration class types as int64_t types."""
 self.build(
 dictionary={
-'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int64_t"'})
-self.image_lookup_for_enum_type()
+'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int64_t"'})
+self.image_lookup_for_enum_type(True)
 
 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527')
 @skipIf(dwarf_version=['<', '4'])
@@ -55,8 +55,8 @@ class CPP11EnumTypesTestCase(TestBase):
 """Test C++11 enumeration class types as uint8_t types."""
 self.build(
 dictionary={
-'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint8_t"'})
-self.image_lookup_for_enum_type()
+'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint8_t"'})
+self.image_lookup_for_enum_type(False)
 
 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527')
 @skipIf(dwarf_version=['<', '4'])
@@ -64,8 +64,8 @@ class CPP11EnumTypesTestCase(TestBase):
 """Test C++11 enumeration class types as uint16_t types."""
 self.build(
 dictionary={
-'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint16_t"'})
-self.image_lookup_for_enum_type()
+'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint16_t"'})
+self.image_lookup_for_enum_type(False)
 
 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527')
 @skipIf(dwarf_version=['<', '4'])
@@ -73,8 +73,8 @@ class CPP11EnumTypesTestCase(TestBase):
 """Test C++11 enumeration class types as uint32_t types."""
 self.build(
 dictionary={
-'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint32_t"'})
-self.image_lookup_for_enum_type()
+  

[Lldb-commits] [PATCH] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

So what's the conclusion here?   Should `HandleProcessEvent` get a SBStream 
variant as well?   I say "as well", because the `FileSP` variant is 
required in order to remove the python binding to the `FILE*` variant, and once 
we have the `FileSP` it seems like it would be really strange to leave out the 
`SBFile`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546



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


[Lldb-commits] [lldb] r374106 - StopInfo/Mach: Use early-exits, reflow messy comments, NFCI

2019-10-08 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Tue Oct  8 12:40:13 2019
New Revision: 374106

URL: http://llvm.org/viewvc/llvm-project?rev=374106=rev
Log:
StopInfo/Mach: Use early-exits, reflow messy comments, NFCI

Modified:
lldb/trunk/include/lldb/Target/StopInfo.h
lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp

Modified: lldb/trunk/include/lldb/Target/StopInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=374106=374105=374106=diff
==
--- lldb/trunk/include/lldb/Target/StopInfo.h (original)
+++ lldb/trunk/include/lldb/Target/StopInfo.h Tue Oct  8 12:40:13 2019
@@ -33,10 +33,13 @@ public:
 
   lldb::ThreadSP GetThread() const { return m_thread_wp.lock(); }
 
-  // The value of the StopInfo depends on the StopReason. StopReason
-  // Meaning --
-  // eStopReasonBreakpoint   BreakpointSiteID eStopReasonSignal
-  // Signal number eStopReasonWatchpoint   WatchpointLocationID
+  // The value of the StopInfo depends on the StopReason.
+  //
+  // StopReason Meaning
+  // 
+  // eStopReasonBreakpoint   BreakpointSiteID
+  // eStopReasonSignal   Signal number
+  // eStopReasonWatchpoint   WatchpointLocationID
   // eStopReasonPlanComplete No significance
 
   uint64_t GetValue() const { return m_value; }

Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=374106=374105=374106=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Tue Oct 
 8 12:40:13 2019
@@ -30,334 +30,341 @@ using namespace lldb;
 using namespace lldb_private;
 
 const char *StopInfoMachException::GetDescription() {
-  if (m_description.empty() && m_value != 0) {
-ExecutionContext exe_ctx(m_thread_wp.lock());
-Target *target = exe_ctx.GetTargetPtr();
-const llvm::Triple::ArchType cpu =
-target ? target->GetArchitecture().GetMachine()
-   : llvm::Triple::UnknownArch;
-
-const char *exc_desc = nullptr;
-const char *code_label = "code";
-const char *code_desc = nullptr;
-const char *subcode_label = "subcode";
-const char *subcode_desc = nullptr;
+  if (!m_description.empty())
+return m_description.c_str();
+  if (GetValue() == eStopReasonInvalid)
+return "invalid stop reason!";
+
+  ExecutionContext exe_ctx(m_thread_wp.lock());
+  Target *target = exe_ctx.GetTargetPtr();
+  const llvm::Triple::ArchType cpu =
+  target ? target->GetArchitecture().GetMachine()
+ : llvm::Triple::UnknownArch;
+
+  const char *exc_desc = nullptr;
+  const char *code_label = "code";
+  const char *code_desc = nullptr;
+  const char *subcode_label = "subcode";
+  const char *subcode_desc = nullptr;
 
 #if defined(__APPLE__)
-char code_desc_buf[32];
-char subcode_desc_buf[32];
+  char code_desc_buf[32];
+  char subcode_desc_buf[32];
 #endif
 
-switch (m_value) {
-case 1: // EXC_BAD_ACCESS
-  exc_desc = "EXC_BAD_ACCESS";
-  subcode_label = "address";
-  switch (cpu) {
-  case llvm::Triple::x86:
-  case llvm::Triple::x86_64:
-switch (m_exc_code) {
-case 0xd:
-  code_desc = "EXC_I386_GPFLT";
-  m_exc_data_count = 1;
-  break;
-}
-break;
-  case llvm::Triple::arm:
-  case llvm::Triple::thumb:
-switch (m_exc_code) {
-case 0x101:
-  code_desc = "EXC_ARM_DA_ALIGN";
-  break;
-case 0x102:
-  code_desc = "EXC_ARM_DA_DEBUG";
-  break;
-}
+  switch (m_value) {
+  case 1: // EXC_BAD_ACCESS
+exc_desc = "EXC_BAD_ACCESS";
+subcode_label = "address";
+switch (cpu) {
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  switch (m_exc_code) {
+  case 0xd:
+code_desc = "EXC_I386_GPFLT";
+m_exc_data_count = 1;
 break;
-
-  case llvm::Triple::ppc:
-  case llvm::Triple::ppc64:
-switch (m_exc_code) {
-case 0x101:
-  code_desc = "EXC_PPC_VM_PROT_READ";
-  break;
-case 0x102:
-  code_desc = "EXC_PPC_BADSPACE";
-  break;
-case 0x103:
-  code_desc = "EXC_PPC_UNALIGNED";
-  break;
-}
+  }
+  break;
+case llvm::Triple::arm:
+case llvm::Triple::thumb:
+  switch (m_exc_code) {
+  case 0x101:
+code_desc = "EXC_ARM_DA_ALIGN";
 break;
-
-  default:
+  case 0x102:
+code_desc = "EXC_ARM_DA_DEBUG";
 break;
   }
   break;
 
-case 2: // EXC_BAD_INSTRUCTION
-  exc_desc = 

[Lldb-commits] [PATCH] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

In D68546#1699397 , @labath wrote:

> Yeah, the %extends are somewhat ugly, but I also find the FileSP overloads in 
> the "public" sections of the SB classes unnerving too, because they are not 
> really public -- no user can actually call them directly in a meaningful way. 
> They are really only meant for the python interface, which sort does sit on 
> the other side of the SB api, but also kind of doesn't. That's the weird part 
> about lldb python support, where python can be embedded *into* lldb, but it 
> also can be sitting *above* it (or both at the same time). I am not really 
> sure what to do about that. I don't suppose there's any way to make the 
> FileSP overloads private?


I don't think so, because the SWIG wrappers need to see them.   They are 
de-facto private though, because they require an argument of type 
`std::shared_ptr`.
All external API clients can see is a forward declaration that 
lldb_private::File is a class.   They can make a NULL pointer to one, but 
that's it.

> Or maybe they actually should be public, and the actual problem is that there 
> is no way for a c++ user to make use of this functionality, even though it 
> should be able to? Right now, the c++ api is sort of disadvantaged in that 
> one cannot create an SBFile that would redirect to some custom fancy c++ 
> output object. I am not saying you should implement that, but if we assume 
> that such functionality were available do you think it would be possible to 
> implement the python stuff on top of that? In that sense, maybe the FileSP 
> overloads are actually fine, and we can treat them as a placeholder for this 
> hypothetical future functionality?
> 
> I am sorry if this doesn't make much sense -- that's because I myself am not 
> clear on this matter. But I hope that I at least managed to give you an idea 
> of the things going through my head right now. If you have any thoughts on 
> any of this, I'd like to hear them.

No, it does make sense.   I too thought it was kind of odd that there's a 
python API which is inaccessible from C++.  I can't really think of any 
ultimate use case where a C++ binding for File I/O callbacks would be needed, 
but if it were, I can think of three ways to do it.

The first and simplest way to support it is to just use `funopen()` or whatever 
the equivalent of that is on your platform to make a `FILE*`.I put the 
`FILE*` constructor in for C++ even though it will never have a SWIG wrapper so 
this would be possible.The disadvantage is that `funopen()` isn't portable, 
so clients that go this route will need platform specific code to do it.

The intermediate method would be to make our own funopen that would act as a 
factory function for `FileSP`. File would remain private, but you could 
make one with callbacks if you wanted to.Disadvantage here is that C++ 
clients would be calling though a chain of two function pointers to actually 
get to the Read and Write methods.   This is still better from a performance 
perspective than calling into a Python method, but if we wanted to avoid that, 
we could go one step further.

The most complicated way we could handle it would be to expose an ABI-stable 
abstract base class of `File` in the API headers. This should be at the 
base of the File class hierarchy, where `IOObject` is now.It would only 
have virtual methods, and it would also have a bunch of unused dummy virtual so 
we can add new virtual methods later if we need too, without changing the ABI.  
   C++ clients could then just subclass their own `File` types and use `FileSP` 
directly. I think to do this properly we'd need to do some more 
refactoring, because I'm not sure what should happen to `IOObject` and `Socket` 
under this scenario, or what kinds of error codes the virtual methods should be 
returning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546



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


[Lldb-commits] [PATCH] D68541: Implement 'up' and 'down' shortcuts in lldb gui

2019-10-08 Thread Luboš Luňák via Phabricator via lldb-commits
llunak added a comment.

In D68541#1698127 , @JDevlieghere 
wrote:

> Would it be possible to add a test for this? Maybe you can extend 
> `TestGuiBasic.py`.


I can, although to me it looks like a new test would be better. But first of 
all I wanted some feedback on this, as the patch in this form doesn't even 
compile. I'd actually personally prefer to just nuke the "Detach and resume 
process" shortcut, as I not only fail to see its usefulness but I also find it 
dangerous (I certainly don't want to hit it by mistake and ruin my debugging 
session), but then I assume there probably was a reason why it was added.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68541



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


[Lldb-commits] [PATCH] D68549: make ConstString allocate memory in non-tiny chunks

2019-10-08 Thread Luboš Luňák via Phabricator via lldb-commits
llunak added a comment.

In D68549#1700019 , @aprantl wrote:

> This makes sense to me. We may need to make this configurable for low-memory 
> hosts at some point.


Note that the memory usage shouldn't be as bad as it might look. As long as the 
BumpPtrAllocatorImpl size exceeds the threshold for a separate allocation 
(glibc malloc will use separate mmap for anything >=128KiB), memory for the 
virtual memory will be really allocated only if needed. And even if, that 1MiB 
is nowhere near the 15MiB liblldb.so takes here.

In D68549#1700022 , @aprantl wrote:

> I assume you experimented with many different values, and these are the best 
> tradeoff?


I've tried few and picked what seemed reasonable. 64KiB for the allocator 
didn't perform as well, but then I don't think there's one good number, so I 
didn't really try to look for one. Also I tried just with my one specific use 
case, and this cannot be benchmarked precisely. The logic was basically just 
that for small projects this doesn't really matter because they won't take up 
much memory anyway and for those that do this should perform better.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68549



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


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-08 Thread Cameron via Phabricator via lldb-commits
cameron314 updated this revision to Diff 223919.
cameron314 added a comment.

Added comments.


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

https://reviews.llvm.org/D68641

Files:
  source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
  source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
  source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
  source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
  source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
  source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
===
--- source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -39,9 +39,14 @@
   bool GetSummary(Stream , const TypeSummaryOptions );
 
 private:
-  ValueObjectSP m_ptr_obj;
-  ValueObjectSP m_obj_obj;
-  ValueObjectSP m_del_obj;
+  // The lifetime of a ValueObject and all its derivative ValueObjects
+  // (children, clones, etc.) is managed by a ClusterManager. These
+  // objects are only destroyed when every shared pointer to any of them
+  // is destroyed, so we must not store a shared pointer to any ValueObject
+  // derived from our backend ValueObject (since we're in the same cluster).
+  ValueObject* m_ptr_obj = nullptr;
+  ValueObject* m_obj_obj = nullptr;
+  ValueObject* m_del_obj = nullptr;
 
   ValueObjectSP GetTuple();
 };
@@ -92,17 +97,17 @@
 
   ValueObjectSP ptr_obj = tuple_frontend->GetChildAtIndex(0);
   if (ptr_obj)
-m_ptr_obj = ptr_obj->Clone(ConstString("pointer"));
+m_ptr_obj = ptr_obj->Clone(ConstString("pointer")).get();
 
   ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1);
   if (del_obj)
-m_del_obj = del_obj->Clone(ConstString("deleter"));
+m_del_obj = del_obj->Clone(ConstString("deleter")).get();
 
   if (m_ptr_obj) {
 Status error;
 ValueObjectSP obj_obj = m_ptr_obj->Dereference(error);
 if (error.Success()) {
-  m_obj_obj = obj_obj->Clone(ConstString("object"));
+  m_obj_obj = obj_obj->Clone(ConstString("object")).get();
 }
   }
 
@@ -114,11 +119,11 @@
 lldb::ValueObjectSP
 LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
   if (idx == 0)
-return m_ptr_obj;
+return m_ptr_obj->GetSP();
   if (idx == 1)
-return m_del_obj;
+return m_del_obj->GetSP();
   if (idx == 2)
-return m_obj_obj;
+return m_obj_obj->GetSP();
   return lldb::ValueObjectSP();
 }
 
Index: source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
===
--- source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
+++ source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -37,7 +37,12 @@
   size_t GetIndexOfChildWithName(ConstString name) override;
 
 private:
-  std::vector m_members;
+  // The lifetime of a ValueObject and all its derivative ValueObjects
+  // (children, clones, etc.) is managed by a ClusterManager. These
+  // objects are only destroyed when every shared pointer to any of them
+  // is destroyed, so we must not store a shared pointer to any ValueObject
+  // derived from our backend ValueObject (since we're in the same cluster).
+  std::vector m_members;
 };
 
 } // end of anonymous namespace
@@ -72,7 +77,7 @@
 if (value_sp) {
   StreamString name;
   name.Printf("[%zd]", m_members.size());
-  m_members.push_back(value_sp->Clone(ConstString(name.GetString(;
+  m_members.push_back(value_sp->Clone(ConstString(name.GetString())).get());
 }
   }
 }
@@ -86,7 +91,7 @@
 lldb::ValueObjectSP
 LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
   if (idx < m_members.size())
-return m_members[idx];
+return m_members[idx]->GetSP();
   return lldb::ValueObjectSP();
 }
 
Index: source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
===
--- source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
+++ source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
@@ -184,7 +184,6 @@
 
 private:
   size_t m_size = 0;
-  ValueObjectSP m_base_sp;
 };
 } // namespace
 
Index: source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
===
--- source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
+++ source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
@@ -30,47 +30,56 @@
   ValueObjectSP GetChildAtIndex(size_t idx) override;
 
 private:
-  std::vector m_elements;
-  ValueObjectSP m_base_sp;
+  // The lifetime of a ValueObject and all its derivative ValueObjects
+  // (children, clones, etc.) is managed by a ClusterManager. These
+  // objects are only destroyed when every shared pointer to any of them
+  // is destroyed, so we must not store a shared pointer to any ValueObject
+  // derived from our backend ValueObject 

[Lldb-commits] [lldb] r374104 - [Reproducer] Don't isntrument methods that get called from the signal handler.

2019-10-08 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Oct  8 12:17:42 2019
New Revision: 374104

URL: http://llvm.org/viewvc/llvm-project?rev=374104=rev
Log:
[Reproducer] Don't isntrument methods that get called from the signal handler.

LLDB's signal handlers call SBDebugger methods, which themselves try to
be really careful about not doing anything non-signal safe. The
Reproducer record macro is not careful though, and does unsafe things
which potentially caused LLDB to crash. Given that these methods are not
particularly interesting I've swapped the RECORD macros with DUMMY ones,
so that we still register the API boundary but don't do anything
non-signal safe.

Thanks Jim for figuring this one out!

Modified:
lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
lldb/trunk/source/API/SBDebugger.cpp

Modified: lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h?rev=374104=374103=374104=diff
==
--- lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h (original)
+++ lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h Tue Oct  8 
12:17:42 2019
@@ -177,6 +177,8 @@ template  inline std::st
 #define LLDB_RECORD_DUMMY(Result, Class, Method, Signature, ...)   
\
   lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION,  
\
 stringify_args(__VA_ARGS__));
+#define LLDB_RECORD_DUMMY_NO_ARGS(Result, Class, Method)   
\
+  lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION);
 
 namespace lldb_private {
 namespace repro {

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=374104=374103=374104=diff
==
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Tue Oct  8 12:17:42 2019
@@ -430,14 +430,14 @@ SBFile SBDebugger::GetErrorFile() {
 }
 
 void SBDebugger::SaveInputTerminalState() {
-  LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, SaveInputTerminalState);
+  LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, SaveInputTerminalState);
 
   if (m_opaque_sp)
 m_opaque_sp->SaveInputTerminalState();
 }
 
 void SBDebugger::RestoreInputTerminalState() {
-  LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, RestoreInputTerminalState);
+  LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, RestoreInputTerminalState);
 
   if (m_opaque_sp)
 m_opaque_sp->RestoreInputTerminalState();
@@ -1093,7 +1093,7 @@ void SBDebugger::DispatchInput(const voi
 }
 
 void SBDebugger::DispatchInputInterrupt() {
-  LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputInterrupt);
+  LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, DispatchInputInterrupt);
 
   if (m_opaque_sp)
 m_opaque_sp->DispatchInputInterrupt();
@@ -1253,8 +1253,7 @@ uint32_t SBDebugger::GetTerminalWidth()
 }
 
 void SBDebugger::SetTerminalWidth(uint32_t term_width) {
-  LLDB_RECORD_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t),
- term_width);
+  LLDB_RECORD_DUMMY(void, SBDebugger, SetTerminalWidth, (uint32_t), 
term_width);
 
   if (m_opaque_sp)
 m_opaque_sp->SetTerminalWidth(term_width);


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


[Lldb-commits] [PATCH] D68658: LLDB: Use LLVM's type for minidump ExceptionStream

2019-10-08 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
JosephTremoulet added a parent revision: D68657: Update MinidumpYAML to use 
minidump::Exception for exception stream.
JosephTremoulet added reviewers: labath, clayborg.

The types defined for it in LLDB are now redundant with core types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68658

Files:
  lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Plugins/Process/minidump/ProcessMinidump.h
  lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -252,10 +252,10 @@
 
 TEST_F(MinidumpParserTest, GetExceptionStream) {
   SetUpData("linux-x86_64.dmp");
-  const MinidumpExceptionStream *exception_stream =
+  const llvm::minidump::ExceptionStream *exception_stream =
   parser->GetExceptionStream();
   ASSERT_NE(nullptr, exception_stream);
-  ASSERT_EQ(11UL, exception_stream->exception_record.exception_code);
+  ASSERT_EQ(11UL, exception_stream->ExceptionRecord.ExceptionCode);
 }
 
 void check_mem_range_exists(MinidumpParser , const uint64_t range_start,
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.h
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.h
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -108,7 +108,7 @@
   FileSpec m_core_file;
   lldb::DataBufferSP m_core_data;
   llvm::ArrayRef m_thread_list;
-  const MinidumpExceptionStream *m_active_exception;
+  const minidump::ExceptionStream *m_active_exception;
   lldb::CommandObjectSP m_command_sp;
   bool m_is_wow64;
 };
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -237,36 +237,37 @@
   if (!m_active_exception)
 return;
 
-  if (m_active_exception->exception_record.exception_code ==
-  MinidumpException::DumpRequested) {
+  if (m_active_exception->ExceptionRecord.ExceptionCode ==
+  static_cast(minidump::ExceptionCode::Linux_DumpRequested)) {
+// TODO: Consider moving this down to the linux-specific path and checking
+// the Simulated cases for Mac and Windows.
 return;
   }
 
   lldb::StopInfoSP stop_info;
   lldb::ThreadSP stop_thread;
 
-  Process::m_thread_list.SetSelectedThreadByID(m_active_exception->thread_id);
+  Process::m_thread_list.SetSelectedThreadByID(m_active_exception->ThreadId);
   stop_thread = Process::m_thread_list.GetSelectedThread();
   ArchSpec arch = GetArchitecture();
 
   if (arch.GetTriple().getOS() == llvm::Triple::Linux) {
 stop_info = StopInfo::CreateStopReasonWithSignal(
-*stop_thread, m_active_exception->exception_record.exception_code);
+*stop_thread, m_active_exception->ExceptionRecord.ExceptionCode);
   } else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
 stop_info = StopInfoMachException::CreateStopReasonWithMachException(
-*stop_thread, m_active_exception->exception_record.exception_code, 2,
-m_active_exception->exception_record.exception_flags,
-m_active_exception->exception_record.exception_address, 0);
+*stop_thread, m_active_exception->ExceptionRecord.ExceptionCode, 2,
+m_active_exception->ExceptionRecord.ExceptionFlags,
+m_active_exception->ExceptionRecord.ExceptionAddress, 0);
   } else {
 std::string desc;
 llvm::raw_string_ostream desc_stream(desc);
 desc_stream << "Exception "
 << llvm::format_hex(
-   m_active_exception->exception_record.exception_code, 8)
+   m_active_exception->ExceptionRecord.ExceptionCode, 8)
 << " encountered at address "
 << llvm::format_hex(
-   m_active_exception->exception_record.exception_address,
-   8);
+   m_active_exception->ExceptionRecord.ExceptionAddress, 8);
 stop_info = StopInfo::CreateStopReasonWithException(
 *stop_thread, desc_stream.str().c_str());
   }
@@ -331,8 +332,8 @@
 
 // If the minidump contains an exception context, use it
 if (m_active_exception != nullptr &&
-m_active_exception->thread_id == thread.ThreadId) {
-  context_location = m_active_exception->thread_context;
+m_active_exception->ThreadId == thread.ThreadId) {
+  

[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-08 Thread Cameron via Phabricator via lldb-commits
cameron314 added a comment.

Right, I'll add comments on the pointer declarations.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [lldb] r374100 - [CMake] Fix building without python on Windows

2019-10-08 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Tue Oct  8 11:38:46 2019
New Revision: 374100

URL: http://llvm.org/viewvc/llvm-project?rev=374100=rev
Log:
[CMake] Fix building without python on Windows

Summary: find_python_libs_windows might set LLDB_DISABLE_PYTHON to ON.
Unfortunately we do not re-check this variable before using variables filled in
by find_python_libs_windows, leading to a failed configuration.

Modified:
lldb/trunk/cmake/modules/LLDBConfig.cmake

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=374100=374099=374100=diff
==
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Tue Oct  8 11:38:46 2019
@@ -267,10 +267,15 @@ function(find_python_libs_windows)
   message(STATUS "LLDB Found PythonIncludeDirs: ${PYTHON_INCLUDE_DIR}")
 endfunction(find_python_libs_windows)
 
+# Call find_python_libs_windows ahead of the rest of the python configuration.
+# It's possible that it won't find a python installation and will then set
+# LLDB_DISABLE_PYTHON to ON.
+if (NOT LLDB_DISABLE_PYTHON AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
+  find_python_libs_windows()
+endif()
+
 if (NOT LLDB_DISABLE_PYTHON)
   if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
-find_python_libs_windows()
-
 if (NOT LLDB_RELOCATABLE_PYTHON)
   file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
   add_definitions( -DLLDB_PYTHON_HOME="${LLDB_PYTHON_HOME}" )


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


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jasonmolenda, jingham, friss.
Herald added a subscriber: JDevlieghere.
Herald added a reviewer: JDevlieghere.

When ingesting aranges from a dSYM it makes sense to always trust the contents 
of the accelerator table since it always comes from dsymutil. According to 
Instruments, skipping the decoding of all CU DIEs to get at the DW_AT_ranges 
attribute removes ~3.5 seconds from setting a breakpoint by file/line when 
debugging clang with a dSYM. Interestingly on the wall clock the speedup is 
less noticeable, but still present.

rdar://problem/56057688


https://reviews.llvm.org/D68655

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -54,13 +54,19 @@
 
   // Manually build arange data for everything that wasn't in the
   // .debug_aranges table.
-  const size_t num_units = GetNumUnits();
-  for (size_t idx = 0; idx < num_units; ++idx) {
-DWARFUnit *cu = GetUnitAtIndex(idx);
-
-dw_offset_t offset = cu->GetOffset();
-if (cus_with_data.find(offset) == cus_with_data.end())
-  cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+  //
+  // This step is skipped for dSYMs and other debug-info-only
+  // objects, which are always trusted to have a complete table.
+  auto *obj = m_dwarf.GetObjectFile();
+  if (!obj || obj->GetType() != ObjectFile::eTypeDebugInfo) {
+const size_t num_units = GetNumUnits();
+for (size_t idx = 0; idx < num_units; ++idx) {
+  DWARFUnit *cu = GetUnitAtIndex(idx);
+
+  dw_offset_t offset = cu->GetOffset();
+  if (cus_with_data.find(offset) == cus_with_data.end())
+cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+}
   }
 
   const bool minimize = true;


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -54,13 +54,19 @@
 
   // Manually build arange data for everything that wasn't in the
   // .debug_aranges table.
-  const size_t num_units = GetNumUnits();
-  for (size_t idx = 0; idx < num_units; ++idx) {
-DWARFUnit *cu = GetUnitAtIndex(idx);
-
-dw_offset_t offset = cu->GetOffset();
-if (cus_with_data.find(offset) == cus_with_data.end())
-  cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+  //
+  // This step is skipped for dSYMs and other debug-info-only
+  // objects, which are always trusted to have a complete table.
+  auto *obj = m_dwarf.GetObjectFile();
+  if (!obj || obj->GetType() != ObjectFile::eTypeDebugInfo) {
+const size_t num_units = GetNumUnits();
+for (size_t idx = 0; idx < num_units; ++idx) {
+  DWARFUnit *cu = GetUnitAtIndex(idx);
+
+  dw_offset_t offset = cu->GetOffset();
+  if (cus_with_data.find(offset) == cus_with_data.end())
+cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+}
   }
 
   const bool minimize = true;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68270: DWARFDebugLoc: Add a function to get the address range of an entry

2019-10-08 Thread Paul Robinson via Phabricator via lldb-commits
probinson added a comment.

Do we care whether llvm-dwarfdump's output bears any similarities to the output 
from GNU readelf or objdump?  There has been a push lately to get the LLVM 
"binutils" to behave more like GNU's, although AFAIK it hasn't gotten to the 
DWARF dumping part.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68270



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


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik accepted this revision.
shafik added a comment.

LGTM




Comment at: source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp:34
   std::vector m_elements;
-  ValueObjectSP m_first;
+  ValueObject* m_first = nullptr;
   CompilerType m_bool_type;

I feel like each of these pointer members deserve a comment.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223902.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188

Files:
  lldb/include/lldb/API/SBFile.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig
  lldb/scripts/interface/SBFile.i
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1014,22 +1014,23 @@
   // first-class object type anymore.  `PyFile_FromFd` is just a thin wrapper
   // over `io.open()`, which returns some object derived from `io.IOBase`. As a
   // result, the only way to detect a file in Python 3 is to check whether it
-  // inherits from `io.IOBase`.  Since it is possible for non-files to also
-  // inherit from `io.IOBase`, we additionally verify that it has the `fileno`
-  // attribute, which should guarantee that it is backed by the file system.
-  PythonObject io_module(PyRefType::Owned, PyImport_ImportModule("io"));
-  PythonDictionary io_dict(PyRefType::Borrowed,
-   PyModule_GetDict(io_module.get()));
-  PythonObject io_base_class = io_dict.GetItemForKey(PythonString("IOBase"));
-
-  PythonObject object_type(PyRefType::Owned, PyObject_Type(py_obj));
-
-  if (1 != PyObject_IsSubclass(object_type.get(), io_base_class.get()))
+  // inherits from `io.IOBase`.
+  auto io_module = PythonModule::Import("io");
+  if (!io_module) {
+llvm::consumeError(io_module.takeError());
 return false;
-  if (!object_type.HasAttribute("fileno"))
+  }
+  auto iobase = io_module.get().Get("IOBase");
+  if (!iobase) {
+llvm::consumeError(iobase.takeError());
 return false;
-
-  return true;
+  }
+  int r = PyObject_IsInstance(py_obj, iobase.get().get());
+  if (r < 0) {
+llvm::consumeError(exception()); // clear the exception and log it.
+return false;
+  }
+  return !!r;
 #endif
 }
 
@@ -1082,6 +1083,20 @@
   return file;
 }
 
+namespace {
+class GIL {
+public:
+  GIL() {
+m_state = PyGILState_Ensure();
+assert(!PyErr_Occurred());
+  }
+  ~GIL() { PyGILState_Release(m_state); }
+
+protected:
+  PyGILState_STATE m_state;
+};
+} // namespace
+
 const char *PythonException::toCString() const {
   if (!m_repr_bytes)
 return "unknown exception";
@@ -1136,4 +1151,371 @@
 
 char PythonException::ID = 0;
 
+llvm::Expected GetOptionsForPyObject(const PythonObject ) {
+  uint32_t options = 0;
+#if PY_MAJOR_VERSION >= 3
+  auto readable = As(obj.CallMethod("readable"));
+  if (!readable)
+return readable.takeError();
+  auto writable = As(obj.CallMethod("writable"));
+  if (!writable)
+return writable.takeError();
+  if (readable.get())
+options |= File::eOpenOptionRead;
+  if (writable.get())
+options |= File::eOpenOptionWrite;
+#else
+  PythonString py_mode = obj.GetAttributeValue("mode").AsType();
+  options = File::GetOptionsFromMode(py_mode.GetString());
+#endif
+  return options;
+}
+
+// Base class template for python files.   All it knows how to do
+// is hold a reference to the python object and close or flush it
+// when the File is closed.
+namespace {
+template  class OwnedPythonFile : public Base {
+public:
+  template 
+  OwnedPythonFile(const PythonFile , bool borrowed, Args... args)
+  : Base(args...), m_py_obj(file), m_borrowed(borrowed) {
+assert(m_py_obj);
+  }
+
+  ~OwnedPythonFile() override {
+assert(m_py_obj);
+GIL takeGIL;
+Close();
+m_py_obj.Reset();
+  }
+
+  bool IsPythonSideValid() const {
+GIL takeGIL;
+auto closed = As(m_py_obj.GetAttribute("closed"));
+if (!closed) {
+  llvm::consumeError(closed.takeError());
+  return false;
+}
+return !closed.get();
+  }
+
+  bool IsValid() const override {
+return IsPythonSideValid() && Base::IsValid();
+  }
+
+  Status Close() override {
+assert(m_py_obj);
+Status py_error, base_error;
+GIL takeGIL;
+if (!m_borrowed) {
+  auto r = m_py_obj.CallMethod("close");
+  if (!r)
+py_error = Status(r.takeError());
+}
+base_error = Base::Close();
+if (py_error.Fail())
+  return py_error;
+return base_error;
+  };
+
+protected:
+  PythonFile m_py_obj;
+  bool m_borrowed;
+};
+} // namespace
+
+// A SimplePythonFile is a OwnedPythonFile that just does all I/O as
+// a NativeFile
+namespace {
+class SimplePythonFile : public OwnedPythonFile {
+public:
+  SimplePythonFile(const PythonFile , bool borrowed, int fd,
+   uint32_t options)
+  : OwnedPythonFile(file, borrowed, fd, options, false) {}
+};
+} // namespace
+
+#if PY_MAJOR_VERSION 

[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-08 Thread Gwen Mittertreiner via Phabricator via lldb-commits
gmittert updated this revision to Diff 223903.
gmittert added a comment.

Alright, rebased and added a comment to it


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68614

Files:
  lit/CMakeLists.txt


Index: lit/CMakeLists.txt
===
--- lit/CMakeLists.txt
+++ lit/CMakeLists.txt
@@ -56,9 +56,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  list(APPPEND LLDB_TEST_DEPS llvm-strip)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 endif()


Index: lit/CMakeLists.txt
===
--- lit/CMakeLists.txt
+++ lit/CMakeLists.txt
@@ -56,9 +56,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  list(APPPEND LLDB_TEST_DEPS llvm-strip)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374096 - Reflow/fix doxygen comments.

2019-10-08 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Oct  8 11:04:49 2019
New Revision: 374096

URL: http://llvm.org/viewvc/llvm-project?rev=374096=rev
Log:
Reflow/fix doxygen comments.

Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=374096=374095=374096=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Oct  8 11:04:49 2019
@@ -63,16 +63,22 @@ class ObjectFile : public std::enable_sh
 public:
   enum Type {
 eTypeInvalid = 0,
-eTypeCoreFile,  /// A core file that has a checkpoint of a program's
-/// execution state
-eTypeExecutable,/// A normal executable
-eTypeDebugInfo, /// An object file that contains only debug information
-eTypeDynamicLinker, /// The platform's dynamic linker executable
-eTypeObjectFile,/// An intermediate object file
-eTypeSharedLibrary, /// A shared library that can be used during execution
-eTypeStubLibrary, /// A library that can be linked against but not used for
-  /// execution
-eTypeJIT, /// JIT code that has symbols, sections and possibly debug info
+/// A core file that has a checkpoint of a program's execution state.
+eTypeCoreFile,
+/// A normal executable.
+eTypeExecutable,
+/// An object file that contains only debug information.
+eTypeDebugInfo,
+/// The platform's dynamic linker executable.
+eTypeDynamicLinker,
+/// An intermediate object file.
+eTypeObjectFile,
+/// A shared library that can be used during execution.
+eTypeSharedLibrary,
+/// A library that can be linked against but not used for execution.
+eTypeStubLibrary,
+/// JIT code that has symbols, sections and possibly debug info.
+eTypeJIT,
 eTypeUnknown
   };
 


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


Re: [Lldb-commits] [PATCH] D68597: Replace static const StringRef with StringRef (NFC)

2019-10-08 Thread Raphael “Teemperor” Isemann via lldb-commits
We actually call the libc++abi guard functions even for const static 
StringRefs, so that patch actually saves us a lot.

> On Oct 7, 2019, at 11:43 PM, Adrian Prantl via Phabricator via lldb-commits 
>  wrote:
> 
> aprantl created this revision.
> aprantl added a reviewer: JDevlieghere.
> 
> I just don't think that we are saving anything by making these StringRefs 
> global variables. The strings they reference are constants anyway.
> 
> 
> https://reviews.llvm.org/D68597
> 
> Files:
>  lldb/source/Interpreter/OptionValueBoolean.cpp
>  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
>  
> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
>  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [PATCH] D68547: exception handling in PythonDataObjects.

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 223900.
lawrence_danna marked 2 inline comments as done.
lawrence_danna added a comment.

style fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68547

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -6,6 +6,26 @@
 //
 //===--===//
 
+//
+// !! FIXME FIXME FIXME !!
+//
+// Python APIs nearly all can return an exception.   They do this
+// by returning NULL, or -1, or some such value and setting
+// the exception state with PyErr_Set*().   Exceptions must be
+// handled before further python API functions are called.   Failure
+// to do so will result in asserts on debug builds of python.
+// It will also sometimes, but not usually result in crashes of
+// release builds.
+//
+// Nearly all the code in this header does not handle python exceptions
+// correctly.  It should all be converted to return Expected<> or
+// Error types to capture the exception.
+//
+// Everything in this file except functions that return Error or
+// Expected<> is considered deprecated and should not be
+// used in new code.  If you need to use it, fix it first.
+//
+
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 
@@ -21,11 +41,13 @@
 
 namespace lldb_private {
 
+class PythonObject;
 class PythonBytes;
 class PythonString;
 class PythonList;
 class PythonDictionary;
 class PythonInteger;
+class PythonException;
 
 class StructuredPythonObject : public StructuredData::Generic {
 public:
@@ -72,8 +94,67 @@
 // not call Py_INCREF.
 };
 
+namespace python {
+
+// Take a reference that you already own, and turn it into
+// a PythonObject.
+//
+// Most python API methods will return a +1 reference
+// if they succeed or NULL if and only if
+// they set an exception.   Use this to collect such return
+// values, after checking for NULL.
+//
+// If T is not just PythonObject, then obj must be already be
+// checked to be of the correct type.
+template  T Take(PyObject *obj) {
+  assert(obj);
+  assert(!PyErr_Occurred());
+  T thing(PyRefType::Owned, obj);
+  assert(thing.IsValid());
+  return std::move(thing);
+}
+
+// Retain a reference you have borrowed, and turn it into
+// a PythonObject.
+//
+// A minority of python APIs return a borrowed reference
+// instead of a +1.   They will also return NULL if and only
+// if they set an exception.   Use this to collect such return
+// values, after checking for NULL.
+//
+// If T is not just PythonObject, then obj must be already be
+// checked to be of the correct type.
+template  T Retain(PyObject *obj) {
+  assert(obj);
+  assert(!PyErr_Occurred());
+  T thing(PyRefType::Borrowed, obj);
+  assert(thing.IsValid());
+  return std::move(thing);
+}
+
+} // namespace python
+
 enum class PyInitialValue { Invalid, Empty };
 
+template  struct PythonFormat;
+
+template <> struct PythonFormat {
+  static constexpr char format = 'K';
+  static auto get(unsigned long long value) { return value; }
+};
+
+template <> struct PythonFormat {
+  static constexpr char format = 'L';
+  static auto get(long long value) { return value; }
+};
+
+template 
+struct PythonFormat<
+T, typename std::enable_if::value>::type> {
+  static constexpr char format = 'O';
+  static auto get(const T ) { return value.get(); }
+};
+
 class PythonObject {
 public:
   PythonObject() : m_py_obj(nullptr) {}
@@ -84,14 +165,19 @@
 
   PythonObject(const PythonObject ) : m_py_obj(nullptr) { Reset(rhs); }
 
+  PythonObject(PythonObject &) {
+m_py_obj = rhs.m_py_obj;
+rhs.m_py_obj = nullptr;
+  }
+
   virtual ~PythonObject() { Reset(); }
 
   void Reset() {
 // Avoid calling the virtual method since it's not necessary
 // to actually validate the type of the PyObject if we're
 // just setting to null.
-if (Py_IsInitialized())
-  Py_XDECREF(m_py_obj);
+if (m_py_obj && Py_IsInitialized())
+  Py_DECREF(m_py_obj);
 m_py_obj = nullptr;
   }
 
@@ -110,6 +196,8 @@
   // PyRefType doesn't make sense, and the copy constructor should be used.
   void Reset(PyRefType type, const PythonObject ) = delete;
 
+  // FIXME We shouldn't have virtual anything.  PythonObject should be a
+  // strictly pass-by-value type.
   virtual void Reset(PyRefType type, PyObject *py_obj) {
 if (py_obj == m_py_obj)
   return;
@@ -123,7 +211,7 @@
 // an owned reference by incrementing it.  If it is an owned
 // reference (for example the 

[Lldb-commits] [PATCH] D68547: exception handling in PythonDataObjects.

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG085328ba: exception handling in PythonDataObjects. 
(authored by lawrence_danna).

Changed prior to commit:
  https://reviews.llvm.org/D68547?vs=223900=223901#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68547

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -6,6 +6,26 @@
 //
 //===--===//
 
+//
+// !! FIXME FIXME FIXME !!
+//
+// Python APIs nearly all can return an exception.   They do this
+// by returning NULL, or -1, or some such value and setting
+// the exception state with PyErr_Set*().   Exceptions must be
+// handled before further python API functions are called.   Failure
+// to do so will result in asserts on debug builds of python.
+// It will also sometimes, but not usually result in crashes of
+// release builds.
+//
+// Nearly all the code in this header does not handle python exceptions
+// correctly.  It should all be converted to return Expected<> or
+// Error types to capture the exception.
+//
+// Everything in this file except functions that return Error or
+// Expected<> is considered deprecated and should not be
+// used in new code.  If you need to use it, fix it first.
+//
+
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 
@@ -21,11 +41,13 @@
 
 namespace lldb_private {
 
+class PythonObject;
 class PythonBytes;
 class PythonString;
 class PythonList;
 class PythonDictionary;
 class PythonInteger;
+class PythonException;
 
 class StructuredPythonObject : public StructuredData::Generic {
 public:
@@ -72,8 +94,67 @@
 // not call Py_INCREF.
 };
 
+namespace python {
+
+// Take a reference that you already own, and turn it into
+// a PythonObject.
+//
+// Most python API methods will return a +1 reference
+// if they succeed or NULL if and only if
+// they set an exception.   Use this to collect such return
+// values, after checking for NULL.
+//
+// If T is not just PythonObject, then obj must be already be
+// checked to be of the correct type.
+template  T Take(PyObject *obj) {
+  assert(obj);
+  assert(!PyErr_Occurred());
+  T thing(PyRefType::Owned, obj);
+  assert(thing.IsValid());
+  return std::move(thing);
+}
+
+// Retain a reference you have borrowed, and turn it into
+// a PythonObject.
+//
+// A minority of python APIs return a borrowed reference
+// instead of a +1.   They will also return NULL if and only
+// if they set an exception.   Use this to collect such return
+// values, after checking for NULL.
+//
+// If T is not just PythonObject, then obj must be already be
+// checked to be of the correct type.
+template  T Retain(PyObject *obj) {
+  assert(obj);
+  assert(!PyErr_Occurred());
+  T thing(PyRefType::Borrowed, obj);
+  assert(thing.IsValid());
+  return std::move(thing);
+}
+
+} // namespace python
+
 enum class PyInitialValue { Invalid, Empty };
 
+template  struct PythonFormat;
+
+template <> struct PythonFormat {
+  static constexpr char format = 'K';
+  static auto get(unsigned long long value) { return value; }
+};
+
+template <> struct PythonFormat {
+  static constexpr char format = 'L';
+  static auto get(long long value) { return value; }
+};
+
+template 
+struct PythonFormat<
+T, typename std::enable_if::value>::type> {
+  static constexpr char format = 'O';
+  static auto get(const T ) { return value.get(); }
+};
+
 class PythonObject {
 public:
   PythonObject() : m_py_obj(nullptr) {}
@@ -84,14 +165,19 @@
 
   PythonObject(const PythonObject ) : m_py_obj(nullptr) { Reset(rhs); }
 
+  PythonObject(PythonObject &) {
+m_py_obj = rhs.m_py_obj;
+rhs.m_py_obj = nullptr;
+  }
+
   virtual ~PythonObject() { Reset(); }
 
   void Reset() {
 // Avoid calling the virtual method since it's not necessary
 // to actually validate the type of the PyObject if we're
 // just setting to null.
-if (Py_IsInitialized())
-  Py_XDECREF(m_py_obj);
+if (m_py_obj && Py_IsInitialized())
+  Py_DECREF(m_py_obj);
 m_py_obj = nullptr;
   }
 
@@ -110,6 +196,8 @@
   // PyRefType doesn't make sense, and the copy constructor should be used.
   void Reset(PyRefType type, const PythonObject ) = delete;
 
+  // FIXME We shouldn't have virtual anything.  PythonObject should be a
+  // strictly pass-by-value type.
   virtual void Reset(PyRefType type, PyObject *py_obj) {
 if (py_obj == m_py_obj)
   return;
@@ -123,7 

[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-08 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

@labath anything else for this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [lldb] r374095 - Fix sign extension handling in DumpEnumValue

2019-10-08 Thread Frederic Riss via lldb-commits
Author: friss
Date: Tue Oct  8 10:59:02 2019
New Revision: 374095

URL: http://llvm.org/viewvc/llvm-project?rev=374095=rev
Log:
Fix sign extension handling in DumpEnumValue

When an enumerator has an unsigned type and its high bit set, the
code introduced in r374067 would fail to match it due to a sign
extension snafu. This commit fixes this aspec of the code and should
fix the bots.

I think it's not a complete fix though, I'll add more test coverage
and additional tweaks in a follow-up commit.

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=374095=374094=374095=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Oct  8 10:59:02 2019
@@ -9374,6 +9374,7 @@ static bool DumpEnumValue(const clang::Q
   // flags.
   for (auto enumerator : enum_decl->enumerators()) {
 uint64_t val = enumerator->getInitVal().getSExtValue();
+val = llvm::SignExtend64(val, 8*byte_size);
 if (llvm::countPopulation(val) != 1 && (val & ~covered_bits) != 0)
   can_be_bitfield = false;
 covered_bits |= val;


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


[Lldb-commits] [lldb] r374094 - exception handling in PythonDataObjects.

2019-10-08 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Tue Oct  8 10:56:18 2019
New Revision: 374094

URL: http://llvm.org/viewvc/llvm-project?rev=374094=rev
Log:
exception handling in PythonDataObjects.

Summary:
Python APIs nearly all can return an exception.   They do this
by returning NULL, or -1, or some such value and setting
the exception state with PyErr_Set*().   Exceptions must be
handled before further python API functions are called.   Failure
to do so will result in asserts on debug builds of python.
It will also sometimes, but not usually result in crashes of
release builds.

Nearly everything in PythonDataObjects.h needs to be updated
to account for this.   This patch doesn't fix everything,
but it does introduce some new methods using Expected<>
return types that are safe to use.

split off from https://reviews.llvm.org/D68188

Reviewers: JDevlieghere, jasonmolenda, labath, zturner

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h

Modified: 
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp?rev=374094=374093=374094=diff
==
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp 
(original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp 
Tue Oct  8 10:56:18 2019
@@ -18,6 +18,7 @@
 #include "lldb/Host/File.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/Log.h"
 #include "lldb/Utility/Stream.h"
 
 #include "llvm/ADT/StringSwitch.h"
@@ -28,6 +29,22 @@
 
 using namespace lldb_private;
 using namespace lldb;
+using namespace lldb_private::python;
+using llvm::Error;
+using llvm::Expected;
+
+template <> Expected python::As(Expected &) {
+  if (!obj)
+return obj.takeError();
+  return obj.get().IsTrue();
+}
+
+template <>
+Expected python::As(Expected &) {
+  if (!obj)
+return obj.takeError();
+  return obj.get().AsLongLong();
+}
 
 void StructuredPythonObject::Serialize(llvm::json::OStream ) const {
   s.value(llvm::formatv("Python Obj: {0:X}", GetValue()).str());
@@ -167,12 +184,6 @@ PythonObject PythonObject::GetAttributeV
   PyObject_GetAttr(m_py_obj, py_attr.get()));
 }
 
-bool PythonObject::IsNone() const { return m_py_obj == Py_None; }
-
-bool PythonObject::IsValid() const { return m_py_obj != nullptr; }
-
-bool PythonObject::IsAllocated() const { return IsValid() && !IsNone(); }
-
 StructuredData::ObjectSP PythonObject::CreateStructuredObject() const {
   switch (GetObjectType()) {
   case PyObjectType::Dictionary:
@@ -334,6 +345,17 @@ StructuredData::StringSP PythonByteArray
 
 // PythonString
 
+Expected PythonString::FromUTF8(llvm::StringRef string) {
+#if PY_MAJOR_VERSION >= 3
+  PyObject *str = PyUnicode_FromStringAndSize(string.data(), string.size());
+#else
+  PyObject *str = PyString_FromStringAndSize(string.data(), string.size());
+#endif
+  if (!str)
+return llvm::make_error();
+  return Take(str);
+}
+
 PythonString::PythonString(PyRefType type, PyObject *py_obj) : PythonObject() {
   Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a string
 }
@@ -342,10 +364,6 @@ PythonString::PythonString(llvm::StringR
   SetString(string);
 }
 
-PythonString::PythonString(const char *string) : PythonObject() {
-  SetString(llvm::StringRef(string));
-}
-
 PythonString::PythonString() : PythonObject() {}
 
 PythonString::~PythonString() {}
@@ -376,8 +394,12 @@ void PythonString::Reset(PyRefType type,
   // In Python 2, Don't store PyUnicode objects directly, because we need
   // access to their underlying character buffers which Python 2 doesn't
   // provide.
-  if (PyUnicode_Check(py_obj))
-result.Reset(PyRefType::Owned, PyUnicode_AsUTF8String(result.get()));
+  if (PyUnicode_Check(py_obj)) {
+PyObject *s = PyUnicode_AsUTF8String(result.get());
+if (s == NULL)
+  PyErr_Clear();
+result.Reset(PyRefType::Owned, s);
+  }
 #endif
   // Calling PythonObject::Reset(const PythonObject&) will lead to stack
   // overflow since it calls back into the virtual implementation.
@@ -385,8 +407,17 @@ void PythonString::Reset(PyRefType type,
 }
 
 llvm::StringRef PythonString::GetString() const {
+  auto s = AsUTF8();
+  if (!s) {
+llvm::consumeError(s.takeError());
+return llvm::StringRef("");
+  }
+  return s.get();
+}
+
+Expected PythonString::AsUTF8() const {
   if (!IsValid())
-return llvm::StringRef();
+return nullDeref();
 
   Py_ssize_t size;
   const char *data;
@@ -394,10 +425,16 @@ llvm::StringRef PythonString::GetString(
 #if PY_MAJOR_VERSION >= 3
   data = PyUnicode_AsUTF8AndSize(m_py_obj, 

[Lldb-commits] [PATCH] D68289: [lldb-server/android] Show more processes by relaxing some checks

2019-10-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

thanks, @labath !


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68289



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


[Lldb-commits] [PATCH] D68312: [gdb-remote] process properly effective uid

2019-10-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace closed this revision.
wallace added a comment.

already committed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68312



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


[Lldb-commits] [PATCH] D68546: remove FILE* usage from ReportEventState() and HandleProcessEvent()

2019-10-08 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D68546#1699390 , @labath wrote:

> Thanks for weighing in, Jim. My responses are inline.
>
> In D68546#1698430 , @jingham wrote:
>
> > SBProcess::ReportEventState was introduced in r112221, and SBStream was 
> > added in r114188, so Pavel's speculation seems like a reasonable one, 
> > though that was 9 years ago...
> >
> > But in the SB API's we use SBStream in a bunch of places to be more like an 
> > SBString, something you can pass to a client and they will add some data to 
> > it, and then you call GetData to get the result.  That's a not very 
> > stream-like usage.
>
>
> Why not? I think that's fairly similar to how one uses `std::ostringstream`.
>
>   std::ostringstream stream;
>   write_some_data_to(stream); // or stream << stuff;
>   std::string data = stream.str();
>
>
> I think the main non-stream like feature of SBStream is that it behaves like 
> std::ostringstream _by default_, but then it can be later converted to 
> something like std::ofstream by calling `RedirectToFile`. However, I think 
> that is something that can still be fixed, mostly..


In most of the uses of SBStream (and all the ones' I've done for the various 
scripts I've written), I would be very surprised if GetData returned nothing 
because the data had gone elsewhere.  I find myself always wanting that output. 
 That's what I meant by saying it was more string-like that stream-like.  But 
that behavior is really at the boundary between lldb & scripts, and can be 
controlled by the person providing the stream.  It is a little weird however 
that this behavior is non-explicit in SBStream.  W.R.T. below, I wonder if it 
wouldn't have been better to make the Stream output -> File behavior be 
something that has to be set at construction time and not modifiable.  It would 
be really surprising if I made an SBStream to gather a Description, and have 
somebody under the covers decide to drain the output off to a file.

> 
> 
>> In the case of HandleProcessEvent, SBDebugger uses it for HandleCommand, 
>> when it wants to dump all the stop event data to the Debugger's STDIO.  That 
>> would be less convenient with an SBStream, you'd have to make one, then 
>> Redirect it to the debugger's stdout & stderr.  That seems kind of awkward.
> 
> So, what would you say if we added a SBStream constructor taking an SBFile 
> (which would do equivalent of `SBStream::RedirectToFile`). Then all 
> HandleCommand would have to do is call `HandleProcessEvent(process, event, 
> SBStream(GetOutputFile()), SBStream(GetErrorFile()))`. I think that would be 
> fairly familiar to anyone who has worked with stream, as creating a stream 
> which uses some other object (file, fd, string, ...) as a backing store is a 
> pretty common pattern.

This would be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68546



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


[Lldb-commits] [PATCH] D68549: make ConstString allocate memory in non-tiny chunks

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I assume you experimented with many different values, and these are the best 
tradeoff?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68549



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


[Lldb-commits] [PATCH] D68549: make ConstString allocate memory in non-tiny chunks

2019-10-08 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.

This makes sense to me. We may need to make this configurable for low-memory 
hosts at some point.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68549



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


[Lldb-commits] [PATCH] D68631: ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested, take 2

2019-10-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Looks reasonable to me, but I'll defer to the people that actually know this 
code.


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

https://reviews.llvm.org/D68631



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


Re: [Lldb-commits] [PATCH] D67520: Add pretty printing of Clang "bitfield" enums

2019-10-08 Thread Frédéric Riss via lldb-commits
So I should see this on my machine, but I don’t...

> On Oct 8, 2019, at 10:06 AM, Shafik Yaghmour via Phabricator 
>  wrote:
> 
> shafik added a comment.
> 
> See the same break on green dragon as well: 
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2360/testReport/LLDB/SymbolFile_NativePDB/s_constant_cpp/
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D67520/new/
> 
> https://reviews.llvm.org/D67520
> 
> 
> 

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


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-08 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.

Cool. May be nice to put a comment on the pointer why this is safe.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [PATCH] D67520: Add pretty printing of Clang "bitfield" enums

2019-10-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

See the same break on green dragon as well: 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2360/testReport/LLDB/SymbolFile_NativePDB/s_constant_cpp/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67520



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


Re: [Lldb-commits] [PATCH] D67520: Add pretty printing of Clang "bitfield" enums

2019-10-08 Thread Frédéric Riss via lldb-commits
Taking a look

> On Oct 8, 2019, at 9:47 AM, Stella Stamenova via Phabricator 
>  wrote:
> 
> stella.stamenova added a comment.
> 
> It looks like this broke one of the tests on the Windows LLDB bot:
> 
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9628/steps/test/logs/stdio
> 
> The bot was already red because of a change from yesterday, so you probably 
> didn't get a notification.
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D67520/new/
> 
> https://reviews.llvm.org/D67520
> 
> 
> 

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


[Lldb-commits] [PATCH] D68605: ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8db229e28771: ObjectFileMachO: Replace std::map with 
llvm::DenseMap (NFC) (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68605?vs=223685=223894#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68605

Files:
  lldb/include/lldb/Utility/ConstString.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2478,8 +2478,8 @@
   std::vector N_BRAC_indexes;
   std::vector N_COMM_indexes;
   typedef std::multimap ValueToSymbolIndexMap;
-  typedef std::map NListIndexToSymbolIndexMap;
-  typedef std::map ConstNameToSymbolIndexMap;
+  typedef llvm::DenseMap NListIndexToSymbolIndexMap;
+  typedef llvm::DenseMap ConstNameToSymbolIndexMap;
   ValueToSymbolIndexMap N_FUN_addr_to_sym_idx;
   ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx;
   ConstNameToSymbolIndexMap N_GSYM_name_to_sym_idx;
@@ -2689,8 +2689,8 @@
 
 offset = 0;
 
-typedef std::map UndefinedNameToDescMap;
-typedef std::map SymbolIndexToName;
+typedef llvm::DenseMap UndefinedNameToDescMap;
+typedef llvm::DenseMap SymbolIndexToName;
 UndefinedNameToDescMap undefined_name_to_desc;
 SymbolIndexToName reexport_shlib_needs_fixup;
 
@@ -3487,15 +3487,11 @@
   // matches, then we can merge the two into just the
   // function symbol to avoid duplicate entries in
   // the symbol table
-  std::pair
-  range;
-  range =
+  auto range =
   N_FUN_addr_to_sym_idx.equal_range(nlist.n_value);
   if (range.first != range.second) {
 bool found_it = false;
-for (ValueToSymbolIndexMap::const_iterator pos =
- range.first;
+for (const auto pos = range.first;
  pos != range.second; ++pos) {
   if (sym[sym_idx].GetMangled().GetName(
   lldb::eLanguageTypeUnknown,
@@ -3536,15 +3532,11 @@
   // matches, then we can merge the two into just the
   // Static symbol to avoid duplicate entries in the
   // symbol table
-  std::pair
-  range;
-  range = N_STSYM_addr_to_sym_idx.equal_range(
+  auto range = N_STSYM_addr_to_sym_idx.equal_range(
   nlist.n_value);
   if (range.first != range.second) {
 bool found_it = false;
-for (ValueToSymbolIndexMap::const_iterator pos =
- range.first;
+for (const auto pos = range.first;
  pos != range.second; ++pos) {
   if (sym[sym_idx].GetMangled().GetName(
   lldb::eLanguageTypeUnknown,
@@ -3667,8 +3659,8 @@
   nlist_idx = 0;
 }
 
-typedef std::map UndefinedNameToDescMap;
-typedef std::map SymbolIndexToName;
+typedef llvm::DenseMap UndefinedNameToDescMap;
+typedef llvm::DenseMap SymbolIndexToName;
 UndefinedNameToDescMap undefined_name_to_desc;
 SymbolIndexToName reexport_shlib_needs_fixup;
 
Index: lldb/include/lldb/Utility/ConstString.h
===
--- lldb/include/lldb/Utility/ConstString.h
+++ lldb/include/lldb/Utility/ConstString.h
@@ -10,6 +10,7 @@
 #define liblldb_ConstString_h_
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/FormatVariadic.h"
 
 #include 
@@ -437,6 +438,14 @@
   static size_t StaticMemorySize();
 
 protected:
+  template  friend struct ::llvm::DenseMapInfo;
+  /// Only used by DenseMapInfo.
+  static ConstString FromStringPoolPointer(const char *ptr) {
+ConstString s;
+s.m_string = ptr;
+return s;
+  };
+
   // Member variables
   const char *m_string;
 };
@@ -451,6 +460,27 @@
   static void format(const lldb_private::ConstString , llvm::raw_ostream ,
  llvm::StringRef Options);
 };
+
+/// DenseMapInfo implementation.
+/// \{
+template <> 

[Lldb-commits] [lldb] r374084 - ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

2019-10-08 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Oct  8 09:59:24 2019
New Revision: 374084

URL: http://llvm.org/viewvc/llvm-project?rev=374084=rev
Log:
ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

This makes parsing the symbol table of clang marginally faster. (Hashtable 
versus tree).

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

Modified:
lldb/trunk/include/lldb/Utility/ConstString.h
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/include/lldb/Utility/ConstString.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ConstString.h?rev=374084=374083=374084=diff
==
--- lldb/trunk/include/lldb/Utility/ConstString.h (original)
+++ lldb/trunk/include/lldb/Utility/ConstString.h Tue Oct  8 09:59:24 2019
@@ -10,6 +10,7 @@
 #define liblldb_ConstString_h_
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/FormatVariadic.h"
 
 #include 
@@ -437,6 +438,14 @@ public:
   static size_t StaticMemorySize();
 
 protected:
+  template  friend struct ::llvm::DenseMapInfo;
+  /// Only used by DenseMapInfo.
+  static ConstString FromStringPoolPointer(const char *ptr) {
+ConstString s;
+s.m_string = ptr;
+return s;
+  };
+
   // Member variables
   const char *m_string;
 };
@@ -451,6 +460,27 @@ template <> struct format_provider struct DenseMapInfo {
+  static inline lldb_private::ConstString getEmptyKey() {
+return lldb_private::ConstString::FromStringPoolPointer(
+DenseMapInfo::getEmptyKey());
+  }
+  static inline lldb_private::ConstString getTombstoneKey() {
+return lldb_private::ConstString::FromStringPoolPointer(
+DenseMapInfo::getTombstoneKey());
+  }
+  static unsigned getHashValue(lldb_private::ConstString val) {
+return DenseMapInfo::getHashValue(val.m_string);
+  }
+  static bool isEqual(lldb_private::ConstString LHS,
+  lldb_private::ConstString RHS) {
+return LHS == RHS;
+  }
+};
+/// \}
 }
 
 #endif // liblldb_ConstString_h_

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=374084=374083=374084=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Oct  8 
09:59:24 2019
@@ -2478,8 +2478,8 @@ size_t ObjectFileMachO::ParseSymtab() {
   std::vector N_BRAC_indexes;
   std::vector N_COMM_indexes;
   typedef std::multimap ValueToSymbolIndexMap;
-  typedef std::map NListIndexToSymbolIndexMap;
-  typedef std::map ConstNameToSymbolIndexMap;
+  typedef llvm::DenseMap NListIndexToSymbolIndexMap;
+  typedef llvm::DenseMap ConstNameToSymbolIndexMap;
   ValueToSymbolIndexMap N_FUN_addr_to_sym_idx;
   ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx;
   ConstNameToSymbolIndexMap N_GSYM_name_to_sym_idx;
@@ -2689,8 +2689,8 @@ size_t ObjectFileMachO::ParseSymtab() {
 
 offset = 0;
 
-typedef std::map UndefinedNameToDescMap;
-typedef std::map SymbolIndexToName;
+typedef llvm::DenseMap 
UndefinedNameToDescMap;
+typedef llvm::DenseMap SymbolIndexToName;
 UndefinedNameToDescMap undefined_name_to_desc;
 SymbolIndexToName reexport_shlib_needs_fixup;
 
@@ -3487,15 +3487,11 @@ size_t ObjectFileMachO::ParseSymtab() {
   // matches, then we can merge the two into just the
   // function symbol to avoid duplicate entries in
   // the symbol table
-  std::pair
-  range;
-  range =
+  auto range =
   N_FUN_addr_to_sym_idx.equal_range(nlist.n_value);
   if (range.first != range.second) {
 bool found_it = false;
-for (ValueToSymbolIndexMap::const_iterator pos =
- range.first;
+for (const auto pos = range.first;
  pos != range.second; ++pos) {
   if (sym[sym_idx].GetMangled().GetName(
   lldb::eLanguageTypeUnknown,
@@ -3536,15 +3532,11 @@ size_t ObjectFileMachO::ParseSymtab() {
   // matches, then we can merge the two into just the
   // Static symbol to avoid duplicate entries in the
   // symbol table
-  std::pair
-  range;
-  range = N_STSYM_addr_to_sym_idx.equal_range(
+  auto range = 

[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-08 Thread Cameron via Phabricator via lldb-commits
cameron314 added a comment.

@aprantl No. A weak pointer would still fix the memory leak, but it's safe to 
use a raw pointer because we only reference objects which are in the same 
cluster as the synthetic children front-end itself. The other (leak-free) 
synthetic front-ends do this as well. We want shared/weak pointers externally, 
but not within the cluster.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [PATCH] D67520: Add pretty printing of Clang "bitfield" enums

2019-10-08 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

It looks like this broke one of the tests on the Windows LLDB bot:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9628/steps/test/logs/stdio

The bot was already red because of a change from yesterday, so you probably 
didn't get a notification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67520



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


[Lldb-commits] [PATCH] D68612: [CMake] Track test dependencies with add_lldb_test_dependency

2019-10-08 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

On Linux OS (Fedora 30 x86_64) with GIT monorepo:
After rL374000 :

  #rm -rf *
  cmake ~/redhat/llvm-monorepo2/llvm/ -DCMAKE_BUILD_TYPE=Release  
-DLLVM_USE_LINKER=gold -DLLVM_ENABLE_PROJECTS="lldb;clang;lld"  
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ 
-DLLVM_ENABLE_ASSERTIONS=ON
  make check-lldb
  ...
  llvm-lit: 
/home/jkratoch/redhat/llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:134: 
fatal: Did not find count in 
/home/jkratoch/redhat/llvm-monorepo2-clangassert/./bin

After rL373996  (this patch):

  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:127: note: Did not 
find obj2yaml in 
llvm-monorepo2-clangassert/./bin:llvm-monorepo2-clangassert/./bin
  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:127: note: Did not 
find llvm-pdbutil in 
llvm-monorepo2-clangassert/./bin:llvm-monorepo2-clangassert/./bin
  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:127: note: Did not 
find llvm-mc in 
llvm-monorepo2-clangassert/./bin:llvm-monorepo2-clangassert/./bin
  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:127: note: Did not 
find llvm-readobj in 
llvm-monorepo2-clangassert/./bin:llvm-monorepo2-clangassert/./bin
  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:127: note: Did not 
find llvm-objdump in 
llvm-monorepo2-clangassert/./bin:llvm-monorepo2-clangassert/./bin
  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:127: note: Did not 
find llvm-objcopy in 
llvm-monorepo2-clangassert/./bin:llvm-monorepo2-clangassert/./bin
  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:127: note: Did not 
find lli in llvm-monorepo2-clangassert/./bin:llvm-monorepo2-clangassert/./bin
  llvm-lit: llvm-monorepo2/llvm/utils/lit/lit/llvm/config.py:169: fatal: Could 
not run process ['llvm-monorepo2-clangassert/./bin/llvm-config', 
'--assertion-mode', '--build-mode', '--targets-built']

Surprisingly a Fedora buildbot does not have this problem 
.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68612



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


[Lldb-commits] [PATCH] D68609: Replace regex match with rfind (NFCish)

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea6377505435: Replace regex match with rfind (NFCish) 
(authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68609?vs=223695=223887#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68609

Files:
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/source/Symbol/ObjectFile.cpp


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -19,7 +19,6 @@
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Timer.h"
 #include "lldb/lldb-private.h"
 
@@ -83,9 +82,8 @@
 
   if (!data_sp || data_sp->GetByteSize() == 0) {
 // Check for archive file with format "/path/to/archive.a(object.o)"
-char path_with_object[PATH_MAX * 2];
-module_sp->GetFileSpec().GetPath(path_with_object,
- sizeof(path_with_object));
+llvm::SmallString<256> path_with_object;
+module_sp->GetFileSpec().GetPath(path_with_object);
 
 ConstString archive_object;
 const bool must_exist = true;
@@ -571,21 +569,22 @@
   }
 }
 
-bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object,
+bool ObjectFile::SplitArchivePathWithObject(llvm::StringRef path_with_object,
 FileSpec _file,
 ConstString _object,
 bool must_exist) {
-  llvm::SmallVector matches;
-  RegularExpression g_object_regex(llvm::StringRef("(.*)\\(([^\\)]+)\\)$"));
-  if 
(g_object_regex.Execute(llvm::StringRef::withNullAsEmpty(path_with_object),
- )) {
-std::string path = matches[1].str();
-std::string obj = matches[2].str();
-archive_file.SetFile(path, FileSpec::Style::native);
-archive_object.SetCString(obj.c_str());
-return !(must_exist && !FileSystem::Instance().Exists(archive_file));
-  }
-  return false;
+  size_t len = path_with_object.size();
+  if (len < 2 || path_with_object.back() != ')')
+return false;
+  llvm::StringRef archive = path_with_object.substr(0, 
path_with_object.rfind('('));
+  if (archive.empty())
+return false;
+  llvm::StringRef object = path_with_object.substr(archive.size() + 
1).drop_back();
+  archive_file.SetFile(archive, FileSpec::Style::native);
+  if (must_exist && !FileSystem::Instance().Exists(archive_file))
+return false;
+  archive_object.SetString(object);
+  return true;
 }
 
 void ObjectFile::ClearSymtab() {
Index: lldb/include/lldb/Symbol/ObjectFile.h
===
--- lldb/include/lldb/Symbol/ObjectFile.h
+++ lldb/include/lldb/Symbol/ObjectFile.h
@@ -201,7 +201,7 @@
   /// \b false otherwise and \a archive_file and \a archive_object
   /// are guaranteed to be remain unchanged.
   static bool SplitArchivePathWithObject(
-  const char *path_with_object, lldb_private::FileSpec _file,
+  llvm::StringRef path_with_object, lldb_private::FileSpec _file,
   lldb_private::ConstString _object, bool must_exist);
 
   // LLVM RTTI support


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -19,7 +19,6 @@
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Timer.h"
 #include "lldb/lldb-private.h"
 
@@ -83,9 +82,8 @@
 
   if (!data_sp || data_sp->GetByteSize() == 0) {
 // Check for archive file with format "/path/to/archive.a(object.o)"
-char path_with_object[PATH_MAX * 2];
-module_sp->GetFileSpec().GetPath(path_with_object,
- sizeof(path_with_object));
+llvm::SmallString<256> path_with_object;
+module_sp->GetFileSpec().GetPath(path_with_object);
 
 ConstString archive_object;
 const bool must_exist = true;
@@ -571,21 +569,22 @@
   }
 }
 
-bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object,
+bool ObjectFile::SplitArchivePathWithObject(llvm::StringRef path_with_object,
 FileSpec _file,
 ConstString _object,
 bool must_exist) {
-  llvm::SmallVector matches;
-  RegularExpression g_object_regex(llvm::StringRef("(.*)\\(([^\\)]+)\\)$"));
-  if 

[Lldb-commits] [PATCH] D68597: Replace static const StringRef with StringRef (NFC)

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG917b8df0e531: Replace static const StringRef with StringRef 
(NFC) (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68597?vs=223664=223886#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68597

Files:
  lldb/source/Interpreter/OptionValueBoolean.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2059,9 +2059,9 @@
   uint32_t i;
   FileSpecList dylib_files;
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS));
-  static const llvm::StringRef g_objc_v2_prefix_class("_OBJC_CLASS_$_");
-  static const llvm::StringRef 
g_objc_v2_prefix_metaclass("_OBJC_METACLASS_$_");
-  static const llvm::StringRef g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
+  llvm::StringRef g_objc_v2_prefix_class("_OBJC_CLASS_$_");
+  llvm::StringRef g_objc_v2_prefix_metaclass("_OBJC_METACLASS_$_");
+  llvm::StringRef g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
 
   for (i = 0; i < m_header.ncmds; ++i) {
 const lldb::offset_t cmd_offset = offset;
@@ -3314,13 +3314,13 @@
 if (symbol_name) {
   llvm::StringRef symbol_name_ref(symbol_name);
   if (symbol_name_ref.startswith("_OBJC_")) {
-static const llvm::StringRef
+llvm::StringRef
 g_objc_v2_prefix_class(
 "_OBJC_CLASS_$_");
-static const llvm::StringRef
+llvm::StringRef
 g_objc_v2_prefix_metaclass(
 "_OBJC_METACLASS_$_");
-static const llvm::StringRef
+llvm::StringRef
 g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
 if (symbol_name_ref.startswith(
 g_objc_v2_prefix_class)) {
@@ -3370,7 +3370,7 @@
   type = eSymbolTypeRuntime;
   if (symbol_name && symbol_name[0] == '.') {
 llvm::StringRef symbol_name_ref(symbol_name);
-static const llvm::StringRef
+llvm::StringRef
 
g_objc_v1_prefix_class(".objc_class_name_");
 if (symbol_name_ref.startswith(
 g_objc_v1_prefix_class)) {
@@ -4206,11 +4206,11 @@
   if (symbol_name) {
 llvm::StringRef symbol_name_ref(symbol_name);
 if (symbol_name_ref.startswith("_OBJC_")) {
-  static const llvm::StringRef g_objc_v2_prefix_class(
+  llvm::StringRef g_objc_v2_prefix_class(
   "_OBJC_CLASS_$_");
-  static const llvm::StringRef g_objc_v2_prefix_metaclass(
+  llvm::StringRef g_objc_v2_prefix_metaclass(
   "_OBJC_METACLASS_$_");
-  static const llvm::StringRef g_objc_v2_prefix_ivar(
+  llvm::StringRef g_objc_v2_prefix_ivar(
   "_OBJC_IVAR_$_");
   if (symbol_name_ref.startswith(g_objc_v2_prefix_class)) {
 symbol_name_non_abi_mangled = symbol_name + 1;
@@ -4250,7 +4250,7 @@
 type = eSymbolTypeRuntime;
 if (symbol_name && symbol_name[0] == '.') {
   llvm::StringRef symbol_name_ref(symbol_name);
-  static const llvm::StringRef g_objc_v1_prefix_class(
+  llvm::StringRef g_objc_v1_prefix_class(
   ".objc_class_name_");
   if (symbol_name_ref.startswith(g_objc_v1_prefix_class)) {
 symbol_name_non_abi_mangled = symbol_name;
Index: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2029,8 +2029,8 @@
   if (name_cstr) {
 llvm::StringRef 

[Lldb-commits] [PATCH] D68595: Remove constructor and unused function (NFC)

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbde5a6a45a3c: Remove constructor and unused method (NFC). 
(authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68595

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1895,18 +1895,6 @@
 };
 
 struct TrieEntry {
-  TrieEntry()
-  : name(), address(LLDB_INVALID_ADDRESS), flags(0), other(0),
-import_name() {}
-
-  void Clear() {
-name.Clear();
-address = LLDB_INVALID_ADDRESS;
-flags = 0;
-other = 0;
-import_name.Clear();
-  }
-
   void Dump() const {
 printf("0x%16.16llx 0x%16.16llx 0x%16.16llx \"%s\"",
static_cast(address),
@@ -1918,9 +1906,9 @@
   printf("\n");
   }
   ConstString name;
-  uint64_t address;
-  uint64_t flags;
-  uint64_t other;
+  uint64_t address = LLDB_INVALID_ADDRESS;
+  uint64_t flags = 0;
+  uint64_t other = 0;
   ConstString import_name;
 };
 


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1895,18 +1895,6 @@
 };
 
 struct TrieEntry {
-  TrieEntry()
-  : name(), address(LLDB_INVALID_ADDRESS), flags(0), other(0),
-import_name() {}
-
-  void Clear() {
-name.Clear();
-address = LLDB_INVALID_ADDRESS;
-flags = 0;
-other = 0;
-import_name.Clear();
-  }
-
   void Dump() const {
 printf("0x%16.16llx 0x%16.16llx 0x%16.16llx \"%s\"",
static_cast(address),
@@ -1918,9 +1906,9 @@
   printf("\n");
   }
   ConstString name;
-  uint64_t address;
-  uint64_t flags;
-  uint64_t other;
+  uint64_t address = LLDB_INVALID_ADDRESS;
+  uint64_t flags = 0;
+  uint64_t other = 0;
   ConstString import_name;
 };
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68605: ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl abandoned this revision.
aprantl added a comment.

Pavel correctly pointed out that this isn't necessarily correct, because the 
addresses could conflict with the Tombstone/Empty keys.


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

https://reviews.llvm.org/D68605



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


[Lldb-commits] [lldb] r374081 - Replace static const StringRef with StringRef (NFC)

2019-10-08 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Oct  8 09:29:36 2019
New Revision: 374081

URL: http://llvm.org/viewvc/llvm-project?rev=374081=rev
Log:
Replace static const StringRef with StringRef (NFC)

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

Modified:
lldb/trunk/source/Interpreter/OptionValueBoolean.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Interpreter/OptionValueBoolean.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueBoolean.cpp?rev=374081=374080=374081=diff
==
--- lldb/trunk/source/Interpreter/OptionValueBoolean.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueBoolean.cpp Tue Oct  8 09:29:36 
2019
@@ -73,10 +73,10 @@ lldb::OptionValueSP OptionValueBoolean::
 
 void OptionValueBoolean::AutoComplete(CommandInterpreter ,
   CompletionRequest ) {
-  static const llvm::StringRef g_autocomplete_entries[] = {
-  "true", "false", "on", "off", "yes", "no", "1", "0"};
+  llvm::StringRef autocomplete_entries[] = {"true", "false", "on", "off",
+"yes",  "no","1",  "0"};
 
-  auto entries = llvm::makeArrayRef(g_autocomplete_entries);
+  auto entries = llvm::makeArrayRef(autocomplete_entries);
 
   // only suggest "true" or "false" by default
   if (request.GetCursorArgumentPrefix().empty())

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=374081=374080=374081=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 Tue Oct  8 09:29:36 2019
@@ -2029,8 +2029,8 @@ lldb::addr_t AppleObjCRuntimeV2::LookupR
   if (name_cstr) {
 llvm::StringRef name_strref(name_cstr);
 
-static const llvm::StringRef ivar_prefix("OBJC_IVAR_$_");
-static const llvm::StringRef class_prefix("OBJC_CLASS_$_");
+llvm::StringRef ivar_prefix("OBJC_IVAR_$_");
+llvm::StringRef class_prefix("OBJC_CLASS_$_");
 
 if (name_strref.startswith(ivar_prefix)) {
   llvm::StringRef ivar_skipped_prefix =

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=374081=374080=374081=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Oct  8 
09:29:36 2019
@@ -2059,9 +2059,9 @@ size_t ObjectFileMachO::ParseSymtab() {
   uint32_t i;
   FileSpecList dylib_files;
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS));
-  static const llvm::StringRef g_objc_v2_prefix_class("_OBJC_CLASS_$_");
-  static const llvm::StringRef 
g_objc_v2_prefix_metaclass("_OBJC_METACLASS_$_");
-  static const llvm::StringRef g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
+  llvm::StringRef g_objc_v2_prefix_class("_OBJC_CLASS_$_");
+  llvm::StringRef g_objc_v2_prefix_metaclass("_OBJC_METACLASS_$_");
+  llvm::StringRef g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
 
   for (i = 0; i < m_header.ncmds; ++i) {
 const lldb::offset_t cmd_offset = offset;
@@ -3314,13 +3314,13 @@ size_t ObjectFileMachO::ParseSymtab() {
 if (symbol_name) {
   llvm::StringRef symbol_name_ref(symbol_name);
   if (symbol_name_ref.startswith("_OBJC_")) {
-static const llvm::StringRef
+llvm::StringRef
 g_objc_v2_prefix_class(
 "_OBJC_CLASS_$_");
-static const llvm::StringRef
+llvm::StringRef
 g_objc_v2_prefix_metaclass(
 "_OBJC_METACLASS_$_");
-static const llvm::StringRef
+llvm::StringRef
 g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
 if (symbol_name_ref.startswith(
 g_objc_v2_prefix_class)) {
@@ -3370,7 +3370,7 @@ size_t ObjectFileMachO::ParseSymtab() {
   type = eSymbolTypeRuntime;
 

[Lldb-commits] [lldb] r374082 - Replace regex match with rfind (NFCish)

2019-10-08 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Oct  8 09:29:39 2019
New Revision: 374082

URL: http://llvm.org/viewvc/llvm-project?rev=374082=rev
Log:
Replace regex match with rfind (NFCish)

This change is mostly performance-neutral since our regex engine is
fast, but it's IMHO slightly more readable.  Also, matching matching
parenthesis is not a great match for regular expressions.

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

Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=374082=374081=374082=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Oct  8 09:29:39 2019
@@ -201,7 +201,7 @@ public:
   /// \b false otherwise and \a archive_file and \a archive_object
   /// are guaranteed to be remain unchanged.
   static bool SplitArchivePathWithObject(
-  const char *path_with_object, lldb_private::FileSpec _file,
+  llvm::StringRef path_with_object, lldb_private::FileSpec _file,
   lldb_private::ConstString _object, bool must_exist);
 
   // LLVM RTTI support

Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=374082=374081=374082=diff
==
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Tue Oct  8 09:29:39 2019
@@ -19,7 +19,6 @@
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Timer.h"
 #include "lldb/lldb-private.h"
 
@@ -83,9 +82,8 @@ ObjectFile::FindPlugin(const lldb::Modul
 
   if (!data_sp || data_sp->GetByteSize() == 0) {
 // Check for archive file with format "/path/to/archive.a(object.o)"
-char path_with_object[PATH_MAX * 2];
-module_sp->GetFileSpec().GetPath(path_with_object,
- sizeof(path_with_object));
+llvm::SmallString<256> path_with_object;
+module_sp->GetFileSpec().GetPath(path_with_object);
 
 ConstString archive_object;
 const bool must_exist = true;
@@ -571,21 +569,22 @@ size_t ObjectFile::ReadSectionData(Secti
   }
 }
 
-bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object,
+bool ObjectFile::SplitArchivePathWithObject(llvm::StringRef path_with_object,
 FileSpec _file,
 ConstString _object,
 bool must_exist) {
-  llvm::SmallVector matches;
-  RegularExpression g_object_regex(llvm::StringRef("(.*)\\(([^\\)]+)\\)$"));
-  if 
(g_object_regex.Execute(llvm::StringRef::withNullAsEmpty(path_with_object),
- )) {
-std::string path = matches[1].str();
-std::string obj = matches[2].str();
-archive_file.SetFile(path, FileSpec::Style::native);
-archive_object.SetCString(obj.c_str());
-return !(must_exist && !FileSystem::Instance().Exists(archive_file));
-  }
-  return false;
+  size_t len = path_with_object.size();
+  if (len < 2 || path_with_object.back() != ')')
+return false;
+  llvm::StringRef archive = path_with_object.substr(0, 
path_with_object.rfind('('));
+  if (archive.empty())
+return false;
+  llvm::StringRef object = path_with_object.substr(archive.size() + 
1).drop_back();
+  archive_file.SetFile(archive, FileSpec::Style::native);
+  if (must_exist && !FileSystem::Instance().Exists(archive_file))
+return false;
+  archive_object.SetString(object);
+  return true;
 }
 
 void ObjectFile::ClearSymtab() {


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


[Lldb-commits] [lldb] r374080 - Remove constructor and unused method (NFC).

2019-10-08 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Oct  8 09:29:33 2019
New Revision: 374080

URL: http://llvm.org/viewvc/llvm-project?rev=374080=rev
Log:
Remove constructor and unused method (NFC).

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

Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=374080=374079=374080=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Oct  8 
09:29:33 2019
@@ -1895,18 +1895,6 @@ protected:
 };
 
 struct TrieEntry {
-  TrieEntry()
-  : name(), address(LLDB_INVALID_ADDRESS), flags(0), other(0),
-import_name() {}
-
-  void Clear() {
-name.Clear();
-address = LLDB_INVALID_ADDRESS;
-flags = 0;
-other = 0;
-import_name.Clear();
-  }
-
   void Dump() const {
 printf("0x%16.16llx 0x%16.16llx 0x%16.16llx \"%s\"",
static_cast(address),
@@ -1918,9 +1906,9 @@ struct TrieEntry {
   printf("\n");
   }
   ConstString name;
-  uint64_t address;
-  uint64_t flags;
-  uint64_t other;
+  uint64_t address = LLDB_INVALID_ADDRESS;
+  uint64_t flags = 0;
+  uint64_t other = 0;
   ConstString import_name;
 };
 


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


[Lldb-commits] [PATCH] D68354: [platform process list] add a flag for showing the processes of all users

2019-10-08 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

I reverted this change b/c the green dragon bots have been red for too long.

When you fix the problem please make sure you add

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

to your commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68354



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


[Lldb-commits] [PATCH] D68558: [Testsuite] Get rid of most of the recursive shared library Makefiles

2019-10-08 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3fb4e49a68f5: [Testsuite] Get rid of most of the recursive 
shared library Makefiles (authored by friss).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68558

Files:
  lldb/packages/Python/lldbsuite/test/commands/expression/top-level/Makefile
  lldb/packages/Python/lldbsuite/test/commands/expression/top-level/dummy.mk
  lldb/packages/Python/lldbsuite/test/commands/target/create-deps/Makefile
  lldb/packages/Python/lldbsuite/test/commands/target/create-deps/a.mk
  lldb/packages/Python/lldbsuite/test/functionalities/exec/Makefile
  lldb/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk
  lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/Makefile
  lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.mk
  lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile
  lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk
  lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk
  lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk
  lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk
  lldb/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
  lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile
  lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk
  lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk
  lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.mk
  
lldb/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.mk
  lldb/packages/Python/lldbsuite/test/macosx/lc-note/kern-ver-str/Makefile
  
lldb/packages/Python/lldbsuite/test/macosx/lc-note/kern-ver-str/create-empty-corefile.mk
  lldb/packages/Python/lldbsuite/test/macosx/macabi/Makefile
  lldb/packages/Python/lldbsuite/test/macosx/macabi/dylib.mk
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk

Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-LIB_PREFIX := svr4lib
-
-DYLIB_NAME := $(LIB_PREFIX)_b\"
-DYLIB_CXX_SOURCES := $(LIB_PREFIX)_b_quote.cpp
-DYLIB_ONLY := YES
-
-include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-LIB_PREFIX := svr4lib
-
-DYLIB_NAME := $(LIB_PREFIX)_a
-DYLIB_CXX_SOURCES := $(LIB_PREFIX)_a.cpp
-DYLIB_ONLY := YES
-
-include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile
@@ -1,15 +1,19 @@
 LIB_PREFIX := svr4lib
-LD_EXTRAS := -L. -l$(LIB_PREFIX)_a -l$(LIB_PREFIX)_b\"
+LD_EXTRAS := -L. -lsvr4lib_a -lsvr4lib_b\"
 CXX_SOURCES := main.cpp
 USE_LIBDL := 1
 MAKE_DSYM := NO
 
-include Makefile.rules
+a.out: svr4lib_a svr4lib_b_quote
 
-a.out: $(LIB_PREFIX)_a $(LIB_PREFIX)_b_quote
+include Makefile.rules
 
-svr4lib_%:
-	$(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f "$(SRCDIR)/$(LIB_PREFIX)_$*.mk"
+svr4lib_a:
+	$(MAKE) -f $(MAKEFILE_RULES) \
+		DYLIB_NAME=svr4lib_a DYLIB_CXX_SOURCES=svr4lib_a.cpp \
+		DYLIB_ONLY=YES
 
-clean::
-	$(MAKE) -f $(SRCDIR)/$(LIB_PREFIX)_a.mk clean
+svr4lib_b_quote:
+	$(MAKE) -f $(MAKEFILE_RULES) \
+		DYLIB_NAME=svr4lib_b\\\" DYLIB_CXX_SOURCES=svr4lib_b_quote.cpp \
+		DYLIB_ONLY=YES
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -36,7 +36,8 @@
 
 SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))
 BUILDDIR := $(shell pwd)
-THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))
+MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST))
+THIS_FILE_DIR := $(shell dirname $(MAKEFILE_RULES))
 LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 
 

[Lldb-commits] [lldb] r374077 - Revert "[platform process list] add a flag for showing the processes of all users"

2019-10-08 Thread Shafik Yaghmour via lldb-commits
Author: shafik
Date: Tue Oct  8 09:24:28 2019
New Revision: 374077

URL: http://llvm.org/viewvc/llvm-project?rev=374077=rev
Log:
Revert "[platform process list] add a flag for showing the processes of all 
users"

This reverts commit 080f35fb875f52c924ee37ed4d56a51fe7056afa.

 Conflicts:

packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py

Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py?rev=374076=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
 (removed)
@@ -1,38 +0,0 @@
-import lldb
-import binascii
-import os
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
-
-class TestPlatformClient(GDBRemoteTestBase):
-
-def test_process_list(self):
-"""Test connecting to a remote linux platform"""
-
-class MyResponder(MockGDBServerResponder):
-def qfProcessInfo(self, packet):
-if "all_users:1" in packet:
-return "pid:10;ppid:1;uid:2;gid:3;euid:4;egid:5;name:" + 
binascii.hexlify("/a/process") + ";args:"
-else:
-return "E04"
-
-self.server.responder = MyResponder()
-
-self.runCmd("platform select remote-linux")
-
-try:
-self.runCmd("platform connect connect://localhost:%d" %
-self.server.port)
-self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
-self.expect("platform process list -x",
-startstr="1 matching process was found", 
endstr="process" + os.linesep)
-self.expect("platform process list -xv",
-substrs=[
-"PIDPARENT USER   GROUP  EFF USER   
EFF GROUP",
-"10 1  2  3  4  
5"])
-self.expect("platform process list",
-error="error: no processes were found on the 
\"remote-linux\" platform")
-finally:
-self.runCmd("platform disconnect")

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py?rev=374077=374076=374077=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
 Tue Oct  8 09:24:28 2019
@@ -160,34 +160,9 @@ class MockGDBServerResponder:
 return self.QListThreadsInStopReply()
 if packet.startswith("qMemoryRegionInfo:"):
 return self.qMemoryRegionInfo()
-if packet == "qQueryGDBServer":
-return self.qQueryGDBServer()
-if packet == "qHostInfo":
-return self.qHostInfo()
-if packet == "qGetWorkingDir":
-return self.qGetWorkingDir()
-if packet == "qsProcessInfo":
-return self.qsProcessInfo()
-if packet.startswith("qfProcessInfo"):
-return self.qfProcessInfo(packet)
 
 return self.other(packet)
 
-def qsProcessInfo(self):
-return "E04"
-
-def qfProcessInfo(self, packet):
-raise "E04"
-
-def qGetWorkingDir(self):
-return "2f"
-
-def qHostInfo(self):
-return "ptrsize:8;endian:little;"
-
-def qQueryGDBServer(self):
-return "E04"
-
 def interrupt(self):
 raise self.UnexpectedPacketException()
 
@@ -196,7 +171,7 @@ class MockGDBServerResponder:
 
 def vCont(self, packet):
 raise self.UnexpectedPacketException()
-
+
 def readRegisters(self):
 return "" * self.registerCount
 
@@ -450,6 +425,7 @@ class MockGDBServer:
 class InvalidPacketException(Exception):
 pass
 
+
 class GDBRemoteTestBase(TestBase):
 """
 Base class for GDB client tests.

Modified: 

[Lldb-commits] [lldb] r374076 - [Testsuite] Get rid of most of the recursive shared library Makefiles

2019-10-08 Thread Frederic Riss via lldb-commits
Author: friss
Date: Tue Oct  8 09:23:28 2019
New Revision: 374076

URL: http://llvm.org/viewvc/llvm-project?rev=374076=rev
Log:
[Testsuite] Get rid of most of the recursive shared library Makefiles

Most of the secondary Makefiles we have are just a couple variable
definitions and then an include of Makefile.rules. This patch removes
most of the secondary Makefiles and replaces them with a direct
invocation of Makefile.rules in the main Makefile. The specificities
of each sub-build are listed right there on the recursive $(MAKE)
call. All the variables that matter are being passed automagically by
make as they have been passed on the command line. The only things you
need to specify are the variables customizating the Makefile.rules
logic for each image.

This patch also removes most of the clean logic from those Makefiles
and from Makefile.rules. The clean rule is not required anymore now
that we run the testsuite in a separate build directory that is wiped
with each run. The patch leaves a very crude version of clean in
Makefile.rules which removes everything inside of $(BUILDDIR). It does
this only when the $(BUILDDIR) looks like a sub-directory of our
standard testsuite build directory to be extra safe.

Reviewers: aprantl, labath

Subscribers: lldb-commits

Tags: #lldb

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

Removed:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/dummy.mk
lldb/trunk/packages/Python/lldbsuite/test/commands/target/create-deps/a.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk

lldb/trunk/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.mk

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.mk

lldb/trunk/packages/Python/lldbsuite/test/macosx/lc-note/kern-ver-str/create-empty-corefile.mk
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/dylib.mk

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk
Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/target/create-deps/Makefile
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile

lldb/trunk/packages/Python/lldbsuite/test/macosx/lc-note/kern-ver-str/Makefile
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/Makefile
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/Makefile?rev=374076=374075=374076=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/Makefile
 Tue Oct  8 09:23:28 2019
@@ -1,11 +1,10 @@
 CXX_SOURCES := main.cpp test.cpp
 
-include Makefile.rules
+all: dummy
 
-a.out: dummy
+include Makefile.rules
 
-dummy:
-   $(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk
+dummy: dummy.cpp
+   $(MAKE) -f $(MAKEFILE_RULES) \
+   CXX_SOURCES=dummy.cpp EXE=dummy
 
-clean::
-   $(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk clean

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/dummy.mk
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/top-level/dummy.mk?rev=374075=auto
==
--- 

[Lldb-commits] [PATCH] D68638: [lldb] Avoid resource leak

2019-10-08 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d7fb29914e3: [lldb] Avoid resource leak (authored by kwk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68638

Files:
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp


Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -92,7 +92,7 @@
   depth = (lldb::SearchDepth) depth_as_int;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
-  StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+  StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
 GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {


Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -92,7 +92,7 @@
   depth = (lldb::SearchDepth) depth_as_int;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
-  StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+  StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
 GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Disclaimer: I'm not familiar with this code. Would it be safe/better to store a 
weak pointer instead of a raw pointer?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [lldb] r374071 - [lldb] Avoid resource leak

2019-10-08 Thread Konrad Kleine via lldb-commits
Author: kwk
Date: Tue Oct  8 08:56:02 2019
New Revision: 374071

URL: http://llvm.org/viewvc/llvm-project?rev=374071=rev
Log:
[lldb] Avoid resource leak

Summary:
Before the pointer variable `args_dict` was assigned the result of an
allocation with `new` and then `args_dict` is passed to
`GetValueForKeyAsDictionary` which immediatly and unconditionally
assigns `args_dict` to `nullptr`:

```
bool GetValueForKeyAsDictionary(llvm::StringRef key,
Dictionary *) const {
  result = nullptr;
```

This caused a memory leak which was found in my coverity scan instance
under CID 224753: https://scan.coverity.com/projects/kwk-llvm-project.

Reviewers: jankratochvil, teemperor

Reviewed By: teemperor

Subscribers: teemperor, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp?rev=374071=374070=374071=diff
==
--- lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp Tue Oct  8 
08:56:02 2019
@@ -92,7 +92,7 @@ BreakpointResolverScripted::CreateFromSt
   depth = (lldb::SearchDepth) depth_as_int;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
-  StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+  StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
 GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {


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


[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-08 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd added inline comments.



Comment at: lit/CMakeLists.txt:64
   )
+if(NOT LLDB_BUILT_STANDALONE)
+  list(APPEND LLDB_TEST_DEPS llvm-strip)

JDevlieghere wrote:
> xiaobai wrote:
> > why not `if(TARGET llvm-strip)`? I think that expresses the intent more 
> > cleanly (and conforms to the existing pattern).
> I actually ran into an issue with that today, we had the following code in 
> the top-level CMake list:
> 
> ```  
> if(TARGET dsymutil)
> add_lldb_test_dependency(dsymutil)
>   endif()
> ```
> Nevertheless, `ninja lldb-test-deps` didn't build dsymutil.
> 
> ```
> $ /V/J/l/build-ra> ninja lldb-test-deps
> [1/1] Python script sym-linking LLDB Python API
> $ /V/J/l/build-ra> ninja dsymutil
> [1/1] Linking CXX executable bin/dsymutil
> ```
My slight preference for this is to actually have a good way to identify that 
this can be simplified once unified builds are the only supported build style.  
I suppose a comment along with the `if(TARGET)` check would work too.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68614



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


[Lldb-commits] [PATCH] D68647: Simplify LZMA decoding by using ArrayRef::take_back

2019-10-08 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
kwk marked an inline comment as done.
Closed by commit rG8970d88b65f0: Simplify LZMA decoding by using 
ArrayRef::take_back (authored by kwk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68647

Files:
  lldb/source/Host/common/LZMA.cpp


Index: lldb/source/Host/common/LZMA.cpp
===
--- lldb/source/Host/common/LZMA.cpp
+++ lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-  , InputBuffer.data() + InputBuffer.size() - 
LZMA_STREAM_HEADER_SIZE);
+  , InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-  lzma_index_buffer_decode(, , nullptr,
-   InputBuffer.data() + InputBuffer.size() -
-   LZMA_STREAM_HEADER_SIZE - 
opts.backward_size,
-   , InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+  , , nullptr,
+  InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE + opts.backward_size)
+  .data(),
+  , InputBuffer.size());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_index_buffer_decode()=%s",


Index: lldb/source/Host/common/LZMA.cpp
===
--- lldb/source/Host/common/LZMA.cpp
+++ lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-  , InputBuffer.data() + InputBuffer.size() - LZMA_STREAM_HEADER_SIZE);
+  , InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-  lzma_index_buffer_decode(, , nullptr,
-   InputBuffer.data() + InputBuffer.size() -
-   LZMA_STREAM_HEADER_SIZE - opts.backward_size,
-   , InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+  , , nullptr,
+  InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE + opts.backward_size)
+  .data(),
+  , InputBuffer.size());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_index_buffer_decode()=%s",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374069 - Simplify LZMA decoding by using ArrayRef::take_back

2019-10-08 Thread Konrad Kleine via lldb-commits
Author: kwk
Date: Tue Oct  8 08:43:29 2019
New Revision: 374069

URL: http://llvm.org/viewvc/llvm-project?rev=374069=rev
Log:
Simplify LZMA decoding by using ArrayRef::take_back

Summary: Follow-up for D66791#inline-616303

Reviewers: labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Host/common/LZMA.cpp

Modified: lldb/trunk/source/Host/common/LZMA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/LZMA.cpp?rev=374069=374068=374069=diff
==
--- lldb/trunk/source/Host/common/LZMA.cpp (original)
+++ lldb/trunk/source/Host/common/LZMA.cpp Tue Oct  8 08:43:29 2019
@@ -76,7 +76,7 @@ getUncompressedSize(llvm::ArrayRefhttps://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67520: Add pretty printing of Clang "bitfield" enums

2019-10-08 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG41ff39605ea1: Add pretty printing of Clang 
bitfield enums (authored by friss).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D67520?vs=223705=223877#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67520

Files:
  lldb/lit/SymbolFile/DWARF/debug-types-missing-signature.test
  lldb/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
  lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -9359,21 +9359,71 @@
   llvm::cast(qual_type.getTypePtr());
   const clang::EnumDecl *enum_decl = enutype->getDecl();
   assert(enum_decl);
-  clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
-  const bool is_signed = qual_type->isSignedIntegerOrEnumerationType();
   lldb::offset_t offset = byte_offset;
-  const int64_t enum_value = data.GetMaxS64Bitfield(
+  const uint64_t enum_svalue = data.GetMaxS64Bitfield(
   , byte_size, bitfield_bit_size, bitfield_bit_offset);
-
+  bool can_be_bitfield = true;
+  uint64_t covered_bits = 0;
+  int num_enumerators = 0;
+
+  // Try to find an exact match for the value.
+  // At the same time, we're applying a heuristic to determine whether we want
+  // to print this enum as a bitfield. We're likely dealing with a bitfield if
+  // every enumrator is either a one bit value or a superset of the previous
+  // enumerators. Also 0 doesn't make sense when the enumerators are used as
+  // flags.
   for (auto enumerator : enum_decl->enumerators()) {
-if (enumerator->getInitVal().getSExtValue() == enum_value) {
+uint64_t val = enumerator->getInitVal().getSExtValue();
+if (llvm::countPopulation(val) != 1 && (val & ~covered_bits) != 0)
+  can_be_bitfield = false;
+covered_bits |= val;
+++num_enumerators;
+if (val == enum_svalue) {
+  // Found an exact match, that's all we need to do.
   s->PutCString(enumerator->getNameAsString());
   return true;
 }
   }
-  // If we have gotten here we didn't get find the enumerator in the
-  // enum decl, so just print the integer.
-  s->Printf("%" PRIi64, enum_value);
+
+  // No exact match, but we don't think this is a bitfield. Print the value as
+  // decimal.
+  if (!can_be_bitfield) {
+s->Printf("%" PRIi64, enum_svalue);
+return true;
+  }
+
+  // Unsigned values make more sense for flags.
+  offset = byte_offset;
+  const uint64_t enum_uvalue = data.GetMaxU64Bitfield(
+  , byte_size, bitfield_bit_size, bitfield_bit_offset);
+
+  uint64_t remaining_value = enum_uvalue;
+  std::vector> values;
+  values.reserve(num_enumerators);
+  for (auto enumerator : enum_decl->enumerators())
+if (auto val = enumerator->getInitVal().getZExtValue())
+  values.emplace_back(val, enumerator->getName());
+
+  // Sort in reverse order of the number of the population count,  so that in
+  // `enum {A, B, ALL = A|B }` we visit ALL first. Use a stable sort so that
+  // A | C where A is declared before C is displayed in this order.
+  std::stable_sort(values.begin(), values.end(), [](const auto , const auto ) {
+return llvm::countPopulation(a.first) > llvm::countPopulation(b.first);
+  });
+
+  for (const auto  : values) {
+if ((remaining_value & val.first) != val.first)
+  continue;
+remaining_value &= ~val.first;
+s->PutCString(val.second);
+if (remaining_value)
+  s->PutCString(" | ");
+  }
+
+  // If there is a remainder that is not covered by the value, print it as hex.
+  if (remaining_value)
+s->Printf("0x%" PRIx64, remaining_value);
+
   return true;
 }
 
@@ -9390,6 +9440,13 @@
 clang::QualType qual_type(GetQualType(type));
 
 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+
+if (type_class == clang::Type::Elaborated) {
+  qual_type = llvm::cast(qual_type)->getNamedType();
+  return DumpTypeValue(qual_type.getAsOpaquePtr(), s, format, data, byte_offset, byte_size,
+   bitfield_bit_size, bitfield_bit_offset, exe_scope);
+}
+
 switch (type_class) {
 case clang::Type::Typedef: {
   clang::QualType typedef_qual_type =
Index: lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
===
--- lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
+++ lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
@@ -18,6 +18,20 @@
 
 int main (int argc, char const *argv[])
 {
+enum bitfield {
+None = 0,
+A = 1 << 0,
+B = 1 << 1,
+C = 1 << 2,
+AB = A | B,
+ALL = A | B | C,
+

[Lldb-commits] [lldb] r374066 - Extract and simplify DumpEnumValue

2019-10-08 Thread Frederic Riss via lldb-commits
Author: friss
Date: Tue Oct  8 08:35:58 2019
New Revision: 374066

URL: http://llvm.org/viewvc/llvm-project?rev=374066=rev
Log:
Extract and simplify DumpEnumValue

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=374066=374065=374066=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Oct  8 08:35:58 2019
@@ -9351,6 +9351,32 @@ void ClangASTContext::DumpValue(
   }
 }
 
+static bool DumpEnumValue(const clang::QualType _type, Stream *s,
+  const DataExtractor , lldb::offset_t 
byte_offset,
+  size_t byte_size, uint32_t bitfield_bit_offset,
+  uint32_t bitfield_bit_size) {
+  const clang::EnumType *enutype =
+  llvm::cast(qual_type.getTypePtr());
+  const clang::EnumDecl *enum_decl = enutype->getDecl();
+  assert(enum_decl);
+  clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
+  const bool is_signed = qual_type->isSignedIntegerOrEnumerationType();
+  lldb::offset_t offset = byte_offset;
+  const int64_t enum_value = data.GetMaxS64Bitfield(
+  , byte_size, bitfield_bit_size, bitfield_bit_offset);
+
+  for (auto enumerator : enum_decl->enumerators()) {
+if (enumerator->getInitVal().getSExtValue() == enum_value) {
+  s->PutCString(enumerator->getNameAsString());
+  return true;
+}
+  }
+  // If we have gotten here we didn't get find the enumerator in the
+  // enum decl, so just print the integer.
+  s->Printf("%" PRIi64, enum_value);
+  return true;
+}
+
 bool ClangASTContext::DumpTypeValue(
 lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format,
 const DataExtractor , lldb::offset_t byte_offset, size_t byte_size,
@@ -9394,45 +9420,9 @@ bool ClangASTContext::DumpTypeValue(
   // If our format is enum or default, show the enumeration value as its
   // enumeration string value, else just display it as requested.
   if ((format == eFormatEnum || format == eFormatDefault) &&
-  GetCompleteType(type)) {
-const clang::EnumType *enutype =
-llvm::cast(qual_type.getTypePtr());
-const clang::EnumDecl *enum_decl = enutype->getDecl();
-assert(enum_decl);
-clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
-const bool is_signed = qual_type->isSignedIntegerOrEnumerationType();
-lldb::offset_t offset = byte_offset;
-if (is_signed) {
-  const int64_t enum_svalue = data.GetMaxS64Bitfield(
-  , byte_size, bitfield_bit_size, bitfield_bit_offset);
-  for (enum_pos = enum_decl->enumerator_begin(),
-  enum_end_pos = enum_decl->enumerator_end();
-   enum_pos != enum_end_pos; ++enum_pos) {
-if (enum_pos->getInitVal().getSExtValue() == enum_svalue) {
-  s->PutCString(enum_pos->getNameAsString());
-  return true;
-}
-  }
-  // If we have gotten here we didn't get find the enumerator in the
-  // enum decl, so just print the integer.
-  s->Printf("%" PRIi64, enum_svalue);
-} else {
-  const uint64_t enum_uvalue = data.GetMaxU64Bitfield(
-  , byte_size, bitfield_bit_size, bitfield_bit_offset);
-  for (enum_pos = enum_decl->enumerator_begin(),
-  enum_end_pos = enum_decl->enumerator_end();
-   enum_pos != enum_end_pos; ++enum_pos) {
-if (enum_pos->getInitVal().getZExtValue() == enum_uvalue) {
-  s->PutCString(enum_pos->getNameAsString());
-  return true;
-}
-  }
-  // If we have gotten here we didn't get find the enumerator in the
-  // enum decl, so just print the integer.
-  s->Printf("%" PRIu64, enum_uvalue);
-}
-return true;
-  }
+  GetCompleteType(type))
+return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
+ bitfield_bit_offset, bitfield_bit_size);
   // format was not enum, just fall through and dump the value as
   // requested
   LLVM_FALLTHROUGH;


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


  1   2   >