[Lldb-commits] [lldb] [Clang] Fix crash when ill-formed code is treated as a deduction guide (PR #67373)

2023-10-02 Thread Mariya Podchishchaeva via lldb-commits

https://github.com/Fznamznon approved this pull request.


https://github.com/llvm/llvm-project/pull/67373
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask` (PR #67723)

2023-10-02 Thread via lldb-commits

https://github.com/shraiysh updated 
https://github.com/llvm/llvm-project/pull/67723

>From 6aabc3c10ea2d587120b74966b7ce96f9b8167af Mon Sep 17 00:00:00 2001
From: Shraiysh Vaishay 
Date: Thu, 28 Sep 2023 13:35:07 -0500
Subject: [PATCH 1/2] [OpenMPIRBuilder] Remove wrapper function in `createTask`

This patch removes the wrapper function in
`OpenMPIRBuilder::createTask`. The outlined function is directly of the
form that is expected by the runtime library calls. This also fixes the
global thread ID argument, which should be used whenever
`kmpc_global_thread_num()` is called inside the outlined function.
---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 106 --
 .../Frontend/OpenMPIRBuilderTest.cpp  |  56 +
 mlir/test/Target/LLVMIR/openmp-llvm.mlir  |  51 +++--
 3 files changed, 99 insertions(+), 114 deletions(-)

diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 9c70d384e55db2b..54012b488c6b671 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -35,6 +35,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Metadata.h"
@@ -1496,6 +1497,14 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 InsertPointTy AllocaIP, BodyGenCallbackTy 
BodyGenCB,
 bool Tied, Value *Final, Value *IfCondition,
 SmallVector Dependencies) {
+  // We create a temporary i32 value that will represent the global tid after
+  // outlining.
+  SmallVector ToBeDeleted;
+  Builder.restoreIP(AllocaIP);
+  AllocaInst *TIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
+  LoadInst *TID = Builder.CreateLoad(Int32, TIDAddr, "tid.addr.use");
+  ToBeDeleted.append({TID, TIDAddr});
+
   if (!updateToLocation(Loc))
 return InsertPointTy();
 
@@ -1523,41 +1532,27 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   BasicBlock *TaskAllocaBB =
   splitBB(Builder, /*CreateBranch=*/true, "task.alloca");
 
+  // Fake use of TID
+  Builder.SetInsertPoint(TaskAllocaBB, TaskAllocaBB->begin());
+  BinaryOperator *AddInst =
+  dyn_cast(Builder.CreateAdd(TID, Builder.getInt32(10)));
+  ToBeDeleted.push_back(AddInst);
+
   OutlineInfo OI;
   OI.EntryBB = TaskAllocaBB;
   OI.OuterAllocaBB = AllocaIP.getBlock();
   OI.ExitBB = TaskExitBB;
-  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition,
-  Dependencies](Function &OutlinedFn) {
-// The input IR here looks like the following-
-// ```
-// func @current_fn() {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-//
-// This is changed to the following-
-//
-// ```
-// func @current_fn() {
-//   runtime_call(..., wrapper_fn, ...)
-// }
-// func @wrapper_fn(..., %args) {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-
-// The stale call instruction will be replaced with a new call instruction
-// for runtime call with a wrapper function.
+  OI.ExcludeArgsFromAggregate = {TID};
+  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition, Dependencies,
+  TaskAllocaBB, ToBeDeleted](Function &OutlinedFn) {
+// Replace the Stale CI by appropriate RTL function call.
 assert(OutlinedFn.getNumUses() == 1 &&
"there must be a single user for the outlined function");
 CallInst *StaleCI = cast(OutlinedFn.user_back());
 
 // HasShareds is true if any variables are captured in the outlined region,
 // false otherwise.
-bool HasShareds = StaleCI->arg_size() > 0;
+bool HasShareds = StaleCI->arg_size() > 1;
 Builder.SetInsertPoint(StaleCI);
 
 // Gather the arguments for emitting the runtime call for
@@ -1595,7 +1590,7 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 Value *SharedsSize = Builder.getInt64(0);
 if (HasShareds) {
   AllocaInst *ArgStructAlloca =
-  dyn_cast(StaleCI->getArgOperand(0));
+  dyn_cast(StaleCI->getArgOperand(1));
   assert(ArgStructAlloca &&
  "Unable to find the alloca instruction corresponding to arguments 
"
  "for extracted function");
@@ -1606,31 +1601,17 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   SharedsSize =
   Builder.getInt64(M.getDataLayout().getTypeStoreSize(ArgStructType));
 }
-
-// Argument - task_entry (the wrapper function)
-// If the outlined function has some captured variables (i.e. HasShareds is
-// true), then the wrapper function will have an additional argument (the
-// struct containing captured variables). Otherwise, no such argument will
-// be present.
-SmallVector 

[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask` (PR #67723)

2023-10-02 Thread via lldb-commits

https://github.com/shraiysh updated 
https://github.com/llvm/llvm-project/pull/67723

>From 6aabc3c10ea2d587120b74966b7ce96f9b8167af Mon Sep 17 00:00:00 2001
From: Shraiysh Vaishay 
Date: Thu, 28 Sep 2023 13:35:07 -0500
Subject: [PATCH 1/2] [OpenMPIRBuilder] Remove wrapper function in `createTask`

This patch removes the wrapper function in
`OpenMPIRBuilder::createTask`. The outlined function is directly of the
form that is expected by the runtime library calls. This also fixes the
global thread ID argument, which should be used whenever
`kmpc_global_thread_num()` is called inside the outlined function.
---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 106 --
 .../Frontend/OpenMPIRBuilderTest.cpp  |  56 +
 mlir/test/Target/LLVMIR/openmp-llvm.mlir  |  51 +++--
 3 files changed, 99 insertions(+), 114 deletions(-)

diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 9c70d384e55db2b..54012b488c6b671 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -35,6 +35,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Metadata.h"
@@ -1496,6 +1497,14 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 InsertPointTy AllocaIP, BodyGenCallbackTy 
BodyGenCB,
 bool Tied, Value *Final, Value *IfCondition,
 SmallVector Dependencies) {
+  // We create a temporary i32 value that will represent the global tid after
+  // outlining.
+  SmallVector ToBeDeleted;
+  Builder.restoreIP(AllocaIP);
+  AllocaInst *TIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
+  LoadInst *TID = Builder.CreateLoad(Int32, TIDAddr, "tid.addr.use");
+  ToBeDeleted.append({TID, TIDAddr});
+
   if (!updateToLocation(Loc))
 return InsertPointTy();
 
@@ -1523,41 +1532,27 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   BasicBlock *TaskAllocaBB =
   splitBB(Builder, /*CreateBranch=*/true, "task.alloca");
 
+  // Fake use of TID
+  Builder.SetInsertPoint(TaskAllocaBB, TaskAllocaBB->begin());
+  BinaryOperator *AddInst =
+  dyn_cast(Builder.CreateAdd(TID, Builder.getInt32(10)));
+  ToBeDeleted.push_back(AddInst);
+
   OutlineInfo OI;
   OI.EntryBB = TaskAllocaBB;
   OI.OuterAllocaBB = AllocaIP.getBlock();
   OI.ExitBB = TaskExitBB;
-  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition,
-  Dependencies](Function &OutlinedFn) {
-// The input IR here looks like the following-
-// ```
-// func @current_fn() {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-//
-// This is changed to the following-
-//
-// ```
-// func @current_fn() {
-//   runtime_call(..., wrapper_fn, ...)
-// }
-// func @wrapper_fn(..., %args) {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-
-// The stale call instruction will be replaced with a new call instruction
-// for runtime call with a wrapper function.
+  OI.ExcludeArgsFromAggregate = {TID};
+  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition, Dependencies,
+  TaskAllocaBB, ToBeDeleted](Function &OutlinedFn) {
+// Replace the Stale CI by appropriate RTL function call.
 assert(OutlinedFn.getNumUses() == 1 &&
"there must be a single user for the outlined function");
 CallInst *StaleCI = cast(OutlinedFn.user_back());
 
 // HasShareds is true if any variables are captured in the outlined region,
 // false otherwise.
-bool HasShareds = StaleCI->arg_size() > 0;
+bool HasShareds = StaleCI->arg_size() > 1;
 Builder.SetInsertPoint(StaleCI);
 
 // Gather the arguments for emitting the runtime call for
@@ -1595,7 +1590,7 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 Value *SharedsSize = Builder.getInt64(0);
 if (HasShareds) {
   AllocaInst *ArgStructAlloca =
-  dyn_cast(StaleCI->getArgOperand(0));
+  dyn_cast(StaleCI->getArgOperand(1));
   assert(ArgStructAlloca &&
  "Unable to find the alloca instruction corresponding to arguments 
"
  "for extracted function");
@@ -1606,31 +1601,17 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   SharedsSize =
   Builder.getInt64(M.getDataLayout().getTypeStoreSize(ArgStructType));
 }
-
-// Argument - task_entry (the wrapper function)
-// If the outlined function has some captured variables (i.e. HasShareds is
-// true), then the wrapper function will have an additional argument (the
-// struct containing captured variables). Otherwise, no such argument will
-// be present.
-SmallVector 

[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask` (PR #67723)

2023-10-02 Thread via lldb-commits

https://github.com/shraiysh updated 
https://github.com/llvm/llvm-project/pull/67723

>From 6aabc3c10ea2d587120b74966b7ce96f9b8167af Mon Sep 17 00:00:00 2001
From: Shraiysh Vaishay 
Date: Thu, 28 Sep 2023 13:35:07 -0500
Subject: [PATCH 1/3] [OpenMPIRBuilder] Remove wrapper function in `createTask`

This patch removes the wrapper function in
`OpenMPIRBuilder::createTask`. The outlined function is directly of the
form that is expected by the runtime library calls. This also fixes the
global thread ID argument, which should be used whenever
`kmpc_global_thread_num()` is called inside the outlined function.
---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 106 --
 .../Frontend/OpenMPIRBuilderTest.cpp  |  56 +
 mlir/test/Target/LLVMIR/openmp-llvm.mlir  |  51 +++--
 3 files changed, 99 insertions(+), 114 deletions(-)

diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 9c70d384e55db2b..54012b488c6b671 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -35,6 +35,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Metadata.h"
@@ -1496,6 +1497,14 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 InsertPointTy AllocaIP, BodyGenCallbackTy 
BodyGenCB,
 bool Tied, Value *Final, Value *IfCondition,
 SmallVector Dependencies) {
+  // We create a temporary i32 value that will represent the global tid after
+  // outlining.
+  SmallVector ToBeDeleted;
+  Builder.restoreIP(AllocaIP);
+  AllocaInst *TIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
+  LoadInst *TID = Builder.CreateLoad(Int32, TIDAddr, "tid.addr.use");
+  ToBeDeleted.append({TID, TIDAddr});
+
   if (!updateToLocation(Loc))
 return InsertPointTy();
 
@@ -1523,41 +1532,27 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   BasicBlock *TaskAllocaBB =
   splitBB(Builder, /*CreateBranch=*/true, "task.alloca");
 
+  // Fake use of TID
+  Builder.SetInsertPoint(TaskAllocaBB, TaskAllocaBB->begin());
+  BinaryOperator *AddInst =
+  dyn_cast(Builder.CreateAdd(TID, Builder.getInt32(10)));
+  ToBeDeleted.push_back(AddInst);
+
   OutlineInfo OI;
   OI.EntryBB = TaskAllocaBB;
   OI.OuterAllocaBB = AllocaIP.getBlock();
   OI.ExitBB = TaskExitBB;
-  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition,
-  Dependencies](Function &OutlinedFn) {
-// The input IR here looks like the following-
-// ```
-// func @current_fn() {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-//
-// This is changed to the following-
-//
-// ```
-// func @current_fn() {
-//   runtime_call(..., wrapper_fn, ...)
-// }
-// func @wrapper_fn(..., %args) {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-
-// The stale call instruction will be replaced with a new call instruction
-// for runtime call with a wrapper function.
+  OI.ExcludeArgsFromAggregate = {TID};
+  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition, Dependencies,
+  TaskAllocaBB, ToBeDeleted](Function &OutlinedFn) {
+// Replace the Stale CI by appropriate RTL function call.
 assert(OutlinedFn.getNumUses() == 1 &&
"there must be a single user for the outlined function");
 CallInst *StaleCI = cast(OutlinedFn.user_back());
 
 // HasShareds is true if any variables are captured in the outlined region,
 // false otherwise.
-bool HasShareds = StaleCI->arg_size() > 0;
+bool HasShareds = StaleCI->arg_size() > 1;
 Builder.SetInsertPoint(StaleCI);
 
 // Gather the arguments for emitting the runtime call for
@@ -1595,7 +1590,7 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 Value *SharedsSize = Builder.getInt64(0);
 if (HasShareds) {
   AllocaInst *ArgStructAlloca =
-  dyn_cast(StaleCI->getArgOperand(0));
+  dyn_cast(StaleCI->getArgOperand(1));
   assert(ArgStructAlloca &&
  "Unable to find the alloca instruction corresponding to arguments 
"
  "for extracted function");
@@ -1606,31 +1601,17 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   SharedsSize =
   Builder.getInt64(M.getDataLayout().getTypeStoreSize(ArgStructType));
 }
-
-// Argument - task_entry (the wrapper function)
-// If the outlined function has some captured variables (i.e. HasShareds is
-// true), then the wrapper function will have an additional argument (the
-// struct containing captured variables). Otherwise, no such argument will
-// be present.
-SmallVector 

[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask` (PR #67723)

2023-10-02 Thread via lldb-commits

https://github.com/shraiysh edited 
https://github.com/llvm/llvm-project/pull/67723
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-02 Thread via lldb-commits

https://github.com/shraiysh updated 
https://github.com/llvm/llvm-project/pull/67723

>From 6aabc3c10ea2d587120b74966b7ce96f9b8167af Mon Sep 17 00:00:00 2001
From: Shraiysh Vaishay 
Date: Thu, 28 Sep 2023 13:35:07 -0500
Subject: [PATCH 1/4] [OpenMPIRBuilder] Remove wrapper function in `createTask`

This patch removes the wrapper function in
`OpenMPIRBuilder::createTask`. The outlined function is directly of the
form that is expected by the runtime library calls. This also fixes the
global thread ID argument, which should be used whenever
`kmpc_global_thread_num()` is called inside the outlined function.
---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 106 --
 .../Frontend/OpenMPIRBuilderTest.cpp  |  56 +
 mlir/test/Target/LLVMIR/openmp-llvm.mlir  |  51 +++--
 3 files changed, 99 insertions(+), 114 deletions(-)

diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 9c70d384e55db2b..54012b488c6b671 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -35,6 +35,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Metadata.h"
@@ -1496,6 +1497,14 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 InsertPointTy AllocaIP, BodyGenCallbackTy 
BodyGenCB,
 bool Tied, Value *Final, Value *IfCondition,
 SmallVector Dependencies) {
+  // We create a temporary i32 value that will represent the global tid after
+  // outlining.
+  SmallVector ToBeDeleted;
+  Builder.restoreIP(AllocaIP);
+  AllocaInst *TIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
+  LoadInst *TID = Builder.CreateLoad(Int32, TIDAddr, "tid.addr.use");
+  ToBeDeleted.append({TID, TIDAddr});
+
   if (!updateToLocation(Loc))
 return InsertPointTy();
 
@@ -1523,41 +1532,27 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   BasicBlock *TaskAllocaBB =
   splitBB(Builder, /*CreateBranch=*/true, "task.alloca");
 
+  // Fake use of TID
+  Builder.SetInsertPoint(TaskAllocaBB, TaskAllocaBB->begin());
+  BinaryOperator *AddInst =
+  dyn_cast(Builder.CreateAdd(TID, Builder.getInt32(10)));
+  ToBeDeleted.push_back(AddInst);
+
   OutlineInfo OI;
   OI.EntryBB = TaskAllocaBB;
   OI.OuterAllocaBB = AllocaIP.getBlock();
   OI.ExitBB = TaskExitBB;
-  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition,
-  Dependencies](Function &OutlinedFn) {
-// The input IR here looks like the following-
-// ```
-// func @current_fn() {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-//
-// This is changed to the following-
-//
-// ```
-// func @current_fn() {
-//   runtime_call(..., wrapper_fn, ...)
-// }
-// func @wrapper_fn(..., %args) {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-
-// The stale call instruction will be replaced with a new call instruction
-// for runtime call with a wrapper function.
+  OI.ExcludeArgsFromAggregate = {TID};
+  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition, Dependencies,
+  TaskAllocaBB, ToBeDeleted](Function &OutlinedFn) {
+// Replace the Stale CI by appropriate RTL function call.
 assert(OutlinedFn.getNumUses() == 1 &&
"there must be a single user for the outlined function");
 CallInst *StaleCI = cast(OutlinedFn.user_back());
 
 // HasShareds is true if any variables are captured in the outlined region,
 // false otherwise.
-bool HasShareds = StaleCI->arg_size() > 0;
+bool HasShareds = StaleCI->arg_size() > 1;
 Builder.SetInsertPoint(StaleCI);
 
 // Gather the arguments for emitting the runtime call for
@@ -1595,7 +1590,7 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 Value *SharedsSize = Builder.getInt64(0);
 if (HasShareds) {
   AllocaInst *ArgStructAlloca =
-  dyn_cast(StaleCI->getArgOperand(0));
+  dyn_cast(StaleCI->getArgOperand(1));
   assert(ArgStructAlloca &&
  "Unable to find the alloca instruction corresponding to arguments 
"
  "for extracted function");
@@ -1606,31 +1601,17 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   SharedsSize =
   Builder.getInt64(M.getDataLayout().getTypeStoreSize(ArgStructType));
 }
-
-// Argument - task_entry (the wrapper function)
-// If the outlined function has some captured variables (i.e. HasShareds is
-// true), then the wrapper function will have an additional argument (the
-// struct containing captured variables). Otherwise, no such argument will
-// be present.
-SmallVector 

[Lldb-commits] [lldb] [mlir][sparse] Update Enum name for CompressedWithHigh (PR #67845)

2023-10-02 Thread Yinying Li via lldb-commits

https://github.com/yinying-lisa-li closed 
https://github.com/llvm/llvm-project/pull/67845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Clang] Fix crash when ill-formed code is treated as a deduction guide (PR #67373)

2023-10-02 Thread Shafik Yaghmour via lldb-commits

https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/67373
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-10-02 Thread via lldb-commits

jimingham wrote:

So first off, the lldb_private API is not a stable API and will likely never 
be.  After all, it vends lots of llvm ADT types and other llvm & clang API's 
which are also not stable API's...  So anything which tends to making these 
API's seem like we're vending them as such, or that it's safe to distribute 
shared libraries that depend on them is a supported mode is going in the wrong 
direction.  If we want to make the plugin API a stable API for external 
customers, we'll have to do a bunch more work (including either getting by-in 
to make ABI stable versions of the underlying llvm/clang API's...)

If you are not planning to make an actual loadable plugin, which I am pretty 
sure we don't want to support with the lldb_private API's at this time, then 
I'm not clear why all this work is necessary, as opposed to just linking to the 
lldb internal headers & building against the .a files.

https://github.com/llvm/llvm-project/pull/67851
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-10-02 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@jimingham , indeed, I don't want to have a plugin that could be loadable by 
any build of lldb. The Mojo SDK is distributing already its own build of 
vanilla lldb along with the mojo plugin that is loaded at runtime and that 
links correctly with that lldb.
I initially tried linking the .a files, but that lead to a not short list of 
dependencies that included clang and other libraries that I also needed to link 
against, which was not very clean and could lead to potential issues on 
windows, where the exports file has a limited size. In the end after all the 
discussion, I think that the cleanest solution that could benefit other plugin 
developers is to allow specifying a custom exports file that can be used 
instead of `third-party/llvm-project/lldb/source/API/liblldb-private.exports` 
offering more control on what to export.

https://github.com/llvm/llvm-project/pull/67851
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc++] Implement ranges::contains_subrange (PR #66963)

2023-10-02 Thread Shafik Yaghmour via lldb-commits

shafik wrote:

Please make sure you add a description to your PR. This is what usually goes 
into the git log and we want those entries to be as descriptive and helpful for 
folks who read the git logs, thank you.

https://github.com/llvm/llvm-project/pull/66963
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Replace lldb's DWARFDebugAbbrev implementation with llvm's (PR #67841)

2023-10-02 Thread Alex Langford via lldb-commits

https://github.com/bulbazord closed 
https://github.com/llvm/llvm-project/pull/67841
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] cdd3e96 - [lldb] Replace lldb's DWARFDebugAbbrev implementation with llvm's (#67841)

2023-10-02 Thread via lldb-commits

Author: Alex Langford
Date: 2023-10-02T10:46:16-07:00
New Revision: cdd3e964f229aac5366433a549466d18ed696660

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

LOG: [lldb] Replace lldb's DWARFDebugAbbrev implementation with llvm's (#67841)

The implementations are now close enough that replacing it is trivial.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h



diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
index dad206040068716..0e4fd5b995d1ba9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -17,7 +17,6 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
   DWARFCompileUnit.cpp
   DWARFContext.cpp
   DWARFDataExtractor.cpp
-  DWARFDebugAbbrev.cpp
   DWARFDebugAranges.cpp
   DWARFDebugArangeSet.cpp
   DWARFDebugInfo.cpp

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index ab3017ba0ffcbca..65debac4c7d9265 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -12,6 +12,10 @@
 #include "DWARFUnit.h"
 #include "llvm/Support/Error.h"
 
+namespace llvm {
+class DWARFAbbreviationDeclarationSet;
+}
+
 class DWARFCompileUnit : public DWARFUnit {
 public:
   void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) override;
@@ -27,7 +31,7 @@ class DWARFCompileUnit : public DWARFUnit {
 private:
   DWARFCompileUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
const DWARFUnitHeader &header,
-   const DWARFAbbreviationDeclarationSet &abbrevs,
+   const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
DIERef::Section section, bool is_dwo)
   : DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
deleted file mode 100644
index f3c2755c5a527cc..000
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//===-- DWARFDebugAbbrev.cpp 
--===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "DWARFDebugAbbrev.h"
-#include "DWARFDataExtractor.h"
-#include "DWARFFormValue.h"
-#include "lldb/Utility/Stream.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// DWARFDebugAbbrev constructor
-DWARFDebugAbbrev::DWARFDebugAbbrev(const DWARFDataExtractor &data)
-: m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()),
-  m_data(data.GetAsLLVM()) {}
-
-// DWARFDebugAbbrev::Parse()
-llvm::Error DWARFDebugAbbrev::parse() {
-  if (!m_data)
-return llvm::Error::success();
-
-  lldb::offset_t offset = 0;
-
-  while (m_data->isValidOffset(offset)) {
-uint32_t initial_cu_offset = offset;
-DWARFAbbreviationDeclarationSet abbrevDeclSet;
-
-llvm::Error error = abbrevDeclSet.extract(*m_data, &offset);
-if (error) {
-  m_data = std::nullopt;
-  return error;
-}
-
-m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
-  }
-  m_data = std::nullopt;
-  m_prev_abbr_offset_pos = m_abbrevCollMap.end();
-  return llvm::ErrorSuccess();
-}
-
-// DWARFDebugAbbrev::GetAbbreviationDeclarationSet()
-const DWARFAbbreviationDeclarationSet *
-DWARFDebugAbbrev::GetAbbreviationDeclarationSet(
-dw_offset_t cu_abbr_offset) const {
-  DWARFAbbreviationDeclarationCollMapConstIter end = m_abbrevCollMap.end();
-  DWARFAbbreviationDeclarationCollMapConstIter pos;
-  if (m_prev_abbr_offset_pos != end &&
-  m_prev_abbr_offset_pos->first == cu_abbr_offset)
-return &(m_prev_abbr_offset_pos->second);
-  else {
-pos = m_abbrevCollMap.find(cu_abbr_offset);
-m_prev_abbr_offset_po

[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-10-02 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/67851
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

https://github.com/jeffreytan81 created 
https://github.com/llvm/llvm-project/pull/68012

This patch implements the data formatters for LibStdC++ `std::variant`.

>From e7e47a211ebaaa0f6380810b6573fadde12ca02d Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 2 Oct 2023 10:53:17 -0700
Subject: [PATCH] Implement data formatters for LibStdC++ std::variant

---
 lldb/examples/synthetic/gnu_libstdcpp.py  | 89 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 18 +++-
 .../libstdcpp/variant/Makefile|  5 ++
 .../TestDataFormatterLibStdcxxVariant.py  | 72 +++
 .../libstdcpp/variant/main.cpp| 79 
 5 files changed, 259 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp

diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 825b7f3787a010d..7462db744674682 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -892,3 +892,92 @@ def update(self):
 except:
 pass
 return False
+
+
+def VariantSummaryProvider(valobj, dict):
+raw_obj = valobj.GetNonSyntheticValue()
+index_obj = raw_obj.GetChildMemberWithName("_M_index")
+data_obj = raw_obj.GetChildMemberWithName("_M_u")
+if not (
+index_obj
+and index_obj.IsValid()
+and data_obj
+and data_obj.IsValid()
+):
+return ""
+
+def get_variant_npos_value(index_byte_size):
+if index_byte_size == 1:
+return 0xFF
+elif index_byte_size == 2:
+return 0x
+else:
+return 0x
+
+npos_value = get_variant_npos_value(index_obj.GetByteSize())
+index = index_obj.GetValueAsUnsigned(0)
+if index == npos_value:
+return " No Value"
+
+active_type = data_obj.GetType().GetTemplateArgumentType(index)
+return f" Active Type = {active_type.GetDisplayTypeName()} "
+
+
+class VariantSynthProvider:
+def __init__(self, valobj, dict):
+self.raw_obj = valobj.GetNonSyntheticValue()
+self.is_valid = False
+self.index = None
+self.data_obj = None
+
+def update(self):
+try:
+self.index = self.raw_obj.GetChildMemberWithName(
+"_M_index"
+).GetValueAsSigned(-1)
+self.is_valid = self.index != -1
+self.data_obj = self.raw_obj.GetChildMemberWithName("_M_u")
+except:
+self.is_valid = False
+return False
+
+def has_children(self):
+return True
+
+def num_children(self):
+return 1 if self.is_valid else 0
+
+def get_child_index(self, name):
+return 0
+
+def get_child_at_index(self, index):
+if not self.is_valid:
+return None
+cur = 0
+node = self.data_obj
+while cur < self.index:
+node = node.GetChildMemberWithName("_M_rest")
+cur += 1
+
+# _M_storage's type depends on variant field's type "_Type".
+#  1. if '_Type' is literal type: _Type _M_storage.
+#  2. otherwise, __gnu_cxx::__aligned_membuf<_Type> _M_storage.
+#
+# For 2. we have to cast it to underlying template _Type.
+
+value = node.GetChildMemberWithName("_M_first").GetChildMemberWithName(
+"_M_storage"
+)
+template_type = value.GetType().GetTemplateArgumentType(0)
+
+# Literal type will return None for GetTemplateArgumentType(0)
+if (
+template_type
+and "__gnu_cxx::__aligned_membuf" in 
value.GetType().GetDisplayTypeName()
+and template_type.IsValid()
+):
+value = value.Cast(template_type)
+
+if value.IsValid():
+return value.Clone("Value")
+return None
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index c1743a5e0a418dd..d8a30729b6d02e1 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -332,11 +332,11 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
   // If we can't parse the incoming name, then just check that it contains 
path.
   if (m_parse_error)
 return m_full.GetStringRef().contains(path);
-
+
   llvm::StringRef identifier;
   llvm::StringRef context;
   std::string path_str = path.str();
-  bool success 
+  bool success
   = CPlusPlusLanguage::ExtractContextAndIdentifier(path_str.c_str(),

[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-02 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/68013

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, 
lldb_private namespaces, as well as other symbols like python and lua (see 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, 
not all symbols in lldb fall into these categories and in order to get access 
to some symbols that live in plugin folders (like dwarf parsing symbols), it's 
useful to be able to specify a custom exports file giving more control to the 
developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is 
used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports 
file.

This is a follow up of https://github.com/llvm/llvm-project/pull/67851


>From 4abd9478422cdf471103ff01d7994d2e7ffc1500 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 2 Oct 2023 13:56:00 -0400
Subject: [PATCH] [LLDB] Allow specifying a custom exports file

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, 
lldb_private namespaces, as well as other symbols like python and lua (see 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, 
not all symbols in lldb fall into these categories and in order to get access 
to some symbols that live in plugin folders (like dwarf parsing symbols), it's 
useful to be able to specify a custom exports file giving more control to the 
developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is 
used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports 
file.

This is a follow up of https://github.com/llvm/llvm-project/pull/67851
---
 lldb/cmake/modules/LLDBConfig.cmake | 3 +++
 lldb/source/API/CMakeLists.txt  | 6 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 380016ce48015fa..264eed1ad82012f 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -125,6 +125,9 @@ endif()
 set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
   "Causes lldb to export all symbols when building liblldb.")
 
+set(LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE "" CACHE PATH
+  "When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the exports file 
to use when building liblldb.")
+
 if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 7cfa3aaafdae188..45e3b7a91034006 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -177,11 +177,15 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
 # from working on some systems but limits the liblldb size.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb 
namespace")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
-  else()
+  elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
 # Don't use an explicit export.  Instead, tell the linker to
 # export all symbols.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
+  else ()
+MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the 
exports "
+" file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
+add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
   endif()
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 elseif (LLDB_EXPORT_ALL_SYMBOLS)

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


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-02 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo ready_for_review 
https://github.com/llvm/llvm-project/pull/68013
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb


Changes

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, 
lldb_private namespaces, as well as other symbols like python and lua (see 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, 
not all symbols in lldb fall into these categories and in order to get access 
to some symbols that live in plugin folders (like dwarf parsing symbols), it's 
useful to be able to specify a custom exports file giving more control to the 
developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is 
used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports 
file.

This is a follow up of https://github.com/llvm/llvm-project/pull/67851


---
Full diff: https://github.com/llvm/llvm-project/pull/68013.diff


2 Files Affected:

- (modified) lldb/cmake/modules/LLDBConfig.cmake (+3) 
- (modified) lldb/source/API/CMakeLists.txt (+5-1) 


``diff
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 380016ce48015fa..264eed1ad82012f 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -125,6 +125,9 @@ endif()
 set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
   "Causes lldb to export all symbols when building liblldb.")
 
+set(LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE "" CACHE PATH
+  "When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the exports file 
to use when building liblldb.")
+
 if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 7cfa3aaafdae188..45e3b7a91034006 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -177,11 +177,15 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
 # from working on some systems but limits the liblldb size.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb 
namespace")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
-  else()
+  elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
 # Don't use an explicit export.  Instead, tell the linker to
 # export all symbols.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
+  else ()
+MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the 
exports "
+" file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
+add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
   endif()
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 elseif (LLDB_EXPORT_ALL_SYMBOLS)

``




https://github.com/llvm/llvm-project/pull/68013
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
2db8540a71ef546087158fcbf38e3b1883c5df48..e7e47a211ebaaa0f6380810b6573fadde12ca02d
 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 lldb/examples/synthetic/gnu_libstdcpp.py
``





View the diff from darker here.


``diff
--- examples/synthetic/gnu_libstdcpp.py 2023-10-02 17:53:17.00 +
+++ examples/synthetic/gnu_libstdcpp.py 2023-10-02 18:07:54.852096 +
@@ -896,16 +896,11 @@
 
 def VariantSummaryProvider(valobj, dict):
 raw_obj = valobj.GetNonSyntheticValue()
 index_obj = raw_obj.GetChildMemberWithName("_M_index")
 data_obj = raw_obj.GetChildMemberWithName("_M_u")
-if not (
-index_obj
-and index_obj.IsValid()
-and data_obj
-and data_obj.IsValid()
-):
+if not (index_obj and index_obj.IsValid() and data_obj and 
data_obj.IsValid()):
 return ""
 
 def get_variant_npos_value(index_byte_size):
 if index_byte_size == 1:
 return 0xFF

``




https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 2db8540a71ef546087158fcbf38e3b1883c5df48 
e7e47a211ebaaa0f6380810b6573fadde12ca02d -- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp
 lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index d8a30729b6d0..ad6d627938c0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -336,10 +336,8 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
   llvm::StringRef identifier;
   llvm::StringRef context;
   std::string path_str = path.str();
-  bool success
-  = CPlusPlusLanguage::ExtractContextAndIdentifier(path_str.c_str(),
-   context,
-   identifier);
+  bool success = CPlusPlusLanguage::ExtractContextAndIdentifier(
+  path_str.c_str(), context, identifier);
   if (!success)
 return m_full.GetStringRef().contains(path);
 
@@ -1105,10 +1103,10 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   stl_synth_flags,
   "lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider")));
   cpp_category_sp->AddTypeSynthetic(
-"^std::variant<.+>$", eFormatterMatchRegex,
-SyntheticChildrenSP(new ScriptedSyntheticChildren(
-stl_synth_flags,
-"lldb.formatters.cpp.gnu_libstdcpp.VariantSynthProvider")));
+  "^std::variant<.+>$", eFormatterMatchRegex,
+  SyntheticChildrenSP(new ScriptedSyntheticChildren(
+  stl_synth_flags,
+  "lldb.formatters.cpp.gnu_libstdcpp.VariantSynthProvider")));
 
   stl_summary_flags.SetDontShowChildren(false);
   stl_summary_flags.SetSkipPointers(false);

``




https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-02 Thread José Lira Junior via lldb-commits

junior-jl wrote:

> You can use `lldb/test/Shell/Commands/command-thread-select.test` as an 
> example to write your own test.

Using this file as a template, I wrote `command-process-launch-user-entry.test` 
as shown below:

```
# RUN: %clang_host -g %S/Inputs/main.c -o %t
# RUN: %lldb %t -s %s -o exit | FileCheck %s

process launch -m
# CHECK-LABEL: process launch -m
# CHECK: Process {{.*}} stopped
# CHECK: stop reason = one-shot breakpoint 1
# CHECK:   frame #0: {{.*}}`main at main.c
```

But I wanted to add the check line `# CHECK: Process {{.*}} launched: '{{.*}}' 
{{.*}}`, but this fails because the following is happening:

1. When the command is executed from the `(lldb)` prompt, it correctly shows 
that the process is launched then stopped.

```
$ ./bin/lldb ~/main.out
(lldb) target create "/home/jose/main.out"
Current executable set to '/home/jose/main.out' (x86_64).
(lldb) process launch -m
Process 63632 launched: '/home/jose/main.out' (x86_64)
Process 63632 stopped
* thread #1, name = 'main.out', stop reason = one-shot breakpoint 1
frame #0: 0x5140 main.out`main at main.c:2
   1int foo() { return 0; }
-> 2int main() { return foo(); }
   3
(lldb) 
```

2. When I run like shown below, the `Process launched` message is shown after 
the stop.

```
$ ./bin/lldb ~/main.out -o 'process launch -m'
(lldb) target create "/home/jose/main.out"
Current executable set to '/home/jose/main.out' (x86_64).
(lldb) process launch -m
Process 63846 stopped
* thread #1, name = 'main.out', stop reason = one-shot breakpoint 1
frame #0: 0x5140 main.out`main at main.c:2
   1int foo() { return 0; }
-> 2int main() { return foo(); }
   3
Process 63846 launched: '/home/jose/main.out' (x86_64)
(lldb) 
```

Is this behaviour expected?

https://github.com/llvm/llvm-project/pull/67019
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-02 Thread Med Ismail Bennani via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


medismailben wrote:

> > You can use `lldb/test/Shell/Commands/command-thread-select.test` as an 
> > example to write your own test.
> 
> Using this file as a template, I wrote 
> `command-process-launch-user-entry.test` as shown below:
> 
> ```
> # RUN: %clang_host -g %S/Inputs/main.c -o %t
> # RUN: %lldb %t -s %s -o exit | FileCheck %s
> 
> process launch -m
> # CHECK-LABEL: process launch -m
> # CHECK: Process {{.*}} stopped
> # CHECK: stop reason = one-shot breakpoint 1
> # CHECK:   frame #0: {{.*}}`main at main.c
> ```
> 
> But I wanted to add the check line `# CHECK: Process {{.*}} launched: 
> '{{.*}}' {{.*}}`, but this fails because the following is happening:
> 
> 1. When the command is executed from the `(lldb)` prompt, it correctly shows 
> that the process is launched then stopped.
> 
> ```
> $ ./bin/lldb ~/main.out
> (lldb) target create "/home/jose/main.out"
> Current executable set to '/home/jose/main.out' (x86_64).
> (lldb) process launch -m
> Process 63632 launched: '/home/jose/main.out' (x86_64)
> Process 63632 stopped
> * thread #1, name = 'main.out', stop reason = one-shot breakpoint 1
> frame #0: 0x5140 main.out`main at main.c:2
>1  int foo() { return 0; }
> -> 2  int main() { return foo(); }
>3  
> (lldb) 
> ```
> 
> 2. When I run like shown below, the `Process launched` message is shown after 
> the stop.
> 
> ```
> $ ./bin/lldb ~/main.out -o 'process launch -m'
> (lldb) target create "/home/jose/main.out"
> Current executable set to '/home/jose/main.out' (x86_64).
> (lldb) process launch -m
> Process 63846 stopped
> * thread #1, name = 'main.out', stop reason = one-shot breakpoint 1
> frame #0: 0x5140 main.out`main at main.c:2
>1  int foo() { return 0; }
> -> 2  int main() { return foo(); }
>3
> Process 63846 launched: '/home/jose/main.out' (x86_64)
> (lldb) 
> ```
> 
> Is this behaviour expected?

I can reproduce it:

```
$ ./bin/lldb /tmp/main -o "b main" -o "r"
(lldb) target create "/tmp/main"
Current executable set to '/tmp/main' (arm64).
(lldb) b main
Breakpoint 1: where = main`main + 12 at main.cpp:2:3, address = 
0x00013fa0
(lldb) r
Process 53764 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00013fa0 main`main at main.cpp:2:3
   1int main() {
-> 2  return 0;
   3}
Process 53764 launched: '/tmp/main' (arm64)
```

By default the debugger runs in asynchronous mode so the stop events can be 
handled in a nondetermistic way. However, I think this confusing and we should 
do something about (in a separate PR). Could you file a new issue describing 
this behavior and pasting the link here.

Your test looks fine to me, so we can move on with it to merge your PR. I'll 
update it after we fix that other bug.


https://github.com/llvm/llvm-project/pull/67019
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Improve omp offload profiler (PR #68016)

2023-10-02 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 0b07b06effe5fdf779b75bb5ac6cf15e477cb0be 
7c550d3190614d7572bc2d63051d7ce56c8f73b6 -- llvm/lib/Support/TimeProfiler.cpp 
openmp/libomptarget/src/api.cpp openmp/libomptarget/src/interface.cpp 
openmp/libomptarget/src/omptarget.cpp openmp/libomptarget/src/private.h
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4446583102a8..330a4d93378a 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -226,7 +226,7 @@ struct llvm::TimeTraceProfiler {
 J.attribute("tid", int64_t(TotalTid));
 J.attribute("ph", "X");
 J.attribute("ts", 0);
-J.attribute("dur", DurNs / 1000 );
+J.attribute("dur", DurNs / 1000);
 J.attribute("name", "Total: " + Total.first);
 J.attributeObject("args", [&] {
   J.attribute("count", int64_t(Count));
@@ -261,10 +261,10 @@ struct llvm::TimeTraceProfiler {
 // Emit the absolute time when this TimeProfiler started.
 // This can be used to combine the profiling data from
 // multiple processes and preserve actual time intervals.
-J.attribute("beginningOfTime",
-time_point_cast(BeginningOfTime)
-.time_since_epoch()
-.count()/1000);
+J.attribute("beginningOfTime", 
time_point_cast(BeginningOfTime)
+   .time_since_epoch()
+   .count() /
+   1000);
 
 J.objectEnd();
   }
diff --git a/openmp/libomptarget/src/api.cpp b/openmp/libomptarget/src/api.cpp
index 5dd918808492..06de1f8f20b7 100644
--- a/openmp/libomptarget/src/api.cpp
+++ b/openmp/libomptarget/src/api.cpp
@@ -50,8 +50,8 @@ EXTERN int omp_get_initial_device(void) {
 }
 
 EXTERN void *omp_target_alloc(size_t Size, int DeviceNum) {
-  TIMESCOPE_WITH_DETAILS("dst_dev="+std::to_string(DeviceNum)
-+";size="+std::to_string(Size));
+  TIMESCOPE_WITH_DETAILS("dst_dev=" + std::to_string(DeviceNum) +
+ ";size=" + std::to_string(Size));
   return targetAllocExplicit(Size, DeviceNum, TARGET_ALLOC_DEFAULT, __func__);
 }
 
@@ -136,9 +136,9 @@ EXTERN int omp_target_is_present(const void *Ptr, int 
DeviceNum) {
 EXTERN int omp_target_memcpy(void *Dst, const void *Src, size_t Length,
  size_t DstOffset, size_t SrcOffset, int DstDevice,
  int SrcDevice) {
-  TIMESCOPE_WITH_DETAILS("dst_dev="+std::to_string(DstDevice)
-  +";src_dev="+std::to_string(SrcDevice)
-  +";size="+std::to_string(Length));
+  TIMESCOPE_WITH_DETAILS("dst_dev=" + std::to_string(DstDevice) +
+ ";src_dev=" + std::to_string(SrcDevice) +
+ ";size=" + std::to_string(Length));
   DP("Call to omp_target_memcpy, dst device %d, src device %d, "
  "dst addr " DPxMOD ", src addr " DPxMOD ", dst offset %zu, "
  "src offset %zu, length %zu\n",
@@ -291,9 +291,9 @@ EXTERN int omp_target_memcpy_async(void *Dst, const void 
*Src, size_t Length,
size_t DstOffset, size_t SrcOffset,
int DstDevice, int SrcDevice,
int DepObjCount, omp_depend_t *DepObjList) {
-  TIMESCOPE_WITH_DETAILS("dst_dev="+std::to_string(DstDevice)
-  +";src_dev="+std::to_string(SrcDevice)
-  +";size="+std::to_string(Length));
+  TIMESCOPE_WITH_DETAILS("dst_dev=" + std::to_string(DstDevice) +
+ ";src_dev=" + std::to_string(SrcDevice) +
+ ";size=" + std::to_string(Length));
   DP("Call to omp_target_memcpy_async, dst device %d, src device %d, "
  "dst addr " DPxMOD ", src addr " DPxMOD ", dst offset %zu, "
  "src offset %zu, length %zu\n",
@@ -379,10 +379,10 @@ EXTERN int omp_target_memcpy_rect_async(
 const size_t *Volume, const size_t *DstOffsets, const size_t *SrcOffsets,
 const size_t *DstDimensions, const size_t *SrcDimensions, int DstDevice,
 int SrcDevice, int DepObjCount, omp_depend_t *DepObjList) {
-  TIMESCOPE_WITH_DETAILS("dst_dev="+std::to_string(DstDevice)
-  +";src_dev="+std::to_string(SrcDevice)
-  +";size="+std::to_string(ElementSize)
-  +";num_dims="+std::to_string(NumDims));
+  TIMESCOPE_WITH_DETAILS("dst_dev=" + std::to_string(DstDevice) +
+ ";src_dev=" + std::to_string(SrcDevice) +
+ ";size=" + std::to_string(ElementSize) +
+ ";num_dims=" + std::to_

[Lldb-commits] [lldb] Improve omp offload profiler (PR #68016)

2023-10-02 Thread via lldb-commits

https://github.com/fel-cab updated 
https://github.com/llvm/llvm-project/pull/68016

>From dd44de067c26ba94b6561c5ed7fa4a5d812a3d1a Mon Sep 17 00:00:00 2001
From: Felipe Cabarcas 
Date: Mon, 18 Sep 2023 12:07:12 +
Subject: [PATCH 1/9] testing Profiler features

---
 openmp/libomptarget/src/interface.cpp | 5 -
 openmp/libomptarget/src/private.h | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/openmp/libomptarget/src/interface.cpp 
b/openmp/libomptarget/src/interface.cpp
index 5f21b16b3fbfb1e..f64e1e268a3952e 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -252,7 +252,10 @@ static inline int targetKernel(ident_t *Loc, int64_t 
DeviceId, int32_t NumTeams,
   static_assert(std::is_convertible_v,
 "Target AsyncInfoTy must be convertible to AsyncInfoTy.");
 
-  TIMESCOPE_WITH_IDENT(Loc);
+  //TIMESCOPE_WITH_IDENT(Loc);
+  TIMESCOPE();
+  //TIMESCOPE_WITH_NAME_AND_IDENT("Hello", Loc);
+  //TIMESCOPE_WITH_RTM_AND_IDENT("Hello", Loc);
 
   DP("Entering target region for device %" PRId64 " with entry point " DPxMOD
  "\n",
diff --git a/openmp/libomptarget/src/private.h 
b/openmp/libomptarget/src/private.h
index cbce15b63a3eba2..dc6cd3944233955 100644
--- a/openmp/libomptarget/src/private.h
+++ b/openmp/libomptarget/src/private.h
@@ -433,7 +433,8 @@ class ExponentialBackoff {
   SourceInfo SI(IDENT);
\
   std::string ProfileLocation = SI.getProfileLocation();   
\
   std::string RTM = RegionTypeMsg; 
\
-  llvm::TimeTraceScope TimeScope(__FUNCTION__, ProfileLocation + RTM)
+  llvm::TimeTraceScope TimeScope(ProfileLocation, ProfileLocation + RTM)
+  //llvm::TimeTraceScope TimeScope(__FUNCTION__, ProfileLocation + RTM)
 #else
 #define TIMESCOPE()
 #define TIMESCOPE_WITH_IDENT(IDENT)

>From 92586bca6364100c7511ad38a30f41b0f86dea9c Mon Sep 17 00:00:00 2001
From: Felipe Cabarcas 
Date: Tue, 19 Sep 2023 12:02:53 +
Subject: [PATCH 2/9] Improve Profiler 1

---
 llvm/lib/Support/TimeProfiler.cpp |  2 +-
 openmp/libomptarget/src/interface.cpp | 17 +
 openmp/libomptarget/src/omptarget.cpp | 10 +-
 openmp/libomptarget/src/private.h |  5 +++--
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b1709..e1458116f64ab47 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -227,7 +227,7 @@ struct llvm::TimeTraceProfiler {
 J.attribute("ph", "X");
 J.attribute("ts", 0);
 J.attribute("dur", DurUs);
-J.attribute("name", "Total " + Total.first);
+J.attribute("name", "Total: " + Total.first);
 J.attributeObject("args", [&] {
   J.attribute("count", int64_t(Count));
   J.attribute("avg ms", int64_t(DurUs / Count / 1000));
diff --git a/openmp/libomptarget/src/interface.cpp 
b/openmp/libomptarget/src/interface.cpp
index f64e1e268a3952e..b8892cbe689107f 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -33,14 +33,14 @@ using namespace llvm::omp::target::ompt;
 

 /// adds requires flags
 EXTERN void __tgt_register_requires(int64_t Flags) {
-  TIMESCOPE();
+  //TIMESCOPE();
   PM->RTLs.registerRequires(Flags);
 }
 
 

 /// adds a target shared library to the target execution image
 EXTERN void __tgt_register_lib(__tgt_bin_desc *Desc) {
-  TIMESCOPE();
+  //TIMESCOPE();
   if (PM->maybeDelayRegisterLib(Desc))
 return;
 
@@ -61,7 +61,7 @@ EXTERN void __tgt_init_all_rtls() { PM->RTLs.initAllRTLs(); }
 

 /// unloads a target shared library
 EXTERN void __tgt_unregister_lib(__tgt_bin_desc *Desc) {
-  TIMESCOPE();
+  //TIMESCOPE();
   PM->RTLs.unregisterLib(Desc);
   for (auto &RTL : PM->RTLs.UsedRTLs) {
 if (RTL->unregister_lib) {
@@ -82,7 +82,8 @@ targetData(ident_t *Loc, int64_t DeviceId, int32_t ArgNum, 
void **ArgsBase,
   static_assert(std::is_convertible_v,
 "TargetAsyncInfoTy must be convertible to AsyncInfoTy.");
 
-  TIMESCOPE_WITH_RTM_AND_IDENT(RegionTypeMsg, Loc);
+  //TIMESCOPE_WITH_RTM_AND_IDENT(RegionTypeMsg, Loc);
+  TIMESCOPE_WITH_RTM_AND_IDENT("targetData", Loc);
 
   DP("Entering data %s region for device %" PRId64 " with %d mappings\n",
  RegionName, DeviceId, ArgNum);
@@ -253,9 +254,9 @@ static inline int targetKernel(ident_t *Loc, int64_t 
DeviceId, int32_t NumTeams,
 "Target AsyncInfoTy must be convertible to AsyncInfoTy.");
 
   //TIMESCOPE_WITH_IDENT(Loc);
-  TIMESCOPE();
+  //TIMESCOPE();
   //TIMESCOPE_WITH_NAME_AND_IDENT("Hello", Loc);
-  //

[Lldb-commits] [lldb] [ELF] Handle relocations in synthetic .eh_frame with a non-zero offset within the output section (PR #65966)

2023-10-02 Thread via lldb-commits

https://github.com/simpal01 updated 
https://github.com/llvm/llvm-project/pull/65966

>From 43c156c679951cc3d827fdb7604e30aab658fd9a Mon Sep 17 00:00:00 2001
From: Simi Pallipurath 
Date: Mon, 11 Sep 2023 14:42:27 +0100
Subject: [PATCH 1/3] [LLD][AARCH64] lld incorrectly handles .eh_frame when it
 has a non-zero offset within its output section.

When the .eh_frame section is placed at a non-zero
offset within its output section, the relocation
value within .eh_frame are computed incorrectly.

We had similar issue in AArch32 and it has been
fixed already in https://reviews.llvm.org/D148033.

While applying the relocation using S+A-P, the value
of P (the location of the relocation) is getting wrong.
P is:
  P = SecAddr + rel.offset, But SecAddr points to the
starting address of the outputsection rather than the
starting address of the eh frame section within that
output section.
---
 lld/ELF/Arch/AArch64.cpp   |  3 ++
 lld/test/ELF/eh-frame-nonzero-offset.s | 55 ++
 2 files changed, 58 insertions(+)
 create mode 100644 lld/test/ELF/eh-frame-nonzero-offset.s

diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 174a0a3624f7765..09477141c777948 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -770,6 +770,9 @@ void AArch64::relocateAlloc(InputSectionBase &sec, uint8_t 
*buf) const {
   uint64_t secAddr = sec.getOutputSection()->addr;
   if (auto *s = dyn_cast(&sec))
 secAddr += s->outSecOff;
+  else if (auto *eh = dyn_cast(&sec))
+if (InputSection *isec = eh->getParent())
+  secAddr += isec->outSecOff;
   AArch64Relaxer relaxer(sec.relocs());
   for (size_t i = 0, size = sec.relocs().size(); i != size; ++i) {
 const Relocation &rel = sec.relocs()[i];
diff --git a/lld/test/ELF/eh-frame-nonzero-offset.s 
b/lld/test/ELF/eh-frame-nonzero-offset.s
new file mode 100644
index 000..ef086fcf670d81b
--- /dev/null
+++ b/lld/test/ELF/eh-frame-nonzero-offset.s
@@ -0,0 +1,55 @@
+// REQUIRES: aarch64
+// RUN: rm -rf %t && split-file %s %t
+
+// RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
+// RUN: ld.lld %t/a.o -T %t/eh-frame-non-zero-offset.t -o %t/non-zero
+// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame 
%t/non-zero | FileCheck --check-prefix=NONZERO %s
+// RUN: ld.lld %t/a.o -T %t/eh-frame-zero-offset.t -o %t/zero
+// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame %t/zero 
| FileCheck --check-prefix=ZERO %s
+
+// NONZERO:  {{[0-9]+}}: 0080 {{.*}} __eh_frame_start
+// NONZERO-NEXT: {{[0-9]+}}: 00ac {{.*}} __eh_frame_end
+
+// NONZERO:  0x0078   1000 
+// NONZERO-NEXT: 0x0088 017a5200 017c1e01 1b0c1f00 1000
+// NONZERO-NEXT: 0x0098 1800 64ff 0800 
+// NONZERO-NEXT: 0x00a8 
+
+// ZERO:  {{[0-9]+}}: 0080 {{.*}} __eh_frame_start
+// ZERO-NEXT: {{[0-9]+}}: 00ac {{.*}} __eh_frame_end
+
+// ZERO:  0x0080 1000  017a5200 017c1e01
+// ZERO-NEXT: 0x0090 1b0c1f00 1000 1800 64ff
+// ZERO-NEXT: 0x00a0 0800  
+
+//--- eh-frame-non-zero-offset.t
+SECTIONS {
+  .text : { *(.text .text.*) }
+  .eh_frame : {
+  /* Alignment padding within .eh_frame */
+  . = ALIGN(128);
+  __eh_frame_start = .;
+  *(.eh_frame .eh_frame.*) ;
+  __eh_frame_end = .;
+  }
+}
+
+//--- eh-frame-zero-offset.t
+SECTIONS {
+  .text : { *(.text .text.*) }
+  .eh_frame : ALIGN(128) {
+  __eh_frame_start = .;
+  *(.eh_frame .eh_frame.*) ;
+  __eh_frame_end = .;
+  }
+}
+
+//--- a.s
+.section .text.01, "ax",%progbits
+.global f1
+.type f1, %function
+f1:
+.cfi_startproc
+   nop
+   nop
+.cfi_endproc

>From bf78a2ee26fac6235f9cb32ced10ae7c92f4b579 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath 
Date: Mon, 18 Sep 2023 19:50:56 +0100
Subject: [PATCH 2/3] fixup! [LLD][AARCH64] lld incorrectly handles .eh_frame
 when it has a non-zero offset within its output section.

---
 lld/ELF/Arch/AArch64.cpp  |  7 ++-
 lld/ELF/Arch/PPC64.cpp|  4 ++
 lld/ELF/Arch/X86_64.cpp   |  4 ++
 lld/ELF/SyntheticSections.cpp |  7 ++-
 lld/ELF/Target.cpp|  4 ++
 ...et.s => eh-frame-nonzero-offset-aarch64.s} |  0
 lld/test/ELF/eh-frame-nonzero-offset-arm.s| 55 +++
 lld/test/ELF/eh-frame-nonzero-offset-ppc.s| 54 ++
 lld/test/ELF/eh-frame-nonzero-offset-x86.s| 54 ++
 9 files changed, 185 insertions(+), 4 deletions(-)
 rename lld/test/ELF/{eh-frame-nonzero-offset.s => 
eh-frame-nonzero-offset-aarch64.s} (100%)
 create mode 100644 lld/test/ELF/eh-frame-nonzero-offset-arm.s
 create mode 100644 lld/test/ELF/eh-frame-nonzero-offset-ppc.s
 create mode 100644 lld/test/ELF/eh-frame-nonzero-offset-x86.s

diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 09477141c777948

[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-02 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/67019

From c2396253b9584af9eabe1e67ed922f5f5f0e879c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Thu, 21 Sep 2023 11:12:58 -0300
Subject: [PATCH 1/3] [lldb] add stop-at-user-entry option to process launch

[lldb] add command start

[lldb] add stop-at-main option to process launch

Revert "[lldb] add command start"

This reverts commit 11270775865a8415e00b4d899703f84717344967.

[lldb] remove shell modification | make bp one-shot

add GetUserEntryPointName method | changed bp creating method

use clang-format

change option description | using set for entrypoint names

use SetVector | change comments style

replace const char* by StringRef | change if statements to return early
---
 lldb/include/lldb/Target/Language.h   | 20 ++--
 .../Commands/CommandOptionsProcessLaunch.cpp  | 48 ++-
 lldb/source/Commands/Options.td   |  4 ++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  6 ++-
 .../Plugins/Language/ObjC/ObjCLanguage.h  |  2 +
 .../ObjCPlusPlus/ObjCPlusPlusLanguage.h   |  2 +
 6 files changed, 73 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index a6b9ccaf31b3c42..cf781fc0e8dd5ee 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -95,21 +95,24 @@ class Language : public PluginInterface {
   class EitherTypeScavenger : public TypeScavenger {
   public:
 EitherTypeScavenger() : TypeScavenger() {
-  for (std::shared_ptr scavenger : { 
std::shared_ptr(new ScavengerTypes())... }) {
+  for (std::shared_ptr scavenger :
+   {std::shared_ptr(new ScavengerTypes())...}) {
 if (scavenger)
   m_scavengers.push_back(scavenger);
   }
 }
+
   protected:
 bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
ResultSet &results) override {
   const bool append = false;
-  for (auto& scavenger : m_scavengers) {
+  for (auto &scavenger : m_scavengers) {
 if (scavenger && scavenger->Find(exe_scope, key, results, append))
   return true;
   }
   return false;
 }
+
   private:
 std::vector> m_scavengers;
   };
@@ -118,22 +121,25 @@ class Language : public PluginInterface {
   class UnionTypeScavenger : public TypeScavenger {
   public:
 UnionTypeScavenger() : TypeScavenger() {
-  for (std::shared_ptr scavenger : { 
std::shared_ptr(new ScavengerTypes())... }) {
+  for (std::shared_ptr scavenger :
+   {std::shared_ptr(new ScavengerTypes())...}) {
 if (scavenger)
   m_scavengers.push_back(scavenger);
   }
 }
+
   protected:
 bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
ResultSet &results) override {
   const bool append = true;
   bool success = false;
-  for (auto& scavenger : m_scavengers) {
+  for (auto &scavenger : m_scavengers) {
 if (scavenger)
   success = scavenger->Find(exe_scope, key, results, append) || 
success;
   }
   return success;
 }
+
   private:
 std::vector> m_scavengers;
   };
@@ -160,6 +166,10 @@ class Language : public PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  // Implement this function to return the user-defined entry point name
+  // for the language
+  virtual llvm::StringRef GetUserEntryPointName() const { return {}; }
+
   virtual bool IsTopLevelFunction(Function &function);
 
   virtual bool IsSourceFile(llvm::StringRef file_path) const = 0;
@@ -232,7 +242,7 @@ class Language : public PluginInterface {
   // a match.  But we wouldn't want this to match AnotherA::my_function.  The
   // user is specifying a truncated path, not a truncated set of characters.
   // This function does a language-aware comparison for those purposes.
-  virtual bool DemangledNameContainsPath(llvm::StringRef path, 
+  virtual bool DemangledNameContainsPath(llvm::StringRef path,
  ConstString demangled) const;
 
   // if a language has a custom format for printing variable declarations that
diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp 
b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
index 85ad8ff5e07132c..2645b7bdd8c4ae6 100644
--- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandOptionsProcessLaunch.h"
 
+#include "lldb/Core/Module.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Host/OptionParser.h"
@@ -15,11 +16,13 @@
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/CommandOptionArgumentTable.h"
 #include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/ExecutionContext.h"
+#inclu

[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-02 Thread José Lira Junior via lldb-commits

junior-jl wrote:

> Could you file a new issue describing this behavior and pasting the link here.

Done! https://github.com/llvm/llvm-project/issues/68035

> Your test looks fine to me, so we can move on with it to merge your PR. I'll 
> update it after we fix that other bug.

Great. Added the test in the latest commit.



https://github.com/llvm/llvm-project/pull/67019
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/68012

>From e7e47a211ebaaa0f6380810b6573fadde12ca02d Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 2 Oct 2023 10:53:17 -0700
Subject: [PATCH 1/2] Implement data formatters for LibStdC++ std::variant

---
 lldb/examples/synthetic/gnu_libstdcpp.py  | 89 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 18 +++-
 .../libstdcpp/variant/Makefile|  5 ++
 .../TestDataFormatterLibStdcxxVariant.py  | 72 +++
 .../libstdcpp/variant/main.cpp| 79 
 5 files changed, 259 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp

diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 825b7f3787a010d..7462db744674682 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -892,3 +892,92 @@ def update(self):
 except:
 pass
 return False
+
+
+def VariantSummaryProvider(valobj, dict):
+raw_obj = valobj.GetNonSyntheticValue()
+index_obj = raw_obj.GetChildMemberWithName("_M_index")
+data_obj = raw_obj.GetChildMemberWithName("_M_u")
+if not (
+index_obj
+and index_obj.IsValid()
+and data_obj
+and data_obj.IsValid()
+):
+return ""
+
+def get_variant_npos_value(index_byte_size):
+if index_byte_size == 1:
+return 0xFF
+elif index_byte_size == 2:
+return 0x
+else:
+return 0x
+
+npos_value = get_variant_npos_value(index_obj.GetByteSize())
+index = index_obj.GetValueAsUnsigned(0)
+if index == npos_value:
+return " No Value"
+
+active_type = data_obj.GetType().GetTemplateArgumentType(index)
+return f" Active Type = {active_type.GetDisplayTypeName()} "
+
+
+class VariantSynthProvider:
+def __init__(self, valobj, dict):
+self.raw_obj = valobj.GetNonSyntheticValue()
+self.is_valid = False
+self.index = None
+self.data_obj = None
+
+def update(self):
+try:
+self.index = self.raw_obj.GetChildMemberWithName(
+"_M_index"
+).GetValueAsSigned(-1)
+self.is_valid = self.index != -1
+self.data_obj = self.raw_obj.GetChildMemberWithName("_M_u")
+except:
+self.is_valid = False
+return False
+
+def has_children(self):
+return True
+
+def num_children(self):
+return 1 if self.is_valid else 0
+
+def get_child_index(self, name):
+return 0
+
+def get_child_at_index(self, index):
+if not self.is_valid:
+return None
+cur = 0
+node = self.data_obj
+while cur < self.index:
+node = node.GetChildMemberWithName("_M_rest")
+cur += 1
+
+# _M_storage's type depends on variant field's type "_Type".
+#  1. if '_Type' is literal type: _Type _M_storage.
+#  2. otherwise, __gnu_cxx::__aligned_membuf<_Type> _M_storage.
+#
+# For 2. we have to cast it to underlying template _Type.
+
+value = node.GetChildMemberWithName("_M_first").GetChildMemberWithName(
+"_M_storage"
+)
+template_type = value.GetType().GetTemplateArgumentType(0)
+
+# Literal type will return None for GetTemplateArgumentType(0)
+if (
+template_type
+and "__gnu_cxx::__aligned_membuf" in 
value.GetType().GetDisplayTypeName()
+and template_type.IsValid()
+):
+value = value.Cast(template_type)
+
+if value.IsValid():
+return value.Clone("Value")
+return None
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index c1743a5e0a418dd..d8a30729b6d02e1 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -332,11 +332,11 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
   // If we can't parse the incoming name, then just check that it contains 
path.
   if (m_parse_error)
 return m_full.GetStringRef().contains(path);
-
+
   llvm::StringRef identifier;
   llvm::StringRef context;
   std::string path_str = path.str();
-  bool success 
+  bool success
   = CPlusPlusLanguage::ExtractContextAndIdentifier(path_str.c_str(),
context,

[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

https://github.com/jeffreytan81 ready_for_review 
https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb


Changes

This patch implements the data formatters for LibStdC++ `std::variant`.

---
Full diff: https://github.com/llvm/llvm-project/pull/68012.diff


5 Files Affected:

- (modified) lldb/examples/synthetic/gnu_libstdcpp.py (+84) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
(+14-4) 
- (added) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile
 (+5) 
- (added) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 (+72) 
- (added) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp
 (+79) 


``diff
diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 825b7f3787a010d..29c926167fb440c 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -892,3 +892,87 @@ def update(self):
 except:
 pass
 return False
+
+
+def VariantSummaryProvider(valobj, dict):
+raw_obj = valobj.GetNonSyntheticValue()
+index_obj = raw_obj.GetChildMemberWithName("_M_index")
+data_obj = raw_obj.GetChildMemberWithName("_M_u")
+if not (index_obj and index_obj.IsValid() and data_obj and 
data_obj.IsValid()):
+return ""
+
+def get_variant_npos_value(index_byte_size):
+if index_byte_size == 1:
+return 0xFF
+elif index_byte_size == 2:
+return 0x
+else:
+return 0x
+
+npos_value = get_variant_npos_value(index_obj.GetByteSize())
+index = index_obj.GetValueAsUnsigned(0)
+if index == npos_value:
+return " No Value"
+
+active_type = data_obj.GetType().GetTemplateArgumentType(index)
+return f" Active Type = {active_type.GetDisplayTypeName()} "
+
+
+class VariantSynthProvider:
+def __init__(self, valobj, dict):
+self.raw_obj = valobj.GetNonSyntheticValue()
+self.is_valid = False
+self.index = None
+self.data_obj = None
+
+def update(self):
+try:
+self.index = self.raw_obj.GetChildMemberWithName(
+"_M_index"
+).GetValueAsSigned(-1)
+self.is_valid = self.index != -1
+self.data_obj = self.raw_obj.GetChildMemberWithName("_M_u")
+except:
+self.is_valid = False
+return False
+
+def has_children(self):
+return True
+
+def num_children(self):
+return 1 if self.is_valid else 0
+
+def get_child_index(self, name):
+return 0
+
+def get_child_at_index(self, index):
+if not self.is_valid:
+return None
+cur = 0
+node = self.data_obj
+while cur < self.index:
+node = node.GetChildMemberWithName("_M_rest")
+cur += 1
+
+# _M_storage's type depends on variant field's type "_Type".
+#  1. if '_Type' is literal type: _Type _M_storage.
+#  2. otherwise, __gnu_cxx::__aligned_membuf<_Type> _M_storage.
+#
+# For 2. we have to cast it to underlying template _Type.
+
+value = node.GetChildMemberWithName("_M_first").GetChildMemberWithName(
+"_M_storage"
+)
+template_type = value.GetType().GetTemplateArgumentType(0)
+
+# Literal type will return None for GetTemplateArgumentType(0)
+if (
+template_type
+and "__gnu_cxx::__aligned_membuf" in 
value.GetType().GetDisplayTypeName()
+and template_type.IsValid()
+):
+value = value.Cast(template_type)
+
+if value.IsValid():
+return value.Clone("Value")
+return None
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index c1743a5e0a418dd..a285864ca2e1229 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -332,11 +332,11 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
   // If we can't parse the incoming name, then just check that it contains 
path.
   if (m_parse_error)
 return m_full.GetStringRef().contains(path);
-
+
   llvm::StringRef identifier;
   llvm::StringRef context;
   std::string path_str = path.str();
-  bool success 
+  bool success
   = CPlusPlusLanguage::ExtractContextAndIdentifier(path_str.c_str(),
context,
identifier);
@@ -372,7 +372,7 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
 return false;
   if (haystack.empty() || !isalnum(haystack.back()))
 return true;
-
+
   return false;
 }
 
@@ -388,7 +388,7 @@ bool CPlusPlusLanguage::IsCPPMangledName(llvm::String

[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/68012

>From e7e47a211ebaaa0f6380810b6573fadde12ca02d Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 2 Oct 2023 10:53:17 -0700
Subject: [PATCH 1/3] Implement data formatters for LibStdC++ std::variant

---
 lldb/examples/synthetic/gnu_libstdcpp.py  | 89 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 18 +++-
 .../libstdcpp/variant/Makefile|  5 ++
 .../TestDataFormatterLibStdcxxVariant.py  | 72 +++
 .../libstdcpp/variant/main.cpp| 79 
 5 files changed, 259 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp

diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 825b7f3787a010d..7462db744674682 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -892,3 +892,92 @@ def update(self):
 except:
 pass
 return False
+
+
+def VariantSummaryProvider(valobj, dict):
+raw_obj = valobj.GetNonSyntheticValue()
+index_obj = raw_obj.GetChildMemberWithName("_M_index")
+data_obj = raw_obj.GetChildMemberWithName("_M_u")
+if not (
+index_obj
+and index_obj.IsValid()
+and data_obj
+and data_obj.IsValid()
+):
+return ""
+
+def get_variant_npos_value(index_byte_size):
+if index_byte_size == 1:
+return 0xFF
+elif index_byte_size == 2:
+return 0x
+else:
+return 0x
+
+npos_value = get_variant_npos_value(index_obj.GetByteSize())
+index = index_obj.GetValueAsUnsigned(0)
+if index == npos_value:
+return " No Value"
+
+active_type = data_obj.GetType().GetTemplateArgumentType(index)
+return f" Active Type = {active_type.GetDisplayTypeName()} "
+
+
+class VariantSynthProvider:
+def __init__(self, valobj, dict):
+self.raw_obj = valobj.GetNonSyntheticValue()
+self.is_valid = False
+self.index = None
+self.data_obj = None
+
+def update(self):
+try:
+self.index = self.raw_obj.GetChildMemberWithName(
+"_M_index"
+).GetValueAsSigned(-1)
+self.is_valid = self.index != -1
+self.data_obj = self.raw_obj.GetChildMemberWithName("_M_u")
+except:
+self.is_valid = False
+return False
+
+def has_children(self):
+return True
+
+def num_children(self):
+return 1 if self.is_valid else 0
+
+def get_child_index(self, name):
+return 0
+
+def get_child_at_index(self, index):
+if not self.is_valid:
+return None
+cur = 0
+node = self.data_obj
+while cur < self.index:
+node = node.GetChildMemberWithName("_M_rest")
+cur += 1
+
+# _M_storage's type depends on variant field's type "_Type".
+#  1. if '_Type' is literal type: _Type _M_storage.
+#  2. otherwise, __gnu_cxx::__aligned_membuf<_Type> _M_storage.
+#
+# For 2. we have to cast it to underlying template _Type.
+
+value = node.GetChildMemberWithName("_M_first").GetChildMemberWithName(
+"_M_storage"
+)
+template_type = value.GetType().GetTemplateArgumentType(0)
+
+# Literal type will return None for GetTemplateArgumentType(0)
+if (
+template_type
+and "__gnu_cxx::__aligned_membuf" in 
value.GetType().GetDisplayTypeName()
+and template_type.IsValid()
+):
+value = value.Cast(template_type)
+
+if value.IsValid():
+return value.Clone("Value")
+return None
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index c1743a5e0a418dd..d8a30729b6d02e1 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -332,11 +332,11 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
   // If we can't parse the incoming name, then just check that it contains 
path.
   if (m_parse_error)
 return m_full.GetStringRef().contains(path);
-
+
   llvm::StringRef identifier;
   llvm::StringRef context;
   std::string path_str = path.str();
-  bool success 
+  bool success
   = CPlusPlusLanguage::ExtractContextAndIdentifier(path_str.c_str(),
context,

[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-10-02 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,252 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+static_assert(!HasContainsIt, 
sentinel_wrapper>>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range&& range) { 
std::ranges::contains(std::forward(range), ValT{}); };
+
+static_assert(!HasContainsR);
+static_assert(HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+ValueT a[] = {1, 2, 3, 4, 5, 6};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 6)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =

var-const wrote:

We're using `ret` in the assert below, so I think this `maybe_unused` shouldn't 
be necessary.

https://github.com/llvm/llvm-project/pull/65148
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-10-02 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,252 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+static_assert(!HasContainsIt, 
sentinel_wrapper>>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range&& range) { 
std::ranges::contains(std::forward(range), ValT{}); };
+
+static_assert(!HasContainsR);
+static_assert(HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+ValueT a[] = {1, 2, 3, 4, 5, 6};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 6)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+std::ranges::contains(whole.begin(), whole.end(), 3);
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+std::ranges::contains(whole, 3);
+  assert(ret);
+}
+  }
+
+  { // check that a range with a single element works
+ValueT a[] = {32};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 1)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // check that an empty range works
+ValueT a[] = {};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 1);
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 1);
+  assert(!ret);
+}
+  }
+
+  { // check that the first element matches
+ValueT a[] = {32, 3, 2, 1, 0, 23, 21, 9, 40, 100};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 10)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // check that the last element matches
+ValueT a[] = {3, 22, 1, 43, 99, 0, 56, 100, 32};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 9)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // no match
+ValueT a[] = {13, 1, 21, 4, 5};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 5)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 10);
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 10);
+  assert(!ret);
+}
+  }
+
+  { // check that the projections are used
+int a[] = {1, 9, 0, 13, 25};
+{
+  bool ret = std::ranges::contains(a, a + 5, -13, [&](int i) { return i * 
-1; });
+  assert(ret);
+}
+{
+  auto range = std::ranges::subrange(a, a + 5);
+  bool ret = std::ranges::contains(range, -13, [&](int i) { return i * -1; 
});
+  assert(ret);
+}
+  }
+
+  { // check the nodiscard extension
+// use #pragma around to suppress error: ignoring return value of function
+// declared with 'nodiscard' attribute [-Werror,-Wunused-result]
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-result"
+ValueT a[] = {1, 9, 0, 13, 25};
+auto w

[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-10-02 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,252 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+static_assert(!HasContainsIt, 
sentinel_wrapper>>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range&& range) { 
std::ranges::contains(std::forward(range), ValT{}); };
+
+static_assert(!HasContainsR);
+static_assert(HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+ValueT a[] = {1, 2, 3, 4, 5, 6};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 6)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+std::ranges::contains(whole.begin(), whole.end(), 3);
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+std::ranges::contains(whole, 3);
+  assert(ret);
+}
+  }
+
+  { // check that a range with a single element works
+ValueT a[] = {32};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 1)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // check that an empty range works
+ValueT a[] = {};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 1);
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 1);
+  assert(!ret);
+}
+  }
+
+  { // check that the first element matches
+ValueT a[] = {32, 3, 2, 1, 0, 23, 21, 9, 40, 100};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 10)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // check that the last element matches
+ValueT a[] = {3, 22, 1, 43, 99, 0, 56, 100, 32};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 9)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // no match
+ValueT a[] = {13, 1, 21, 4, 5};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 5)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 10);
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 10);
+  assert(!ret);
+}
+  }
+
+  { // check that the projections are used
+int a[] = {1, 9, 0, 13, 25};
+{
+  bool ret = std::ranges::contains(a, a + 5, -13, [&](int i) { return i * 
-1; });
+  assert(ret);
+}
+{
+  auto range = std::ranges::subrange(a, a + 5);
+  bool ret = std::ranges::contains(range, -13, [&](int i) { return i * -1; 
});
+  assert(ret);
+}
+  }
+
+  { // check the nodiscard extension
+// use #pragma around to suppress error: ignoring return value of function
+// declared with 'nodiscard' attribute [-Werror,-Wunused-result]
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-result"
+ValueT a[] = {1, 9, 0, 13, 25};
+auto w

[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-10-02 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,252 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+static_assert(!HasContainsIt, 
sentinel_wrapper>>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range&& range) { 
std::ranges::contains(std::forward(range), ValT{}); };
+
+static_assert(!HasContainsR);
+static_assert(HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+ValueT a[] = {1, 2, 3, 4, 5, 6};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 6)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+std::ranges::contains(whole.begin(), whole.end(), 3);
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+std::ranges::contains(whole, 3);
+  assert(ret);
+}
+  }
+
+  { // check that a range with a single element works
+ValueT a[] = {32};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 1)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // check that an empty range works
+ValueT a[] = {};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 1);
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 1);
+  assert(!ret);
+}
+  }
+
+  { // check that the first element matches
+ValueT a[] = {32, 3, 2, 1, 0, 23, 21, 9, 40, 100};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 10)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // check that the last element matches
+ValueT a[] = {3, 22, 1, 43, 99, 0, 56, 100, 32};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 9)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 32);
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 32);
+  assert(ret);
+}
+  }
+
+  { // no match
+ValueT a[] = {13, 1, 21, 4, 5};
+auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a + 5)));
+{
+  bool ret = std::ranges::contains(whole.begin(), whole.end(), 10);
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains(whole, 10);
+  assert(!ret);
+}
+  }
+
+  { // check that the projections are used
+int a[] = {1, 9, 0, 13, 25};
+{
+  bool ret = std::ranges::contains(a, a + 5, -13, [&](int i) { return i * 
-1; });
+  assert(ret);
+}
+{
+  auto range = std::ranges::subrange(a, a + 5);
+  bool ret = std::ranges::contains(range, -13, [&](int i) { return i * -1; 
});
+  assert(ret);
+}
+  }
+
+  { // check the nodiscard extension
+// use #pragma around to suppress error: ignoring return value of function
+// declared with 'nodiscard' attribute [-Werror,-Wunused-result]
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-result"
+ValueT a[] = {1, 9, 0, 13, 25};
+auto w

[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-10-02 Thread Konstantin Varlamov via lldb-commits

https://github.com/var-const unassigned 
https://github.com/llvm/llvm-project/pull/65148
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR (PR #68042)

2023-10-02 Thread via lldb-commits

https://github.com/shraiysh created 
https://github.com/llvm/llvm-project/pull/68042

This patch adds translation from `omp.teams` operation to LLVM IR using 
OpenMPIRBuilder. The clauses are not handled in this patch.

>From c7c9e907d897ae667331761d8097ccb7852c5d93 Mon Sep 17 00:00:00 2001
From: Shraiysh Vaishay 
Date: Mon, 2 Oct 2023 16:43:13 -0500
Subject: [PATCH] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR

This patch adds translation from `omp.teams` operation to LLVM IR using
OpenMPIRBuilder.

The clauses are not handled in this patch.
---
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  |  21 +++
 mlir/test/Target/LLVMIR/openmp-teams.mlir | 136 ++
 2 files changed, 157 insertions(+)
 create mode 100644 mlir/test/Target/LLVMIR/openmp-teams.mlir

diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 8f7f1963b3e5a4f..b9643be40e13c01 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -661,6 +661,24 @@ convertOmpSingle(omp::SingleOp &singleOp, 
llvm::IRBuilderBase &builder,
   return bodyGenStatus;
 }
 
+// Convert an OpenMP Teams construct to LLVM IR using OpenMPIRBuilder
+static LogicalResult convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase 
&builder, LLVM::ModuleTranslation &moduleTranslation) {
+  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+  LogicalResult bodyGenStatus = success();
+  if(op.getNumTeamsLower() || op.getNumTeamsUpper() || op.getIfExpr() || 
op.getThreadLimit() || !op.getAllocatorsVars().empty() || op.getReductions()) {
+return op.emitError("unhandled clauses for translation to LLVM IR");
+  }
+  auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codegenIP){
+LLVM::ModuleTranslation::SaveStack 
frame(moduleTranslation, allocaIP);
+builder.restoreIP(codegenIP);
+convertOmpOpRegions(op.getRegion(), "omp.teams.region", builder, 
moduleTranslation, bodyGenStatus);
+  };
+
+  llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
+  builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createTeams(ompLoc, 
bodyCB));
+  return bodyGenStatus;
+}
+
 /// Converts an OpenMP task construct into LLVM IR using OpenMPIRBuilder.
 static LogicalResult
 convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
@@ -2406,6 +2424,9 @@ LogicalResult 
OpenMPDialectLLVMIRTranslationInterface::convertOperation(
   .Case([&](omp::SingleOp op) {
 return convertOmpSingle(op, builder, moduleTranslation);
   })
+  .Case([&](omp::TeamsOp op) {
+return convertOmpTeams(op, builder, moduleTranslation);
+  })
   .Case([&](omp::TaskOp op) {
 return convertOmpTaskOp(op, builder, moduleTranslation);
   })
diff --git a/mlir/test/Target/LLVMIR/openmp-teams.mlir 
b/mlir/test/Target/LLVMIR/openmp-teams.mlir
new file mode 100644
index 000..c9005fca94a7c20
--- /dev/null
+++ b/mlir/test/Target/LLVMIR/openmp-teams.mlir
@@ -0,0 +1,136 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @foo()
+
+// CHECK-LABEL: @omp_teams_simple
+// CHECK: call void {{.*}} @__kmpc_fork_teams(ptr @{{.+}}, i32 0, ptr 
[[wrapperfn:.+]])
+// CHECK: ret void
+llvm.func @omp_teams_simple() {
+omp.teams {
+llvm.call @foo() : () -> ()
+omp.terminator
+}
+llvm.return
+}
+
+// CHECK: define internal void @[[outlinedfn:.+]]()
+// CHECK:   call void @foo()
+// CHECK:   ret void
+// CHECK: define void [[wrapperfn]](ptr %[[global_tid:.+]], ptr 
%[[bound_tid:.+]])
+// CHECK:   call void @[[outlinedfn]]
+// CHECK:   ret void
+
+// -
+
+llvm.func @foo(i32) -> ()
+
+// CHECK-LABEL: @omp_teams_shared_simple
+// CHECK-SAME: (i32 [[arg0:%.+]])
+// CHECK: [[structArg:%.+]] = alloca { i32 }
+// CHECK: br
+// CHECK: [[gep:%.+]] = getelementptr { i32 }, ptr [[structArg]], i32 0, i32 0
+// CHECK: store i32 [[arg0]], ptr [[gep]]
+// CHECK: call void {{.+}} @__kmpc_fork_teams(ptr @{{.+}}, i32 1, ptr 
[[wrapperfn:.+]], ptr [[structArg]])
+// CHECK: ret void
+llvm.func @omp_teams_shared_simple(%arg0: i32) {
+omp.teams {
+llvm.call @foo(%arg0) : (i32) -> ()
+omp.terminator
+}
+llvm.return
+}
+
+// CHECK: define internal void [[outlinedfn:@.+]](ptr [[structArg:%.+]])
+// CHECK:   [[gep:%.+]] = getelementptr { i32 }, ptr [[structArg]], i32 0, i32 0
+// CHECK:   [[loadgep:%.+]] = load i32, ptr [[gep]]
+// CHECK:   call void @foo(i32 [[loadgep]])
+// CHECK:   ret void
+// CHECK: define void [[wrapperfn]](ptr [[global_tid:.+]], ptr 
[[bound_tid:.+]], ptr [[structArg:.+]])
+// CHECK:   call void [[outlinedfn]](ptr [[structArg]])
+// CHECK:   ret void
+
+// -
+
+llvm.func @my_alloca_fn() -> !llvm.ptr
+llvm.func @foo(i32, f32, !llvm.ptr, f128, !llvm.ptr, i32) -> ()
+llvm.func @bar()
+
+// CHECK-LABEL: @omp_teams_branching_sha

[Lldb-commits] [lldb] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR (PR #68042)

2023-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-flang-openmp


Changes

This patch adds translation from `omp.teams` operation to LLVM IR using 
OpenMPIRBuilder. The clauses are not handled in this patch.

---
Full diff: https://github.com/llvm/llvm-project/pull/68042.diff


2 Files Affected:

- (modified) 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+21) 
- (added) mlir/test/Target/LLVMIR/openmp-teams.mlir (+136) 


``diff
diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 8f7f1963b3e5a4f..b9643be40e13c01 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -661,6 +661,24 @@ convertOmpSingle(omp::SingleOp &singleOp, 
llvm::IRBuilderBase &builder,
   return bodyGenStatus;
 }
 
+// Convert an OpenMP Teams construct to LLVM IR using OpenMPIRBuilder
+static LogicalResult convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase 
&builder, LLVM::ModuleTranslation &moduleTranslation) {
+  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+  LogicalResult bodyGenStatus = success();
+  if(op.getNumTeamsLower() || op.getNumTeamsUpper() || op.getIfExpr() || 
op.getThreadLimit() || !op.getAllocatorsVars().empty() || op.getReductions()) {
+return op.emitError("unhandled clauses for translation to LLVM IR");
+  }
+  auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codegenIP){
+LLVM::ModuleTranslation::SaveStack 
frame(moduleTranslation, allocaIP);
+builder.restoreIP(codegenIP);
+convertOmpOpRegions(op.getRegion(), "omp.teams.region", builder, 
moduleTranslation, bodyGenStatus);
+  };
+
+  llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
+  builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createTeams(ompLoc, 
bodyCB));
+  return bodyGenStatus;
+}
+
 /// Converts an OpenMP task construct into LLVM IR using OpenMPIRBuilder.
 static LogicalResult
 convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
@@ -2406,6 +2424,9 @@ LogicalResult 
OpenMPDialectLLVMIRTranslationInterface::convertOperation(
   .Case([&](omp::SingleOp op) {
 return convertOmpSingle(op, builder, moduleTranslation);
   })
+  .Case([&](omp::TeamsOp op) {
+return convertOmpTeams(op, builder, moduleTranslation);
+  })
   .Case([&](omp::TaskOp op) {
 return convertOmpTaskOp(op, builder, moduleTranslation);
   })
diff --git a/mlir/test/Target/LLVMIR/openmp-teams.mlir 
b/mlir/test/Target/LLVMIR/openmp-teams.mlir
new file mode 100644
index 000..c9005fca94a7c20
--- /dev/null
+++ b/mlir/test/Target/LLVMIR/openmp-teams.mlir
@@ -0,0 +1,136 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @foo()
+
+// CHECK-LABEL: @omp_teams_simple
+// CHECK: call void {{.*}} @__kmpc_fork_teams(ptr @{{.+}}, i32 0, ptr 
[[wrapperfn:.+]])
+// CHECK: ret void
+llvm.func @omp_teams_simple() {
+omp.teams {
+llvm.call @foo() : () -> ()
+omp.terminator
+}
+llvm.return
+}
+
+// CHECK: define internal void @[[outlinedfn:.+]]()
+// CHECK:   call void @foo()
+// CHECK:   ret void
+// CHECK: define void [[wrapperfn]](ptr %[[global_tid:.+]], ptr 
%[[bound_tid:.+]])
+// CHECK:   call void @[[outlinedfn]]
+// CHECK:   ret void
+
+// -
+
+llvm.func @foo(i32) -> ()
+
+// CHECK-LABEL: @omp_teams_shared_simple
+// CHECK-SAME: (i32 [[arg0:%.+]])
+// CHECK: [[structArg:%.+]] = alloca { i32 }
+// CHECK: br
+// CHECK: [[gep:%.+]] = getelementptr { i32 }, ptr [[structArg]], i32 0, i32 0
+// CHECK: store i32 [[arg0]], ptr [[gep]]
+// CHECK: call void {{.+}} @__kmpc_fork_teams(ptr @{{.+}}, i32 1, ptr 
[[wrapperfn:.+]], ptr [[structArg]])
+// CHECK: ret void
+llvm.func @omp_teams_shared_simple(%arg0: i32) {
+omp.teams {
+llvm.call @foo(%arg0) : (i32) -> ()
+omp.terminator
+}
+llvm.return
+}
+
+// CHECK: define internal void [[outlinedfn:@.+]](ptr [[structArg:%.+]])
+// CHECK:   [[gep:%.+]] = getelementptr { i32 }, ptr [[structArg]], i32 0, i32 0
+// CHECK:   [[loadgep:%.+]] = load i32, ptr [[gep]]
+// CHECK:   call void @foo(i32 [[loadgep]])
+// CHECK:   ret void
+// CHECK: define void [[wrapperfn]](ptr [[global_tid:.+]], ptr 
[[bound_tid:.+]], ptr [[structArg:.+]])
+// CHECK:   call void [[outlinedfn]](ptr [[structArg]])
+// CHECK:   ret void
+
+// -
+
+llvm.func @my_alloca_fn() -> !llvm.ptr
+llvm.func @foo(i32, f32, !llvm.ptr, f128, !llvm.ptr, i32) -> ()
+llvm.func @bar()
+
+// CHECK-LABEL: @omp_teams_branching_shared
+// CHECK-SAME: (i1 [[condition:%.+]], i32 [[arg0:%.+]], float [[arg1:%.+]], 
ptr [[arg2:%.+]], fp128 [[arg3:%.+]])
+
+// Checking that the allocation for struct argument happens in the alloca 
block.
+// CHECK: [[structArg:%.+]] = alloca { i1, i32, float, ptr, fp128, ptr, i32 }
+// CHECK: [[allocated:%.+]] = call ptr @my_alloca_fn()
+//

[Lldb-commits] [lldb] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR (PR #68042)

2023-10-02 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 457f582ffe23e951380bc345c4c96ec053c09681 
dc0304897ba3f8731bb6062f357fe885ca7e584b -- 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index b9643be40e13..9eefd1be8ad0 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -662,20 +662,27 @@ convertOmpSingle(omp::SingleOp &singleOp, 
llvm::IRBuilderBase &builder,
 }
 
 // Convert an OpenMP Teams construct to LLVM IR using OpenMPIRBuilder
-static LogicalResult convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase 
&builder, LLVM::ModuleTranslation &moduleTranslation) {
+static LogicalResult
+convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase &builder,
+LLVM::ModuleTranslation &moduleTranslation) {
   using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
   LogicalResult bodyGenStatus = success();
-  if(op.getNumTeamsLower() || op.getNumTeamsUpper() || op.getIfExpr() || 
op.getThreadLimit() || !op.getAllocatorsVars().empty() || op.getReductions()) {
+  if (op.getNumTeamsLower() || op.getNumTeamsUpper() || op.getIfExpr() ||
+  op.getThreadLimit() || !op.getAllocatorsVars().empty() ||
+  op.getReductions()) {
 return op.emitError("unhandled clauses for translation to LLVM IR");
   }
-  auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codegenIP){
-LLVM::ModuleTranslation::SaveStack 
frame(moduleTranslation, allocaIP);
+  auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codegenIP) {
+LLVM::ModuleTranslation::SaveStack frame(
+moduleTranslation, allocaIP);
 builder.restoreIP(codegenIP);
-convertOmpOpRegions(op.getRegion(), "omp.teams.region", builder, 
moduleTranslation, bodyGenStatus);
+convertOmpOpRegions(op.getRegion(), "omp.teams.region", builder,
+moduleTranslation, bodyGenStatus);
   };
 
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
-  builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createTeams(ompLoc, 
bodyCB));
+  builder.restoreIP(
+  moduleTranslation.getOpenMPBuilder()->createTeams(ompLoc, bodyCB));
   return bodyGenStatus;
 }
 

``




https://github.com/llvm/llvm-project/pull/68042
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-02 Thread Med Ismail Bennani via lldb-commits
=?utf-8?q?Jos=C3=A9?= L. Junior ,
=?utf-8?q?Jos=C3=A9?= L. Junior 
Message-ID:
In-Reply-To: 


medismailben wrote:

@clayborg what do you think ? Can we merge this ?

https://github.com/llvm/llvm-project/pull/67019
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-10-02 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,190 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range range) { std::ranges::contains(range, 
ValT{}); };
+
+static_assert(HasContainsR, int>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR, 
NotEqualityComparable>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+// clang-format off
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+{
+  ValueT a[] = {1, 2, 3, 4, 5, 6};
+  std::same_as auto ret =
+std::ranges::contains(Iter(a), Sent(Iter(a + 6)), 3);
+  assert(ret);
+}
+{
+  ValueT a[] = {1, 2, 3, 4, 5, 6};
+  auto range = std::ranges::subrange(Iter(a), Sent(Iter(a + 6)));
+  std::same_as decltype(auto) ret =
+std::ranges::contains(range, 3);
+  assert(ret);
+}
+  }
+
+  { // check that an empty range works
+{
+  ValueT a[] = {};
+  auto ret = std::ranges::contains(Iter(a), Sent(Iter(a)), 1);
+  assert(!ret);
+}
+{
+  ValueT a[] = {};
+  auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+  auto ret = std::ranges::contains(range, 1);
+  assert(!ret);
+}
+  }
+
+  { // check that no match
+{
+  ValueT a[] = {13, 1, 21, 4, 5};
+  auto ret = std::ranges::contains(Iter(a), Sent(Iter(a + 5)), 10);
+  assert(!ret);
+}
+{
+  ValueT a[] = {13, 1, 21, 4, 5};
+  auto range = std::ranges::subrange(Iter(a), Sent(Iter(a + 5)));
+  auto ret = std::ranges::contains(range, 10);
+  assert(!ret);
+}
+  }
+
+  if (!std::is_constant_evaluated())
+comparable_data.clear();
+}
+template 
+class TriviallyComparable {

var-const wrote:

Thanks for pointing me to the patch. It looks like this is to test an 
optimization that's specific to `find`. IMO we shouldn't duplicate those tests 
here, so I'd just remove the `Comparable` and `TriviallyComparable` tests. It 
might make sense to add a benchmark for `ranges::contains`, though.

https://github.com/llvm/llvm-project/pull/65148
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

LGTM with some comments.

https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben approved this pull request.


https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,72 @@
+"""
+Test lldb data formatter for LibStdC++ std::variant.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+
+
+class LibStdcxxVariantDataFormatterTestCase(TestBase):
+@add_test_categories(["libstdcxx"])
+def test_with_run_command(self):
+"""Test LibStdC++ std::variant data formatter works correctly."""
+self.build(dictionary={USE_LIBSTDCPP: "1"})
+
+(self.target, self.process, _, bkpt) = 
lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+lldbutil.continue_to_breakpoint(self.process, bkpt)
+self.assertEqual(3 + 4, 7)

medismailben wrote:

What's the point of this ?

https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,72 @@
+"""
+Test lldb data formatter for LibStdC++ std::variant.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+
+
+class LibStdcxxVariantDataFormatterTestCase(TestBase):
+@add_test_categories(["libstdcxx"])
+def test_with_run_command(self):
+"""Test LibStdC++ std::variant data formatter works correctly."""
+self.build(dictionary={USE_LIBSTDCPP: "1"})

medismailben wrote:

Do you need to specify this since you already set `USE_LIBSTDCPP` in the 
Makefile ?

https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben edited 
https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][FreeBSD] Add dynamic loader handle class for FreeBSD Kernel (PR #67106)

2023-10-02 Thread Ed Maste via lldb-commits

emaste wrote:

Hmm, when I attempt to close it via the GitHub UI I get:
![image](https://github.com/llvm/llvm-project/assets/1034582/54534c5d-9873-40c4-81af-45c50919dc92)

I think I can just fetch the commit locally and then push it to the tree

https://github.com/llvm/llvm-project/pull/67106
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/68050

Expose Platform::Attach through the SB API.

rdar://116188959

>From 6cf631f5acf3eb18e7cf12a2b996c9f974a360e2 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Sun, 1 Oct 2023 20:48:50 -0700
Subject: [PATCH] [lldb] Expose Platform::Attach through the SB API

Expose Platform::Attach through the SB API.

rdar://116188959
---
 lldb/include/lldb/API/SBAttachInfo.h  |  1 +
 lldb/include/lldb/API/SBDebugger.h|  1 +
 lldb/include/lldb/API/SBPlatform.h|  5 ++
 lldb/include/lldb/API/SBProcess.h |  1 +
 .../Python/lldbsuite/test/gdbclientutils.py   |  6 ++
 lldb/source/API/SBPlatform.cpp| 25 
 .../gdb_remote_client/TestPlatformAttach.py   | 58 +++
 7 files changed, 97 insertions(+)
 create mode 100644 
lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py

diff --git a/lldb/include/lldb/API/SBAttachInfo.h 
b/lldb/include/lldb/API/SBAttachInfo.h
index ea1145e625856f0..c18655fee77e0ac 100644
--- a/lldb/include/lldb/API/SBAttachInfo.h
+++ b/lldb/include/lldb/API/SBAttachInfo.h
@@ -197,6 +197,7 @@ class LLDB_API SBAttachInfo {
 
 protected:
   friend class SBTarget;
+  friend class SBPlatform;
 
   friend class lldb_private::ScriptInterpreter;
 
diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 29cf2c16fad4bd7..218113a7a391f35 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -487,6 +487,7 @@ class LLDB_API SBDebugger {
   friend class SBProcess;
   friend class SBSourceManager;
   friend class SBStructuredData;
+  friend class SBPlatform;
   friend class SBTarget;
   friend class SBTrace;
 
diff --git a/lldb/include/lldb/API/SBPlatform.h 
b/lldb/include/lldb/API/SBPlatform.h
index 6567277a5d161e7..614ee3202def5bc 100644
--- a/lldb/include/lldb/API/SBPlatform.h
+++ b/lldb/include/lldb/API/SBPlatform.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBPLATFORM_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBProcess.h"
 
 #include 
 
@@ -19,6 +20,7 @@ struct PlatformShellCommand;
 namespace lldb {
 
 class SBLaunchInfo;
+class SBAttachInfo;
 
 class LLDB_API SBPlatformConnectOptions {
 public:
@@ -149,6 +151,9 @@ class LLDB_API SBPlatform {
 
   SBError Launch(SBLaunchInfo &launch_info);
 
+  SBProcess Attach(SBAttachInfo &attach_info, const SBDebugger &debugger,
+   SBTarget &target, SBError &error);
+
   SBError Kill(const lldb::pid_t pid);
 
   SBError
diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 16527bb0291fcb4..8c1c81418f83d12 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -449,6 +449,7 @@ class LLDB_API SBProcess {
   friend class SBExecutionContext;
   friend class SBFunction;
   friend class SBModule;
+  friend class SBPlatform;
   friend class SBTarget;
   friend class SBThread;
   friend class SBValue;
diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py 
b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
index a0104d36df8d903..1784487323ad6be 100644
--- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
@@ -196,6 +196,9 @@ def respond(self, packet):
 return self.vFile(packet)
 if packet.startswith("vRun;"):
 return self.vRun(packet)
+if packet.startswith("qLaunchGDBServer;"):
+_, host = packet.partition(";")[2].split(":")
+return self.qLaunchGDBServer(host)
 if packet.startswith("qLaunchSuccess"):
 return self.qLaunchSuccess()
 if packet.startswith("QEnvironment:"):
@@ -329,6 +332,9 @@ def vFile(self, packet):
 def vRun(self, packet):
 return ""
 
+def qLaunchGDBServer(self, host):
+raise self.UnexpectedPacketException()
+
 def qLaunchSuccess(self):
 return ""
 
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index f8300a5bab30e41..7dfbb1373989c02 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -7,12 +7,14 @@
 
//===--===//
 
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBModuleSpec.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBTarget.h"
 #include "lldb/API/SBUnixSignals.h"
 #include "lldb/Host/File.h"
 #include "lldb/Target/Platform.h"
@@ -574,6 +576,29 @@ SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
   });
 }
 
+SBProcess SBPlatform::Attach(SBAttachInfo &attach_info,
+ const SBDebugger &debugger, SBTarget &target,
+ SBError &error) {
+  L

[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb


Changes

Expose Platform::Attach through the SB API.

rdar://116188959

---
Full diff: https://github.com/llvm/llvm-project/pull/68050.diff


7 Files Affected:

- (modified) lldb/include/lldb/API/SBAttachInfo.h (+1) 
- (modified) lldb/include/lldb/API/SBDebugger.h (+1) 
- (modified) lldb/include/lldb/API/SBPlatform.h (+5) 
- (modified) lldb/include/lldb/API/SBProcess.h (+1) 
- (modified) lldb/packages/Python/lldbsuite/test/gdbclientutils.py (+6) 
- (modified) lldb/source/API/SBPlatform.cpp (+25) 
- (added) lldb/test/API/functionalities/gdb_remote_client/TestPlatformAttach.py 
(+58) 


``diff
diff --git a/lldb/include/lldb/API/SBAttachInfo.h 
b/lldb/include/lldb/API/SBAttachInfo.h
index ea1145e625856f0..c18655fee77e0ac 100644
--- a/lldb/include/lldb/API/SBAttachInfo.h
+++ b/lldb/include/lldb/API/SBAttachInfo.h
@@ -197,6 +197,7 @@ class LLDB_API SBAttachInfo {
 
 protected:
   friend class SBTarget;
+  friend class SBPlatform;
 
   friend class lldb_private::ScriptInterpreter;
 
diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 29cf2c16fad4bd7..218113a7a391f35 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -487,6 +487,7 @@ class LLDB_API SBDebugger {
   friend class SBProcess;
   friend class SBSourceManager;
   friend class SBStructuredData;
+  friend class SBPlatform;
   friend class SBTarget;
   friend class SBTrace;
 
diff --git a/lldb/include/lldb/API/SBPlatform.h 
b/lldb/include/lldb/API/SBPlatform.h
index 6567277a5d161e7..614ee3202def5bc 100644
--- a/lldb/include/lldb/API/SBPlatform.h
+++ b/lldb/include/lldb/API/SBPlatform.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBPLATFORM_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBProcess.h"
 
 #include 
 
@@ -19,6 +20,7 @@ struct PlatformShellCommand;
 namespace lldb {
 
 class SBLaunchInfo;
+class SBAttachInfo;
 
 class LLDB_API SBPlatformConnectOptions {
 public:
@@ -149,6 +151,9 @@ class LLDB_API SBPlatform {
 
   SBError Launch(SBLaunchInfo &launch_info);
 
+  SBProcess Attach(SBAttachInfo &attach_info, const SBDebugger &debugger,
+   SBTarget &target, SBError &error);
+
   SBError Kill(const lldb::pid_t pid);
 
   SBError
diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 16527bb0291fcb4..8c1c81418f83d12 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -449,6 +449,7 @@ class LLDB_API SBProcess {
   friend class SBExecutionContext;
   friend class SBFunction;
   friend class SBModule;
+  friend class SBPlatform;
   friend class SBTarget;
   friend class SBThread;
   friend class SBValue;
diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py 
b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
index a0104d36df8d903..1784487323ad6be 100644
--- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
@@ -196,6 +196,9 @@ def respond(self, packet):
 return self.vFile(packet)
 if packet.startswith("vRun;"):
 return self.vRun(packet)
+if packet.startswith("qLaunchGDBServer;"):
+_, host = packet.partition(";")[2].split(":")
+return self.qLaunchGDBServer(host)
 if packet.startswith("qLaunchSuccess"):
 return self.qLaunchSuccess()
 if packet.startswith("QEnvironment:"):
@@ -329,6 +332,9 @@ def vFile(self, packet):
 def vRun(self, packet):
 return ""
 
+def qLaunchGDBServer(self, host):
+raise self.UnexpectedPacketException()
+
 def qLaunchSuccess(self):
 return ""
 
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index f8300a5bab30e41..7dfbb1373989c02 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -7,12 +7,14 @@
 
//===--===//
 
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBModuleSpec.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBTarget.h"
 #include "lldb/API/SBUnixSignals.h"
 #include "lldb/Host/File.h"
 #include "lldb/Target/Platform.h"
@@ -574,6 +576,29 @@ SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
   });
 }
 
+SBProcess SBPlatform::Attach(SBAttachInfo &attach_info,
+ const SBDebugger &debugger, SBTarget &target,
+ SBError &error) {
+  LLDB_INSTRUMENT_VA(this, attach_info);
+
+  if (PlatformSP platform_sp = GetSP()) {
+if (platform_sp->IsConnected()) {
+  ProcessAttachInfo &info = attach_info.ref();
+  Status status;
+  ProcessSP process_sp = platform_sp->Attach(info, debugger.ref(),
+  

[Lldb-commits] [lldb] [lldb] Unifying Scripted Affordance Interfaces (wip) (PR #68052)

2023-10-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben edited 
https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/test] Update TestProgressReporting.py (NFC) (PR #68053)

2023-10-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben created 
https://github.com/llvm/llvm-project/pull/68053

None

>From fddfbe53a9ab5c27da24b233cc449d0fe102a4b1 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 2 Oct 2023 16:54:45 -0700
Subject: [PATCH] [lldb/test] Update TestProgressReporting.py (NFC)

Signed-off-by: Med Ismail Bennani 
---
 .../functionalities/progress_reporting/TestProgressReporting.py  | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py 
b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
index 0e72770e350366d..42d6c6e206f701e 100644
--- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -11,6 +11,7 @@
 class TestProgressReporting(TestBase):
 def setUp(self):
 TestBase.setUp(self)
+
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
 self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress

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


[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread Alex Langford via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/68050
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread Alex Langford via lldb-commits


@@ -19,6 +20,7 @@ struct PlatformShellCommand;
 namespace lldb {
 
 class SBLaunchInfo;
+class SBAttachInfo;

bulbazord wrote:

sort

https://github.com/llvm/llvm-project/pull/68050
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread Alex Langford via lldb-commits


@@ -574,6 +576,29 @@ SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
   });
 }
 
+SBProcess SBPlatform::Attach(SBAttachInfo &attach_info,
+ const SBDebugger &debugger, SBTarget &target,
+ SBError &error) {
+  LLDB_INSTRUMENT_VA(this, attach_info);

bulbazord wrote:

This needs to instrument more things than just attach_info, right?

https://github.com/llvm/llvm-project/pull/68050
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread Alex Langford via lldb-commits


@@ -574,6 +576,29 @@ SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
   });
 }
 
+SBProcess SBPlatform::Attach(SBAttachInfo &attach_info,
+ const SBDebugger &debugger, SBTarget &target,

bulbazord wrote:

I'd like to see the `attach_info` parameter marked const if possible, but it 
looks like `SBAttachInfo::ref` is not const. Maybe we can add an overload?

I think that you can do `const SBTarget &target` without any further changes 
because `SBTarget::GetSP` is marked `const`.

https://github.com/llvm/llvm-project/pull/68050
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

Looks fine to me, but I want to really make sure we get this interface right. 
Left some comments inline.

https://github.com/llvm/llvm-project/pull/68050
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose Platform::Attach through the SB API (PR #68050)

2023-10-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/68050
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Unifying Scripted Affordance Interfaces (wip) (PR #68052)

2023-10-02 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 824b1677a44e25b7c9808c774ba2d894ff14df2b 
3ef039a731e09ec3767e71714fc273084c5773a8 -- 
lldb/include/lldb/Interpreter/Interfaces/OperatingSystemInterface.h 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.cpp
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h
 lldb/include/lldb/Interpreter/ScriptInterpreter.h 
lldb/include/lldb/Target/ThreadPlanPython.h lldb/include/lldb/lldb-forward.h 
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp 
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h 
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h 
lldb/source/Target/ThreadPlanPython.cpp 
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 31b1087fe930..3202eae9d195 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -25,10 +25,10 @@ public:
   ScriptedInterface() = default;
   virtual ~ScriptedInterface() = default;
 
-  template 
+  template 
   StructuredData::GenericSP
   CreatePluginObject(llvm::StringRef class_name,
- StructuredData::Generic *script_obj, Args && ...args) {
+ StructuredData::Generic *script_obj, Args &&...args) {
 llvm_unreachable("Not implemented.");
   }
 
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index cf7ba42af77d..28cf1f104fb2 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -19,7 +19,7 @@
 namespace lldb_private {
 class ScriptedPlatformInterface : virtual public ScriptedInterface {
 public:
-  template 
+  template 
   StructuredData::GenericSP
   CreatePluginObject(llvm::StringRef class_name,
  StructuredData::Generic *script_obj, Args &&...args) {
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index 9aec14c92f2c..54350914f5da 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -21,7 +21,7 @@
 namespace lldb_private {
 class ScriptedProcessInterface : virtual public ScriptedInterface {
 public:
-  template 
+  template 
   StructuredData::GenericSP
   CreatePluginObject(llvm::StringRef class_name,
  StructuredData::Generic *script_obj, Args &&...args) {
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
index 9c6e46cb7f59..48b81d86b306 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
@@ -20,7 +20,7 @@
 namespace lldb_private {
 class ScriptedThreadInterface : virtual public ScriptedInterface {
 public:
-  template 
+  template 
   StructuredData::GenericSP
   CreatePluginObject(llvm::StringRef class_name,
  StructuredData::Generic *script_obj, Args &&...args) {
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterf

[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits


@@ -0,0 +1,72 @@
+"""
+Test lldb data formatter for LibStdC++ std::variant.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+
+
+class LibStdcxxVariantDataFormatterTestCase(TestBase):
+@add_test_categories(["libstdcxx"])
+def test_with_run_command(self):
+"""Test LibStdC++ std::variant data formatter works correctly."""
+self.build(dictionary={USE_LIBSTDCPP: "1"})
+
+(self.target, self.process, _, bkpt) = 
lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+lldbutil.continue_to_breakpoint(self.process, bkpt)
+self.assertEqual(3 + 4, 7)

jeffreytan81 wrote:

lol, this is an old diff that I drafted several months ago so totally forgot 
why I added this in the first place :-)

https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits


@@ -0,0 +1,72 @@
+"""
+Test lldb data formatter for LibStdC++ std::variant.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+
+
+class LibStdcxxVariantDataFormatterTestCase(TestBase):
+@add_test_categories(["libstdcxx"])
+def test_with_run_command(self):
+"""Test LibStdC++ std::variant data formatter works correctly."""
+self.build(dictionary={USE_LIBSTDCPP: "1"})

jeffreytan81 wrote:

Good point. Will remove. 

https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/68012

>From e7e47a211ebaaa0f6380810b6573fadde12ca02d Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 2 Oct 2023 10:53:17 -0700
Subject: [PATCH 1/4] Implement data formatters for LibStdC++ std::variant

---
 lldb/examples/synthetic/gnu_libstdcpp.py  | 89 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 18 +++-
 .../libstdcpp/variant/Makefile|  5 ++
 .../TestDataFormatterLibStdcxxVariant.py  | 72 +++
 .../libstdcpp/variant/main.cpp| 79 
 5 files changed, 259 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp

diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 825b7f3787a010d..7462db744674682 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -892,3 +892,92 @@ def update(self):
 except:
 pass
 return False
+
+
+def VariantSummaryProvider(valobj, dict):
+raw_obj = valobj.GetNonSyntheticValue()
+index_obj = raw_obj.GetChildMemberWithName("_M_index")
+data_obj = raw_obj.GetChildMemberWithName("_M_u")
+if not (
+index_obj
+and index_obj.IsValid()
+and data_obj
+and data_obj.IsValid()
+):
+return ""
+
+def get_variant_npos_value(index_byte_size):
+if index_byte_size == 1:
+return 0xFF
+elif index_byte_size == 2:
+return 0x
+else:
+return 0x
+
+npos_value = get_variant_npos_value(index_obj.GetByteSize())
+index = index_obj.GetValueAsUnsigned(0)
+if index == npos_value:
+return " No Value"
+
+active_type = data_obj.GetType().GetTemplateArgumentType(index)
+return f" Active Type = {active_type.GetDisplayTypeName()} "
+
+
+class VariantSynthProvider:
+def __init__(self, valobj, dict):
+self.raw_obj = valobj.GetNonSyntheticValue()
+self.is_valid = False
+self.index = None
+self.data_obj = None
+
+def update(self):
+try:
+self.index = self.raw_obj.GetChildMemberWithName(
+"_M_index"
+).GetValueAsSigned(-1)
+self.is_valid = self.index != -1
+self.data_obj = self.raw_obj.GetChildMemberWithName("_M_u")
+except:
+self.is_valid = False
+return False
+
+def has_children(self):
+return True
+
+def num_children(self):
+return 1 if self.is_valid else 0
+
+def get_child_index(self, name):
+return 0
+
+def get_child_at_index(self, index):
+if not self.is_valid:
+return None
+cur = 0
+node = self.data_obj
+while cur < self.index:
+node = node.GetChildMemberWithName("_M_rest")
+cur += 1
+
+# _M_storage's type depends on variant field's type "_Type".
+#  1. if '_Type' is literal type: _Type _M_storage.
+#  2. otherwise, __gnu_cxx::__aligned_membuf<_Type> _M_storage.
+#
+# For 2. we have to cast it to underlying template _Type.
+
+value = node.GetChildMemberWithName("_M_first").GetChildMemberWithName(
+"_M_storage"
+)
+template_type = value.GetType().GetTemplateArgumentType(0)
+
+# Literal type will return None for GetTemplateArgumentType(0)
+if (
+template_type
+and "__gnu_cxx::__aligned_membuf" in 
value.GetType().GetDisplayTypeName()
+and template_type.IsValid()
+):
+value = value.Cast(template_type)
+
+if value.IsValid():
+return value.Clone("Value")
+return None
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index c1743a5e0a418dd..d8a30729b6d02e1 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -332,11 +332,11 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
   // If we can't parse the incoming name, then just check that it contains 
path.
   if (m_parse_error)
 return m_full.GetStringRef().contains(path);
-
+
   llvm::StringRef identifier;
   llvm::StringRef context;
   std::string path_str = path.str();
-  bool success 
+  bool success
   = CPlusPlusLanguage::ExtractContextAndIdentifier(path_str.c_str(),
context,

[Lldb-commits] [lldb] 1ec4330 - Implement data formatters for LibStdC++ std::variant (#68012)

2023-10-02 Thread via lldb-commits

Author: jeffreytan81
Date: 2023-10-02T17:46:41-07:00
New Revision: 1ec4330f7e4d9b1ed1880c957e9e897f4eaf204f

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

LOG: Implement data formatters for LibStdC++ std::variant (#68012)

This patch implements the data formatters for LibStdC++ `std::variant`.

-

Co-authored-by: jeffreytan81 

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp

Modified: 
lldb/examples/synthetic/gnu_libstdcpp.py
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 




diff  --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 825b7f3787a010d..29c926167fb440c 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -892,3 +892,87 @@ def update(self):
 except:
 pass
 return False
+
+
+def VariantSummaryProvider(valobj, dict):
+raw_obj = valobj.GetNonSyntheticValue()
+index_obj = raw_obj.GetChildMemberWithName("_M_index")
+data_obj = raw_obj.GetChildMemberWithName("_M_u")
+if not (index_obj and index_obj.IsValid() and data_obj and 
data_obj.IsValid()):
+return ""
+
+def get_variant_npos_value(index_byte_size):
+if index_byte_size == 1:
+return 0xFF
+elif index_byte_size == 2:
+return 0x
+else:
+return 0x
+
+npos_value = get_variant_npos_value(index_obj.GetByteSize())
+index = index_obj.GetValueAsUnsigned(0)
+if index == npos_value:
+return " No Value"
+
+active_type = data_obj.GetType().GetTemplateArgumentType(index)
+return f" Active Type = {active_type.GetDisplayTypeName()} "
+
+
+class VariantSynthProvider:
+def __init__(self, valobj, dict):
+self.raw_obj = valobj.GetNonSyntheticValue()
+self.is_valid = False
+self.index = None
+self.data_obj = None
+
+def update(self):
+try:
+self.index = self.raw_obj.GetChildMemberWithName(
+"_M_index"
+).GetValueAsSigned(-1)
+self.is_valid = self.index != -1
+self.data_obj = self.raw_obj.GetChildMemberWithName("_M_u")
+except:
+self.is_valid = False
+return False
+
+def has_children(self):
+return True
+
+def num_children(self):
+return 1 if self.is_valid else 0
+
+def get_child_index(self, name):
+return 0
+
+def get_child_at_index(self, index):
+if not self.is_valid:
+return None
+cur = 0
+node = self.data_obj
+while cur < self.index:
+node = node.GetChildMemberWithName("_M_rest")
+cur += 1
+
+# _M_storage's type depends on variant field's type "_Type".
+#  1. if '_Type' is literal type: _Type _M_storage.
+#  2. otherwise, __gnu_cxx::__aligned_membuf<_Type> _M_storage.
+#
+# For 2. we have to cast it to underlying template _Type.
+
+value = node.GetChildMemberWithName("_M_first").GetChildMemberWithName(
+"_M_storage"
+)
+template_type = value.GetType().GetTemplateArgumentType(0)
+
+# Literal type will return None for GetTemplateArgumentType(0)
+if (
+template_type
+and "__gnu_cxx::__aligned_membuf" in 
value.GetType().GetDisplayTypeName()
+and template_type.IsValid()
+):
+value = value.Cast(template_type)
+
+if value.IsValid():
+return value.Clone("Value")
+return None

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index c1743a5e0a418dd..ad6d627938c0520 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -332,14 +332,12 @@ bool 
CPlusPlusLanguage::MethodName::ContainsPath(llvm::StringRef path) {
   // If we can't parse the incoming name, then just check that it contains 
path.
   if (m_parse_error)
 return m_full.GetStringRef().contains(path);
-
+
   llvm::StringRef identifier;
   llvm::StringRef context;
   std::string path_str = path.str();
-  bool success 
-  = CPlusPlusLanguage::ExtractContextAndIdentifier(path_str.c_str(),
-   context,
-   identifier);
+  bool succ

[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread via lldb-commits

https://github.com/jeffreytan81 closed 
https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/test] Update TestProgressReporting.py (NFC) (PR #68053)

2023-10-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben closed 
https://github.com/llvm/llvm-project/pull/68053
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Implement data formatters for LibStdC++ std::variant (PR #68012)

2023-10-02 Thread antoine moynault via lldb-commits

antmox wrote:

Hello,
It looks like this broke 2 bots:
lldb-aarch64-ubuntu : https://lab.llvm.org/buildbot/#/builders/96/builds/46436
lldb-arm-ubuntu : https://lab.llvm.org/buildbot/#/builders/17/builds/44011
Could you please take a look ?

https://github.com/llvm/llvm-project/pull/68012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits