[Lldb-commits] [lldb] 791b6eb - [lldb] Speculative fix to TestGuiExpandThreadsTree

2021-09-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-21T10:01:00+02:00
New Revision: 791b6ebc86680168d634103b67a92a354c075cc4

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

LOG: [lldb] Speculative fix to TestGuiExpandThreadsTree

This test relies on being able to unwind from an arbitrary place inside
libc. While I am not sure this is the cause of the observed flakyness,
it is known that we are not able to unwind correctly from some places in
(linux) libc.

This patch adds additional synchronization to ensure that the inferior
is in the main function (instead of pthread guts) when lldb tries to
unwind it. At the very least, it should make the test runs more
predictable/repeatable.

Added: 
lldb/test/API/commands/gui/expand-threads-tree/main.cpp

Modified: 
lldb/test/API/commands/gui/expand-threads-tree/Makefile
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py

Removed: 
lldb/test/API/commands/gui/expand-threads-tree/main.c



diff  --git a/lldb/test/API/commands/gui/expand-threads-tree/Makefile 
b/lldb/test/API/commands/gui/expand-threads-tree/Makefile
index 0c11fbdd8669c..566938ca0cc4e 100644
--- a/lldb/test/API/commands/gui/expand-threads-tree/Makefile
+++ b/lldb/test/API/commands/gui/expand-threads-tree/Makefile
@@ -1,3 +1,3 @@
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 ENABLE_THREADS := YES
 include Makefile.rules

diff  --git 
a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py 
b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
index c3ec4b285ecd0..9eed5b0ef6c39 100644
--- a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
+++ b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
@@ -22,7 +22,7 @@ def test_gui(self):
 self.build()
 
 self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
-self.expect("breakpoint set -r thread_start_routine", 
substrs=["Breakpoint 1", "address ="])
+self.expect("breakpoint set -n break_here", substrs=["Breakpoint 1", 
"address ="])
 self.expect("run", substrs=["stop reason ="])
 
 escape_key = chr(27).encode()
@@ -33,7 +33,7 @@ def test_gui(self):
 self.child.expect_exact("Threads")
 
 # The thread running thread_start_routine should be expanded.
-self.child.expect_exact("frame #0: thread_start_routine")
+self.child.expect_exact("frame #0: break_here")
 
 # Exit GUI.
 self.child.send(escape_key)

diff  --git a/lldb/test/API/commands/gui/expand-threads-tree/main.c 
b/lldb/test/API/commands/gui/expand-threads-tree/main.c
deleted file mode 100644
index 32e6d17c799a6..0
--- a/lldb/test/API/commands/gui/expand-threads-tree/main.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include 
-
-void *thread_start_routine(void *arg) { return NULL; }
-
-int main() {
-  pthread_t thread;
-  pthread_create(&thread, NULL, thread_start_routine, NULL);
-  pthread_join(thread, NULL);
-  return 0;
-}

diff  --git a/lldb/test/API/commands/gui/expand-threads-tree/main.cpp 
b/lldb/test/API/commands/gui/expand-threads-tree/main.cpp
new file mode 100644
index 0..5a7cbb78563c0
--- /dev/null
+++ b/lldb/test/API/commands/gui/expand-threads-tree/main.cpp
@@ -0,0 +1,24 @@
+#include "pseudo_barrier.h"
+#include 
+
+
+pseudo_barrier_t barrier_before;
+pseudo_barrier_t barrier_after;
+
+void break_here() {}
+
+void thread_func() {
+pseudo_barrier_wait(barrier_before);
+break_here();
+pseudo_barrier_wait(barrier_after);
+}
+
+int main() {
+  pseudo_barrier_init(barrier_before, 2);
+  pseudo_barrier_init(barrier_after, 2);
+  std::thread thread(thread_func);
+  pseudo_barrier_wait(barrier_before);
+  pseudo_barrier_wait(barrier_after);
+  thread.join();
+  return 0;
+}



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


