[Lldb-commits] [PATCH] D137057: [LLDB][LoongArch] Add LoongArch ArchSpec and subtype detection

2022-10-31 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel created this revision.
seehearfeel added reviewers: SixWeining, wangleiat, xen0n, xry111, MaskRay, 
DavidSpickett.
Herald added subscribers: StephenFan, emaste.
Herald added a project: All.
seehearfeel requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Define LoongArch architecture subtypes, add the LoongArch ArchSpec bits,
and inspect the ELF header to detect the right subtype based on ELF class.

Here is a simple test:

  [loongson@linux ~]$ cat hello.c 
  #include 
  
  int main()
  {
printf("Hello, World!\n");
return 0;
  }
  [loongson@linux ~]$ clang hello.c -g -o hello

Without this patch:

  [loongson@linux ~]$ llvm-project/llvm/build/bin/lldb hello
  (lldb) target create "hello"
  error: '/home/loongson/hello' doesn't contain any 'host' platform 
architectures: unknown

With this patch:

  [loongson@linux ~]$ llvm-project/llvm/build/bin/lldb hello
  (lldb) target create "hello"
  Current executable set to '/home/loongson/hello' (loongarch64).
  (lldb) run
  Process 735167 launched: '/home/loongson/hello' (loongarch64)
  Hello, World!
  Process 735167 exited with status = 0 (0x) 
  (lldb) quit
  [loongson@linux ~]$ llvm-project/llvm/build/bin/llvm-lit 
llvm-project/lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml
  llvm-lit: /home/loongson/llvm-project/llvm/utils/lit/lit/llvm/config.py:456: 
note: using clang: /home/loongson/llvm-project/llvm/build/bin/clang
  -- Testing: 1 tests, 1 workers --
  PASS: lldb-shell :: ObjectFile/ELF/loongarch-arch.yaml (1 of 1)
  
  Testing Time: 0.09s
Passed: 1


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137057

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml

Index: lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml
@@ -0,0 +1,24 @@
+# RUN: yaml2obj --docnum=1 %s > %t32
+# RUN: yaml2obj --docnum=2 %s > %t64
+# RUN: lldb-test object-file %t32 | FileCheck --check-prefix=CHECK-LA32 %s
+# RUN: lldb-test object-file %t64 | FileCheck --check-prefix=CHECK-LA64 %s
+
+# CHECK-LA32: Architecture: loongarch32--
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_LOONGARCH
+...
+
+# CHECK-LA64: Architecture: loongarch64--
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_LOONGARCH
+...
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -220,6 +220,11 @@
 {eByteOrderLittle, 8, 2, 4, llvm::Triple::riscv64, ArchSpec::eCore_riscv64,
  "riscv64"},
 
+{eByteOrderLittle, 4, 1, 4, llvm::Triple::loongarch32,
+ ArchSpec::eCore_loongarch32, "loongarch32"},
+{eByteOrderLittle, 8, 1, 4, llvm::Triple::loongarch64,
+ ArchSpec::eCore_loongarch64, "loongarch64"},
+
 {eByteOrderLittle, 4, 4, 4, llvm::Triple::UnknownArch,
  ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
@@ -406,6 +411,12 @@
  ArchSpec::eRISCVSubType_riscv32, 0xu, 0xu}, // riscv32
 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV,
  ArchSpec::eRISCVSubType_riscv64, 0xu, 0xu}, // riscv64
+{ArchSpec::eCore_loongarch32, llvm::ELF::EM_LOONGARCH,
+ ArchSpec::eLOONGARCHSubType_loongarch32, 0xu,
+ 0xu}, // loongarch32
+{ArchSpec::eCore_loongarch64, llvm::ELF::EM_LOONGARCH,
+ ArchSpec::eLOONGARCHSubType_loongarch64, 0xu,
+ 0xu}, // loongarch64
 };
 
 static const ArchDefinition g_elf_arch_def = {
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -320,6 +320,18 @@
 return ArchSpec::eCore_ppc64_generic;
 }
 
+static uint32_t loongarchVariantFromElfFlags(const elf::ELFHeader &header) {
+  uint32_t fileclass = header.e_ident[EI_CLASS];
+  switch (fileclass) {
+  case llvm::ELF::ELFCLASS32:
+return ArchSpec::eLOONGARCHSubType_loongarch32;
+  case llvm::ELF::ELFCLASS64:
+return ArchSpec::eLOONGARCHSubType_loongarch64;
+  default:
+return ArchSpec::eLOONGARCHSubType_unknown;
+  }
+}
+
 static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
   if (header.e_machine == llvm::ELF::EM_MIPS)
 return mipsVariantFromElfFlags(header);
