[Lldb-commits] [PATCH] D136809: [CMake] Make sure all headers are installed into `CLANG_RESOURCE_DIR`

2022-11-11 Thread LJC via Phabricator via lldb-commits
paperchalice updated this revision to Diff 474715.
paperchalice added a comment.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add cmake module to handle clang resource dir.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136809

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  cmake/Modules/GetClangResourceDir.cmake
  compiler-rt/cmake/base-config-ix.cmake
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake
  openmp/CMakeLists.txt

Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -79,8 +79,8 @@
 if(${OPENMP_STANDALONE_BUILD})
   set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
 else()
-  string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION})
-  set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include")
+  include(GetClangResourceDir)
+  get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
 endif()
 
 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -257,7 +257,11 @@
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
  ${PACKAGE_VERSION})
-  set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+set(resource_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR})
+  else()
+set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  endif()
   set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
   foreach(type ${flag_types})
 set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})
Index: lldb/unittests/Expression/ClangParserTest.cpp
===
--- lldb/unittests/Expression/ClangParserTest.cpp
+++ lldb/unittests/Expression/ClangParserTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangHost.h"
 #include "TestingSupport/SubsystemRAII.h"
@@ -37,12 +38,16 @@
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
 #if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
-  std::string path_to_clang_dir =
-  "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING;
+  std::string path_to_clang_dir = CLANG_RESOURCE_DIR[0]
+  ? "/foo/bar/bin/" CLANG_RESOURCE_DIR
+  : "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME
+"/clang/" CLANG_VERSION_MAJOR_STRING;
 #else
   std::string path_to_liblldb = "C:\\foo\\bar\\lib";
   std::string path_to_clang_dir =
-  "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
+  CLANG_RESOURCE_DIR[0]
+  ? "C:\\foo\\bar\\bin\\" CLANG_RESOURCE_DIR
+  : "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
 #endif
   EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -54,8 +54,11 @@
 
   static const llvm::StringRef kResourceDirSuffixes[] = {
   // LLVM.org's build of LLDB uses the clang resource directory placed
-  // in $install_dir/lib{,64}/clang/$clang_version.
-  CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING,
+  // in $install_dir/lib{,64}/clang/$clang_version or
+  // $install_dir/bin/$CLANG_RESOURCE_DIR
+  CLANG_RESOURCE_DIR[0] ? "bin/" CLANG_RESOURCE_DIR
+: CLANG_INSTALL_LIBDIR_BASENAME
+  "/clang/" CLANG_VERSION_MAJOR_STRING,
   // swift-lldb uses the clang resource directory copied from swift, which
   // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
   // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -7,6 +7,7 @@
 include(Check

[Lldb-commits] [PATCH] D136809: [CMake] Make sure all headers are installed into `CLANG_RESOURCE_DIR`

2022-11-11 Thread LJC via Phabricator via lldb-commits
paperchalice added inline comments.
Herald added subscribers: Michael137, JDevlieghere.



Comment at: clang/lib/Headers/CMakeLists.txt:285
+include(GetClangResourceDir)
+get_clang_resource_dir(output_dir PREFIX ${LLVM_BINARY_DIR}/$ SUBDIR 
include)
 set(out_files)

Another choice is `${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}`, but the variable 
`CMAKE_CFG_INTDIR` is [[ 
https://cmake.org/cmake/help/latest/variable/CMAKE_CFG_INTDIR.html | deprecated 
]] since 3.21



Comment at: cmake/Modules/GetClangResourceDir.cmake:13
+  else()
+string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION})
+set(ret_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR})

Can I always rely on `PACKAGE_VERSION`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136809

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


[Lldb-commits] [PATCH] D132624: [LLDB] Devirtualize coroutine promise types for `std::coroutine_handle`

2022-11-11 Thread Adrian Vogelsgesang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG558db7787005: [LLDB] Devirtualize coroutine promise types 
for `std::coroutine_handle` (authored by avogelsgesang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132624

Files:
  lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
@@ -43,6 +43,8 @@
   bool is_supported = is_implementation_supported();
   int_generator gen = my_generator_func();
   std::coroutine_handle<> type_erased_hdl = gen.hdl;
+  std::coroutine_handle incorrectly_typed_hdl =
+  std::coroutine_handle::from_address(gen.hdl.address());
   gen.hdl.resume();// Break at initial_suspend
   gen.hdl.resume();// Break after co_yield
   empty_function_so_we_can_set_a_breakpoint(); // Break at final_suspend
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
@@ -16,6 +16,7 @@
 def do_test(self, stdlib_type):
 """Test std::coroutine_handle is displayed correctly."""
 self.build(dictionary={stdlib_type: "1"})
+is_clang = self.expectedCompiler(["clang"])
 
 test_generator_func_ptr_re = re.compile(
 r"^\(a.out`my_generator_func\(\) at main.cpp:[0-9]*\)$")
@@ -37,14 +38,31 @@
 ValueCheck(name="current_value", value = "-1"),
 ])
 ])
-# For type-erased `coroutine_handle<>` we are missing the `promise`
-# but still show `resume` and `destroy`.
-self.expect_expr("type_erased_hdl",
-result_summary=re.compile("^coro frame = 0x[0-9a-f]*$"),
-result_children=[
-ValueCheck(name="resume", summary = test_generator_func_ptr_re),
-ValueCheck(name="destroy", summary = test_generator_func_ptr_re),
-])
+if is_clang:
+# For a type-erased `coroutine_handle<>`, we can still devirtualize
+# the promise call and display the correctly typed promise.
+self.expect_expr("type_erased_hdl",
+result_summary=re.compile("^coro frame = 0x[0-9a-f]*$"),
+result_children=[
+ValueCheck(name="resume", summary = test_generator_func_ptr_re),
+ValueCheck(name="destroy", summary = test_generator_func_ptr_re),
+ValueCheck(name="promise", children=[
+ValueCheck(name="current_value", value = "-1"),
+])
+])
+# For an incorrectly typed `coroutine_handle`, we use the user-supplied
+# incorrect type instead of inferring the correct type. Strictly speaking,
+# incorrectly typed coroutine handles are undefined behavior. However,
+# it provides probably a better debugging experience if we display the
+# promise as seen by the program instead of fixing this bug based on
+# the available debug info.
+self.expect_expr("incorrectly_typed_hdl",
+result_summary=re.compile("^coro frame = 0x[0-9a-f]*$"),
+result_children=[
+ValueCheck(name="resume", summary = test_generator_func_ptr_re),
+ValueCheck(name="destroy", summary = test_generator_func_ptr_re),
+ValueCheck(name="promise", value="-1")
+])
 
 # Run until after the `co_yield`
 process = self.process()