[Lldb-commits] [PATCH] D110027: [lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs

2021-09-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:4619
+for (uint32_t &x : remote_reg_info.value_regs) {
+  std::map::iterator x_lldb =
+  remote_to_local_map.find(x);

auto :)



Comment at: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:4626-4629
+  std::map::iterator x_lldb =
+  remote_to_local_map.find(x);
+  x = x_lldb != remote_to_local_map.end() ? x_lldb->second
+  : LLDB_INVALID_REGNUM;

Make this a lambda and then do 
`llvm::transform(remote_reg_info.invalidate_regs, 
remote_reg_info.invalidate_regs.begin(), lambda)`


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

https://reviews.llvm.org/D110027

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


[Lldb-commits] [PATCH] D110027: [lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs

2021-09-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 373814.
mgorny marked 2 inline comments as done.
mgorny added a comment.

Both requests implemented.


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

https://reviews.llvm.org/D110027

Files:
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4596,20 +4596,43 @@
   // ABI is also potentially incorrect.
   ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use);
 
+  std::map remote_to_local_map;
   uint32_t remote_regnum = 0;
+  for (auto it : llvm::enumerate(registers)) {
+RemoteRegisterInfo &remote_reg_info = it.value();
+
+// Assign successive remote regnums if missing.
+if (remote_reg_info.regnum_remote == LLDB_INVALID_REGNUM)
+  remote_reg_info.regnum_remote = remote_regnum;
+
+// Create a mapping from remote to local regnos.
+remote_to_local_map[remote_reg_info.regnum_remote] = it.index();
+
+remote_regnum = remote_reg_info.regnum_remote + 1;
+  }
+
   for (auto it : llvm::enumerate(registers)) {
 uint32_t local_regnum = it.index();
 RemoteRegisterInfo &remote_reg_info = it.value();
-// Use remote regnum if available, previous remote regnum + 1 when not.
-if (remote_reg_info.regnum_remote != LLDB_INVALID_REGNUM)
-  remote_regnum = remote_reg_info.regnum_remote;
+
+auto proc_to_lldb = [&remote_to_local_map](uint32_t process_regnum) {
+  auto lldb_regit = remote_to_local_map.find(process_regnum);
+  return lldb_regit != remote_to_local_map.end() ? lldb_regit->second
+ : LLDB_INVALID_REGNUM;
+};
+
+llvm::transform(remote_reg_info.value_regs,
+remote_reg_info.value_regs.begin(), proc_to_lldb);
+llvm::transform(remote_reg_info.invalidate_regs,
+remote_reg_info.invalidate_regs.begin(), proc_to_lldb);
 
 struct RegisterInfo reg_info {
   remote_reg_info.name.AsCString(), remote_reg_info.alt_name.AsCString(),
   remote_reg_info.byte_size, remote_reg_info.byte_offset,
   remote_reg_info.encoding, remote_reg_info.format,
   {remote_reg_info.regnum_ehframe, remote_reg_info.regnum_dwarf,
-   remote_reg_info.regnum_generic, remote_regnum++, local_regnum},
+   remote_reg_info.regnum_generic, remote_reg_info.regnum_remote,
+   local_regnum},
   remote_reg_info.value_regs.data(),
   remote_reg_info.invalidate_regs.data(),
   remote_reg_info.dwarf_opcode_bytes.data(),
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -253,7 +253,7 @@
 // We have a valid primordial register as our constituent. Grab the
 // corresponding register info.
 const RegisterInfo *prim_reg_info =
-GetRegisterInfo(eRegisterKindProcessPlugin, prim_reg);
+GetRegisterInfo(eRegisterKindLLDB, prim_reg);
 if (prim_reg_info == nullptr)
   success = false;
 else {
@@ -384,7 +384,7 @@
 // We have a valid primordial register as our constituent. Grab the
 // corresponding register info.
 const RegisterInfo *value_reg_info =
-GetRegisterInfo(eRegisterKindProcessPlugin, reg);
+GetRegisterInfo(eRegisterKindLLDB, reg);
 if (value_reg_info == nullptr)
   success = false;
 else
@@ -405,7 +405,7 @@
reg != LLDB_INVALID_REGNUM;
reg = reg_info->invalidate_regs[++idx])
 SetRegisterIsValid(ConvertRegisterKindToRegisterNumber(
-   eRegisterKindProcessPlugin, reg),
+   eRegisterKindLLDB, reg),
false);
 }
 
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -665,9 +665,7 @@
   if (reg.byte_offset == LLDB_INVALID_INDEX32) {
 uint32_t value_regnum = reg.value_regs[0];
 if (value_regnum != LLDB_INVALID_INDEX32)
-  reg.byte_offset =
-  GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
-  ->byte_offset;
+  reg.byte_offset = Get

[Lldb-commits] [PATCH] D109777: [lldb] [Windows] Fix continuing from breakpoints and singlestepping on ARM/AArch64

2021-09-21 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

@labath Does this seem ok to you now, and/or do you have any refactoring 
suggestion regarding getting the breakpoint opcode size in ProcessWindows.cpp?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109777

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


[Lldb-commits] [PATCH] D110172: [lldb/win] Default to native PDB reader when building with LLVM_ENABLE_DIA_SDK=NO

2021-09-21 Thread Nico Weber via Phabricator via lldb-commits
thakis created this revision.
thakis added reviewers: labath, amccarth.
thakis added a project: LLDB.
Herald added a subscriber: JDevlieghere.
thakis requested review of this revision.

Trying to use the DIA SDK reader only to fail with "DIA SDK wasn't enabled"
isn't very useful. The native PDB reader is missing some stuff, but it's
still better than nothing.

Reduces number of lldb-check-shell test failures with LLVM_ENABLE_DIA_SDK=NO 
from
27 to 15.


https://reviews.llvm.org/D110172

Files:
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,6 +87,7 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
   return use_native.equals_insensitive("on") ||
  use_native.equals_insensitive("yes") ||
@@ -91,6 +96,9 @@
 #else
   return true;
 #endif
+#else
+  return true;
+#endif
 }
 
 void SymbolFilePDB::Initialize() {


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,6 +87,7 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
   return use_native.equals_insensitive("on") ||
  use_native.equals_insensitive("yes") ||
@@ -91,6 +96,9 @@
 #else
   return true;
 #endif
+#else
+  return true;
+#endif
 }
 
 void SymbolFilePDB::Initialize() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109834: [lldb/win] Improve check-lldb-shell with LLVM_ENABLE_DIA_SDK=NO

2021-09-21 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

Well, it's a start, so let's land that part (D110172 
).


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

https://reviews.llvm.org/D109834

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


[Lldb-commits] [PATCH] D110172: [lldb/win] Default to native PDB reader when building with LLVM_ENABLE_DIA_SDK=NO

2021-09-21 Thread Nico Weber via Phabricator via lldb-commits
thakis updated this revision to Diff 373909.
thakis added a comment.

slightly simpler preprocessor goop


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

https://reviews.llvm.org/D110172

Files:
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,14 +87,16 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
-  return use_native.equals_insensitive("on") ||
- use_native.equals_insensitive("yes") ||
- use_native.equals_insensitive("1") ||
- use_native.equals_insensitive("true");
-#else
-  return true;
+  if (use_native.equals_insensitive("on") ||
+  use_native.equals_insensitive("yes") ||
+  use_native.equals_insensitive("1") ||
+  use_native.equals_insensitive("true"))
+return false;
+#endif
 #endif