@@ -327,6 +339,8 @@
 return ppc64VariantFromElfFlags(header);
   else if (header.e_machine == llvm::ELF::EM_RI

[Lldb-commits] [PATCH] D136362: [LLDB][RISCV] Add RV64C instruction support for EmulateInstructionRISCV

2022-10-31 Thread Emmmer S via Phabricator via lldb-commits
Emmmer added a comment.

In D136362#3895385 , @seehearfeel 
wrote:

> ...
> This is OK used with gcc/c++ 12.
> ...
> We can see that "ninja check-lldb" failed due to OOM
> used with gcc/c++ 13.

Then I guess it is a gcc-specific bug and you could try to report this to their 
developers.

>   git clone https://github.com/llvm/llvm-project.git
>   mkdir -p llvm-project/llvm/build
>   cd llvm-project/llvm/build
>   cmake .. -G "Ninja" -DLLVM_TARGETS_TO_BUILD="X86" \
>-DLLVM_ENABLE_PROJECTS="clang;lldb" \
>-DCMAKE_BUILD_TYPE=Release \
>-DLLVM_BUILD_RUNTIME=OFF \
>-DCMAKE_C_COMPILER="/usr/local/gcc/bin/gcc" \
>-DCMAKE_CXX_COMPILER="/usr/local/gcc/bin/c++"
>   ninja
>   ninja check-lldb

We can try `arc patch --diff 137041` before `cmake` and observation if it 
failed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136362

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


[Lldb-commits] [PATCH] D136844: [libclang] Expose completion result kind in `CXCompletionResult`

2022-10-31 Thread Kadir Cetinkaya via Phabricator via lldb-commits
kadircet added inline comments.



Comment at: clang/include/clang/Sema/CodeCompleteConsumer.h:755
-  /// Describes the kind of result generated.
-  enum ResultKind {
-/// Refers to a declaration.

egorzhdan wrote:
> kadircet wrote:
> > i don't follow the reason for replacing this struct with 
> > `CXCompletionResultKind` and renaming occurrences in half of the codebase. 
> > can we keep this around, introduce the new enum type into `Index.h` and 
> > have `clang/tools/libclang/CIndexCodeCompletion.cpp` do the conversion from 
> > Sema type to Index type instead?
> > 
> > Unless I am missing some other requirement for doing so. i feel like the 
> > conceptual dependency from Sema to Index is one we should get rid of, 
> > rather than make tighter.
> This was mostly done to be consistent with the way `CXCursorKind` and 
> `CXAvailabilityKind` are declared in `Index.h` and used as fields of 
> `CodeCompletionResult`. I think updating the enum name in a few source files 
> shouldn't be a major problem, but I can avoid it if you feel strongly against 
> this approach.
I completely agree with the consistency argument, but IMO the conceptual 
dependency from clang-sema to clang-cindex is just wrong.

cindex is mostly implemented by `libclang`, which is part of clang-tools. all 
of this works today because clang-sema is only using declarations visible in 
headers and doesn't properly depend on `libclang` in the build files.

Hence I believe rather than preserving consistency here, we should be moving 
towards breaking that dependency over time. Therefore I was opposing the idea 
of introducing another type usage that'll make this dependency more strong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136844

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


[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:7612
+  ->getIntegerType()
+  ->isSpecificBuiltinType(BuiltinType::Bool)) &&
  "only boolean supported");

Can you call `TypeSystemClang::IsBooleanType` from here instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

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


[Lldb-commits] [PATCH] D137057: [LLDB][LoongArch] Add LoongArch ArchSpec and subtype detection

2022-10-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

Looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137057

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


[Lldb-commits] [PATCH] D137057: [LLDB][LoongArch] Add LoongArch ArchSpec and subtype detection

2022-10-31 Thread WÁNG Xuěruì via Phabricator via lldb-commits
xen0n added inline comments.



Comment at: lldb/include/lldb/Utility/ArchSpec.h:111
 
+  enum LOONGARCHSubType {
+eLOONGARCHSubType_unknown,

Should be `LoongArch`. It's that way everywhere else in LLVM land.



Comment at: lldb/source/Utility/ArchSpec.cpp:223
 
+{eByteOrderLittle, 4, 1, 4, llvm::Triple::loongarch32,
+ ArchSpec::eCore_loongarch32, "loongarch32"},

`min_opcode_byte_size` should be 4 too, all LoongArch insns are 32 bits long. 
Same for `loongarch64`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137057

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


[Lldb-commits] [PATCH] D137057: [LLDB][LoongArch] Add LoongArch ArchSpec and subtype detection

2022-10-31 Thread Lu Weining via Phabricator via lldb-commits
SixWeining added inline comments.



Comment at: lldb/source/Utility/ArchSpec.cpp:223
 
+{eByteOrderLittle, 4, 1, 4, llvm::Triple::loongarch32,
+ ArchSpec::eCore_loongarch32, "loongarch32"},

xen0n wrote:
> `min_opcode_byte_size` should be 4 too, all LoongArch insns are 32 bits long. 
> Same for `loongarch64`.
Right. So, the test doesn't cover this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137057

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


[Lldb-commits] [PATCH] D136934: [lldb][FormatEntity][NFC] Move function argument parsing code into separate functions

2022-10-31 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.



Comment at: lldb/source/Core/FormatEntity.cpp:1057
+  // the arguments list
+  if (generic && open_paren && generic < open_paren) {
+int generic_depth = 1;

aprantl wrote:
> Would be nice to rewrite this on top of StringRef at some point.
After we stop using this for c++, I think we should replace this code with 
something really simple (e.g., drop everything after the first `(`), and tell 
everyone to write their language plugins if they need more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136934

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


[Lldb-commits] [PATCH] D137057: [LLDB][LoongArch] Add LoongArch ArchSpec and subtype detection

2022-10-31 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel added inline comments.



Comment at: lldb/source/Utility/ArchSpec.cpp:223
 
+{eByteOrderLittle, 4, 1, 4, llvm::Triple::loongarch32,
+ ArchSpec::eCore_loongarch32, "loongarch32"},

SixWeining wrote:
> xen0n wrote:
> > `min_opcode_byte_size` should be 4 too, all LoongArch insns are 32 bits 
> > long. Same for `loongarch64`.
> Right. So, the test doesn't cover this change?
OK, thank you.

It is a bit confusing at the first glance.
Maybe "min_opcode_byte_size" should rename to "min_insn_byte_size",
and "max_opcode_byte_size" should rename to "max_insn_byte_size".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137057

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


[Lldb-commits] [PATCH] D136935: [lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType

2022-10-31 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

In D136935#3892336 , @Michael137 
wrote:

> In D136935#3892082 , @labath wrote:
>
>> The return type handling for function pointers is not correct. If it's hard 
>> to do, then maybe we could skip it (i suspect the original code didn't 
>> handle that either), but I have a feeling it might not be that hard, given 
>> that we're already able correctly extract the innermost argument types.
>
> The slightly unfortunate bit is that if we wanted to collect all but the 
> inner function name into `m_return_type` we'd have to allocate a new string 
> and do some concatenation (or create some sort of `struct ReturnType { 
> llvm::StringRef LHS, RHS }`). Not too difficult to implement AFAICT but not 
> sure we need to support this at the moment. Functions that have a function 
> return type encoded in the mangled name currently don't format correctly, so 
> not supporting it wouldn't regress that. Wdyt?

Sounds good. Ship it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136935

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


[Lldb-commits] [PATCH] D137057: [LLDB][LoongArch] Add LoongArch ArchSpec and subtype detection

2022-10-31 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel added a comment.

In D137057#3895926 , @DavidSpickett 
wrote:

> Looks good to me.

Thanks for your review.

Let me update the diff to do some small modifications.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137057

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


[Lldb-commits] [PATCH] D136934: [lldb][FormatEntity][NFC] Move function argument parsing code into separate functions

2022-10-31 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added inline comments.



Comment at: lldb/source/Core/FormatEntity.cpp:1057
+  // the arguments list
+  if (generic && open_paren && generic < open_paren) {
+int generic_depth = 1;

labath wrote:
> aprantl wrote:
> > Would be nice to rewrite this on top of StringRef at some point.
> After we stop using this for c++, I think we should replace this code with 
> something really simple (e.g., drop everything after the first `(`), and tell 
> everyone to write their language plugins if they need more.
FYI @aprantl  we have a copy of all this in the Swift fork: 
https://github.com/apple/llvm-project/blob/next/lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp#L1386

Curious whether some of that can be trimmed. Not familiar enough with Swift 
syntax to say for sure. But looks like some of it could be re-used from 
FormatEntity


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136934

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


[Lldb-commits] [PATCH] D137057: [LLDB][LoongArch] Add LoongArch ArchSpec and subtype detection

2022-10-31 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel updated this revision to Diff 471973.
seehearfeel added a comment.

(1) Rename LOONGARCHSubType to LoongArchSubType
(2) Define min_opcode_byte_size as 4 for LoongArch


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

https://reviews.llvm.org/D137057

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml

Index: lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml
@@ -0,0 +1,24 @@
+# RUN: yaml2obj --docnum=1 %s > %t32
+# RUN: yaml2obj --docnum=2 %s > %t64
+# RUN: lldb-test object-file %t32 | FileCheck --check-prefix=CHECK-LA32 %s
+# RUN: lldb-test object-file %t64 | FileCheck --check-prefix=CHECK-LA64 %s
+
+# CHECK-LA32: Architecture: loongarch32--
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_LOONGARCH
+...
+
+# CHECK-LA64: Architecture: loongarch64--
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_LOONGARCH
+...
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -220,6 +220,11 @@
 {eByteOrderLittle, 8, 2, 4, llvm::Triple::riscv64, ArchSpec::eCore_riscv64,
  "riscv64"},
 
+{eByteOrderLittle, 4, 4, 4, llvm::Triple::loongarch32,
+ ArchSpec::eCore_loongarch32, "loongarch32"},
+{eByteOrderLittle, 8, 4, 4, llvm::Triple::loongarch64,
+ ArchSpec::eCore_loongarch64, "loongarch64"},
+
 {eByteOrderLittle, 4, 4, 4, llvm::Triple::UnknownArch,
  ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
@@ -406,6 +411,12 @@
  ArchSpec::eRISCVSubType_riscv32, 0xu, 0xu}, // riscv32
 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV,
  ArchSpec::eRISCVSubType_riscv64, 0xu, 0xu}, // riscv64
+{ArchSpec::eCore_loongarch32, llvm::ELF::EM_LOONGARCH,
+ ArchSpec::eLoongArchSubType_loongarch32, 0xu,
+ 0xu}, // loongarch32
+{ArchSpec::eCore_loongarch64, llvm::ELF::EM_LOONGARCH,
+ ArchSpec::eLoongArchSubType_loongarch64, 0xu,
+ 0xu}, // loongarch64
 };
 
 static const ArchDefinition g_elf_arch_def = {
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -320,6 +320,18 @@
 return ArchSpec::eCore_ppc64_generic;
 }
 
+static uint32_t loongarchVariantFromElfFlags(const elf::ELFHeader &header) {
+  uint32_t fileclass = header.e_ident[EI_CLASS];
+  switch (fileclass) {
+  case llvm::ELF::ELFCLASS32:
+return ArchSpec::eLoongArchSubType_loongarch32;
+  case llvm::ELF::ELFCLASS64:
+return ArchSpec::eLoongArchSubType_loongarch64;
+  default:
+return ArchSpec::eLoongArchSubType_unknown;
+  }
+}
+
 static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
   if (header.e_machine == llvm::ELF::EM_MIPS)
 return mipsVariantFromElfFlags(header);
@@ -327,6 +339,8 @@
 return ppc64VariantFromElfFlags(header);
   else if (header.e_machine == llvm::ELF::EM_RISCV)
 return riscvVariantFromElfFlags(header);
+  else if (header.e_machine == llvm::ELF::EM_LOONGARCH)
+return loongarchVariantFromElfFlags(header);
 
   return LLDB_INVALID_CPUTYPE;
 }
Index: lldb/include/lldb/Utility/ArchSpec.h
===
--- lldb/include/lldb/Utility/ArchSpec.h
+++ lldb/include/lldb/Utility/ArchSpec.h
@@ -108,6 +108,12 @@
 eRISCVSubType_riscv64,
   };
 
+  enum LoongArchSubType {
+eLoongArchSubType_unknown,
+eLoongArchSubType_loongarch32,
+eLoongArchSubType_loongarch64,
+  };
+
   enum Core {
 eCore_arm_generic,
 eCore_arm_armv4,
@@ -204,6 +210,9 @@
 eCore_riscv32,
 eCore_riscv64,
 
+eCore_loongarch32,
+eCore_loongarch64,
+
 eCore_uknownMach32,
 eCore_uknownMach64,
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D136761: [lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

2022-10-31 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

This isn't your fault, but this `GetFunctionDisplayName` doesn't seems 
particularly well suited, as it forces you to reimplement a lot of the printing 
functionality for each language plugin.  I'd expect the customization point to 
be something like your helper `PrettyPrintFunctionNameWithArgs` function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136761

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


[Lldb-commits] [lldb] d0bf48c - [lldb][FormatEntity][NFC] Move function argument parsing code into separate functions

2022-10-31 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-10-31T12:25:18Z
New Revision: d0bf48c7b179027d978c479167e23825b8d0c4f6

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

LOG: [lldb][FormatEntity][NFC] Move function argument parsing code into 
separate functions

Hopefully makes the code more readable and allows
us to re-use argument pretty-printing code from
the `CPlusPlusLanguage` plugin in a follow-up commit.

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

Added: 


Modified: 
lldb/include/lldb/Core/FormatEntity.h
lldb/source/Core/FormatEntity.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index cd9019d47..a4972be514cfc 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -241,6 +241,17 @@ class FormatEntity {
  llvm::StringRef elements,
  llvm::StringRef element_format);
 
+  /// For each variable in 'args' this function writes the variable
+  /// name and it's pretty-printed value representation to 'out_stream'
+  /// in following format:
+  ///
+  /// \verbatim
+  /// name_1=repr_1, name_2=repr_2 ...
+  /// \endverbatim
+  static void PrettyPrintFunctionArguments(Stream &out_stream,
+   VariableList const &args,
+   ExecutionContextScope *exe_scope);
+
 protected:
   static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry,
   uint32_t depth);

diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 3b0b569bd51ec..c5cad95ecafe1 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1039,6 +1039,71 @@ static inline bool IsToken(const char *var_name_begin, 
const char *var) {
   return (::strncmp(var_name_begin, var, strlen(var)) == 0);
 }
 
+/// Parses the basename out of a demangled function name
+/// that may include function arguments. Supports
+/// template functions.
+///
+/// Returns pointers to the opening and closing parenthesis of
+/// `full_name`. Can return nullptr for either parenthesis if
+/// none is exists.
+static std::pair
+ParseBaseName(char const *full_name) {
+  const char *open_paren = strchr(full_name, '(');
+  const char *close_paren = nullptr;
+  const char *generic = strchr(full_name, '<');
+  // if before the arguments list begins there is a template sign
+  // then scan to the end of the generic args before you try to find
+  // the arguments list
+  if (generic && open_paren && generic < open_paren) {
+int generic_depth = 1;
+++generic;
+for (; *generic && generic_depth > 0; generic++) {
+  if (*generic == '<')
+generic_depth++;
+  if (*generic == '>')
+generic_depth--;
+}
+if (*generic)
+  open_paren = strchr(generic, '(');
+else
+  open_paren = nullptr;
+  }
+
+  if (open_paren) {
+if (IsToken(open_paren, "(anonymous namespace)")) {
+  open_paren = strchr(open_paren + strlen("(anonymous namespace)"), '(');
+  if (open_paren)
+close_paren = strchr(open_paren, ')');
+} else
+  close_paren = strchr(open_paren, ')');
+  }
+
+  return {open_paren, close_paren};
+}
+
+/// Writes out the function name in 'full_name' to 'out_stream'
+/// but replaces each argument type with the variable name
+/// and the corresponding pretty-printed value
+static void PrettyPrintFunctionNameWithArgs(Stream &out_stream,
+char const *full_name,
+ExecutionContextScope *exe_scope,
+VariableList const &args) {
+  auto [open_paren, close_paren] = ParseBaseName(full_name);
+  if (open_paren)
+out_stream.Write(full_name, open_paren - full_name + 1);
+  else {
+out_stream.PutCString(full_name);
+out_stream.PutChar('(');
+  }
+
+  FormatEntity::PrettyPrintFunctionArguments(out_stream, args, exe_scope);
+
+  if (close_paren)
+out_stream.PutCString(close_paren);
+  else
+out_stream.PutChar(')');
+}
+
 bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream 
&s,
const SymbolContext *sc,
const ExecutionContext *exe_ctx,
@@ -1645,100 +1710,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 variable_list_sp->AppendVariablesWithScope(
 eValueTypeVariableArgument, args);
   if (args.GetSize() > 0) {
-const char *open_paren = strchr(cstr, '(');
-const char *close_paren = nullptr;
-const char *generic = strchr(cstr, '<');
- 

[Lldb-commits] [PATCH] D136934: [lldb][FormatEntity][NFC] Move function argument parsing code into separate functions

2022-10-31 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0bf48c7b179: [lldb][FormatEntity][NFC] Move function 
argument parsing code into separate… (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136934

Files:
  lldb/include/lldb/Core/FormatEntity.h
  lldb/source/Core/FormatEntity.cpp

Index: lldb/source/Core/FormatEntity.cpp
===
--- lldb/source/Core/FormatEntity.cpp
+++ lldb/source/Core/FormatEntity.cpp
@@ -1039,6 +1039,71 @@
   return (::strncmp(var_name_begin, var, strlen(var)) == 0);
 }
 
+/// Parses the basename out of a demangled function name
+/// that may include function arguments. Supports
+/// template functions.
+///
+/// Returns pointers to the opening and closing parenthesis of
+/// `full_name`. Can return nullptr for either parenthesis if
+/// none is exists.
+static std::pair
+ParseBaseName(char const *full_name) {
+  const char *open_paren = strchr(full_name, '(');
+  const char *close_paren = nullptr;
+  const char *generic = strchr(full_name, '<');
+  // if before the arguments list begins there is a template sign
+  // then scan to the end of the generic args before you try to find
+  // the arguments list
+  if (generic && open_paren && generic < open_paren) {
+int generic_depth = 1;
+++generic;
+for (; *generic && generic_depth > 0; generic++) {
+  if (*generic == '<')
+generic_depth++;
+  if (*generic == '>')
+generic_depth--;
+}
+if (*generic)
+  open_paren = strchr(generic, '(');
+else
+  open_paren = nullptr;
+  }
+
+  if (open_paren) {
+if (IsToken(open_paren, "(anonymous namespace)")) {
+  open_paren = strchr(open_paren + strlen("(anonymous namespace)"), '(');
+  if (open_paren)
+close_paren = strchr(open_paren, ')');
+} else
+  close_paren = strchr(open_paren, ')');
+  }
+
+  return {open_paren, close_paren};
+}
+
+/// Writes out the function name in 'full_name' to 'out_stream'
+/// but replaces each argument type with the variable name
+/// and the corresponding pretty-printed value
+static void PrettyPrintFunctionNameWithArgs(Stream &out_stream,
+char const *full_name,
+ExecutionContextScope *exe_scope,
+VariableList const &args) {
+  auto [open_paren, close_paren] = ParseBaseName(full_name);
+  if (open_paren)
+out_stream.Write(full_name, open_paren - full_name + 1);
+  else {
+out_stream.PutCString(full_name);
+out_stream.PutChar('(');
+  }
+
+  FormatEntity::PrettyPrintFunctionArguments(out_stream, args, exe_scope);
+
+  if (close_paren)
+out_stream.PutCString(close_paren);
+  else
+out_stream.PutChar(')');
+}
+
 bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream &s,
const SymbolContext *sc,
const ExecutionContext *exe_ctx,
@@ -1645,100 +1710,7 @@
 variable_list_sp->AppendVariablesWithScope(
 eValueTypeVariableArgument, args);
   if (args.GetSize() > 0) {
-const char *open_paren = strchr(cstr, '(');
-const char *close_paren = nullptr;
-const char *generic = strchr(cstr, '<');
-// if before the arguments list begins there is a template sign
-// then scan to the end of the generic args before you try to find
-// the arguments list
-if (generic && open_paren && generic < open_paren) {
-  int generic_depth = 1;
-  ++generic;
-  for (; *generic && generic_depth > 0; generic++) {
-if (*generic == '<')
-  generic_depth++;
-if (*generic == '>')
-  generic_depth--;
-  }
-  if (*generic)
-open_paren = strchr(generic, '(');
-  else
-open_paren = nullptr;
-}
-if (open_paren) {
-  if (IsToken(open_paren, "(anonymous namespace)")) {
-open_paren =
-strchr(open_paren + strlen("(anonymous namespace)"), '(');
-if (open_paren)
-  close_paren = strchr(open_paren, ')');
-  } else
-close_paren = strchr(open_paren, ')');
-}
-
-if (open_paren)
-  s.Write(cstr, open_paren - cstr + 1);
-else {
-  s.PutCString(cstr);
-  s.PutChar('(');
-}
-const size_t num_args = args.GetSize();
-for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) {
-  std::string buffer;
-
-  VariableSP var_sp(args.GetVariableAtIndex(arg_idx));
-

[Lldb-commits] [lldb] 031096d - [lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

2022-10-31 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-10-31T12:25:19Z
New Revision: 031096d04d09ac4a93859d161fb42d1a1b308253

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

LOG: [lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

This patch implements the `GetFunctionDisplayName` API which gets
used by the frame-formatting code to decide how to print a
function name.

Currently this API trivially returns `false`, so we try to parse
the demangled function base-name by hand. We try find the closing
parenthesis by doing a forward scan through the demangled name. However,
for arguments that contain parenthesis (e.g., function pointers)
this would leave garbage in the frame function name.

By re-using the `CPlusPlusLanguage` parser for this we offload the
need to parse function names to a component that knows how to do this
already.

We leave the existing parsing code in `FormatEntity` since it's used
in cases where a language-plugin is not available (and is not
necessarily C++ specific).

**Example**

For following function:
```
int foo(std::function const& func) { return 1; }
```

Before patch:
```
frame #0: 0x0001151c a.out`foo(func= Function = bar() )> const&) at 
sample.cpp:11:49
```

After patch:
```
frame #0: 0x0001151c a.out`foo(func= Function = bar() ) at 
sample.cpp:11:49
```

**Testing**

* Added shell test

Added: 
lldb/test/Shell/Settings/Inputs/names.cpp
lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test

Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 3e94f555d3cda..752e68c73f875 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -23,11 +23,13 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/UniqueCStringMap.h"
+#include "lldb/Core/ValueObjectVariable.h"
 #include "lldb/DataFormatters/CXXFunctionPointer.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/VectorType.h"
 #include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -171,6 +173,40 @@ static bool IsTrivialBasename(const llvm::StringRef 
&basename) {
   return idx == basename.size();
 }
 
+/// Writes out the function name in 'full_name' to 'out_stream'
+/// but replaces each argument type with the variable name
+/// and the corresponding pretty-printed value
+static bool PrettyPrintFunctionNameWithArgs(Stream &out_stream,
+char const *full_name,
+ExecutionContextScope *exe_scope,
+VariableList const &args) {
+  CPlusPlusLanguage::MethodName cpp_method{ConstString(full_name)};
+
+  if (!cpp_method.IsValid())
+return false;
+
+  llvm::StringRef return_type = cpp_method.GetReturnType();
+  if (!return_type.empty()) {
+out_stream.PutCString(return_type);
+out_stream.PutChar(' ');
+  }
+
+  out_stream.PutCString(cpp_method.GetScopeQualifiedName());
+  out_stream.PutChar('(');
+
+  FormatEntity::PrettyPrintFunctionArguments(out_stream, args, exe_scope);
+
+  out_stream.PutChar(')');
+
+  llvm::StringRef qualifiers = cpp_method.GetQualifiers();
+  if (!qualifiers.empty()) {
+out_stream.PutChar(' ');
+out_stream.PutCString(qualifiers);
+  }
+
+  return true;
+}
+
 bool CPlusPlusLanguage::MethodName::TrySimplifiedParse() {
   // This method tries to parse simple method definitions which are presumably
   // most comman in user programs. Definitions that can be parsed by this
@@ -1465,3 +1501,66 @@ bool CPlusPlusLanguage::IsSourceFile(llvm::StringRef 
file_path) const {
   // that we could check for.
   return file_path.contains("/usr/include/c++/");
 }
+
+bool CPlusPlusLanguage::GetFunctionDisplayName(
+const SymbolContext *sc, const ExecutionContext *exe_ctx,
+FunctionNameRepresentation representation, Stream &s) {
+  switch (representation) {
+  case FunctionNameRepresentation::eNameWithArgs: {
+// Print the function name with arguments in it
+if (sc->function) {
+  ExecutionContextScope *exe_scope =
+  exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
+  const char *cstr = sc->function->GetName().AsCString(nullptr);
+  if (cstr) {
+const InlineFunctionInfo *inline_info = nullptr;
+VariableListSP 

[Lldb-commits] [PATCH] D136935: [lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType

2022-10-31 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG76f34ed28378: [lldb][CPlusPlus] Introduce 
CPlusPlusLanguage::MethodName::GetReturnType (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136935

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
  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
@@ -17,130 +17,136 @@
 TEST(CPlusPlusLanguage, MethodNameParsing) {
   struct TestCase {
 std::string input;
-std::string context, basename, arguments, qualifiers, scope_qualified_name;
+std::string return_type, context, basename, arguments, qualifiers,
+scope_qualified_name;
   };
 
   TestCase test_cases[] = {
-  {"main(int, char *[]) ", "", "main", "(int, char *[])", "", "main"},
-  {"foo::bar(baz) const", "foo", "bar", "(baz)", "const", "foo::bar"},
-  {"foo::~bar(baz)", "foo", "~bar", "(baz)", "", "foo::~bar"},
-  {"a::b::c::d(e,f)", "a::b::c", "d", "(e,f)", "", "a::b::c::d"},
-  {"void f(int)", "", "f", "(int)", "", "f"},
+  {"main(int, char *[]) ", "", "", "main", "(int, char *[])", "", "main"},
+  {"foo::bar(baz) const", "", "foo", "bar", "(baz)", "const", "foo::bar"},
+  {"foo::~bar(baz)", "", "foo", "~bar", "(baz)", "", "foo::~bar"},
+  {"a::b::c::d(e,f)", "", "a::b::c", "d", "(e,f)", "", "a::b::c::d"},
+  {"void f(int)", "void", "", "f", "(int)", "", "f"},
 
   // Operators
   {"std::basic_ostream >& "
-   "std::operator<< >"
-   "(std::basic_ostream >&, char const*)",
-   "std", "operator<< >",
+   "std::operator<< >(std::basic_ostream >&, char const*)",
+   "std::basic_ostream >&", "std",
+   "operator<< >",
"(std::basic_ostream >&, char const*)", "",
"std::operator<< >"},
   {"operator delete[](void*, clang::ASTContext const&, unsigned long)", "",
-   "operator delete[]", "(void*, clang::ASTContext const&, unsigned long)",
-   "", "operator delete[]"},
-  {"llvm::Optional::operator bool() const",
+   "", "operator delete[]",
+   "(void*, clang::ASTContext const&, unsigned long)", "",
+   "operator delete[]"},
+  {"llvm::Optional::operator bool() const", "",
"llvm::Optional", "operator bool", "()", "const",
"llvm::Optional::operator bool"},
-  {"(anonymous namespace)::FactManager::operator[](unsigned short)",
+  {"(anonymous namespace)::FactManager::operator[](unsigned short)", "",
"(anonymous namespace)::FactManager", "operator[]", "(unsigned short)",
"", "(anonymous namespace)::FactManager::operator[]"},
   {"const int& std::map>::operator[](short) const",
-   "std::map>", "operator[]", "(short)", "const",
-   "std::map>::operator[]"},
-  {"CompareInsn::operator()(llvm::StringRef, InsnMatchEntry const&)",
+   "const int&", "std::map>", "operator[]", "(short)",
+   "const", "std::map>::operator[]"},
+  {"CompareInsn::operator()(llvm::StringRef, InsnMatchEntry const&)", "",
"CompareInsn", "operator()", "(llvm::StringRef, InsnMatchEntry const&)",
"", "CompareInsn::operator()"},
-  {"llvm::Optional::operator*() const &",
+  {"llvm::Optional::operator*() const &", "",
"llvm::Optional", "operator*", "()", "const &",
"llvm::Optional::operator*"},
   {"auto std::__1::ranges::__begin::__fn::operator()[abi:v16](char const (&) [18ul]) const",
-   "std::__1::ranges::__begin::__fn",
+   "auto", "std::__1::ranges::__begin::__fn",
"operator()[abi:v16]", "(char const (&) [18ul])",
"const",
"std::__1::ranges::__begin::__fn::operator()[abi:v16]"},
   // Internal classes
-  {"operator<<(Cls, Cls)::Subclass::function()",
+  {"operator<<(Cls, Cls)::Subclass::function()", "",
"operator<<(Cls, Cls)::Subclass", "function", "()", "",
"operator<<(Cls, Cls)::Subclass::function"},
-  {"SAEC::checkFunction(context&) const::CallBack::CallBack(int)",
+  {"SAEC::checkFunction(context&) const::CallBack::CallBack(int)", "",
"SAEC::checkFunction(context&) const::CallBack", "CallBack", "(int)", "",
"SAEC::checkFunction(context&) const::CallBack::CallBack"},
   // Anonymous namespace
-  {"XX::(anonymous namespace)::anon_class::anon_func() const",
+  {"XX::(anonymous namespace)::anon_class::anon_func() const", "",
"XX::(anonymous namespace)::anon_class"

[Lldb-commits] [lldb] 76f34ed - [lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType

2022-10-31 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-10-31T12:25:18Z
New Revision: 76f34ed2837880c1865202f28988b01c93ac4f89

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

LOG: [lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType

This patch adds a way to extract the return type out
of the `CPlusPlusNameParser`. This will be useful
for cases where we want a function's basename *and* the
return type but not the function arguments; this is
currently not possible (the parser either gives us the
full name or just the basename). Since the parser knows
how to handle return types already we should just expose
this to users that need it.

**Testing**

* Added unit-tests

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

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index d4dfc4c0e1d2e..3e94f555d3cda 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -109,6 +109,7 @@ void CPlusPlusLanguage::MethodName::Clear() {
   m_context = llvm::StringRef();
   m_arguments = llvm::StringRef();
   m_qualifiers = llvm::StringRef();
+  m_return_type = llvm::StringRef();
   m_parsed = false;
   m_parse_error = false;
 }
@@ -206,6 +207,7 @@ bool CPlusPlusLanguage::MethodName::TrySimplifiedParse() {
   m_basename = llvm::StringRef();
   m_arguments = llvm::StringRef();
   m_qualifiers = llvm::StringRef();
+  m_return_type = llvm::StringRef();
   return false;
 }
   }
@@ -223,6 +225,7 @@ void CPlusPlusLanguage::MethodName::Parse() {
 m_context = function.value().name.context;
 m_arguments = function.value().arguments;
 m_qualifiers = function.value().qualifiers;
+m_return_type = function.value().return_type;
 m_parse_error = false;
   } else {
 m_parse_error = true;
@@ -256,6 +259,12 @@ llvm::StringRef 
CPlusPlusLanguage::MethodName::GetQualifiers() {
   return m_qualifiers;
 }
 
+llvm::StringRef CPlusPlusLanguage::MethodName::GetReturnType() {
+  if (!m_parsed)
+Parse();
+  return m_return_type;
+}
+
 std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
   if (!m_parsed)
 Parse();

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 4d4226accd02b..f9b3251374d0e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -55,7 +55,13 @@ class CPlusPlusLanguage : public Language {
 llvm::StringRef GetArguments();
 
 llvm::StringRef GetQualifiers();
-
+
+/// Returns the methods return-type.
+///
+/// Currently returns an empty llvm::StringRef
+/// if the return-type is a function pointer.
+llvm::StringRef GetReturnType();
+
 bool ContainsPath(llvm::StringRef path);
 
   private:
@@ -78,12 +84,13 @@ class CPlusPlusLanguage : public Language {
 bool TrySimplifiedParse();
 
 ConstString m_full; // Full name:
-// "lldb::SBTarget::GetBreakpointAtIndex(unsigned int)
-// const"
-llvm::StringRef m_basename;   // Basename: "GetBreakpointAtIndex"
-llvm::StringRef m_context;// Decl context: "lldb::SBTarget"
-llvm::StringRef m_arguments;  // Arguments:"(unsigned int)"
-llvm::StringRef m_qualifiers; // Qualifiers:   "const"
+// "size_t 
lldb::SBTarget::GetBreakpointAtIndex(unsigned
+// int) const"
+llvm::StringRef m_basename;// Basename: "GetBreakpointAtIndex"
+llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
+llvm::StringRef m_arguments;   // Arguments:"(unsigned int)"
+llvm::StringRef m_qualifiers;  // Qualifiers:   "const"
+llvm::StringRef m_return_type; // Return type:  "size_t"
 bool m_parsed = false;
 bool m_parse_error = false;
   };

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index 427e5190846d0..70d8652f40cff 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -105,10 +105,16 @@ clang::Token &CPlu

[Lldb-commits] [PATCH] D137000: [lldb] Make callback-based formatter matching available from the CLI.

2022-10-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Seems fine to me.




Comment at: lldb/source/Commands/Options.td:1231
 Desc<"Type names are actually regular expressions.">;
+  def type_synth_add_recognizer_function : Option<"recognizer-function", "R">,
+Desc<"Type names are actually the names of python functions that decide "

There's a little-known trick to avoid a short version of an option by using a 
non-printable character here (like `"\\x01"`, see `disassemble --force`). Given 
that we don't expect this to be widely used (and that `R` could also mean 
`Regex`), maybe this is the time to use it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137000

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


[Lldb-commits] [PATCH] D136761: [lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

2022-10-31 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added inline comments.



Comment at: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test:14
+c
+# CHECK: frame int ns::foo>(t= Function = 
(anonymous namespace)::anon_bar() )
+c

The `__1` breaks the linux build bots apparently. Will make this check a bit 
more flexible in follow-up commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136761

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


[Lldb-commits] [lldb] 6268a67 - [LLDB][AArch64] Add SME2 to disassembler test

2022-10-31 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-10-31T14:13:55Z
New Revision: 6268a6704a848ab880f1740f420e18449d9c06f2

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

LOG: [LLDB][AArch64] Add SME2 to disassembler test

+all includes it since 5d67b051e29c2bde42a5004634296b88542c096a.

Added: 


Modified: 
lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s

Removed: 




diff  --git a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s 
b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
index 07fad4d487e19..762eef4ef7792 100644
--- a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
+++ b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
@@ -49,6 +49,7 @@ fn:
   addha za0.s, p0/m, p0/m, z0.s   // SME
   fmopa za0.d, p0/m, p0/m, z0.d, z0.d // SMEF64
   addha za0.d, p0/m, p0/m, z0.d   // SMEI64
+  add {z0.h, z1.h}, {z0.h, z1.h}, z0.h // SME2
 lbl:
   bc.eq lbl   // HBC
   cpyfp [x0]!, [x1]!, x2! // MOPS
@@ -95,6 +96,7 @@ lbl:
 # CHECK: addha  za0.s, p0/m, p0/m, z0.s
 # CHECK: fmopa  za0.d, p0/m, p0/m, z0.d, z0.d
 # CHECK: addha  za0.d, p0/m, p0/m, z0.d
-# CHECK: bc.eq  0x98
+# CHECK: add{ z0.h, z1.h }, { z0.h, z1.h }, z0.h
+# CHECK: bc.eq  0x9c
 # CHECK: cpyfp  [x0]!, [x1]!, x2!
 # CHECK: mrsx0, PMCCNTR_EL0



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


[Lldb-commits] [PATCH] D136761: [lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

2022-10-31 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

Closed with commit `031096d04d09ac4a93859d161fb42d1a1b308253` (for some reason 
the Phab link wasn't in the commit message)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136761

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


[Lldb-commits] [lldb] 9dd413a - [lldb][Test] Fix TestFrameFormatNameWithArgs.test on Linux

2022-10-31 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-10-31T14:35:37Z
New Revision: 9dd413a1be61f8fd84e67d255a245260755d8230

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

LOG: [lldb][Test] Fix TestFrameFormatNameWithArgs.test on Linux

Be less strict about the `std::` namespace string. Depending
on platform it may contain an inline namespace, e.g., `__1`.

Added: 


Modified: 
lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test

Removed: 




diff  --git a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test 
b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
index 9cf3dba3d6590..ab16c656624d8 100644
--- a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -7,19 +7,19 @@ break set -n returns_func_ptr
 run
 # CHECK: frame int ns::foo(t={{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = bar() )
+# CHECK: frame int ns::foo>(t= Function = bar() )
 c
 # CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t={{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = 
(anonymous namespace)::anon_bar() )
+# CHECK: frame int ns::foo>(t= Function = 
(anonymous namespace)::anon_bar() )
 c
-# CHECK: frame int ns::foo const&) 
const noexcept>(t={{.*}})
+# CHECK: frame int ns::foo 
const&) const noexcept>(t={{.*}})
 c
 # CHECK: frame ns::returns_func_ptr((null)={{.*}})
 c
-# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = bar() ) const
+# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = bar() ) const
 c
-# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = (anonymous namespace)::anon_bar() ) const
+# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = (anonymous namespace)::anon_bar() ) const
 c
 # CHECK: frame void Foo::operator<<<1ul>(this={{.*}}, (null)=0)
 c



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


[Lldb-commits] [PATCH] D136565: [clang] Instantiate alias templates with sugar

2022-10-31 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov updated this revision to Diff 472021.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136565

Files:
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/AST/ast-dump-template-decls.cpp
  clang/test/CXX/temp/temp.deduct.guide/p3.cpp
  clang/test/Misc/diag-template-diffing.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaTemplate/make_integer_seq.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp
  
lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py

Index: lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
@@ -24,9 +24,9 @@
  result_type="std::weak_ptr",
  result_summary="3 strong=1 weak=2",
  result_children=[ValueCheck(name="__ptr_")])
-self.expect_expr("*w.lock()", result_type="int", result_value="3")
-self.expect_expr("*w.lock() = 5", result_type="int", result_value="5")
-self.expect_expr("*w.lock()", result_type="int", result_value="5")
+self.expect_expr("*w.lock()", result_type="element_type", result_value="3")
+self.expect_expr("*w.lock() = 5", result_type="element_type", result_value="5")
+self.expect_expr("*w.lock()", result_type="element_type", result_value="5")
 self.expect_expr("w.use_count()", result_type="long", result_value="1")
 self.expect("expr w.reset()")
 self.expect_expr("w.use_count()", result_type="long", result_value="0")
Index: lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
@@ -23,7 +23,7 @@
 self.expect_expr("w",
  result_type="std::weak_ptr",
  result_children=[ValueCheck(name="__ptr_")])
-self.expect_expr("*w.lock()", result_type="Foo")
+self.expect_expr("*w.lock()", result_type="element_type")
 self.expect_expr("w.lock()->a", result_type="int", result_value="3")
 self.expect_expr("w.lock()->a = 5",
  result_type="int",
Index: lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
@@ -24,9 +24,9 @@
  result_type="std::shared_ptr",
  result_summary="3 strong=1 weak=1",
  result_children=[ValueCheck(name="__ptr_")])
-self.expect_expr("*s", result_type="int", result_value="3")
-self.expect_expr("*s = 5", result_type="int", result_value="5")
-self.expect_expr("*s", result_type="int", result_value="5")
+self.expect_expr("*s", result_type="element_type", result_value="3")
+self.expect_expr("*s = 5", result_type="element_type", result_value="5")
+self.expect_expr("*s", result_type="element_type", result_value="5")
 self.expect_expr("(bool)s", result_type="bool", result_value="true")
 self.expect("expr s.reset()")
 self.expect_expr("(bool)s", result_type="bool", result_value="false")
Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -437,7 +437,7 @@
 
   template class X> struct A {
 template N> struct B; // expected-note 2{{here}}
-template struct B {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'Y' (aka 'type-parameter-0-0 *')}}
+template  struct B {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'Y' (aka 'T *')}}
   };
   A::B ax;
   A::B ay; // expected-error {{undefined}} expected-note {{instantiation of}}
Index: clang/test/SemaTemplate/make

[Lldb-commits] [PATCH] D137000: [lldb] Make callback-based formatter matching available from the CLI.

2022-10-31 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

This looks good.  The one detail that remains is error handling for the 
command.  You can't provide the --regex option and this matcher at the same 
time, and it is also an error to have both this matcher function and any 
arguments in the argument list.  We handle the former by judicious use of 
"option groups" (see the Group(N) entries in the Option.td).  The latter you 
will have to do by hand, checking that if match_type is 
eFormatterMatchCallback, then if there are any arguments, you should raise an 
error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137000

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


[Lldb-commits] [lldb] 279fe62 - [clang] Instantiate alias templates with sugar

2022-10-31 Thread Matheus Izvekov via lldb-commits

Author: Matheus Izvekov
Date: 2022-10-31T17:57:19+01:00
New Revision: 279fe6281d2ca5b2318c7437316c28750feaac8d

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

LOG: [clang] Instantiate alias templates with sugar

This makes use of the changes introduced in D134604, in order to
instantiate alias templates witn a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be
able to resugar them later anyway.

Signed-off-by: Matheus Izvekov 

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/AST/ast-dump-template-decls.cpp
clang/test/CXX/temp/temp.deduct.guide/p3.cpp
clang/test/Misc/diag-template-diffing.cpp
clang/test/SemaCXX/sizeless-1.cpp
clang/test/SemaTemplate/make_integer_seq.cpp
clang/test/SemaTemplate/temp_arg_nontype.cpp

lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py

lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py

lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 9f64defaf898f..8bca0dc974539 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1067,7 +1067,7 @@ class Foo final {})cpp";
  HI.LocalScope = "";
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "template  using AA = A";
- HI.Type = {"A", "type-parameter-0-0"}; // FIXME: should be 'T'
+ HI.Type = {"A", "T"};
  HI.TemplateParameters = {{{"typename"}, std::string("T"), 
llvm::None}};
}},
   {// Constant array

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index b04458687ac02..4a7a420759e9a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3854,8 +3854,8 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
 
 // Only substitute for the innermost template argument list.
 MultiLevelTemplateArgumentList TemplateArgLists;
-TemplateArgLists.addOuterTemplateArguments(Template, CanonicalConverted,
-   /*Final=*/false);
+TemplateArgLists.addOuterTemplateArguments(Template, SugaredConverted,
+   /*Final=*/true);
 TemplateArgLists.addOuterRetainedLevels(
 AliasTemplate->getTemplateParameters()->getDepth());
 

diff  --git a/clang/test/AST/ast-dump-template-decls.cpp 
b/clang/test/AST/ast-dump-template-decls.cpp
index 49760d17c7f22..3bc0357d1b51f 100644
--- a/clang/test/AST/ast-dump-template-decls.cpp
+++ b/clang/test/AST/ast-dump-template-decls.cpp
@@ -120,8 +120,6 @@ using type2 = typename C::type1;
 // CHECK-NEXT: TemplateArgument type 'void'
 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'void'
 // CHECK-NEXT: FunctionProtoType 0x{{[^ ]*}} 'void (int)' cdecl
-// CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'void' sugar class depth 
0 index 0 U
-// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'type1'
 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'void'
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar class depth 0 
index 0 T
 // CHECK-NEXT: ClassTemplateSpecialization 0x{{[^ ]*}} 'C'
@@ -129,38 +127,24 @@ using type2 = typename C::type1;
 } // namespace PR55886
 
 namespace PR56099 {
-template  struct Y;
-template  using Z = Y;
-template  struct foo {
-  template  using bind = Z;
-};
-using t1 = foo::bind;
-// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar typename 
depth 0 index 0 ... Bs pack_index 3
-// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar typename 
depth 0 index 0 ... Bs pack_index 2
-// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar typename 
depth 0 index 0 ... Bs pack_index 1
-// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar typename 
depth 0 index 0 ... Bs pack_index 0
-// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
-
 template  struct D {
-  template  using B = int(int (*...p)(T, U));
+  template  struct bind {
+using bound_type = int(int (*...p)(T, U));
+  };
 };
-using t2 = D::B;
-// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar 
alias B
+templ

[Lldb-commits] [PATCH] D136565: [clang] Instantiate alias templates with sugar

2022-10-31 Thread Matheus Izvekov via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG279fe6281d2c: [clang] Instantiate alias templates with sugar 
(authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136565

Files:
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/AST/ast-dump-template-decls.cpp
  clang/test/CXX/temp/temp.deduct.guide/p3.cpp
  clang/test/Misc/diag-template-diffing.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaTemplate/make_integer_seq.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp
  
lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py

Index: lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
@@ -24,9 +24,9 @@
  result_type="std::weak_ptr",
  result_summary="3 strong=1 weak=2",
  result_children=[ValueCheck(name="__ptr_")])
-self.expect_expr("*w.lock()", result_type="int", result_value="3")
-self.expect_expr("*w.lock() = 5", result_type="int", result_value="5")
-self.expect_expr("*w.lock()", result_type="int", result_value="5")
+self.expect_expr("*w.lock()", result_type="element_type", result_value="3")
+self.expect_expr("*w.lock() = 5", result_type="element_type", result_value="5")
+self.expect_expr("*w.lock()", result_type="element_type", result_value="5")
 self.expect_expr("w.use_count()", result_type="long", result_value="1")
 self.expect("expr w.reset()")
 self.expect_expr("w.use_count()", result_type="long", result_value="0")
Index: lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
@@ -23,7 +23,7 @@
 self.expect_expr("w",
  result_type="std::weak_ptr",
  result_children=[ValueCheck(name="__ptr_")])
-self.expect_expr("*w.lock()", result_type="Foo")
+self.expect_expr("*w.lock()", result_type="element_type")
 self.expect_expr("w.lock()->a", result_type="int", result_value="3")
 self.expect_expr("w.lock()->a = 5",
  result_type="int",
Index: lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
@@ -24,9 +24,9 @@
  result_type="std::shared_ptr",
  result_summary="3 strong=1 weak=1",
  result_children=[ValueCheck(name="__ptr_")])
-self.expect_expr("*s", result_type="int", result_value="3")
-self.expect_expr("*s = 5", result_type="int", result_value="5")
-self.expect_expr("*s", result_type="int", result_value="5")
+self.expect_expr("*s", result_type="element_type", result_value="3")
+self.expect_expr("*s = 5", result_type="element_type", result_value="5")
+self.expect_expr("*s", result_type="element_type", result_value="5")
 self.expect_expr("(bool)s", result_type="bool", result_value="true")
 self.expect("expr s.reset()")
 self.expect_expr("(bool)s", result_type="bool", result_value="false")
Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -437,7 +437,7 @@
 
   template class X> struct A {
 template N> struct B; // expected-note 2{{here}}
-template struct B {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'Y' (aka 'type-parameter-0-0 *')}}
+template  struct B {}; // expected-error {{non-type template argument specializes a t

[Lldb-commits] [PATCH] D136958: [lldb] Document QSetDetachOnError packet

2022-10-31 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.

LGTM.  Not really the place for it, but the idea is:  if lldb launched a 
process, when lldb quits, the inferior process should be killed.  But if lldb 
attached to a running process, when lldb quits, the inferior process should be 
detached from & left running.  debugserver often can't tell the difference 
between these (when you run a process on a local system, lldb actually does the 
posix_spawn and then tells debugserver to attach to it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136958

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


[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 472053.
aeubanks added a comment.
Herald added a reviewer: shafik.

undo a lot of code added in D135169 . it 
seems a little overengineered when we can just check if the type is bool when 
setting the initializer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -154,12 +154,6 @@
   return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
 }
 
-bool CompilerType::IsBooleanType() const {
-  if (IsValid())
-return m_type_system->IsBooleanType(m_type);
-  return false;
-}
-
 bool CompilerType::IsPointerType(CompilerType *pointee_type) const {
   if (IsValid()) {
 return m_type_system->IsPointerType(m_type, pointee_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -592,8 +592,6 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool &is_signed) override;
 
-  bool IsBooleanType(lldb::opaque_compiler_type_t type) override;
-
   bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
 
   static bool IsObjCClassType(const CompilerType &type);
@@ -863,8 +861,6 @@
   static void SetIntegerInitializerForVariable(clang::VarDecl *var,
const llvm::APInt &init_value);
 
-  static void SetBoolInitializerForVariable(clang::VarDecl *var, bool value);
-
   /// Initializes a variable with a floating point value.
   /// \param var The variable to initialize. Must not already have an
   ///initializer and must have a floating point type.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3226,20 +3226,6 @@
   return false;
 }
 
-bool TypeSystemClang::IsBooleanType(lldb::opaque_compiler_type_t type) {
-  if (!type)
-return false;
-
-  clang::QualType qual_type(GetCanonicalQualType(type));
-  const clang::BuiltinType *builtin_type =
-  llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
-
-  if (!builtin_type)
-return false;
-
-  return builtin_type->isBooleanType();
-}
-
 bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 bool &is_signed) {
   if (type) {
@@ -7593,18 +7579,6 @@
   return var_decl;
 }
 
-void TypeSystemClang::SetBoolInitializerForVariabl

[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:7612
+  ->getIntegerType()
+  ->isSpecificBuiltinType(BuiltinType::Bool)) &&
  "only boolean supported");

DavidSpickett wrote:
> Can you call `TypeSystemClang::IsBooleanType` from here instead?
better?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

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


[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 472061.
aeubanks added a comment.

capitalize comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137045

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -154,12 +154,6 @@
   return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
 }
 
-bool CompilerType::IsBooleanType() const {
-  if (IsValid())
-return m_type_system->IsBooleanType(m_type);
-  return false;
-}
-
 bool CompilerType::IsPointerType(CompilerType *pointee_type) const {
   if (IsValid()) {
 return m_type_system->IsPointerType(m_type, pointee_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -592,8 +592,6 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool &is_signed) override;
 
-  bool IsBooleanType(lldb::opaque_compiler_type_t type) override;
-
   bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
 
   static bool IsObjCClassType(const CompilerType &type);
@@ -863,8 +861,6 @@
   static void SetIntegerInitializerForVariable(clang::VarDecl *var,
const llvm::APInt &init_value);
 
-  static void SetBoolInitializerForVariable(clang::VarDecl *var, bool value);
-
   /// Initializes a variable with a floating point value.
   /// \param var The variable to initialize. Must not already have an
   ///initializer and must have a floating point type.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3226,20 +3226,6 @@
   return false;
 }
 
-bool TypeSystemClang::IsBooleanType(lldb::opaque_compiler_type_t type) {
-  if (!type)
-return false;
-
-  clang::QualType qual_type(GetCanonicalQualType(type));
-  const clang::BuiltinType *builtin_type =
-  llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
-
-  if (!builtin_type)
-return false;
-
-  return builtin_type->isBooleanType();
-}
-
 bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 bool &is_signed) {
   if (type) {
@@ -7593,18 +7579,6 @@
   return var_decl;
 }
 
-void TypeSystemClang::SetBoolInitializerForVariable(VarDecl *var, bool value) {
-  assert(!var->hasInit() && "variable already initialized");
-
-  QualType qt = var->getType();
-  assert(qt->isSpecificBuiltinType(BuiltinType::Bool) &&
-

[Lldb-commits] [PATCH] D136761: [lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

2022-10-31 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

Looks like in addition to the Linux failure, this also broke the Windows LLDB 
bot: https://lab.llvm.org/buildbot/#/builders/83/builds/25424/steps/7/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136761

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


[Lldb-commits] [PATCH] D136844: [libclang] Expose completion result kind in `CXCompletionResult`

2022-10-31 Thread Egor Zhdan via Phabricator via lldb-commits
egorzhdan added inline comments.



Comment at: clang/include/clang/Sema/CodeCompleteConsumer.h:755
-  /// Describes the kind of result generated.
-  enum ResultKind {
-/// Refers to a declaration.

kadircet wrote:
> egorzhdan wrote:
> > kadircet wrote:
> > > i don't follow the reason for replacing this struct with 
> > > `CXCompletionResultKind` and renaming occurrences in half of the 
> > > codebase. can we keep this around, introduce the new enum type into 
> > > `Index.h` and have `clang/tools/libclang/CIndexCodeCompletion.cpp` do the 
> > > conversion from Sema type to Index type instead?
> > > 
> > > Unless I am missing some other requirement for doing so. i feel like the 
> > > conceptual dependency from Sema to Index is one we should get rid of, 
> > > rather than make tighter.
> > This was mostly done to be consistent with the way `CXCursorKind` and 
> > `CXAvailabilityKind` are declared in `Index.h` and used as fields of 
> > `CodeCompletionResult`. I think updating the enum name in a few source 
> > files shouldn't be a major problem, but I can avoid it if you feel strongly 
> > against this approach.
> I completely agree with the consistency argument, but IMO the conceptual 
> dependency from clang-sema to clang-cindex is just wrong.
> 
> cindex is mostly implemented by `libclang`, which is part of clang-tools. all 
> of this works today because clang-sema is only using declarations visible in 
> headers and doesn't properly depend on `libclang` in the build files.
> 
> Hence I believe rather than preserving consistency here, we should be moving 
> towards breaking that dependency over time. Therefore I was opposing the idea 
> of introducing another type usage that'll make this dependency more strong.
>  all of this works today because clang-sema is only using declarations 
> visible in headers and doesn't properly depend on libclang in the build files.

Oh I see, this is a great point, I didn't realize that. I'll update the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136844

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This makes setting breakpoints work with -gsimple-template-names.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137098

Files:
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py


Index: 
lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
===
--- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto 
ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto 
ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto 
ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto 
ns::Foo::func>()']},
 
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -464,6 +464,17 @@
 if (!m_set.function_methods.Find(
 name, DIERefCallback(callback, name.GetStringRef(
   return;
+// With -gsimple-template-names, the die name may not contain template
+// parameters. Try stripping the template parameters and try again.
+const llvm::StringRef name_ref = name.AsCString();
+auto it = name_ref.find('<');
+if (it != llvm::StringRef::npos) {
+  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
+  if (!m_set.function_methods.Find(
+  ConstString(name_no_template_params),
+  DIERefCallback(callback, name_no_template_params)))
+return;
+}
   }
 
   if (name_type_mask & eFunctionNameTypeSelector &&


Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
===
--- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto ns::Foo::func>()']},
 
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -464,6 +464,17 @@
 if (!m_set.function_methods.Find(
 name, DIERefCallback(callback, name.GetStringRef(
   return;
+// With -gsimple-template-names, the die name may not contain templat

[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-10-31 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks added a comment.
Herald added a subscriber: JDevlieghere.

(I don't understand why this works yet, it should be giving us false positives?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

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


[Lldb-commits] [PATCH] D137000: [lldb] Make callback-based formatter matching available from the CLI.

2022-10-31 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added a comment.

> You can't provide the --regex option and this matcher at the same time

Thanks for spotting this. I'll get to it.

> it is also an error to have both this matcher function and any arguments in 
> the argument list

Not with the code as it is. I've made the new flag have similar semantics to 
`--regex`. If I'm not mistaken, with `--regex`, all the arguments in the 
argument list are treated as regular expressions instead of type names, and 
with `--recognizer-function` all the arguments in the argument list will be 
treated as recognizer functions instead.

Would you prefer having the `--recognizer-function` flag take an argument 
instead and error out if the argument list is not empty? On one hand I can see 
the argument for that being somewhat more intuitive. On the other hand, making 
the new flag be "special" (in the sense that it doesn't behave like `--regex`) 
makes the command set a little less consistent which IMO is less intuitive. I'm 
happy to go either way if you have a strong opinion about the way it should 
work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137000

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

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

updated description with why this doesn't produce false positives with 
breakpoints

this doesn't support regex function name lookup, not sure if we care enough 
about the interaction between regexes/function names under simple template 
names. if we do, we could instead add template parameters to the names we put 
in the manual index. I did take a quick look at doing that but it'd require 
more work


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names in the manual index

2022-10-31 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In D137098#3897289 , @aeubanks wrote:

> updated description with why this doesn't produce false positives with 
> breakpoints
>
> this doesn't support regex function name lookup, not sure if we care enough 
> about the interaction between regexes/function names under simple template 
> names. if we do, we could instead add template parameters to the names we put 
> in the manual index. I did take a quick look at doing that but it'd require 
> more work

Presumably that'd then lead to divergence between manual and automatic index - 
which would be bad. So if this behavior is the same between automatic and 
manual index with simplified template names, that's probably good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137098

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


[Lldb-commits] [lldb] 84ea6b6 - [lldb] Add diagnostics

2022-10-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-10-31T14:40:38-07:00
New Revision: 84ea6b6f78df789db6724ef8d774cf04d94d2313

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

LOG: [lldb] Add diagnostics

Around this time last year, I said on the mailing list [1] that I wanted
to to transform the reproducers into something that resembles a
sysdiagnose on Apple platforms: a collection of files containing a
variety of information to help diagnose bugs or troubleshoot issues.

This patch adds that framework. Based on lessons learned from the
reproducers, I've intentionally tried to keep it small and simple.
Different parts of LLDB can register callbacks (this is necessary for
layering purposes) that will get called when the diagnostics should be
generated.

[1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html

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

Added: 
lldb/include/lldb/Utility/Diagnostics.h
lldb/source/Utility/Diagnostics.cpp

Modified: 
lldb/include/lldb/API/SBDebugger.h
lldb/source/API/SBDebugger.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Initialization/SystemInitializerCommon.cpp
lldb/source/Utility/CMakeLists.txt
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index d3de61caeb811..950e8e29ef79c 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -94,6 +94,8 @@ class LLDB_API SBDebugger {
 
   static void PrintStackTraceOnError();
 
+  static void PrintDiagnosticsOnError();
+
   static void Terminate();
 
   // Deprecated, use the one that takes a source_init_files bool.

diff  --git a/lldb/include/lldb/Utility/Diagnostics.h 
b/lldb/include/lldb/Utility/Diagnostics.h
new file mode 100644
index 0..4a748bd73fd50
--- /dev/null
+++ b/lldb/include/lldb/Utility/Diagnostics.h
@@ -0,0 +1,56 @@
+//===-- Diagnostics.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_UTILITY_DIAGNOSTICS_H
+#define LLDB_UTILITY_DIAGNOSTICS_H
+
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/Error.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_private {
+
+/// Diagnostics are a collection of files to help investigate bugs and
+/// troubleshoot issues. Any part of the debugger can register itself with the
+/// help of a callback to emit one or more files into the diagnostic directory.
+class Diagnostics {
+public:
+  Diagnostics();
+  ~Diagnostics();
+
+  /// Gather diagnostics in the given directory.
+  llvm::Error Create(const FileSpec &dir);
+
+  /// Gather diagnostics and print a message to the given output stream.
+  bool Dump(llvm::raw_ostream &stream);
+
+  using Callback = std::function;
+
+  void AddCallback(Callback callback);
+
+  static Diagnostics &Instance();
+  static void Initialize();
+  static void Terminate();
+
+private:
+  static llvm::Optional &InstanceImpl();
+
+  llvm::SmallVector m_callbacks;
+  std::mutex m_callbacks_mutex;
+};
+
+} // namespace lldb_private
+
+#endif

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index c35c60476ffbd..ae66ff951b34a 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -51,6 +51,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/TargetList.h"
 #include "lldb/Utility/Args.h"
+#include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Version/Version.h"
 
@@ -218,6 +219,16 @@ void SBDebugger::PrintStackTraceOnError() {
   llvm::sys::PrintStackTraceOnErrorSignal(executable);
 }
 
+static void DumpDiagnostics(void *cookie) {
+  Diagnostics::Instance().Dump(llvm::errs());
+}
+
+void SBDebugger::PrintDiagnosticsOnError() {
+  LLDB_INSTRUMENT();
+
+  llvm::sys::AddSignalHandler(&DumpDiagnostics, nullptr);
+}
+
 void SBDebugger::Terminate() {
   LLDB_INSTRUMENT();
 

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index e12979234bb96..a4c453c6f422c 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -44,6 +44,7 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadList.h"
 #include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utilit

[Lldb-commits] [lldb] 0d01300 - [lldb] Add a "diagnostics dump" command

2022-10-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-10-31T14:40:41-07:00
New Revision: 0d01300aacf6029b6d63f7dcede3ca8e15229d34

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

LOG: [lldb] Add a "diagnostics dump" command

Add a "diagnostics dump" command to, as the name implies, dump the
diagnostics to disk. The goal of this command is to let the user
generate the diagnostics in case of an issue that doesn't cause the
debugger to crash.

This command is also critical for testing, where we don't want to cause
a crash to emit the diagnostics.

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

Added: 
lldb/source/Commands/CommandObjectDiagnostics.cpp
lldb/source/Commands/CommandObjectDiagnostics.h
lldb/test/Shell/Diagnostics/TestDump.test

Modified: 
lldb/include/lldb/Utility/Diagnostics.h
lldb/source/Commands/CMakeLists.txt
lldb/source/Commands/Options.td
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Utility/Diagnostics.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Diagnostics.h 
b/lldb/include/lldb/Utility/Diagnostics.h
index 4a748bd73fd50..86c97c7ff074d 100644
--- a/lldb/include/lldb/Utility/Diagnostics.h
+++ b/lldb/include/lldb/Utility/Diagnostics.h
@@ -34,7 +34,10 @@ class Diagnostics {
   llvm::Error Create(const FileSpec &dir);
 
   /// Gather diagnostics and print a message to the given output stream.
+  /// @{
   bool Dump(llvm::raw_ostream &stream);
+  bool Dump(llvm::raw_ostream &stream, const FileSpec &dir);
+  /// @}
 
   using Callback = std::function;
 
@@ -44,6 +47,9 @@ class Diagnostics {
   static void Initialize();
   static void Terminate();
 
+  /// Create a unique diagnostic directory.
+  static llvm::Expected CreateUniqueDirectory();
+
 private:
   static llvm::Optional &InstanceImpl();
 

diff  --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index a7d64a3de374a..0b705ade5ea87 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -8,6 +8,7 @@ add_lldb_library(lldbCommands
   CommandObjectBreakpoint.cpp
   CommandObjectBreakpointCommand.cpp
   CommandObjectCommands.cpp
+  CommandObjectDiagnostics.cpp
   CommandObjectDisassemble.cpp
   CommandObjectExpression.cpp
   CommandObjectFrame.cpp

diff  --git a/lldb/source/Commands/CommandObjectDiagnostics.cpp 
b/lldb/source/Commands/CommandObjectDiagnostics.cpp
new file mode 100644
index 0..12d491529ebaf
--- /dev/null
+++ b/lldb/source/Commands/CommandObjectDiagnostics.cpp
@@ -0,0 +1,114 @@
+//===-- CommandObjectDiagnostics.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 "CommandObjectDiagnostics.h"
+#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionArgumentTable.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Interpreter/OptionValueEnumeration.h"
+#include "lldb/Interpreter/OptionValueUInt64.h"
+#include "lldb/Interpreter/Options.h"
+#include "lldb/Utility/Diagnostics.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+#define LLDB_OPTIONS_diagnostics_dump
+#include "CommandOptions.inc"
+
+class CommandObjectDiagnosticsDump : public CommandObjectParsed {
+public:
+  // Constructors and Destructors
+  CommandObjectDiagnosticsDump(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "diagnostics dump",
+"Dump diagnostics to disk", nullptr) {}
+
+  ~CommandObjectDiagnosticsDump() override = default;
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() = default;
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  Status error;
+  const int short_option = m_getopt_table[option_idx].val;
+
+  switch (short_option) {
+  case 'd':
+directory.SetDirectory(option_arg);
+break;
+  default:
+llvm_unreachable("Unimplemented option");
+  }
+  return error;
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  directory.Clear();
+}
+
+llvm::ArrayRef GetDefinitions() override {
+  return llvm::makeArrayRef(g_diagnostics_dump_options);
+}
+
+FileSpec directory;
+  };
+
+  Options *GetOptions() override { return &m_options; }
+
+protected:
+  llvm::Expected GetDirect

[Lldb-commits] [lldb] 8aed0ce - [lldb] Emit diagnostic events in the diagnostic dump

2022-10-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-10-31T14:40:41-07:00
New Revision: 8aed0ce20fc6be41a7e49ea1433095d4cf583e56

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

LOG: [lldb] Emit diagnostic events in the diagnostic dump

Connect the diagnostic events with the diagnostic infrastructure.

 - Emit existing diagnostic events (warnings and errors) to the
   diagnostic log.
 - Introduce a new diagnostic event (info) that's used exclusively for
   diagnostic logging and does not get broadcast.

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

Added: 
lldb/test/Shell/Diagnostics/TestDiagnosticsLog.test

Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/include/lldb/Core/DebuggerEvents.h
lldb/include/lldb/Utility/Diagnostics.h
lldb/source/Core/Debugger.cpp
lldb/source/Core/DebuggerEvents.cpp
lldb/source/Utility/Diagnostics.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 394dac3662345..041d1fd864733 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -425,6 +425,26 @@ class Debugger : public 
std::enable_shared_from_this,
   llvm::Optional debugger_id = llvm::None,
   std::once_flag *once = nullptr);
 
+  /// Report info events.
+  ///
+  /// Unlike warning and error events, info events are not broadcast but are
+  /// logged for diagnostic purposes.
+  ///
+  /// \param[in] message
+  ///   The info message to be reported.
+  ///
+  /// \param [in] debugger_id
+  ///   If this optional parameter has a value, it indicates this diagnostic is
+  ///   associated with a unique debugger instance.
+  ///
+  /// \param [in] once
+  ///   If a pointer is passed to a std::once_flag, then it will be used to
+  ///   ensure the given info is only logged once.
+  static void
+  ReportInfo(std::string message,
+ llvm::Optional debugger_id = llvm::None,
+ std::once_flag *once = nullptr);
+
   static void ReportSymbolChange(const ModuleSpec &module_spec);
 
 protected:

diff  --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index e1203dcf38c8c..f2e23a94e610f 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -52,6 +52,7 @@ class ProgressEventData : public EventData {
 class DiagnosticEventData : public EventData {
 public:
   enum class Type {
+Info,
 Warning,
 Error,
   };

diff  --git a/lldb/include/lldb/Utility/Diagnostics.h 
b/lldb/include/lldb/Utility/Diagnostics.h
index 86c97c7ff074d..d4041d5ea8bcb 100644
--- a/lldb/include/lldb/Utility/Diagnostics.h
+++ b/lldb/include/lldb/Utility/Diagnostics.h
@@ -39,11 +39,15 @@ class Diagnostics {
   bool Dump(llvm::raw_ostream &stream, const FileSpec &dir);
   /// @}
 
+  void Report(llvm::StringRef message);
+
   using Callback = std::function;
 
   void AddCallback(Callback callback);
 
   static Diagnostics &Instance();
+
+  static bool Enabled();
   static void Initialize();
   static void Terminate();
 
@@ -53,6 +57,10 @@ class Diagnostics {
 private:
   static llvm::Optional &InstanceImpl();
 
+  llvm::Error DumpDiangosticsLog(const FileSpec &dir) const;
+
+  RotatingLogHandler m_log_handler;
+
   llvm::SmallVector m_callbacks;
   std::mutex m_callbacks_mutex;
 };

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index a4c453c6f422c..77d943787df9c 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1311,6 +1311,9 @@ static void PrivateReportDiagnostic(Debugger &debugger,
 bool debugger_specific) {
   uint32_t event_type = 0;
   switch (type) {
+  case DiagnosticEventData::Type::Info:
+assert(false && "DiagnosticEventData::Type::Info should not be broadcast");
+return;
   case DiagnosticEventData::Type::Warning:
 event_type = Debugger::eBroadcastBitWarning;
 break;
@@ -1339,6 +1342,15 @@ void 
Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type,
 llvm::Optional 
debugger_id,
 std::once_flag *once) {
   auto ReportDiagnosticLambda = [&]() {
+// The diagnostic subsystem is optional but we still want to broadcast
+// events when it's disabled.
+if (Diagnostics::Enabled())
+  Diagnostics::Instance().Report(message);
+
+// We don't broadcast info events.
+if (type == DiagnosticEventData::Type::Info)
+  return;
+
 // Check if this diagnostic is for a specific debugger.
 if (debugger_id) {
   // It is debugger specific, grab it and deliver the event if the debugger
@@ -1377,6 +1389,13 @@ void Debugger::ReportError(std::string message,

[Lldb-commits] [PATCH] D134991: [lldb] Add diagnostics

2022-10-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG84ea6b6f78df: [lldb] Add diagnostics (authored by 
JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134991

Files:
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/Utility/Diagnostics.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Initialization/SystemInitializerCommon.cpp
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/Diagnostics.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -788,6 +788,10 @@
<< '\n';
 return 1;
   }
+
+  // Setup LLDB signal handlers once the debugger has been initialized.
+  SBDebugger::PrintDiagnosticsOnError();
+
   SBHostOS::ThreadCreated("");
 
   signal(SIGINT, sigint_handler);
Index: lldb/source/Utility/Diagnostics.cpp
===
--- /dev/null
+++ lldb/source/Utility/Diagnostics.cpp
@@ -0,0 +1,74 @@
+//===-- Diagnostics.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 "lldb/Utility/Diagnostics.h"
+#include "lldb/Utility/LLDBAssert.h"
+
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace lldb_private;
+using namespace lldb;
+using namespace llvm;
+
+void Diagnostics::Initialize() {
+  lldbassert(!InstanceImpl() && "Already initialized.");
+  InstanceImpl().emplace();
+}
+
+void Diagnostics::Terminate() {
+  lldbassert(InstanceImpl() && "Already terminated.");
+  InstanceImpl().reset();
+}
+
+Optional &Diagnostics::InstanceImpl() {
+  static Optional g_diagnostics;
+  return g_diagnostics;
+}
+
+Diagnostics &Diagnostics::Instance() { return *InstanceImpl(); }
+
+Diagnostics::Diagnostics() {}
+
+Diagnostics::~Diagnostics() {}
+
+void Diagnostics::AddCallback(Callback callback) {
+  std::lock_guard guard(m_callbacks_mutex);
+  m_callbacks.push_back(callback);
+}
+
+bool Diagnostics::Dump(raw_ostream &stream) {
+  SmallString<128> diagnostics_dir;
+  std::error_code ec =
+  sys::fs::createUniqueDirectory("diagnostics", diagnostics_dir);
+  if (ec) {
+stream << "unable to create diagnostic dir: "
+   << toString(errorCodeToError(ec)) << '\n';
+return false;
+  }
+
+  stream << "LLDB diagnostics written to " << diagnostics_dir << "\n";
+  stream << "Please include the directory content when filing a bug report\n";
+
+  Error error = Create(FileSpec(diagnostics_dir.str()));
+  if (error) {
+stream << toString(std::move(error)) << '\n';
+return false;
+  }
+
+  return true;
+}
+
+Error Diagnostics::Create(const FileSpec &dir) {
+  for (Callback c : m_callbacks) {
+if (Error err = c(dir))
+  return err;
+  }
+  return Error::success();
+}
Index: lldb/source/Utility/CMakeLists.txt
===
--- lldb/source/Utility/CMakeLists.txt
+++ lldb/source/Utility/CMakeLists.txt
@@ -35,6 +35,7 @@
   DataBufferLLVM.cpp
   DataEncoder.cpp
   DataExtractor.cpp
+  Diagnostics.cpp
   Environment.cpp
   Event.cpp
   FileSpec.cpp
Index: lldb/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -12,6 +12,8 @@
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/Socket.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Timer.h"
 #include "lldb/Version/Version.h"
@@ -63,6 +65,7 @@
 
   InitializeLldbChannel();
 
+  Diagnostics::Initialize();
   FileSystem::Initialize();
   HostInfo::Initialize(m_shlib_dir_helper);
 
@@ -95,4 +98,5 @@
   HostInfo::Terminate();
   Log::DisableAllLogChannels();
   FileSystem::Terminate();
+  Diagnostics::Terminate();
 }
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -44,6 +44,7 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadList.h"
 #include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility

[Lldb-commits] [PATCH] D135622: [lldb] Add a "diagnostics dump" command

2022-10-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0d01300aacf6: [lldb] Add a "diagnostics dump" 
command (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135622

Files:
  lldb/include/lldb/Utility/Diagnostics.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectDiagnostics.cpp
  lldb/source/Commands/CommandObjectDiagnostics.h
  lldb/source/Commands/Options.td
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Utility/Diagnostics.cpp
  lldb/test/Shell/Diagnostics/TestDump.test

Index: lldb/test/Shell/Diagnostics/TestDump.test
===
--- /dev/null
+++ lldb/test/Shell/Diagnostics/TestDump.test
@@ -0,0 +1,15 @@
+# Check that the diagnostics dump command uses the correct directory and
+# creates one if needed.
+
+# Dump to an existing directory.
+# RUN: rm -rf %t.existing
+# RUN: mkdir -p %t.existing
+# RUN: %lldb -o 'diagnostics dump -d %t.existing'
+# RUN: file %t.existing | FileCheck %s
+
+# Dump to a non-existing directory.
+# RUN: rm -rf %t.nonexisting
+# RUN: %lldb -o 'diagnostics dump -d %t.nonexisting'
+# RUN: file %t.nonexisting | FileCheck %s
+
+# CHECK: : directory
Index: lldb/source/Utility/Diagnostics.cpp
===
--- lldb/source/Utility/Diagnostics.cpp
+++ lldb/source/Utility/Diagnostics.cpp
@@ -44,19 +44,21 @@
 }
 
 bool Diagnostics::Dump(raw_ostream &stream) {
-  SmallString<128> diagnostics_dir;
-  std::error_code ec =
-  sys::fs::createUniqueDirectory("diagnostics", diagnostics_dir);
-  if (ec) {
+  Expected diagnostics_dir = CreateUniqueDirectory();
+  if (!diagnostics_dir) {
 stream << "unable to create diagnostic dir: "
-   << toString(errorCodeToError(ec)) << '\n';
+   << toString(diagnostics_dir.takeError()) << '\n';
 return false;
   }
 
-  stream << "LLDB diagnostics written to " << diagnostics_dir << "\n";
+  return Dump(stream, *diagnostics_dir);
+}
+
+bool Diagnostics::Dump(raw_ostream &stream, const FileSpec &dir) {
+  stream << "LLDB diagnostics will be written to " << dir.GetPath() << "\n";
   stream << "Please include the directory content when filing a bug report\n";
 
-  Error error = Create(FileSpec(diagnostics_dir.str()));
+  Error error = Create(dir);
   if (error) {
 stream << toString(std::move(error)) << '\n';
 return false;
@@ -65,6 +67,15 @@
   return true;
 }
 
+llvm::Expected Diagnostics::CreateUniqueDirectory() {
+  SmallString<128> diagnostics_dir;
+  std::error_code ec =
+  sys::fs::createUniqueDirectory("diagnostics", diagnostics_dir);
+  if (ec)
+return errorCodeToError(ec);
+  return FileSpec(diagnostics_dir.str());
+}
+
 Error Diagnostics::Create(const FileSpec &dir) {
   for (Callback c : m_callbacks) {
 if (Error err = c(dir))
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -15,6 +15,7 @@
 #include "Commands/CommandObjectApropos.h"
 #include "Commands/CommandObjectBreakpoint.h"
 #include "Commands/CommandObjectCommands.h"
+#include "Commands/CommandObjectDiagnostics.h"
 #include "Commands/CommandObjectDisassemble.h"
 #include "Commands/CommandObjectExpression.h"
 #include "Commands/CommandObjectFrame.h"
@@ -518,6 +519,7 @@
   REGISTER_COMMAND_OBJECT("apropos", CommandObjectApropos);
   REGISTER_COMMAND_OBJECT("breakpoint", CommandObjectMultiwordBreakpoint);
   REGISTER_COMMAND_OBJECT("command", CommandObjectMultiwordCommands);
+  REGISTER_COMMAND_OBJECT("diagnostics", CommandObjectDiagnostics);
   REGISTER_COMMAND_OBJECT("disassemble", CommandObjectDisassemble);
   REGISTER_COMMAND_OBJECT("expression", CommandObjectExpression);
   REGISTER_COMMAND_OBJECT("frame", CommandObjectMultiwordFrame);
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -343,6 +343,11 @@
 Desc<"Force disassembly of large functions.">;
 }
 
+let Command = "diagnostics dump" in {
+  def diagnostics_dump_directory : Option<"directory", "d">, Group<1>,
+Arg<"Path">, Desc<"Dump the diagnostics to the given directory.">;
+}
+
 let Command = "expression" in {
   def expression_options_all_threads : Option<"all-threads", "a">,
 Groups<[1,2]>, Arg<"Boolean">, Desc<"Should we run all threads if the "
Index: lldb/source/Commands/CommandObjectDiagnostics.h
===
--- /dev/null
+++ lldb/source/Commands/CommandObjectDiagnostics.h
@@ -0,0 +1,29 @@
+//===-- CommandObjectDiagnostics.h ---

[Lldb-commits] [PATCH] D136648: [lldb] Emit diagnostic events in the diagnostic dump

2022-10-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8aed0ce20fc6: [lldb] Emit diagnostic events in the 
diagnostic dump (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D136648?vs=470319&id=472139#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136648

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/DebuggerEvents.h
  lldb/include/lldb/Utility/Diagnostics.h
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/DebuggerEvents.cpp
  lldb/source/Utility/Diagnostics.cpp
  lldb/test/Shell/Diagnostics/TestDiagnosticsLog.test

Index: lldb/test/Shell/Diagnostics/TestDiagnosticsLog.test
===
--- /dev/null
+++ lldb/test/Shell/Diagnostics/TestDiagnosticsLog.test
@@ -0,0 +1,33 @@
+# RUN: yaml2obj %s -o %t
+# RUN: mkdir -p %t.diags
+# RUN: %lldb -c %t -o 'diagnostics dump -d %t.diags' 2> %t.stderr
+
+# RUN: cat %t.stderr | FileCheck %s --check-prefix ERROR
+# RUN: cat %t.diags/diagnostics.log | FileCheck %s --check-prefix ERROR
+
+# ERROR: unable to retrieve process ID from minidump file, setting process ID to 1
+
+--- !minidump
+Streams:
+  - Type:ThreadList
+Threads:
+  - Thread Id:   0x3E81
+Context: 0B001000330006020100100010A234EBFC7F10A234EBFC7FF09C34EBFC7FC0A91ABCE97FA0163FBCE97F4602921C400030A434EBFC7FC61D40007F03801F0000FF00252525252525252525252525252525250000FF00FF00
+Stack:
+  Start of Memory Range: 0x7FFCEB34A000
+  Content: ''
+  - Type:ModuleList
+Modules:
+  - Base of Image:   0x0040
+Size of Image:   0x00017000
+Module Name: 'a.out'
+CodeView Record: ''
+  - Type:SystemInfo
+Processor Arch:  AMD64
+Platform ID: Linux
+CSD Version: 'Linux 3.13'
+CPU:
+  Vendor ID:   GenuineIntel
+  Version Info:0x
+  Feature Info:0x
+...
Index: lldb/source/Utility/Diagnostics.cpp
===
--- lldb/source/Utility/Diagnostics.cpp
+++ lldb/source/Utility/Diagnostics.cpp
@@ -17,6 +17,8 @@
 using namespace lldb;
 using namespace llvm;
 
+static constexpr size_t g_num_log_messages = 100;
+
 void Diagnostics::Initialize() {
   lldbassert(!InstanceImpl() && "Already initialized.");
   InstanceImpl().emplace();
@@ -27,6 +29,8 @@
   InstanceImpl().reset();
 }
 
+bool Diagnostics::Enabled() { retu

[Lldb-commits] [PATCH] D137000: [lldb] Make callback-based formatter matching available from the CLI.

2022-10-31 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added a comment.

I'm looking at the option of using a non-printable character for the short 
flag, and at the same time make `--regex` and `--recognizer-function` mutually 
exclusive using option groups. One problem I see is that the command help gets 
pretty confusing. Using a non-printable character as the short option name 
makes the option completely disappear from the "Command Options Usage" summary 
part of the help.

For example, for `disassemble` the `--force` option is defined with 
`Groups[2,3,4,5,7]` but there's no indication in the usage summary that 
`--force` is only usable in some of the groups:

  Command Options Usage:
disassemble [-bkmr] -s  [-A ] [-C ] 
[-e ] [-F ] [-P ]
disassemble [-bkmr] -s  [-A ] [-C ] 
[-c ] [-F ] [-P ]
disassemble [-bkmr] [-A ] [-C ] [-c ] [-F 
] [-n ] [-P ]
disassemble [-bfkmr] [-A ] [-C ] [-c ] [-F 
] [-P ]
disassemble [-bkmpr] [-A ] [-C ] [-c ] [-F 
] [-P ]
disassemble [-bklmr] [-A ] [-C ] [-F ] 
[-P ]
disassemble [-bkmr] [-a ] [-A ] [-C ] 
[-c ] [-F ] [-P ]



--

In the `type summary add` and `type synth add` class it would be even worse 
IMO, because we're now using the groups to enforce two mutually exclusive 
flags. `--regex` (`-x`) is currently accepted everywhere:

  type summary add -c [-Oprvx] [-C ] [-w ]  [ [...]]
  type summary add [-ehprvx] -s  [-C ] [-w ] [-n 
]  [ [...]]
  type summary add [-Pehprvx] [-C ] [-w ] [-n ] [-F 
] [-o ]  [ [...]]

so we need to double the number of groups. Half would have `-x` and the other 
half would have `-R`. But if we don't have a short flag, then we end up with 
something like this:

  type summary add -c [-Oprvx] [-C ] [-w ]  [ [...]]
  type summary add [-ehprvx] -s  [-C ] [-w ] [-n 
]  [ [...]]
  type summary add [-Pehprvx] [-C ] [-w ] [-n ] [-F 
] [-o ]  [ [...]]
  type summary add -c [-Oprv] [-C ] [-w ]  [ [...]]
  type summary add [-ehprv] -s  [-C ] [-w ] [-n 
]  [ [...]]
  type summary add [-Pehprv] [-C ] [-w ] [-n ] [-F 
] [-o ]  [ [...]]

... where the only visible difference between groups 1-3 and 4-6 is that they 
don't have the optional `-x`.

I think a reasonable compromise would be to remove the short `-R` flag, not use 
groups to enforce the mutual exclusion with `-x`, and have some ad-hoc error 
logic to alert the user if they specify both options at the same time. This way 
we don't have to duplicate the number of groups just for the sake of an option 
that will presumably be only very rarely used. I'll give that a try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137000

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


[Lldb-commits] [PATCH] D136844: [libclang] Expose completion result kind in `CXCompletionResult`

2022-10-31 Thread Egor Zhdan via Phabricator via lldb-commits
egorzhdan updated this revision to Diff 472171.
egorzhdan added a comment.

Preserve `CodeCompletionResult::ResultKind` and do the conversion to 
`CXCompletionResultKind` in `CIndexCodeCompletion.cpp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136844

Files:
  clang/include/clang-c/Index.h
  clang/test/Index/arc-complete.m
  clang/test/Index/code-completion.cpp
  clang/test/Index/complete-at-directives.m
  clang/test/Index/complete-at-exprstmt.m
  clang/test/Index/complete-declarators.cpp
  clang/test/Index/complete-declarators.m
  clang/test/Index/complete-exprs.c
  clang/test/Index/complete-exprs.cpp
  clang/test/Index/complete-exprs.m
  clang/test/Index/complete-lambdas.cpp
  clang/test/Index/complete-lambdas.mm
  clang/test/Index/complete-memfunc-cvquals.cpp
  clang/test/Index/complete-method-decls.m
  clang/test/Index/complete-modules.m
  clang/test/Index/complete-preprocessor.m
  clang/test/Index/complete-recovery.m
  clang/test/Index/complete-stmt.c
  clang/test/Index/complete-super.cpp
  clang/test/Index/complete-synthesized.m
  clang/test/Index/complete-type-factors.m
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/tools/libclang/libclang.map

Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -4,6 +4,11 @@
 # On platforms where versions scripts are not used, this file will be used to
 # generate a list of exports for libclang.so
 
+LLVM_15 {
+  global:
+clang_getCompletionResultKindSpelling;
+};
+
 LLVM_13 {
   global:
 clang_BlockCommandComment_getArgText;
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -586,6 +586,20 @@
   includeBriefComments());
 
 CXCompletionResult R;
+switch (Results[I].Kind) {
+case CodeCompletionResult::RK_Declaration:
+  R.ResultKind = CXCompletionResult_Declaration;
+  break;
+case CodeCompletionResult::RK_Keyword:
+  R.ResultKind = CXCompletionResult_Keyword;
+  break;
+case CodeCompletionResult::RK_Macro:
+  R.ResultKind = CXCompletionResult_Macro;
+  break;
+case CodeCompletionResult::RK_Pattern:
+  R.ResultKind = CXCompletionResult_Pattern;
+  break;
+}
 R.CursorKind = Results[I].CursorKind;
 R.CompletionString = StoredCompletion;
 StoredResults.push_back(R);
@@ -666,6 +680,7 @@
 includeBriefComments(), Braced);
 
 CXCompletionResult R;
+R.ResultKind = CXCompletionResult_Declaration;
 R.CursorKind = CXCursor_OverloadCandidate;
 R.CompletionString = StoredCompletion;
 StoredResults.push_back(R);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5390,6 +5390,22 @@
   return clang_getCursorSpelling(C);
 }
 
+CXString
+clang_getCompletionResultKindSpelling(enum CXCompletionResultKind Kind) {
+  switch (Kind) {
+  case CXCompletionResult_Declaration:
+return cxstring::createRef("Declaration");
+  case CXCompletionResult_Keyword:
+return cxstring::createRef("Keyword");
+  case CXCompletionResult_Macro:
+return cxstring::createRef("Macro");
+  case CXCompletionResult_Pattern:
+return cxstring::createRef("Pattern");
+  }
+
+  llvm_unreachable("Unhandled CXCompletionResultKind");
+}
+
 CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
   switch (Kind) {
   case CXCursor_FunctionDecl:
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -2505,7 +2505,10 @@
 unsigned index,
 FILE *file) {
   CXCompletionResult *completion_result = completion_results->Results + index;
-  CXString ks = clang_getCursorKindSpelling(completion_result->CursorKind);
+  CXString ks =
+  completion_result->CursorKind == CXCursor_NotImplemented
+  ? clang_getCompletionResultKindSpelling(completion_result->ResultKind)
+  : clang_getCursorKindSpelling(completion_result->CursorKind);
   unsigned annotationCount;
   enum CXCursorKind ParentKind;
   CXString ParentName;
Index: clang/test/Index/complete-type-factors.m
===
--- clang/test/Index/complete-type-factors.m
+++ clang/

[Lldb-commits] [PATCH] D136844: [libclang] Expose completion result kind in `CXCompletionResult`

2022-10-31 Thread Ben Barham via Phabricator via lldb-commits
bnbarham accepted this revision.
bnbarham added a comment.
This revision is now accepted and ready to land.

Thanks Egor!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136844

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


[Lldb-commits] [PATCH] D137000: [lldb] Make callback-based formatter matching available from the CLI.

2022-10-31 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe updated this revision to Diff 472185.
jgorbe added a comment.

- Removed `-R` short option to avoid confusion with regex. Updated doc, test 
case, and example.
- Added some logic to make `--recognizer-function` and `--regex` mutually 
exclusive. Specifying both now results in an error being reported to the user.
- Rebased on top of current HEAD.




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

https://reviews.llvm.org/D137000

Files:
  lldb/docs/use/variable.rst
  lldb/examples/synthetic/recognizer_function/example.py
  lldb/examples/synthetic/recognizer_function/lldb-commands
  lldb/examples/synthetic/recognizer_function/program.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Commands/Options.td
  
lldb/test/API/functionalities/data-formatter/callback-matching/TestDataFormatterCallbackMatching.py
  
lldb/test/API/functionalities/data-formatter/callback-matching/formatters_with_callback.py

Index: lldb/test/API/functionalities/data-formatter/callback-matching/formatters_with_callback.py
===
--- lldb/test/API/functionalities/data-formatter/callback-matching/formatters_with_callback.py
+++ lldb/test/API/functionalities/data-formatter/callback-matching/formatters_with_callback.py
@@ -24,7 +24,7 @@
 return None
 
 
-def __lldb_init_module(debugger, dict):
+def register_formatters(debugger):
 cat = debugger.CreateCategory("callback_formatters")
 cat.AddTypeSummary(
 lldb.SBTypeNameSpecifier("formatters_with_callback.derives_from_base",
Index: lldb/test/API/functionalities/data-formatter/callback-matching/TestDataFormatterCallbackMatching.py
===
--- lldb/test/API/functionalities/data-formatter/callback-matching/TestDataFormatterCallbackMatching.py
+++ lldb/test/API/functionalities/data-formatter/callback-matching/TestDataFormatterCallbackMatching.py
@@ -16,7 +16,7 @@
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-def test_callback_matchers(self):
+def test_callback_matchers_api_registration(self):
 """Test data formatter commands."""
 self.build()
 
@@ -31,6 +31,7 @@
 # now set up a summary function that uses a python callback to match
 # classes that derive from `Base`.
 self.runCmd("command script import --allow-reload ./formatters_with_callback.py")
+self.runCmd("script formatters_with_callback.register_formatters(lldb.debugger)")
 
 # Now `derived` should use our callback summary + synthetic children.
 self.expect("frame variable derived",
@@ -47,3 +48,40 @@
 substrs=['hello from callback summary'])
 self.expect("frame variable nd",
 substrs=['z = '])
+
+def test_callback_matchers_cli_registration(self):
+"""Test data formatter commands."""
+self.build()
+
+_, process, thread, _ = lldbutil.run_to_line_breakpoint(
+self, lldb.SBFileSpec("main.cpp"), self.line)
+
+# Print derived without a formatter.
+self.expect("frame variable derived",
+substrs=['x = ',
+ 'y = '])
+
+# now set up a summary function that uses a python callback to match
+# classes that derive from `Base`.
+self.runCmd("command script import --allow-reload ./formatters_with_callback.py")
+self.runCmd("type summary add -e -s 'hello from callback summary' "
+"--recognizer-function formatters_with_callback.derives_from_base")
+self.runCmd("type synth add -l formatters_with_callback.SynthProvider "
+"--recognizer-function formatters_with_callback.derives_from_base")
+
+# Now `derived` should use our callback summary + synthetic children.
+self.expect("frame variable derived",
+substrs=['hello from callback summary',
+ 'synthetic_child = '])
+
+# But not other classes.
+self.expect("frame variable base", matching=False,
+substrs=['hello from callback summary'])
+self.expect("frame variable base",
+substrs=['x = '])
+
+self.expect("frame variable nd", matching=False,
+substrs=['hello from callback summary'])
+self.expect("frame variable nd",
+substrs=['z = '])
+
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -1189,6 +1189,11 @@
 Desc<"Don't use this format for references-to-type objects.">;
   def type_summary_add_regex : Option<"regex", "x">,
 Desc<"Type names are actually regular expressions.">;
+  def type_summary_add_recognizer_fu

[Lldb-commits] [PATCH] D137137: [lldb/Interpreter] Open saved transcript in GUI Editor

2022-10-31 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, kastiglione.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch will automatically open LLDB's saved transcript file on the
graphical editor if lldb is running under an interactive graphical session.

rdar://92692106

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137137

Files:
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3224,6 +3224,14 @@
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
+  if (Host::IsInteractiveGraphicSession()) {
+const FileSpec file_spec;
+error = file->GetFileSpec(const_cast(file_spec));
+if (error.Success())
+  if (!Host::OpenFileInExternalEditor(file_spec, 1))
+result.AppendMessage("Unable to open file in external editor\n");
+  }
+
   return true;
 }
 


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3224,6 +3224,14 @@
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
+  if (Host::IsInteractiveGraphicSession()) {
+const FileSpec file_spec;
+error = file->GetFileSpec(const_cast(file_spec));
+if (error.Success())
+  if (!Host::OpenFileInExternalEditor(file_spec, 1))
+result.AppendMessage("Unable to open file in external editor\n");
+  }
+
   return true;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D137137: [lldb/Interpreter] Open saved transcript in GUI Editor

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

Should this be controllable with a setting? I'm not sure I (always) want my 
editor to pop up when I save a transcript.




Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:3232
+  if (!Host::OpenFileInExternalEditor(file_spec, 1))
+result.AppendMessage("Unable to open file in external editor\n");
+  }

If we want to report the error we should should use `AppendErrorMessage` and 
return false, but personally I don't think this warrants failing the command 
for and I would just fail silently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137137

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


[Lldb-commits] [PATCH] D136761: [lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

2022-10-31 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D136761#3897029 , 
@stella.stamenova wrote:

> Looks like in addition to the Linux failure, this also broke the Windows LLDB 
> bot: 
> https://lab.llvm.org/buildbot/#/builders/83/builds/25424/steps/7/logs/stdio

Thanks for letting me know. Will be able to take a look only in an hour or so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136761

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


[Lldb-commits] [PATCH] D137137: [lldb/Interpreter] Open saved transcript in GUI Editor

2022-10-31 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 472211.
mib edited the summary of this revision.
mib added a comment.

Address @JDevlieghere comments


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

https://reviews.llvm.org/D137137

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td


Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,10 @@
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"If true, LLDB will open the saved session's transcripts in the 
external editor.">;
   def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"A path where LLDB will save the session's transcripts. This is 
particularly useful when you can't set the session file, for example when using 
`save-session-on-quit`.">;
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -169,6 +169,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+bool CommandInterpreter::GetOpenTranscriptInEditor() const {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
+}
+
 FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
   const uint32_t idx = ePropertySaveSessionDirectory;
   return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
@@ -3224,6 +3235,13 @@
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
+  if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) {
+const FileSpec file_spec;
+error = file->GetFileSpec(const_cast(file_spec));
+if (error.Success())
+  Host::OpenFileInExternalEditor(file_spec, 1);
+  }
+
   return true;
 }
 
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -559,6 +559,9 @@
   bool GetSaveSessionOnQuit() const;
   void SetSaveSessionOnQuit(bool enable);
 
+  bool GetOpenTranscriptInEditor() const;
+  void SetOpenTranscriptInEditor(bool enable);
+
   FileSpec GetSaveSessionDirectory() const;
   void SetSaveSessionDirectory(llvm::StringRef path);
 


Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,10 @@
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"If true, LLDB will open the saved session's transcripts in the external editor.">;
   def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"A path where LLDB will save the session's transcripts. This is particularly useful when you can't set the session file, for example when using `save-session-on-quit`.">;
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -169,6 +169,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+bool CommandInterpreter::GetOpenTranscriptInEditor() const {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
+}
+
 FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
   const uint32_t idx = ePropertySaveSessionDirectory;
   return m_collection_sp->GetPropertyAtIndexAsFileSpec(nul

[Lldb-commits] [PATCH] D137137: [lldb/Interpreter] Open saved transcript in GUI Editor

2022-10-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM!


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

https://reviews.llvm.org/D137137

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


[Lldb-commits] [lldb] 3e03873 - [lldb][Test] Fix TestFrameFormatNameWithArgs.test on Windows/Linux

2022-10-31 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-10-31T22:59:16-07:00
New Revision: 3e03873e363b5aa90e4488da63a6de0648d11aba

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

LOG: [lldb][Test] Fix TestFrameFormatNameWithArgs.test on Windows/Linux

* Windows doesn't support setting these breakpoints by basename
* On Linux std::function arguments aren't formatted as such

Added: 


Modified: 
lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test

Removed: 




diff  --git a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test 
b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
index ab16c656624d8..d990114f57845 100644
--- a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,3 +1,4 @@
+# REQUIRES: system-darwin
 # RUN: %clangxx_host -g -O0 %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"



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