[Lldb-commits] [lldb] f5114f4 - [lldb/Reproducer] Disable test on Windows to unblock the bot.

2019-12-06 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-06T16:17:31-08:00
New Revision: f5114f4d575e7a901d41277997d0c10074aa1a4e

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

LOG: [lldb/Reproducer] Disable test on Windows to unblock the bot.

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja

Added: 


Modified: 
lldb/test/Shell/Reproducer/TestRelativePath.test

Removed: 




diff  --git a/lldb/test/Shell/Reproducer/TestRelativePath.test 
b/lldb/test/Shell/Reproducer/TestRelativePath.test
index fa7518784550..2ee4bf0c9649 100644
--- a/lldb/test/Shell/Reproducer/TestRelativePath.test
+++ b/lldb/test/Shell/Reproducer/TestRelativePath.test
@@ -1,3 +1,4 @@
+# UNSUPPORTED: system-windows
 # This tests relative capture paths.
 
 # RUN: mkdir -p %t



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


[Lldb-commits] [PATCH] D71151: [lldb][test] Remove symlink for API tests.

2019-12-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Why don't we move the `lldbsuite` as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71151



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


[Lldb-commits] [PATCH] D71150: [lldb][test] Create a separate LLDB_TEST_SRC var to allow moving tests.

2019-12-06 Thread pre-merge checks [bot] via Phabricator via lldb-commits
merge_guards_bot added a comment.

Build result: pass - 60563 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71150



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


[Lldb-commits] [PATCH] D71151: [lldb][test] Remove symlink for API tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere.
Herald added subscribers: lldb-commits, jfb, arphaman, atanasyan, mgrang, 
jrtc27, christof, kbarton, krytarowski, arichardson, nemanjai, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: jfb.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.
rupprecht added a comment.
Herald added subscribers: wuzish, dexonsmith.
rupprecht added a parent revision: D71150: [lldb][test] Create a separate 
LLDB_TEST_SRC var to allow moving tests..

Since the diff is large, I'll paste the only non-mechanical part here:

  % git diff HEAD^1 -- lldb/packages/Python/lldbsuite/__init__.py 
lldb/test/API/lit.cfg.py
  diff --git a/lldb/packages/Python/lldbsuite/__init__.py 
b/lldb/packages/Python/lldbsuite/__init__.py
  index c98c668ed6b..188f6ed1532 100644
  --- a/lldb/packages/Python/lldbsuite/__init__.py
  +++ b/lldb/packages/Python/lldbsuite/__init__.py
  @@ -22,11 +22,4 @@ lldb_root = find_lldb_root()
   
   # lldbsuite.lldb_test_src_root refers to the root of the python test case 
tree
   # (i.e. the actual unit tests).
  -lldb_test_root = os.path.join(
  -lldb_root,
  -"packages",
  -"Python",
  -"lldbsuite",
  -"test")
  -# TODO(rupprecht): update the above definition after moving test cases:
  -# lldb_test_root = os.path.join(lldb_root, "test", "API", "test")
  +lldb_test_root = os.path.join(lldb_root, "test", "API", "test")
  diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
  index 9b1c3c12f17..90d8a141e9a 100644
  --- a/lldb/test/API/lit.cfg.py
  +++ b/lldb/test/API/lit.cfg.py
  @@ -17,8 +17,7 @@ config.suffixes = ['.py']
   
   # test_source_root: The root path where tests are located.
   # test_exec_root: The root path where tests should be run.
  -config.test_source_root = os.path.join(config.lldb_src_root, 'packages',
  -   'Python', 'lldbsuite', 'test')
  +config.test_source_root = os.path.dirname(__file__)
   config.test_exec_root = config.test_source_root
   
   if 'Address' in config.llvm_use_sanitizer:


This is a largely mechanical change, moved with the following steps:

  rm lldb/test/API/testcases
  mkdir -p lldb/test/API/test/{test_runner/test,tools/lldb-{server,vscode}}
  mv lldb/packages/Python/lldbsuite/test/.categories lldb/test/API/test/
  mv lldb/packages/Python/lldbsuite/test/test_runner/test 