@@ -73,6 +91,18 @@
 ValueCheck(name="current_value", value = "42"),
 ])
 ])
+if is_clang:
+# Devirtualization still works, also at the final suspension point, despite
+# the `resume` pointer being reset to a nullptr
+self.expect_expr("type_erased_hdl",
+result_summary=re.compile("^coro frame = 0x[0-9a-f]*$"),
+result_children=[
+ValueCheck(name="resum

[Lldb-commits] [lldb] 558db77 - [LLDB] Devirtualize coroutine promise types for `std::coroutine_handle`

2022-11-11 Thread Adrian Vogelsgesang via lldb-commits

Author: Adrian Vogelsgesang
Date: 2022-11-11T09:37:08-08:00
New Revision: 558db7787005348e2efaabb628ec36f1c461a741

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

LOG: [LLDB] Devirtualize coroutine promise types for `std::coroutine_handle`

This commit teaches the `std::coroutine_handle` pretty-printer to
devirtualize type-erased promise types. This is particularly useful to
resonstruct call stacks, either of asynchronous control flow or of
recursive invocations of `std::generator`. For the example recently
introduced by https://reviews.llvm.org/D132451, printing the `__promise`
variable now shows

```
(std::__coroutine_traits_sfinae::promise_type) __promise = {
  continuation = coro frame = 0x55562430 {
resume = 0x6310 (a.out`task detail::chain_fn<1>() at 
llvm-nested-example.cpp:66)
destroy = 0x6700 (a.out`task detail::chain_fn<1>() at 
llvm-nested-example.cpp:66)
promise = {
  continuation = coro frame = 0x555623e0 {
resume = 0x7070 (a.out`task detail::chain_fn<2>() at 
llvm-nested-example.cpp:66)
destroy = 0x7460 (a.out`task detail::chain_fn<2>() at 
llvm-nested-example.cpp:66)
promise = {
  ...
}
  }
  result = 0
}
  }
  result = 0
}
```

(shortened to keep the commit message readable) instead of

```
(std::__coroutine_traits_sfinae::promise_type) __promise = {
  continuation = coro frame = 0x55562430 {
resume = 0x6310 (a.out`task detail::chain_fn<1>() at 
llvm-nested-example.cpp:66)
destroy = 0x6700 (a.out`task detail::chain_fn<1>() at 
llvm-nested-example.cpp:66)
  }
  result = 0
}
```

Note how the new debug output reveals the complete asynchronous call
stack: our own function resumes `chain_fn<1>` which in turn will resume
`chain_fn<2>` and so on. Thereby this change allows users of lldb to
inspect the logical coroutine call stack without using any custom debug
scripts (although the display is still a bit clumsy. It would be nicer
to also integrate this into lldb's backtrace feature, but I don't know
how to do so)

The devirtualization currently works by introspecting the function
pointed to by the `destroy` pointer. (The `resume` pointer is not worth
much, given that for the final suspend point `resume` is set to a
nullptr. We have to use the `destroy` pointer instead.) We then look
for a `__promise` variable inside the `destroy` function. This
`__promise` variable is synthetically generated by LLVM, and looking at
its type reveals the type-erased promise_type.

This approach only works for clang-generated code, though. While gcc
also adds a `_Coro_promise` variable to the `resume` function, it does
not do so for the `destroy` function. However, we can't use the `resume`
function, as it will be reset to a nullptr at the final suspension
point. For the time being, I am happy with de-virtualization only working
for clang. A follow-up commit will further improve devirtualization and
also expose the variables spilled to the coroutine frame. As part of
this, I will also revisit gcc support.

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

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 5427a7a2b7850..89ee4bb67f931 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -9,6 +9,8 @@
 #include "Coroutines.h"
 
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/VariableList.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -32,6 +34,57 @@ static ValueObjectSP GetCoroFramePtrFromHandle(ValueObject 
&valobj) {
   return ptr_sp;
 }
 
+static Function *ExtractDestroyFunction(ValueObjectSP &frame_ptr_sp) {
+  lldb::TargetSP target_sp = frame_ptr_sp->GetTargetSP();
+  lldb::ProcessSP process_sp = frame_ptr_sp->GetProcessSP();
+  auto ptr_size = process_sp->GetAddressByteSize();
+
+  AddressType addr_type;
+  lldb::addr_t frame_ptr_addr = frame_ptr_sp->GetPointerValue(&addr_type);
+  if (!frame_ptr_addr || frame_ptr_addr == LLDB_INVALID_ADDRESS)
+return nullptr;
+  lldbassert(addr_type == AddressType::eAddressTypeLoad);
+
+  Status error;
+  // The destroy pointer is the 2nd pointer inside the compiler-generated
+  // `pair`.
+  auto destroy_func_ptr_addr = frame_ptr_addr + ptr_si

[Lldb-commits] [lldb] d7e1c27 - Revert "[LLDB] Devirtualize coroutine promise types for `std::coroutine_handle`"

2022-11-11 Thread Adrian Vogelsgesang via lldb-commits

Author: Adrian Vogelsgesang
Date: 2022-11-11T10:00:58-08:00
New Revision: d7e1c2770fa57fb8df2f09f74d433ac9cf80a595

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

LOG: Revert "[LLDB] Devirtualize coroutine promise types for 
`std::coroutine_handle`"

This reverts commit 558db7787005348e2efaabb628ec36f1c461a741 due to
buildbot failures on ARM
* https://lab.llvm.org/buildbot/#/builders/96/builds/31416
* https://lab.llvm.org/buildbot/#/builders/17/builds/30086

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 89ee4bb67f931..5427a7a2b7850 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -9,8 +9,6 @@
 #include "Coroutines.h"
 
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "lldb/Symbol/Function.h"
-#include "lldb/Symbol/VariableList.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -34,57 +32,6 @@ static ValueObjectSP GetCoroFramePtrFromHandle(ValueObject 
&valobj) {
   return ptr_sp;
 }
 
-static Function *ExtractDestroyFunction(ValueObjectSP &frame_ptr_sp) {
-  lldb::TargetSP target_sp = frame_ptr_sp->GetTargetSP();
-  lldb::ProcessSP process_sp = frame_ptr_sp->GetProcessSP();
-  auto ptr_size = process_sp->GetAddressByteSize();
-
-  AddressType addr_type;
-  lldb::addr_t frame_ptr_addr = frame_ptr_sp->GetPointerValue(&addr_type);
-  if (!frame_ptr_addr || frame_ptr_addr == LLDB_INVALID_ADDRESS)
-return nullptr;
-  lldbassert(addr_type == AddressType::eAddressTypeLoad);
-
-  Status error;
-  // The destroy pointer is the 2nd pointer inside the compiler-generated
-  // `pair`.
-  auto destroy_func_ptr_addr = frame_ptr_addr + ptr_size;
-  lldb::addr_t destroy_func_addr =
-  process_sp->ReadPointerFromMemory(destroy_func_ptr_addr, error);
-  if (error.Fail())
-return nullptr;
-
-  Address destroy_func_address;
-  if (!target_sp->ResolveLoadAddress(destroy_func_addr, destroy_func_address))
-return nullptr;
-
-  Function *destroy_func =
-  destroy_func_address.CalculateSymbolContextFunction();
-  if (!destroy_func)
-return nullptr;
-
-  return destroy_func;
-}
-
-static CompilerType InferPromiseType(Function &destroy_func) {
-  SymbolContext sc;
-  Block &block = destroy_func.GetBlock(true);
-  auto variable_list = block.GetBlockVariableList(true);
-
-  // clang generates an artificial `__promise` variable inside the
-  // `destroy` function. Look for it.
-  auto promise_var = variable_list->FindVariable(ConstString("__promise"));
-  if (!promise_var)
-return {};
-  if (!promise_var->IsArtificial())
-return {};
-
-  Type *promise_type = promise_var->GetType();
-  if (!promise_type)
-return {};
-  return promise_type->GetForwardCompilerType();
-}
-
 static CompilerType GetCoroutineFrameType(TypeSystemClang &ast_ctx,
   CompilerType promise_type) {
   CompilerType void_type = ast_ctx.GetBasicType(lldb::eBasicTypeVoid);
@@ -111,11 +58,7 @@ bool 
lldb_private::formatters::StdlibCoroutineHandleSummaryProvider(
   if (!ptr_sp)
 return false;
 
-  if (!ptr_sp->GetValueAsUnsigned(0)) {
-stream << "nullptr";
-  } else {
-stream.Printf("coro frame = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
-  }
+  stream.Printf("coro frame = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
   return true;
 }
 
@@ -157,26 +100,15 @@ bool 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
   if (!ptr_sp)
 return false;
 
-  // Get the `promise_type` from the template argument
+  TypeSystemClang *ast_ctx = llvm::dyn_cast_or_null(
+  valobj_sp->GetCompilerType().GetTypeSystem());
+  if (!ast_ctx)
+return false;
+
   CompilerType promise_type(
   valobj_sp->GetCompilerType().GetTypeTemplateArgument(0));
   if (!promise_type)
 return false;
-
-  // Try to infer the promise_type if it was type-erased
-  if (promise_type.IsVoidType()) {
-if (Function *destroy_func = ExtractDestroyFunction(ptr_sp)) {
-  if (CompilerType inferred_type = InferPromiseType(*destroy_func)) {
-promise_type = inferred_type;
-  }
-}
-  }
-
-  // Build the coroutine frame type
-  TypeSystemClang *ast_ctx = llvm::dyn_cast_or_null(
-  ptr_sp->GetCompilerType().GetTypeSystem());
-  if (!ast_ctx)
-return {};
   CompilerType coro_frame_type = GetCoroutineFrameType(*ast_ctx, promise_type);
 
   m_frame_

[Lldb-commits] [lldb] 2d2854c - [lldb] [cmake] Fix typo in unittest directory path

2022-11-11 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-11-11T20:40:37+01:00
New Revision: 2d2854c7d5f9c1723e7ecbe7e8b8f9a2a78941a9

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

LOG: [lldb] [cmake] Fix typo in unittest directory path

Fix a typo in a11cd0d94ed3cabf0998a0289aead05da94c86eb that resulted
in additional "}" in unittest directory path, e.g.:

CMake Error at cmake/modules/LLDBStandalone.cmake:104 (add_subdirectory):
  add_subdirectory given source
  
"/var/tmp/portage/dev-util/lldb-16.0.0_pre2022/work/lldb/../third-party}/utils/unittest"
  which is not an existing directory.
Call Stack (most recent call first):
  CMakeLists.txt:29 (include)

Added: 


Modified: 
lldb/cmake/modules/LLDBStandalone.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBStandalone.cmake 
b/lldb/cmake/modules/LLDBStandalone.cmake
index ce16f558012c5..22a284adc222b 100644
--- a/lldb/cmake/modules/LLDBStandalone.cmake
+++ b/lldb/cmake/modules/LLDBStandalone.cmake
@@ -101,7 +101,7 @@ if(LLDB_INCLUDE_TESTS)
   # Build the gtest library needed for unittests, if we have LLVM sources
   # handy.
   if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest AND NOT TARGET llvm_gtest)
-add_subdirectory(${LLVM_THIRD_PARTY_DIR}}/utils/unittest 
third-party/unittest)
+add_subdirectory(${LLVM_THIRD_PARTY_DIR}/utils/unittest 
third-party/unittest)
   endif()
   # LLVMTestingSupport library is needed for Process/gdb-remote.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support



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


[Lldb-commits] [PATCH] D133395: [lldb] Update regex to be less fragile in TestDataFormatterGenericUnordered

2022-11-11 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f121a3f18f7: [lldb] Update regex to be less fragile in 
TestDataFormatterGenericUnordered (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133395

Files:
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -36,6 +36,9 @@
 self.runCmd(
 "settings set target.max-children-count 256",
 check=False)
+self.runCmd(
+'settings set auto-one-line-summaries true',
+check=False)
 
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
@@ -47,16 +50,19 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
+# Ensure key/value children, not wrapped in a layer.
+# This regex depends on auto-one-line-summaries.
+self.runCmd('settings set auto-one-line-summaries false')
+children_are_key_value = r'\[0\] = \{\s*first = '
 
 self.look_for_content_and_continue(
 "map", ['%s::unordered_map' % ns,
-must_not_contain__cc,
+children_are_key_value,
 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
 
 self.look_for_content_and_continue(
 "mmap", ['%s::unordered_multimap' % ns,
- must_not_contain__cc,
+ children_are_key_value,
  'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -36,6 +36,9 @@
 self.runCmd(
 "settings set target.max-children-count 256",
 check=False)
+self.runCmd(
+'settings set auto-one-line-summaries true',
+check=False)
 
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
@@ -47,16 +50,19 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
+# Ensure key/value children, not wrapped in a layer.
+# This regex depends on auto-one-line-summaries.
+self.runCmd('settings set auto-one-line-summaries false')
+children_are_key_value = r'\[0\] = \{\s*first = '
 
 self.look_for_content_and_continue(
 "map", ['%s::unordered_map' % ns,
-must_not_contain__cc,
+children_are_key_value,
 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
 
 self.look_for_content_and_continue(
 "mmap", ['%s::unordered_multimap' % ns,
- must_not_contain__cc,
+ children_are_key_value,
  'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8f121a3 - [lldb] Update regex to be less fragile in TestDataFormatterGenericUnordered

2022-11-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-11-11T11:42:56-08:00
New Revision: 8f121a3f18f7cc9dac08b7fb43ed7deec6adf583

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

LOG: [lldb] Update regex to be less fragile in TestDataFormatterGenericUnordered

Follow up to D129386 where libc++ naming conventions were made consistent.

This changes the pattern to not rely on the internal name (`__cc` or `__cc_`),
and instead uses a pattern to check that the child has the form:

```
[0] = {
  first = ...
```

Thanks to @rupprecht for pointing out this issue: 
https://reviews.llvm.org/D133259#3773120

Reviewed By: rupprecht

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

Added: 


Modified: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
index 7730e780bd478..0f6ea01282407 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -36,6 +36,9 @@ def cleanup():
 self.runCmd(
 "settings set target.max-children-count 256",
 check=False)
+self.runCmd(
+'settings set auto-one-line-summaries true',
+check=False)
 
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
@@ -47,16 +50,19 @@ def cleanup():
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
+# Ensure key/value children, not wrapped in a layer.
+# This regex depends on auto-one-line-summaries.
+self.runCmd('settings set auto-one-line-summaries false')
+children_are_key_value = r'\[0\] = \{\s*first = '
 
 self.look_for_content_and_continue(
 "map", ['%s::unordered_map' % ns,
-must_not_contain__cc,
+children_are_key_value,
 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
 
 self.look_for_content_and_continue(
 "mmap", ['%s::unordered_multimap' % ns,
- must_not_contain__cc,
+ children_are_key_value,
  'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 



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


[Lldb-commits] [lldb] b66da73 - [lldb] Don't assume name of libc++ inline namespace in LibCxxUnorderedMap

2022-11-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-11-11T11:59:36-08:00
New Revision: b66da73a05abe88bbe34bf7ffbe09f6e3d7f1fe0

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

LOG: [lldb] Don't assume name of libc++ inline namespace in LibCxxUnorderedMap

Follow up to D117383, fixing the assumption that libc++ always uses `__1` as
its inline namespace name.

Reviewed By: rupprecht

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

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 90e6e124090e9..cba1078d05d7b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -67,11 +67,23 @@ size_t 
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
   return m_num_elements;
 }
 
+static void consumeInlineNamespace(llvm::StringRef &name) {
+  // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+::
+  auto scratch = name;
+  if (scratch.consume_front("__") && std::isalnum(scratch[0])) {
+scratch = scratch.drop_while([](char c) { return std::isalnum(c); });
+if (scratch.consume_front("::")) {
+  // Successfully consumed a namespace.
+  name = scratch;
+}
+  }
+}
+
 static bool isStdTemplate(ConstString type_name, llvm::StringRef type) {
   llvm::StringRef name = type_name.GetStringRef();
-  // The type name may or may not be prefixed with `std::` or `std::__1::`.
+  // The type name may be prefixed with `std::__::`.
   if (name.consume_front("std::"))
-name.consume_front("__1::");
+consumeInlineNamespace(name);
   return name.consume_front(type) && name.startswith("<");
 }
 



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


[Lldb-commits] [PATCH] D133259: [lldb] Don't assume name of libc++ inline namespace in LibCxxUnorderedMap

2022-11-11 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb66da73a05ab: [lldb] Don't assume name of libc++ inline 
namespace in LibCxxUnorderedMap (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133259

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -67,11 +67,23 @@
   return m_num_elements;
 }
 
+static void consumeInlineNamespace(llvm::StringRef &name) {
+  // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+::
+  auto scratch = name;
+  if (scratch.consume_front("__") && std::isalnum(scratch[0])) {
+scratch = scratch.drop_while([](char c) { return std::isalnum(c); });
+if (scratch.consume_front("::")) {
+  // Successfully consumed a namespace.
+  name = scratch;
+}
+  }
+}
+
 static bool isStdTemplate(ConstString type_name, llvm::StringRef type) {
   llvm::StringRef name = type_name.GetStringRef();
-  // The type name may or may not be prefixed with `std::` or `std::__1::`.
+  // The type name may be prefixed with `std::__::`.
   if (name.consume_front("std::"))
-name.consume_front("__1::");
+consumeInlineNamespace(name);
   return name.consume_front(type) && name.startswith("<");
 }
 


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -67,11 +67,23 @@
   return m_num_elements;
 }
 
+static void consumeInlineNamespace(llvm::StringRef &name) {
+  // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+::
+  auto scratch = name;
+  if (scratch.consume_front("__") && std::isalnum(scratch[0])) {
+scratch = scratch.drop_while([](char c) { return std::isalnum(c); });
+if (scratch.consume_front("::")) {
+  // Successfully consumed a namespace.
+  name = scratch;
+}
+  }
+}
+
 static bool isStdTemplate(ConstString type_name, llvm::StringRef type) {
   llvm::StringRef name = type_name.GetStringRef();
-  // The type name may or may not be prefixed with `std::` or `std::__1::`.
+  // The type name may be prefixed with `std::__::`.
   if (name.consume_front("std::"))
-name.consume_front("__1::");
+consumeInlineNamespace(name);
   return name.consume_front(type) && name.startswith("<");
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137860: [lldb] Allow flexible importing of in_call_stack

2022-11-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Allow `in_call_stack` to be imported in either of the following ways:

  command script import path/to/in_call_stack.py
  command script import lldb.utils.in_call_stack


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137860

Files:
  lldb/examples/python/in_call_stack.py


Index: lldb/examples/python/in_call_stack.py
===
--- lldb/examples/python/in_call_stack.py
+++ lldb/examples/python/in_call_stack.py
@@ -3,7 +3,7 @@
 
 def __lldb_init_module(debugger, internal_dict):
   debugger.HandleCommand(
-  'command alias in_call_stack breakpoint command add --python-function 
in_call_stack.in_call_stack -k name -v %1'
+  f'command alias in_call_stack breakpoint command add --python-function 
{__name__}.in_call_stack -k name -v %1'
   )
 
 


Index: lldb/examples/python/in_call_stack.py
===
--- lldb/examples/python/in_call_stack.py
+++ lldb/examples/python/in_call_stack.py
@@ -3,7 +3,7 @@
 
 def __lldb_init_module(debugger, internal_dict):
   debugger.HandleCommand(
-  'command alias in_call_stack breakpoint command add --python-function in_call_stack.in_call_stack -k name -v %1'
+  f'command alias in_call_stack breakpoint command add --python-function {__name__}.in_call_stack -k name -v %1'
   )
 
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137860: [lldb] Allow flexible importing of in_call_stack

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

I made this change in situ in the version we ship in the LLDB.framework, and 
this does the right thing!  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137860

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


[Lldb-commits] [PATCH] D136650: Make CompilerType safe [Was: Add a check for TypeSystem use-after-free problems]

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

Ping @JDevlieghere @labath


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

https://reviews.llvm.org/D136650

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


[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-11 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 474848.
aeubanks added a comment.

use getNameForDiagnostics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- lldb/test/API/lang/cpp/unique-types2/main.cpp
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -1,3 +1,7 @@
+namespace ns {
+struct Bar {};
+} // namespace ns
+
 template  struct Foo {
   T t;
   template  class Nested {
@@ -23,5 +27,6 @@
   FooPack p7;
 
   Foo::Nested n1;
+  Foo::Nested n2;
   // Set breakpoint here
 }
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
===
--- lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
@@ -36,6 +36,7 @@
 self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
 self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 
 self.expect_expr("t1", result_type="Foo")
 self.expect_expr("t1", result_type="Foo")
@@ -49,6 +50,7 @@
 self.expect_expr("p6", result_type="FooPack")
 self.expect_expr("p7", result_type="FooPack")
 self.expect_expr("n1", result_type="Foo::Nested")
+self.expect_expr("n2", result_type="Foo::Nested")
 
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "15.0"])
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -644,7 +644,7 @@
   // Accessors
 
   ConstString GetTypeName(lldb::opaque_compiler_type_t type,
-  bool BaseOnly) override;
+  bool base_only) override;
 
   ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override;
 
@@ -1051,7 +1051,8 @@
   clang::PrintingPolicy GetTypePrintingPolicy();
   /// Returns the internal type name for the given NamedDecl using the
   /// type printing policy.
-  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl);
+  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl,
+ bool qualified = true);
 
   const clang::ClassTemplateSpecializationDecl *
   GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2131,11 +2131,12 @@
   return printing_policy;
 }
 
-std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl) {
+std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl,
+bool qualified) {
   clang::PrintingPolicy printing_policy = GetTypePrintingPolicy();
   std::string result;
   llvm::raw_string_ostream os(result);
-  named_decl->printQualifiedName(os, printing_policy);
+  named_decl->getNameForDiagnostic(os, printing_policy, qualified);
   return result;
 }
 
@@ -3768,7 +3769,7 @@
 }
 
 ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type,
- bool BaseOnly) {
+ bool base_only) {
   if (!type)
 return ConstString();
 
@@ -3790,9 +3791,9 @@
 return ConstString(GetTypeNameForDecl(typedef_decl));
   }
 
-  clang::PrintingPolicy printing_policy(GetTypePrintingPolicy());
-  printing_policy.SuppressScope = BaseOnly;
-  return ConstString(qual_type.getAsString(printing_policy));
+  if (auto *named_decl = qual_type->getAsTagDecl())
+return ConstString(GetTypeNameForDecl(named_decl, !base_only));
+  return ConstString(qual_type.getAsString(GetTypePrintingPolicy()));
 }
 
 ConstString
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D136650: Make CompilerType safe [Was: Add a check for TypeSystem use-after-free problems]

2022-11-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM modulo a few small nits




Comment at: lldb/include/lldb/Symbol/CompilerType.h:60
+}
+operator bool() const { return (bool)m_typesystem_sp; }
+bool operator==(const TypeSystemSPWrapper &other) const;

Nit: `static_cast(m_typesystem_sp)`



Comment at: lldb/source/API/SBModule.cpp:457
+sb_type = SBType(ts->GetBuiltinTypeByName(name));
+  else
+return {};

no else after return



Comment at: lldb/source/API/SBModule.cpp:502-504
+  CompilerType compiler_type =
+ts->GetBuiltinTypeByName(name);
+  if (compiler_type)

`if (CompilerType compiler_type = ts->GetBuiltinTypeByName(name))`


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

https://reviews.llvm.org/D136650

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


[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-11 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 474850.
aeubanks added a comment.

add comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
  lldb/test/API/lang/cpp/unique-types2/main.cpp

Index: lldb/test/API/lang/cpp/unique-types2/main.cpp
===
--- lldb/test/API/lang/cpp/unique-types2/main.cpp
+++ lldb/test/API/lang/cpp/unique-types2/main.cpp
@@ -1,3 +1,7 @@
+namespace ns {
+struct Bar {};
+} // namespace ns
+
 template  struct Foo {
   T t;
   template  class Nested {
@@ -23,5 +27,6 @@
   FooPack p7;
 
   Foo::Nested n1;
+  Foo::Nested n2;
   // Set breakpoint here
 }
Index: lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
===
--- lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
+++ lldb/test/API/lang/cpp/unique-types2/TestUniqueTypes2.py
@@ -36,6 +36,7 @@
 self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
 self.expect("image lookup -A -t 'Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 self.expect("image lookup -A -t '::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, error=True)
+self.expect("image lookup -A -t 'Foo::Nested'", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["1 match found"])
 
 self.expect_expr("t1", result_type="Foo")
 self.expect_expr("t1", result_type="Foo")
@@ -49,6 +50,7 @@
 self.expect_expr("p6", result_type="FooPack")
 self.expect_expr("p7", result_type="FooPack")
 self.expect_expr("n1", result_type="Foo::Nested")
+self.expect_expr("n2", result_type="Foo::Nested")
 
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "15.0"])
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -644,7 +644,7 @@
   // Accessors
 
   ConstString GetTypeName(lldb::opaque_compiler_type_t type,
-  bool BaseOnly) override;
+  bool base_only) override;
 
   ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override;
 
@@ -1051,7 +1051,8 @@
   clang::PrintingPolicy GetTypePrintingPolicy();
   /// Returns the internal type name for the given NamedDecl using the
   /// type printing policy.
-  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl);
+  std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl,
+ bool qualified = true);
 
   const clang::ClassTemplateSpecializationDecl *
   GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2131,11 +2131,12 @@
   return printing_policy;
 }
 
-std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl) {
+std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl,
+bool qualified) {
   clang::PrintingPolicy printing_policy = GetTypePrintingPolicy();
   std::string result;
   llvm::raw_string_ostream os(result);
-  named_decl->printQualifiedName(os, printing_policy);
+  named_decl->getNameForDiagnostic(os, printing_policy, qualified);
   return result;
 }
 
@@ -3768,7 +3769,7 @@
 }
 
 ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type,
- bool BaseOnly) {
+ bool base_only) {
   if (!type)
 return ConstString();
 
@@ -3790,9 +3791,13 @@
 return ConstString(GetTypeNameForDecl(typedef_decl));
   }
 
-  clang::PrintingPolicy printing_policy(GetTypePrintingPolicy());
-  printing_policy.SuppressScope = BaseOnly;
-  return ConstString(qual_type.getAsString(printing_policy));
+  // For consistency, this follows the same code path that clang uses to emit
+  // debug info. This also handles when we don't want any scopes preceding the
+  // name.
+  if (auto *named_decl = qual_type->getAsTagDecl())
+return ConstString(GetTypeNameForDecl(named_decl, !base_only));
+
+  return ConstString(qual_type.getAsString(GetTypePrintingPolicy()));
 }
 
 ConstString
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-11 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.

