[Lldb-commits] [PATCH] D142862: [Support] change StringMap hash function from djbHash to xxHash

2023-02-01 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

https://llvm-compile-time-tracker.com/compare.php?from=1a17739d3aa78599c32f6106e05dcfa7f3f9e823&to=9c1adc5fcca177d6628bdb22c72e7546c7b691aa&stat=instructions:u

looks good to me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142862

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


[Lldb-commits] [PATCH] D142862: [Support] change StringMap hash function from djbHash to xxHash

2023-02-01 Thread Erik Desjardins via Phabricator via lldb-commits
erikdesjardins added a comment.

In D142862#4089860 , 
@serge-sans-paille wrote:

> Can  you take a shot against https://llvm-compile-time-tracker.com/ so that 
> we get an hint of the practical speedup?

I ran rustc perf tests using a patched LLVM in 
https://github.com/rust-lang/rust/pull/107552#issuecomment-1411927687,
you can see the results here: 
https://perf.rust-lang.org/compare.html?start=ad8e1dc2863f63c35ef3ceef3064d0851a1d2582&end=8aaf54b663467dc48ff24d764aa9f73c61db2733&stat=instructions:u
Improvements from 0.2%-2% on various benchmarks, no regressions.

@serge-sans-paille it looks like you have access to llvm-compile-time-tracker, 
can you push this patch up so we can see those perf tests too?
Probable oneliner: `git remote add erikdesjardins 
https://github.com/erikdesjardins/llvm-project.git && git fetch erikdesjardins 
&& git push origin erikdesjardins/xxhash-perf:refs/heads/perf/xxhash`

> Do you intend to (optionnaly) provide XXH3 as described in 
> https://github.com/Cyan4973/xxHash ?

The current version of xxhash in tree is stripped down to just xxhash64. I 
don't intend to change that as part of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142862

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


[Lldb-commits] [PATCH] D142862: [Support] change StringMap hash function from djbHash to xxHash

2023-02-01 Thread Erik Desjardins via Phabricator via lldb-commits
erikdesjardins updated this revision to Diff 494155.
erikdesjardins added a comment.

rebase over landed D142861 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142862

Files:
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
  clang-tools-extra/test/modularize/ProblemsInconsistent.modularize
  clang/unittests/Basic/SarifTest.cpp
  compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  llvm/lib/Support/StringMap.cpp
  llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
  llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
  llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
  llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
  llvm/test/DebugInfo/X86/gnu-public-names.ll
  llvm/test/ObjectYAML/Offload/binary.yaml
  llvm/test/ObjectYAML/Offload/multiple_members.yaml
  llvm/test/tools/dsymutil/ARM/extern-alias.test
  llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
  mlir/test/Transforms/print-op-graph.mlir
  mlir/test/mlir-lsp-server/completion.test

Index: mlir/test/mlir-lsp-server/completion.test
===
--- mlir/test/mlir-lsp-server/completion.test
+++ mlir/test/mlir-lsp-server/completion.test
@@ -84,18 +84,18 @@
 // CHECK-NEXT:"isIncomplete": false,
 // CHECK-NEXT:"items": [
 // CHECK-NEXT:  {
-// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
-// CHECK-NEXT:"insertText": "cast",
-// CHECK-NEXT:"insertTextFormat": 1,
-// CHECK-NEXT:"kind": 6,
-// CHECK-NEXT:"label": "%cast"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  {
 // CHECK-NEXT:"detail": "arg #0: i32",
 // CHECK-NEXT:"insertText": "arg",
 // CHECK-NEXT:"insertTextFormat": 1,
 // CHECK-NEXT:"kind": 6,
 // CHECK-NEXT:"label": "%arg"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
+// CHECK-NEXT:"insertText": "cast",
+// CHECK-NEXT:"insertTextFormat": 1,
+// CHECK-NEXT:"kind": 6,
+// CHECK-NEXT:"label": "%cast"
 // CHECK-NEXT:  }
 // CHECK: ]
 // CHECK-NEXT:  }
Index: mlir/test/Transforms/print-op-graph.mlir
===
--- mlir/test/Transforms/print-op-graph.mlir
+++ mlir/test/Transforms/print-op-graph.mlir
@@ -6,49 +6,49 @@
 //   DFG: subgraph {{.*}}
 //   DFG:   label = "func.func{{.*}}merge_blocks
 //   DFG:   subgraph {{.*}} {
-//   DFG: v[[ARG0:.*]] [label = "arg0"
-//   DFG: v[[CONST10:.*]] [label ={{.*}}10 : i32
+//   DFG: v[[ARG0:.*]] [shape = ellipse, label = "arg0"
+//   DFG: v[[CONST10:.*]] [shape = ellipse, label ={{.*}}10 : i32
 //   DFG: subgraph [[CLUSTER_MERGE_BLOCKS:.*]] {
-//   DFG:   v[[ANCHOR:.*]] [label = " ", shape = plain]
+//   DFG:   v[[ANCHOR:.*]] [shape = plain, label = " "]
 //   DFG:   label = "test.merge_blocks
 //   DFG:   subgraph {{.*}} {
-//   DFG: v[[TEST_BR:.*]] [label = "test.br
+//   DFG: v[[TEST_BR:.*]] [shape = ellipse, label = "test.br
 //   DFG:   }
 //   DFG:   subgraph {{.*}} {
 //   DFG:   }
 //   DFG: }
-//   DFG: v[[TEST_RET:.*]] [label = "test.return
+//   DFG: v[[TEST_RET:.*]] [shape = ellipse, label = "test.return
 //   DFG:   v[[ARG0]] -> v[[TEST_BR]]
 //   DFG:   v[[CONST10]] -> v[[TEST_BR]]
-//   DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [{{.*}}, ltail = [[CLUSTER_MERGE_BLOCKS]]]
-//   DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [{{.*}}, ltail = [[CLUSTER_MERGE_BLOCKS]]]
+//   DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], {{.*}}]
+//   DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], {{.*}}]
 
 // CFG-LABEL: digraph G {
 //   CFG:   subgraph {{.*}} {
 //   CFG: subgraph {{.*}}
 //   CFG:   label = "func.func{{.*}}merge_blocks
 //   CFG:   subgraph {{.*}} {
-//   CFG: v[[C1:.*]] [label = "arith.constant
-//   CFG: v[[C2:.*]] [label = "arith.constant
-//   CFG: v[[C3:.*]] [label = "arith.constant
-//   CFG: v[[C4:.*]] [label = "arith.constant
-//   CFG: v[[TEST_FUNC:.*]] [label = "test.func
+//   CFG: v[[C1:.*]] [shape = ellipse, label = "arith.constant
+//   CFG: v[[C2:.*]] [shape = ellipse, label = "arith.constant
+//   CFG: v[[C3:.*]] [shape = ellipse, label = "arith.constant
+//   CFG: v[[C4:.*]] [shape = ellipse, 

[Lldb-commits] [PATCH] D143127: [LLDB] Fix assertion failure by removing `CopyType` in `std::coroutine_handle` pretty printer

2023-02-01 Thread Adrian Vogelsgesang via Phabricator via lldb-commits
avogelsgesang created this revision.
avogelsgesang added reviewers: labath, aprantl.
Herald added a subscriber: ChuanqiXu.
Herald added a project: All.
avogelsgesang requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The pretty printer for `std::coroutine_handle` was running into

> Assertion failed: (target_ctx != source_ctx && "Can't import into itself")

from ClangASTImporter.h, line 270.

This commit fixes the issue by removing the `CopyType` call from the
pretty printer. While this call was necessary in the past, it seems to
be no longer required, at least all test cases are still passing. Maybe
something changed in the meantime around the handling of `TypesystemClang`
instances. I don't quite understand why `CopyType` was necessary earlier.

I am not sure how to add a regression test for this, though. It seems
the issue is already triggered by the exising `TestCoroutineHandle.py`,
but API tests seem to ignore all violations of `lldbassert` and still
report the test as "passed", even if assertions were triggered


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143127

Files:
  lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
  lldb/source/Plugins/Language/CPlusPlus/Coroutines.h