+  return true;
 }
 
 void SymbolFilePDB::Initialize() {


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,14 +87,16 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
-  return use_native.equals_insensitive("on") ||
- use_native.equals_insensitive("yes") ||
- use_native.equals_insensitive("1") ||
- use_native.equals_insensitive("true");
-#else
-  return true;
+  if (use_native.equals_insensitive("on") ||
+  use_native.equals_insensitive("yes") ||
+  use_native.equals_insensitive("1") ||
+  use_native.equals_insensitive("true"))
+return false;
+#endif
 #endif
+  return true;
 }
 
 void SymbolFilePDB::Initialize() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D110172: [lldb/win] Default to native PDB reader when building with LLVM_ENABLE_DIA_SDK=NO

2021-09-21 Thread Nico Weber via Phabricator via lldb-commits
thakis updated this revision to Diff 373910.
thakis added a comment.

slightly nicer preprocessor goop in more correct


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

https://reviews.llvm.org/D110172

Files:
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,14 +87,16 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
-  return use_native.equals_insensitive("on") ||
- use_native.equals_insensitive("yes") ||
- use_native.equals_insensitive("1") ||
- use_native.equals_insensitive("true");
-#else
-  return true;
+  if (!use_native.equals_insensitive("on") &&
+  !use_native.equals_insensitive("yes") &&
+  !use_native.equals_insensitive("1") &&
+  !use_native.equals_insensitive("true"))
+return false;
+#endif
 #endif
+  return true;
 }
 
 void SymbolFilePDB::Initialize() {


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,14 +87,16 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
-  return use_native.equals_insensitive("on") ||
- use_native.equals_insensitive("yes") ||
- use_native.equals_insensitive("1") ||
- use_native.equals_insensitive("true");
-#else
-  return true;
+  if (!use_native.equals_insensitive("on") &&
+  !use_native.equals_insensitive("yes") &&
+  !use_native.equals_insensitive("1") &&
+  !use_native.equals_insensitive("true"))
+return false;
+#endif
 #endif
+  return true;
 }
 
 void SymbolFilePDB::Initialize() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-21 Thread Alf via Phabricator via lldb-commits
gAlfonso-bit added a comment.

@Mordante Alfonso Gregory gfunni...@gmail.com


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

https://reviews.llvm.org/D107717

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


[Lldb-commits] [PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-21 Thread Alf via Phabricator via lldb-commits
gAlfonso-bit added a comment.

@ldionne can you please please merge


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

https://reviews.llvm.org/D107717

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


[Lldb-commits] [PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-21 Thread Mark de Wever via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2c319fdc6b3: [LLVM][CMake][NFC] Resolve FIXME: Rename 
LLVM_CMAKE_PATH to LLVM_CMAKE_DIR… (authored by gAlfonso-bit, committed by 
Mordante).
Herald added a project: LLDB.
Herald added a reviewer: libunwind.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107717

Files:
  clang/CMakeLists.txt
  clang/lib/Basic/CMakeLists.txt
  compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  flang/CMakeLists.txt
  libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
  libunwind/CMakeLists.txt
  lld/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/source/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/include/llvm/Support/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 # This variable makes sure that e.g. llvm-lit is found.
 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 
 # This variable is used by individual runtimes to locate LLVM files.
 set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
Index: llvm/include/llvm/Support/CMakeLists.txt
===
--- llvm/include/llvm/Support/CMakeLists.txt
+++ llvm/include/llvm/Support/CMakeLists.txt
@@ -3,7 +3,7 @@
 # The VC revision include that we want to generate.
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h")
 
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(LLVM_APPEND_VC_REV)
   set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -295,8 +295,8 @@
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
-# Note: LLVM_CMAKE_PATH does not include generated files
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+# Note: LLVM_CMAKE_DIR does not include generated files
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
 set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 
Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lldb_vc AND LLVM_APPEND_VC_REV)
   set(lldb_source_dir ${LLDB_SOURCE_DIR})
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -3,8 +3,8 @@
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH)
 
-# We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc
-set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
+# We set LLVM_CMAKE_DIR so that GetSVN.cmake is found correctly when building SVNVersion.inc
+set(LLVM_CMAKE_DIR ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
 
 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
Index: lld/Common/CMakeLists.txt
===
--- lld/Common/CMakeLists.txt
+++ lld/Common/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lld_vc AND LLVM_APPEND_VC_REV)
   set(lld_source_dir ${LLD_SOURCE_DIR})
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -27,7 +27,7 @@
 
   list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
   list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
-  list(GET LLVM_CONFIG_OUTPUT 

[Lldb-commits] [PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-21 Thread Alf via Phabricator via lldb-commits
gAlfonso-bit updated this revision to Diff 372770.
gAlfonso-bit added a comment.

Rebased to main


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

https://reviews.llvm.org/D107717

Files:
  clang/CMakeLists.txt
  clang/lib/Basic/CMakeLists.txt
  compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  flang/CMakeLists.txt
  libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
  libunwind/CMakeLists.txt
  lld/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/source/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/include/llvm/Support/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 # This variable makes sure that e.g. llvm-lit is found.
 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 
 # This variable is used by individual runtimes to locate LLVM files.
 set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
Index: llvm/include/llvm/Support/CMakeLists.txt
===
--- llvm/include/llvm/Support/CMakeLists.txt
+++ llvm/include/llvm/Support/CMakeLists.txt
@@ -3,7 +3,7 @@
 # The VC revision include that we want to generate.
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h")
 
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(LLVM_APPEND_VC_REV)
   set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -295,8 +295,8 @@
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
-# Note: LLVM_CMAKE_PATH does not include generated files
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+# Note: LLVM_CMAKE_DIR does not include generated files
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
 set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 
Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lldb_vc AND LLVM_APPEND_VC_REV)
   set(lldb_source_dir ${LLDB_SOURCE_DIR})
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -3,8 +3,8 @@
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH)
 