lldb/test/API/test/test_runner
  for d in $(find lldb/packages/Python/lldbsuite/test/* -maxdepth 0 -type d | 
egrep -v "make|plugins|test_runner|tools"); do mv $d lldb/test/API/test; done
  for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-vscode 
-maxdepth 1 -mindepth 1 | grep -v ".py"); do mv $d 
lldb/test/API/test/tools/lldb-vscode; done
  for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-server 
-maxdepth 1 -mindepth 1 | egrep -v 
"gdbremote_testcase.py|lldbgdbserverutils.py|socket_packet_pump.py"); do mv $d 
lldb/test/API/test/tools/lldb-server; done

lldb/packages/Python/lldbsuite/__init__.py and lldb/test/API/lit.cfg.py were 
also updated with the new directory structure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71151

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/.categories
  lldb/packages/Python/lldbsuite/test/android/platform/Makefile
  
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
  lldb/packages/Python/lldbsuite/test/android/platform/main.cpp
  lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/Makefile
  
lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py
  
lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/main.cpp.template
  lldb/packages/Python/lldbsuite/test/api/command-return-object/Makefile
  
lldb/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
  lldb/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
  lldb/packages/Python/lldbsuite/test/api/listeners/Makefile
  lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py
  lldb/packages/Python/lldbsuite/test/api/listeners/main.c
  lldb/packages/Python/lldbsuite/test/api/log/TestAPILog.py
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/.categories
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/Makefile
  
lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
  
lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/testprog.cpp
  lldb/packages/Python/lldbsuite/test/api/multiple-targets/Makefile
  
lldb/packages/Python/lldbsuite/test/api/multiple-targets/TestMultipleTargets.py
  lldb/packages/Python/lldbsuite/test/api/multiple-targets/main.cpp
  lldb/packages/Python/lldbsuite/test/api/multithreaded/Makefile
  

[Lldb-commits] [PATCH] D71150: [lldb][test] Create a separate LLDB_TEST_SRC var to allow moving tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This creates a separate LLDB_TEST_SRC var to match the existing LLDB_TEST var. 
LLDB_TEST points to the test framework, LLDB_TEST_SRC points to the tests 
themselves.

The var points to the same place, but a future patch will move the tree + 
update var.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71150

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -61,12 +61,13 @@
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
 lldb_build = os.environ["LLDB_BUILD"]
-if not (lldb_test and lldb_build and test_subdir and test_name and
-(not os.path.isabs(test_subdir))):
+if not (lldb_test and lldb_test_src and lldb_build and test_subdir and
+test_name and (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
 build_dir = os.path.join(lldb_build, test_subdir, test_name)
-src_dir = os.path.join(lldb_test, test_subdir)
+src_dir = os.path.join(lldb_test_src, test_subdir)
 # This is a bit of a hack to make inline testcases work.
 makefile = os.path.join(src_dir, "Makefile")
 if not os.path.isfile(makefile):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -498,7 +498,7 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST"]) + 1:]
+rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -518,10 +518,10 @@
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST} is defined.
-# See also dotest.py which sets up ${LLDB_TEST}.
-if ("LLDB_TEST" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST"],
+# Change current working directory if ${LLDB_TEST_SRC} is defined.
+# See also dotest.py which sets up ${LLDB_TEST_SRC}.
+if ("LLDB_TEST_SRC" in os.environ):
+full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
 cls.mydir)
 if traceAlways:
 print("Change dir to:", full_dir, file=sys.stderr)
@@ -656,7 +656,7 @@
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST"], self.mydir)
+return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1089,7 +1089,7 @@
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST"],
+dname = os.path.join(os.environ["LLDB_TEST_SRC"],
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -488,6 +488,7 @@
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
+os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 builddir = configuration.test_build_dir
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -20,10 +20,13 @@
 # lldbsuite.lldb_root refers to the root of the git/svn source checkout
 lldb_root = find_lldb_root()
 
-# lldbsuite.lldb_test_root refers to the root of the python test tree
+# lldbsuite.lldb_test_src_root refers to the root of the python test case tree
+# (i.e. the actual unit tests).
 lldb_test_root = os.path.join(
 lldb_root,
 "packages",
 "Python",
 "lldbsuite",
 "test")
+# TODO(rupprecht): update the above definition after moving test cases:
+# lldb_test_root = os.path.join(lldb_root, "test", "API", "test")



[Lldb-commits] [PATCH] D71105: [lldb/Reproducers] Support multiple GDB remotes

2019-12-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 232653.
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

- Address CR feedback.
- Introduce `AbstractRecorder` to reuse code between the `PacketRecorder` and 
the `DataRecorder`.
- Move GDB related reproducer code into `Utility/GDBRemote.h`.
- Rename `ProcessGDBRemoteProvider` to `GDBRemoteProvider`.


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

https://reviews.llvm.org/D71105

Files:
  lldb/include/lldb/Utility/GDBRemote.h
  lldb/include/lldb/Utility/Reproducer.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Commands/CommandObjectReproducer.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/Reproducer.cpp

Index: lldb/source/Utility/Reproducer.cpp
===
--- lldb/source/Utility/Reproducer.cpp
+++ lldb/source/Utility/Reproducer.cpp
@@ -255,7 +255,7 @@
 DataRecorder *CommandProvider::GetNewDataRecorder() {
   std::size_t i = m_data_recorders.size() + 1;
   std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
-  llvm::Twine(i) + llvm::Twine(".txt"))
+  llvm::Twine(i) + llvm::Twine(".yaml"))
  .str();
   auto recorder_or_error =
   DataRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename));
@@ -304,53 +304,9 @@
   os << m_cwd << "\n";
 }
 
-llvm::raw_ostream *ProcessGDBRemoteProvider::GetHistoryStream() {
-  FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
-
-  std::error_code EC;
-  m_stream_up = std::make_unique(history_file.GetPath(), EC,
- sys::fs::OpenFlags::OF_Text);
-  return m_stream_up.get();
-}
-
-std::unique_ptr CommandLoader::Create(Loader *loader) {
-  if (!loader)
-return {};
-
-  FileSpec file = loader->GetFile();
-  if (!file)
-return {};
-
-  auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
-  if (auto err = error_or_file.getError())
-return {};
-
-  std::vector files;
-  llvm::yaml::Input yin((*error_or_file)->getBuffer());
-  yin >> files;
-
-  if (auto err = yin.error())
-return {};
-
-  for (auto  : files) {
-FileSpec absolute_path =
-loader->GetRoot().CopyByAppendingPathComponent(file);
-file = absolute_path.GetPath();
-  }
-
-  return std::make_unique(std::move(files));
-}
-
-llvm::Optional CommandLoader::GetNextFile() {
-  if (m_index >= m_files.size())
-return {};
-  return m_files[m_index++];
-}
-
 void ProviderBase::anchor() {}
 char CommandProvider::ID = 0;
 char FileProvider::ID = 0;
-char ProcessGDBRemoteProvider::ID = 0;
 char ProviderBase::ID = 0;
 char VersionProvider::ID = 0;
 char WorkingDirectoryProvider::ID = 0;
@@ -358,8 +314,6 @@
 const char *CommandProvider::Info::name = "command-interpreter";
 const char *FileProvider::Info::file = "files.yaml";
 const char *FileProvider::Info::name = "files";
-const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml";
-const char *ProcessGDBRemoteProvider::Info::name = "gdb-remote";
 const char *VersionProvider::Info::file = "version.txt";
 const char *VersionProvider::Info::name = "version";
 const char *WorkingDirectoryProvider::Info::file = "cwd.txt";
Index: lldb/source/Utility/GDBRemote.cpp
===
--- lldb/source/Utility/GDBRemote.cpp
+++ lldb/source/Utility/GDBRemote.cpp
@@ -14,6 +14,7 @@
 #include 
 
 using namespace lldb;
+using namespace lldb_private::repro;
 using namespace lldb_private;
 using namespace llvm;
 
@@ -45,12 +46,6 @@
   return bytes_written;
 }
 
-void GDBRemotePacket::Serialize(raw_ostream ) const {
-  yaml::Output yout(strm);
-  yout << const_cast(*this);
-  strm.flush();
-}
-
 llvm::StringRef GDBRemotePacket::GetTypeStr() const {
   switch (type) {
   case GDBRemotePacket::ePacketTypeSend:
@@ -103,3 +98,66 @@
 
   return {};
 }
+
+void GDBRemoteProvider::Keep() {
+  std::vector files;
+  for (auto  : m_packet_recorders) {
+files.push_back(recorder->GetFilename().GetPath());
+  }
+
+  FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
+  std::error_code ec;
+  llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+  if (ec)
+return;
+  yaml::Output yout(os);
+  yout << files;
+}
+
+void GDBRemoteProvider::Discard() { m_packet_recorders.clear(); }
+
+llvm::Expected>
+PacketRecorder::Create(const FileSpec ) {
+  std::error_code ec;
+  auto recorder = std::make_unique(std::move(filename), ec);
+  if (ec)
+return llvm::errorCodeToError(ec);
+  return 

[Lldb-commits] [PATCH] D70622: [cmake][lit] Follow symlinks when looking for lit tests & reconfigure lldb's tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht abandoned this revision.
rupprecht added a comment.

Officially abandoning this

rG0d236d8b4f8aecc258e26ad53755a39d9b76032e 
 - fixes 
makefiles when separated from `Makefile.rules`
rG03a242bd41ee49e17f8da96af9787d13e7ea2b93 
 - fixes 
`.categories` lookup when tests are moved

I have one more to split up `os.environ["LLDB_TEST"]` into separate trees for 
test framework/test source, then the tests can be moved in a very mechanical 
way. (It will create heavy merge conflicts, I want it to be trivial to apply 
for downstream users).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70622



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


[Lldb-commits] [PATCH] D69371: [ARM64] Cleanup and speedup NativeRegisterContextLinux_arm64

2019-12-06 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6f9d7b8fb2e: Cleanup and speedup 
NativeRegisterContextLinux_arm64 (authored by omjavaid).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D69371?vs=232501=232586#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69371

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp

Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -241,6 +241,9 @@
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
+  // Before thread resumes, clear any cached register data structures
+  GetRegisterContext().InvalidateAllRegisters();
+
   return NativeProcessLinux::PtraceWrapper(PTRACE_CONT, GetID(), nullptr,
reinterpret_cast(data));
 }
@@ -262,6 +265,9 @@
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
+  // Before thread resumes, clear any cached register data structures
+  GetRegisterContext().InvalidateAllRegisters();
+
   // If hardware single-stepping is not supported, we just do a continue. The
   // breakpoint on the next instruction has been setup in
   // NativeProcessLinux::Resume.
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -40,6 +40,8 @@
 
   Status WriteAllRegisterValues(const lldb::DataBufferSP _sp) override;
 
+  void InvalidateAllRegisters() override;
+
   // Hardware breakpoints/watchpoint management functions
 
   uint32_t NumSupportedHardwareBreakpoints() override;
@@ -77,11 +79,6 @@
   enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK };
 
 protected:
-  Status DoReadRegisterValue(uint32_t offset, const char *reg_name,
- uint32_t size, RegisterValue ) override;
-
-  Status DoWriteRegisterValue(uint32_t offset, const char *reg_name,
-  const RegisterValue ) override;
 
   Status ReadGPR() override;
 
@@ -125,8 +122,17 @@
 uint32_t fpcr;
   };
 
-  uint64_t m_gpr_arm64[k_num_gpr_registers_arm64]; // 64-bit general purpose
-   // registers.
+  struct GPR {
+uint64_t x[31];
+uint64_t sp;
+uint64_t pc;
+uint64_t pstate;
+  };
+
+  bool m_gpr_is_valid;
+  bool m_fpu_is_valid;
+
+  GPR m_gpr_arm64; // 64-bit general purpose registers.
   RegInfo m_reg_info;
   FPU m_fpr; // floating-point registers including extended register sets.
 
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -152,6 +152,9 @@
   m_max_hwp_supported = 16;
   m_max_hbp_supported = 16;
   m_refresh_hwdebug_info = true;
+
+  m_gpr_is_valid = false;
+  m_fpu_is_valid = false;
 }
 
 uint32_t NativeRegisterContextLinux_arm64::GetRegisterSetCount() const {
@@ -185,41 +188,39 @@
 
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
 
-  if (IsFPR(reg)) {
-error = ReadFPR();
-if (error.Fail())
-  return error;
-  } else {
-uint32_t full_reg = reg;
-bool is_subreg = reg_info->invalidate_regs &&
- (reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM);
+  if (reg == LLDB_INVALID_REGNUM)
+return Status("no lldb regnum for %s", reg_info && reg_info->name
+   ? reg_info->name
+   : "");
+
+  uint8_t *src;
+  uint32_t offset;
 
-if (is_subreg) {
-  // Read the full aligned 64-bit register.
-  full_reg = reg_info->invalidate_regs[0];
+  if (IsGPR(reg)) {
+if (!m_gpr_is_valid) {
+  error = ReadGPR();
+  if (error.Fail())
+return error;
 }
 
-error = ReadRegisterRaw(full_reg, reg_value);
+offset = reg_info->byte_offset;
+assert(offset < GetGPRSize());
+src = (uint8_t *)GetGPRBuffer() + offset;
 
-if (error.Success()) {
-  // If our read was not aligned (for ah,bh,ch,dh), shift our returned
-  // value one byte to the right.
-  if (is_subreg && (reg_info->byte_offset & 0x1))
-reg_value.SetUInt64(reg_value.GetAsUInt64() >> 8);
+  } else 

[Lldb-commits] [lldb] b6f9d7b - Cleanup and speedup NativeRegisterContextLinux_arm64

2019-12-06 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2019-12-06T22:18:57+05:00
New Revision: b6f9d7b8fb2eb6b78ac93ebd5ea4e36c04469285

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

LOG: Cleanup and speedup NativeRegisterContextLinux_arm64

Summary:
This patch simplifies register accesses in NativeRegisterContextLinux_arm64
and also adds some bare minimum caching to avoid multiple calls to ptrace
during a stop.

Linux ptrace returns data in the form of structures containing GPR/FPR data.
This means that one single call is enough to read all GPRs or FPRs. We do
that once per stop and keep reading from or writing to the buffer that we
have in NativeRegisterContextLinux_arm64 class. Before a resume or detach we
write all buffers back.

This is tested on aarch64 thunder x1 with Ubuntu 18.04. Also tested
regressions on x86_64.

Reviewers: labath, clayborg

Reviewed By: labath

Subscribers: kristof.beyls, lldb-commits

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

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
index 3b98310c1963..9a89a13f5f5b 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -28,6 +28,9 @@ class NativeRegisterContextLinux : public 
NativeRegisterContextRegisterInfo {
   CreateHostNativeRegisterContextLinux(const ArchSpec _arch,
NativeThreadProtocol _thread);
 
+  // Invalidates cached values in register context data structures
+  virtual void InvalidateAllRegisters(){}
+
 protected:
   lldb::ByteOrder GetByteOrder() const;
 

diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index 15336d8749ca..ea7337b632ee 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -152,6 +152,9 @@ 
NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64(
   m_max_hwp_supported = 16;
   m_max_hbp_supported = 16;
   m_refresh_hwdebug_info = true;
+
+  m_gpr_is_valid = false;
+  m_fpu_is_valid = false;
 }
 
 uint32_t NativeRegisterContextLinux_arm64::GetRegisterSetCount() const {
@@ -185,41 +188,39 @@ NativeRegisterContextLinux_arm64::ReadRegister(const 
RegisterInfo *reg_info,
 
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
 
-  if (IsFPR(reg)) {
-error = ReadFPR();
-if (error.Fail())
-  return error;
-  } else {
-uint32_t full_reg = reg;
-bool is_subreg = reg_info->invalidate_regs &&
- (reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM);
+  if (reg == LLDB_INVALID_REGNUM)
+return Status("no lldb regnum for %s", reg_info && reg_info->name
+   ? reg_info->name
+   : "");
+
+  uint8_t *src;
+  uint32_t offset;
 
-if (is_subreg) {
-  // Read the full aligned 64-bit register.
-  full_reg = reg_info->invalidate_regs[0];
+  if (IsGPR(reg)) {
+if (!m_gpr_is_valid) {
+  error = ReadGPR();
+  if (error.Fail())
+return error;
 }
 
-error = ReadRegisterRaw(full_reg, reg_value);
+offset = reg_info->byte_offset;
+assert(offset < GetGPRSize());
+src = (uint8_t *)GetGPRBuffer() + offset;
 
-if (error.Success()) {
-  // If our read was not aligned (for ah,bh,ch,dh), shift our returned
-  // value one byte to the right.
-  if (is_subreg && (reg_info->byte_offset & 0x1))
-reg_value.SetUInt64(reg_value.GetAsUInt64() >> 8);
+  } else if (IsFPR(reg)) {
+if (!m_fpu_is_valid) {
 
-  // If our return byte size was greater than the return value reg size,
-  // then use the type specified by reg_info rather than the uint64_t
-  // default
-  if (reg_value.GetByteSize() > reg_info->byte_size)
-reg_value.SetType(reg_info);
+  error = ReadFPR();
+  if (error.Fail())
+return error;
 }
-return error;
-  }
+offset = CalculateFprOffset(reg_info);
+assert(offset < GetFPRSize());
+src = (uint8_t *)GetFPRBuffer() + offset;
+  } else
+return Status("failed - register wasn't recognized to be a GPR or an FPR, "
+  "write strategy unknown");
 
-  // Get pointer to 

[Lldb-commits] [PATCH] D71099: [lldb][test] Handle .categories lookup for inline tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03a242bd41ee: [lldb][test] Handle .categories lookup for 
inline tests. (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71099

Files:
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@
 """
 import inspect
 import os.path
-folder = inspect.getfile(test.__class__)
-folder = os.path.dirname(folder)
+# Use test.test_filename if the test was created with
+# lldbinline.MakeInlineTest().
+if hasattr(test, 'test_filename'):
+start_path = test.test_filename
+else:
+start_path = inspect.getfile(test.__class__)
+
+folder = os.path.dirname(start_path)
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@
 else:
 folder = os.path.dirname(folder)
 continue
+raise Exception("Did not find a .categories file, starting at: %s" % 
start_path)
 
 
 def getCategoriesForTest(self, test):


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@
 """
 import inspect
 import os.path
-folder = inspect.getfile(test.__class__)
-folder = os.path.dirname(folder)
+# Use test.test_filename if the test was created with
+# lldbinline.MakeInlineTest().
+if hasattr(test, 'test_filename'):
+start_path = test.test_filename
+else:
+start_path = inspect.getfile(test.__class__)
+
+folder = os.path.dirname(start_path)
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@
 else:
 folder = os.path.dirname(folder)
 continue
+raise Exception("Did not find a .categories file, starting at: %s" % start_path)
 
 
 def getCategoriesForTest(self, test):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 03a242b - [lldb][test] Handle .categories lookup for inline tests.

2019-12-06 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2019-12-06T08:36:23-08:00
New Revision: 03a242bd41ee49e17f8da96af9787d13e7ea2b93

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

LOG: [lldb][test] Handle .categories lookup for inline tests.

Summary:
When creating a test with `lldbinline.MakeInlineTest()`, the reported 
`inspect.getfile(test.__class__)` is `lldbtest.pyc`, meaning any `.categories` 
file will be ineffective for those tests. Check for the test_filename first, 
which inline tests will set.

Additionally, raise an error with the starting dir if `.categories` is not 
found. This makes the problem more obvious when it occurs: when the test is 
separated from the test framework tree.

Reviewers: labath, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/test_result.py 
b/lldb/packages/Python/lldbsuite/test/test_result.py
index 8573b3b6be6f..7c924cfd6f2a 100644
--- a/lldb/packages/Python/lldbsuite/test/test_result.py
+++ b/lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@ def _getFileBasedCategories(test):
 """
 import inspect
 import os.path
-folder = inspect.getfile(test.__class__)
-folder = os.path.dirname(folder)
+# Use test.test_filename if the test was created with
+# lldbinline.MakeInlineTest().
+if hasattr(test, 'test_filename'):
+start_path = test.test_filename
+else:
+start_path = inspect.getfile(test.__class__)
+
+folder = os.path.dirname(start_path)
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@ def _getFileBasedCategories(test):
 else:
 folder = os.path.dirname(folder)
 continue
+raise Exception("Did not find a .categories file, starting at: %s" % 
start_path)
 
 
 def getCategoriesForTest(self, test):



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


[Lldb-commits] [PATCH] D71108: [LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers

2019-12-06 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, clayborg.
Herald added a project: LLDB.

If not set, the address byte size was implied to be the one of the host process.

This allows reverting the functional change from 31087b2ae9154, since now 
PECOFF does the same as ELF and MachO wrt setting both byte order and address 
size on m_data within ParseHeader.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71108

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Symbol/ObjectFile.cpp


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor ) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -314,6 +314,7 @@
   ParseCOFFOptionalHeader();
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor ) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -314,6 +314,7 @@
   ParseCOFFOptionalHeader();
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-06 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D70840#1767611 , @mstorsjo wrote:

> In D70840#1767049 , @labath wrote:
>
> > In D70840#1767028 , @mstorsjo 
> > wrote:
> >
> > > In D70840#1765373 , @clayborg 
> > > wrote:
> > >
> > > > So some background on how address masks are handled in LLDB:
> > > >
> > > > Typically the way we have tried to take care of the extra Thumb bit for 
> > > > ARM using:
> > > >
> > > >   lldb::addr_t Address::GetCallableLoadAddress(Target *target, bool 
> > > > is_indirect = false) const;
> > > >   lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass 
> > > > addr_class = AddressClass::eInvalid) const;
> > > >   
> > > >
> > > > The first will add the extra bit to an address if needed. The latter 
> > > > will strip the bit if needed. This does require a target though and the 
> > > > target uses the "Architecture" class for ARM to do the work of using 
> > > > the mask. Not sure if we want to try to get an architecture class and 
> > > > use that here for stripping the bit instead of using an address mask?
> > >
> > >
> > > So, where do I get hold of an Architecture* object instance from within 
> > > the relevant contexts (within SymbolFileDWARF, where we have a reference 
> > > to the object file)? Also within source/Symbol/DWARFCallFrameInfo.cpp 
> > > where we have existing code that does the same.
> >
> >
> > Well... that's the tricky part (which I've tried to allude to in  
> > D70840#1763639 . Currently the 
> > only thing holding an architecture object is the target class, but since 
> > one of the goals of the SymbolFile stuff is to be independent of any 
> > particular target, you cannot easily get hold of that. That is why I tried 
> > to steer this towards having this in the ArchSpec class. If we don't want 
> > that, we'll probably have to create one new Architecture instance local to 
> > each Module object...
>
>
> Ah, sorry for overlooking those parts of your comment. @clayborg - what do 
> you think of @labath's suggestions here?


Ping @clayborg - can you comment on @labath's suggestions?


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D70847: [lldb] Set executable module when adding modules to the Target

2019-12-06 Thread Anton Kolesov via Phabricator via lldb-commits
anton.kolesov updated this revision to Diff 232512.
anton.kolesov retitled this revision from "[lldb-vscode] Ensure that target 
matches the executable file" to "[lldb] Set executable module when adding 
modules to the Target".
anton.kolesov edited the summary of this revision.
anton.kolesov added a comment.

Reimplement the solution based on a comment from Greg.

Tested with testsuite on Linux for x64 - there are no changes in test results. 
Also manually tested with a proprietary process plugin - currently it is not 
possible to run existing testsuite with that plugin because it targets embedded 
systems which has no `cwd`, `exit()` or environment.

I also attemted to test this against Windows hosts and targets. The change, 
apparently, resolves that launch capability on Windows, however setting of 
breakpoints doesn't work - it is only possible to stop application on entry, 
and on resume it will run till the end. Among the existing lldb-vscode tests 
some of them depend on  unavailable on windows, others fail because 
of the breakpoints that don't work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70847

Files:
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2016,12 +2016,15 @@
 // there wasn't an equivalent module in the list already, and if there was,
 // let's remove it.
 if (module_sp) {
+  bool isExecutable = false;
   ObjectFile *objfile = module_sp->GetObjectFile();
   if (objfile) {
 switch (objfile->GetType()) {
+case ObjectFile::eTypeExecutable: /// A normal executable
+  isExecutable = true;
+  LLVM_FALLTHROUGH;
 case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint 
of
 /// a program's execution state
-case ObjectFile::eTypeExecutable:/// A normal executable
 case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker
  /// executable
 case ObjectFile::eTypeObjectFile:/// An intermediate object file
@@ -2084,6 +2087,16 @@
 } else {
   m_images.Append(module_sp, notify);
 }
+
+// Ensure that architecture of the Target matches that of the
+// executable file. Otherwise Target might use a "default" platform
+// that can't actually debug the executable. For example, if the Target
+// is created and by default assumes that it should use "gdb-remote"
+// process, however executable has an architecture that requires a
+// different Process class - without explicitly set executable module
+// Target would attempt to use "gdb-remote" created initially.
+if (isExecutable)
+  SetExecutableModule(module_sp, eLoadDependentsNo);
   } else
 module_sp.reset();
 }


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2016,12 +2016,15 @@
 // there wasn't an equivalent module in the list already, and if there was,
 // let's remove it.
 if (module_sp) {
+  bool isExecutable = false;
   ObjectFile *objfile = module_sp->GetObjectFile();
   if (objfile) {
 switch (objfile->GetType()) {
+case ObjectFile::eTypeExecutable: /// A normal executable
+  isExecutable = true;
+  LLVM_FALLTHROUGH;
 case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of
 /// a program's execution state
-case ObjectFile::eTypeExecutable:/// A normal executable
 case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker
  /// executable
 case ObjectFile::eTypeObjectFile:/// An intermediate object file
@@ -2084,6 +2087,16 @@
 } else {
   m_images.Append(module_sp, notify);
 }
+
+// Ensure that architecture of the Target matches that of the
+// executable file. Otherwise Target might use a "default" platform
+// that can't actually debug the executable. For example, if the Target
+// is created and by default assumes that it should use "gdb-remote"
+// process, however executable has an architecture that requires a
+// different Process class - without explicitly set executable module
+// Target would attempt to use "gdb-remote" created initially.
+if (isExecutable)
+  SetExecutableModule(module_sp, eLoadDependentsNo);
   } else
 module_sp.reset();
 }
___
lldb-commits mailing list

[Lldb-commits] [lldb] fc39b94 - [lldb][NFC] Move [SU]Int64ValueIsValidForByteSize to RegisterValue

2019-12-06 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-06T11:16:39+01:00
New Revision: fc39b94849c89843aebb210c5d9be9c48e2b43a6

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

LOG: [lldb][NFC] Move [SU]Int64ValueIsValidForByteSize to RegisterValue

These functions are an implementation detail of RegisterValue, so
it doesn't make a lot of sense to implement them in a totally
unrelated class.

Added: 


Modified: 
lldb/include/lldb/Utility/Args.h
lldb/source/Utility/RegisterValue.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Args.h 
b/lldb/include/lldb/Utility/Args.h
index 7987787e7af5..1308f4038dbd 100644
--- a/lldb/include/lldb/Utility/Args.h
+++ b/lldb/include/lldb/Utility/Args.h
@@ -252,35 +252,6 @@ class Args {
   // For re-setting or blanking out the list of arguments.
   void Clear();
 
-  static bool UInt64ValueIsValidForByteSize(uint64_t uval64,
-size_t total_byte_size) {
-if (total_byte_size > 8)
-  return false;
-
-if (total_byte_size == 8)
-  return true;
-
-const uint64_t max = (static_cast(1)
-  << static_cast(total_byte_size * 8)) -
- 1;
-return uval64 <= max;
-  }
-
-  static bool SInt64ValueIsValidForByteSize(int64_t sval64,
-size_t total_byte_size) {
-if (total_byte_size > 8)
-  return false;
-
-if (total_byte_size == 8)
-  return true;
-
-const int64_t max = (static_cast(1)
- << static_cast(total_byte_size * 8 - 1)) -
-1;
-const int64_t min = ~(max);
-return min <= sval64 && sval64 <= max;
-  }
-
   static lldb::Encoding
   StringToEncoding(llvm::StringRef s,
lldb::Encoding fail_value = lldb::eEncodingInvalid);

diff  --git a/lldb/source/Utility/RegisterValue.cpp 
b/lldb/source/Utility/RegisterValue.cpp
index a01c35a2818e..36790f5d8efa 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -8,7 +8,6 @@
 
 #include "lldb/Utility/RegisterValue.h"
 
-#include "lldb/Utility/Args.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
@@ -330,6 +329,35 @@ static bool ParseVectorEncoding(const RegisterInfo 
*reg_info,
   return true;
 }
 
+static bool UInt64ValueIsValidForByteSize(uint64_t uval64,
+  size_t total_byte_size) {
+  if (total_byte_size > 8)
+return false;
+
+  if (total_byte_size == 8)
+return true;
+
+  const uint64_t max =
+  (static_cast(1) << static_cast(total_byte_size * 8)) 
-
+  1;
+  return uval64 <= max;
+}
+
+static bool SInt64ValueIsValidForByteSize(int64_t sval64,
+  size_t total_byte_size) {
+  if (total_byte_size > 8)
+return false;
+
+  if (total_byte_size == 8)
+return true;
+
+  const int64_t max = (static_cast(1)
+   << static_cast(total_byte_size * 8 - 1)) -
+  1;
+  const int64_t min = ~(max);
+  return min <= sval64 && sval64 <= max;
+}
+
 Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info,
  llvm::StringRef value_str) {
   Status error;
@@ -368,7 +396,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo 
*reg_info,
   break;
 }
 
-if (!Args::UInt64ValueIsValidForByteSize(uval64, byte_size)) {
+if (!UInt64ValueIsValidForByteSize(uval64, byte_size)) {
   error.SetErrorStringWithFormat(
   "value 0x%" PRIx64
   " is too large to fit in a %u byte unsigned integer value",
@@ -397,7 +425,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo 
*reg_info,
   break;
 }
 
-if (!Args::SInt64ValueIsValidForByteSize(ival64, byte_size)) {
+if (!SInt64ValueIsValidForByteSize(ival64, byte_size)) {
   error.SetErrorStringWithFormat(
   "value 0x%" PRIx64
   " is too large to fit in a %u byte signed integer value",



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


[Lldb-commits] [lldb] f69f923 - [lldb/DWARF] Fix DW_AT_addr_base & DW_AT_low_pc interaction

2019-12-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-06T10:33:13+01:00
New Revision: f69f92344adaada1f8f3cfcd711037227432b062

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

LOG: [lldb/DWARF] Fix DW_AT_addr_base & DW_AT_low_pc interaction

In DWARF5 DW_AT_low_pc (and DW_AT_entry_pc, and possibly others) can use
DW_FORM_addrx to refer to the address indirectly. This means we need to
have processed the DW_AT_addr_base attribute before we can do anything
with these.

Since we were processing the unit attributes serially, this created a
problem in cases where the DW_AT_addr_base comes after DW_AT_low_pc --
we would end up computing the wrong unit base address, which also
corrupted any values which later depended on that (for instance range
lists). Clang currently always emits DW_AT_addr_base last.

The fix is simple -- process DW_AT_addr_base first, regardless of its
position in the attribute list.

Added: 
lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 35f5c30e1778..072cbc2abc3a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -287,16 +287,25 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry 
_die) {
 
   DWARFAttributes attributes;
   size_t num_attributes = cu_die.GetAttributes(this, attributes);
+
+  // Extract DW_AT_addr_base first, as other attributes may need it.
+  for (size_t i = 0; i < num_attributes; ++i) {
+if (attributes.AttributeAtIndex(i) != DW_AT_addr_base)
+  continue;
+DWARFFormValue form_value;
+if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+  addr_base = form_value.Unsigned();
+  SetAddrBase(*addr_base);
+  break;
+}
+  }
+
   for (size_t i = 0; i < num_attributes; ++i) {
 dw_attr_t attr = attributes.AttributeAtIndex(i);
 DWARFFormValue form_value;
 if (!attributes.ExtractFormValueAtIndex(i, form_value))
   continue;
 switch (attr) {
-case DW_AT_addr_base:
-  addr_base = form_value.Unsigned();
-  SetAddrBase(*addr_base);
-  break;
 case DW_AT_rnglists_base:
   ranges_base = form_value.Unsigned();
   SetRangesBase(*ranges_base);

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s 
b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
new file mode 100644
index ..df089668cd96
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s
@@ -0,0 +1,106 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t -o "image lookup -v -s lookup_rnglists" \
+# RUN:   -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_rnglists
+# CHECK:  Function: id = {0x7fff002d}, name = "rnglists", range = 
[0x-0x0003)
+# CHECK:Blocks: id = {0x7fff002d}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {0x7fff0043}, range = [0x0001-0x0002)
+
+.text
+rnglists:
+nop
+.Lblock1_begin:
+lookup_rnglists:
+nop
+.Lblock1_end:
+nop
+.Lrnglists_end:
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   17  # DW_AT_low_pc
+.byte   27  # DW_FORM_addrx
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_CHILDREN_yes
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0 

[Lldb-commits] [lldb] b6e2cf3 - [lldb][NFC] Remove ability to pass a custom printf format to DataExtractor::PutToLog

2019-12-06 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-06T10:27:45+01:00
New Revision: b6e2cf3270dab43dbc6ffad4695c5c14789bc5e5

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

LOG: [lldb][NFC] Remove ability to pass a custom printf format to 
DataExtractor::PutToLog

This is luckily not used anywhere.

Added: 


Modified: 
lldb/include/lldb/Utility/DataExtractor.h
lldb/source/Utility/DataExtractor.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/DataExtractor.h 
b/lldb/include/lldb/Utility/DataExtractor.h
index 333baf9fd349..bf0d1055cf43 100644
--- a/lldb/include/lldb/Utility/DataExtractor.h
+++ b/lldb/include/lldb/Utility/DataExtractor.h
@@ -188,16 +188,11 @@ class DataExtractor {
   /// The type of objects to use when dumping data from this
   /// object. See DataExtractor::Type.
   ///
-  /// \param[in] type_format
-  /// The optional format to use for the \a type objects. If this
-  /// is nullptr, the default format for the \a type will be used.
-  ///
   /// \return
   /// The offset at which dumping ended.
   lldb::offset_t PutToLog(Log *log, lldb::offset_t offset,
   lldb::offset_t length, uint64_t base_addr,
-  uint32_t num_per_line, Type type,
-  const char *type_format = nullptr) const;
+  uint32_t num_per_line, Type type) const;
 
   /// Extract an arbitrary number of bytes in the specified byte order.
   ///

diff  --git a/lldb/source/Utility/DataExtractor.cpp 
b/lldb/source/Utility/DataExtractor.cpp
index 4e45baf3aa41..ea4fb09bdaab 100644
--- a/lldb/source/Utility/DataExtractor.cpp
+++ b/lldb/source/Utility/DataExtractor.cpp
@@ -985,8 +985,7 @@ uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) 
const {
 lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset,
offset_t length, uint64_t base_addr,
uint32_t num_per_line,
-   DataExtractor::Type type,
-   const char *format) const {
+   DataExtractor::Type type) const {
   if (log == nullptr)
 return start_offset;
 
@@ -1010,29 +1009,29 @@ lldb::offset_t DataExtractor::PutToLog(Log *log, 
offset_t start_offset,
 
 switch (type) {
 case TypeUInt8:
-  sstr.Printf(format ? format : " %2.2x", GetU8());
+  sstr.Printf(" %2.2x", GetU8());
   break;
 case TypeChar: {
   char ch = GetU8();
-  sstr.Printf(format ? format : " %c", isprint(ch) ? ch : ' ');
+  sstr.Printf(" %c", isprint(ch) ? ch : ' ');
 } break;
 case TypeUInt16:
-  sstr.Printf(format ? format : " %4.4x", GetU16());
+  sstr.Printf(" %4.4x", GetU16());
   break;
 case TypeUInt32:
-  sstr.Printf(format ? format : " %8.8x", GetU32());
+  sstr.Printf(" %8.8x", GetU32());
   break;
 case TypeUInt64:
-  sstr.Printf(format ? format : " %16.16" PRIx64, GetU64());
+  sstr.Printf(" %16.16" PRIx64, GetU64());
   break;
 case TypePointer:
-  sstr.Printf(format ? format : " 0x%" PRIx64, GetAddress());
+  sstr.Printf(" 0x%" PRIx64, GetAddress());
   break;
 case TypeULEB128:
-  sstr.Printf(format ? format : " 0x%" PRIx64, GetULEB128());
+  sstr.Printf(" 0x%" PRIx64, GetULEB128());
   break;
 case TypeSLEB128:
-  sstr.Printf(format ? format : " %" PRId64, GetSLEB128());
+  sstr.Printf(" %" PRId64, GetSLEB128());
   break;
 }
   }



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


[Lldb-commits] [lldb] 5ee8e67 - [lldb/DWARF] Fix DW_AT_rnglists_base handling for dwo files

2019-12-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-06T10:26:52+01:00
New Revision: 5ee8e673135891072789f0f9bf14a5d82f0f8e01

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

LOG: [lldb/DWARF] Fix DW_AT_rnglists_base handling for dwo files

the value of DW_AT_rnglists_base of the skeleton unit is for that unit
alone (e.g. used in DW_AT_ranges of the unit DIE) and should not apply
to the split unit.

The split unit has a hardcoded range list base value -- we should
initialize range list code whenever we detect a nonempty
debug_rnglists.dwo section.

Added: 
lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index ab8b3cfc280e..35f5c30e1778 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -358,10 +358,12 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry 
_die) {
   else if (gnu_addr_base)
 dwo_cu->SetAddrBase(*gnu_addr_base);
 
-  if (ranges_base)
-dwo_cu->SetRangesBase(*ranges_base);
-  else if (gnu_ranges_base)
+  if (GetVersion() <= 4 && gnu_ranges_base)
 dwo_cu->SetRangesBase(*gnu_ranges_base);
+  else if (m_dwo_symbol_file->GetDWARFContext()
+   .getOrLoadRngListsData()
+   .GetByteSize() > 0)
+dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
 
   for (size_t i = 0; i < m_dwo_symbol_file->DebugInfo()->GetNumUnits(); ++i) {
 DWARFUnit *unit = m_dwo_symbol_file->DebugInfo()->GetUnitAtIndex(i);

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s 
b/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
new file mode 100644
index ..17ed6a76b7eb
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists-dwo.s
@@ -0,0 +1,156 @@
+# REQUIRES: x86
+
+# RUN: cd %T
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s >debug_rnglists-dwo.o
+# RUN: %lldb debug_rnglists-dwo.o -o "image lookup -v -s lookup_rnglists" \
+# RUN:   -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_rnglists
+# CHECK:  Function: id = {0x0028}, name = "rnglists", range = 
[0x-0x0003)
+# CHECK:Blocks: id = {0x0028}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {0x0037}, range = [0x0001-0x0002)
+
+.text
+rnglists:
+nop
+.Lblock1_begin:
+lookup_rnglists:
+nop
+.Lblock1_end:
+nop
+.Lrnglists_end:
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   0xdeadbeefbaadf00d  # DWO id
+.byte   1   # Abbrev [1] 0xc:0x5f 
DW_TAG_compile_unit
+.asciz  "debug_rnglists-dwo.o"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   rnglists
+.quad   .Lblock1_begin
+.Ldebug_addr_end0:
+
+.section.debug_rnglists,"",@progbits
+# 

[Lldb-commits] [lldb] 777d1f7 - [lldb] Migrate VMRange::Dump to raw_ostream

2019-12-06 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-06T10:19:20+01:00
New Revision: 777d1f7272b52cbe372e7234a7247b189e416062

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

LOG: [lldb] Migrate VMRange::Dump to raw_ostream

Added: 


Modified: 
lldb/include/lldb/Utility/VMRange.h
lldb/source/Core/Section.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Utility/VMRange.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/VMRange.h 
b/lldb/include/lldb/Utility/VMRange.h
index 9c2f9d090919..72f859b67582 100644
--- a/lldb/include/lldb/Utility/VMRange.h
+++ b/lldb/include/lldb/Utility/VMRange.h
@@ -10,15 +10,12 @@
 #define liblldb_VMRange_h_
 
 #include "lldb/lldb-types.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include 
 #include 
 #include 
 
-namespace lldb_private {
-class Stream;
-}
-
 namespace lldb_private {
 
 // A vm address range. These can represent offsets ranges or actual
@@ -81,7 +78,7 @@ class VMRange {
 return false;
   }
 
-  void Dump(Stream *s, lldb::addr_t base_addr = 0,
+  void Dump(llvm::raw_ostream , lldb::addr_t base_addr = 0,
 uint32_t addr_width = 8) const;
 
   static bool ContainsValue(const VMRange::collection ,

diff  --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index e8fcca4603df..4a9acab2e27c 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -323,7 +323,7 @@ void Section::Dump(Stream *s, Target *target, uint32_t 
depth) const {
 }
 
 VMRange range(addr, addr + m_byte_size);
-range.Dump(s, 0);
+range.Dump(s->AsRawOstream(), 0);
   }
 
   s->Printf("%c %c%c%c  0x%8.8" PRIx64 " 0x%8.8" PRIx64 " 0x%8.8x ",

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index df31d15e7d59..1297255a38be 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -131,7 +131,7 @@ void DWARFExpression::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->PutCString(", ");
 VMRange addr_range(curr_base_addr + begin_addr_offset,
curr_base_addr + end_addr_offset);
-addr_range.Dump(s, 0, 8);
+addr_range.Dump(s->AsRawOstream(), 0, 8);
 s->PutChar('{');
 lldb::offset_t location_length = m_data.GetU16();
 DumpLocation(s, offset, location_length, level, abi);

diff  --git a/lldb/source/Utility/VMRange.cpp b/lldb/source/Utility/VMRange.cpp
index e7c6b0bcccbb..c8c3334138d3 100644
--- a/lldb/source/Utility/VMRange.cpp
+++ b/lldb/source/Utility/VMRange.cpp
@@ -35,9 +35,10 @@ bool VMRange::ContainsRange(const VMRange::collection ,
  }) != coll.end();
 }
 
-void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const {
-  DumpAddressRange(s->AsRawOstream(), offset + GetBaseAddress(),
-   offset + GetEndAddress(), addr_width);
+void VMRange::Dump(llvm::raw_ostream , lldb::addr_t offset,
+   uint32_t addr_width) const {
+  DumpAddressRange(s, offset + GetBaseAddress(), offset + GetEndAddress(),
+   addr_width);
 }
 
 bool lldb_private::operator==(const VMRange , const VMRange ) {



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


[Lldb-commits] [PATCH] D70722: [lldb/IRExecutionUnit] Stop searching based on demangled names

2019-12-06 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0d2472ff6f60: [lldb/IRExecutionUnit] Stop searching based on 
demangled names (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70722

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
  lldb/source/Expression/IRExecutionUnit.cpp


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -728,8 +728,6 @@
 if (best_alternate_mangled_name) {
   CPP_specs.push_back(best_alternate_mangled_name);
 }
-
-CPP_specs.push_back(SearchSpec(demangled, 
lldb::eFunctionNameTypeFull));
   }
 }
 
Index: 
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
===
--- 
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
+++ 
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
@@ -63,7 +63,6 @@
 # a vtable entry that does not exist in the compiled program).
 self.expect("expr d.foo()", substrs=["2"])
 
-@skipIfLinux # Calling constructor causes SIGABRT
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr43707")
 def test_call_on_temporary(self):
 """Test calls to overridden methods in derived classes."""


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -728,8 +728,6 @@
 if (best_alternate_mangled_name) {
   CPP_specs.push_back(best_alternate_mangled_name);
 }
-
-CPP_specs.push_back(SearchSpec(demangled, lldb::eFunctionNameTypeFull));
   }
 }
 
Index: lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
@@ -63,7 +63,6 @@
 # a vtable entry that does not exist in the compiled program).
 self.expect("expr d.foo()", substrs=["2"])
 
-@skipIfLinux # Calling constructor causes SIGABRT
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr43707")
 def test_call_on_temporary(self):
 """Test calls to overridden methods in derived classes."""
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 0d2472f - [lldb/IRExecutionUnit] Stop searching based on demangled names

2019-12-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-06T10:17:49+01:00
New Revision: 0d2472ff6f604af842059d9a0098db274515a2d3

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

LOG: [lldb/IRExecutionUnit] Stop searching based on demangled names

Summary:
This was causing problems on linux, where we'd end up calling the
deleting destructor instead of a regular one (because they have the same
demangled name), making a lot of mischief in the process.

The only place where this was necessary (according to the test suite, at
least) was to call a base structor instead of a complete one, but this
is now handled in a more targeted fashion.

TestCallOverriddenMethod is now re-enabled as it now passes reliably.

Reviewers: teemperor, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
lldb/source/Expression/IRExecutionUnit.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
index 9c25597391de..ddaafaab9fd2 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
@@ -63,7 +63,6 @@ def test_call_on_derived(self):
 # a vtable entry that does not exist in the compiled program).
 self.expect("expr d.foo()", substrs=["2"])
 
-@skipIfLinux # Calling constructor causes SIGABRT
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr43707")
 def test_call_on_temporary(self):
 """Test calls to overridden methods in derived classes."""

diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 33d48842f869..bdf3c92a3117 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -728,8 +728,6 @@ void IRExecutionUnit::CollectCandidateCPlusPlusNames(
 if (best_alternate_mangled_name) {
   CPP_specs.push_back(best_alternate_mangled_name);
 }
-
-CPP_specs.push_back(SearchSpec(demangled, 
lldb::eFunctionNameTypeFull));
   }
 }
 



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


[Lldb-commits] [lldb] 6e1f317 - [lldb/DWARF] Remove DWARFDebugRangesBase abstract class

2019-12-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-06T10:15:46+01:00
New Revision: 6e1f3170e061b16c9096a769508f0a6d7eb95b9c

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

LOG: [lldb/DWARF] Remove DWARFDebugRangesBase abstract class

now that we use llvm to parse debug_rnglists, this abstraction is not
useful.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
index 99ef04d7ee21..1888a7760f27 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -17,22 +17,13 @@ namespace lldb_private {
 class DWARFContext;
 }
 
-class DWARFDebugRangesBase {
-public:
-  virtual ~DWARFDebugRangesBase(){};
-
-  virtual void Extract(lldb_private::DWARFContext ) = 0;
-  virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
-  DWARFRangeList _list) const = 0;
-};
-
-class DWARFDebugRanges final : public DWARFDebugRangesBase {
+class DWARFDebugRanges {
 public:
   DWARFDebugRanges();
 
-  void Extract(lldb_private::DWARFContext ) override;
+  void Extract(lldb_private::DWARFContext );
   bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
-  DWARFRangeList _list) const override;
+  DWARFRangeList _list) const;
 
   static void Dump(lldb_private::Stream ,
const lldb_private::DWARFDataExtractor _ranges_data,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 71375da844da..ab8b3cfc280e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -883,7 +883,7 @@ uint32_t DWARFUnit::GetHeaderByteSize() const {
 llvm::Expected
 DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
   if (GetVersion() <= 4) {
-const DWARFDebugRangesBase *debug_ranges = m_dwarf.GetDebugRanges();
+const DWARFDebugRanges *debug_ranges = m_dwarf.GetDebugRanges();
 if (!debug_ranges)
   return llvm::make_error(
   "No debug_ranges section");



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


[Lldb-commits] [PATCH] D69371: [ARM64] Cleanup and speedup NativeRegisterContextLinux_arm64

2019-12-06 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h:32
+  // Invalidates cached values in register context data structures
+  virtual void InvalidateAllRegisters(){};
+

no semicolon here


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

https://reviews.llvm.org/D69371



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


[Lldb-commits] [PATCH] D69371: [ARM64] Cleanup and speedup NativeRegisterContextLinux_arm64

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

I think this looks good now. Thanks for your patience.


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

https://reviews.llvm.org/D69371



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


[Lldb-commits] [PATCH] D71105: [lldb/Reproducers] Support multiple GDB remotes

2019-12-06 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looks pretty straight-forward, but I am still not happy about how more and more 
of ProcessGDBRemote is infiltrating its way into the Utility module. I think 
that the reproducer code specific to gdb-remote should live next to the code 
it's capturing, and Utility/Reproducer.cpp should just provide the general 
architecture...




Comment at: lldb/include/lldb/Utility/Reproducer.h:429
 private:
+  FileSpec GetMainFile(Loader *loader) {
+return loader->template GetFile();

is this used anywhere?



Comment at: lldb/source/Commands/CommandObjectReproducer.cpp:441
 
-  std::vector packets;
-  yaml::Input yin((*error_or_file)->getBuffer());
-  yin >> packets;
+  static std::unique_ptr<
+  repro::MultiLoader>

static? Is it not possible to dump multiple reproducer files in one session ?



Comment at: lldb/source/Commands/CommandObjectReproducer.cpp:447
+  llvm::Optional gdb_file = multi_loader->GetNextFile();
+  while (gdb_file) {
+auto error_or_file = MemoryBuffer::getFile(*gdb_file);

maybe `while ((gdb_file = multi_loader->GetNextFile()))` (with an optional `!= 
None`) ?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71105



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


[Lldb-commits] [lldb] 4dac97e - [lldb][NFC] Migrate FileSpec::Dump to raw_ostream

2019-12-06 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-06T09:40:42+01:00
New Revision: 4dac97eb1e6563750e682e482e68f29ac076a4f7

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

LOG: [lldb][NFC] Migrate FileSpec::Dump to raw_ostream

Added: 


Modified: 
lldb/include/lldb/Utility/FileSpec.h
lldb/source/Breakpoint/BreakpointLocation.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Core/FileSpecList.cpp
lldb/source/Core/FormatEntity.cpp
lldb/source/Core/Module.cpp
lldb/source/Interpreter/OptionValueFileSpecList.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/source/Symbol/LineEntry.cpp
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Utility/FileSpec.cpp
lldb/source/Utility/ProcessInfo.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/FileSpec.h 
b/lldb/include/lldb/Utility/FileSpec.h
index 61b6209bb3c0..533426671cc6 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -211,7 +211,7 @@ class FileSpec {
   ///
   /// \param[in] s
   /// The stream to which to dump the object description.
-  void Dump(Stream *s) const;
+  void Dump(llvm::raw_ostream ) const;
 
   Style GetPathStyle() const;
 

diff  --git a/lldb/source/Breakpoint/BreakpointLocation.cpp 
b/lldb/source/Breakpoint/BreakpointLocation.cpp
index e6d7d85f9060..7f08b08c6055 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -519,7 +519,7 @@ void BreakpointLocation::GetDescription(Stream *s,
   if (sc.module_sp) {
 s->EOL();
 s->Indent("module = ");
-sc.module_sp->GetFileSpec().Dump(s);
+sc.module_sp->GetFileSpec().Dump(s->AsRawOstream());
   }
 
   if (sc.comp_unit != nullptr) {

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index ac3188740234..345c325563f0 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1349,7 +1349,7 @@ static void DumpFullpath(Stream , const FileSpec 
*file_spec_ptr,
   strm.Printf("%-*s", width, fullpath.c_str());
   return;
 } else {
-  file_spec_ptr->Dump();
+  file_spec_ptr->Dump(strm.AsRawOstream());
   return;
 }
   }

diff  --git a/lldb/source/Core/FileSpecList.cpp 
b/lldb/source/Core/FileSpecList.cpp
index 95133faf7502..6651324fa362 100644
--- a/lldb/source/Core/FileSpecList.cpp
+++ b/lldb/source/Core/FileSpecList.cpp
@@ -47,7 +47,7 @@ void FileSpecList::Clear() { m_files.clear(); }
 void FileSpecList::Dump(Stream *s, const char *separator_cstr) const {
   collection::const_iterator pos, end = m_files.end();
   for (pos = m_files.begin(); pos != end; ++pos) {
-pos->Dump(s);
+pos->Dump(s->AsRawOstream());
 if (separator_cstr && ((pos + 1) != end))
   s->PutCString(separator_cstr);
   }

diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 81ad6d127f04..beab026e67aa 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -2310,7 +2310,7 @@ bool FormatEntity::FormatFileSpec(const FileSpec 
_spec, Stream ,
   llvm::StringRef variable_name,
   llvm::StringRef variable_format) {
   if (variable_name.empty() || variable_name.equals(".fullpath")) {
-file_spec.Dump();
+file_spec.Dump(s.AsRawOstream());
 return true;
   } else if (variable_name.equals(".basename")) {
 s.PutCString(file_spec.GetFilename().AsCString(""));

diff  --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index cc4eea674170..5bb6a55457dd 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1511,7 +1511,7 @@ bool Module::LoadScriptingResourceInTarget(Target 
*target, Status ,
   return false;
 }
 StreamString scripting_stream;
-scripting_fspec.Dump(_stream);
+scripting_fspec.Dump(scripting_stream.AsRawOstream());
 const bool can_reload = true;
 const bool init_lldb_globals = false;
 bool did_load = script_interpreter->LoadScriptingModule(

diff  --git a/lldb/source/Interpreter/OptionValueFileSpecList.cpp 
b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
index 1a9d3c9ecb87..f2367b1941c9 100644
--- a/lldb/source/Interpreter/OptionValueFileSpecList.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
@@ -33,7 +33,7 @@ void OptionValueFileSpecList::DumpValue(const 
ExecutionContext *exe_ctx,
 strm.Indent();
 strm.Printf("[%u]: ", i);
   

[Lldb-commits] [PATCH] D70622: [cmake][lit] Follow symlinks when looking for lit tests & reconfigure lldb's tests.

2019-12-06 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for looking into this, Jordan.

I'm not sure how hard it is, but I think it would be nice to not have the 
actual tests intermingled with the test framework stuff.

(Also, another reason for moving the tests is that the symlink trick will just 
not work on windows.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70622



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


[Lldb-commits] [PATCH] D70883: [vscode.py] Make read_packet only return None when EOF

2019-12-06 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D70883#1771686 , @aadsm wrote:

> Fair enough, I haven't seen evidence of this (haven't searched for it) but I 
> imagine IDEs need to ignore this as well otherwise they just barf if they're 
> expecting `Content-Length` and a wild print appears. The notion of stdout of 
> SBDebugger is the SBCommandReturnObject which doesn't print right away (only 
> when the command finishes executing) and from my previous tests .flush() 
> doesn't help with this. I believe this is the reason why people opt to use 
> print instead in their custom commands. But I don't think it's a reasonable 
> assumption (or api contract) to tell people they can't use print or it breaks 
> lldb-vscode.
>
> I'm going to fix this in lldb-vscode itself to wrap all stdout in a proper 
> DAP console response.


Interesting.. I was expecting this was already handled somehow within lldb -- 
we have a fair amount of code 

 which tries to install fake stdin/out handles when running a python script. 
I'd start with checking out why that piece of code isn't kicking in...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70883



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