Index: lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
===
--- lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
+++ lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
@@ -16,8 +16,6 @@
 
 namespace lldb_private {
 
-class ClangASTImporter;
-
 namespace formatters {
 
 /// Summary provider for `std::coroutine_handle` from  libc++, libstdc++ and
@@ -50,7 +48,6 @@
   lldb::ValueObjectSP m_resume_ptr_sp;
   lldb::ValueObjectSP m_destroy_ptr_sp;
   lldb::ValueObjectSP m_promise_ptr_sp;
-  std::unique_ptr m_ast_importer;
 };
 
 SyntheticChildrenFrontEnd *
Index: lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -8,7 +8,6 @@
 
 #include "Coroutines.h"
 
-#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
@@ -97,8 +96,7 @@
 
 lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
 StdlibCoroutineHandleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
-: SyntheticChildrenFrontEnd(*valobj_sp),
-  m_ast_importer(std::make_unique()) {
+: SyntheticChildrenFrontEnd(*valobj_sp) {
   if (valobj_sp)
 Update();
 }
@@ -174,8 +172,7 @@
 if (Function *destroy_func =
 ExtractDestroyFunction(target_sp, frame_ptr_addr)) {
   if (CompilerType inferred_type = InferPromiseType(*destroy_func)) {
-// Copy the type over to the correct `TypeSystemClang` instance
-promise_type = m_ast_importer->CopyType(*ast_ctx, inferred_type);
+promise_type = inferred_type;
   }
 }
   }


Index: lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
===
--- lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
+++ lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
@@ -16,8 +16,6 @@
 
 namespace lldb_private {
 
-class ClangASTImporter;
-
 namespace formatters {
 
 /// Summary provider for `std::coroutine_handle` from  libc++, libstdc++ and
@@ -50,7 +48,6 @@
   lldb::ValueObjectSP m_resume_ptr_sp;
   lldb::ValueObjectSP m_destroy_ptr_sp;
   lldb::ValueObjectSP m_promise_ptr_sp;
-  std::unique_ptr m_ast_importer;
 };
 
 SyntheticChildrenFrontEnd *
Index: lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -8,7 +8,6 @@
 
 #include "Coroutines.h"
 
-#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
@@ -97,8 +96,7 @@
 
 lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
 StdlibCoroutineHandleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
-: SyntheticChildrenFrontEnd(*valobj_sp),
-  m_ast_importer(std::make_unique()) {
+: SyntheticChildrenFrontEnd(*valobj_sp) {
   if (valobj_sp)
 Update();
 }
@@ -174,8 +172,7 @@
 if (Function *destroy_func =
 ExtractDestroyFunction(target_sp, frame_ptr_addr)) {
   if (CompilerType inferred_type = InferPromiseType(*destroy_func)) {
-// Copy the type over to the correct `TypeSystemClang` instance
-promise_type = m_ast_importer->CopyType(*ast_ctx, inferred_type);
+promise_type = inferred_type;
   }
 }
   }
__

[Lldb-commits] [PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-02-01 Thread Junchang Liu via Phabricator via lldb-commits
paperchalice added a comment.

In D141907#4094748 , @MaskRay wrote:

> The CMake part of this patch improves the matter. Manually constructed 
> resource dir (many duplicates) string is replace with a library function call.
>
> However, the introduced conditions in C++ code like
>
>   std::string path_to_clang_dir = std::string(CLANG_RESOURCE_DIR).empty()
>   ? "/foo/bar/" 
> LLDB_INSTALL_LIBDIR_BASENAME
> "/clang/" CLANG_VERSION_MAJOR_STRING
>   : "/foo/bar/bin/" CLANG_RESOURCE_DIR;
>
> makes me uncomfortable.
>
> I wish that we can just replace all manually constructed 
> `CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING` with a 
> simple `CLANG_RESOURCE_DIR` which is guaranteed to be non-empty.
>
> edeaf16f2c2f02d6e43312d48d26d354d87913f3 (2011) added the CMake variable 
> `CLANG_RESOURCE_DIR` but did not explain why. 
> In the long term, the CMake variable `CLANG_RESOURCE_DIR` probably should be 
> removed.

clang::driver::Driver::GetResourcesPath 

 would be a better choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

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


[Lldb-commits] [lldb] 4adabb8 - Fix typo: FineLineEntriesForFileIndex -> FindLineEntriesForFileIndex.

2023-02-01 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2023-02-01T16:41:17-08:00
New Revision: 4adabb8786b87e9f105e37d5606e1c0187abc647

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

LOG: Fix typo: FineLineEntriesForFileIndex -> FindLineEntriesForFileIndex.

Added: 


Modified: 
lldb/include/lldb/Symbol/LineTable.h
lldb/source/Core/FileLineResolver.cpp
lldb/source/Symbol/LineTable.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/LineTable.h 
b/lldb/include/lldb/Symbol/LineTable.h
index 7fca44b5930b7..6d158ab518879 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -161,7 +161,7 @@ class LineTable {
   uint32_t start_idx, const std::vector &file_idx,
   const SourceLocationSpec &src_location_spec, LineEntry *line_entry_ptr);
 
-  size_t FineLineEntriesForFileIndex(uint32_t file_idx, bool append,
+  size_t FindLineEntriesForFileIndex(uint32_t file_idx, bool append,
  SymbolContextList &sc_list);
 
   /// Get the line entry from the line table at index \a idx.

diff  --git a/lldb/source/Core/FileLineResolver.cpp 
b/lldb/source/Core/FileLineResolver.cpp
index 2cf7007165bc6..612614a41bb0e 100644
--- a/lldb/source/Core/FileLineResolver.cpp
+++ b/lldb/source/Core/FileLineResolver.cpp
@@ -48,7 +48,7 @@ FileLineResolver::SearchCallback(SearchFilter &filter, 
SymbolContext &context,
   // Match all lines in a file...
   const bool append = true;
   while (file_idx != UINT32_MAX) {
-line_table->FineLineEntriesForFileIndex(file_idx, append,
+line_table->FindLineEntriesForFileIndex(file_idx, append,
 m_sc_list);
 // Get the next file index in case we have multiple file entries
 // for the same file

diff  --git a/lldb/source/Symbol/LineTable.cpp 
b/lldb/source/Symbol/LineTable.cpp
index cd8d520ada781..59b5d6125e04e 100644
--- a/lldb/source/Symbol/LineTable.cpp
+++ b/lldb/source/Symbol/LineTable.cpp
@@ -325,7 +325,7 @@ uint32_t LineTable::FindLineEntryIndexByFileIndex(
   start_idx, file_idx, src_location_spec, line_entry_ptr, 
file_idx_matcher);
 }
 
-size_t LineTable::FineLineEntriesForFileIndex(uint32_t file_idx, bool append,
+size_t LineTable::FindLineEntriesForFileIndex(uint32_t file_idx, bool append,
   SymbolContextList &sc_list) {
 
   if (!append)



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


[Lldb-commits] [PATCH] D143122: [lldb/python] Fix scripted_platform python module creation

2023-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added a reviewer: bulbazord.
mib added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch should fix the creation and addition of the `scripted_platform`
python module into the `lldb.plugins` module.

Previously, we were creating the `plugins` submodule, each time with a
different source file (either `scripted_process` or `scripted_platform`).

The removes the redundant `create_python_package` call and group both
python source files toghether.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143122

Files:
  lldb/bindings/python/CMakeLists.txt


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -103,13 +103,7 @@
 ${lldb_python_target_dir}
 "plugins"
 FILES
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py")
-
-  create_python_package(
-${swig_target}
-${lldb_python_target_dir}
-"plugins"
-FILES
+"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py"
 "${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_platform.py")
 
   if(APPLE)


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -103,13 +103,7 @@
 ${lldb_python_target_dir}
 "plugins"
 FILES
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py")
-
-  create_python_package(
-${swig_target}
-${lldb_python_target_dir}
-"plugins"
-FILES
+"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py"
 "${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_platform.py")
 
   if(APPLE)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D139945: [lldb] Add scripted process launch/attach option to platform commands

2023-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 494110.
mib added a comment.

Rebase


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

https://reviews.llvm.org/D139945

Files:
  lldb/bindings/interface/SBAttachInfo.i
  lldb/include/lldb/API/SBAttachInfo.h
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Target/Process.h
  lldb/source/API/SBAttachInfo.cpp
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandOptionsProcessAttach.cpp
  lldb/source/Commands/CommandOptionsProcessAttach.h

Index: lldb/source/Commands/CommandOptionsProcessAttach.h
===
--- /dev/null
+++ lldb/source/Commands/CommandOptionsProcessAttach.h
@@ -0,0 +1,47 @@
+//===-- CommandOptionsProcessAttach.h ---*- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOPTIONSPROCESSATTACH_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOPTIONSPROCESSATTACH_H
+
+#include "lldb/Interpreter/Options.h"
+#include "lldb/Target/Process.h"
+
+namespace lldb_private {
+
+// CommandOptionsProcessAttach
+
+class CommandOptionsProcessAttach : public lldb_private::OptionGroup {
+public:
+  CommandOptionsProcessAttach() {
+// Keep default values of all options in one place: OptionParsingStarting
+// ()
+OptionParsingStarting(nullptr);
+  }
+
+  ~CommandOptionsProcessAttach() override = default;
+
+  lldb_private::Status
+  SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ lldb_private::ExecutionContext *execution_context) override;
+
+  void OptionParsingStarting(
+  lldb_private::ExecutionContext *execution_context) override {
+attach_info.Clear();
+  }
+
+  llvm::ArrayRef GetDefinitions() override;
+
+  // Instance variables to hold the values for command options.
+
+  lldb_private::ProcessAttachInfo attach_info;
+}; // CommandOptionsProcessAttach
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOPTIONSPROCESSATTACH_H
Index: lldb/source/Commands/CommandOptionsProcessAttach.cpp
===
--- /dev/null
+++ lldb/source/Commands/CommandOptionsProcessAttach.cpp
@@ -0,0 +1,76 @@
+//===-- CommandOptionsProcessAttach.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 "CommandOptionsProcessAttach.h"
+
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandCompletions.h"
+#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandOptionArgumentTable.h"
+#include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Target/Target.h"
+
+#include "llvm/ADT/ArrayRef.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+
+#define LLDB_OPTIONS_process_attach
+#include "CommandOptions.inc"
+
+Status CommandOptionsProcessAttach::SetOptionValue(
+uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) {
+  Status error;
+  const int short_option = g_process_attach_options[option_idx].short_option;
+  switch (short_option) {
+  case 'c':
+attach_info.SetContinueOnceAttached(true);
+break;
+
+  case 'p': {
+lldb::pid_t pid;
+if (option_arg.getAsInteger(0, pid)) {
+  error.SetErrorStringWithFormat("invalid process ID '%s'",
+ option_arg.str().c_str());
+} else {
+  attach_info.SetProcessID(pid);
+}
+  } break;
+
+  case 'P':
+attach_info.SetProcessPluginName(option_arg);
+break;
+
+  case 'n':
+attach_info.GetExecutableFile().SetFile(option_arg,
+FileSpec::Style::native);
+break;
+
+  case 'w':
+attach_info.SetWaitForLaunch(true);
+break;
+
+  case 'i':
+attach_info.SetIgnoreExisting(false);
+break;
+
+  default:
+llvm_unreachable("Unimplemented option");
+  }
+  return error;
+}
+
+llvm::ArrayRef CommandOptionsProcessAttach::GetDefinitions() {
+  return llvm::makeArrayRef(g_process_attach_options);
+}
Index: lldb/source/Commands/CommandObjectProcess.cpp
===
--- lldb/source/Commands/CommandObjectProcess.cpp
+++ 

[Lldb-commits] [PATCH] D139252: [lldb/Plugins] Introduce Scripted Platform Plugin

2023-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 494107.
mib added a comment.

Small fixes


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

https://reviews.llvm.org/D139252

Files:
  lldb/bindings/python/python-swigsafecast.swig
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_process/scripted_platform.py
  lldb/include/lldb/API/SBAttachInfo.h
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBLaunchInfo.h
  lldb/include/lldb/API/SBProcess.h
  lldb/include/lldb/API/SBTarget.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/Platform/CMakeLists.txt
  lldb/source/Plugins/Platform/scripted/CMakeLists.txt
  lldb/source/Plugins/Platform/scripted/ScriptedPlatform.cpp
  lldb/source/Plugins/Platform/scripted/ScriptedPlatform.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.h
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
  lldb/test/API/functionalities/scripted_platform/my_scripted_platform.py
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -139,6 +139,26 @@
   return nullptr;
 }
 
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBProcess(PyObject *data) {
+  return nullptr;
+}
+
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBDebugger(PyObject *data) {
+  return nullptr;
+}
+
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBTarget(PyObject *data) {
+  return nullptr;
+}
+
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject *data) {
+  return nullptr;
+}
+
+void *lldb_private::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject *data) {
+  return nullptr;
+}
+
 void *lldb_private::LLDBSWIGPython_CastPyObjectToSBError(PyObject *data) {
   return nullptr;
 }
Index: lldb/test/API/functionalities/scripted_platform/my_scripted_platform.py
===
--- lldb/test/API/functionalities/scripted_platform/my_scripted_platform.py
+++ lldb/test/API/functionalities/scripted_platform/my_scripted_platform.py
@@ -23,6 +23,9 @@
 def get_process_info(self, pid):
 return self.processes[pid]
 
+def attach_to_process(self, attach_info, target, debugger, error):
+return None
+
 def launch_process(self, launch_info):
 return lldb.SBError()
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
@@ -117,6 +117,22 @@
 return python::ToSWIGWrapper(arg);
   }
 
+  python::PythonObject Transform(lldb::TargetSP arg) {
+return python::ToSWIGWrapper(arg);
+  }
+
+  python::PythonObject Transform(lldb::DebuggerSP arg) {
+return python::ToSWIGWrapper(arg);
+  }
+
+  python::PythonObject Transform(lldb::ProcessAttachInfoSP arg) {
+return python::ToSWIGWrapper(arg);
+  }
+
+  python::PythonObject Transform(lldb::ProcessLaunchInfoSP arg) {
+return python::ToSWIGWrapper(arg);
+  }
+
   template 
   void ReverseTransform(T &original_arg, U transformed_arg, Status &error) {
 // If U is not a PythonObject, don't touch it!
@@ -198,6 +214,29 @@
 Status ScriptedPythonInterface::ExtractValueFromPythonObject(
 python::PythonObject &p, Status &error);
 
+template <>
+lldb::ProcessSP
+ScriptedPythonInterface::ExtractValueFromPythonObject(
+python::PythonObject &p, Status &error);
+
+template <>
+lldb::DebuggerSP
+ScriptedPythonInterface::ExtractValueFromPythonObject(
+python::PythonObject &p, Status &error);
+
+template <>
+lldb::TargetSP
+ScriptedPythonInterface::ExtractValueFromPythonObject(
+python::PythonObject &p, Status &error);
+
+template <>
+lldb::ProcessAttachInfoSP ScriptedPythonInterface::ExtractValueFromPythonObject<
+lldb::ProcessAttachInfoSP>(python::PythonObject &p, Status &error);
+
+template <>
+lldb::ProcessLaunchInfoSP ScriptedPythonInterface::ExtractValueFromPythonObject<
+lldb::ProcessLaunchInfoSP>(python::PythonObject &p, Status &error);
+
 template <>
 lldb::DataExtractorSP
 Scripte

[Lldb-commits] [PATCH] D143104: [lldb/Plugins] Add Attach capabilities to ScriptedProcess

2023-02-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.
This revision is now accepted and ready to land.

Makes sense to me. It does seem a little weird that you can specify a name or a 
pid for attaching to a scripted process but I suppose that's just a part of the 
interface.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143104

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


[Lldb-commits] [PATCH] D143068: [lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 494058.
Michael137 added a comment.

- Update commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143068

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
  lldb/test/API/commands/expression/inline-namespace/main.cpp


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp
===
--- lldb/test/API/commands/expression/inline-namespace/main.cpp
+++ lldb/test/API/commands/expression/inline-namespace/main.cpp
@@ -1,10 +1,28 @@
 namespace A {
   inline namespace B {
 int f() { return 3; }
+int global_var = 0;
+
+namespace C {
+int global_var = 1;
+}
+
+inline namespace D {
+int nested_var = 2;
+}
   };
+
+  namespace E {
+  inline namespace F {
+  int other_var = 3;
+  }
+  } // namespace E
+
+  int global_var = 4;
 }
 
 int main(int argc, char **argv) {
   // Set break point at this line.
-  return A::f();
+  return A::f() + A::B::global_var + A::C::global_var + A::E::F::other_var +
+ A::B::D::nested_var;
 }
Index: lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
===
--- lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
+++ lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
@@ -23,3 +23,35 @@
 # But we should still find the function when we pretend the inline
 # namespace is not inline.
 self.expect_expr("A::B::f()", result_type="int", result_value="3")
+
+self.expect_expr("A::B::global_var", result_type="int", 
result_value="0")
+# FIXME: should be ambiguous lookup but ClangExpressionDeclMap takes
+#first global variable that the lookup found, which in this 
case
+#is A::B::global_var
+self.expect_expr("A::global_var", result_type="int", result_value="0")
+
+self.expect_expr("A::B::C::global_var", result_type="int", 
result_value="1")
+self.expect_expr("A::C::global_var", result_type="int", 
result_value="1")
+
+self.expect_expr("A::B::D::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::D::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::B::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::nested_var", result_type="int", result_value="2")
+
+self.expect_expr("A::E::F::other_var", result_type="int", 
result_value="3")
+self.expect_expr("A::E::other_var", result_type="int", 
result_value="3")
+
+self.expect("expr A::E::global_var", error=True, substrs=["no member 
named 'global_var' in namespace 'A::E'"])
+self.expect("expr A::E::F::global_var", error=True, substrs=["no 
member named 'global_var' in namespace 'A::E::F'"])
+
+self.expect("expr A::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A'"])
+self.expect("expr A::B::other_var", error=True, substrs=["no member 
named 'other_var' in namespace 'A::B'"])
+self.expect("expr B::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A::B'"])
+
+# 'frame variable' can correctly distinguish between A::B::global_var 
and A::global_var
+gvars = self.target().FindGlobalVariables("A::global_var", 10)
+self.assertEqual(len(gvars), 1)
+self.assertEqual(gvars[0].GetValueAsSigned(), 4)
+
+self.expect("frame variable A::global_var", substrs=["(int) 
A::global_var = 4"])
+self.expect("frame variable A::B::global_var", substrs=["(int) 
A::B::global_var = 0"])
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -,8 +,14 @@
   if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
 CompilerDeclContext actual_parent_decl_ctx =
 dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+/// If the actual namespace is inline (i.e., had a 
DW_AT_export_symbols)
+/// and a child (possibly through other layers of inline namespaces)
+/// of the namespace referred to by 'basename', allow the lookup to
+/// succeed.
 if (!actual_parent_decl_ctx ||
-actual_parent_decl_ctx != parent_decl_ctx)
+(actual_parent_decl_ctx != parent_decl_ctx &&
+ !parent_decl_ctx.IsContainedInLookup(actual_parent_decl_ctx)))
   return true;
   }
 }


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp
==

[Lldb-commits] [PATCH] D143068: [lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 494057.
Michael137 added a comment.

- Add comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143068

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
  lldb/test/API/commands/expression/inline-namespace/main.cpp


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp
===
--- lldb/test/API/commands/expression/inline-namespace/main.cpp
+++ lldb/test/API/commands/expression/inline-namespace/main.cpp
@@ -1,10 +1,28 @@
 namespace A {
   inline namespace B {
 int f() { return 3; }
+int global_var = 0;
+
+namespace C {
+int global_var = 1;
+}
+
+inline namespace D {
+int nested_var = 2;
+}
   };
+
+  namespace E {
+  inline namespace F {
+  int other_var = 3;
+  }
+  } // namespace E
+
+  int global_var = 4;
 }
 
 int main(int argc, char **argv) {
   // Set break point at this line.
-  return A::f();
+  return A::f() + A::B::global_var + A::C::global_var + A::E::F::other_var +
+ A::B::D::nested_var;
 }
Index: lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
===
--- lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
+++ lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
@@ -23,3 +23,35 @@
 # But we should still find the function when we pretend the inline
 # namespace is not inline.
 self.expect_expr("A::B::f()", result_type="int", result_value="3")
+
+self.expect_expr("A::B::global_var", result_type="int", 
result_value="0")
+# FIXME: should be ambiguous lookup but ClangExpressionDeclMap takes
+#first global variable that the lookup found, which in this 
case
+#is A::B::global_var
+self.expect_expr("A::global_var", result_type="int", result_value="0")
+
+self.expect_expr("A::B::C::global_var", result_type="int", 
result_value="1")
+self.expect_expr("A::C::global_var", result_type="int", 
result_value="1")
+
+self.expect_expr("A::B::D::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::D::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::B::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::nested_var", result_type="int", result_value="2")
+
+self.expect_expr("A::E::F::other_var", result_type="int", 
result_value="3")
+self.expect_expr("A::E::other_var", result_type="int", 
result_value="3")
+
+self.expect("expr A::E::global_var", error=True, substrs=["no member 
named 'global_var' in namespace 'A::E'"])
+self.expect("expr A::E::F::global_var", error=True, substrs=["no 
member named 'global_var' in namespace 'A::E::F'"])
+
+self.expect("expr A::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A'"])
+self.expect("expr A::B::other_var", error=True, substrs=["no member 
named 'other_var' in namespace 'A::B'"])
+self.expect("expr B::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A::B'"])
+
+# 'frame variable' can correctly distinguish between A::B::global_var 
and A::global_var
+gvars = self.target().FindGlobalVariables("A::global_var", 10)
+self.assertEqual(len(gvars), 1)
+self.assertEqual(gvars[0].GetValueAsSigned(), 4)
+
+self.expect("frame variable A::global_var", substrs=["(int) 
A::global_var = 4"])
+self.expect("frame variable A::B::global_var", substrs=["(int) 
A::B::global_var = 0"])
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -,8 +,14 @@
   if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
 CompilerDeclContext actual_parent_decl_ctx =
 dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+/// If the actual namespace is inline (i.e., had a 
DW_AT_export_symbols)
+/// and a child (possibly through other layers of inline namespaces)
+/// of the namespace referred to by 'basename', allow the lookup to
+/// succeed.
 if (!actual_parent_decl_ctx ||
-actual_parent_decl_ctx != parent_decl_ctx)
+(actual_parent_decl_ctx != parent_decl_ctx &&
+ !parent_decl_ctx.IsContainedInLookup(actual_parent_decl_ctx)))
   return true;
   }
 }


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp

[Lldb-commits] [PATCH] D143062: [lldb] Allow evaluating expressions in C++20 mode

2023-02-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:548
+[[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus:
   case lldb::eLanguageTypeC_plus_plus_11:

Why no case C++17?



Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:551
   case lldb::eLanguageTypeC_plus_plus_14:
 lang_opts.CPlusPlus11 = true;
 m_compiler->getHeaderSearchOpts().UseLibcxx = true;

Why does this not set C++14? Because it's effectively equivalent?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143062

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


[Lldb-commits] [PATCH] D143104: [lldb/Plugins] Add Attach capabilities to ScriptedProcess

2023-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, bulbazord.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch adds process attach capabilities to the ScriptedProcess
plugin. This doesn't really expects a PID or process name, since the
process state is already script, however, this allows to create a
scripted process without requiring to have an executuble in the target.

In order to do so, this patch also moves the scripted process related
getters and setters from the `ProcessLaunchInfo` and
`ProcessAttachInfo` classes to the `ProcessInfo` class, so they can be
accessed interchangeably.

rdar://104577406

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143104

Files:
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Host/ProcessLaunchInfo.h
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/Utility/ProcessInfo.h
  lldb/source/Host/common/ProcessLaunchInfo.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Target/Target.cpp
  lldb/source/Utility/ProcessInfo.cpp

Index: lldb/source/Utility/ProcessInfo.cpp
===
--- lldb/source/Utility/ProcessInfo.cpp
+++ lldb/source/Utility/ProcessInfo.cpp
@@ -21,12 +21,14 @@
 using namespace lldb_private;
 
 ProcessInfo::ProcessInfo()
-: m_executable(), m_arguments(), m_environment(), m_arch() {}
+: m_executable(), m_arguments(), m_environment(), m_arch(),
+  m_scripted_process_class_name(), m_scripted_process_dictionary_sp() {}
 
 ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,
  lldb::pid_t pid)
 : m_executable(name), m_arguments(), m_environment(), m_arch(arch),
-  m_pid(pid) {}
+  m_pid(pid), m_scripted_process_class_name(),
+  m_scripted_process_dictionary_sp() {}
 
 void ProcessInfo::Clear() {
   m_executable.Clear();
@@ -36,6 +38,8 @@
   m_gid = UINT32_MAX;
   m_arch.Clear();
   m_pid = LLDB_INVALID_PROCESS_ID;
+  m_scripted_process_class_name.clear();
+  m_scripted_process_dictionary_sp.reset();
 }
 
 const char *ProcessInfo::GetName() const {
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3080,6 +3080,22 @@
 
 void Target::ClearAllLoadedSections() { m_section_load_history.Clear(); }
 
+void Target::SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info) {
+  if (process_info.IsScriptedProcess()) {
+// Only copy scripted process launch options.
+ProcessLaunchInfo &default_launch_info = const_cast(
+GetGlobalProperties().GetProcessLaunchInfo());
+
+default_launch_info.SetProcessPluginName("ScriptedProcess");
+default_launch_info.SetScriptedProcessClassName(
+process_info.GetScriptedProcessClassName());
+default_launch_info.SetScriptedProcessDictionarySP(
+process_info.GetScriptedProcessDictionarySP());
+
+SetProcessLaunchInfo(default_launch_info);
+  }
+}
+
 Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
   m_stats.SetLaunchOrAttachTime();
   Status error;
@@ -3109,19 +3125,7 @@
 
   launch_info.GetFlags().Set(eLaunchFlagDebug);
 
-  if (launch_info.IsScriptedProcess()) {
-// Only copy scripted process launch options.
-ProcessLaunchInfo &default_launch_info = const_cast(
-GetGlobalProperties().GetProcessLaunchInfo());
-
-default_launch_info.SetProcessPluginName("ScriptedProcess");
-default_launch_info.SetScriptedProcessClassName(
-launch_info.GetScriptedProcessClassName());
-default_launch_info.SetScriptedProcessDictionarySP(
-launch_info.GetScriptedProcessDictionarySP());
-
-SetProcessLaunchInfo(launch_info);
-  }
+  SaveScriptedLaunchInfo(launch_info);
 
   // Get the value of synchronous execution here.  If you wait till after you
   // have started to run, then you could have hit a breakpoint, whose command
@@ -3334,11 +3338,12 @@
 
   Status error;
   if (state != eStateConnected && platform_sp != nullptr &&
-  platform_sp->CanDebugProcess()) {
+  platform_sp->CanDebugProcess() && !attach_info.IsScriptedProcess()) {
 SetPlatform(platform_sp);
 process_sp = platform_sp->Attach(attach_info, GetDebugger(), this, error);
   } else {
 if (state != eStateConnected) {
+  SaveScriptedLaunchInfo(attach_info);
   const char *plugin_name = attach_info.GetProcessPluginName();
   process_sp =
   CreateProcess(attach_info.

[Lldb-commits] [PATCH] D143061: [lldb][Language] Add more language types

2023-02-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:492
+  eLanguageTypeAda2005 = 0x002e,
+  eLanguageTypeAda2012 = 0x002f,
+

aprantl wrote:
> Michael137 wrote:
> > aprantl wrote:
> > > Would it make sense to generate this list from the macros in 
> > > `llvm/include/llvm/BinaryFormat/Dwarf.def` with some clever application 
> > > of the ## operator?
> > The only thing that's stopping us from doing this is that the constants for 
> > the vendor extensions are not consecutive with the rest of the constants. 
> > So if one ever does try to use that language constant we'd run into 
> > out-of-bounds accesses here and there
> Do have arrays that are indexed by language? Or what would be an example of 
> that?
Also, we could still define eNumLanguagesTypes to be at the end of the official 
block?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143061

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


[Lldb-commits] [PATCH] D143061: [lldb][Language] Add more language types

2023-02-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:492
+  eLanguageTypeAda2005 = 0x002e,
+  eLanguageTypeAda2012 = 0x002f,
+

Michael137 wrote:
> aprantl wrote:
> > Would it make sense to generate this list from the macros in 
> > `llvm/include/llvm/BinaryFormat/Dwarf.def` with some clever application of 
> > the ## operator?
> The only thing that's stopping us from doing this is that the constants for 
> the vendor extensions are not consecutive with the rest of the constants. So 
> if one ever does try to use that language constant we'd run into 
> out-of-bounds accesses here and there
Do have arrays that are indexed by language? Or what would be an example of 
that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143061

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


[Lldb-commits] [PATCH] D143068: [lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces

2023-02-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2227
+(actual_parent_decl_ctx != parent_decl_ctx &&
+ !parent_decl_ctx.IsContainedInLookup(actual_parent_decl_ctx)))
   return true;

From the textual description above it sounds like this is a C++ specific 
feature, but the change is in generic code. Is IsContainedInLookup() 
implemented in a language-specific way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143068

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


[Lldb-commits] [PATCH] D143061: [lldb][Language] Add more language types

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:492
+  eLanguageTypeAda2005 = 0x002e,
+  eLanguageTypeAda2012 = 0x002f,
+

aprantl wrote:
> Would it make sense to generate this list from the macros in 
> `llvm/include/llvm/BinaryFormat/Dwarf.def` with some clever application of 
> the ## operator?
The only thing that's stopping us from doing this is that the constants for the 
vendor extensions are not consecutive with the rest of the constants. So if one 
ever does try to use that language constant we'd run into out-of-bounds 
accesses here and there


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143061

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


[Lldb-commits] [PATCH] D143061: [lldb][Language] Add more language types

2023-02-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:492
+  eLanguageTypeAda2005 = 0x002e,
+  eLanguageTypeAda2012 = 0x002f,
+

Would it make sense to generate this list from the macros in 
`llvm/include/llvm/BinaryFormat/Dwarf.def` with some clever application of the 
## operator?



Comment at: lldb/source/Target/Language.cpp:211
+{"ada2005", eLanguageTypeAda2005},
+{"ada2012", eLanguageTypeAda2012},
 // Vendor Extensions

Should we sink this into the Dwarf.def?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143061

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


[Lldb-commits] [PATCH] D140839: [lldb] Enable TestFrameFormatNameWithArgs in case of cross compilation

2023-02-01 Thread Ayush Sahay via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08032411301e: [lldb] Enable TestFrameFormatNameWithArgs in 
case of cross compilation (authored by asahay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140839

Files:
  lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
  lldb/test/Shell/helper/build.py


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -110,6 +110,12 @@
 nargs='+',
 help='Source file(s) to compile / object file(s) to link')
 
+parser.add_argument('--std',
+metavar='std',
+dest='std',
+required=False,
+help='Specify the C/C++ standard.')
+
 
 args = parser.parse_args(args=sys.argv[1:])
 
@@ -231,6 +237,7 @@
 self.verbose = args.verbose
 self.obj_ext = obj_ext
 self.lib_paths = args.libs_dir
+self.std = args.std
 
 def _exe_file_name(self):
 assert self.mode != 'compile'
@@ -581,6 +588,9 @@
 args.append('--')
 args.append(source)
 
+if self.std:
+args.append('/std:' + self.std)
+
 return ('compiling', [source], obj,
 self.compile_env,
 args)
@@ -652,6 +662,9 @@
 if sys.platform == 'darwin':
 args.extend(['-isysroot', self.apple_sdk])
 
+if self.std:
+args.append('-std={0}'.format(self.std))
+
 return ('compiling', [source], obj, None, args)
 
 def _get_link_command(self):
@@ -789,6 +802,7 @@
 print('  Verbose: ' + str(args.verbose))
 print('  Dryrun: ' + str(args.dry))
 print('  Inputs: ' + format_text(args.inputs, 0, 10))
+print('  C/C++ Standard: ' + str(args.std))
 print('Script Environment:')
 print_environment(os.environ)
 
Index: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
===
--- lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,5 +1,5 @@
 # UNSUPPORTED: system-windows
-# RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
+# RUN: %build %S/Inputs/names.cpp --std c++17 -o %t.out
 # RUN: %lldb -b -s %s %t.out | FileCheck %s
 settings set -f frame-format "frame ${function.name-with-args}\n"
 break set -n foo


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -110,6 +110,12 @@
 nargs='+',
 help='Source file(s) to compile / object file(s) to link')
 
+parser.add_argument('--std',
+metavar='std',
+dest='std',
+required=False,
+help='Specify the C/C++ standard.')
+
 
 args = parser.parse_args(args=sys.argv[1:])
 
@@ -231,6 +237,7 @@
 self.verbose = args.verbose
 self.obj_ext = obj_ext
 self.lib_paths = args.libs_dir
+self.std = args.std
 
 def _exe_file_name(self):
 assert self.mode != 'compile'
@@ -581,6 +588,9 @@
 args.append('--')
 args.append(source)
 
+if self.std:
+args.append('/std:' + self.std)
+
 return ('compiling', [source], obj,
 self.compile_env,
 args)
@@ -652,6 +662,9 @@
 if sys.platform == 'darwin':
 args.extend(['-isysroot', self.apple_sdk])
 
+if self.std:
+args.append('-std={0}'.format(self.std))
+
 return ('compiling', [source], obj, None, args)
 
 def _get_link_command(self):
@@ -789,6 +802,7 @@
 print('  Verbose: ' + str(args.verbose))
 print('  Dryrun: ' + str(args.dry))
 print('  Inputs: ' + format_text(args.inputs, 0, 10))
+print('  C/C++ Standard: ' + str(args.std))
 print('Script Environment:')
 print_environment(os.environ)
 
Index: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
===
--- lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,5 +1,5 @@
 # UNSUPPORTED: system-windows
-# RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
+# RUN: %build %S/Inputs/names.cpp --std c++17 -o %t.out
 # RUN: %lldb -b -s %s %t.out | FileCheck %s
 settings set -f frame-format "frame ${function.name-with-args}\n"
 break set -n foo
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 0803241 - [lldb] Enable TestFrameFormatNameWithArgs in case of cross compilation

2023-02-01 Thread Ayush Sahay via lldb-commits

Author: Ayush Sahay
Date: 2023-02-01T23:05:28+05:30
New Revision: 08032411301e8996879c4b558b8bb3808d5dfe6f

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

LOG: [lldb] Enable TestFrameFormatNameWithArgs in case of cross compilation

TestFrameFormatNameWithArgs.test is enabled only in case of native
compilation but is applicable in case of cross compilation too. So,
provision support for enabling it in case of both, native and cross
compilation.

Reviewed By: Michael137

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

Added: 


Modified: 
lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
lldb/test/Shell/helper/build.py

Removed: 




diff  --git a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test 
b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
index dc4dedadee80a..eeb46cfd6bf9d 100644
--- a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,5 +1,5 @@
 # UNSUPPORTED: system-windows
-# RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
+# RUN: %build %S/Inputs/names.cpp --std c++17 -o %t.out
 # RUN: %lldb -b -s %s %t.out | FileCheck %s
 settings set -f frame-format "frame ${function.name-with-args}\n"
 break set -n foo

diff  --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index 96684b7b3e669..55d871f2a0400 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -110,6 +110,12 @@
 nargs='+',
 help='Source file(s) to compile / object file(s) to link')
 
+parser.add_argument('--std',
+metavar='std',
+dest='std',
+required=False,
+help='Specify the C/C++ standard.')
+
 
 args = parser.parse_args(args=sys.argv[1:])
 
@@ -231,6 +237,7 @@ def __init__(self, toolchain_type, args, obj_ext):
 self.verbose = args.verbose
 self.obj_ext = obj_ext
 self.lib_paths = args.libs_dir
+self.std = args.std
 
 def _exe_file_name(self):
 assert self.mode != 'compile'
@@ -581,6 +588,9 @@ def _get_compilation_command(self, source, obj):
 args.append('--')
 args.append(source)
 
+if self.std:
+args.append('/std:' + self.std)
+
 return ('compiling', [source], obj,
 self.compile_env,
 args)
@@ -652,6 +662,9 @@ def _get_compilation_command(self, source, obj):
 if sys.platform == 'darwin':
 args.extend(['-isysroot', self.apple_sdk])
 
+if self.std:
+args.append('-std={0}'.format(self.std))
+
 return ('compiling', [source], obj, None, args)
 
 def _get_link_command(self):
@@ -789,6 +802,7 @@ def fix_arguments(args):
 print('  Verbose: ' + str(args.verbose))
 print('  Dryrun: ' + str(args.dry))
 print('  Inputs: ' + format_text(args.inputs, 0, 10))
+print('  C/C++ Standard: ' + str(args.std))
 print('Script Environment:')
 print_environment(os.environ)
 



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


[Lldb-commits] [PATCH] D142824: [lldb][NFC] Use move instead of copy

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6953dc95a976: [lldb][NFC] Use move instead of copy (authored 
by ccotter, committed by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142824

Files:
  
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
  lldb/source/Target/Process.cpp


Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -3352,7 +3352,7 @@
 
 void Process::SetUnixSignals(UnixSignalsSP &&signals_sp) {
   assert(signals_sp && "null signals_sp");
-  m_unix_signals_sp = signals_sp;
+  m_unix_signals_sp = std::move(signals_sp);
 }
 
 const lldb::UnixSignalsSP &Process::GetUnixSignals() {
Index: lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
===
--- lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
+++ lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
@@ -69,7 +69,7 @@
 
 void HTRBlockLayer::AppendNewBlock(size_t block_id, HTRBlock &&block) {
   m_block_id_trace.emplace_back(block_id);
-  m_block_defs.emplace(block_id, block);
+  m_block_defs.emplace(block_id, std::move(block));
 }
 
 void HTRBlockLayer::AppendRepeatedBlock(size_t block_id) {
Index: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
===
--- 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -559,7 +559,7 @@
 }
 
 void GDBRemoteCommunicationServerPlatform::SetPortMap(PortMap &&port_map) {
-  m_port_map = port_map;
+  m_port_map = std::move(port_map);
 }
 
 const FileSpec &GDBRemoteCommunicationServerPlatform::GetDomainSocketDir() {


Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -3352,7 +3352,7 @@
 
 void Process::SetUnixSignals(UnixSignalsSP &&signals_sp) {
   assert(signals_sp && "null signals_sp");
-  m_unix_signals_sp = signals_sp;
+  m_unix_signals_sp = std::move(signals_sp);
 }
 
 const lldb::UnixSignalsSP &Process::GetUnixSignals() {
Index: lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
===
--- lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
+++ lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
@@ -69,7 +69,7 @@
 
 void HTRBlockLayer::AppendNewBlock(size_t block_id, HTRBlock &&block) {
   m_block_id_trace.emplace_back(block_id);
-  m_block_defs.emplace(block_id, block);
+  m_block_defs.emplace(block_id, std::move(block));
 }
 
 void HTRBlockLayer::AppendRepeatedBlock(size_t block_id) {
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -559,7 +559,7 @@
 }
 
 void GDBRemoteCommunicationServerPlatform::SetPortMap(PortMap &&port_map) {
-  m_port_map = port_map;
+  m_port_map = std::move(port_map);
 }
 
 const FileSpec &GDBRemoteCommunicationServerPlatform::GetDomainSocketDir() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 6953dc9 - [lldb][NFC] Use move instead of copy

2023-02-01 Thread Michael Buch via lldb-commits

Author: Chris Cotter
Date: 2023-02-01T15:51:24Z
New Revision: 6953dc95a9761768cad3c329ebac35927df126ab

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

LOG: [lldb][NFC] Use move instead of copy

Summary: For functions that accept an rvalue reference type
parameter, use move to avoid copying the parameter.

These were found when implementing CppCoreGuideline F.18 in
clang-tidy.

Committed on behalf of ccotter (Chris Cotter)

Reviewers: Michael137

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

Added: 


Modified: 

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
lldb/source/Target/Process.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index bdb6480ff4d90..4ffa7faa49424 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -559,7 +559,7 @@ Status 
GDBRemoteCommunicationServerPlatform::LaunchProcess() {
 }
 
 void GDBRemoteCommunicationServerPlatform::SetPortMap(PortMap &&port_map) {
-  m_port_map = port_map;
+  m_port_map = std::move(port_map);
 }
 
 const FileSpec &GDBRemoteCommunicationServerPlatform::GetDomainSocketDir() {

diff  --git a/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp 
b/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
index 13c63f2f7e37c..abe1581682685 100644
--- a/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
+++ b/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
@@ -69,7 +69,7 @@ size_t IHTRLayer::GetLayerId() const { return m_layer_id; }
 
 void HTRBlockLayer::AppendNewBlock(size_t block_id, HTRBlock &&block) {
   m_block_id_trace.emplace_back(block_id);
-  m_block_defs.emplace(block_id, block);
+  m_block_defs.emplace(block_id, std::move(block));
 }
 
 void HTRBlockLayer::AppendRepeatedBlock(size_t block_id) {

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index e0cca0595ee30..f6c53e6d4c2d0 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -3352,7 +3352,7 @@ Status Process::Signal(int signal) {
 
 void Process::SetUnixSignals(UnixSignalsSP &&signals_sp) {
   assert(signals_sp && "null signals_sp");
-  m_unix_signals_sp = signals_sp;
+  m_unix_signals_sp = std::move(signals_sp);
 }
 
 const lldb::UnixSignalsSP &Process::GetUnixSignals() {



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


[Lldb-commits] [PATCH] D142824: [lldb][NFC] Use move instead of copy

2023-02-01 Thread Chris Cotter via Phabricator via lldb-commits
ccotter added a comment.

This should do: `Chris Cotter `

thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142824

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


[Lldb-commits] [PATCH] D143068: [lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 493938.
Michael137 added a comment.

- Add test-case for nested inline namespaces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143068

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
  lldb/test/API/commands/expression/inline-namespace/main.cpp


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp
===
--- lldb/test/API/commands/expression/inline-namespace/main.cpp
+++ lldb/test/API/commands/expression/inline-namespace/main.cpp
@@ -1,10 +1,28 @@
 namespace A {
   inline namespace B {
 int f() { return 3; }
+int global_var = 0;
+
+namespace C {
+int global_var = 1;
+}
+
+inline namespace D {
+int nested_var = 2;
+}
   };
+
+  namespace E {
+  inline namespace F {
+  int other_var = 3;
+  }
+  } // namespace E
+
+  int global_var = 4;
 }
 
 int main(int argc, char **argv) {
   // Set break point at this line.
-  return A::f();
+  return A::f() + A::B::global_var + A::C::global_var + A::E::F::other_var +
+ A::B::D::nested_var;
 }
Index: lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
===
--- lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
+++ lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
@@ -23,3 +23,35 @@
 # But we should still find the function when we pretend the inline
 # namespace is not inline.
 self.expect_expr("A::B::f()", result_type="int", result_value="3")
+
+self.expect_expr("A::B::global_var", result_type="int", 
result_value="0")
+# FIXME: should be ambiguous lookup but ClangExpressionDeclMap takes
+#first global variable that the lookup found, which in this 
case
+#is A::B::global_var
+self.expect_expr("A::global_var", result_type="int", result_value="0")
+
+self.expect_expr("A::B::C::global_var", result_type="int", 
result_value="1")
+self.expect_expr("A::C::global_var", result_type="int", 
result_value="1")
+
+self.expect_expr("A::B::D::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::D::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::B::nested_var", result_type="int", 
result_value="2")
+self.expect_expr("A::nested_var", result_type="int", result_value="2")
+
+self.expect_expr("A::E::F::other_var", result_type="int", 
result_value="3")
+self.expect_expr("A::E::other_var", result_type="int", 
result_value="3")
+
+self.expect("expr A::E::global_var", error=True, substrs=["no member 
named 'global_var' in namespace 'A::E'"])
+self.expect("expr A::E::F::global_var", error=True, substrs=["no 
member named 'global_var' in namespace 'A::E::F'"])
+
+self.expect("expr A::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A'"])
+self.expect("expr A::B::other_var", error=True, substrs=["no member 
named 'other_var' in namespace 'A::B'"])
+self.expect("expr B::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A::B'"])
+
+# 'frame variable' can correctly distinguish between A::B::global_var 
and A::global_var
+gvars = self.target().FindGlobalVariables("A::global_var", 10)
+self.assertEqual(len(gvars), 1)
+self.assertEqual(gvars[0].GetValueAsSigned(), 4)
+
+self.expect("frame variable A::global_var", substrs=["(int) 
A::global_var = 4"])
+self.expect("frame variable A::B::global_var", substrs=["(int) 
A::B::global_var = 0"])
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2223,7 +2223,8 @@
 CompilerDeclContext actual_parent_decl_ctx =
 dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
 if (!actual_parent_decl_ctx ||
-actual_parent_decl_ctx != parent_decl_ctx)
+(actual_parent_decl_ctx != parent_decl_ctx &&
+ !parent_decl_ctx.IsContainedInLookup(actual_parent_decl_ctx)))
   return true;
   }
 }


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp
===
--- lldb/test/API/commands/expression/inline-namespace/main.cpp
+++ lldb/test/API/commands/expression/inline-namespace/main.cpp
@@ -1,10 +1,28 @@
 namespace A {
   inline namespace B {
 int f() { return 3; }
+int global_var = 0;
+
+namespace C {
+int global_var = 1;
+}
+

[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-02-01 Thread Callum Macmillan via Phabricator via lldb-commits
cimacmillan marked 12 inline comments as done.
cimacmillan added a comment.

@clayborg Thanks for your feedback. I've refactored the Watchpoint class 
slightly so that it encapsulates the parsing of the setDataBreakpoints request 
and be used to get the Breakpoint info to attach to the response. This is more 
similar to how the other breakpoint classes are written, and encapsulates 
things a bit better.




Comment at: 
lldb/test/API/tools/lldb-vscode/breakpoint_data/TestVSCode_setDataBreakpoints.py:73
+num_a = array_find(locals, lambda x: x['name'] == 'num_a')
+self.assertIsNotNone(num_a)
+

clayborg wrote:
> might be better as suggested?
There isn't an IsValid function in this case as it's not the SBValue type. I 
suppose is the variable was invalid, the rest of the test would fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140630

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


[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-02-01 Thread Callum Macmillan via Phabricator via lldb-commits
cimacmillan updated this revision to Diff 493936.
cimacmillan added a comment.

Refactored Watchpoint class and addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140630

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/breakpoint_data/Makefile
  
lldb/test/API/tools/lldb-vscode/breakpoint_data/TestVSCode_setDataBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint_data/main.cpp
  lldb/test/API/tools/lldb-vscode/breakpoint_data_optimized/Makefile
  
lldb/test/API/tools/lldb-vscode/breakpoint_data_optimized/TestVSCode_setDataBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint_data_optimized/main.cpp
  lldb/tools/lldb-vscode/CMakeLists.txt
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/Watchpoint.cpp
  lldb/tools/lldb-vscode/Watchpoint.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "llvm/ADT/ArrayRef.h"
@@ -56,6 +57,8 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include "lldb/API/SBMemoryRegionInfo.h"
+
 #include "JSONUtils.h"
 #include "LLDBUtils.h"
 #include "OutputRedirector.h"
@@ -1541,6 +1544,8 @@
   body.try_emplace("supportsProgressReporting", true);
   // The debug adapter supports 'logMessage' in breakpoint.
   body.try_emplace("supportsLogPoints", true);
+  // The debug adapter supports data breakpoints
+  body.try_emplace("supportsDataBreakpoints", true);
 
   response.try_emplace("body", std::move(body));
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
@@ -2117,6 +2122,334 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+static lldb::SBValue get_variable(std::string variable_name,
+  uint32_t variables_reference) {
+  bool is_duplicated_variable_name =
+  variable_name.find(" @") != llvm::StringRef::npos;
+  lldb::SBValue variable;
+
+  if (lldb::SBValueList *top_scope = GetTopLevelScope(variables_reference)) {
+// variablesReference is one of our scopes, not an actual variable it is
+// asking for a variable in locals or globals or registers
+int64_t end_idx = top_scope->GetSize();
+// Searching backward so that we choose the variable in closest scope
+// among variables of the same name.
+for (int64_t i = end_idx - 1; i >= 0; --i) {
+  lldb::SBValue curr_variable = top_scope->GetValueAtIndex(i);
+  std::string local_variable = CreateUniqueVariableNameForDisplay(
+  curr_variable, is_duplicated_variable_name);
+  if (variable_name == local_variable) {
+variable = curr_variable;
+break;
+  }
+}
+  } else {
+// This is not under the globals or locals scope, so there are no duplicated
+// names.
+
+// We have a named item within an actual variable so we need to find it
+// withing the container variable by name.
+lldb::SBValue container = g_vsc.variables.GetVariable(variables_reference);
+if (!container.IsValid()) {
+  return variable;
+}
+
+variable = container.GetChildMemberWithName(variable_name.data());
+if (!variable.IsValid()) {
+  if (variable_name.size() > 0 && variable_name[0] == '[') {
+llvm::StringRef index_str(std::move(variable_name.substr(1)));
+uint64_t index = 0;
+if (!index_str.consumeInteger(0, index)) {
+  if (index_str == "]")
+variable = container.GetChildAtIndex(index);
+}
+  }
+}
+  }
+
+  return variable;
+}
+
+// "SetDataBreakpointsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Replaces all existing data breakpoints with new data
+// breakpoints.\nTo clear all data breakpoints, specify an empty
+// array.\nWhen a data breakpoint is hit, a `stopped` event (with reason
+// `data breakpoint`) is generated.\nClients should only call this request
+// if the corresponding capability `supportsDataBreakpoints` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "setDataBreakpoints" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/SetDataBreakpointsArguments"
+//   }
+// },
+// "required": [ "command", "arguments"  ]
+//   }]
+// },
+// "SetDataBreakpointsArguments": {
+//   "type": "object",
+//   "description": "Arguments for `setDataBreakpoints` request.",
+//   "properties": {
+// "breakpoints": {
+//   "type": "array",
+//   "items": {
+// "$ref": "#/definitions/Da

[Lldb-commits] [PATCH] D142824: [lldb][NFC] Use move instead of copy

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D142824#4095360 , @ccotter wrote:

> Thanks! I don't have push access, so if you're good with this, could you 
> please land this for me?

Sure, could you let me know which email and name you'd like me to use in the 
commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142824

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


[Lldb-commits] [PATCH] D143068: [lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, labath, jingham.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Currently evaluating an expression involving a global variable inside
an inline namespace will fail to lookup said variable. This is because
the `SymbolFileDWARF::FindGlobalVariables` discards from consideration
all DIEs whose decl_context doesn't exactly match that of the lookup.

This patch relaxes this restriction by checking whether C++ rules
would permit the lookup.

The motivation for this is evaluating `std::ranges` expressions, which
heavily rely on global variables inside inline namespaces. E.g.,
`std::views::all(...)` is just an invocation of the `operator()`
on `std::ranges::views::__cpo::all`.

**Testing**

- Added API tests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143068

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
  lldb/test/API/commands/expression/inline-namespace/main.cpp


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp
===
--- lldb/test/API/commands/expression/inline-namespace/main.cpp
+++ lldb/test/API/commands/expression/inline-namespace/main.cpp
@@ -1,10 +1,23 @@
 namespace A {
   inline namespace B {
 int f() { return 3; }
+int global_var = 0;
+
+namespace C {
+int global_var = 1;
+}
   };
+
+  namespace D {
+  inline namespace F {
+  int other_var = 2;
+  }
+  } // namespace D
+
+  int global_var = 3;
 }
 
 int main(int argc, char **argv) {
   // Set break point at this line.
-  return A::f();
+  return A::f() + A::B::global_var + A::C::global_var + A::D::F::other_var;
 }
Index: lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
===
--- lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
+++ lldb/test/API/commands/expression/inline-namespace/TestInlineNamespace.py
@@ -23,3 +23,30 @@
 # But we should still find the function when we pretend the inline
 # namespace is not inline.
 self.expect_expr("A::B::f()", result_type="int", result_value="3")
+
+self.expect_expr("A::B::global_var", result_type="int", 
result_value="0")
+# FIXME: should be ambiguous lookup but ClangExpressionDeclMap takes
+#first global variable that the lookup found, which in this 
case
+#is A::B::global_var
+self.expect_expr("A::global_var", result_type="int", result_value="0")
+
+self.expect_expr("A::B::C::global_var", result_type="int", 
result_value="1")
+self.expect_expr("A::C::global_var", result_type="int", 
result_value="1")
+
+self.expect_expr("A::D::F::other_var", result_type="int", 
result_value="2")
+self.expect_expr("A::D::other_var", result_type="int", 
result_value="2")
+
+self.expect("expr A::D::global_var", error=True, substrs=["no member 
named 'global_var' in namespace 'A::D'"])
+self.expect("expr A::D::F::global_var", error=True, substrs=["no 
member named 'global_var' in namespace 'A::D::F'"])
+
+self.expect("expr A::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A'"])
+self.expect("expr A::B::other_var", error=True, substrs=["no member 
named 'other_var' in namespace 'A::B'"])
+self.expect("expr B::other_var", error=True, substrs=["no member named 
'other_var' in namespace 'A::B'"])
+
+# 'frame variable' can correctly distinguish between A::B::global_var 
and A::global_var
+gvars = self.target().FindGlobalVariables("A::global_var", 10)
+self.assertEqual(len(gvars), 1)
+self.assertEqual(gvars[0].GetValueAsSigned(), 3)
+
+self.expect("frame variable A::global_var", substrs=["(int) 
A::global_var = 3"])
+self.expect("frame variable A::B::global_var", substrs=["(int) 
A::B::global_var = 0"])
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2223,7 +2223,8 @@
 CompilerDeclContext actual_parent_decl_ctx =
 dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
 if (!actual_parent_decl_ctx ||
-actual_parent_decl_ctx != parent_decl_ctx)
+(actual_parent_decl_ctx != parent_decl_ctx
+ && !parent_decl_ctx.IsContainedInLookup(actual_parent_decl_ctx)))
   return true;
   }
 }


Index: lldb/test/API/commands/expression/inline-namespace/main.cpp
===
--- lldb/test/API/commands/exp

[Lldb-commits] [PATCH] D143062: [lldb] Allow evaluating expressions in C++20 mode

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 493899.
Michael137 added a comment.

- Remove redundant change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143062

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Target/Language.cpp
  lldb/test/API/lang/cpp/standards/cpp20/Makefile
  lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
  lldb/test/API/lang/cpp/standards/cpp20/main.cpp
  lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -205,7 +205,11 @@
 
   {"auto Foo[abi:abc]::operator<<>(int) &", "auto",
"Foo[abi:abc]", "operator<<>", "(int)", "&",
-   "Foo[abi:abc]::operator<<>"}};
+   "Foo[abi:abc]::operator<<>"},
+
+  {"auto A::operator<=>[abi:tag]()", "auto", "A",
+   "operator<=>[abi:tag]", "()", "",
+   "A::operator<=>[abi:tag]"}};
 
   for (const auto &test : test_cases) {
 CPlusPlusLanguage::MethodName method(ConstString(test.input));
@@ -227,7 +231,6 @@
   std::string test_cases[] = {
   "int Foo::operator[]<[10>()",
   "Foo::operator bool[10]()",
-  "auto A::operator<=>[abi:tag]()",
   "auto A::operator<<<(int)",
   "auto A::operator>>>(int)",
   "auto A::operator<<(int)",
@@ -356,10 +359,9 @@
   EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "f>", context, basename));
 
-  // We expect these cases to fail until we turn on C++2a
-  EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+  EXPECT_TRUE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "A::operator<=>", context, basename));
-  EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+  EXPECT_TRUE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "operator<=>", context, basename));
 }
 
Index: lldb/test/API/lang/cpp/standards/cpp20/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp20/main.cpp
@@ -0,0 +1,7 @@
+#include 
+
+struct Foo {
+  friend auto operator<=>(Foo const &, Foo const &) { return true; }
+};
+
+int main() { return Foo{} <=> Foo{}; }
Index: lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCPP20Standard(TestBase):
+def test_cpp20(self):
+"""
+Tests that we can evaluate an expression in C++20 mode
+"""
+self.build()
+lldbutil.run_to_source_breakpoint(self, "Foo{}", lldb.SBFileSpec("main.cpp"))
+
+self.expect("expr -l c++11 -- Foo{} <=> Foo{}", error=True, substrs=["'<=>' is a single token in C++20; add a space to avoid a change in behavior"])
+
+self.expect("expr -l c++20 -- Foo{} <=> Foo{}", substrs=["(bool) $0 = true"])
Index: lldb/test/API/lang/cpp/standards/cpp20/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp20/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20
+
+include Makefile.rules
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -268,6 +268,8 @@
   case eLanguageTypeC_plus_plus_03:
   case eLanguageTypeC_plus_plus_11:
   case eLanguageTypeC_plus_plus_14:
+  case eLanguageTypeC_plus_plus_17:
+  case eLanguageTypeC_plus_plus_20:
   case eLanguageTypeObjC_plus_plus:
 return true;
   default:
@@ -307,6 +309,8 @@
   case eLanguageTypeC_plus_plus_03:
   case eLanguageTypeC_plus_plus_11:
   case eLanguageTypeC_plus_plus_14:
+  case eLanguageTypeC_plus_plus_17:
+  case eLanguageTypeC_plus_plus_20:
   case eLanguageTypeObjC_plus_plus:
   case eLanguageTypeObjC:
 return true;
@@ -330,6 +334,8 @@
   case eLanguageTypeC_plus_plus_03:
   case eLanguageTypeC_plus_plus_11:
   case eLanguageTypeC_plus_plus_14:
+  case eLanguageTypeC_plus_plus_17:
+  case eLanguageTypeC_plus_plus_20:
 return eLanguageTypeC_plus_plus;
   case eLanguageTypeC:
   case eLanguageTypeC89:
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeS

[Lldb-commits] [PATCH] D143062: [lldb] Allow evaluating expressions in C++20 mode

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, labath.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch allows users to evaluate expressions using
`expr -l c++20`. Currently DWARF keeps the CU's at
`DW_AT_language` at `DW_LANG_C_plus_plus_14` even
when compiling with `-std=c++20`. So even in "C++20
programs" expression evaluation will by default be
performed in `C++11` mode for now.

Enabling `C++14` has been previously attempted at
https://reviews.llvm.org/D80308

There are some remaining issues around evaluating C++20
expressions. Mainly, lack of support for C++20 AST nodes in
`clang::ASTImporter`. But these can be addressed in follow-up
patches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143062

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Target/Language.cpp
  lldb/test/API/lang/cpp/standards/cpp20/Makefile
  lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
  lldb/test/API/lang/cpp/standards/cpp20/main.cpp
  lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -205,7 +205,11 @@
 
   {"auto Foo[abi:abc]::operator<<>(int) &", "auto",
"Foo[abi:abc]", "operator<<>", "(int)", "&",
-   "Foo[abi:abc]::operator<<>"}};
+   "Foo[abi:abc]::operator<<>"},
+
+  {"auto A::operator<=>[abi:tag]()", "auto", "A",
+   "operator<=>[abi:tag]", "()", "",
+   "A::operator<=>[abi:tag]"}};
 
   for (const auto &test : test_cases) {
 CPlusPlusLanguage::MethodName method(ConstString(test.input));
@@ -227,7 +231,6 @@
   std::string test_cases[] = {
   "int Foo::operator[]<[10>()",
   "Foo::operator bool[10]()",
-  "auto A::operator<=>[abi:tag]()",
   "auto A::operator<<<(int)",
   "auto A::operator>>>(int)",
   "auto A::operator<<(int)",
@@ -356,10 +359,9 @@
   EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "f>", context, basename));
 
-  // We expect these cases to fail until we turn on C++2a
-  EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+  EXPECT_TRUE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "A::operator<=>", context, basename));
-  EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+  EXPECT_TRUE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "operator<=>", context, basename));
 }
 
Index: lldb/test/API/lang/cpp/standards/cpp20/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp20/main.cpp
@@ -0,0 +1,7 @@
+#include 
+
+struct Foo {
+  friend auto operator<=>(Foo const &, Foo const &) { return true; }
+};
+
+int main() { return Foo{} <=> Foo{}; }
Index: lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCPP20Standard(TestBase):
+def test_cpp20(self):
+"""
+Tests that we can evaluate an expression in C++20 mode
+"""
+self.build()
+lldbutil.run_to_source_breakpoint(self, "Foo{}", lldb.SBFileSpec("main.cpp"))
+
+self.expect("expr -l c++11 -- Foo{} <=> Foo{}", error=True, substrs=["'<=>' is a single token in C++20; add a space to avoid a change in behavior"])
+
+self.expect("expr -l c++20 -- Foo{} <=> Foo{}", substrs=["(bool) $0 = true"])
Index: lldb/test/API/lang/cpp/standards/cpp20/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp20/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20
+
+include Makefile.rules
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -268,6 +268,8 @@
   case eLanguageTypeC_plus_plus_03:
   case eLanguageTypeC_plus_plus_11:
   case eLanguageTypeC_plus_plus_14:
+  case eLanguageTypeC_plus_plus_17:
+  case eLanguageTypeC_plus_plus_20:
   case eLanguageTypeObjC_plus_plus:
 return true;
   default:
@@ -307,6 +309,8 @@
   case eLanguageTypeC_plus_plus_03:
   case eLanguageTypeC_plus_plus_11:
   case eLanguageTypeC_plus_

[Lldb-commits] [PATCH] D143061: [lldb][Language] Add more language types

2023-02-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, labath.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Adds more languages to the `language_names` list in
preparation for adding support for C++20 expression
evaluation.

The language constants were taken from the DWARFv5
constants defined in LLVM's `Dwarf.def`. Two vendor
constants overlap with the DWARFv5 constants so bump
their values. Their actual value is not important,
whereas keeping the enum values consecutive is (since
they are used for array lookups).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143061

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Target/Language.cpp


Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -194,9 +194,24 @@
 {"c++14", eLanguageTypeC_plus_plus_14},
 {"fortran03", eLanguageTypeFortran03},
 {"fortran08", eLanguageTypeFortran08},
+{"renderscript", eLanguageTypeRenderScript},
+{"bliss", eLanguageTypeBLISS},
+{"kotlin", eLanguageTypeKotlin},
+{"zig", eLanguageTypeZig},
+{"crystal", eLanguageTypeCrystal},
+{"",
+ static_cast(
+ 0x0029)}, // Not yet taken by any language in the DWARF spec
+   // and thus has no entry in LanguageType
+{"c++17", eLanguageTypeC_plus_plus_17},
+{"c++20", eLanguageTypeC_plus_plus_20},
+{"c17", eLanguageTypeC17},
+{"fortran18", eLanguageTypeFortran18},
+{"ada2005", eLanguageTypeAda2005},
+{"ada2012", eLanguageTypeAda2012},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
-{"renderscript", eLanguageTypeExtRenderScript},
+{"google_renderscript", eLanguageTypeExtRenderScript},
 // Now synonyms, in arbitrary order
 {"objc", eLanguageTypeObjC},
 {"objc++", eLanguageTypeObjC_plus_plus},
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -479,13 +479,26 @@
   eLanguageTypeC_plus_plus_14 = 0x0021, ///< ISO C++:2014.
   eLanguageTypeFortran03 = 0x0022,  ///< ISO Fortran 2003.
   eLanguageTypeFortran08 = 0x0023,  ///< ISO Fortran 2008.
+  eLanguageTypeRenderScript = 0x0024,
+  eLanguageTypeBLISS = 0x0025,
+  eLanguageTypeKotlin = 0x0026,
+  eLanguageTypeZig = 0x0027,
+  eLanguageTypeCrystal = 0x0028,
+  eLanguageTypeC_plus_plus_17 = 0x002a, ///< ISO C++:2017.
+  eLanguageTypeC_plus_plus_20 = 0x002b, ///< ISO C++:2020.
+  eLanguageTypeC17 = 0x002c,
+  eLanguageTypeFortran18 = 0x002d,
+  eLanguageTypeAda2005 = 0x002e,
+  eLanguageTypeAda2012 = 0x002f,
+
   // Vendor Extensions
   // Note: Language::GetNameForLanguageType
   // assumes these can be used as indexes into array language_names, and
   // Language::SetLanguageFromCString and Language::AsCString assume these can
   // be used as indexes into array g_languages.
-  eLanguageTypeMipsAssembler = 0x0024,   ///< Mips_Assembler.
-  eLanguageTypeExtRenderScript = 0x0025, ///< RenderScript.
+  eLanguageTypeMipsAssembler,   ///< Mips_Assembler.
+  eLanguageTypeExtRenderScript, ///< GOOGLE_RenderScript.
+
   eNumLanguageTypes
 };
 


Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -194,9 +194,24 @@
 {"c++14", eLanguageTypeC_plus_plus_14},
 {"fortran03", eLanguageTypeFortran03},
 {"fortran08", eLanguageTypeFortran08},
+{"renderscript", eLanguageTypeRenderScript},
+{"bliss", eLanguageTypeBLISS},
+{"kotlin", eLanguageTypeKotlin},
+{"zig", eLanguageTypeZig},
+{"crystal", eLanguageTypeCrystal},
+{"",
+ static_cast(
+ 0x0029)}, // Not yet taken by any language in the DWARF spec
+   // and thus has no entry in LanguageType
+{"c++17", eLanguageTypeC_plus_plus_17},
+{"c++20", eLanguageTypeC_plus_plus_20},
+{"c17", eLanguageTypeC17},
+{"fortran18", eLanguageTypeFortran18},
+{"ada2005", eLanguageTypeAda2005},
+{"ada2012", eLanguageTypeAda2012},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
-{"renderscript", eLanguageTypeExtRenderScript},
+{"google_renderscript", eLanguageTypeExtRenderScript},
 // Now synonyms, in arbitrary order
 {"objc", eLanguageTypeObjC},
 {"objc++", eLanguageTypeObjC_plus_plus},
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -479,13 +479,26 @@
   eLanguageTypeC_plus_plus_14 = 0x0021, ///< ISO C++:2014.
   eLanguageTypeFortran03 = 0x0022,  ///< ISO Fortran 2003.
 

[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-02-01 Thread Callum Macmillan via Phabricator via lldb-commits
cimacmillan marked 6 inline comments as done.
cimacmillan added inline comments.



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:2188
+
+static std::optional set_data_breakpoint(const llvm::json::Object 
*breakpoint) {
+  std::string breakpoint_id = GetString(breakpoint, "id").str();

clayborg wrote:
> This function should probably be able to return an error for each watchpoint 
> if anything fails so this can be reported back as a description or error 
> response in the "setDataBreakpoints" response? We shouldn't be printing to 
> the console for errors in the "breakpoint" object arguments or if the 
> watchpoint actually fails to resolve (was in a register). An error message 
> should be returned somehow if this is possible?
Thanks for your feedback, working through comments now. About this and 

> Is there a way to return an error for a specific data breakpoint instead of 
> us printing to the console?

We can return whether the breakpoint is verified, which displays a greyed dot 
similar to when a line breakpoint can't be set. There doesn't seem to be a way 
to display the error in VS code with the message. I think the logging would be 
useful in that case, but I can also include it in the message response in case 
this is added to VS code.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140630

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