-# We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc
-set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
+# We set LLVM_CMAKE_DIR so that GetSVN.cmake is found correctly when building SVNVersion.inc
+set(LLVM_CMAKE_DIR ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
 
 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
Index: lld/Common/CMakeLists.txt
===
--- lld/Common/CMakeLists.txt
+++ lld/Common/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lld_vc AND LLVM_APPEND_VC_REV)
   set(lld_source_dir ${LLD_SOURCE_DIR})
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -27,7 +27,7 @@
 
   list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
   list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
-  list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_PATH)
+  list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_DIR)
   list(GET LLVM_CONFIG_OUTPUT 3 MAIN_SRC_DIR)
 
   set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree")
@@ -35,14 +35,14 @@
   set(LLVM_MAIN_SRC_DIR ${MAIN_SR

[Lldb-commits] [PATCH] D109345: MemoryBuffer: Migrate to Expected/llvm::Error from ErrorOr/std::error_code

2021-09-21 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

Thanks for the suggestions/details, @dexonsmith  - I've posted to llvm-dev 
here: https://groups.google.com/g/llvm-dev/c/m9UVRhzJvh4/m/qdd_SyPuCQAJ and 
will wait for some follow-up (or dead silence) before starting along probably 
your latter suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109345

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


[Lldb-commits] [PATCH] D109345: MemoryBuffer: Migrate to Expected/llvm::Error from ErrorOr/std::error_code

2021-09-21 Thread Duncan P. N. Exon Smith via Phabricator via lldb-commits
dexonsmith added a comment.

In D109345#3008426 , @dblaikie wrote:

> Thanks for the suggestions/details, @dexonsmith  - I've posted to llvm-dev 
> here: https://groups.google.com/g/llvm-dev/c/m9UVRhzJvh4/m/qdd_SyPuCQAJ and 
> will wait for some follow-up (or dead silence) before starting along probably 
> your latter suggestion.

SGTM, thanks David!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109345

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


[Lldb-commits] [PATCH] D110172: [lldb/win] Default to native PDB reader when building with LLVM_ENABLE_DIA_SDK=NO

2021-09-21 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D110172

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


[Lldb-commits] [lldb] 908c115 - [lldb/win] Default to native PDB reader when LLVM_ENABLE_DIA_SDK=NO

2021-09-21 Thread Nico Weber via lldb-commits

Author: Nico Weber
Date: 2021-09-21T13:02:52-04:00
New Revision: 908c1154421287c6ffa0ef06ef5225a8fd0b06a7

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

LOG: [lldb/win] Default to native PDB reader when LLVM_ENABLE_DIA_SDK=NO

Trying to use the DIA SDK reader only to fail with "DIA SDK wasn't enabled"
isn't very useful. The native PDB reader is missing some stuff, but it's still
better than nothing.

Reduces number of lldb-check-shell test failures with LLVM_ENABLE_DIA_SDK=NO
from 27 to 15.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 794fab5f73095..be1c62c62006a 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,14 +87,16 @@ bool ShouldAddLine(uint32_t requested_line, uint32_t 
actual_line,
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
-  return use_native.equals_insensitive("on") ||
- use_native.equals_insensitive("yes") ||
- use_native.equals_insensitive("1") ||
- use_native.equals_insensitive("true");
-#else
-  return true;
+  if (!use_native.equals_insensitive("on") &&
+  !use_native.equals_insensitive("yes") &&
+  !use_native.equals_insensitive("1") &&
+  !use_native.equals_insensitive("true"))
+return false;
+#endif
 #endif
+  return true;
 }
 
 void SymbolFilePDB::Initialize() {



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


[Lldb-commits] [PATCH] D110172: [lldb/win] Default to native PDB reader when building with LLVM_ENABLE_DIA_SDK=NO

2021-09-21 Thread Nico Weber via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG908c11544212: [lldb/win] Default to native PDB reader when 
LLVM_ENABLE_DIA_SDK=NO (authored by thakis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110172

Files:
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,14 +87,16 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
-  return use_native.equals_insensitive("on") ||
- use_native.equals_insensitive("yes") ||
- use_native.equals_insensitive("1") ||
- use_native.equals_insensitive("true");
-#else
-  return true;
+  if (!use_native.equals_insensitive("on") &&
+  !use_native.equals_insensitive("yes") &&
+  !use_native.equals_insensitive("1") &&
+  !use_native.equals_insensitive("true"))
+return false;
+#endif
 #endif
+  return true;
 }
 
 void SymbolFilePDB::Initialize() {


Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,14 +87,16 @@
 
 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
-  return use_native.equals_insensitive("on") ||
- use_native.equals_insensitive("yes") ||
- use_native.equals_insensitive("1") ||
- use_native.equals_insensitive("true");
-#else
-  return true;
+  if (!use_native.equals_insensitive("on") &&
+  !use_native.equals_insensitive("yes") &&
+  !use_native.equals_insensitive("1") &&
+  !use_native.equals_insensitive("true"))
+return false;
+#endif
 #endif
+  return true;
 }
 
 void SymbolFilePDB::Initialize() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 40e971a - nullptr printing - update for a change to clang type printing that now uses "std::nullptr_t"

2021-09-21 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2021-09-21T11:50:24-07:00
New Revision: 40e971a21052a8638933037615e3c681e193f3fc

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

LOG: nullptr printing - update for a change to clang type printing that now 
uses "std::nullptr_t"

Added: 


Modified: 
lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp 
b/lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp
index 030ae95bf1ea1..75f9a029d448c 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp
@@ -210,9 +210,9 @@ auto null = &nullary;
 // FIXME: These currently don't work because clang-cl emits incorrect debug 
info
 // for std::nullptr_t.  We should fix these in clang-cl.
 auto rae = &unaryret;
-// CHECK: (nullptr_t (*)()) rae = {{.*}}
+// CHECK: (std::nullptr_t (*)()) rae = {{.*}}
 auto aae = &unary;
-// CHECK: (void (*)(nullptr_t)) aae = {{.*}}
+// CHECK: (void (*)(std::nullptr_t)) aae = {{.*}}
 
 int main(int argc, char **argv) {
   return 0;



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


[Lldb-commits] [PATCH] D109797: Fix rendezvous for rebase_exec=true case

2021-09-21 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay updated this revision to Diff 374026.
emrekultursay added a comment.

Update test to pass on MacOS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109797

Files:
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/test/API/functionalities/dlopen/Makefile
  lldb/test/API/functionalities/dlopen/TestDlopen.py
  lldb/test/API/functionalities/dlopen/b.cpp
  lldb/test/API/functionalities/dlopen/main.cpp

Index: lldb/test/API/functionalities/dlopen/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/main.cpp
@@ -0,0 +1,29 @@
+#include 
+#include 
+#include 
+#include 
+
+int main(int argc, char* argv[]) {
+  const char* solib = "./liblib_b.so";
+  if (argc == 2) {
+solib = argv[1];
+  }
+  printf("Using solib at: %s\n", solib);
+
+  int main_thread_continue = 0;
+  // Wait until debugger is attached.
+  int i = 0;
+  int timeout = 10;
+  for (i = 0; i < timeout; i++) {
+usleep(1000*1000); // break here
+if (main_thread_continue) {
+  break;
+}
+  }
+  assert(i != timeout && "timed out waiting for debugger");
+
+  // dlopen the 'liblib_b.so' shared library.
+  void* h = dlopen(solib, RTLD_LAZY);
+  assert(h && "dlopen failed?");
+  return i; // break after dlopen
+}
Index: lldb/test/API/functionalities/dlopen/b.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/b.cpp
@@ -0,0 +1,4 @@
+
+
+int LLDB_DYLIB_EXPORT b_function() { return 500; }
+
Index: lldb/test/API/functionalities/dlopen/TestDlopen.py
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/TestDlopen.py
@@ -0,0 +1,64 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfRemote
+@skipIfWindows
+def test_dlopen_after_attach(self):
+self.build()
+lib_name = 'liblib_b.so'
+if self.platformIsDarwin():
+  lib_name = 'liblib_b.dylib'
+
+exe = self.getBuildArtifact("a.out")
+lib = self.getBuildArtifact(lib_name)
+
+# Spawn a new process.
+# use realpath to workaround llvm.org/pr48376
+# Pass path to solib for dlopen to properly locate the library.
+popen = self.spawnSubprocess(os.path.realpath(exe), args = [os.path.realpath(lib)])
+pid = popen.pid
+
+# Attach to the spawned process.
+self.runCmd("process attach -p " + str(pid))
+
+target = self.dbg.GetSelectedTarget()
+process = target.GetProcess()
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Continue until first breakpoint.
+breakpoint1 = self.target().BreakpointCreateBySourceRegex(
+"// break here", lldb.SBFileSpec("main.cpp"))
+self.assertEqual(breakpoint1.GetNumResolvedLocations(), 1)
+stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint1)
+self.assertEqual(len(stopped_threads), 1)
+
+# Check that image list does not contain liblib_b before dlopen.
+self.match(
+"image list",
+patterns = [lib_name],
+matching = False,
+msg = lib_name + " should not have been in image list")
+
+# Change a variable to escape the loop
+self.runCmd("expression main_thread_continue = 1")
+
+# Continue so that dlopen is called.
+breakpoint2 = self.target().BreakpointCreateBySourceRegex(
+"// break after dlopen", lldb.SBFileSpec("main.cpp"))
+self.assertEqual(breakpoint2.GetNumResolvedLocations(), 1)
+process.Continue()
+self.assertEqual(len(stopped_threads), 1)
+
+# Check that image list contains liblib_b after dlopen.
+self.match(
+"image list",
+patterns = [lib_name],
+matching = True,
+msg = lib_name + " missing in image list")
+
Index: lldb/test/API/functionalities/dlopen/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp
+USE_LIBDL := 1
+
+lib_b:
+	$(MAKE) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_CXX_SOURCES=b.cpp DYLIB_NAME=lib_b
+all: lib_b
+
+include Makefile.rules
Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===
--- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -442,14 +442,18 @@
 if (module_sp->GetObjectFile()-

[Lldb-commits] [PATCH] D109797: Fix rendezvous for rebase_exec=true case

2021-09-21 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay updated this revision to Diff 374027.
emrekultursay added a comment.

Minor fix in test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109797

Files:
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/test/API/functionalities/dlopen/Makefile
  lldb/test/API/functionalities/dlopen/TestDlopen.py
  lldb/test/API/functionalities/dlopen/b.cpp
  lldb/test/API/functionalities/dlopen/main.cpp

Index: lldb/test/API/functionalities/dlopen/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/main.cpp
@@ -0,0 +1,29 @@
+#include 
+#include 
+#include 
+#include 
+
+int main(int argc, char* argv[]) {
+  const char* solib = "./liblib_b.so";
+  if (argc == 2) {
+solib = argv[1];
+  }
+  printf("Using solib at: %s\n", solib);
+
+  int main_thread_continue = 0;
+  // Wait until debugger is attached.
+  int i = 0;
+  int timeout = 10;
+  for (i = 0; i < timeout; i++) {
+usleep(1000*1000); // break here
+if (main_thread_continue) {
+  break;
+}
+  }
+  assert(i != timeout && "timed out waiting for debugger");
+
+  // dlopen the 'liblib_b.so' shared library.
+  void* h = dlopen(solib, RTLD_LAZY);
+  assert(h && "dlopen failed?");
+  return i; // break after dlopen
+}
Index: lldb/test/API/functionalities/dlopen/b.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/b.cpp
@@ -0,0 +1,4 @@
+
+
+int LLDB_DYLIB_EXPORT b_function() { return 500; }
+
Index: lldb/test/API/functionalities/dlopen/TestDlopen.py
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/TestDlopen.py
@@ -0,0 +1,64 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfRemote
+@skipIfWindows
+def test_dlopen_after_attach(self):
+self.build()
+lib_name = 'liblib_b.so'
+if self.platformIsDarwin():
+  lib_name = 'liblib_b.dylib'
+
+exe = self.getBuildArtifact("a.out")
+lib = self.getBuildArtifact(lib_name)
+
+# Spawn a new process.
+# use realpath to workaround llvm.org/pr48376
+# Pass path to solib for dlopen to properly locate the library.
+popen = self.spawnSubprocess(os.path.realpath(exe), args = [os.path.realpath(lib)])
+pid = popen.pid
+
+# Attach to the spawned process.
+self.runCmd("process attach -p " + str(pid))
+
+target = self.dbg.GetSelectedTarget()
+process = target.GetProcess()
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Continue until first breakpoint.
+breakpoint1 = self.target().BreakpointCreateBySourceRegex(
+"// break here", lldb.SBFileSpec("main.cpp"))
+self.assertEqual(breakpoint1.GetNumResolvedLocations(), 1)
+stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint1)
+self.assertEqual(len(stopped_threads), 1)
+
+# Check that image list does not contain liblib_b before dlopen.
+self.match(
+"image list",
+patterns = [lib_name],
+matching = False,
+msg = lib_name + " should not have been in image list")
+
+# Change a variable to escape the loop
+self.runCmd("expression main_thread_continue = 1")
+
+# Continue so that dlopen is called.
+breakpoint2 = self.target().BreakpointCreateBySourceRegex(
+"// break after dlopen", lldb.SBFileSpec("main.cpp"))
+self.assertEqual(breakpoint2.GetNumResolvedLocations(), 1)
+stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint2)
+self.assertEqual(len(stopped_threads), 1)
+
+# Check that image list contains liblib_b after dlopen.
+self.match(
+"image list",
+patterns = [lib_name],
+matching = True,
+msg = lib_name + " missing in image list")
+
Index: lldb/test/API/functionalities/dlopen/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/dlopen/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp
+USE_LIBDL := 1
+
+lib_b:
+	$(MAKE) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_CXX_SOURCES=b.cpp DYLIB_NAME=lib_b
+all: lib_b
+
+include Makefile.rules
Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===
--- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -442,14 +

[Lldb-commits] [PATCH] D109797: Fix rendezvous for rebase_exec=true case

2021-09-21 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay added a comment.

plabath/mgorny: This change is ready for another round of review.  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109797

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


[Lldb-commits] [PATCH] D109928: [lldb] Remove IRExecutionUnit::CollectFallbackNames

2021-09-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

I think this looks fine, just verify that this in a C++ case an expression with 
an `extern "C"` function call works fine e.g.

  extern "C" {
int g() { return 10;}
  }
  
  int main() {
 return g();  // break here and run expr g()
  }

I discovered the other day that we mangle `extern "C"` functions in C++ mode 
and I have a fix I wanted to run by everyone but I have not had a chance to do 
it yet.

So this case get resolved in `CollectFallbackNames(...)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109928

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


[Lldb-commits] [PATCH] D110013: [lldb][crashlog] Avoid specifying arch for image when a UUID is present

2021-09-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Without having dug into this deeper, do you think not specifying the arch could 
cause any problems with universal binaries? I guess not, because we still have 
the UUID, and the UUID is per arch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110013

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


[Lldb-commits] [PATCH] D109937: [lldb] Handle malformed qfThreadInfo reply

2021-09-21 Thread Ted Woodward via Phabricator via lldb-commits
ted updated this revision to Diff 374049.
ted added a comment.

[lldb] Handle malformed qfThreadInfo reply

Add requested test.
Refine handling of malformed reply with no valid threads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109937

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py


Index: 
lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py
===
--- /dev/null
+++ 
lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py
@@ -0,0 +1,29 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestThreadInfoTrailingComma(GDBRemoteTestBase):
+
+def test(self):
+class MyResponder(MockGDBServerResponder):
+def haltReason(self):
+return "T02thread:1"
+
+def qfThreadInfo(self):
+return "m1,2,3,4,"
+
+self.server.responder = MyResponder()
+target = self.dbg.CreateTarget('')
+if self.TraceOn():
+  self.runCmd("log enable gdb-remote packets")
+  self.addTearDownHook(
+lambda: self.runCmd("log disable gdb-remote packets"))
+process = self.connect(target)
+print(process.GetThreadAtIndex(0).GetFrameAtIndex(0))
+
print(process.GetThreadAtIndex(0).GetFrameAtIndex(0).FindRegister("pc"))
+self.assertEqual(process.GetThreadAtIndex(0).GetThreadID(), 1)
+self.assertEqual(process.GetThreadAtIndex(1).GetThreadID(), 2)
+self.assertEqual(process.GetThreadAtIndex(2).GetThreadID(), 3)
+self.assertEqual(process.GetThreadAtIndex(3).GetThreadID(), 4)
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
@@ -2906,8 +2906,12 @@
   if (ch == 'm') {
 do {
   auto pid_tid = response.GetPidTid(LLDB_INVALID_PROCESS_ID);
+  // If we get an invalid response, break out of the loop.
+  // If there are valid tids, they have been added to ids.
+  // If there are no valid tids, we'll fall through to the
+  // bare-iron target handling below.
   if (!pid_tid)
-return {};
+break;
 
   ids.push_back(pid_tid.getValue());
   ch = response.GetChar(); // Skip the command separator


Index: lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py
@@ -0,0 +1,29 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestThreadInfoTrailingComma(GDBRemoteTestBase):
+
+def test(self):
+class MyResponder(MockGDBServerResponder):
+def haltReason(self):
+return "T02thread:1"
+
+def qfThreadInfo(self):
+return "m1,2,3,4,"
+
+self.server.responder = MyResponder()
+target = self.dbg.CreateTarget('')
+if self.TraceOn():
+  self.runCmd("log enable gdb-remote packets")
+  self.addTearDownHook(
+lambda: self.runCmd("log disable gdb-remote packets"))
+process = self.connect(target)
+print(process.GetThreadAtIndex(0).GetFrameAtIndex(0))
+print(process.GetThreadAtIndex(0).GetFrameAtIndex(0).FindRegister("pc"))
+self.assertEqual(process.GetThreadAtIndex(0).GetThreadID(), 1)
+self.assertEqual(process.GetThreadAtIndex(1).GetThreadID(), 2)
+self.assertEqual(process.GetThreadAtIndex(2).GetThreadID(), 3)
+self.assertEqual(process.GetThreadAtIndex(3).GetThreadID(), 4)
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
@@ -2906,8 +2906,12 @@
   if (ch == 'm') {
 do {
   auto pid_tid = response.GetPidTid(LLDB_INVALID_PROCESS_ID);
+  // If we get an invalid response, break out of the loop.
+  // If there are valid tids, they have been added to ids.
+  // If there are no valid tids, we'll fall through to the
+  // bare-iron target handling below.
   if (!pid_tid)
-return {};
+break;
 
   ids.push_back(pid

[Lldb-commits] [PATCH] D110013: [lldb][crashlog] Avoid specifying arch for image when a UUID is present

2021-09-21 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.

In D110013#3013733 , @aprantl wrote:

> Without having dug into this deeper, do you think not specifying the arch 
> could cause any problems with universal binaries? I guess not, because we 
> still have the UUID, and the UUID is per arch?

Exactly. The bug in question actually did source universal binaries: 
CreateTargetInternal was able to select the correct slice based on the UUID.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110013

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


[Lldb-commits] [PATCH] D109928: [lldb] Remove IRExecutionUnit::CollectFallbackNames

2021-09-21 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

In D109928#3013627 , @shafik wrote:

> I think this looks fine, just verify that this in a C++ case an expression 
> with an `extern "C"` function call works fine e.g.
>
>   extern "C" {
> int g() { return 10;}
>   }
>   
>   int main() {
>  return g();  // break here and run expr g()
>   }
>
> I discovered the other day that we mangle `extern "C"` functions in C++ mode 
> and I have a fix I wanted to run by everyone but I have not had a chance to 
> do it yet.
>
> So this case get resolved in `CollectFallbackNames(...)`.

I believe this is already covered by `TestExternCSymbols.py` in 
`test/API/cpp/extern_c/`. `CollectFallbackNames` did correctly resolve this 
case, so I made sure this change didn't break that test.

Anything you think I should change or is this good to go?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109928

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


[Lldb-commits] [PATCH] D110013: [lldb][crashlog] Avoid specifying arch for image when a UUID is present

2021-09-21 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D110013#3013733 , @aprantl wrote:

> Without having dug into this deeper, do you think not specifying the arch 
> could cause any problems with universal binaries? I guess not, because we 
> still have the UUID, and the UUID is per arch?

Yeah in the no-UUID case we need to depend on a filepath and an arch to 
uniquely identify a binary (and hope that the filepath is the same binary).  In 
practice we see UUIDs for all binaries on darwin systems in crash reports.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110013

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


[Lldb-commits] [lldb] 47f79c6 - [lldb] Add --stack option to `target symbols add` command

2021-09-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-09-21T23:08:14-07:00
New Revision: 47f79c6057764e0c83016269ae2359f8c5c8d135

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

LOG: [lldb] Add --stack option to `target symbols add` command

Currently you can ask the target symbols add command to locate the debug
symbols for the current frame. This patch add an options to do that for
the whole call stack.

Differential revision: https://reviews.llvm.org/D110011

Added: 
lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py

Modified: 
lldb/source/Commands/CommandObjectTarget.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 92aa8fc70a7bb..439ac45bfbec5 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -3962,8 +3962,12 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
 "name."),
 m_current_frame_option(
 LLDB_OPT_SET_2, false, "frame", 'F',
-"Locate the debug symbols for the currently selected frame.",
-false, true)
+"Locate the debug symbols for the currently selected frame.", 
false,
+true),
+m_current_stack_option(LLDB_OPT_SET_2, false, "stack", 'S',
+   "Locate the debug symbols for every frame in "
+   "the current call stack.",
+   false, true)
 
   {
 m_option_group.Append(&m_uuid_option_group, LLDB_OPT_SET_ALL,
@@ -3971,6 +3975,8 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
 m_option_group.Append(&m_file_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(&m_current_frame_option, LLDB_OPT_SET_2,
   LLDB_OPT_SET_2);
+m_option_group.Append(&m_current_stack_option, LLDB_OPT_SET_2,
+  LLDB_OPT_SET_2);
 m_option_group.Finalize();
   }
 
@@ -4247,6 +4253,63 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
 return true;
   }
 
+  bool AddSymbolsForStack(CommandReturnObject &result, bool &flush) {
+assert(m_current_stack_option.GetOptionValue().OptionWasSet());
+
+Process *process = m_exe_ctx.GetProcessPtr();
+if (!process) {
+  result.AppendError(
+  "a process must exist in order to use the --stack option");
+  return false;
+}
+
+const StateType process_state = process->GetState();
+if (!StateIsStoppedState(process_state, true)) {
+  result.AppendErrorWithFormat("process is not stopped: %s",
+   StateAsCString(process_state));
+  return false;
+}
+
+Thread *thread = m_exe_ctx.GetThreadPtr();
+if (!thread) {
+  result.AppendError("invalid current thread");
+  return false;
+}
+
+bool symbols_found = false;
+uint32_t frame_count = thread->GetStackFrameCount();
+for (uint32_t i = 0; i < frame_count; ++i) {
+  lldb::StackFrameSP frame_sp = thread->GetStackFrameAtIndex(i);
+
+  ModuleSP frame_module_sp(
+  frame_sp->GetSymbolContext(eSymbolContextModule).module_sp);
+  if (!frame_module_sp)
+continue;
+
+  ModuleSpec module_spec;
+  module_spec.GetUUID() = frame_module_sp->GetUUID();
+
+  if (FileSystem::Instance().Exists(
+  frame_module_sp->GetPlatformFileSpec())) {
+module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
+module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
+  }
+
+  bool current_frame_flush = false;
+  if (DownloadObjectAndSymbolFile(module_spec, result, 
current_frame_flush))
+symbols_found = true;
+  flush |= current_frame_flush;
+}
+
+if (!symbols_found) {
+  result.AppendError(
+  "unable to find debug symbols in the current call stack");
+  return false;
+}
+
+return true;
+  }
+
   bool DoExecute(Args &args, CommandReturnObject &result) override {
 Target *target = m_exe_ctx.GetTargetPtr();
 result.SetStatus(eReturnStatusFailed);
@@ -4257,6 +4320,8 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
 const bool file_option_set = m_file_option.GetOptionValue().OptionWasSet();
 const bool frame_option_set =
 m_current_frame_option.GetOptionValue().OptionWasSet();
+const bool stack_option_set =
+m_current_stack_option.GetOptionValue().OptionWasSet();
 const size_t argc = args.GetArgumentCount();
 
 if (argc == 0) {
@@ -4266,6 +4331,8 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
 AddSymbolsForFile(result, flush);
   else if (frame_option_set)

[Lldb-commits] [PATCH] D110011: [lldb] Add --stack option to `target symbols add` command

2021-09-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47f79c605776: [lldb] Add --stack option to `target symbols 
add` command (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110011

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py

Index: lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
===
--- /dev/null
+++ lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
@@ -0,0 +1,98 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipUnlessDarwin
+class AddDsymDownload(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+dwarfdump_uuid_regex = re.compile('UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*')
+
+def get_uuid(self):
+dwarfdump_cmd_output = subprocess.check_output(
+('/usr/bin/dwarfdump --uuid "%s"' % self.exe),
+shell=True).decode("utf-8")
+for line in dwarfdump_cmd_output.splitlines():
+match = self.dwarfdump_uuid_regex.search(line)
+if match:
+return match.group(1)
+return None
+
+def create_dsym_for_uuid(self):
+shell_cmds = [
+'#! /bin/sh', '# the last argument is the uuid',
+'while [ $# -gt 1 ]', 'do', '  shift', 'done', 'ret=0',
+'echo ""',
+'echo "http://www.apple.com/DTDs/PropertyList-1.0.dtd\\";>"',
+'echo ""', '',
+'if [ "$1" != "%s" ]' % (self.uuid), 'then',
+'  echo "DBGErrornot found"',
+'  echo ""', '  exit 1', 'fi',
+'  uuid=%s' % self.uuid,
+'  bin=%s' % self.exe,
+'  dsym=%s' % self.dsym, 'echo "$uuid"', '',
+'echo "DBGDSYMPath$dsym"',
+'echo "DBGSymbolRichExecutable$bin"',
+'echo ""', 'exit $ret'
+]
+
+with open(self.dsym_for_uuid, "w") as writer:
+for l in shell_cmds:
+writer.write(l + '\n')
+
+os.chmod(self.dsym_for_uuid, 0o755)
+
+def setUp(self):
+TestBase.setUp(self)
+self.source = 'main.c'
+self.exe = self.getBuildArtifact("a.out")
+self.dsym = os.path.join(
+self.getBuildDir(),
+"hide.app/Contents/a.out.dSYM/Contents/Resources/DWARF/",
+os.path.basename(self.exe))
+self.dsym_for_uuid = self.getBuildArtifact("dsym-for-uuid.sh")
+
+self.buildDefault(dictionary={'MAKE_DSYM': 'YES'})
+self.assertTrue(os.path.exists(self.exe))
+self.assertTrue(os.path.exists(self.dsym))
+
+self.uuid = self.get_uuid()
+self.assertNotEqual(self.uuid, None, "Could not get uuid for a.out")
+
+self.create_dsym_for_uuid()
+
+os.environ['LLDB_APPLE_DSYMFORUUID_EXECUTABLE'] = self.dsym_for_uuid
+self.addTearDownHook(
+lambda: os.environ.pop('LLDB_APPLE_DSYMFORUUID_EXECUTABLE', None))
+
+def do_test(self, command):
+self.target = self.dbg.CreateTarget(self.exe)
+self.assertTrue(self.target, VALID_TARGET)
+
+main_bp = self.target.BreakpointCreateByName("main", "a.out")
+self.assertTrue(main_bp, VALID_BREAKPOINT)
+
+self.process = self.target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(self.process, PROCESS_IS_VALID)
+
+# The stop reason of the thread should be breakpoint.
+self.assertEquals(self.process.GetState(), lldb.eStateStopped,
+  STOPPED_DUE_TO_BREAKPOINT)
+
+self.runCmd(command)
+self.expect("frame select", substrs=['a.out`main at main.c'])
+
+@no_debug_info_test
+def test_frame(self):
+self.do_test("add-dsym --frame")
+
+@no_debug_info_test
+def test_uuid(self):
+self.do_test("add-dsym --uuid {}".format(self.uuid))
+
+@no_debug_info_test
+def test_stack(self):
+self.do_test("add-dsym --stack")
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -3962,8 +3962,12 @@
 "name."),
 m_current_frame_option(
 LLDB_OPT_SET_2, false, "frame", 'F',
-"Locate the debug symbols for the currently selected frame.",
-false, true)
+"Locate the debug symbols for the currently selected frame.", false,
+true),
+m_current_stack_option(LLDB_OPT_SET_2, false, "stack", 'S',
+   "Locate the debug symbols for every frame in "