In D137583#3917735 , @dblaikie wrote:

> In D137583#3917706 , @aaron.ballman 
> wrote:
>
>>> ...we expect template params to be fully qualified when comparing them for 
>>> simple template names
>>
>> So lldb is not inspecting the AST, they're doing reflection (of a sort) on 
>> the pretty printed names? Or am I misunderstanding something?
>
> Not reflection as such - but building names for the user, but partly from the 
> AST - basically LLDB wants to be able to produce the same name that 
> CGDebugInfo produces - so, maybe it should produce it the same way as 
> CGDebugInfo, which isn't to use the pretty printer from scratch.
>
> @aeubanks would this work for lldb's use case? 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGDebugInfo.cpp#L5229
>  it'd be identical to the original debug info generation, and looks like it 
> doesn't require a printing policy change/feature. Sorry I didn't think of 
> that earlier. I guess since `Qualified` would be `false` for lldb's use case, 
> you could go down into the implementation and just call the unqualified side 
> directly: `NamedDecl::printName(OS, Policy);` should print it unqualified for 
> this name, but respect the qualified printing policy flag for any nested 
> names, parameters, etc.

much better, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

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


[Lldb-commits] [lldb] 307f395 - [lldb] Allow flexible importing of in_call_stack

2022-11-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-11-11T14:28:40-08:00
New Revision: 307f395d4ffee839dd0bd88c879539428cc31693

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

LOG: [lldb] Allow flexible importing of in_call_stack

Allow `in_call_stack` to be imported in either of the following ways:

```
command script import path/to/in_call_stack.py
command script import lldb.utils.in_call_stack
```

rdar://102249295

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

Added: 


Modified: 
lldb/examples/python/in_call_stack.py

Removed: 




diff  --git a/lldb/examples/python/in_call_stack.py 
b/lldb/examples/python/in_call_stack.py
index 0647f2ca3425..9fd32c0e211d 100755
--- a/lldb/examples/python/in_call_stack.py
+++ b/lldb/examples/python/in_call_stack.py
@@ -3,7 +3,7 @@
 
 def __lldb_init_module(debugger, internal_dict):
   debugger.HandleCommand(
-  'command alias in_call_stack breakpoint command add --python-function 
in_call_stack.in_call_stack -k name -v %1'
+  f'command alias in_call_stack breakpoint command add --python-function 
{__name__}.in_call_stack -k name -v %1'
   )
 
 



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


[Lldb-commits] [PATCH] D137860: [lldb] Allow flexible importing of in_call_stack

2022-11-11 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG307f395d4ffe: [lldb] Allow flexible importing of 
in_call_stack (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137860

Files:
  lldb/examples/python/in_call_stack.py


Index: lldb/examples/python/in_call_stack.py
===
--- lldb/examples/python/in_call_stack.py
+++ lldb/examples/python/in_call_stack.py
@@ -3,7 +3,7 @@
 
 def __lldb_init_module(debugger, internal_dict):
   debugger.HandleCommand(
-  'command alias in_call_stack breakpoint command add --python-function 
in_call_stack.in_call_stack -k name -v %1'
+  f'command alias in_call_stack breakpoint command add --python-function 
{__name__}.in_call_stack -k name -v %1'
   )
 
 


Index: lldb/examples/python/in_call_stack.py
===
--- lldb/examples/python/in_call_stack.py
+++ lldb/examples/python/in_call_stack.py
@@ -3,7 +3,7 @@
 
 def __lldb_init_module(debugger, internal_dict):
   debugger.HandleCommand(
-  'command alias in_call_stack breakpoint command add --python-function in_call_stack.in_call_stack -k name -v %1'
+  f'command alias in_call_stack breakpoint command add --python-function {__name__}.in_call_stack -k name -v %1'
   )
 
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133366: [lldb] Fix SBFileSpec.fullpath for Windows

2022-11-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 474866.
kastiglione added a comment.

Add a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133366

Files:
  lldb/bindings/interface/SBFileSpec.i
  lldb/test/API/python_api/file_spec/TestFileSpecAPI.py


Index: lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
===
--- /dev/null
+++ lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
@@ -0,0 +1,15 @@
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_full_path(self):
+file_spec = lldb.SBFileSpec()
+file_spec.SetDirectory("a")
+file_spec.SetFilename("b")
+self.assertEqual(file_spec.fullpath, os.path.join("a", "b"))
Index: lldb/bindings/interface/SBFileSpec.i
===
--- lldb/bindings/interface/SBFileSpec.i
+++ lldb/bindings/interface/SBFileSpec.i
@@ -88,7 +88,7 @@
 spec_dir = self.GetDirectory()
 spec_file = self.GetFilename()
 if spec_dir and spec_file:
-return '%s/%s' % (spec_dir, spec_file)
+return os.path.join(spec_dir, spec_file)
 elif spec_dir:
 return spec_dir
 elif spec_file:


Index: lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
===
--- /dev/null
+++ lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
@@ -0,0 +1,15 @@
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_full_path(self):
+file_spec = lldb.SBFileSpec()
+file_spec.SetDirectory("a")
+file_spec.SetFilename("b")
+self.assertEqual(file_spec.fullpath, os.path.join("a", "b"))
Index: lldb/bindings/interface/SBFileSpec.i
===
--- lldb/bindings/interface/SBFileSpec.i
+++ lldb/bindings/interface/SBFileSpec.i
@@ -88,7 +88,7 @@
 spec_dir = self.GetDirectory()
 spec_file = self.GetFilename()
 if spec_dir and spec_file:
-return '%s/%s' % (spec_dir, spec_file)
+return os.path.join(spec_dir, spec_file)
 elif spec_dir:
 return spec_dir
 elif spec_file:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137682: Change IRMemoryMap's last-resort magic address to an inaddressable address so it doesn't conflict

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

Except that you explicitly want to use the expression parser here so you 
shouldn't use `p` in the test, this seems fine to me.  It would be better to 
have a less fragile strategy for getting an unused region, but short of doing 
exhaustive searches which have their own problems we haven't come up with 
anything.  So making a better hack seems worthy.  Fix the `p` usage and this is 
good to go.




Comment at: lldb/test/API/lang/c/high-mem-global/TestHighMemGlobal.py:29
+
+self.expect("p global.c", substrs=[' = 1'])
+self.expect("p global.d", substrs=[' = 2'])

Unless you want to test the alias, it's better to use `expr` rather than `p` in 
tests.  We might some day change what the `p` alias does, and for instance if 
we get clever about using more static data fetching for `p` then your test 
won't test what you think it does anymore.



Comment at: lldb/test/API/lang/c/high-mem-global/TestHighMemGlobal.py:62
+self.runCmd("p int $global_e = global.e")
+self.expect("p $global_c != 1 || $global_d != 2 || $global_e != 3", 
substrs=[' = true'])

If you are really worried about false positives here, you could just use 
funkier values for the three members.  Not sure that's really necessary, 
however.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137682

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


[Lldb-commits] [PATCH] D137873: [LLDB][Minidump] Set abi environment for windows.

2022-11-11 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu created this revision.
zequanwu added a reviewer: labath.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

If we don't set it, clang will use itanium abi to create record layout which may
cause crash.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137873

Files:
  lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/test/Shell/Minidump/Windows/find-module.test


Index: lldb/test/Shell/Minidump/Windows/find-module.test
===
--- lldb/test/Shell/Minidump/Windows/find-module.test
+++ lldb/test/Shell/Minidump/Windows/find-module.test
@@ -4,7 +4,11 @@
 RUN: yaml2obj %S/Inputs/find-module.exe.yaml -o %T/find-module.exe
 RUN: yaml2obj %S/Inputs/find-module.dmp.yaml -o %T/find-module.dmp
 RUN: %lldb -O "settings set target.exec-search-paths %T" \
-RUN:   -c %T/find-module.dmp -o "image dump objfile" -o exit | FileCheck %s
+RUN:   -c %T/find-module.dmp -o "image dump objfile" -o "target list" -o exit \
+RUN:   | FileCheck %s
 
 CHECK-LABEL: image dump objfile
 CHECK: ObjectFilePECOFF, file = '{{.*}}find-module.exe', arch = i386
+
+CHECK-LABEL: target list
+CHECK: arch=i386-pc-windows-msvc
Index: lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -178,6 +178,7 @@
   case OSPlatform::Win32CE:
 triple.setOS(llvm::Triple::OSType::Win32);
 triple.setVendor(llvm::Triple::VendorType::PC);
+triple.setEnvironment(llvm::Triple::EnvironmentType::MSVC);
 break;
   case OSPlatform::Linux:
 triple.setOS(llvm::Triple::OSType::Linux);


Index: lldb/test/Shell/Minidump/Windows/find-module.test
===
--- lldb/test/Shell/Minidump/Windows/find-module.test
+++ lldb/test/Shell/Minidump/Windows/find-module.test
@@ -4,7 +4,11 @@
 RUN: yaml2obj %S/Inputs/find-module.exe.yaml -o %T/find-module.exe
 RUN: yaml2obj %S/Inputs/find-module.dmp.yaml -o %T/find-module.dmp
 RUN: %lldb -O "settings set target.exec-search-paths %T" \
-RUN:   -c %T/find-module.dmp -o "image dump objfile" -o exit | FileCheck %s
+RUN:   -c %T/find-module.dmp -o "image dump objfile" -o "target list" -o exit \
+RUN:   | FileCheck %s
 
 CHECK-LABEL: image dump objfile
 CHECK: ObjectFilePECOFF, file = '{{.*}}find-module.exe', arch = i386
+
+CHECK-LABEL: target list
+CHECK: arch=i386-pc-windows-msvc
Index: lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -178,6 +178,7 @@
   case OSPlatform::Win32CE:
 triple.setOS(llvm::Triple::OSType::Win32);
 triple.setVendor(llvm::Triple::VendorType::PC);
+triple.setEnvironment(llvm::Triple::EnvironmentType::MSVC);
 break;
   case OSPlatform::Linux:
 triple.setOS(llvm::Triple::OSType::Linux);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133366: [lldb] Fix SBFileSpec.fullpath for Windows

2022-11-11 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5223366416fb: [lldb] Fix SBFileSpec.fullpath for Windows 
(authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133366

Files:
  lldb/bindings/interface/SBFileSpec.i
  lldb/test/API/python_api/file_spec/TestFileSpecAPI.py


Index: lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
===
--- /dev/null
+++ lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
@@ -0,0 +1,15 @@
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_full_path(self):
+file_spec = lldb.SBFileSpec()
+file_spec.SetDirectory("a")
+file_spec.SetFilename("b")
+self.assertEqual(file_spec.fullpath, os.path.join("a", "b"))
Index: lldb/bindings/interface/SBFileSpec.i
===
--- lldb/bindings/interface/SBFileSpec.i
+++ lldb/bindings/interface/SBFileSpec.i
@@ -88,7 +88,7 @@
 spec_dir = self.GetDirectory()
 spec_file = self.GetFilename()
 if spec_dir and spec_file:
-return '%s/%s' % (spec_dir, spec_file)
+return os.path.join(spec_dir, spec_file)
 elif spec_dir:
 return spec_dir
 elif spec_file:


Index: lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
===
--- /dev/null
+++ lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
@@ -0,0 +1,15 @@
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_full_path(self):
+file_spec = lldb.SBFileSpec()
+file_spec.SetDirectory("a")
+file_spec.SetFilename("b")
+self.assertEqual(file_spec.fullpath, os.path.join("a", "b"))
Index: lldb/bindings/interface/SBFileSpec.i
===
--- lldb/bindings/interface/SBFileSpec.i
+++ lldb/bindings/interface/SBFileSpec.i
@@ -88,7 +88,7 @@
 spec_dir = self.GetDirectory()
 spec_file = self.GetFilename()
 if spec_dir and spec_file:
-return '%s/%s' % (spec_dir, spec_file)
+return os.path.join(spec_dir, spec_file)
 elif spec_dir:
 return spec_dir
 elif spec_file:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5223366 - [lldb] Fix SBFileSpec.fullpath for Windows

2022-11-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-11-11T16:07:38-08:00
New Revision: 5223366416fbde8ac5d53c586c985bffac9cb168

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

LOG: [lldb] Fix SBFileSpec.fullpath for Windows

Fix `fullpath` to not assume a `/` path separator. This was discovered when
D133130 failed on Windows. Use `os.path.join()` to fix the issue.

Reviewed By: mib

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

Added: 
lldb/test/API/python_api/file_spec/TestFileSpecAPI.py

Modified: 
lldb/bindings/interface/SBFileSpec.i

Removed: 




diff  --git a/lldb/bindings/interface/SBFileSpec.i 
b/lldb/bindings/interface/SBFileSpec.i
index b549321487ec2..104339472384f 100644
--- a/lldb/bindings/interface/SBFileSpec.i
+++ b/lldb/bindings/interface/SBFileSpec.i
@@ -88,7 +88,7 @@ public:
 spec_dir = self.GetDirectory()
 spec_file = self.GetFilename()
 if spec_dir and spec_file:
-return '%s/%s' % (spec_dir, spec_file)
+return os.path.join(spec_dir, spec_file)
 elif spec_dir:
 return spec_dir
 elif spec_file:

diff  --git a/lldb/test/API/python_api/file_spec/TestFileSpecAPI.py 
b/lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
new file mode 100644
index 0..6c074df0c12fb
--- /dev/null
+++ b/lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
@@ -0,0 +1,15 @@
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_full_path(self):
+file_spec = lldb.SBFileSpec()
+file_spec.SetDirectory("a")
+file_spec.SetFilename("b")
+self.assertEqual(file_spec.fullpath, os.path.join("a", "b"))



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


[Lldb-commits] [lldb] 1fb5c7a - [lldb] Rewrite to assertEqual/assertNotEqual (NFC)

2022-11-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-11-11T17:03:02-08:00
New Revision: 1fb5c7a2f17f10e768160fe23d4a04537c7224c1

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

LOG: [lldb] Rewrite to assertEqual/assertNotEqual (NFC)

Using the more specific assert* methods results in more useful error message.

Added: 


Modified: 
lldb/test/API/api/listeners/TestListener.py
lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
lldb/test/API/commands/expression/formatters/TestFormatters.py
lldb/test/API/commands/trace/TestTraceExport.py

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
lldb/test/API/functionalities/dwo/TestZeroDwoId.py
lldb/test/API/functionalities/fat_archives/TestFatArchives.py
lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py
lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py
lldb/test/API/lang/c/fpeval/TestFPEval.py
lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
lldb/test/API/lang/cpp/dynamic-value/TestCppValueCast.py
lldb/test/API/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py
lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
lldb/test/API/lang/objc/objc-stepping/TestObjCStepping.py

lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py

lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py
lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py
lldb/test/API/macosx/queues/TestQueues.py
lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py
lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py
lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
lldb/test/API/python_api/module_section/TestModuleAndSection.py
lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py
lldb/test/API/python_api/sbdata/TestSBData.py
lldb/test/API/python_api/value/TestValueAPI.py
lldb/test/API/python_api/value_var_update/TestValueVarUpdate.py
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py

Removed: 




diff  --git a/lldb/test/API/api/listeners/TestListener.py 
b/lldb/test/API/api/listeners/TestListener.py
index de0491b6dbc15..c6f15bf4f92cb 100644
--- a/lldb/test/API/api/listeners/TestListener.py
+++ b/lldb/test/API/api/listeners/TestListener.py
@@ -63,8 +63,8 @@ def test_receiving_breakpoint_added_from_debugger(self):
 self.assertTrue(
 lldb.SBBreakpoint.EventIsBreakpointEvent(event),
 "It is a breakpoint event.")
-self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(
-event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint 
added event.")
+
self.assertEqual(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event),
+lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.")
 self.assertEqual(
 bkpt, lldb.SBBreakpoint.GetBreakpointFromEvent(event),
 "It is our breakpoint.")
@@ -106,8 +106,8 @@ def test_recieving_breakpoint_added_from_target(self):
 self.assertTrue(
 lldb.SBBreakpoint.EventIsBreakpointEvent(event),
 "It is a breakpoint event.")
-self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(
-event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint 
added event.")
+
self.assertEqual(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event),
+lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.")
 self.assertEqual(
 bkpt, lldb.SBBreakpoint.GetBreakpointFromEvent(event),
 "It is our breakpoint.")

diff  --git 
a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py 
b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
index 487c55f2bb3bb..995a5955b0762 100644
--- a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
+++ b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
@@ -31,9 +31,8 @@ def test(self):
 
 def check_after_call(self, num_sigchld):
 after_call = self.sigchld_no.GetValueAsSigned(-1)
-self.assertTrue(
-after_call -
-self.start_sigchld_no == num_sigchld,
+self.assertEqual(
+after_call - self.start_sigchld_no, num_sigchld,
 "Really got %d SIGCHLD signals through the call." %
 (num_sigchld))
 self.start_sigchld_no = after_call
@@ -58,8 +57,8 @@ def call_function(self):
 "Got a value for sigchld_no")
 
 self.start_sigch